@musistudio/claude-code-router 1.0.36 → 1.0.38
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/README.md +12 -4
- package/README_zh.md +11 -4
- package/dist/cli.js +1098 -438
- package/dist/index.html +123 -54
- package/package.json +2 -2
- package/config.example.json +0 -119
package/dist/cli.js
CHANGED
|
@@ -1138,11 +1138,11 @@ var require_lib = __commonJS({
|
|
|
1138
1138
|
"node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/index.js"(exports2, module2) {
|
|
1139
1139
|
var parse = require_parse();
|
|
1140
1140
|
var stringify = require_stringify();
|
|
1141
|
-
var
|
|
1141
|
+
var JSON53 = {
|
|
1142
1142
|
parse,
|
|
1143
1143
|
stringify
|
|
1144
1144
|
};
|
|
1145
|
-
module2.exports =
|
|
1145
|
+
module2.exports = JSON53;
|
|
1146
1146
|
}
|
|
1147
1147
|
});
|
|
1148
1148
|
|
|
@@ -1202,13 +1202,68 @@ var init_logCleanup = __esm({
|
|
|
1202
1202
|
}
|
|
1203
1203
|
});
|
|
1204
1204
|
|
|
1205
|
+
// src/utils/update.ts
|
|
1206
|
+
async function checkForUpdates(currentVersion) {
|
|
1207
|
+
try {
|
|
1208
|
+
const { stdout } = await execPromise("npm view @musistudio/claude-code-router version");
|
|
1209
|
+
const latestVersion = stdout.trim();
|
|
1210
|
+
const hasUpdate = compareVersions(latestVersion, currentVersion) > 0;
|
|
1211
|
+
let changelog = "";
|
|
1212
|
+
return { hasUpdate, latestVersion, changelog };
|
|
1213
|
+
} catch (error) {
|
|
1214
|
+
console.error("Error checking for updates:", error);
|
|
1215
|
+
return { hasUpdate: false, latestVersion: currentVersion, changelog: "" };
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
async function performUpdate() {
|
|
1219
|
+
try {
|
|
1220
|
+
const { stdout, stderr } = await execPromise("npm update -g @musistudio/claude-code-router");
|
|
1221
|
+
if (stderr) {
|
|
1222
|
+
console.error("Update stderr:", stderr);
|
|
1223
|
+
}
|
|
1224
|
+
console.log("Update stdout:", stdout);
|
|
1225
|
+
return {
|
|
1226
|
+
success: true,
|
|
1227
|
+
message: "Update completed successfully. Please restart the application to apply changes."
|
|
1228
|
+
};
|
|
1229
|
+
} catch (error) {
|
|
1230
|
+
console.error("Error performing update:", error);
|
|
1231
|
+
return {
|
|
1232
|
+
success: false,
|
|
1233
|
+
message: `Failed to perform update: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
function compareVersions(v1, v2) {
|
|
1238
|
+
const parts1 = v1.split(".").map(Number);
|
|
1239
|
+
const parts2 = v2.split(".").map(Number);
|
|
1240
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
1241
|
+
const num1 = i < parts1.length ? parts1[i] : 0;
|
|
1242
|
+
const num2 = i < parts2.length ? parts2[i] : 0;
|
|
1243
|
+
if (num1 > num2) return 1;
|
|
1244
|
+
if (num1 < num2) return -1;
|
|
1245
|
+
}
|
|
1246
|
+
return 0;
|
|
1247
|
+
}
|
|
1248
|
+
var import_child_process, import_util, execPromise;
|
|
1249
|
+
var init_update = __esm({
|
|
1250
|
+
"src/utils/update.ts"() {
|
|
1251
|
+
"use strict";
|
|
1252
|
+
import_child_process = require("child_process");
|
|
1253
|
+
import_util = require("util");
|
|
1254
|
+
execPromise = (0, import_util.promisify)(import_child_process.exec);
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
|
|
1205
1258
|
// src/utils/index.ts
|
|
1206
1259
|
var utils_exports = {};
|
|
1207
1260
|
__export(utils_exports, {
|
|
1208
1261
|
backupConfigFile: () => backupConfigFile,
|
|
1262
|
+
checkForUpdates: () => checkForUpdates,
|
|
1209
1263
|
cleanupLogFiles: () => cleanupLogFiles,
|
|
1210
1264
|
initConfig: () => initConfig,
|
|
1211
1265
|
initDir: () => initDir,
|
|
1266
|
+
performUpdate: () => performUpdate,
|
|
1212
1267
|
readConfigFile: () => readConfigFile,
|
|
1213
1268
|
writeConfigFile: () => writeConfigFile
|
|
1214
1269
|
});
|
|
@@ -1222,6 +1277,7 @@ var init_utils = __esm({
|
|
|
1222
1277
|
import_node_path3 = __toESM(require("node:path"));
|
|
1223
1278
|
init_constants();
|
|
1224
1279
|
init_logCleanup();
|
|
1280
|
+
init_update();
|
|
1225
1281
|
interpolateEnvVars = (obj) => {
|
|
1226
1282
|
if (typeof obj === "string") {
|
|
1227
1283
|
return obj.replace(/\$\{([^}]+)\}|\$([A-Z_][A-Z0-9_]*)/g, (match, braced, unbraced) => {
|
|
@@ -4774,8 +4830,8 @@ var require_req = __commonJS({
|
|
|
4774
4830
|
if (req.originalUrl) {
|
|
4775
4831
|
_req.url = req.originalUrl;
|
|
4776
4832
|
} else {
|
|
4777
|
-
const
|
|
4778
|
-
_req.url = typeof
|
|
4833
|
+
const path7 = req.path;
|
|
4834
|
+
_req.url = typeof path7 === "string" ? path7 : req.url ? req.url.path || req.url : void 0;
|
|
4779
4835
|
}
|
|
4780
4836
|
if (req.query) {
|
|
4781
4837
|
_req.query = req.query;
|
|
@@ -4964,17 +5020,17 @@ var require_parse2 = __commonJS({
|
|
|
4964
5020
|
const wildcards = [];
|
|
4965
5021
|
var wcLen = 0;
|
|
4966
5022
|
const secret = paths.reduce(function(o, strPath, ix) {
|
|
4967
|
-
var
|
|
5023
|
+
var path7 = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
|
|
4968
5024
|
const leadingBracket = strPath[0] === "[";
|
|
4969
|
-
|
|
5025
|
+
path7 = path7.map((p) => {
|
|
4970
5026
|
if (p[0] === "[") return p.substr(1, p.length - 2);
|
|
4971
5027
|
else return p;
|
|
4972
5028
|
});
|
|
4973
|
-
const star =
|
|
5029
|
+
const star = path7.indexOf("*");
|
|
4974
5030
|
if (star > -1) {
|
|
4975
|
-
const before =
|
|
5031
|
+
const before = path7.slice(0, star);
|
|
4976
5032
|
const beforeStr = before.join(".");
|
|
4977
|
-
const after =
|
|
5033
|
+
const after = path7.slice(star + 1, path7.length);
|
|
4978
5034
|
const nested = after.length > 0;
|
|
4979
5035
|
wcLen++;
|
|
4980
5036
|
wildcards.push({
|
|
@@ -4985,7 +5041,7 @@ var require_parse2 = __commonJS({
|
|
|
4985
5041
|
});
|
|
4986
5042
|
} else {
|
|
4987
5043
|
o[strPath] = {
|
|
4988
|
-
path:
|
|
5044
|
+
path: path7,
|
|
4989
5045
|
val: void 0,
|
|
4990
5046
|
precensored: false,
|
|
4991
5047
|
circle: "",
|
|
@@ -5031,20 +5087,20 @@ var require_redactor = __commonJS({
|
|
|
5031
5087
|
return redact;
|
|
5032
5088
|
}
|
|
5033
5089
|
function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
|
|
5034
|
-
return Object.keys(secret).map((
|
|
5035
|
-
const { escPath, leadingBracket, path: arrPath } = secret[
|
|
5090
|
+
return Object.keys(secret).map((path7) => {
|
|
5091
|
+
const { escPath, leadingBracket, path: arrPath } = secret[path7];
|
|
5036
5092
|
const skip = leadingBracket ? 1 : 0;
|
|
5037
5093
|
const delim = leadingBracket ? "" : ".";
|
|
5038
5094
|
const hops = [];
|
|
5039
5095
|
var match;
|
|
5040
|
-
while ((match = rx.exec(
|
|
5096
|
+
while ((match = rx.exec(path7)) !== null) {
|
|
5041
5097
|
const [, ix] = match;
|
|
5042
5098
|
const { index, input } = match;
|
|
5043
5099
|
if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
|
|
5044
5100
|
}
|
|
5045
5101
|
var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
|
|
5046
|
-
if (existence.length === 0) existence += `o${delim}${
|
|
5047
|
-
else existence += ` && o${delim}${
|
|
5102
|
+
if (existence.length === 0) existence += `o${delim}${path7} != null`;
|
|
5103
|
+
else existence += ` && o${delim}${path7} != null`;
|
|
5048
5104
|
const circularDetection = `
|
|
5049
5105
|
switch (true) {
|
|
5050
5106
|
${hops.reverse().map((p) => `
|
|
@@ -5057,12 +5113,12 @@ var require_redactor = __commonJS({
|
|
|
5057
5113
|
const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
|
|
5058
5114
|
return `
|
|
5059
5115
|
if (${existence}) {
|
|
5060
|
-
const val = o${delim}${
|
|
5116
|
+
const val = o${delim}${path7}
|
|
5061
5117
|
if (val === censor) {
|
|
5062
5118
|
secret[${escPath}].precensored = true
|
|
5063
5119
|
} else {
|
|
5064
5120
|
secret[${escPath}].val = val
|
|
5065
|
-
o${delim}${
|
|
5121
|
+
o${delim}${path7} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
|
|
5066
5122
|
${circularDetection}
|
|
5067
5123
|
}
|
|
5068
5124
|
}
|
|
@@ -5114,13 +5170,13 @@ var require_modifiers = __commonJS({
|
|
|
5114
5170
|
target[k] = values[i];
|
|
5115
5171
|
}
|
|
5116
5172
|
}
|
|
5117
|
-
function groupRedact(o,
|
|
5118
|
-
const target = get(o,
|
|
5173
|
+
function groupRedact(o, path7, censor, isCensorFct, censorFctTakesPath) {
|
|
5174
|
+
const target = get(o, path7);
|
|
5119
5175
|
if (target == null || typeof target === "string") return { keys: null, values: null, target, flat: true };
|
|
5120
5176
|
const keys = Object.keys(target);
|
|
5121
5177
|
const keysLength = keys.length;
|
|
5122
|
-
const pathLength =
|
|
5123
|
-
const pathWithKey = censorFctTakesPath ? [...
|
|
5178
|
+
const pathLength = path7.length;
|
|
5179
|
+
const pathWithKey = censorFctTakesPath ? [...path7] : void 0;
|
|
5124
5180
|
const values = new Array(keysLength);
|
|
5125
5181
|
for (var i = 0; i < keysLength; i++) {
|
|
5126
5182
|
const key = keys[i];
|
|
@@ -5138,29 +5194,29 @@ var require_modifiers = __commonJS({
|
|
|
5138
5194
|
}
|
|
5139
5195
|
function nestedRestore(instructions) {
|
|
5140
5196
|
for (let i = 0; i < instructions.length; i++) {
|
|
5141
|
-
const { target, path:
|
|
5197
|
+
const { target, path: path7, value } = instructions[i];
|
|
5142
5198
|
let current = target;
|
|
5143
|
-
for (let i2 =
|
|
5144
|
-
current = current[
|
|
5199
|
+
for (let i2 = path7.length - 1; i2 > 0; i2--) {
|
|
5200
|
+
current = current[path7[i2]];
|
|
5145
5201
|
}
|
|
5146
|
-
current[
|
|
5202
|
+
current[path7[0]] = value;
|
|
5147
5203
|
}
|
|
5148
5204
|
}
|
|
5149
|
-
function nestedRedact(store, o,
|
|
5150
|
-
const target = get(o,
|
|
5205
|
+
function nestedRedact(store, o, path7, ns, censor, isCensorFct, censorFctTakesPath) {
|
|
5206
|
+
const target = get(o, path7);
|
|
5151
5207
|
if (target == null) return;
|
|
5152
5208
|
const keys = Object.keys(target);
|
|
5153
5209
|
const keysLength = keys.length;
|
|
5154
5210
|
for (var i = 0; i < keysLength; i++) {
|
|
5155
5211
|
const key = keys[i];
|
|
5156
|
-
specialSet(store, target, key,
|
|
5212
|
+
specialSet(store, target, key, path7, ns, censor, isCensorFct, censorFctTakesPath);
|
|
5157
5213
|
}
|
|
5158
5214
|
return store;
|
|
5159
5215
|
}
|
|
5160
5216
|
function has(obj, prop) {
|
|
5161
5217
|
return obj !== void 0 && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
|
|
5162
5218
|
}
|
|
5163
|
-
function specialSet(store, o, k,
|
|
5219
|
+
function specialSet(store, o, k, path7, afterPath, censor, isCensorFct, censorFctTakesPath) {
|
|
5164
5220
|
const afterPathLen = afterPath.length;
|
|
5165
5221
|
const lastPathIndex = afterPathLen - 1;
|
|
5166
5222
|
const originalKey = k;
|
|
@@ -5203,7 +5259,7 @@ var require_modifiers = __commonJS({
|
|
|
5203
5259
|
if (consecutive) {
|
|
5204
5260
|
redactPathCurrent = node(redactPathCurrent, wck, depth);
|
|
5205
5261
|
level = i;
|
|
5206
|
-
ov = iterateNthLevel(wcov, level - 1, k,
|
|
5262
|
+
ov = iterateNthLevel(wcov, level - 1, k, path7, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
|
|
5207
5263
|
} else {
|
|
5208
5264
|
if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
|
|
5209
5265
|
if (kIsWc) {
|
|
@@ -5211,7 +5267,7 @@ var require_modifiers = __commonJS({
|
|
|
5211
5267
|
} else {
|
|
5212
5268
|
ov = wcov[k];
|
|
5213
5269
|
}
|
|
5214
|
-
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...
|
|
5270
|
+
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path7, originalKey, ...afterPath]) : censor(ov) : censor;
|
|
5215
5271
|
if (kIsWc) {
|
|
5216
5272
|
const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
|
|
5217
5273
|
store.push(rv);
|
|
@@ -5234,7 +5290,7 @@ var require_modifiers = __commonJS({
|
|
|
5234
5290
|
} else {
|
|
5235
5291
|
ov = n[k];
|
|
5236
5292
|
redactPathCurrent = node(redactPathCurrent, k, depth);
|
|
5237
|
-
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...
|
|
5293
|
+
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path7, originalKey, ...afterPath]) : censor(ov) : censor;
|
|
5238
5294
|
if (has(n, k) && nv === ov || nv === void 0 && censor !== void 0) {
|
|
5239
5295
|
} else {
|
|
5240
5296
|
const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
|
|
@@ -5257,7 +5313,7 @@ var require_modifiers = __commonJS({
|
|
|
5257
5313
|
}
|
|
5258
5314
|
return n;
|
|
5259
5315
|
}
|
|
5260
|
-
function iterateNthLevel(wcov, level, k,
|
|
5316
|
+
function iterateNthLevel(wcov, level, k, path7, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
|
|
5261
5317
|
if (level === 0) {
|
|
5262
5318
|
if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
|
|
5263
5319
|
if (kIsWc) {
|
|
@@ -5265,7 +5321,7 @@ var require_modifiers = __commonJS({
|
|
|
5265
5321
|
} else {
|
|
5266
5322
|
ov = wcov[k];
|
|
5267
5323
|
}
|
|
5268
|
-
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...
|
|
5324
|
+
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path7, originalKey, ...afterPath]) : censor(ov) : censor;
|
|
5269
5325
|
if (kIsWc) {
|
|
5270
5326
|
const rv = restoreInstr(redactPathCurrent, ov, parent);
|
|
5271
5327
|
store.push(rv);
|
|
@@ -5284,7 +5340,7 @@ var require_modifiers = __commonJS({
|
|
|
5284
5340
|
for (const key in wcov) {
|
|
5285
5341
|
if (typeof wcov[key] === "object") {
|
|
5286
5342
|
redactPathCurrent = node(redactPathCurrent, key, depth);
|
|
5287
|
-
iterateNthLevel(wcov[key], level - 1, k,
|
|
5343
|
+
iterateNthLevel(wcov[key], level - 1, k, path7, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
|
|
5288
5344
|
}
|
|
5289
5345
|
}
|
|
5290
5346
|
}
|
|
@@ -5306,12 +5362,12 @@ var require_modifiers = __commonJS({
|
|
|
5306
5362
|
}
|
|
5307
5363
|
function restoreInstr(node2, value, target) {
|
|
5308
5364
|
let current = node2;
|
|
5309
|
-
const
|
|
5365
|
+
const path7 = [];
|
|
5310
5366
|
do {
|
|
5311
|
-
|
|
5367
|
+
path7.push(current.key);
|
|
5312
5368
|
current = current.parent;
|
|
5313
5369
|
} while (current.parent != null);
|
|
5314
|
-
return { path:
|
|
5370
|
+
return { path: path7, value, target };
|
|
5315
5371
|
}
|
|
5316
5372
|
}
|
|
5317
5373
|
});
|
|
@@ -5341,10 +5397,10 @@ var require_restorer = __commonJS({
|
|
|
5341
5397
|
};
|
|
5342
5398
|
}
|
|
5343
5399
|
function resetTmpl(secret, paths) {
|
|
5344
|
-
return paths.map((
|
|
5345
|
-
const { circle, escPath, leadingBracket } = secret[
|
|
5400
|
+
return paths.map((path7) => {
|
|
5401
|
+
const { circle, escPath, leadingBracket } = secret[path7];
|
|
5346
5402
|
const delim = leadingBracket ? "" : ".";
|
|
5347
|
-
const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${
|
|
5403
|
+
const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path7} = secret[${escPath}].val`;
|
|
5348
5404
|
const clear = `secret[${escPath}].val = undefined`;
|
|
5349
5405
|
return `
|
|
5350
5406
|
if (secret[${escPath}].val !== undefined) {
|
|
@@ -5576,8 +5632,8 @@ var require_redaction = __commonJS({
|
|
|
5576
5632
|
if (shape[k] === null) {
|
|
5577
5633
|
o[k] = (value) => topCensor(value, [k]);
|
|
5578
5634
|
} else {
|
|
5579
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
5580
|
-
return censor(value, [k, ...
|
|
5635
|
+
const wrappedCensor = typeof censor === "function" ? (value, path7) => {
|
|
5636
|
+
return censor(value, [k, ...path7]);
|
|
5581
5637
|
} : censor;
|
|
5582
5638
|
o[k] = fastRedact({
|
|
5583
5639
|
paths: shape[k],
|
|
@@ -5777,10 +5833,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
5777
5833
|
var require_sonic_boom = __commonJS({
|
|
5778
5834
|
"node_modules/.pnpm/sonic-boom@4.2.0/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
5779
5835
|
"use strict";
|
|
5780
|
-
var
|
|
5836
|
+
var fs7 = require("fs");
|
|
5781
5837
|
var EventEmitter = require("events");
|
|
5782
5838
|
var inherits = require("util").inherits;
|
|
5783
|
-
var
|
|
5839
|
+
var path7 = require("path");
|
|
5784
5840
|
var sleep = require_atomic_sleep();
|
|
5785
5841
|
var assert = require("assert");
|
|
5786
5842
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -5834,20 +5890,20 @@ var require_sonic_boom = __commonJS({
|
|
|
5834
5890
|
const mode = sonic.mode;
|
|
5835
5891
|
if (sonic.sync) {
|
|
5836
5892
|
try {
|
|
5837
|
-
if (sonic.mkdir)
|
|
5838
|
-
const fd2 =
|
|
5893
|
+
if (sonic.mkdir) fs7.mkdirSync(path7.dirname(file), { recursive: true });
|
|
5894
|
+
const fd2 = fs7.openSync(file, flags, mode);
|
|
5839
5895
|
fileOpened(null, fd2);
|
|
5840
5896
|
} catch (err) {
|
|
5841
5897
|
fileOpened(err);
|
|
5842
5898
|
throw err;
|
|
5843
5899
|
}
|
|
5844
5900
|
} else if (sonic.mkdir) {
|
|
5845
|
-
|
|
5901
|
+
fs7.mkdir(path7.dirname(file), { recursive: true }, (err) => {
|
|
5846
5902
|
if (err) return fileOpened(err);
|
|
5847
|
-
|
|
5903
|
+
fs7.open(file, flags, mode, fileOpened);
|
|
5848
5904
|
});
|
|
5849
5905
|
} else {
|
|
5850
|
-
|
|
5906
|
+
fs7.open(file, flags, mode, fileOpened);
|
|
5851
5907
|
}
|
|
5852
5908
|
}
|
|
5853
5909
|
function SonicBoom(opts) {
|
|
@@ -5888,16 +5944,16 @@ var require_sonic_boom = __commonJS({
|
|
|
5888
5944
|
this.flush = flushBuffer;
|
|
5889
5945
|
this.flushSync = flushBufferSync;
|
|
5890
5946
|
this._actualWrite = actualWriteBuffer;
|
|
5891
|
-
fsWriteSync = () =>
|
|
5892
|
-
fsWrite = () =>
|
|
5947
|
+
fsWriteSync = () => fs7.writeSync(this.fd, this._writingBuf);
|
|
5948
|
+
fsWrite = () => fs7.write(this.fd, this._writingBuf, this.release);
|
|
5893
5949
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
5894
5950
|
this._writingBuf = "";
|
|
5895
5951
|
this.write = write;
|
|
5896
5952
|
this.flush = flush;
|
|
5897
5953
|
this.flushSync = flushSync;
|
|
5898
5954
|
this._actualWrite = actualWrite;
|
|
5899
|
-
fsWriteSync = () =>
|
|
5900
|
-
fsWrite = () =>
|
|
5955
|
+
fsWriteSync = () => fs7.writeSync(this.fd, this._writingBuf, "utf8");
|
|
5956
|
+
fsWrite = () => fs7.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
5901
5957
|
} else {
|
|
5902
5958
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
5903
5959
|
}
|
|
@@ -5953,7 +6009,7 @@ var require_sonic_boom = __commonJS({
|
|
|
5953
6009
|
}
|
|
5954
6010
|
}
|
|
5955
6011
|
if (this._fsync) {
|
|
5956
|
-
|
|
6012
|
+
fs7.fsyncSync(this.fd);
|
|
5957
6013
|
}
|
|
5958
6014
|
const len = this._len;
|
|
5959
6015
|
if (this._reopening) {
|
|
@@ -6065,7 +6121,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6065
6121
|
const onDrain = () => {
|
|
6066
6122
|
if (!this._fsync) {
|
|
6067
6123
|
try {
|
|
6068
|
-
|
|
6124
|
+
fs7.fsync(this.fd, (err) => {
|
|
6069
6125
|
this._flushPending = false;
|
|
6070
6126
|
cb(err);
|
|
6071
6127
|
});
|
|
@@ -6167,7 +6223,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6167
6223
|
const fd2 = this.fd;
|
|
6168
6224
|
this.once("ready", () => {
|
|
6169
6225
|
if (fd2 !== this.fd) {
|
|
6170
|
-
|
|
6226
|
+
fs7.close(fd2, (err) => {
|
|
6171
6227
|
if (err) {
|
|
6172
6228
|
return this.emit("error", err);
|
|
6173
6229
|
}
|
|
@@ -6216,7 +6272,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6216
6272
|
buf = this._bufs[0];
|
|
6217
6273
|
}
|
|
6218
6274
|
try {
|
|
6219
|
-
const n =
|
|
6275
|
+
const n = fs7.writeSync(this.fd, buf, "utf8");
|
|
6220
6276
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
6221
6277
|
buf = releasedBufObj.writingBuf;
|
|
6222
6278
|
this._len = releasedBufObj.len;
|
|
@@ -6232,7 +6288,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6232
6288
|
}
|
|
6233
6289
|
}
|
|
6234
6290
|
try {
|
|
6235
|
-
|
|
6291
|
+
fs7.fsyncSync(this.fd);
|
|
6236
6292
|
} catch {
|
|
6237
6293
|
}
|
|
6238
6294
|
}
|
|
@@ -6253,7 +6309,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6253
6309
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
6254
6310
|
}
|
|
6255
6311
|
try {
|
|
6256
|
-
const n =
|
|
6312
|
+
const n = fs7.writeSync(this.fd, buf);
|
|
6257
6313
|
buf = buf.subarray(n);
|
|
6258
6314
|
this._len = Math.max(this._len - n, 0);
|
|
6259
6315
|
if (buf.length <= 0) {
|
|
@@ -6281,13 +6337,13 @@ var require_sonic_boom = __commonJS({
|
|
|
6281
6337
|
this._writingBuf = this._writingBuf || this._bufs.shift() || "";
|
|
6282
6338
|
if (this.sync) {
|
|
6283
6339
|
try {
|
|
6284
|
-
const written =
|
|
6340
|
+
const written = fs7.writeSync(this.fd, this._writingBuf, "utf8");
|
|
6285
6341
|
release(null, written);
|
|
6286
6342
|
} catch (err) {
|
|
6287
6343
|
release(err);
|
|
6288
6344
|
}
|
|
6289
6345
|
} else {
|
|
6290
|
-
|
|
6346
|
+
fs7.write(this.fd, this._writingBuf, "utf8", release);
|
|
6291
6347
|
}
|
|
6292
6348
|
}
|
|
6293
6349
|
function actualWriteBuffer() {
|
|
@@ -6296,7 +6352,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6296
6352
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
6297
6353
|
if (this.sync) {
|
|
6298
6354
|
try {
|
|
6299
|
-
const written =
|
|
6355
|
+
const written = fs7.writeSync(this.fd, this._writingBuf);
|
|
6300
6356
|
release(null, written);
|
|
6301
6357
|
} catch (err) {
|
|
6302
6358
|
release(err);
|
|
@@ -6305,7 +6361,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6305
6361
|
if (kCopyBuffer) {
|
|
6306
6362
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
6307
6363
|
}
|
|
6308
|
-
|
|
6364
|
+
fs7.write(this.fd, this._writingBuf, release);
|
|
6309
6365
|
}
|
|
6310
6366
|
}
|
|
6311
6367
|
function actualClose(sonic) {
|
|
@@ -6321,12 +6377,12 @@ var require_sonic_boom = __commonJS({
|
|
|
6321
6377
|
sonic._lens = [];
|
|
6322
6378
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
6323
6379
|
try {
|
|
6324
|
-
|
|
6380
|
+
fs7.fsync(sonic.fd, closeWrapped);
|
|
6325
6381
|
} catch {
|
|
6326
6382
|
}
|
|
6327
6383
|
function closeWrapped() {
|
|
6328
6384
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
6329
|
-
|
|
6385
|
+
fs7.close(sonic.fd, done);
|
|
6330
6386
|
} else {
|
|
6331
6387
|
done();
|
|
6332
6388
|
}
|
|
@@ -7572,9 +7628,9 @@ var require_levels = __commonJS({
|
|
|
7572
7628
|
const { levels, levelVal } = this;
|
|
7573
7629
|
return levels && levels.labels ? levels.labels[levelVal] : "";
|
|
7574
7630
|
}
|
|
7575
|
-
function isLevelEnabled(
|
|
7631
|
+
function isLevelEnabled(logLevel2) {
|
|
7576
7632
|
const { values } = this.levels;
|
|
7577
|
-
const logLevelVal = values[
|
|
7633
|
+
const logLevelVal = values[logLevel2];
|
|
7578
7634
|
return logLevelVal !== void 0 && this[levelCompSym](logLevelVal, this[levelValSym]);
|
|
7579
7635
|
}
|
|
7580
7636
|
function compareLevel(direction, current, expected) {
|
|
@@ -11902,7 +11958,7 @@ var require_context = __commonJS({
|
|
|
11902
11958
|
childLoggerFactory,
|
|
11903
11959
|
errorHandler,
|
|
11904
11960
|
bodyLimit,
|
|
11905
|
-
logLevel,
|
|
11961
|
+
logLevel: logLevel2,
|
|
11906
11962
|
logSerializers,
|
|
11907
11963
|
attachValidation,
|
|
11908
11964
|
validatorCompiler,
|
|
@@ -11937,7 +11993,7 @@ var require_context = __commonJS({
|
|
|
11937
11993
|
};
|
|
11938
11994
|
this.exposeHeadRoute = exposeHeadRoute;
|
|
11939
11995
|
this.prefixTrailingSlash = prefixTrailingSlash;
|
|
11940
|
-
this.logLevel =
|
|
11996
|
+
this.logLevel = logLevel2 || server[kLogLevel];
|
|
11941
11997
|
this.logSerializers = logSerializers;
|
|
11942
11998
|
this[kFourOhFourContext] = null;
|
|
11943
11999
|
this.attachValidation = attachValidation;
|
|
@@ -16185,9 +16241,9 @@ var require_validate = __commonJS({
|
|
|
16185
16241
|
}
|
|
16186
16242
|
let expr = data;
|
|
16187
16243
|
const segments = jsonPointer.split("/");
|
|
16188
|
-
for (const
|
|
16189
|
-
if (
|
|
16190
|
-
data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(
|
|
16244
|
+
for (const segment2 of segments) {
|
|
16245
|
+
if (segment2) {
|
|
16246
|
+
data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment2))}`;
|
|
16191
16247
|
expr = (0, codegen_1._)`${expr} && ${data}`;
|
|
16192
16248
|
}
|
|
16193
16249
|
}
|
|
@@ -16782,8 +16838,8 @@ var require_schemes = __commonJS({
|
|
|
16782
16838
|
wsComponents.secure = void 0;
|
|
16783
16839
|
}
|
|
16784
16840
|
if (wsComponents.resourceName) {
|
|
16785
|
-
const [
|
|
16786
|
-
wsComponents.path =
|
|
16841
|
+
const [path7, query] = wsComponents.resourceName.split("?");
|
|
16842
|
+
wsComponents.path = path7 && path7 !== "/" ? path7 : void 0;
|
|
16787
16843
|
wsComponents.query = query;
|
|
16788
16844
|
wsComponents.resourceName = void 0;
|
|
16789
16845
|
}
|
|
@@ -20099,12 +20155,12 @@ var require_dist2 = __commonJS({
|
|
|
20099
20155
|
throw new Error(`Unknown format "${name}"`);
|
|
20100
20156
|
return f;
|
|
20101
20157
|
};
|
|
20102
|
-
function addFormats(ajv, list,
|
|
20158
|
+
function addFormats(ajv, list, fs7, exportName) {
|
|
20103
20159
|
var _a;
|
|
20104
20160
|
var _b;
|
|
20105
20161
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
20106
20162
|
for (const f of list)
|
|
20107
|
-
ajv.addFormat(f,
|
|
20163
|
+
ajv.addFormat(f, fs7[f]);
|
|
20108
20164
|
}
|
|
20109
20165
|
module2.exports = exports2 = formatsPlugin;
|
|
20110
20166
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -28778,40 +28834,40 @@ var require_node = __commonJS({
|
|
|
28778
28834
|
super();
|
|
28779
28835
|
this.staticChildren = {};
|
|
28780
28836
|
}
|
|
28781
|
-
findStaticMatchingChild(
|
|
28782
|
-
const staticChild = this.staticChildren[
|
|
28783
|
-
if (staticChild === void 0 || !staticChild.matchPrefix(
|
|
28837
|
+
findStaticMatchingChild(path7, pathIndex) {
|
|
28838
|
+
const staticChild = this.staticChildren[path7.charAt(pathIndex)];
|
|
28839
|
+
if (staticChild === void 0 || !staticChild.matchPrefix(path7, pathIndex)) {
|
|
28784
28840
|
return null;
|
|
28785
28841
|
}
|
|
28786
28842
|
return staticChild;
|
|
28787
28843
|
}
|
|
28788
|
-
getStaticChild(
|
|
28789
|
-
if (
|
|
28844
|
+
getStaticChild(path7, pathIndex = 0) {
|
|
28845
|
+
if (path7.length === pathIndex) {
|
|
28790
28846
|
return this;
|
|
28791
28847
|
}
|
|
28792
|
-
const staticChild = this.findStaticMatchingChild(
|
|
28848
|
+
const staticChild = this.findStaticMatchingChild(path7, pathIndex);
|
|
28793
28849
|
if (staticChild) {
|
|
28794
|
-
return staticChild.getStaticChild(
|
|
28850
|
+
return staticChild.getStaticChild(path7, pathIndex + staticChild.prefix.length);
|
|
28795
28851
|
}
|
|
28796
28852
|
return null;
|
|
28797
28853
|
}
|
|
28798
|
-
createStaticChild(
|
|
28799
|
-
if (
|
|
28854
|
+
createStaticChild(path7) {
|
|
28855
|
+
if (path7.length === 0) {
|
|
28800
28856
|
return this;
|
|
28801
28857
|
}
|
|
28802
|
-
let staticChild = this.staticChildren[
|
|
28858
|
+
let staticChild = this.staticChildren[path7.charAt(0)];
|
|
28803
28859
|
if (staticChild) {
|
|
28804
28860
|
let i = 1;
|
|
28805
28861
|
for (; i < staticChild.prefix.length; i++) {
|
|
28806
|
-
if (
|
|
28862
|
+
if (path7.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
|
|
28807
28863
|
staticChild = staticChild.split(this, i);
|
|
28808
28864
|
break;
|
|
28809
28865
|
}
|
|
28810
28866
|
}
|
|
28811
|
-
return staticChild.createStaticChild(
|
|
28867
|
+
return staticChild.createStaticChild(path7.slice(i));
|
|
28812
28868
|
}
|
|
28813
|
-
const label =
|
|
28814
|
-
this.staticChildren[label] = new StaticNode(
|
|
28869
|
+
const label = path7.charAt(0);
|
|
28870
|
+
this.staticChildren[label] = new StaticNode(path7);
|
|
28815
28871
|
return this.staticChildren[label];
|
|
28816
28872
|
}
|
|
28817
28873
|
};
|
|
@@ -28871,8 +28927,8 @@ var require_node = __commonJS({
|
|
|
28871
28927
|
parentNode.staticChildren[parentPrefix.charAt(0)] = staticNode;
|
|
28872
28928
|
return staticNode;
|
|
28873
28929
|
}
|
|
28874
|
-
getNextNode(
|
|
28875
|
-
let node = this.findStaticMatchingChild(
|
|
28930
|
+
getNextNode(path7, pathIndex, nodeStack, paramsCount) {
|
|
28931
|
+
let node = this.findStaticMatchingChild(path7, pathIndex);
|
|
28876
28932
|
let parametricBrotherNodeIndex = 0;
|
|
28877
28933
|
if (node === null) {
|
|
28878
28934
|
if (this.parametricChildren.length === 0) {
|
|
@@ -28919,8 +28975,8 @@ var require_node = __commonJS({
|
|
|
28919
28975
|
this.kind = NODE_TYPES.PARAMETRIC;
|
|
28920
28976
|
this.nodePaths = /* @__PURE__ */ new Set([nodePath]);
|
|
28921
28977
|
}
|
|
28922
|
-
getNextNode(
|
|
28923
|
-
return this.findStaticMatchingChild(
|
|
28978
|
+
getNextNode(path7, pathIndex) {
|
|
28979
|
+
return this.findStaticMatchingChild(path7, pathIndex);
|
|
28924
28980
|
}
|
|
28925
28981
|
};
|
|
28926
28982
|
var WildcardNode = class extends Node {
|
|
@@ -29256,33 +29312,33 @@ var require_url_sanitizer = __commonJS({
|
|
|
29256
29312
|
}
|
|
29257
29313
|
return null;
|
|
29258
29314
|
}
|
|
29259
|
-
function safeDecodeURI(
|
|
29315
|
+
function safeDecodeURI(path7, useSemicolonDelimiter) {
|
|
29260
29316
|
let shouldDecode = false;
|
|
29261
29317
|
let shouldDecodeParam = false;
|
|
29262
29318
|
let querystring = "";
|
|
29263
|
-
for (let i = 1; i <
|
|
29264
|
-
const charCode =
|
|
29319
|
+
for (let i = 1; i < path7.length; i++) {
|
|
29320
|
+
const charCode = path7.charCodeAt(i);
|
|
29265
29321
|
if (charCode === 37) {
|
|
29266
|
-
const highCharCode =
|
|
29267
|
-
const lowCharCode =
|
|
29322
|
+
const highCharCode = path7.charCodeAt(i + 1);
|
|
29323
|
+
const lowCharCode = path7.charCodeAt(i + 2);
|
|
29268
29324
|
if (decodeComponentChar(highCharCode, lowCharCode) === null) {
|
|
29269
29325
|
shouldDecode = true;
|
|
29270
29326
|
} else {
|
|
29271
29327
|
shouldDecodeParam = true;
|
|
29272
29328
|
if (highCharCode === 50 && lowCharCode === 53) {
|
|
29273
29329
|
shouldDecode = true;
|
|
29274
|
-
|
|
29330
|
+
path7 = path7.slice(0, i + 1) + "25" + path7.slice(i + 1);
|
|
29275
29331
|
i += 2;
|
|
29276
29332
|
}
|
|
29277
29333
|
i += 2;
|
|
29278
29334
|
}
|
|
29279
29335
|
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
29280
|
-
querystring =
|
|
29281
|
-
|
|
29336
|
+
querystring = path7.slice(i + 1);
|
|
29337
|
+
path7 = path7.slice(0, i);
|
|
29282
29338
|
break;
|
|
29283
29339
|
}
|
|
29284
29340
|
}
|
|
29285
|
-
const decodedPath = shouldDecode ? decodeURI(
|
|
29341
|
+
const decodedPath = shouldDecode ? decodeURI(path7) : path7;
|
|
29286
29342
|
return { path: decodedPath, querystring, shouldDecodeParam };
|
|
29287
29343
|
}
|
|
29288
29344
|
function safeDecodeURIComponent(uriComponent) {
|
|
@@ -29375,7 +29431,7 @@ var require_find_my_way = __commonJS({
|
|
|
29375
29431
|
this.routes = [];
|
|
29376
29432
|
this.trees = {};
|
|
29377
29433
|
}
|
|
29378
|
-
Router.prototype.on = function on(method,
|
|
29434
|
+
Router.prototype.on = function on(method, path7, opts, handler, store) {
|
|
29379
29435
|
if (typeof opts === "function") {
|
|
29380
29436
|
if (handler !== void 0) {
|
|
29381
29437
|
store = handler;
|
|
@@ -29383,34 +29439,34 @@ var require_find_my_way = __commonJS({
|
|
|
29383
29439
|
handler = opts;
|
|
29384
29440
|
opts = {};
|
|
29385
29441
|
}
|
|
29386
|
-
assert(typeof
|
|
29387
|
-
assert(
|
|
29388
|
-
assert(
|
|
29442
|
+
assert(typeof path7 === "string", "Path should be a string");
|
|
29443
|
+
assert(path7.length > 0, "The path could not be empty");
|
|
29444
|
+
assert(path7[0] === "/" || path7[0] === "*", "The first character of a path should be `/` or `*`");
|
|
29389
29445
|
assert(typeof handler === "function", "Handler should be a function");
|
|
29390
|
-
const optionalParamMatch =
|
|
29446
|
+
const optionalParamMatch = path7.match(OPTIONAL_PARAM_REGEXP);
|
|
29391
29447
|
if (optionalParamMatch) {
|
|
29392
|
-
assert(
|
|
29393
|
-
const pathFull =
|
|
29394
|
-
const pathOptional =
|
|
29448
|
+
assert(path7.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
29449
|
+
const pathFull = path7.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
29450
|
+
const pathOptional = path7.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
|
|
29395
29451
|
this.on(method, pathFull, opts, handler, store);
|
|
29396
29452
|
this.on(method, pathOptional, opts, handler, store);
|
|
29397
29453
|
return;
|
|
29398
29454
|
}
|
|
29399
|
-
const route =
|
|
29455
|
+
const route = path7;
|
|
29400
29456
|
if (this.ignoreDuplicateSlashes) {
|
|
29401
|
-
|
|
29457
|
+
path7 = removeDuplicateSlashes(path7);
|
|
29402
29458
|
}
|
|
29403
29459
|
if (this.ignoreTrailingSlash) {
|
|
29404
|
-
|
|
29460
|
+
path7 = trimLastSlash(path7);
|
|
29405
29461
|
}
|
|
29406
29462
|
const methods = Array.isArray(method) ? method : [method];
|
|
29407
29463
|
for (const method2 of methods) {
|
|
29408
29464
|
assert(typeof method2 === "string", "Method should be a string");
|
|
29409
29465
|
assert(httpMethods.includes(method2), `Method '${method2}' is not an http method.`);
|
|
29410
|
-
this._on(method2,
|
|
29466
|
+
this._on(method2, path7, opts, handler, store, route);
|
|
29411
29467
|
}
|
|
29412
29468
|
};
|
|
29413
|
-
Router.prototype._on = function _on(method,
|
|
29469
|
+
Router.prototype._on = function _on(method, path7, opts, handler, store) {
|
|
29414
29470
|
let constraints = {};
|
|
29415
29471
|
if (opts.constraints !== void 0) {
|
|
29416
29472
|
assert(typeof opts.constraints === "object" && opts.constraints !== null, "Constraints should be an object");
|
|
@@ -29423,7 +29479,7 @@ var require_find_my_way = __commonJS({
|
|
|
29423
29479
|
if (this.trees[method] === void 0) {
|
|
29424
29480
|
this.trees[method] = new StaticNode("/");
|
|
29425
29481
|
}
|
|
29426
|
-
let pattern =
|
|
29482
|
+
let pattern = path7;
|
|
29427
29483
|
if (pattern === "*" && this.trees[method].prefix.length !== 0) {
|
|
29428
29484
|
const currentRoot = this.trees[method];
|
|
29429
29485
|
this.trees[method] = new StaticNode("");
|
|
@@ -29526,19 +29582,19 @@ var require_find_my_way = __commonJS({
|
|
|
29526
29582
|
throw new Error(`Method '${method}' already declared for route '${pattern}' with constraints '${JSON.stringify(constraints)}'`);
|
|
29527
29583
|
}
|
|
29528
29584
|
}
|
|
29529
|
-
const route = { method, path:
|
|
29585
|
+
const route = { method, path: path7, pattern, params, opts, handler, store };
|
|
29530
29586
|
this.routes.push(route);
|
|
29531
29587
|
currentNode.addRoute(route, this.constrainer);
|
|
29532
29588
|
};
|
|
29533
|
-
Router.prototype.hasRoute = function hasRoute(method,
|
|
29534
|
-
const route = this.findRoute(method,
|
|
29589
|
+
Router.prototype.hasRoute = function hasRoute(method, path7, constraints) {
|
|
29590
|
+
const route = this.findRoute(method, path7, constraints);
|
|
29535
29591
|
return route !== null;
|
|
29536
29592
|
};
|
|
29537
|
-
Router.prototype.findRoute = function findNode(method,
|
|
29593
|
+
Router.prototype.findRoute = function findNode(method, path7, constraints = {}) {
|
|
29538
29594
|
if (this.trees[method] === void 0) {
|
|
29539
29595
|
return null;
|
|
29540
29596
|
}
|
|
29541
|
-
let pattern =
|
|
29597
|
+
let pattern = path7;
|
|
29542
29598
|
let currentNode = this.trees[method];
|
|
29543
29599
|
let parentNodePathIndex = currentNode.prefix.length;
|
|
29544
29600
|
const params = [];
|
|
@@ -29656,39 +29712,39 @@ var require_find_my_way = __commonJS({
|
|
|
29656
29712
|
this.trees = {};
|
|
29657
29713
|
this.routes = [];
|
|
29658
29714
|
};
|
|
29659
|
-
Router.prototype.off = function off(method,
|
|
29660
|
-
assert(typeof
|
|
29661
|
-
assert(
|
|
29662
|
-
assert(
|
|
29715
|
+
Router.prototype.off = function off(method, path7, constraints) {
|
|
29716
|
+
assert(typeof path7 === "string", "Path should be a string");
|
|
29717
|
+
assert(path7.length > 0, "The path could not be empty");
|
|
29718
|
+
assert(path7[0] === "/" || path7[0] === "*", "The first character of a path should be `/` or `*`");
|
|
29663
29719
|
assert(
|
|
29664
29720
|
typeof constraints === "undefined" || typeof constraints === "object" && !Array.isArray(constraints) && constraints !== null,
|
|
29665
29721
|
"Constraints should be an object or undefined."
|
|
29666
29722
|
);
|
|
29667
|
-
const optionalParamMatch =
|
|
29723
|
+
const optionalParamMatch = path7.match(OPTIONAL_PARAM_REGEXP);
|
|
29668
29724
|
if (optionalParamMatch) {
|
|
29669
|
-
assert(
|
|
29670
|
-
const pathFull =
|
|
29671
|
-
const pathOptional =
|
|
29725
|
+
assert(path7.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
|
|
29726
|
+
const pathFull = path7.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
|
|
29727
|
+
const pathOptional = path7.replace(OPTIONAL_PARAM_REGEXP, "$2");
|
|
29672
29728
|
this.off(method, pathFull, constraints);
|
|
29673
29729
|
this.off(method, pathOptional, constraints);
|
|
29674
29730
|
return;
|
|
29675
29731
|
}
|
|
29676
29732
|
if (this.ignoreDuplicateSlashes) {
|
|
29677
|
-
|
|
29733
|
+
path7 = removeDuplicateSlashes(path7);
|
|
29678
29734
|
}
|
|
29679
29735
|
if (this.ignoreTrailingSlash) {
|
|
29680
|
-
|
|
29736
|
+
path7 = trimLastSlash(path7);
|
|
29681
29737
|
}
|
|
29682
29738
|
const methods = Array.isArray(method) ? method : [method];
|
|
29683
29739
|
for (const method2 of methods) {
|
|
29684
|
-
this._off(method2,
|
|
29740
|
+
this._off(method2, path7, constraints);
|
|
29685
29741
|
}
|
|
29686
29742
|
};
|
|
29687
|
-
Router.prototype._off = function _off(method,
|
|
29743
|
+
Router.prototype._off = function _off(method, path7, constraints) {
|
|
29688
29744
|
assert(typeof method === "string", "Method should be a string");
|
|
29689
29745
|
assert(httpMethods.includes(method), `Method '${method}' is not an http method.`);
|
|
29690
29746
|
function matcherWithoutConstraints(route) {
|
|
29691
|
-
return method !== route.method ||
|
|
29747
|
+
return method !== route.method || path7 !== route.path;
|
|
29692
29748
|
}
|
|
29693
29749
|
function matcherWithConstraints(route) {
|
|
29694
29750
|
return matcherWithoutConstraints(route) || !deepEqual(constraints, route.opts.constraints || {});
|
|
@@ -29725,37 +29781,37 @@ var require_find_my_way = __commonJS({
|
|
|
29725
29781
|
if (handle === null) return this._defaultRoute(req, res, ctx);
|
|
29726
29782
|
return ctx === void 0 ? handle.handler(req, res, handle.params, handle.store, handle.searchParams) : handle.handler.call(ctx, req, res, handle.params, handle.store, handle.searchParams);
|
|
29727
29783
|
};
|
|
29728
|
-
Router.prototype.find = function find(method,
|
|
29784
|
+
Router.prototype.find = function find(method, path7, derivedConstraints) {
|
|
29729
29785
|
let currentNode = this.trees[method];
|
|
29730
29786
|
if (currentNode === void 0) return null;
|
|
29731
|
-
if (
|
|
29732
|
-
|
|
29787
|
+
if (path7.charCodeAt(0) !== 47) {
|
|
29788
|
+
path7 = path7.replace(FULL_PATH_REGEXP, "/");
|
|
29733
29789
|
}
|
|
29734
29790
|
if (this.ignoreDuplicateSlashes) {
|
|
29735
|
-
|
|
29791
|
+
path7 = removeDuplicateSlashes(path7);
|
|
29736
29792
|
}
|
|
29737
29793
|
let sanitizedUrl;
|
|
29738
29794
|
let querystring2;
|
|
29739
29795
|
let shouldDecodeParam;
|
|
29740
29796
|
try {
|
|
29741
|
-
sanitizedUrl = safeDecodeURI(
|
|
29742
|
-
|
|
29797
|
+
sanitizedUrl = safeDecodeURI(path7, this.useSemicolonDelimiter);
|
|
29798
|
+
path7 = sanitizedUrl.path;
|
|
29743
29799
|
querystring2 = sanitizedUrl.querystring;
|
|
29744
29800
|
shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
|
|
29745
29801
|
} catch (error) {
|
|
29746
|
-
return this._onBadUrl(
|
|
29802
|
+
return this._onBadUrl(path7);
|
|
29747
29803
|
}
|
|
29748
29804
|
if (this.ignoreTrailingSlash) {
|
|
29749
|
-
|
|
29805
|
+
path7 = trimLastSlash(path7);
|
|
29750
29806
|
}
|
|
29751
|
-
const originPath =
|
|
29807
|
+
const originPath = path7;
|
|
29752
29808
|
if (this.caseSensitive === false) {
|
|
29753
|
-
|
|
29809
|
+
path7 = path7.toLowerCase();
|
|
29754
29810
|
}
|
|
29755
29811
|
const maxParamLength = this.maxParamLength;
|
|
29756
29812
|
let pathIndex = currentNode.prefix.length;
|
|
29757
29813
|
const params = [];
|
|
29758
|
-
const pathLen =
|
|
29814
|
+
const pathLen = path7.length;
|
|
29759
29815
|
const brothersNodesStack = [];
|
|
29760
29816
|
while (true) {
|
|
29761
29817
|
if (pathIndex === pathLen && currentNode.isLeafNode) {
|
|
@@ -29769,7 +29825,7 @@ var require_find_my_way = __commonJS({
|
|
|
29769
29825
|
};
|
|
29770
29826
|
}
|
|
29771
29827
|
}
|
|
29772
|
-
let node = currentNode.getNextNode(
|
|
29828
|
+
let node = currentNode.getNextNode(path7, pathIndex, brothersNodesStack, params.length);
|
|
29773
29829
|
if (node === null) {
|
|
29774
29830
|
if (brothersNodesStack.length === 0) {
|
|
29775
29831
|
return null;
|
|
@@ -29823,8 +29879,8 @@ var require_find_my_way = __commonJS({
|
|
|
29823
29879
|
Router.prototype._rebuild = function(routes) {
|
|
29824
29880
|
this.reset();
|
|
29825
29881
|
for (const route of routes) {
|
|
29826
|
-
const { method, path:
|
|
29827
|
-
this._on(method,
|
|
29882
|
+
const { method, path: path7, opts, handler, store } = route;
|
|
29883
|
+
this._on(method, path7, opts, handler, store);
|
|
29828
29884
|
}
|
|
29829
29885
|
};
|
|
29830
29886
|
Router.prototype._defaultRoute = function(req, res, ctx) {
|
|
@@ -29835,13 +29891,13 @@ var require_find_my_way = __commonJS({
|
|
|
29835
29891
|
res.end();
|
|
29836
29892
|
}
|
|
29837
29893
|
};
|
|
29838
|
-
Router.prototype._onBadUrl = function(
|
|
29894
|
+
Router.prototype._onBadUrl = function(path7) {
|
|
29839
29895
|
if (this.onBadUrl === null) {
|
|
29840
29896
|
return null;
|
|
29841
29897
|
}
|
|
29842
29898
|
const onBadUrl = this.onBadUrl;
|
|
29843
29899
|
return {
|
|
29844
|
-
handler: (req, res, ctx) => onBadUrl(
|
|
29900
|
+
handler: (req, res, ctx) => onBadUrl(path7, req, res),
|
|
29845
29901
|
params: {},
|
|
29846
29902
|
store: null
|
|
29847
29903
|
};
|
|
@@ -29873,25 +29929,25 @@ var require_find_my_way = __commonJS({
|
|
|
29873
29929
|
if (!httpMethods.hasOwnProperty(i)) continue;
|
|
29874
29930
|
const m = httpMethods[i];
|
|
29875
29931
|
const methodName = m.toLowerCase();
|
|
29876
|
-
Router.prototype[methodName] = function(
|
|
29877
|
-
return this.on(m,
|
|
29932
|
+
Router.prototype[methodName] = function(path7, handler, store) {
|
|
29933
|
+
return this.on(m, path7, handler, store);
|
|
29878
29934
|
};
|
|
29879
29935
|
}
|
|
29880
|
-
Router.prototype.all = function(
|
|
29881
|
-
this.on(httpMethods,
|
|
29936
|
+
Router.prototype.all = function(path7, handler, store) {
|
|
29937
|
+
this.on(httpMethods, path7, handler, store);
|
|
29882
29938
|
};
|
|
29883
29939
|
module2.exports = Router;
|
|
29884
29940
|
function escapeRegExp(string) {
|
|
29885
29941
|
return string.replace(ESCAPE_REGEXP, "\\$&");
|
|
29886
29942
|
}
|
|
29887
|
-
function removeDuplicateSlashes(
|
|
29888
|
-
return
|
|
29943
|
+
function removeDuplicateSlashes(path7) {
|
|
29944
|
+
return path7.indexOf("//") !== -1 ? path7.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path7;
|
|
29889
29945
|
}
|
|
29890
|
-
function trimLastSlash(
|
|
29891
|
-
if (
|
|
29892
|
-
return
|
|
29946
|
+
function trimLastSlash(path7) {
|
|
29947
|
+
if (path7.length > 1 && path7.charCodeAt(path7.length - 1) === 47) {
|
|
29948
|
+
return path7.slice(0, -1);
|
|
29893
29949
|
}
|
|
29894
|
-
return
|
|
29950
|
+
return path7;
|
|
29895
29951
|
}
|
|
29896
29952
|
function trimRegExpStartAndEnd(regexString) {
|
|
29897
29953
|
if (regexString.charCodeAt(1) === 94) {
|
|
@@ -29902,22 +29958,22 @@ var require_find_my_way = __commonJS({
|
|
|
29902
29958
|
}
|
|
29903
29959
|
return regexString;
|
|
29904
29960
|
}
|
|
29905
|
-
function getClosingParenthensePosition(
|
|
29961
|
+
function getClosingParenthensePosition(path7, idx) {
|
|
29906
29962
|
let parentheses = 1;
|
|
29907
|
-
while (idx <
|
|
29963
|
+
while (idx < path7.length) {
|
|
29908
29964
|
idx++;
|
|
29909
|
-
if (
|
|
29965
|
+
if (path7.charCodeAt(idx) === 92) {
|
|
29910
29966
|
idx++;
|
|
29911
29967
|
continue;
|
|
29912
29968
|
}
|
|
29913
|
-
if (
|
|
29969
|
+
if (path7.charCodeAt(idx) === 41) {
|
|
29914
29970
|
parentheses--;
|
|
29915
|
-
} else if (
|
|
29971
|
+
} else if (path7.charCodeAt(idx) === 40) {
|
|
29916
29972
|
parentheses++;
|
|
29917
29973
|
}
|
|
29918
29974
|
if (!parentheses) return idx;
|
|
29919
29975
|
}
|
|
29920
|
-
throw new TypeError('Invalid regexp expression in "' +
|
|
29976
|
+
throw new TypeError('Invalid regexp expression in "' + path7 + '"');
|
|
29921
29977
|
}
|
|
29922
29978
|
function defaultBuildPrettyMeta(route) {
|
|
29923
29979
|
if (!route) return {};
|
|
@@ -30124,12 +30180,12 @@ var require_route = __commonJS({
|
|
|
30124
30180
|
function route({ options: options2, isFastify }) {
|
|
30125
30181
|
throwIfAlreadyStarted("Cannot add route!");
|
|
30126
30182
|
const opts = { ...options2 };
|
|
30127
|
-
const
|
|
30183
|
+
const path7 = opts.url || opts.path || "";
|
|
30128
30184
|
if (!opts.handler) {
|
|
30129
|
-
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method,
|
|
30185
|
+
throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path7);
|
|
30130
30186
|
}
|
|
30131
30187
|
if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
|
|
30132
|
-
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method,
|
|
30188
|
+
throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path7);
|
|
30133
30189
|
}
|
|
30134
30190
|
validateBodyLimitOption(opts.bodyLimit);
|
|
30135
30191
|
const shouldExposeHead = opts.exposeHeadRoute ?? globalExposeHeadRoutes;
|
|
@@ -30138,22 +30194,22 @@ var require_route = __commonJS({
|
|
|
30138
30194
|
if (Array.isArray(opts.method)) {
|
|
30139
30195
|
for (let i = 0; i < opts.method.length; ++i) {
|
|
30140
30196
|
opts.method[i] = normalizeAndValidateMethod.call(this, opts.method[i]);
|
|
30141
|
-
validateSchemaBodyOption.call(this, opts.method[i],
|
|
30197
|
+
validateSchemaBodyOption.call(this, opts.method[i], path7, opts.schema);
|
|
30142
30198
|
isGetRoute = opts.method.includes("GET");
|
|
30143
30199
|
isHeadRoute = opts.method.includes("HEAD");
|
|
30144
30200
|
}
|
|
30145
30201
|
} else {
|
|
30146
30202
|
opts.method = normalizeAndValidateMethod.call(this, opts.method);
|
|
30147
|
-
validateSchemaBodyOption.call(this, opts.method,
|
|
30203
|
+
validateSchemaBodyOption.call(this, opts.method, path7, opts.schema);
|
|
30148
30204
|
isGetRoute = opts.method === "GET";
|
|
30149
30205
|
isHeadRoute = opts.method === "HEAD";
|
|
30150
30206
|
}
|
|
30151
30207
|
const headOpts = shouldExposeHead && isGetRoute ? { ...options2 } : null;
|
|
30152
30208
|
const prefix = this[kRoutePrefix];
|
|
30153
|
-
if (
|
|
30209
|
+
if (path7 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
|
|
30154
30210
|
switch (opts.prefixTrailingSlash) {
|
|
30155
30211
|
case "slash":
|
|
30156
|
-
addNewRoute.call(this, { path:
|
|
30212
|
+
addNewRoute.call(this, { path: path7, isFastify });
|
|
30157
30213
|
break;
|
|
30158
30214
|
case "no-slash":
|
|
30159
30215
|
addNewRoute.call(this, { path: "", isFastify });
|
|
@@ -30162,20 +30218,20 @@ var require_route = __commonJS({
|
|
|
30162
30218
|
default:
|
|
30163
30219
|
addNewRoute.call(this, { path: "", isFastify });
|
|
30164
30220
|
if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith("/"))) {
|
|
30165
|
-
addNewRoute.call(this, { path:
|
|
30221
|
+
addNewRoute.call(this, { path: path7, prefixing: true, isFastify });
|
|
30166
30222
|
}
|
|
30167
30223
|
}
|
|
30168
|
-
} else if (
|
|
30169
|
-
addNewRoute.call(this, { path:
|
|
30224
|
+
} else if (path7[0] === "/" && prefix.endsWith("/")) {
|
|
30225
|
+
addNewRoute.call(this, { path: path7.slice(1), isFastify });
|
|
30170
30226
|
} else {
|
|
30171
|
-
addNewRoute.call(this, { path:
|
|
30227
|
+
addNewRoute.call(this, { path: path7, isFastify });
|
|
30172
30228
|
}
|
|
30173
30229
|
return this;
|
|
30174
|
-
function addNewRoute({ path:
|
|
30175
|
-
const url = prefix +
|
|
30230
|
+
function addNewRoute({ path: path8, prefixing = false, isFastify: isFastify2 = false }) {
|
|
30231
|
+
const url = prefix + path8;
|
|
30176
30232
|
opts.url = url;
|
|
30177
30233
|
opts.path = url;
|
|
30178
|
-
opts.routePath =
|
|
30234
|
+
opts.routePath = path8;
|
|
30179
30235
|
opts.prefix = prefix;
|
|
30180
30236
|
opts.logLevel = opts.logLevel || this[kLogLevel];
|
|
30181
30237
|
if (this[kLogSerializers] || opts.logSerializers) {
|
|
@@ -30299,7 +30355,7 @@ var require_route = __commonJS({
|
|
|
30299
30355
|
});
|
|
30300
30356
|
if (shouldExposeHead && isGetRoute && !isHeadRoute && !hasHEADHandler) {
|
|
30301
30357
|
const onSendHandlers = parseHeadOnSendHandlers(headOpts.onSend);
|
|
30302
|
-
prepareRoute.call(this, { method: "HEAD", url:
|
|
30358
|
+
prepareRoute.call(this, { method: "HEAD", url: path8, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
|
|
30303
30359
|
}
|
|
30304
30360
|
}
|
|
30305
30361
|
}
|
|
@@ -30400,9 +30456,9 @@ var require_route = __commonJS({
|
|
|
30400
30456
|
}
|
|
30401
30457
|
return method;
|
|
30402
30458
|
}
|
|
30403
|
-
function validateSchemaBodyOption(method,
|
|
30459
|
+
function validateSchemaBodyOption(method, path7, schema) {
|
|
30404
30460
|
if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
|
|
30405
|
-
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method,
|
|
30461
|
+
throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path7);
|
|
30406
30462
|
}
|
|
30407
30463
|
}
|
|
30408
30464
|
function validateBodyLimitOption(bodyLimit) {
|
|
@@ -30481,7 +30537,7 @@ var require_fourOhFour = __commonJS({
|
|
|
30481
30537
|
});
|
|
30482
30538
|
}
|
|
30483
30539
|
function createOnBadUrl() {
|
|
30484
|
-
return function onBadUrl(
|
|
30540
|
+
return function onBadUrl(path7, req, res) {
|
|
30485
30541
|
const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext];
|
|
30486
30542
|
const id = getGenReqId(fourOhFourContext.server, req);
|
|
30487
30543
|
const childLogger = createChildLogger(fourOhFourContext, logger, req, id);
|
|
@@ -34198,7 +34254,7 @@ ${body}`);
|
|
|
34198
34254
|
}
|
|
34199
34255
|
fourOhFour.router.lookup(req, res);
|
|
34200
34256
|
}
|
|
34201
|
-
function onBadUrl(
|
|
34257
|
+
function onBadUrl(path7, req, res) {
|
|
34202
34258
|
if (frameworkErrors) {
|
|
34203
34259
|
const id = getGenReqId(onBadUrlContext.server, req);
|
|
34204
34260
|
const childLogger = createChildLogger(onBadUrlContext, logger, req, id);
|
|
@@ -34207,9 +34263,9 @@ ${body}`);
|
|
|
34207
34263
|
if (disableRequestLogging === false) {
|
|
34208
34264
|
childLogger.info({ req: request }, "incoming request");
|
|
34209
34265
|
}
|
|
34210
|
-
return frameworkErrors(new FST_ERR_BAD_URL(
|
|
34266
|
+
return frameworkErrors(new FST_ERR_BAD_URL(path7), request, reply);
|
|
34211
34267
|
}
|
|
34212
|
-
const body = `{"error":"Bad Request","code":"FST_ERR_BAD_URL","message":"'${
|
|
34268
|
+
const body = `{"error":"Bad Request","code":"FST_ERR_BAD_URL","message":"'${path7}' is not a valid url component","statusCode":400}`;
|
|
34213
34269
|
res.writeHead(400, {
|
|
34214
34270
|
"Content-Type": "application/json",
|
|
34215
34271
|
"Content-Length": body.length
|
|
@@ -34838,8 +34894,8 @@ var require_package2 = __commonJS({
|
|
|
34838
34894
|
// node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js
|
|
34839
34895
|
var require_main = __commonJS({
|
|
34840
34896
|
"node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
|
|
34841
|
-
var
|
|
34842
|
-
var
|
|
34897
|
+
var fs7 = require("fs");
|
|
34898
|
+
var path7 = require("path");
|
|
34843
34899
|
var os2 = require("os");
|
|
34844
34900
|
var crypto2 = require("crypto");
|
|
34845
34901
|
var packageJson = require_package2();
|
|
@@ -34947,7 +35003,7 @@ var require_main = __commonJS({
|
|
|
34947
35003
|
if (options && options.path && options.path.length > 0) {
|
|
34948
35004
|
if (Array.isArray(options.path)) {
|
|
34949
35005
|
for (const filepath of options.path) {
|
|
34950
|
-
if (
|
|
35006
|
+
if (fs7.existsSync(filepath)) {
|
|
34951
35007
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
34952
35008
|
}
|
|
34953
35009
|
}
|
|
@@ -34955,15 +35011,15 @@ var require_main = __commonJS({
|
|
|
34955
35011
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
34956
35012
|
}
|
|
34957
35013
|
} else {
|
|
34958
|
-
possibleVaultPath =
|
|
35014
|
+
possibleVaultPath = path7.resolve(process.cwd(), ".env.vault");
|
|
34959
35015
|
}
|
|
34960
|
-
if (
|
|
35016
|
+
if (fs7.existsSync(possibleVaultPath)) {
|
|
34961
35017
|
return possibleVaultPath;
|
|
34962
35018
|
}
|
|
34963
35019
|
return null;
|
|
34964
35020
|
}
|
|
34965
35021
|
function _resolveHome(envPath) {
|
|
34966
|
-
return envPath[0] === "~" ?
|
|
35022
|
+
return envPath[0] === "~" ? path7.join(os2.homedir(), envPath.slice(1)) : envPath;
|
|
34967
35023
|
}
|
|
34968
35024
|
function _configVault(options) {
|
|
34969
35025
|
const debug = Boolean(options && options.debug);
|
|
@@ -34980,7 +35036,7 @@ var require_main = __commonJS({
|
|
|
34980
35036
|
return { parsed };
|
|
34981
35037
|
}
|
|
34982
35038
|
function configDotenv(options) {
|
|
34983
|
-
const dotenvPath =
|
|
35039
|
+
const dotenvPath = path7.resolve(process.cwd(), ".env");
|
|
34984
35040
|
let encoding = "utf8";
|
|
34985
35041
|
const debug = Boolean(options && options.debug);
|
|
34986
35042
|
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
@@ -35004,13 +35060,13 @@ var require_main = __commonJS({
|
|
|
35004
35060
|
}
|
|
35005
35061
|
let lastError;
|
|
35006
35062
|
const parsedAll = {};
|
|
35007
|
-
for (const
|
|
35063
|
+
for (const path8 of optionPaths) {
|
|
35008
35064
|
try {
|
|
35009
|
-
const parsed = DotenvModule.parse(
|
|
35065
|
+
const parsed = DotenvModule.parse(fs7.readFileSync(path8, { encoding }));
|
|
35010
35066
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
35011
35067
|
} catch (e) {
|
|
35012
35068
|
if (debug) {
|
|
35013
|
-
_debug(`Failed to load ${
|
|
35069
|
+
_debug(`Failed to load ${path8} ${e.message}`);
|
|
35014
35070
|
}
|
|
35015
35071
|
lastError = e;
|
|
35016
35072
|
}
|
|
@@ -35025,7 +35081,7 @@ var require_main = __commonJS({
|
|
|
35025
35081
|
const shortPaths = [];
|
|
35026
35082
|
for (const filePath of optionPaths) {
|
|
35027
35083
|
try {
|
|
35028
|
-
const relative =
|
|
35084
|
+
const relative = path7.relative(process.cwd(), filePath);
|
|
35029
35085
|
shortPaths.push(relative);
|
|
35030
35086
|
} catch (e) {
|
|
35031
35087
|
if (debug) {
|
|
@@ -36039,14 +36095,14 @@ var require_util4 = __commonJS({
|
|
|
36039
36095
|
}
|
|
36040
36096
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
36041
36097
|
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
36042
|
-
let
|
|
36098
|
+
let path7 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
36043
36099
|
if (origin[origin.length - 1] === "/") {
|
|
36044
36100
|
origin = origin.slice(0, origin.length - 1);
|
|
36045
36101
|
}
|
|
36046
|
-
if (
|
|
36047
|
-
|
|
36102
|
+
if (path7 && path7[0] !== "/") {
|
|
36103
|
+
path7 = `/${path7}`;
|
|
36048
36104
|
}
|
|
36049
|
-
return new URL(`${origin}${
|
|
36105
|
+
return new URL(`${origin}${path7}`);
|
|
36050
36106
|
}
|
|
36051
36107
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
36052
36108
|
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -36594,9 +36650,9 @@ var require_diagnostics = __commonJS({
|
|
|
36594
36650
|
"undici:client:sendHeaders",
|
|
36595
36651
|
(evt) => {
|
|
36596
36652
|
const {
|
|
36597
|
-
request: { method, path:
|
|
36653
|
+
request: { method, path: path7, origin }
|
|
36598
36654
|
} = evt;
|
|
36599
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
36655
|
+
debugLog("sending request to %s %s%s", method, origin, path7);
|
|
36600
36656
|
}
|
|
36601
36657
|
);
|
|
36602
36658
|
}
|
|
@@ -36610,14 +36666,14 @@ var require_diagnostics = __commonJS({
|
|
|
36610
36666
|
"undici:request:headers",
|
|
36611
36667
|
(evt) => {
|
|
36612
36668
|
const {
|
|
36613
|
-
request: { method, path:
|
|
36669
|
+
request: { method, path: path7, origin },
|
|
36614
36670
|
response: { statusCode }
|
|
36615
36671
|
} = evt;
|
|
36616
36672
|
debugLog(
|
|
36617
36673
|
"received response to %s %s%s - HTTP %d",
|
|
36618
36674
|
method,
|
|
36619
36675
|
origin,
|
|
36620
|
-
|
|
36676
|
+
path7,
|
|
36621
36677
|
statusCode
|
|
36622
36678
|
);
|
|
36623
36679
|
}
|
|
@@ -36626,23 +36682,23 @@ var require_diagnostics = __commonJS({
|
|
|
36626
36682
|
"undici:request:trailers",
|
|
36627
36683
|
(evt) => {
|
|
36628
36684
|
const {
|
|
36629
|
-
request: { method, path:
|
|
36685
|
+
request: { method, path: path7, origin }
|
|
36630
36686
|
} = evt;
|
|
36631
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
36687
|
+
debugLog("trailers received from %s %s%s", method, origin, path7);
|
|
36632
36688
|
}
|
|
36633
36689
|
);
|
|
36634
36690
|
diagnosticsChannel.subscribe(
|
|
36635
36691
|
"undici:request:error",
|
|
36636
36692
|
(evt) => {
|
|
36637
36693
|
const {
|
|
36638
|
-
request: { method, path:
|
|
36694
|
+
request: { method, path: path7, origin },
|
|
36639
36695
|
error
|
|
36640
36696
|
} = evt;
|
|
36641
36697
|
debugLog(
|
|
36642
36698
|
"request to %s %s%s errored - %s",
|
|
36643
36699
|
method,
|
|
36644
36700
|
origin,
|
|
36645
|
-
|
|
36701
|
+
path7,
|
|
36646
36702
|
error.message
|
|
36647
36703
|
);
|
|
36648
36704
|
}
|
|
@@ -36737,7 +36793,7 @@ var require_request3 = __commonJS({
|
|
|
36737
36793
|
var kHandler = Symbol("handler");
|
|
36738
36794
|
var Request = class {
|
|
36739
36795
|
constructor(origin, {
|
|
36740
|
-
path:
|
|
36796
|
+
path: path7,
|
|
36741
36797
|
method,
|
|
36742
36798
|
body,
|
|
36743
36799
|
headers,
|
|
@@ -36752,11 +36808,11 @@ var require_request3 = __commonJS({
|
|
|
36752
36808
|
servername,
|
|
36753
36809
|
throwOnError
|
|
36754
36810
|
}, handler) {
|
|
36755
|
-
if (typeof
|
|
36811
|
+
if (typeof path7 !== "string") {
|
|
36756
36812
|
throw new InvalidArgumentError("path must be a string");
|
|
36757
|
-
} else if (
|
|
36813
|
+
} else if (path7[0] !== "/" && !(path7.startsWith("http://") || path7.startsWith("https://")) && method !== "CONNECT") {
|
|
36758
36814
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
36759
|
-
} else if (invalidPathRegex.test(
|
|
36815
|
+
} else if (invalidPathRegex.test(path7)) {
|
|
36760
36816
|
throw new InvalidArgumentError("invalid request path");
|
|
36761
36817
|
}
|
|
36762
36818
|
if (typeof method !== "string") {
|
|
@@ -36821,7 +36877,7 @@ var require_request3 = __commonJS({
|
|
|
36821
36877
|
this.completed = false;
|
|
36822
36878
|
this.aborted = false;
|
|
36823
36879
|
this.upgrade = upgrade || null;
|
|
36824
|
-
this.path = query ? serializePathWithQuery(
|
|
36880
|
+
this.path = query ? serializePathWithQuery(path7, query) : path7;
|
|
36825
36881
|
this.origin = origin;
|
|
36826
36882
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
36827
36883
|
this.blocking = blocking ?? this.method !== "HEAD";
|
|
@@ -41598,7 +41654,7 @@ var require_client_h1 = __commonJS({
|
|
|
41598
41654
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
41599
41655
|
}
|
|
41600
41656
|
function writeH1(client, request) {
|
|
41601
|
-
const { method, path:
|
|
41657
|
+
const { method, path: path7, host, upgrade, blocking, reset } = request;
|
|
41602
41658
|
let { body, headers, contentLength } = request;
|
|
41603
41659
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
41604
41660
|
if (util.isFormDataLike(body)) {
|
|
@@ -41664,7 +41720,7 @@ var require_client_h1 = __commonJS({
|
|
|
41664
41720
|
if (blocking) {
|
|
41665
41721
|
socket[kBlocking] = true;
|
|
41666
41722
|
}
|
|
41667
|
-
let header = `${method} ${
|
|
41723
|
+
let header = `${method} ${path7} HTTP/1.1\r
|
|
41668
41724
|
`;
|
|
41669
41725
|
if (typeof host === "string") {
|
|
41670
41726
|
header += `host: ${host}\r
|
|
@@ -42221,7 +42277,7 @@ var require_client_h2 = __commonJS({
|
|
|
42221
42277
|
function writeH2(client, request) {
|
|
42222
42278
|
const requestTimeout = request.bodyTimeout ?? client[kBodyTimeout];
|
|
42223
42279
|
const session = client[kHTTP2Session];
|
|
42224
|
-
const { method, path:
|
|
42280
|
+
const { method, path: path7, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
|
|
42225
42281
|
let { body } = request;
|
|
42226
42282
|
if (upgrade) {
|
|
42227
42283
|
util.errorRequest(client, request, new Error("Upgrade not supported for H2"));
|
|
@@ -42292,7 +42348,7 @@ var require_client_h2 = __commonJS({
|
|
|
42292
42348
|
stream.setTimeout(requestTimeout);
|
|
42293
42349
|
return true;
|
|
42294
42350
|
}
|
|
42295
|
-
headers[HTTP2_HEADER_PATH] =
|
|
42351
|
+
headers[HTTP2_HEADER_PATH] = path7;
|
|
42296
42352
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
42297
42353
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
42298
42354
|
if (body && typeof body.read === "function") {
|
|
@@ -45819,20 +45875,20 @@ var require_mock_utils = __commonJS({
|
|
|
45819
45875
|
}
|
|
45820
45876
|
return normalizedQp;
|
|
45821
45877
|
}
|
|
45822
|
-
function safeUrl(
|
|
45823
|
-
if (typeof
|
|
45824
|
-
return
|
|
45878
|
+
function safeUrl(path7) {
|
|
45879
|
+
if (typeof path7 !== "string") {
|
|
45880
|
+
return path7;
|
|
45825
45881
|
}
|
|
45826
|
-
const pathSegments =
|
|
45882
|
+
const pathSegments = path7.split("?", 3);
|
|
45827
45883
|
if (pathSegments.length !== 2) {
|
|
45828
|
-
return
|
|
45884
|
+
return path7;
|
|
45829
45885
|
}
|
|
45830
45886
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
45831
45887
|
qp.sort();
|
|
45832
45888
|
return [...pathSegments, qp.toString()].join("?");
|
|
45833
45889
|
}
|
|
45834
|
-
function matchKey(mockDispatch2, { path:
|
|
45835
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
45890
|
+
function matchKey(mockDispatch2, { path: path7, method, body, headers }) {
|
|
45891
|
+
const pathMatch = matchValue(mockDispatch2.path, path7);
|
|
45836
45892
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
45837
45893
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
45838
45894
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -45857,8 +45913,8 @@ var require_mock_utils = __commonJS({
|
|
|
45857
45913
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
45858
45914
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
45859
45915
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
45860
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
45861
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
45916
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path7, ignoreTrailingSlash }) => {
|
|
45917
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path7)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path7), resolvedPath);
|
|
45862
45918
|
});
|
|
45863
45919
|
if (matchedMockDispatches.length === 0) {
|
|
45864
45920
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -45896,19 +45952,19 @@ var require_mock_utils = __commonJS({
|
|
|
45896
45952
|
mockDispatches.splice(index, 1);
|
|
45897
45953
|
}
|
|
45898
45954
|
}
|
|
45899
|
-
function removeTrailingSlash(
|
|
45900
|
-
while (
|
|
45901
|
-
|
|
45955
|
+
function removeTrailingSlash(path7) {
|
|
45956
|
+
while (path7.endsWith("/")) {
|
|
45957
|
+
path7 = path7.slice(0, -1);
|
|
45902
45958
|
}
|
|
45903
|
-
if (
|
|
45904
|
-
|
|
45959
|
+
if (path7.length === 0) {
|
|
45960
|
+
path7 = "/";
|
|
45905
45961
|
}
|
|
45906
|
-
return
|
|
45962
|
+
return path7;
|
|
45907
45963
|
}
|
|
45908
45964
|
function buildKey(opts) {
|
|
45909
|
-
const { path:
|
|
45965
|
+
const { path: path7, method, body, headers, query } = opts;
|
|
45910
45966
|
return {
|
|
45911
|
-
path:
|
|
45967
|
+
path: path7,
|
|
45912
45968
|
method,
|
|
45913
45969
|
body,
|
|
45914
45970
|
headers,
|
|
@@ -46223,7 +46279,7 @@ var require_mock_interceptor = __commonJS({
|
|
|
46223
46279
|
var require_mock_client = __commonJS({
|
|
46224
46280
|
"node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-client.js"(exports2, module2) {
|
|
46225
46281
|
"use strict";
|
|
46226
|
-
var { promisify } = require("node:util");
|
|
46282
|
+
var { promisify: promisify2 } = require("node:util");
|
|
46227
46283
|
var Client = require_client();
|
|
46228
46284
|
var { buildMockDispatch } = require_mock_utils();
|
|
46229
46285
|
var {
|
|
@@ -46271,7 +46327,7 @@ var require_mock_client = __commonJS({
|
|
|
46271
46327
|
this[kDispatches] = [];
|
|
46272
46328
|
}
|
|
46273
46329
|
async [kClose]() {
|
|
46274
|
-
await
|
|
46330
|
+
await promisify2(this[kOriginalClose])();
|
|
46275
46331
|
this[kConnected] = 0;
|
|
46276
46332
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
46277
46333
|
}
|
|
@@ -46484,7 +46540,7 @@ var require_mock_call_history = __commonJS({
|
|
|
46484
46540
|
var require_mock_pool = __commonJS({
|
|
46485
46541
|
"node_modules/.pnpm/undici@7.11.0/node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
|
|
46486
46542
|
"use strict";
|
|
46487
|
-
var { promisify } = require("node:util");
|
|
46543
|
+
var { promisify: promisify2 } = require("node:util");
|
|
46488
46544
|
var Pool = require_pool();
|
|
46489
46545
|
var { buildMockDispatch } = require_mock_utils();
|
|
46490
46546
|
var {
|
|
@@ -46532,7 +46588,7 @@ var require_mock_pool = __commonJS({
|
|
|
46532
46588
|
this[kDispatches] = [];
|
|
46533
46589
|
}
|
|
46534
46590
|
async [kClose]() {
|
|
46535
|
-
await
|
|
46591
|
+
await promisify2(this[kOriginalClose])();
|
|
46536
46592
|
this[kConnected] = 0;
|
|
46537
46593
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
46538
46594
|
}
|
|
@@ -46565,10 +46621,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
46565
46621
|
}
|
|
46566
46622
|
format(pendingInterceptors) {
|
|
46567
46623
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
46568
|
-
({ method, path:
|
|
46624
|
+
({ method, path: path7, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
46569
46625
|
Method: method,
|
|
46570
46626
|
Origin: origin,
|
|
46571
|
-
Path:
|
|
46627
|
+
Path: path7,
|
|
46572
46628
|
"Status code": statusCode,
|
|
46573
46629
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
46574
46630
|
Invocations: timesInvoked,
|
|
@@ -46645,9 +46701,9 @@ var require_mock_agent = __commonJS({
|
|
|
46645
46701
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
46646
46702
|
const dispatchOpts = { ...opts };
|
|
46647
46703
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
46648
|
-
const [
|
|
46704
|
+
const [path7, searchParams] = dispatchOpts.path.split("?");
|
|
46649
46705
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
46650
|
-
dispatchOpts.path = `${
|
|
46706
|
+
dispatchOpts.path = `${path7}?${normalizedSearchParams}`;
|
|
46651
46707
|
}
|
|
46652
46708
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
46653
46709
|
}
|
|
@@ -46941,9 +46997,9 @@ var require_redirect_handler = __commonJS({
|
|
|
46941
46997
|
return;
|
|
46942
46998
|
}
|
|
46943
46999
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
46944
|
-
const
|
|
47000
|
+
const path7 = search ? `${pathname}${search}` : pathname;
|
|
46945
47001
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
46946
|
-
this.opts.path =
|
|
47002
|
+
this.opts.path = path7;
|
|
46947
47003
|
this.opts.origin = origin;
|
|
46948
47004
|
this.opts.maxRedirections = 0;
|
|
46949
47005
|
this.opts.query = null;
|
|
@@ -52627,9 +52683,9 @@ var require_util7 = __commonJS({
|
|
|
52627
52683
|
}
|
|
52628
52684
|
}
|
|
52629
52685
|
}
|
|
52630
|
-
function validateCookiePath(
|
|
52631
|
-
for (let i = 0; i <
|
|
52632
|
-
const code =
|
|
52686
|
+
function validateCookiePath(path7) {
|
|
52687
|
+
for (let i = 0; i < path7.length; ++i) {
|
|
52688
|
+
const code = path7.charCodeAt(i);
|
|
52633
52689
|
if (code < 32 || // exclude CTLs (0-31)
|
|
52634
52690
|
code === 127 || // DEL
|
|
52635
52691
|
code === 59) {
|
|
@@ -55669,11 +55725,11 @@ var require_undici = __commonJS({
|
|
|
55669
55725
|
if (typeof opts.path !== "string") {
|
|
55670
55726
|
throw new InvalidArgumentError("invalid opts.path");
|
|
55671
55727
|
}
|
|
55672
|
-
let
|
|
55728
|
+
let path7 = opts.path;
|
|
55673
55729
|
if (!opts.path.startsWith("/")) {
|
|
55674
|
-
|
|
55730
|
+
path7 = `/${path7}`;
|
|
55675
55731
|
}
|
|
55676
|
-
url = new URL(util.parseOrigin(url).origin +
|
|
55732
|
+
url = new URL(util.parseOrigin(url).origin + path7);
|
|
55677
55733
|
} else {
|
|
55678
55734
|
if (!opts) {
|
|
55679
55735
|
opts = typeof url === "object" ? url : {};
|
|
@@ -56709,11 +56765,11 @@ var require_commonjs3 = __commonJS({
|
|
|
56709
56765
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
56710
56766
|
};
|
|
56711
56767
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
56712
|
-
var
|
|
56768
|
+
var path7 = {
|
|
56713
56769
|
win32: { sep: "\\" },
|
|
56714
56770
|
posix: { sep: "/" }
|
|
56715
56771
|
};
|
|
56716
|
-
exports2.sep = defaultPlatform === "win32" ?
|
|
56772
|
+
exports2.sep = defaultPlatform === "win32" ? path7.win32.sep : path7.posix.sep;
|
|
56717
56773
|
exports2.minimatch.sep = exports2.sep;
|
|
56718
56774
|
exports2.GLOBSTAR = Symbol("globstar **");
|
|
56719
56775
|
exports2.minimatch.GLOBSTAR = exports2.GLOBSTAR;
|
|
@@ -59981,12 +60037,12 @@ var require_commonjs6 = __commonJS({
|
|
|
59981
60037
|
/**
|
|
59982
60038
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
59983
60039
|
*/
|
|
59984
|
-
resolve(
|
|
59985
|
-
if (!
|
|
60040
|
+
resolve(path7) {
|
|
60041
|
+
if (!path7) {
|
|
59986
60042
|
return this;
|
|
59987
60043
|
}
|
|
59988
|
-
const rootPath = this.getRootString(
|
|
59989
|
-
const dir =
|
|
60044
|
+
const rootPath = this.getRootString(path7);
|
|
60045
|
+
const dir = path7.substring(rootPath.length);
|
|
59990
60046
|
const dirParts = dir.split(this.splitSep);
|
|
59991
60047
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
59992
60048
|
return result;
|
|
@@ -60739,8 +60795,8 @@ var require_commonjs6 = __commonJS({
|
|
|
60739
60795
|
/**
|
|
60740
60796
|
* @internal
|
|
60741
60797
|
*/
|
|
60742
|
-
getRootString(
|
|
60743
|
-
return node_path_1.win32.parse(
|
|
60798
|
+
getRootString(path7) {
|
|
60799
|
+
return node_path_1.win32.parse(path7).root;
|
|
60744
60800
|
}
|
|
60745
60801
|
/**
|
|
60746
60802
|
* @internal
|
|
@@ -60787,8 +60843,8 @@ var require_commonjs6 = __commonJS({
|
|
|
60787
60843
|
/**
|
|
60788
60844
|
* @internal
|
|
60789
60845
|
*/
|
|
60790
|
-
getRootString(
|
|
60791
|
-
return
|
|
60846
|
+
getRootString(path7) {
|
|
60847
|
+
return path7.startsWith("/") ? "/" : "";
|
|
60792
60848
|
}
|
|
60793
60849
|
/**
|
|
60794
60850
|
* @internal
|
|
@@ -60838,8 +60894,8 @@ var require_commonjs6 = __commonJS({
|
|
|
60838
60894
|
*
|
|
60839
60895
|
* @internal
|
|
60840
60896
|
*/
|
|
60841
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
60842
|
-
this.#fs = fsFromOption(
|
|
60897
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs7 = defaultFS } = {}) {
|
|
60898
|
+
this.#fs = fsFromOption(fs7);
|
|
60843
60899
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
60844
60900
|
cwd = (0, node_url_1.fileURLToPath)(cwd);
|
|
60845
60901
|
}
|
|
@@ -60878,11 +60934,11 @@ var require_commonjs6 = __commonJS({
|
|
|
60878
60934
|
/**
|
|
60879
60935
|
* Get the depth of a provided path, string, or the cwd
|
|
60880
60936
|
*/
|
|
60881
|
-
depth(
|
|
60882
|
-
if (typeof
|
|
60883
|
-
|
|
60937
|
+
depth(path7 = this.cwd) {
|
|
60938
|
+
if (typeof path7 === "string") {
|
|
60939
|
+
path7 = this.cwd.resolve(path7);
|
|
60884
60940
|
}
|
|
60885
|
-
return
|
|
60941
|
+
return path7.depth();
|
|
60886
60942
|
}
|
|
60887
60943
|
/**
|
|
60888
60944
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -61369,9 +61425,9 @@ var require_commonjs6 = __commonJS({
|
|
|
61369
61425
|
process2();
|
|
61370
61426
|
return results;
|
|
61371
61427
|
}
|
|
61372
|
-
chdir(
|
|
61428
|
+
chdir(path7 = this.cwd) {
|
|
61373
61429
|
const oldCwd = this.cwd;
|
|
61374
|
-
this.cwd = typeof
|
|
61430
|
+
this.cwd = typeof path7 === "string" ? this.cwd.resolve(path7) : path7;
|
|
61375
61431
|
this.cwd[setAsCwd](oldCwd);
|
|
61376
61432
|
}
|
|
61377
61433
|
};
|
|
@@ -61398,8 +61454,8 @@ var require_commonjs6 = __commonJS({
|
|
|
61398
61454
|
/**
|
|
61399
61455
|
* @internal
|
|
61400
61456
|
*/
|
|
61401
|
-
newRoot(
|
|
61402
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
61457
|
+
newRoot(fs7) {
|
|
61458
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
|
|
61403
61459
|
}
|
|
61404
61460
|
/**
|
|
61405
61461
|
* Return true if the provided path string is an absolute path
|
|
@@ -61428,8 +61484,8 @@ var require_commonjs6 = __commonJS({
|
|
|
61428
61484
|
/**
|
|
61429
61485
|
* @internal
|
|
61430
61486
|
*/
|
|
61431
|
-
newRoot(
|
|
61432
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
61487
|
+
newRoot(fs7) {
|
|
61488
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
|
|
61433
61489
|
}
|
|
61434
61490
|
/**
|
|
61435
61491
|
* Return true if the provided path string is an absolute path
|
|
@@ -61759,8 +61815,8 @@ var require_processor = __commonJS({
|
|
|
61759
61815
|
}
|
|
61760
61816
|
// match, absolute, ifdir
|
|
61761
61817
|
entries() {
|
|
61762
|
-
return [...this.store.entries()].map(([
|
|
61763
|
-
|
|
61818
|
+
return [...this.store.entries()].map(([path7, n]) => [
|
|
61819
|
+
path7,
|
|
61764
61820
|
!!(n & 2),
|
|
61765
61821
|
!!(n & 1)
|
|
61766
61822
|
]);
|
|
@@ -61978,9 +62034,9 @@ var require_walker = __commonJS({
|
|
|
61978
62034
|
signal;
|
|
61979
62035
|
maxDepth;
|
|
61980
62036
|
includeChildMatches;
|
|
61981
|
-
constructor(patterns,
|
|
62037
|
+
constructor(patterns, path7, opts) {
|
|
61982
62038
|
this.patterns = patterns;
|
|
61983
|
-
this.path =
|
|
62039
|
+
this.path = path7;
|
|
61984
62040
|
this.opts = opts;
|
|
61985
62041
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
61986
62042
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -61999,11 +62055,11 @@ var require_walker = __commonJS({
|
|
|
61999
62055
|
});
|
|
62000
62056
|
}
|
|
62001
62057
|
}
|
|
62002
|
-
#ignored(
|
|
62003
|
-
return this.seen.has(
|
|
62058
|
+
#ignored(path7) {
|
|
62059
|
+
return this.seen.has(path7) || !!this.#ignore?.ignored?.(path7);
|
|
62004
62060
|
}
|
|
62005
|
-
#childrenIgnored(
|
|
62006
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
62061
|
+
#childrenIgnored(path7) {
|
|
62062
|
+
return !!this.#ignore?.childrenIgnored?.(path7);
|
|
62007
62063
|
}
|
|
62008
62064
|
// backpressure mechanism
|
|
62009
62065
|
pause() {
|
|
@@ -62219,8 +62275,8 @@ var require_walker = __commonJS({
|
|
|
62219
62275
|
exports2.GlobUtil = GlobUtil;
|
|
62220
62276
|
var GlobWalker = class extends GlobUtil {
|
|
62221
62277
|
matches = /* @__PURE__ */ new Set();
|
|
62222
|
-
constructor(patterns,
|
|
62223
|
-
super(patterns,
|
|
62278
|
+
constructor(patterns, path7, opts) {
|
|
62279
|
+
super(patterns, path7, opts);
|
|
62224
62280
|
}
|
|
62225
62281
|
matchEmit(e) {
|
|
62226
62282
|
this.matches.add(e);
|
|
@@ -62258,8 +62314,8 @@ var require_walker = __commonJS({
|
|
|
62258
62314
|
exports2.GlobWalker = GlobWalker;
|
|
62259
62315
|
var GlobStream = class extends GlobUtil {
|
|
62260
62316
|
results;
|
|
62261
|
-
constructor(patterns,
|
|
62262
|
-
super(patterns,
|
|
62317
|
+
constructor(patterns, path7, opts) {
|
|
62318
|
+
super(patterns, path7, opts);
|
|
62263
62319
|
this.results = new minipass_1.Minipass({
|
|
62264
62320
|
signal: this.signal,
|
|
62265
62321
|
objectMode: true
|
|
@@ -62661,11 +62717,11 @@ var require_Mime = __commonJS({
|
|
|
62661
62717
|
}
|
|
62662
62718
|
}
|
|
62663
62719
|
};
|
|
62664
|
-
Mime.prototype.getType = function(
|
|
62665
|
-
|
|
62666
|
-
let last =
|
|
62720
|
+
Mime.prototype.getType = function(path7) {
|
|
62721
|
+
path7 = String(path7);
|
|
62722
|
+
let last = path7.replace(/^.*[/\\]/, "").toLowerCase();
|
|
62667
62723
|
let ext = last.replace(/^.*\./, "").toLowerCase();
|
|
62668
|
-
let hasPath = last.length <
|
|
62724
|
+
let hasPath = last.length < path7.length;
|
|
62669
62725
|
let hasDot = ext.length < last.length - 1;
|
|
62670
62726
|
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
62671
62727
|
};
|
|
@@ -63694,8 +63750,8 @@ var require_createHttpError = __commonJS({
|
|
|
63694
63750
|
var require_send = __commonJS({
|
|
63695
63751
|
"node_modules/.pnpm/@fastify+send@4.1.0/node_modules/@fastify/send/lib/send.js"(exports2, module2) {
|
|
63696
63752
|
"use strict";
|
|
63697
|
-
var
|
|
63698
|
-
var
|
|
63753
|
+
var fs7 = require("node:fs");
|
|
63754
|
+
var path7 = require("node:path");
|
|
63699
63755
|
var stream = require("node:stream");
|
|
63700
63756
|
var debug = require("node:util").debuglog("send");
|
|
63701
63757
|
var decode = require_fast_decode_uri_component();
|
|
@@ -63711,11 +63767,11 @@ var require_send = __commonJS({
|
|
|
63711
63767
|
var { parseBytesRange } = require_parseBytesRange();
|
|
63712
63768
|
var { parseTokenList } = require_parseTokenList();
|
|
63713
63769
|
var { createHttpError } = require_createHttpError();
|
|
63714
|
-
var extname =
|
|
63715
|
-
var join5 =
|
|
63716
|
-
var normalize =
|
|
63717
|
-
var resolve =
|
|
63718
|
-
var sep2 =
|
|
63770
|
+
var extname = path7.extname;
|
|
63771
|
+
var join5 = path7.join;
|
|
63772
|
+
var normalize = path7.normalize;
|
|
63773
|
+
var resolve = path7.resolve;
|
|
63774
|
+
var sep2 = path7.sep;
|
|
63719
63775
|
var Readable = stream.Readable;
|
|
63720
63776
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
63721
63777
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
@@ -63782,36 +63838,36 @@ var require_send = __commonJS({
|
|
|
63782
63838
|
};
|
|
63783
63839
|
}
|
|
63784
63840
|
function normalizePath(_path, root) {
|
|
63785
|
-
let
|
|
63786
|
-
if (
|
|
63841
|
+
let path8 = decode(_path);
|
|
63842
|
+
if (path8 == null) {
|
|
63787
63843
|
return { statusCode: 400 };
|
|
63788
63844
|
}
|
|
63789
|
-
if (~
|
|
63845
|
+
if (~path8.indexOf("\0")) {
|
|
63790
63846
|
return { statusCode: 400 };
|
|
63791
63847
|
}
|
|
63792
63848
|
let parts;
|
|
63793
63849
|
if (root !== null) {
|
|
63794
|
-
if (
|
|
63795
|
-
|
|
63850
|
+
if (path8) {
|
|
63851
|
+
path8 = normalize("." + sep2 + path8);
|
|
63796
63852
|
}
|
|
63797
|
-
if (UP_PATH_REGEXP.test(
|
|
63798
|
-
debug('malicious path "%s"',
|
|
63853
|
+
if (UP_PATH_REGEXP.test(path8)) {
|
|
63854
|
+
debug('malicious path "%s"', path8);
|
|
63799
63855
|
return { statusCode: 403 };
|
|
63800
63856
|
}
|
|
63801
|
-
parts =
|
|
63802
|
-
|
|
63857
|
+
parts = path8.split(sep2);
|
|
63858
|
+
path8 = normalize(join5(root, path8));
|
|
63803
63859
|
} else {
|
|
63804
|
-
if (UP_PATH_REGEXP.test(
|
|
63805
|
-
debug('malicious path "%s"',
|
|
63860
|
+
if (UP_PATH_REGEXP.test(path8)) {
|
|
63861
|
+
debug('malicious path "%s"', path8);
|
|
63806
63862
|
return { statusCode: 403 };
|
|
63807
63863
|
}
|
|
63808
|
-
parts = normalize(
|
|
63809
|
-
|
|
63864
|
+
parts = normalize(path8).split(sep2);
|
|
63865
|
+
path8 = resolve(path8);
|
|
63810
63866
|
}
|
|
63811
|
-
return { path:
|
|
63867
|
+
return { path: path8, parts };
|
|
63812
63868
|
}
|
|
63813
|
-
function hasTrailingSlash(
|
|
63814
|
-
return
|
|
63869
|
+
function hasTrailingSlash(path8) {
|
|
63870
|
+
return path8[path8.length - 1] === "/";
|
|
63815
63871
|
}
|
|
63816
63872
|
function isConditionalGET(request) {
|
|
63817
63873
|
return request.headers["if-match"] || request.headers["if-unmodified-since"] || request.headers["if-none-match"] || request.headers["if-modified-since"];
|
|
@@ -63901,9 +63957,9 @@ var require_send = __commonJS({
|
|
|
63901
63957
|
lastModified <= ifRangeTimestamp
|
|
63902
63958
|
);
|
|
63903
63959
|
}
|
|
63904
|
-
function tryStat(
|
|
63960
|
+
function tryStat(path8) {
|
|
63905
63961
|
return new Promise((resolve2) => {
|
|
63906
|
-
|
|
63962
|
+
fs7.stat(path8, function onstat(error, stat2) {
|
|
63907
63963
|
resolve2({ error, stat: stat2 });
|
|
63908
63964
|
});
|
|
63909
63965
|
});
|
|
@@ -63939,7 +63995,7 @@ var require_send = __commonJS({
|
|
|
63939
63995
|
return sendError(500, err);
|
|
63940
63996
|
}
|
|
63941
63997
|
}
|
|
63942
|
-
function sendNotModified(headers,
|
|
63998
|
+
function sendNotModified(headers, path8, stat2) {
|
|
63943
63999
|
debug("not modified");
|
|
63944
64000
|
delete headers["Content-Encoding"];
|
|
63945
64001
|
delete headers["Content-Language"];
|
|
@@ -63952,15 +64008,15 @@ var require_send = __commonJS({
|
|
|
63952
64008
|
stream: Readable.from(""),
|
|
63953
64009
|
// metadata
|
|
63954
64010
|
type: "file",
|
|
63955
|
-
metadata: { path:
|
|
64011
|
+
metadata: { path: path8, stat: stat2 }
|
|
63956
64012
|
};
|
|
63957
64013
|
}
|
|
63958
|
-
function sendFileDirectly(request,
|
|
64014
|
+
function sendFileDirectly(request, path8, stat2, options) {
|
|
63959
64015
|
let len = stat2.size;
|
|
63960
64016
|
let offset = options.start ?? 0;
|
|
63961
64017
|
let statusCode = 200;
|
|
63962
64018
|
const headers = {};
|
|
63963
|
-
debug('send "%s"',
|
|
64019
|
+
debug('send "%s"', path8);
|
|
63964
64020
|
if (options.acceptRanges) {
|
|
63965
64021
|
debug("accept ranges");
|
|
63966
64022
|
headers["Accept-Ranges"] = "bytes";
|
|
@@ -63984,7 +64040,7 @@ var require_send = __commonJS({
|
|
|
63984
64040
|
headers.ETag = etag;
|
|
63985
64041
|
}
|
|
63986
64042
|
if (options.contentType) {
|
|
63987
|
-
let type = mime.getType(
|
|
64043
|
+
let type = mime.getType(path8) || mime.default_type;
|
|
63988
64044
|
debug("content-type %s", type);
|
|
63989
64045
|
if (type && isUtf8MimeType(type)) {
|
|
63990
64046
|
type += "; charset=utf-8";
|
|
@@ -63998,7 +64054,7 @@ var require_send = __commonJS({
|
|
|
63998
64054
|
return sendError(412);
|
|
63999
64055
|
}
|
|
64000
64056
|
if (isNotModifiedFailure(request, headers)) {
|
|
64001
|
-
return sendNotModified(headers,
|
|
64057
|
+
return sendNotModified(headers, path8, stat2);
|
|
64002
64058
|
}
|
|
64003
64059
|
}
|
|
64004
64060
|
len = Math.max(0, len - offset);
|
|
@@ -64040,10 +64096,10 @@ var require_send = __commonJS({
|
|
|
64040
64096
|
stream: Readable.from(""),
|
|
64041
64097
|
// metadata
|
|
64042
64098
|
type: "file",
|
|
64043
|
-
metadata: { path:
|
|
64099
|
+
metadata: { path: path8, stat: stat2 }
|
|
64044
64100
|
};
|
|
64045
64101
|
}
|
|
64046
|
-
const stream2 =
|
|
64102
|
+
const stream2 = fs7.createReadStream(path8, {
|
|
64047
64103
|
highWaterMark: options.highWaterMark,
|
|
64048
64104
|
start: offset,
|
|
64049
64105
|
end: Math.max(offset, offset + len - 1)
|
|
@@ -64054,10 +64110,10 @@ var require_send = __commonJS({
|
|
|
64054
64110
|
stream: stream2,
|
|
64055
64111
|
// metadata
|
|
64056
64112
|
type: "file",
|
|
64057
|
-
metadata: { path:
|
|
64113
|
+
metadata: { path: path8, stat: stat2 }
|
|
64058
64114
|
};
|
|
64059
64115
|
}
|
|
64060
|
-
function sendRedirect(
|
|
64116
|
+
function sendRedirect(path8, options) {
|
|
64061
64117
|
if (hasTrailingSlash(options.path)) {
|
|
64062
64118
|
return sendError(403);
|
|
64063
64119
|
}
|
|
@@ -64075,14 +64131,14 @@ var require_send = __commonJS({
|
|
|
64075
64131
|
stream: Readable.from(doc[0]),
|
|
64076
64132
|
// metadata
|
|
64077
64133
|
type: "directory",
|
|
64078
|
-
metadata: { requestPath: options.path, path:
|
|
64134
|
+
metadata: { requestPath: options.path, path: path8 }
|
|
64079
64135
|
};
|
|
64080
64136
|
}
|
|
64081
|
-
async function sendIndex(request,
|
|
64137
|
+
async function sendIndex(request, path8, options) {
|
|
64082
64138
|
let err;
|
|
64083
64139
|
for (let i = 0; i < options.index.length; i++) {
|
|
64084
64140
|
const index = options.index[i];
|
|
64085
|
-
const p = join5(
|
|
64141
|
+
const p = join5(path8, index);
|
|
64086
64142
|
const { error, stat: stat2 } = await tryStat(p);
|
|
64087
64143
|
if (error) {
|
|
64088
64144
|
err = error;
|
|
@@ -64096,13 +64152,13 @@ var require_send = __commonJS({
|
|
|
64096
64152
|
}
|
|
64097
64153
|
return sendError(404);
|
|
64098
64154
|
}
|
|
64099
|
-
async function sendFile(request,
|
|
64100
|
-
const { error, stat: stat2 } = await tryStat(
|
|
64101
|
-
if (error && error.code === "ENOENT" && !extname(
|
|
64155
|
+
async function sendFile(request, path8, options) {
|
|
64156
|
+
const { error, stat: stat2 } = await tryStat(path8);
|
|
64157
|
+
if (error && error.code === "ENOENT" && !extname(path8) && path8[path8.length - 1] !== sep2) {
|
|
64102
64158
|
let err = error;
|
|
64103
64159
|
for (let i = 0; i < options.extensions.length; i++) {
|
|
64104
64160
|
const extension = options.extensions[i];
|
|
64105
|
-
const p =
|
|
64161
|
+
const p = path8 + "." + extension;
|
|
64106
64162
|
const { error: error2, stat: stat3 } = await tryStat(p);
|
|
64107
64163
|
if (error2) {
|
|
64108
64164
|
err = error2;
|
|
@@ -64120,14 +64176,14 @@ var require_send = __commonJS({
|
|
|
64120
64176
|
return sendError(404);
|
|
64121
64177
|
}
|
|
64122
64178
|
if (error) return sendStatError(error);
|
|
64123
|
-
if (stat2.isDirectory()) return sendRedirect(
|
|
64124
|
-
return sendFileDirectly(request,
|
|
64179
|
+
if (stat2.isDirectory()) return sendRedirect(path8, options);
|
|
64180
|
+
return sendFileDirectly(request, path8, stat2, options);
|
|
64125
64181
|
}
|
|
64126
64182
|
async function send(request, _path, options) {
|
|
64127
64183
|
const opts = normalizeOptions(options);
|
|
64128
64184
|
opts.path = _path;
|
|
64129
64185
|
const parsed = normalizePath(_path, opts.root);
|
|
64130
|
-
const { path:
|
|
64186
|
+
const { path: path8, parts } = parsed;
|
|
64131
64187
|
if (parsed.statusCode !== void 0) {
|
|
64132
64188
|
return sendError(parsed.statusCode);
|
|
64133
64189
|
}
|
|
@@ -64137,23 +64193,23 @@ var require_send = __commonJS({
|
|
|
64137
64193
|
/* c8 ignore start */
|
|
64138
64194
|
/* unreachable, because NODE_DEBUG can not be set after process is running */
|
|
64139
64195
|
case 0:
|
|
64140
|
-
debug('allow dotfile "%s"',
|
|
64196
|
+
debug('allow dotfile "%s"', path8);
|
|
64141
64197
|
break;
|
|
64142
64198
|
/* c8 ignore stop */
|
|
64143
64199
|
case 2:
|
|
64144
|
-
debug('deny dotfile "%s"',
|
|
64200
|
+
debug('deny dotfile "%s"', path8);
|
|
64145
64201
|
return sendError(403);
|
|
64146
64202
|
case 1:
|
|
64147
64203
|
// 'ignore'
|
|
64148
64204
|
default:
|
|
64149
|
-
debug('ignore dotfile "%s"',
|
|
64205
|
+
debug('ignore dotfile "%s"', path8);
|
|
64150
64206
|
return sendError(404);
|
|
64151
64207
|
}
|
|
64152
64208
|
}
|
|
64153
64209
|
if (opts.index.length && hasTrailingSlash(_path)) {
|
|
64154
|
-
return sendIndex(request,
|
|
64210
|
+
return sendIndex(request, path8, opts);
|
|
64155
64211
|
}
|
|
64156
|
-
return sendFile(request,
|
|
64212
|
+
return sendFile(request, path8, opts);
|
|
64157
64213
|
}
|
|
64158
64214
|
module2.exports.send = send;
|
|
64159
64215
|
}
|
|
@@ -64540,30 +64596,30 @@ var require_dirList = __commonJS({
|
|
|
64540
64596
|
"node_modules/.pnpm/@fastify+static@8.2.0/node_modules/@fastify/static/lib/dirList.js"(exports2, module2) {
|
|
64541
64597
|
"use strict";
|
|
64542
64598
|
var os2 = require("node:os");
|
|
64543
|
-
var
|
|
64544
|
-
var
|
|
64599
|
+
var path7 = require("node:path");
|
|
64600
|
+
var fs7 = require("node:fs/promises");
|
|
64545
64601
|
var fastq = require_queue();
|
|
64546
64602
|
var fastqConcurrency = Math.max(1, os2.cpus().length - 1);
|
|
64547
64603
|
var dirList = {
|
|
64548
64604
|
_getExtendedInfo: async function(dir, info) {
|
|
64549
|
-
const depth = dir.split(
|
|
64550
|
-
const files = await
|
|
64605
|
+
const depth = dir.split(path7.sep).length;
|
|
64606
|
+
const files = await fs7.readdir(dir);
|
|
64551
64607
|
const worker = async (filename) => {
|
|
64552
|
-
const filePath =
|
|
64608
|
+
const filePath = path7.join(dir, filename);
|
|
64553
64609
|
let stats;
|
|
64554
64610
|
try {
|
|
64555
|
-
stats = await
|
|
64611
|
+
stats = await fs7.stat(filePath);
|
|
64556
64612
|
} catch {
|
|
64557
64613
|
return;
|
|
64558
64614
|
}
|
|
64559
64615
|
if (stats.isDirectory()) {
|
|
64560
64616
|
info.totalFolderCount++;
|
|
64561
|
-
filePath.split(
|
|
64617
|
+
filePath.split(path7.sep).length === depth + 1 && info.folderCount++;
|
|
64562
64618
|
await dirList._getExtendedInfo(filePath, info);
|
|
64563
64619
|
} else {
|
|
64564
64620
|
info.totalSize += stats.size;
|
|
64565
64621
|
info.totalFileCount++;
|
|
64566
|
-
filePath.split(
|
|
64622
|
+
filePath.split(path7.sep).length === depth + 1 && info.fileCount++;
|
|
64567
64623
|
info.lastModified = Math.max(info.lastModified, stats.mtimeMs);
|
|
64568
64624
|
}
|
|
64569
64625
|
};
|
|
@@ -64596,7 +64652,7 @@ var require_dirList = __commonJS({
|
|
|
64596
64652
|
*/
|
|
64597
64653
|
list: async function(dir, options, dotfiles) {
|
|
64598
64654
|
const entries = { dirs: [], files: [] };
|
|
64599
|
-
let files = await
|
|
64655
|
+
let files = await fs7.readdir(dir);
|
|
64600
64656
|
if (dotfiles === "deny" || dotfiles === "ignore") {
|
|
64601
64657
|
files = files.filter((file) => file.charAt(0) !== ".");
|
|
64602
64658
|
}
|
|
@@ -64606,14 +64662,14 @@ var require_dirList = __commonJS({
|
|
|
64606
64662
|
const worker = async (filename) => {
|
|
64607
64663
|
let stats;
|
|
64608
64664
|
try {
|
|
64609
|
-
stats = await
|
|
64665
|
+
stats = await fs7.stat(path7.join(dir, filename));
|
|
64610
64666
|
} catch {
|
|
64611
64667
|
return;
|
|
64612
64668
|
}
|
|
64613
64669
|
const entry = { name: filename, stats };
|
|
64614
64670
|
if (stats.isDirectory()) {
|
|
64615
64671
|
if (options.extendedFolderInfo) {
|
|
64616
|
-
entry.extendedInfo = await dirList.getExtendedInfo(
|
|
64672
|
+
entry.extendedInfo = await dirList.getExtendedInfo(path7.join(dir, filename));
|
|
64617
64673
|
}
|
|
64618
64674
|
entries.dirs.push(entry);
|
|
64619
64675
|
} else {
|
|
@@ -64669,11 +64725,11 @@ var require_dirList = __commonJS({
|
|
|
64669
64725
|
* @return {ListFile}
|
|
64670
64726
|
*/
|
|
64671
64727
|
htmlInfo: function(entry, route, prefix, options) {
|
|
64672
|
-
if (options.names?.includes(
|
|
64673
|
-
route =
|
|
64728
|
+
if (options.names?.includes(path7.basename(route))) {
|
|
64729
|
+
route = path7.normalize(path7.join(route, ".."));
|
|
64674
64730
|
}
|
|
64675
64731
|
return {
|
|
64676
|
-
href: encodeURI(
|
|
64732
|
+
href: encodeURI(path7.join(prefix, route, entry.name).replace(/\\/gu, "/")),
|
|
64677
64733
|
name: entry.name,
|
|
64678
64734
|
stats: entry.stats,
|
|
64679
64735
|
extendedInfo: entry.extendedInfo
|
|
@@ -64686,7 +64742,7 @@ var require_dirList = __commonJS({
|
|
|
64686
64742
|
* @return {boolean}
|
|
64687
64743
|
*/
|
|
64688
64744
|
handle: function(route, options) {
|
|
64689
|
-
return options.names?.includes(
|
|
64745
|
+
return options.names?.includes(path7.basename(route)) || // match trailing slash
|
|
64690
64746
|
((options.names?.includes("/") && route[route.length - 1] === "/") ?? false);
|
|
64691
64747
|
},
|
|
64692
64748
|
/**
|
|
@@ -64696,7 +64752,7 @@ var require_dirList = __commonJS({
|
|
|
64696
64752
|
*/
|
|
64697
64753
|
path: function(root, route) {
|
|
64698
64754
|
const _route = route[route.length - 1] === "/" ? route + "none" : route;
|
|
64699
|
-
return
|
|
64755
|
+
return path7.dirname(path7.join(root, _route));
|
|
64700
64756
|
},
|
|
64701
64757
|
/**
|
|
64702
64758
|
* validate options
|
|
@@ -64731,7 +64787,7 @@ var require_dirList = __commonJS({
|
|
|
64731
64787
|
var require_static = __commonJS({
|
|
64732
64788
|
"node_modules/.pnpm/@fastify+static@8.2.0/node_modules/@fastify/static/index.js"(exports2, module2) {
|
|
64733
64789
|
"use strict";
|
|
64734
|
-
var
|
|
64790
|
+
var path7 = require("node:path");
|
|
64735
64791
|
var { fileURLToPath } = require("node:url");
|
|
64736
64792
|
var { statSync } = require("node:fs");
|
|
64737
64793
|
var { glob } = require_commonjs7();
|
|
@@ -64838,7 +64894,7 @@ var require_static = __commonJS({
|
|
|
64838
64894
|
const routes = /* @__PURE__ */ new Set();
|
|
64839
64895
|
const roots = Array.isArray(sendOptions.root) ? sendOptions.root : [sendOptions.root];
|
|
64840
64896
|
for (let rootPath of roots) {
|
|
64841
|
-
rootPath = rootPath.split(
|
|
64897
|
+
rootPath = rootPath.split(path7.win32.sep).join(path7.posix.sep);
|
|
64842
64898
|
!rootPath.endsWith("/") && (rootPath += "/");
|
|
64843
64899
|
const files = await glob("**/**", {
|
|
64844
64900
|
cwd: rootPath,
|
|
@@ -64849,16 +64905,16 @@ var require_static = __commonJS({
|
|
|
64849
64905
|
ignore: opts.globIgnore
|
|
64850
64906
|
});
|
|
64851
64907
|
for (let file of files) {
|
|
64852
|
-
file = file.split(
|
|
64908
|
+
file = file.split(path7.win32.sep).join(path7.posix.sep);
|
|
64853
64909
|
const route = prefix + file;
|
|
64854
64910
|
if (routes.has(route)) {
|
|
64855
64911
|
continue;
|
|
64856
64912
|
}
|
|
64857
64913
|
routes.add(route);
|
|
64858
64914
|
setUpHeadAndGet(routeOpts, route, `/${file}`, rootPath);
|
|
64859
|
-
const key =
|
|
64915
|
+
const key = path7.posix.basename(route);
|
|
64860
64916
|
if (indexes.includes(key) && !indexDirs.has(key)) {
|
|
64861
|
-
indexDirs.set(
|
|
64917
|
+
indexDirs.set(path7.posix.dirname(route), rootPath);
|
|
64862
64918
|
}
|
|
64863
64919
|
}
|
|
64864
64920
|
}
|
|
@@ -64914,11 +64970,11 @@ var require_static = __commonJS({
|
|
|
64914
64970
|
} = await send(request.raw, encodeURI(pathnameForSend), options);
|
|
64915
64971
|
switch (type) {
|
|
64916
64972
|
case "directory": {
|
|
64917
|
-
const
|
|
64973
|
+
const path8 = metadata.path;
|
|
64918
64974
|
if (opts.list) {
|
|
64919
64975
|
await dirList.send({
|
|
64920
64976
|
reply,
|
|
64921
|
-
dir:
|
|
64977
|
+
dir: path8,
|
|
64922
64978
|
options: opts.list,
|
|
64923
64979
|
route: pathname,
|
|
64924
64980
|
prefix,
|
|
@@ -65077,7 +65133,7 @@ var require_static = __commonJS({
|
|
|
65077
65133
|
'"root" option array contains one or more duplicate paths'
|
|
65078
65134
|
);
|
|
65079
65135
|
}
|
|
65080
|
-
rootPath.map((
|
|
65136
|
+
rootPath.map((path8) => checkPath(fastify, path8));
|
|
65081
65137
|
return;
|
|
65082
65138
|
}
|
|
65083
65139
|
if (typeof rootPath === "string") {
|
|
@@ -65089,7 +65145,7 @@ var require_static = __commonJS({
|
|
|
65089
65145
|
if (typeof rootPath !== "string") {
|
|
65090
65146
|
throw new TypeError('"root" option must be a string');
|
|
65091
65147
|
}
|
|
65092
|
-
if (
|
|
65148
|
+
if (path7.isAbsolute(rootPath) === false) {
|
|
65093
65149
|
throw new Error('"root" option must be an absolute path');
|
|
65094
65150
|
}
|
|
65095
65151
|
let pathStat;
|
|
@@ -65106,8 +65162,8 @@ var require_static = __commonJS({
|
|
|
65106
65162
|
throw new Error('"root" option must point to a directory');
|
|
65107
65163
|
}
|
|
65108
65164
|
}
|
|
65109
|
-
function getContentType(
|
|
65110
|
-
const type = send.mime.getType(
|
|
65165
|
+
function getContentType(path8) {
|
|
65166
|
+
const type = send.mime.getType(path8) || send.mime.default_type;
|
|
65111
65167
|
if (!send.isUtf8MimeType(type)) {
|
|
65112
65168
|
return type;
|
|
65113
65169
|
}
|
|
@@ -65116,7 +65172,7 @@ var require_static = __commonJS({
|
|
|
65116
65172
|
function findIndexFile(pathname, root, indexFiles = ["index.html"]) {
|
|
65117
65173
|
if (Array.isArray(indexFiles)) {
|
|
65118
65174
|
return indexFiles.find((filename) => {
|
|
65119
|
-
const p =
|
|
65175
|
+
const p = path7.join(root, pathname, filename);
|
|
65120
65176
|
try {
|
|
65121
65177
|
const stats = statSync(p);
|
|
65122
65178
|
return !stats.isDirectory();
|
|
@@ -65168,6 +65224,57 @@ var require_static = __commonJS({
|
|
|
65168
65224
|
}
|
|
65169
65225
|
});
|
|
65170
65226
|
|
|
65227
|
+
// package.json
|
|
65228
|
+
var require_package3 = __commonJS({
|
|
65229
|
+
"package.json"(exports2, module2) {
|
|
65230
|
+
module2.exports = {
|
|
65231
|
+
name: "@musistudio/claude-code-router",
|
|
65232
|
+
version: "1.0.38",
|
|
65233
|
+
description: "Use Claude Code without an Anthropics account and route it to another LLM provider",
|
|
65234
|
+
bin: {
|
|
65235
|
+
ccr: "./dist/cli.js"
|
|
65236
|
+
},
|
|
65237
|
+
scripts: {
|
|
65238
|
+
build: "node scripts/build.js",
|
|
65239
|
+
release: "npm run build && npm publish"
|
|
65240
|
+
},
|
|
65241
|
+
keywords: [
|
|
65242
|
+
"claude",
|
|
65243
|
+
"code",
|
|
65244
|
+
"router",
|
|
65245
|
+
"llm",
|
|
65246
|
+
"anthropic"
|
|
65247
|
+
],
|
|
65248
|
+
author: "musistudio",
|
|
65249
|
+
license: "MIT",
|
|
65250
|
+
dependencies: {
|
|
65251
|
+
"@fastify/static": "^8.2.0",
|
|
65252
|
+
"@musistudio/llms": "^1.0.24",
|
|
65253
|
+
dotenv: "^16.4.7",
|
|
65254
|
+
json5: "^2.2.3",
|
|
65255
|
+
openurl: "^1.1.1",
|
|
65256
|
+
"pino-rotating-file-stream": "^0.0.2",
|
|
65257
|
+
tiktoken: "^1.0.21",
|
|
65258
|
+
uuid: "^11.1.0"
|
|
65259
|
+
},
|
|
65260
|
+
devDependencies: {
|
|
65261
|
+
"@types/node": "^24.0.15",
|
|
65262
|
+
esbuild: "^0.25.1",
|
|
65263
|
+
fastify: "^5.4.0",
|
|
65264
|
+
shx: "^0.4.0",
|
|
65265
|
+
typescript: "^5.8.2"
|
|
65266
|
+
},
|
|
65267
|
+
publishConfig: {
|
|
65268
|
+
ignore: [
|
|
65269
|
+
"!build/",
|
|
65270
|
+
"src/",
|
|
65271
|
+
"screenshots/"
|
|
65272
|
+
]
|
|
65273
|
+
}
|
|
65274
|
+
};
|
|
65275
|
+
}
|
|
65276
|
+
});
|
|
65277
|
+
|
|
65171
65278
|
// node_modules/.pnpm/tiktoken@1.0.21/node_modules/tiktoken/tiktoken_bg.cjs
|
|
65172
65279
|
var require_tiktoken_bg = __commonJS({
|
|
65173
65280
|
"node_modules/.pnpm/tiktoken@1.0.21/node_modules/tiktoken/tiktoken_bg.cjs"(exports2, module2) {
|
|
@@ -65562,13 +65669,13 @@ var require_tiktoken = __commonJS({
|
|
|
65562
65669
|
var wasm = require_tiktoken_bg();
|
|
65563
65670
|
var imports = {};
|
|
65564
65671
|
imports["./tiktoken_bg.js"] = wasm;
|
|
65565
|
-
var
|
|
65566
|
-
var
|
|
65567
|
-
var candidates = __dirname.split(
|
|
65568
|
-
const prefix = array.slice(0, index + 1).join(
|
|
65569
|
-
if (!prefix.includes("node_modules" +
|
|
65672
|
+
var path7 = require("path");
|
|
65673
|
+
var fs7 = require("fs");
|
|
65674
|
+
var candidates = __dirname.split(path7.sep).reduce((memo, _, index, array) => {
|
|
65675
|
+
const prefix = array.slice(0, index + 1).join(path7.sep) + path7.sep;
|
|
65676
|
+
if (!prefix.includes("node_modules" + path7.sep)) {
|
|
65570
65677
|
memo.unshift(
|
|
65571
|
-
|
|
65678
|
+
path7.join(
|
|
65572
65679
|
prefix,
|
|
65573
65680
|
"node_modules",
|
|
65574
65681
|
"tiktoken",
|
|
@@ -65579,11 +65686,11 @@ var require_tiktoken = __commonJS({
|
|
|
65579
65686
|
}
|
|
65580
65687
|
return memo;
|
|
65581
65688
|
}, []);
|
|
65582
|
-
candidates.unshift(
|
|
65689
|
+
candidates.unshift(path7.join(__dirname, "./tiktoken_bg.wasm"));
|
|
65583
65690
|
var bytes = null;
|
|
65584
65691
|
for (const candidate of candidates) {
|
|
65585
65692
|
try {
|
|
65586
|
-
bytes =
|
|
65693
|
+
bytes = fs7.readFileSync(candidate);
|
|
65587
65694
|
break;
|
|
65588
65695
|
} catch {
|
|
65589
65696
|
}
|
|
@@ -65605,7 +65712,7 @@ var import_os = require("os");
|
|
|
65605
65712
|
var import_path4 = require("path");
|
|
65606
65713
|
init_utils();
|
|
65607
65714
|
|
|
65608
|
-
// node_modules/.pnpm/@musistudio+llms@1.0.
|
|
65715
|
+
// node_modules/.pnpm/@musistudio+llms@1.0.24_ws@8.18.3_zod@3.25.67/node_modules/@musistudio/llms/dist/esm/server.mjs
|
|
65609
65716
|
var import_node_fs = require("node:fs");
|
|
65610
65717
|
var import_node_path4 = require("node:path");
|
|
65611
65718
|
var import_node_stream = __toESM(require("node:stream"), 1);
|
|
@@ -74622,7 +74729,7 @@ async function jf(r, e, t) {
|
|
|
74622
74729
|
function Lf(r, e, t, n) {
|
|
74623
74730
|
let o = new Headers({ "Content-Type": "application/json" });
|
|
74624
74731
|
t.headers && Object.entries(t.headers).forEach(([f, h]) => {
|
|
74625
|
-
o.set(f, h);
|
|
74732
|
+
h && o.set(f, h);
|
|
74626
74733
|
});
|
|
74627
74734
|
let a, u = AbortSignal.timeout(t.TIMEOUT ?? 60 * 1e3 * 60);
|
|
74628
74735
|
if (t.signal) {
|
|
@@ -74630,9 +74737,9 @@ function Lf(r, e, t, n) {
|
|
|
74630
74737
|
t.signal.addEventListener("abort", h), u.addEventListener("abort", h), a = f.signal;
|
|
74631
74738
|
} else a = u;
|
|
74632
74739
|
let l = { method: "POST", headers: o, body: JSON.stringify(e), signal: a };
|
|
74633
|
-
return t.httpsProxy && (l.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())), n?.debug({ request: l, requestUrl: typeof r == "string" ? r : r.toString(), useProxy: t.httpsProxy }, "final request"), fetch(typeof r == "string" ? r : r.toString(), l);
|
|
74740
|
+
return t.httpsProxy && (l.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())), n?.debug({ request: l, headers: Object.fromEntries(o.entries()), requestUrl: typeof r == "string" ? r : r.toString(), useProxy: t.httpsProxy }, "final request"), fetch(typeof r == "string" ? r : r.toString(), l);
|
|
74634
74741
|
}
|
|
74635
|
-
var Uf = "1.0.
|
|
74742
|
+
var Uf = "1.0.24";
|
|
74636
74743
|
async function o0(r, e, t, n) {
|
|
74637
74744
|
let o = r.body, a = r.provider, u = t._server.providerService.getProvider(a);
|
|
74638
74745
|
if (!u) throw bt(`Provider '${a}' not found`, 404, "provider_not_found");
|
|
@@ -74641,7 +74748,7 @@ async function o0(r, e, t, n) {
|
|
|
74641
74748
|
}
|
|
74642
74749
|
async function i0(r, e, t, n) {
|
|
74643
74750
|
let o = r, a = {}, u = false;
|
|
74644
|
-
if (u = a0(e, t, r), u && (a.headers = n), !u && typeof t.transformRequestOut == "function") {
|
|
74751
|
+
if (u = a0(e, t, r), u && (n instanceof Headers ? n.delete("content-length") : delete n["content-length"], a.headers = n), !u && typeof t.transformRequestOut == "function") {
|
|
74645
74752
|
let l = await t.transformRequestOut(o);
|
|
74646
74753
|
l.body ? (o = l.body, a = l.config || {}) : o = l;
|
|
74647
74754
|
}
|
|
@@ -74663,7 +74770,7 @@ async function u0(r, e, t, n, o, a) {
|
|
|
74663
74770
|
if (f.body) {
|
|
74664
74771
|
r = f.body;
|
|
74665
74772
|
let h = e.headers || {};
|
|
74666
|
-
f.config?.headers && (h = { ...h,
|
|
74773
|
+
f.config?.headers && (h = { ...h, ...f.config.headers }, delete h.host, delete f.config.headers), e = { ...e, ...f.config, headers: h };
|
|
74667
74774
|
} else r = f;
|
|
74668
74775
|
}
|
|
74669
74776
|
let l = await Lf(u, r, { httpsProxy: n._server.configService.getHttpsProxy(), ...e, headers: { Authorization: `Bearer ${t.apiKey}`, ...e?.headers || {} } }, n.log);
|
|
@@ -74900,7 +75007,7 @@ var bo = class {
|
|
|
74900
75007
|
name = "Anthropic";
|
|
74901
75008
|
endPoint = "/v1/messages";
|
|
74902
75009
|
async auth(e, t) {
|
|
74903
|
-
return { body: e, config: { headers: { "x-api-key": t.apiKey,
|
|
75010
|
+
return { body: e, config: { headers: { "x-api-key": t.apiKey, authorization: void 0 } } };
|
|
74904
75011
|
}
|
|
74905
75012
|
async transformRequestOut(e) {
|
|
74906
75013
|
let t = [];
|
|
@@ -74966,10 +75073,13 @@ var bo = class {
|
|
|
74966
75073
|
}
|
|
74967
75074
|
}, U = () => {
|
|
74968
75075
|
if (!g) try {
|
|
74969
|
-
u
|
|
75076
|
+
u ? (v(o.encode(`event: message_delta
|
|
74970
75077
|
data: ${JSON.stringify(u)}
|
|
74971
75078
|
|
|
74972
|
-
`)), u = null)
|
|
75079
|
+
`)), u = null) : v(o.encode(`event: message_delta
|
|
75080
|
+
data: ${JSON.stringify({ type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null }, usage: { input_tokens: 0, output_tokens: 0, cache_read_input_tokens: 0 } })}
|
|
75081
|
+
|
|
75082
|
+
`));
|
|
74973
75083
|
let j = { type: "message_stop" };
|
|
74974
75084
|
v(o.encode(`event: message_stop
|
|
74975
75085
|
data: ${JSON.stringify(j)}
|
|
@@ -74994,14 +75104,7 @@ data: ${JSON.stringify(j)}
|
|
|
74994
75104
|
if (g || d) break;
|
|
74995
75105
|
if (!he.startsWith("data: ")) continue;
|
|
74996
75106
|
let le = he.slice(6);
|
|
74997
|
-
if (this.logger.debug(`recieved data: ${le}`), le
|
|
74998
|
-
u && (v(o.encode(`event: message_delta
|
|
74999
|
-
data: ${JSON.stringify(u)}
|
|
75000
|
-
|
|
75001
|
-
`)), u = null);
|
|
75002
|
-
continue;
|
|
75003
|
-
}
|
|
75004
|
-
try {
|
|
75107
|
+
if (this.logger.debug(`recieved data: ${le}`), le !== "[DONE]") try {
|
|
75005
75108
|
let ne = JSON.parse(le);
|
|
75006
75109
|
if (P++, this.logger.debug({ response: ne }, "Original Response"), ne.error) {
|
|
75007
75110
|
let oe = { type: "error", message: { type: "api_error", message: JSON.stringify(ne.error) } };
|
|
@@ -76646,6 +76749,7 @@ var XT = bl;
|
|
|
76646
76749
|
|
|
76647
76750
|
// src/server.ts
|
|
76648
76751
|
init_utils();
|
|
76752
|
+
init_utils();
|
|
76649
76753
|
var import_path2 = require("path");
|
|
76650
76754
|
var import_static = __toESM(require_static());
|
|
76651
76755
|
var createServer = (config) => {
|
|
@@ -76673,11 +76777,6 @@ var createServer = (config) => {
|
|
|
76673
76777
|
return { success: true, message: "Config saved successfully" };
|
|
76674
76778
|
});
|
|
76675
76779
|
server.app.post("/api/restart", async (req, reply) => {
|
|
76676
|
-
const accessLevel = req.accessLevel || "restricted";
|
|
76677
|
-
if (accessLevel !== "full") {
|
|
76678
|
-
reply.status(403).send("Full access required to restart service");
|
|
76679
|
-
return;
|
|
76680
|
-
}
|
|
76681
76780
|
reply.send({ success: true, message: "Service restart initiated" });
|
|
76682
76781
|
setTimeout(() => {
|
|
76683
76782
|
const { spawn: spawn3 } = require("child_process");
|
|
@@ -76695,6 +76794,34 @@ var createServer = (config) => {
|
|
|
76695
76794
|
server.app.get("/ui", async (_, reply) => {
|
|
76696
76795
|
return reply.redirect("/ui/");
|
|
76697
76796
|
});
|
|
76797
|
+
server.app.get("/api/update/check", async (req, reply) => {
|
|
76798
|
+
try {
|
|
76799
|
+
const currentVersion = require_package3().version;
|
|
76800
|
+
const { hasUpdate, latestVersion, changelog } = await checkForUpdates(currentVersion);
|
|
76801
|
+
return {
|
|
76802
|
+
hasUpdate,
|
|
76803
|
+
latestVersion: hasUpdate ? latestVersion : void 0,
|
|
76804
|
+
changelog: hasUpdate ? changelog : void 0
|
|
76805
|
+
};
|
|
76806
|
+
} catch (error) {
|
|
76807
|
+
console.error("Failed to check for updates:", error);
|
|
76808
|
+
reply.status(500).send({ error: "Failed to check for updates" });
|
|
76809
|
+
}
|
|
76810
|
+
});
|
|
76811
|
+
server.app.post("/api/update/perform", async (req, reply) => {
|
|
76812
|
+
try {
|
|
76813
|
+
const accessLevel = req.accessLevel || "restricted";
|
|
76814
|
+
if (accessLevel !== "full") {
|
|
76815
|
+
reply.status(403).send("Full access required to perform updates");
|
|
76816
|
+
return;
|
|
76817
|
+
}
|
|
76818
|
+
const result = await performUpdate();
|
|
76819
|
+
return result;
|
|
76820
|
+
} catch (error) {
|
|
76821
|
+
console.error("Failed to perform update:", error);
|
|
76822
|
+
reply.status(500).send({ error: "Failed to perform update" });
|
|
76823
|
+
}
|
|
76824
|
+
});
|
|
76698
76825
|
return server;
|
|
76699
76826
|
};
|
|
76700
76827
|
|
|
@@ -76709,8 +76836,16 @@ var LOG_FILE = import_node_path5.default.join(HOME_DIR, "claude-code-router.log"
|
|
|
76709
76836
|
if (!import_node_fs2.default.existsSync(HOME_DIR)) {
|
|
76710
76837
|
import_node_fs2.default.mkdirSync(HOME_DIR, { recursive: true });
|
|
76711
76838
|
}
|
|
76839
|
+
var isLogEnabled = null;
|
|
76840
|
+
var logLevel = "info";
|
|
76841
|
+
function configureLogging(config) {
|
|
76842
|
+
isLogEnabled = config.LOG !== false;
|
|
76843
|
+
logLevel = config.LOG_LEVEL || "info";
|
|
76844
|
+
}
|
|
76712
76845
|
function log2(...args) {
|
|
76713
|
-
|
|
76846
|
+
if (isLogEnabled === null) {
|
|
76847
|
+
isLogEnabled = true;
|
|
76848
|
+
}
|
|
76714
76849
|
if (!isLogEnabled) {
|
|
76715
76850
|
return;
|
|
76716
76851
|
}
|
|
@@ -76860,7 +76995,7 @@ var apiKeyAuth = (config) => async (req, reply, done) => {
|
|
|
76860
76995
|
`http://127.0.0.1:${config.PORT || 3456}`,
|
|
76861
76996
|
`http://localhost:${config.PORT || 3456}`
|
|
76862
76997
|
];
|
|
76863
|
-
if (req.headers.origin && allowedOrigins.includes(req.headers.origin)) {
|
|
76998
|
+
if (req.headers.origin && !allowedOrigins.includes(req.headers.origin)) {
|
|
76864
76999
|
reply.status(403).send("CORS not allowed for this origin");
|
|
76865
77000
|
return;
|
|
76866
77001
|
} else {
|
|
@@ -76960,8 +77095,8 @@ function savePid(pid) {
|
|
|
76960
77095
|
function cleanupPidFile() {
|
|
76961
77096
|
if ((0, import_fs2.existsSync)(PID_FILE)) {
|
|
76962
77097
|
try {
|
|
76963
|
-
const
|
|
76964
|
-
|
|
77098
|
+
const fs7 = require("fs");
|
|
77099
|
+
fs7.unlinkSync(PID_FILE);
|
|
76965
77100
|
} catch (e) {
|
|
76966
77101
|
}
|
|
76967
77102
|
}
|
|
@@ -76996,13 +77131,13 @@ async function getServiceInfo() {
|
|
|
76996
77131
|
init_constants();
|
|
76997
77132
|
|
|
76998
77133
|
// node_modules/.pnpm/rotating-file-stream@3.2.6/node_modules/rotating-file-stream/dist/esm/index.js
|
|
76999
|
-
var
|
|
77134
|
+
var import_child_process2 = require("child_process");
|
|
77000
77135
|
var import_zlib = require("zlib");
|
|
77001
77136
|
var import_stream = require("stream");
|
|
77002
77137
|
var import_fs3 = require("fs");
|
|
77003
77138
|
var import_promises3 = require("fs/promises");
|
|
77004
77139
|
var import_path3 = require("path");
|
|
77005
|
-
var
|
|
77140
|
+
var import_util2 = require("util");
|
|
77006
77141
|
var import_timers = require("timers");
|
|
77007
77142
|
async function exists(filename) {
|
|
77008
77143
|
return new Promise((resolve) => (0, import_fs3.access)(filename, import_fs3.constants.F_OK, (error) => resolve(!error)));
|
|
@@ -77038,11 +77173,11 @@ var RotatingFileStream = class extends import_stream.Writable {
|
|
|
77038
77173
|
timeout;
|
|
77039
77174
|
timeoutPromise;
|
|
77040
77175
|
constructor(generator, options) {
|
|
77041
|
-
const { encoding, history, maxFiles, maxSize, path:
|
|
77176
|
+
const { encoding, history, maxFiles, maxSize, path: path7 } = options;
|
|
77042
77177
|
super({ decodeStrings: true, defaultEncoding: encoding });
|
|
77043
77178
|
this.createGzip = import_zlib.createGzip;
|
|
77044
|
-
this.exec =
|
|
77045
|
-
this.filename =
|
|
77179
|
+
this.exec = import_child_process2.exec;
|
|
77180
|
+
this.filename = path7 + generator(null);
|
|
77046
77181
|
this.fsCreateReadStream = import_fs3.createReadStream;
|
|
77047
77182
|
this.fsCreateWriteStream = import_fs3.createWriteStream;
|
|
77048
77183
|
this.fsOpen = import_promises3.open;
|
|
@@ -77054,7 +77189,7 @@ var RotatingFileStream = class extends import_stream.Writable {
|
|
|
77054
77189
|
this.options = options;
|
|
77055
77190
|
this.stdout = process.stdout;
|
|
77056
77191
|
if (maxFiles || maxSize)
|
|
77057
|
-
options.history =
|
|
77192
|
+
options.history = path7 + (history ? history : this.generator(null) + ".txt");
|
|
77058
77193
|
this.on("close", () => this.finished ? null : this.emit("finish"));
|
|
77059
77194
|
this.on("finish", () => this.finished = this.clear());
|
|
77060
77195
|
(async () => {
|
|
@@ -77182,9 +77317,9 @@ var RotatingFileStream = class extends import_stream.Writable {
|
|
|
77182
77317
|
return this.move();
|
|
77183
77318
|
}
|
|
77184
77319
|
async findName() {
|
|
77185
|
-
const { interval, path:
|
|
77320
|
+
const { interval, path: path7, intervalBoundary } = this.options;
|
|
77186
77321
|
for (let index = 1; index < 1e3; ++index) {
|
|
77187
|
-
const filename =
|
|
77322
|
+
const filename = path7 + this.generator(interval && intervalBoundary ? new Date(this.prev) : this.rotation, index);
|
|
77188
77323
|
if (!await exists(filename))
|
|
77189
77324
|
return filename;
|
|
77190
77325
|
}
|
|
@@ -77214,11 +77349,11 @@ var RotatingFileStream = class extends import_stream.Writable {
|
|
|
77214
77349
|
return this.unlink(filename);
|
|
77215
77350
|
}
|
|
77216
77351
|
async classical() {
|
|
77217
|
-
const { compress, path:
|
|
77352
|
+
const { compress, path: path7, rotate } = this.options;
|
|
77218
77353
|
let rotatedName = "";
|
|
77219
77354
|
for (let count = rotate; count > 0; --count) {
|
|
77220
|
-
const currName =
|
|
77221
|
-
const prevName = count === 1 ? this.filename :
|
|
77355
|
+
const currName = path7 + this.generator(count);
|
|
77356
|
+
const prevName = count === 1 ? this.filename : path7 + this.generator(count - 1);
|
|
77222
77357
|
if (!await exists(prevName))
|
|
77223
77358
|
continue;
|
|
77224
77359
|
if (!rotatedName)
|
|
@@ -77481,7 +77616,7 @@ function checkSize(value) {
|
|
|
77481
77616
|
return ret.num;
|
|
77482
77617
|
}
|
|
77483
77618
|
var checks = {
|
|
77484
|
-
encoding: (type, options, value) => new
|
|
77619
|
+
encoding: (type, options, value) => new import_util2.TextDecoder(value),
|
|
77485
77620
|
immutable: () => {
|
|
77486
77621
|
},
|
|
77487
77622
|
initialRotation: () => {
|
|
@@ -77595,7 +77730,7 @@ function createStream(filename, options) {
|
|
|
77595
77730
|
|
|
77596
77731
|
// node_modules/.pnpm/pino-rotating-file-stream@0.0.2/node_modules/pino-rotating-file-stream/dist/mjs/index.js
|
|
77597
77732
|
var mjs_default = (options) => {
|
|
77598
|
-
const { filename, size, maxSize, interval, compress, path:
|
|
77733
|
+
const { filename, size, maxSize, interval, compress, path: path7, ...otherOptions } = options;
|
|
77599
77734
|
return createStream(filename, {
|
|
77600
77735
|
...otherOptions,
|
|
77601
77736
|
// Set some default values
|
|
@@ -77603,7 +77738,7 @@ var mjs_default = (options) => {
|
|
|
77603
77738
|
maxSize: maxSize || "1G",
|
|
77604
77739
|
interval: interval || "7d",
|
|
77605
77740
|
compress: compress || "gzip",
|
|
77606
|
-
path:
|
|
77741
|
+
path: path7
|
|
77607
77742
|
});
|
|
77608
77743
|
};
|
|
77609
77744
|
|
|
@@ -77637,6 +77772,7 @@ async function run(options = {}) {
|
|
|
77637
77772
|
await initDir();
|
|
77638
77773
|
await cleanupLogFiles();
|
|
77639
77774
|
const config = await initConfig();
|
|
77775
|
+
configureLogging(config);
|
|
77640
77776
|
let HOST = config.HOST;
|
|
77641
77777
|
if (config.HOST && !config.APIKEY) {
|
|
77642
77778
|
HOST = "127.0.0.1";
|
|
@@ -77655,6 +77791,15 @@ async function run(options = {}) {
|
|
|
77655
77791
|
});
|
|
77656
77792
|
console.log(HOST);
|
|
77657
77793
|
const servicePort = process.env.SERVICE_PORT ? parseInt(process.env.SERVICE_PORT) : port;
|
|
77794
|
+
const loggerConfig = config.LOG !== false ? {
|
|
77795
|
+
level: config.LOG_LEVEL || "info",
|
|
77796
|
+
stream: mjs_default({
|
|
77797
|
+
path: HOME_DIR,
|
|
77798
|
+
filename: config.LOGNAME || `./logs/ccr-${+/* @__PURE__ */ new Date()}.log`,
|
|
77799
|
+
maxFiles: 3,
|
|
77800
|
+
interval: "1d"
|
|
77801
|
+
})
|
|
77802
|
+
} : false;
|
|
77658
77803
|
const server = createServer({
|
|
77659
77804
|
jsonPath: CONFIG_FILE,
|
|
77660
77805
|
initialConfig: {
|
|
@@ -77668,15 +77813,7 @@ async function run(options = {}) {
|
|
|
77668
77813
|
"claude-code-router.log"
|
|
77669
77814
|
)
|
|
77670
77815
|
},
|
|
77671
|
-
logger:
|
|
77672
|
-
level: "debug",
|
|
77673
|
-
stream: mjs_default({
|
|
77674
|
-
path: HOME_DIR,
|
|
77675
|
-
filename: config.LOGNAME || `./logs/ccr-${+/* @__PURE__ */ new Date()}.log`,
|
|
77676
|
-
maxFiles: 3,
|
|
77677
|
-
interval: "1d"
|
|
77678
|
-
})
|
|
77679
|
-
}
|
|
77816
|
+
logger: loggerConfig
|
|
77680
77817
|
});
|
|
77681
77818
|
server.addHook("preHandler", async (req, reply) => {
|
|
77682
77819
|
return new Promise((resolve, reject) => {
|
|
@@ -77720,7 +77857,7 @@ async function showStatus() {
|
|
|
77720
77857
|
}
|
|
77721
77858
|
|
|
77722
77859
|
// src/utils/codeCommand.ts
|
|
77723
|
-
var
|
|
77860
|
+
var import_child_process3 = require("child_process");
|
|
77724
77861
|
init_utils();
|
|
77725
77862
|
|
|
77726
77863
|
// src/utils/close.ts
|
|
@@ -77774,7 +77911,7 @@ async function executeCodeCommand(args = []) {
|
|
|
77774
77911
|
const claudePath = process.env.CLAUDE_PATH || "claude";
|
|
77775
77912
|
const joinedArgs = args.length > 0 ? args.map((arg) => `"${arg.replace(/\"/g, '\\"')}"`).join(" ") : "";
|
|
77776
77913
|
const stdioConfig = config.NON_INTERACTIVE_MODE ? ["pipe", "inherit", "inherit"] : "inherit";
|
|
77777
|
-
const claudeProcess = (0,
|
|
77914
|
+
const claudeProcess = (0, import_child_process3.spawn)(claudePath + (joinedArgs ? ` ${joinedArgs}` : ""), [], {
|
|
77778
77915
|
env,
|
|
77779
77916
|
stdio: stdioConfig,
|
|
77780
77917
|
shell: true
|
|
@@ -77797,11 +77934,513 @@ async function executeCodeCommand(args = []) {
|
|
|
77797
77934
|
});
|
|
77798
77935
|
}
|
|
77799
77936
|
|
|
77800
|
-
//
|
|
77801
|
-
var
|
|
77937
|
+
// src/utils/statusline.ts
|
|
77938
|
+
var import_promises5 = __toESM(require("node:fs/promises"));
|
|
77939
|
+
var import_child_process4 = require("child_process");
|
|
77940
|
+
var import_node_path6 = __toESM(require("node:path"));
|
|
77941
|
+
init_constants();
|
|
77942
|
+
var import_json52 = __toESM(require_lib());
|
|
77943
|
+
var COLORS = {
|
|
77944
|
+
reset: "\x1B[0m",
|
|
77945
|
+
bold: "\x1B[1m",
|
|
77946
|
+
dim: "\x1B[2m",
|
|
77947
|
+
// 标准颜色
|
|
77948
|
+
black: "\x1B[30m",
|
|
77949
|
+
red: "\x1B[31m",
|
|
77950
|
+
green: "\x1B[32m",
|
|
77951
|
+
yellow: "\x1B[33m",
|
|
77952
|
+
blue: "\x1B[34m",
|
|
77953
|
+
magenta: "\x1B[35m",
|
|
77954
|
+
cyan: "\x1B[36m",
|
|
77955
|
+
white: "\x1B[37m",
|
|
77956
|
+
// 亮色
|
|
77957
|
+
bright_black: "\x1B[90m",
|
|
77958
|
+
bright_red: "\x1B[91m",
|
|
77959
|
+
bright_green: "\x1B[92m",
|
|
77960
|
+
bright_yellow: "\x1B[93m",
|
|
77961
|
+
bright_blue: "\x1B[94m",
|
|
77962
|
+
bright_magenta: "\x1B[95m",
|
|
77963
|
+
bright_cyan: "\x1B[96m",
|
|
77964
|
+
bright_white: "\x1B[97m",
|
|
77965
|
+
// 背景颜色
|
|
77966
|
+
bg_black: "\x1B[40m",
|
|
77967
|
+
bg_red: "\x1B[41m",
|
|
77968
|
+
bg_green: "\x1B[42m",
|
|
77969
|
+
bg_yellow: "\x1B[43m",
|
|
77970
|
+
bg_blue: "\x1B[44m",
|
|
77971
|
+
bg_magenta: "\x1B[45m",
|
|
77972
|
+
bg_cyan: "\x1B[46m",
|
|
77973
|
+
bg_white: "\x1B[47m",
|
|
77974
|
+
// 亮背景色
|
|
77975
|
+
bg_bright_black: "\x1B[100m",
|
|
77976
|
+
bg_bright_red: "\x1B[101m",
|
|
77977
|
+
bg_bright_green: "\x1B[102m",
|
|
77978
|
+
bg_bright_yellow: "\x1B[103m",
|
|
77979
|
+
bg_bright_blue: "\x1B[104m",
|
|
77980
|
+
bg_bright_magenta: "\x1B[105m",
|
|
77981
|
+
bg_bright_cyan: "\x1B[106m",
|
|
77982
|
+
bg_bright_white: "\x1B[107m"
|
|
77983
|
+
};
|
|
77984
|
+
var TRUE_COLOR_PREFIX = "\x1B[38;2;";
|
|
77985
|
+
function hexToRgb(hex) {
|
|
77986
|
+
hex = hex.replace(/^#/, "").trim();
|
|
77987
|
+
if (hex.length === 3) {
|
|
77988
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
77989
|
+
}
|
|
77990
|
+
if (hex.length !== 6) {
|
|
77991
|
+
return null;
|
|
77992
|
+
}
|
|
77993
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
77994
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
77995
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
77996
|
+
if (isNaN(r) || isNaN(g) || isNaN(b) || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
|
|
77997
|
+
return null;
|
|
77998
|
+
}
|
|
77999
|
+
return { r, g, b };
|
|
78000
|
+
}
|
|
78001
|
+
function getColorCode(colorName) {
|
|
78002
|
+
if (colorName.startsWith("#") || /^[0-9a-fA-F]{6}$/.test(colorName) || /^[0-9a-fA-F]{3}$/.test(colorName)) {
|
|
78003
|
+
const rgb = hexToRgb(colorName);
|
|
78004
|
+
if (rgb) {
|
|
78005
|
+
return `${TRUE_COLOR_PREFIX}${rgb.r};${rgb.g};${rgb.b}m`;
|
|
78006
|
+
}
|
|
78007
|
+
}
|
|
78008
|
+
return "";
|
|
78009
|
+
}
|
|
78010
|
+
function replaceVariables(text, variables) {
|
|
78011
|
+
return text.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
|
|
78012
|
+
return variables[varName] || match;
|
|
78013
|
+
});
|
|
78014
|
+
}
|
|
78015
|
+
var DEFAULT_THEME = {
|
|
78016
|
+
modules: [
|
|
78017
|
+
{
|
|
78018
|
+
type: "workDir",
|
|
78019
|
+
icon: "\u{F024B}",
|
|
78020
|
+
// nf-md-folder_outline
|
|
78021
|
+
text: "{{workDirName}}",
|
|
78022
|
+
color: "bright_blue"
|
|
78023
|
+
},
|
|
78024
|
+
{
|
|
78025
|
+
type: "gitBranch",
|
|
78026
|
+
icon: "\uE725",
|
|
78027
|
+
// nf-dev-git_branch
|
|
78028
|
+
text: "{{gitBranch}}",
|
|
78029
|
+
color: "bright_magenta"
|
|
78030
|
+
},
|
|
78031
|
+
{
|
|
78032
|
+
type: "model",
|
|
78033
|
+
icon: "\u{F06A9}",
|
|
78034
|
+
// nf-md-robot_outline
|
|
78035
|
+
text: "{{model}}",
|
|
78036
|
+
color: "bright_cyan"
|
|
78037
|
+
},
|
|
78038
|
+
{
|
|
78039
|
+
type: "usage",
|
|
78040
|
+
icon: "\u2191",
|
|
78041
|
+
// 上箭头
|
|
78042
|
+
text: "{{inputTokens}}",
|
|
78043
|
+
color: "bright_green"
|
|
78044
|
+
},
|
|
78045
|
+
{
|
|
78046
|
+
type: "usage",
|
|
78047
|
+
icon: "\u2193",
|
|
78048
|
+
// 下箭头
|
|
78049
|
+
text: "{{outputTokens}}",
|
|
78050
|
+
color: "bright_yellow"
|
|
78051
|
+
}
|
|
78052
|
+
]
|
|
78053
|
+
};
|
|
78054
|
+
var POWERLINE_THEME = {
|
|
78055
|
+
modules: [
|
|
78056
|
+
{
|
|
78057
|
+
type: "workDir",
|
|
78058
|
+
icon: "\u{F024B}",
|
|
78059
|
+
// nf-md-folder_outline
|
|
78060
|
+
text: "{{workDirName}}",
|
|
78061
|
+
color: "white",
|
|
78062
|
+
background: "bg_bright_blue"
|
|
78063
|
+
},
|
|
78064
|
+
{
|
|
78065
|
+
type: "gitBranch",
|
|
78066
|
+
icon: "\uE725",
|
|
78067
|
+
// nf-dev-git_branch
|
|
78068
|
+
text: "{{gitBranch}}",
|
|
78069
|
+
color: "white",
|
|
78070
|
+
background: "bg_bright_magenta"
|
|
78071
|
+
},
|
|
78072
|
+
{
|
|
78073
|
+
type: "model",
|
|
78074
|
+
icon: "\u{F06A9}",
|
|
78075
|
+
// nf-md-robot_outline
|
|
78076
|
+
text: "{{model}}",
|
|
78077
|
+
color: "white",
|
|
78078
|
+
background: "bg_bright_cyan"
|
|
78079
|
+
},
|
|
78080
|
+
{
|
|
78081
|
+
type: "usage",
|
|
78082
|
+
icon: "\u2191",
|
|
78083
|
+
// 上箭头
|
|
78084
|
+
text: "{{inputTokens}}",
|
|
78085
|
+
color: "white",
|
|
78086
|
+
background: "bg_bright_green"
|
|
78087
|
+
},
|
|
78088
|
+
{
|
|
78089
|
+
type: "usage",
|
|
78090
|
+
icon: "\u2193",
|
|
78091
|
+
// 下箭头
|
|
78092
|
+
text: "{{outputTokens}}",
|
|
78093
|
+
color: "white",
|
|
78094
|
+
background: "bg_bright_yellow"
|
|
78095
|
+
}
|
|
78096
|
+
]
|
|
78097
|
+
};
|
|
78098
|
+
var SIMPLE_THEME = {
|
|
78099
|
+
modules: [
|
|
78100
|
+
{
|
|
78101
|
+
type: "workDir",
|
|
78102
|
+
icon: "",
|
|
78103
|
+
text: "{{workDirName}}",
|
|
78104
|
+
color: "bright_blue"
|
|
78105
|
+
},
|
|
78106
|
+
{
|
|
78107
|
+
type: "gitBranch",
|
|
78108
|
+
icon: "",
|
|
78109
|
+
text: "{{gitBranch}}",
|
|
78110
|
+
color: "bright_magenta"
|
|
78111
|
+
},
|
|
78112
|
+
{
|
|
78113
|
+
type: "model",
|
|
78114
|
+
icon: "",
|
|
78115
|
+
text: "{{model}}",
|
|
78116
|
+
color: "bright_cyan"
|
|
78117
|
+
},
|
|
78118
|
+
{
|
|
78119
|
+
type: "usage",
|
|
78120
|
+
icon: "\u2191",
|
|
78121
|
+
text: "{{inputTokens}}",
|
|
78122
|
+
color: "bright_green"
|
|
78123
|
+
},
|
|
78124
|
+
{
|
|
78125
|
+
type: "usage",
|
|
78126
|
+
icon: "\u2193",
|
|
78127
|
+
text: "{{outputTokens}}",
|
|
78128
|
+
color: "bright_yellow"
|
|
78129
|
+
}
|
|
78130
|
+
]
|
|
78131
|
+
};
|
|
78132
|
+
function formatUsage(input_tokens, output_tokens) {
|
|
78133
|
+
if (input_tokens > 1e3 || output_tokens > 1e3) {
|
|
78134
|
+
const inputFormatted = input_tokens > 1e3 ? `${(input_tokens / 1e3).toFixed(1)}k` : `${input_tokens}`;
|
|
78135
|
+
const outputFormatted = output_tokens > 1e3 ? `${(output_tokens / 1e3).toFixed(1)}k` : `${output_tokens}`;
|
|
78136
|
+
return `${inputFormatted} ${outputFormatted}`;
|
|
78137
|
+
}
|
|
78138
|
+
return `${input_tokens} ${output_tokens}`;
|
|
78139
|
+
}
|
|
78140
|
+
async function getProjectThemeConfig() {
|
|
78141
|
+
try {
|
|
78142
|
+
const configPath = CONFIG_FILE;
|
|
78143
|
+
try {
|
|
78144
|
+
await import_promises5.default.access(configPath);
|
|
78145
|
+
} catch {
|
|
78146
|
+
return { theme: null, style: "default" };
|
|
78147
|
+
}
|
|
78148
|
+
const configContent = await import_promises5.default.readFile(configPath, "utf-8");
|
|
78149
|
+
const config = import_json52.default.parse(configContent);
|
|
78150
|
+
if (config.StatusLine) {
|
|
78151
|
+
const currentStyle = config.StatusLine.currentStyle || "default";
|
|
78152
|
+
if (config.StatusLine[currentStyle] && config.StatusLine[currentStyle].modules) {
|
|
78153
|
+
return { theme: config.StatusLine[currentStyle], style: currentStyle };
|
|
78154
|
+
}
|
|
78155
|
+
}
|
|
78156
|
+
} catch (error) {
|
|
78157
|
+
}
|
|
78158
|
+
return { theme: null, style: "default" };
|
|
78159
|
+
}
|
|
78160
|
+
function shouldUseSimpleTheme() {
|
|
78161
|
+
if (process.env.USE_SIMPLE_ICONS === "true") {
|
|
78162
|
+
return true;
|
|
78163
|
+
}
|
|
78164
|
+
const term = process.env.TERM || "";
|
|
78165
|
+
const unsupportedTerms = ["dumb", "unknown"];
|
|
78166
|
+
if (unsupportedTerms.includes(term)) {
|
|
78167
|
+
return true;
|
|
78168
|
+
}
|
|
78169
|
+
return false;
|
|
78170
|
+
}
|
|
78171
|
+
function canDisplayNerdFonts() {
|
|
78172
|
+
if (process.env.USE_SIMPLE_ICONS === "true") {
|
|
78173
|
+
return false;
|
|
78174
|
+
}
|
|
78175
|
+
const fontEnvVars = ["NERD_FONT", "NERDFONT", "FONT"];
|
|
78176
|
+
for (const envVar of fontEnvVars) {
|
|
78177
|
+
const value = process.env[envVar];
|
|
78178
|
+
if (value && (value.includes("Nerd") || value.includes("nerd"))) {
|
|
78179
|
+
return true;
|
|
78180
|
+
}
|
|
78181
|
+
}
|
|
78182
|
+
const termProgram = process.env.TERM_PROGRAM || "";
|
|
78183
|
+
const supportedTerminals = ["iTerm.app", "vscode", "Hyper", "kitty", "alacritty"];
|
|
78184
|
+
if (supportedTerminals.includes(termProgram)) {
|
|
78185
|
+
return true;
|
|
78186
|
+
}
|
|
78187
|
+
const colorTerm = process.env.COLORTERM || "";
|
|
78188
|
+
if (colorTerm.includes("truecolor") || colorTerm.includes("24bit")) {
|
|
78189
|
+
return true;
|
|
78190
|
+
}
|
|
78191
|
+
return process.env.USE_SIMPLE_ICONS !== "true";
|
|
78192
|
+
}
|
|
78193
|
+
async function parseStatusLineData(input) {
|
|
78194
|
+
try {
|
|
78195
|
+
const useSimpleTheme = shouldUseSimpleTheme();
|
|
78196
|
+
const canDisplayNerd = canDisplayNerdFonts();
|
|
78197
|
+
const effectiveTheme = useSimpleTheme || !canDisplayNerd ? SIMPLE_THEME : DEFAULT_THEME;
|
|
78198
|
+
const { theme: projectTheme, style: currentStyle } = await getProjectThemeConfig();
|
|
78199
|
+
const theme = projectTheme || effectiveTheme;
|
|
78200
|
+
const workDir = input.workspace.current_dir;
|
|
78201
|
+
let gitBranch = "";
|
|
78202
|
+
try {
|
|
78203
|
+
gitBranch = (0, import_child_process4.execSync)("git branch --show-current", {
|
|
78204
|
+
cwd: workDir,
|
|
78205
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
78206
|
+
}).toString().trim();
|
|
78207
|
+
} catch (error) {
|
|
78208
|
+
}
|
|
78209
|
+
const transcriptContent = await import_promises5.default.readFile(input.transcript_path, "utf-8");
|
|
78210
|
+
const lines = transcriptContent.trim().split("\n");
|
|
78211
|
+
let model = "";
|
|
78212
|
+
let inputTokens = 0;
|
|
78213
|
+
let outputTokens = 0;
|
|
78214
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
78215
|
+
try {
|
|
78216
|
+
const message = JSON.parse(lines[i]);
|
|
78217
|
+
if (message.type === "assistant" && message.message.model) {
|
|
78218
|
+
model = message.message.model;
|
|
78219
|
+
if (message.message.usage) {
|
|
78220
|
+
inputTokens = message.message.usage.input_tokens;
|
|
78221
|
+
outputTokens = message.message.usage.output_tokens;
|
|
78222
|
+
}
|
|
78223
|
+
break;
|
|
78224
|
+
}
|
|
78225
|
+
} catch (parseError) {
|
|
78226
|
+
continue;
|
|
78227
|
+
}
|
|
78228
|
+
}
|
|
78229
|
+
if (!model) {
|
|
78230
|
+
try {
|
|
78231
|
+
const projectConfigPath = import_node_path6.default.join(workDir, ".claude-code-router", "config.json");
|
|
78232
|
+
let configPath = projectConfigPath;
|
|
78233
|
+
try {
|
|
78234
|
+
await import_promises5.default.access(projectConfigPath);
|
|
78235
|
+
} catch {
|
|
78236
|
+
configPath = CONFIG_FILE;
|
|
78237
|
+
}
|
|
78238
|
+
const configContent = await import_promises5.default.readFile(configPath, "utf-8");
|
|
78239
|
+
const config = import_json52.default.parse(configContent);
|
|
78240
|
+
if (config.Router && config.Router.default) {
|
|
78241
|
+
const [, defaultModel] = config.Router.default.split(",");
|
|
78242
|
+
if (defaultModel) {
|
|
78243
|
+
model = defaultModel.trim();
|
|
78244
|
+
}
|
|
78245
|
+
}
|
|
78246
|
+
} catch (configError) {
|
|
78247
|
+
}
|
|
78248
|
+
}
|
|
78249
|
+
if (!model) {
|
|
78250
|
+
model = input.model.display_name;
|
|
78251
|
+
}
|
|
78252
|
+
const workDirName = workDir.split("/").pop() || "";
|
|
78253
|
+
const usage = formatUsage(inputTokens, outputTokens);
|
|
78254
|
+
const [formattedInputTokens, formattedOutputTokens] = usage.split(" ");
|
|
78255
|
+
const variables = {
|
|
78256
|
+
workDirName,
|
|
78257
|
+
gitBranch,
|
|
78258
|
+
model,
|
|
78259
|
+
inputTokens: formattedInputTokens,
|
|
78260
|
+
outputTokens: formattedOutputTokens
|
|
78261
|
+
};
|
|
78262
|
+
const isPowerline = currentStyle === "powerline";
|
|
78263
|
+
if (isPowerline) {
|
|
78264
|
+
return renderPowerlineStyle(theme, variables);
|
|
78265
|
+
} else {
|
|
78266
|
+
return renderDefaultStyle(theme, variables);
|
|
78267
|
+
}
|
|
78268
|
+
} catch (error) {
|
|
78269
|
+
return "";
|
|
78270
|
+
}
|
|
78271
|
+
}
|
|
78272
|
+
function renderDefaultStyle(theme, variables) {
|
|
78273
|
+
const modules = theme.modules || DEFAULT_THEME.modules;
|
|
78274
|
+
const parts = [];
|
|
78275
|
+
for (let i = 0; i < Math.min(modules.length, 5); i++) {
|
|
78276
|
+
const module2 = modules[i];
|
|
78277
|
+
const color = module2.color ? getColorCode(module2.color) : "";
|
|
78278
|
+
const background = module2.background ? getColorCode(module2.background) : "";
|
|
78279
|
+
const icon = module2.icon || "";
|
|
78280
|
+
const text = replaceVariables(module2.text, variables);
|
|
78281
|
+
if (!text && module2.type !== "usage") {
|
|
78282
|
+
continue;
|
|
78283
|
+
}
|
|
78284
|
+
let part = `${background}${color}`;
|
|
78285
|
+
if (icon) {
|
|
78286
|
+
part += `${icon} `;
|
|
78287
|
+
}
|
|
78288
|
+
part += `${text}${COLORS.reset}`;
|
|
78289
|
+
parts.push(part);
|
|
78290
|
+
}
|
|
78291
|
+
return parts.join(" ");
|
|
78292
|
+
}
|
|
78293
|
+
var SEP_RIGHT = "\uE0B0";
|
|
78294
|
+
var COLOR_MAP = {
|
|
78295
|
+
// 基础颜色映射到256色
|
|
78296
|
+
black: 0,
|
|
78297
|
+
red: 1,
|
|
78298
|
+
green: 2,
|
|
78299
|
+
yellow: 3,
|
|
78300
|
+
blue: 4,
|
|
78301
|
+
magenta: 5,
|
|
78302
|
+
cyan: 6,
|
|
78303
|
+
white: 7,
|
|
78304
|
+
bright_black: 8,
|
|
78305
|
+
bright_red: 9,
|
|
78306
|
+
bright_green: 10,
|
|
78307
|
+
bright_yellow: 11,
|
|
78308
|
+
bright_blue: 12,
|
|
78309
|
+
bright_magenta: 13,
|
|
78310
|
+
bright_cyan: 14,
|
|
78311
|
+
bright_white: 15,
|
|
78312
|
+
// 亮背景色映射
|
|
78313
|
+
bg_black: 0,
|
|
78314
|
+
bg_red: 1,
|
|
78315
|
+
bg_green: 2,
|
|
78316
|
+
bg_yellow: 3,
|
|
78317
|
+
bg_blue: 4,
|
|
78318
|
+
bg_magenta: 5,
|
|
78319
|
+
bg_cyan: 6,
|
|
78320
|
+
bg_white: 7,
|
|
78321
|
+
bg_bright_black: 8,
|
|
78322
|
+
bg_bright_red: 9,
|
|
78323
|
+
bg_bright_green: 10,
|
|
78324
|
+
bg_bright_yellow: 11,
|
|
78325
|
+
bg_bright_blue: 12,
|
|
78326
|
+
bg_bright_magenta: 13,
|
|
78327
|
+
bg_bright_cyan: 14,
|
|
78328
|
+
bg_bright_white: 15,
|
|
78329
|
+
// 自定义颜色映射
|
|
78330
|
+
bg_bright_orange: 202,
|
|
78331
|
+
bg_bright_purple: 129
|
|
78332
|
+
};
|
|
78333
|
+
function getTrueColorRgb(colorName) {
|
|
78334
|
+
if (COLOR_MAP[colorName] !== void 0) {
|
|
78335
|
+
const color256 = COLOR_MAP[colorName];
|
|
78336
|
+
return color256ToRgb(color256);
|
|
78337
|
+
}
|
|
78338
|
+
if (colorName.startsWith("#") || /^[0-9a-fA-F]{6}$/.test(colorName) || /^[0-9a-fA-F]{3}$/.test(colorName)) {
|
|
78339
|
+
return hexToRgb(colorName);
|
|
78340
|
+
}
|
|
78341
|
+
if (colorName.startsWith("bg_#")) {
|
|
78342
|
+
return hexToRgb(colorName.substring(3));
|
|
78343
|
+
}
|
|
78344
|
+
return null;
|
|
78345
|
+
}
|
|
78346
|
+
function color256ToRgb(index) {
|
|
78347
|
+
if (index < 0 || index > 255) return null;
|
|
78348
|
+
if (index < 16) {
|
|
78349
|
+
const basicColors = [
|
|
78350
|
+
[0, 0, 0],
|
|
78351
|
+
[128, 0, 0],
|
|
78352
|
+
[0, 128, 0],
|
|
78353
|
+
[128, 128, 0],
|
|
78354
|
+
[0, 0, 128],
|
|
78355
|
+
[128, 0, 128],
|
|
78356
|
+
[0, 128, 128],
|
|
78357
|
+
[192, 192, 192],
|
|
78358
|
+
[128, 128, 128],
|
|
78359
|
+
[255, 0, 0],
|
|
78360
|
+
[0, 255, 0],
|
|
78361
|
+
[255, 255, 0],
|
|
78362
|
+
[0, 0, 255],
|
|
78363
|
+
[255, 0, 255],
|
|
78364
|
+
[0, 255, 255],
|
|
78365
|
+
[255, 255, 255]
|
|
78366
|
+
];
|
|
78367
|
+
return { r: basicColors[index][0], g: basicColors[index][1], b: basicColors[index][2] };
|
|
78368
|
+
} else if (index < 232) {
|
|
78369
|
+
const i = index - 16;
|
|
78370
|
+
const r = Math.floor(i / 36);
|
|
78371
|
+
const g = Math.floor(i % 36 / 6);
|
|
78372
|
+
const b = i % 6;
|
|
78373
|
+
const rgb = [0, 95, 135, 175, 215, 255];
|
|
78374
|
+
return { r: rgb[r], g: rgb[g], b: rgb[b] };
|
|
78375
|
+
} else {
|
|
78376
|
+
const gray = 8 + (index - 232) * 10;
|
|
78377
|
+
return { r: gray, g: gray, b: gray };
|
|
78378
|
+
}
|
|
78379
|
+
}
|
|
78380
|
+
function segment(text, textFg, bgColor, nextBgColor) {
|
|
78381
|
+
const bgRgb = getTrueColorRgb(bgColor);
|
|
78382
|
+
if (!bgRgb) {
|
|
78383
|
+
const defaultBlueRgb = { r: 33, g: 150, b: 243 };
|
|
78384
|
+
const curBg2 = `\x1B[48;2;${defaultBlueRgb.r};${defaultBlueRgb.g};${defaultBlueRgb.b}m`;
|
|
78385
|
+
const fgColor2 = `\x1B[38;2;255;255;255m`;
|
|
78386
|
+
const body2 = `${curBg2}${fgColor2} ${text} \x1B[0m`;
|
|
78387
|
+
return body2;
|
|
78388
|
+
}
|
|
78389
|
+
const curBg = `\x1B[48;2;${bgRgb.r};${bgRgb.g};${bgRgb.b}m`;
|
|
78390
|
+
let fgRgb = { r: 255, g: 255, b: 255 };
|
|
78391
|
+
const textFgRgb = getTrueColorRgb(textFg);
|
|
78392
|
+
if (textFgRgb) {
|
|
78393
|
+
fgRgb = textFgRgb;
|
|
78394
|
+
}
|
|
78395
|
+
const fgColor = `\x1B[38;2;${fgRgb.r};${fgRgb.g};${fgRgb.b}m`;
|
|
78396
|
+
const body = `${curBg}${fgColor} ${text} \x1B[0m`;
|
|
78397
|
+
if (nextBgColor != null) {
|
|
78398
|
+
const nextBgRgb = getTrueColorRgb(nextBgColor);
|
|
78399
|
+
if (nextBgRgb) {
|
|
78400
|
+
const sepCurFg2 = `\x1B[38;2;${bgRgb.r};${bgRgb.g};${bgRgb.b}m`;
|
|
78401
|
+
const sepNextBg2 = `\x1B[48;2;${nextBgRgb.r};${nextBgRgb.g};${nextBgRgb.b}m`;
|
|
78402
|
+
const sep3 = `${sepCurFg2}${sepNextBg2}${SEP_RIGHT}\x1B[0m`;
|
|
78403
|
+
return body + sep3;
|
|
78404
|
+
}
|
|
78405
|
+
const sepCurFg = `\x1B[38;2;${bgRgb.r};${bgRgb.g};${bgRgb.b}m`;
|
|
78406
|
+
const sepNextBg = `\x1B[48;2;0;0;0m`;
|
|
78407
|
+
const sep2 = `${sepCurFg}${sepNextBg}${SEP_RIGHT}\x1B[0m`;
|
|
78408
|
+
return body + sep2;
|
|
78409
|
+
}
|
|
78410
|
+
return body;
|
|
78411
|
+
}
|
|
78412
|
+
function renderPowerlineStyle(theme, variables) {
|
|
78413
|
+
const modules = theme.modules || POWERLINE_THEME.modules;
|
|
78414
|
+
const segments = [];
|
|
78415
|
+
for (let i = 0; i < Math.min(modules.length, 5); i++) {
|
|
78416
|
+
const module2 = modules[i];
|
|
78417
|
+
const color = module2.color || "white";
|
|
78418
|
+
const backgroundName = module2.background || "";
|
|
78419
|
+
const icon = module2.icon || "";
|
|
78420
|
+
const text = replaceVariables(module2.text, variables);
|
|
78421
|
+
if (!text && module2.type !== "usage") {
|
|
78422
|
+
continue;
|
|
78423
|
+
}
|
|
78424
|
+
let displayText = "";
|
|
78425
|
+
if (icon) {
|
|
78426
|
+
displayText += `${icon} `;
|
|
78427
|
+
}
|
|
78428
|
+
displayText += text;
|
|
78429
|
+
let nextBackground = null;
|
|
78430
|
+
if (i < modules.length - 1) {
|
|
78431
|
+
const nextModule = modules[i + 1];
|
|
78432
|
+
nextBackground = nextModule.background || null;
|
|
78433
|
+
}
|
|
78434
|
+
const actualBackground = backgroundName || "bg_bright_blue";
|
|
78435
|
+
const segmentStr = segment(displayText, color, actualBackground, nextBackground);
|
|
78436
|
+
segments.push(segmentStr);
|
|
78437
|
+
}
|
|
78438
|
+
return segments.join("");
|
|
78439
|
+
}
|
|
77802
78440
|
|
|
77803
78441
|
// src/cli.ts
|
|
77804
|
-
var
|
|
78442
|
+
var import_package = __toESM(require_package3());
|
|
78443
|
+
var import_child_process5 = require("child_process");
|
|
77805
78444
|
init_constants();
|
|
77806
78445
|
var import_fs6 = __toESM(require("fs"));
|
|
77807
78446
|
var import_path6 = require("path");
|
|
@@ -77814,6 +78453,7 @@ Commands:
|
|
|
77814
78453
|
stop Stop server
|
|
77815
78454
|
restart Restart server
|
|
77816
78455
|
status Show server status
|
|
78456
|
+
statusline Integrated statusline
|
|
77817
78457
|
code Execute claude command
|
|
77818
78458
|
ui Open the web UI in browser
|
|
77819
78459
|
-v, version Show version information
|
|
@@ -77865,11 +78505,31 @@ async function main() {
|
|
|
77865
78505
|
case "status":
|
|
77866
78506
|
await showStatus();
|
|
77867
78507
|
break;
|
|
78508
|
+
case "statusline":
|
|
78509
|
+
let inputData = "";
|
|
78510
|
+
process.stdin.setEncoding("utf-8");
|
|
78511
|
+
process.stdin.on("readable", () => {
|
|
78512
|
+
let chunk;
|
|
78513
|
+
while ((chunk = process.stdin.read()) !== null) {
|
|
78514
|
+
inputData += chunk;
|
|
78515
|
+
}
|
|
78516
|
+
});
|
|
78517
|
+
process.stdin.on("end", async () => {
|
|
78518
|
+
try {
|
|
78519
|
+
const input = JSON.parse(inputData);
|
|
78520
|
+
const statusLine = await parseStatusLineData(input);
|
|
78521
|
+
console.log(statusLine);
|
|
78522
|
+
} catch (error) {
|
|
78523
|
+
console.error("Error parsing status line data:", error);
|
|
78524
|
+
process.exit(1);
|
|
78525
|
+
}
|
|
78526
|
+
});
|
|
78527
|
+
break;
|
|
77868
78528
|
case "code":
|
|
77869
78529
|
if (!isServiceRunning()) {
|
|
77870
78530
|
console.log("Service not running, starting service...");
|
|
77871
78531
|
const cliPath2 = (0, import_path6.join)(__dirname, "cli.js");
|
|
77872
|
-
const startProcess2 = (0,
|
|
78532
|
+
const startProcess2 = (0, import_child_process5.spawn)("node", [cliPath2, "start"], {
|
|
77873
78533
|
detached: true,
|
|
77874
78534
|
stdio: "ignore"
|
|
77875
78535
|
});
|
|
@@ -77896,7 +78556,7 @@ async function main() {
|
|
|
77896
78556
|
if (!isServiceRunning()) {
|
|
77897
78557
|
console.log("Service not running, starting service...");
|
|
77898
78558
|
const cliPath2 = (0, import_path6.join)(__dirname, "cli.js");
|
|
77899
|
-
const startProcess2 = (0,
|
|
78559
|
+
const startProcess2 = (0, import_child_process5.spawn)("node", [cliPath2, "start"], {
|
|
77900
78560
|
detached: true,
|
|
77901
78561
|
stdio: "ignore"
|
|
77902
78562
|
});
|
|
@@ -77933,7 +78593,7 @@ async function main() {
|
|
|
77933
78593
|
console.log(
|
|
77934
78594
|
"Please edit this file with your actual configuration."
|
|
77935
78595
|
);
|
|
77936
|
-
const restartProcess = (0,
|
|
78596
|
+
const restartProcess = (0, import_child_process5.spawn)("node", [cliPath2, "start"], {
|
|
77937
78597
|
detached: true,
|
|
77938
78598
|
stdio: "ignore"
|
|
77939
78599
|
});
|
|
@@ -77975,7 +78635,7 @@ async function main() {
|
|
|
77975
78635
|
console.error("Unsupported platform for opening browser");
|
|
77976
78636
|
process.exit(1);
|
|
77977
78637
|
}
|
|
77978
|
-
(0,
|
|
78638
|
+
(0, import_child_process5.exec)(openCommand, (error) => {
|
|
77979
78639
|
if (error) {
|
|
77980
78640
|
console.error("Failed to open browser:", error.message);
|
|
77981
78641
|
process.exit(1);
|
|
@@ -77984,7 +78644,7 @@ async function main() {
|
|
|
77984
78644
|
break;
|
|
77985
78645
|
case "-v":
|
|
77986
78646
|
case "version":
|
|
77987
|
-
console.log(`claude-code-router version: ${version}`);
|
|
78647
|
+
console.log(`claude-code-router version: ${import_package.version}`);
|
|
77988
78648
|
break;
|
|
77989
78649
|
case "restart":
|
|
77990
78650
|
try {
|
|
@@ -78004,7 +78664,7 @@ async function main() {
|
|
|
78004
78664
|
}
|
|
78005
78665
|
console.log("Starting claude code router service...");
|
|
78006
78666
|
const cliPath = (0, import_path6.join)(__dirname, "cli.js");
|
|
78007
|
-
const startProcess = (0,
|
|
78667
|
+
const startProcess = (0, import_child_process5.spawn)("node", [cliPath, "start"], {
|
|
78008
78668
|
detached: true,
|
|
78009
78669
|
stdio: "ignore"
|
|
78010
78670
|
});
|