node-karin 1.9.8 → 1.9.10
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/CHANGELOG.md +31 -0
- package/dist/index.d.ts +121 -54
- package/dist/index.mjs +646 -502
- package/dist/start/index.mjs +23 -25
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -76,8 +76,8 @@ function getDefaultExportFromCjs(x) {
|
|
|
76
76
|
function requireMain() {
|
|
77
77
|
if (hasRequiredMain) return main$1.exports;
|
|
78
78
|
hasRequiredMain = 1;
|
|
79
|
-
const
|
|
80
|
-
const
|
|
79
|
+
const fs38 = fs15;
|
|
80
|
+
const path37 = path;
|
|
81
81
|
const os5 = require$$2;
|
|
82
82
|
const crypto9 = require$$22;
|
|
83
83
|
const packageJson = require$$4;
|
|
@@ -180,7 +180,7 @@ function requireMain() {
|
|
|
180
180
|
if (options && options.path && options.path.length > 0) {
|
|
181
181
|
if (Array.isArray(options.path)) {
|
|
182
182
|
for (const filepath of options.path) {
|
|
183
|
-
if (
|
|
183
|
+
if (fs38.existsSync(filepath)) {
|
|
184
184
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -188,15 +188,15 @@ function requireMain() {
|
|
|
188
188
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
189
189
|
}
|
|
190
190
|
} else {
|
|
191
|
-
possibleVaultPath =
|
|
191
|
+
possibleVaultPath = path37.resolve(process.cwd(), ".env.vault");
|
|
192
192
|
}
|
|
193
|
-
if (
|
|
193
|
+
if (fs38.existsSync(possibleVaultPath)) {
|
|
194
194
|
return possibleVaultPath;
|
|
195
195
|
}
|
|
196
196
|
return null;
|
|
197
197
|
}
|
|
198
198
|
function _resolveHome(envPath) {
|
|
199
|
-
return envPath[0] === "~" ?
|
|
199
|
+
return envPath[0] === "~" ? path37.join(os5.homedir(), envPath.slice(1)) : envPath;
|
|
200
200
|
}
|
|
201
201
|
function _configVault2(options) {
|
|
202
202
|
const debug3 = Boolean(options && options.debug);
|
|
@@ -212,7 +212,7 @@ function requireMain() {
|
|
|
212
212
|
return { parsed };
|
|
213
213
|
}
|
|
214
214
|
function configDotenv2(options) {
|
|
215
|
-
const dotenvPath =
|
|
215
|
+
const dotenvPath = path37.resolve(process.cwd(), ".env");
|
|
216
216
|
let encoding = "utf8";
|
|
217
217
|
const debug3 = Boolean(options && options.debug);
|
|
218
218
|
if (options && options.encoding) {
|
|
@@ -237,7 +237,7 @@ function requireMain() {
|
|
|
237
237
|
const parsedAll = {};
|
|
238
238
|
for (const path210 of optionPaths) {
|
|
239
239
|
try {
|
|
240
|
-
const parsed = DotenvModule.parse(
|
|
240
|
+
const parsed = DotenvModule.parse(fs38.readFileSync(path210, { encoding }));
|
|
241
241
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
242
242
|
} catch (e) {
|
|
243
243
|
if (debug3) {
|
|
@@ -893,30 +893,30 @@ var init_watch = __esm({
|
|
|
893
893
|
"src/utils/fs/watch.ts"() {
|
|
894
894
|
init_require();
|
|
895
895
|
cache2 = /* @__PURE__ */ new Map();
|
|
896
|
-
watch = (
|
|
897
|
-
const isWatch = cache2.get(
|
|
896
|
+
watch = (file2, fnc2, options) => {
|
|
897
|
+
const isWatch = cache2.get(file2);
|
|
898
898
|
if (isWatch) {
|
|
899
899
|
isWatch.close();
|
|
900
|
-
cache2.delete(
|
|
900
|
+
cache2.delete(file2);
|
|
901
901
|
}
|
|
902
|
-
const watcher2 = chokidar.watch(
|
|
903
|
-
cache2.set(
|
|
902
|
+
const watcher2 = chokidar.watch(file2);
|
|
903
|
+
cache2.set(file2, watcher2);
|
|
904
904
|
watcher2.on("change", async () => {
|
|
905
|
-
logger.info(`[watch][change] ${path4.relative(process.cwd(),
|
|
906
|
-
const oldData = requireFileSync(
|
|
907
|
-
clearRequireFile(
|
|
908
|
-
const newData = requireFileSync(
|
|
905
|
+
logger.info(`[watch][change] ${path4.relative(process.cwd(), file2).replace(/\\/g, "/")}`);
|
|
906
|
+
const oldData = requireFileSync(file2, { ...options, readCache: true });
|
|
907
|
+
clearRequireFile(file2);
|
|
908
|
+
const newData = requireFileSync(file2, { ...options, force: true });
|
|
909
909
|
typeof fnc2 === "function" && fnc2(oldData, newData);
|
|
910
910
|
});
|
|
911
911
|
watcher2.on("unlink", () => {
|
|
912
|
-
logger.info(`[watch][unlink] ${path4.relative(process.cwd(),
|
|
913
|
-
clearRequireFile(
|
|
912
|
+
logger.info(`[watch][unlink] ${path4.relative(process.cwd(), file2).replace(/\\/g, "/")}`);
|
|
913
|
+
clearRequireFile(file2);
|
|
914
914
|
});
|
|
915
915
|
watcher2.once("close", () => {
|
|
916
|
-
cache2.delete(
|
|
917
|
-
clearRequireFile(
|
|
916
|
+
cache2.delete(file2);
|
|
917
|
+
clearRequireFile(file2);
|
|
918
918
|
});
|
|
919
|
-
return new Watch(
|
|
919
|
+
return new Watch(file2, watcher2, options);
|
|
920
920
|
};
|
|
921
921
|
watchAndMerge = (dynamicFile, defaultCFile, fnc2) => {
|
|
922
922
|
const watcher2 = watch(dynamicFile, fnc2);
|
|
@@ -926,9 +926,9 @@ var init_watch = __esm({
|
|
|
926
926
|
watcher;
|
|
927
927
|
file;
|
|
928
928
|
options;
|
|
929
|
-
constructor(
|
|
929
|
+
constructor(file2, watcher2, options) {
|
|
930
930
|
this.watcher = watcher2;
|
|
931
|
-
this.file =
|
|
931
|
+
this.file = file2;
|
|
932
932
|
this.options = options;
|
|
933
933
|
}
|
|
934
934
|
/**
|
|
@@ -983,25 +983,25 @@ var init_watch = __esm({
|
|
|
983
983
|
var exists, isDir, isFile, mkdir, existToMkdir;
|
|
984
984
|
var init_fsPromises = __esm({
|
|
985
985
|
"src/utils/fs/fsPromises.ts"() {
|
|
986
|
-
exists = async (
|
|
986
|
+
exists = async (file2) => {
|
|
987
987
|
try {
|
|
988
|
-
await fs5.promises.access(
|
|
988
|
+
await fs5.promises.access(file2, fs5.constants.F_OK);
|
|
989
989
|
return true;
|
|
990
990
|
} catch {
|
|
991
991
|
return false;
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
|
-
isDir = async (
|
|
994
|
+
isDir = async (file2) => {
|
|
995
995
|
try {
|
|
996
|
-
const stat = await fs5.promises.stat(
|
|
996
|
+
const stat = await fs5.promises.stat(file2);
|
|
997
997
|
return stat.isDirectory();
|
|
998
998
|
} catch {
|
|
999
999
|
return false;
|
|
1000
1000
|
}
|
|
1001
1001
|
};
|
|
1002
|
-
isFile = async (
|
|
1002
|
+
isFile = async (file2) => {
|
|
1003
1003
|
try {
|
|
1004
|
-
const stat = await fs5.promises.stat(
|
|
1004
|
+
const stat = await fs5.promises.stat(file2);
|
|
1005
1005
|
return stat.isFile();
|
|
1006
1006
|
} catch {
|
|
1007
1007
|
return false;
|
|
@@ -1015,9 +1015,9 @@ var init_fsPromises = __esm({
|
|
|
1015
1015
|
return false;
|
|
1016
1016
|
}
|
|
1017
1017
|
};
|
|
1018
|
-
existToMkdir = async (
|
|
1018
|
+
existToMkdir = async (file2) => {
|
|
1019
1019
|
try {
|
|
1020
|
-
if (!await exists(
|
|
1020
|
+
if (!await exists(file2)) await mkdir(file2);
|
|
1021
1021
|
return true;
|
|
1022
1022
|
} catch {
|
|
1023
1023
|
return false;
|
|
@@ -1028,19 +1028,19 @@ var init_fsPromises = __esm({
|
|
|
1028
1028
|
var existsSync, isDirSync, isFileSync, mkdirSync, existToMkdirSync, rmSync;
|
|
1029
1029
|
var init_fsSync = __esm({
|
|
1030
1030
|
"src/utils/fs/fsSync.ts"() {
|
|
1031
|
-
existsSync = (
|
|
1032
|
-
return fs5.existsSync(
|
|
1031
|
+
existsSync = (file2) => {
|
|
1032
|
+
return fs5.existsSync(file2);
|
|
1033
1033
|
};
|
|
1034
|
-
isDirSync = (
|
|
1034
|
+
isDirSync = (file2) => {
|
|
1035
1035
|
try {
|
|
1036
|
-
return fs5.statSync(
|
|
1036
|
+
return fs5.statSync(file2).isDirectory();
|
|
1037
1037
|
} catch {
|
|
1038
1038
|
return false;
|
|
1039
1039
|
}
|
|
1040
1040
|
};
|
|
1041
|
-
isFileSync = (
|
|
1041
|
+
isFileSync = (file2) => {
|
|
1042
1042
|
try {
|
|
1043
|
-
return fs5.statSync(
|
|
1043
|
+
return fs5.statSync(file2).isFile();
|
|
1044
1044
|
} catch {
|
|
1045
1045
|
return false;
|
|
1046
1046
|
}
|
|
@@ -1053,9 +1053,9 @@ var init_fsSync = __esm({
|
|
|
1053
1053
|
return false;
|
|
1054
1054
|
}
|
|
1055
1055
|
};
|
|
1056
|
-
existToMkdirSync = (
|
|
1056
|
+
existToMkdirSync = (file2) => {
|
|
1057
1057
|
try {
|
|
1058
|
-
if (!fs5.existsSync(
|
|
1058
|
+
if (!fs5.existsSync(file2)) mkdirSync(file2);
|
|
1059
1059
|
return true;
|
|
1060
1060
|
} catch {
|
|
1061
1061
|
return false;
|
|
@@ -1089,13 +1089,13 @@ var init_file = __esm({
|
|
|
1089
1089
|
downFile = async (fileUrl, savePath, param = {}) => {
|
|
1090
1090
|
return downloadFile(fileUrl, savePath, { ...param, returnBoolean: true });
|
|
1091
1091
|
};
|
|
1092
|
-
absPath = (
|
|
1093
|
-
|
|
1094
|
-
if (
|
|
1095
|
-
|
|
1096
|
-
if (absPath2)
|
|
1097
|
-
if (prefix)
|
|
1098
|
-
return
|
|
1092
|
+
absPath = (file2, absPath2 = true, prefix = false) => {
|
|
1093
|
+
file2 = file2.replace(/\\/g, "/");
|
|
1094
|
+
if (file2.startsWith("file://")) file2 = file2.replace(sep, "");
|
|
1095
|
+
file2 = path4.normalize(file2);
|
|
1096
|
+
if (absPath2) file2 = path4.resolve(file2);
|
|
1097
|
+
if (prefix) file2 = "file://" + file2;
|
|
1098
|
+
return file2.replace(/\\/g, "/");
|
|
1099
1099
|
};
|
|
1100
1100
|
createPluginDir = async (name, files) => {
|
|
1101
1101
|
if (!Array.isArray(files)) files = ["config", "data", "resources"];
|
|
@@ -1106,8 +1106,8 @@ var init_file = __esm({
|
|
|
1106
1106
|
const [orgName, pkgName] = name.split("/");
|
|
1107
1107
|
pluginPath = path4.join(karinPathBase, orgName, pkgName);
|
|
1108
1108
|
}
|
|
1109
|
-
await Promise.all(files.map((
|
|
1110
|
-
const filePath = path4.join(pluginPath,
|
|
1109
|
+
await Promise.all(files.map((file2) => {
|
|
1110
|
+
const filePath = path4.join(pluginPath, file2);
|
|
1111
1111
|
if (!fs5.existsSync(filePath)) return fs5.promises.mkdir(filePath, { recursive: true });
|
|
1112
1112
|
return Promise.resolve();
|
|
1113
1113
|
}));
|
|
@@ -1116,29 +1116,29 @@ var init_file = __esm({
|
|
|
1116
1116
|
if (!fs5.existsSync(filePath)) {
|
|
1117
1117
|
throw new Error(`\u8DEF\u5F84\u4E0D\u5B58\u5728: ${filePath}`);
|
|
1118
1118
|
}
|
|
1119
|
-
let files = fs5.readdirSync(filePath, { withFileTypes: true }).filter((
|
|
1119
|
+
let files = fs5.readdirSync(filePath, { withFileTypes: true }).filter((file2) => file2.isFile()).map((file2) => file2.name);
|
|
1120
1120
|
if (suffixs.length) {
|
|
1121
1121
|
const normalizedSuffixs = suffixs.map((suffix) => suffix.startsWith(".") ? suffix : `.${suffix}`);
|
|
1122
|
-
files = files.filter((
|
|
1123
|
-
const suffix = path4.extname(
|
|
1122
|
+
files = files.filter((file2) => {
|
|
1123
|
+
const suffix = path4.extname(file2);
|
|
1124
1124
|
return suffix && normalizedSuffixs.includes(suffix);
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
1127
|
return files;
|
|
1128
1128
|
};
|
|
1129
1129
|
copyFilesSync = (files, defaulPath, userPath) => {
|
|
1130
|
-
files.forEach((
|
|
1131
|
-
const defaulFile = path4.join(defaulPath,
|
|
1132
|
-
const userFile = path4.join(userPath,
|
|
1130
|
+
files.forEach((file2) => {
|
|
1131
|
+
const defaulFile = path4.join(defaulPath, file2);
|
|
1132
|
+
const userFile = path4.join(userPath, file2);
|
|
1133
1133
|
if (!fs5.existsSync(userFile)) {
|
|
1134
1134
|
fs5.copyFileSync(defaulFile, userFile);
|
|
1135
1135
|
}
|
|
1136
1136
|
});
|
|
1137
1137
|
};
|
|
1138
1138
|
copyFiles = async (files, defaulPath, userPath) => {
|
|
1139
|
-
await Promise.all(files.map(async (
|
|
1140
|
-
const defaulFile = path4.join(defaulPath,
|
|
1141
|
-
const userFile = path4.join(userPath,
|
|
1139
|
+
await Promise.all(files.map(async (file2) => {
|
|
1140
|
+
const defaulFile = path4.join(defaulPath, file2);
|
|
1141
|
+
const userFile = path4.join(userPath, file2);
|
|
1142
1142
|
if (!fs5.existsSync(userFile)) {
|
|
1143
1143
|
await fs5.promises.copyFile(defaulFile, userFile);
|
|
1144
1144
|
}
|
|
@@ -1175,13 +1175,13 @@ var init_file = __esm({
|
|
|
1175
1175
|
const result = [];
|
|
1176
1176
|
const readDirRecursive = (currentDir, prefix = "") => {
|
|
1177
1177
|
const files = fs5.readdirSync(currentDir, { withFileTypes: true });
|
|
1178
|
-
for (const
|
|
1179
|
-
const relativePath = path4.join(prefix,
|
|
1180
|
-
const fullPath = path4.join(currentDir,
|
|
1181
|
-
if (
|
|
1178
|
+
for (const file2 of files) {
|
|
1179
|
+
const relativePath = path4.join(prefix, file2.name);
|
|
1180
|
+
const fullPath = path4.join(currentDir, file2.name);
|
|
1181
|
+
if (file2.isDirectory()) {
|
|
1182
1182
|
readDirRecursive(fullPath, relativePath);
|
|
1183
|
-
} else if (
|
|
1184
|
-
const suffix = path4.extname(
|
|
1183
|
+
} else if (file2.isFile()) {
|
|
1184
|
+
const suffix = path4.extname(file2.name);
|
|
1185
1185
|
if (suffixs.length > 0) {
|
|
1186
1186
|
const normalizedSuffixs = suffixs.map((s) => s.startsWith(".") ? s : `.${s}`);
|
|
1187
1187
|
if (normalizedSuffixs.includes(suffix)) {
|
|
@@ -1209,13 +1209,13 @@ var init_file = __esm({
|
|
|
1209
1209
|
const result = [];
|
|
1210
1210
|
const readDirRecursive = async (currentDir, prefix = "") => {
|
|
1211
1211
|
const files = await fs5.promises.readdir(currentDir, { withFileTypes: true });
|
|
1212
|
-
await Promise.all(files.map(async (
|
|
1213
|
-
const relativePath = path4.join(prefix,
|
|
1214
|
-
const fullPath = path4.join(currentDir,
|
|
1215
|
-
if (
|
|
1212
|
+
await Promise.all(files.map(async (file2) => {
|
|
1213
|
+
const relativePath = path4.join(prefix, file2.name);
|
|
1214
|
+
const fullPath = path4.join(currentDir, file2.name);
|
|
1215
|
+
if (file2.isDirectory()) {
|
|
1216
1216
|
await readDirRecursive(fullPath, relativePath);
|
|
1217
|
-
} else if (
|
|
1218
|
-
const suffix = path4.extname(
|
|
1217
|
+
} else if (file2.isFile()) {
|
|
1218
|
+
const suffix = path4.extname(file2.name);
|
|
1219
1219
|
if (suffixs.length > 0) {
|
|
1220
1220
|
const normalizedSuffixs = suffixs.map((s) => s.startsWith(".") ? s : `.${s}`);
|
|
1221
1221
|
if (normalizedSuffixs.includes(suffix)) {
|
|
@@ -1287,9 +1287,9 @@ var init_data = __esm({
|
|
|
1287
1287
|
stream3.on("end", () => resolve(Buffer.concat(chunks)));
|
|
1288
1288
|
stream3.on("error", (error) => reject(error));
|
|
1289
1289
|
});
|
|
1290
|
-
readFile = async (
|
|
1290
|
+
readFile = async (path37) => {
|
|
1291
1291
|
try {
|
|
1292
|
-
const data = await fs5.promises.readFile(
|
|
1292
|
+
const data = await fs5.promises.readFile(path37);
|
|
1293
1293
|
return data;
|
|
1294
1294
|
} catch (error) {
|
|
1295
1295
|
logger.error(error);
|
|
@@ -1305,36 +1305,36 @@ var init_data = __esm({
|
|
|
1305
1305
|
var readJsonSync, writeJsonSync, readJson, writeJson, json;
|
|
1306
1306
|
var init_json = __esm({
|
|
1307
1307
|
"src/utils/fs/json.ts"() {
|
|
1308
|
-
readJsonSync = (
|
|
1308
|
+
readJsonSync = (path37, isThrow = false) => {
|
|
1309
1309
|
try {
|
|
1310
|
-
const data = fs5.readFileSync(
|
|
1310
|
+
const data = fs5.readFileSync(path37, "utf8");
|
|
1311
1311
|
return JSON.parse(data);
|
|
1312
1312
|
} catch (error) {
|
|
1313
1313
|
if (isThrow) throw error;
|
|
1314
1314
|
return null;
|
|
1315
1315
|
}
|
|
1316
1316
|
};
|
|
1317
|
-
writeJsonSync = (
|
|
1317
|
+
writeJsonSync = (path37, data, isThrow = false) => {
|
|
1318
1318
|
try {
|
|
1319
|
-
fs5.writeFileSync(
|
|
1319
|
+
fs5.writeFileSync(path37, JSON.stringify(data, null, 2));
|
|
1320
1320
|
return true;
|
|
1321
1321
|
} catch (error) {
|
|
1322
1322
|
if (isThrow) throw error;
|
|
1323
1323
|
return false;
|
|
1324
1324
|
}
|
|
1325
1325
|
};
|
|
1326
|
-
readJson = async (
|
|
1326
|
+
readJson = async (path37, isThrow = false) => {
|
|
1327
1327
|
try {
|
|
1328
|
-
const data = await fs5.promises.readFile(
|
|
1328
|
+
const data = await fs5.promises.readFile(path37, "utf8");
|
|
1329
1329
|
return JSON.parse(data);
|
|
1330
1330
|
} catch (error) {
|
|
1331
1331
|
if (isThrow) throw error;
|
|
1332
1332
|
return null;
|
|
1333
1333
|
}
|
|
1334
1334
|
};
|
|
1335
|
-
writeJson = async (
|
|
1335
|
+
writeJson = async (path37, data, isThrow = false) => {
|
|
1336
1336
|
try {
|
|
1337
|
-
await fs5.promises.writeFile(
|
|
1337
|
+
await fs5.promises.writeFile(path37, JSON.stringify(data, null, 2));
|
|
1338
1338
|
return true;
|
|
1339
1339
|
} catch (error) {
|
|
1340
1340
|
if (isThrow) throw error;
|
|
@@ -1370,8 +1370,8 @@ var init_path = __esm({
|
|
|
1370
1370
|
if (returnType === "name") {
|
|
1371
1371
|
list2.push(entry.name);
|
|
1372
1372
|
} else if (returnType === "rel") {
|
|
1373
|
-
const
|
|
1374
|
-
list2.push(path4.relative(process.cwd(),
|
|
1373
|
+
const file2 = path4.resolve(dir2, entry.name);
|
|
1374
|
+
list2.push(path4.relative(process.cwd(), file2));
|
|
1375
1375
|
} else if (returnType === "abs") {
|
|
1376
1376
|
list2.push(formatPath(path4.resolve(dir2, entry.name)));
|
|
1377
1377
|
}
|
|
@@ -1520,9 +1520,9 @@ var init_yaml = __esm({
|
|
|
1520
1520
|
filePath;
|
|
1521
1521
|
doc;
|
|
1522
1522
|
document;
|
|
1523
|
-
constructor(
|
|
1524
|
-
this.filePath =
|
|
1525
|
-
const data = YAML.parseDocument(fs5.existsSync(
|
|
1523
|
+
constructor(file2) {
|
|
1524
|
+
this.filePath = file2;
|
|
1525
|
+
const data = YAML.parseDocument(fs5.existsSync(file2) ? fs5.readFileSync(file2, "utf8") : file2);
|
|
1526
1526
|
this.doc = data;
|
|
1527
1527
|
this.document = data;
|
|
1528
1528
|
}
|
|
@@ -1530,10 +1530,10 @@ var init_yaml = __esm({
|
|
|
1530
1530
|
* 获取指定路径的值
|
|
1531
1531
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1532
1532
|
*/
|
|
1533
|
-
get(
|
|
1533
|
+
get(path37) {
|
|
1534
1534
|
try {
|
|
1535
|
-
if (!
|
|
1536
|
-
return lodash3.get(this.document.toJSON(),
|
|
1535
|
+
if (!path37) return this.document.toJSON();
|
|
1536
|
+
return lodash3.get(this.document.toJSON(), path37);
|
|
1537
1537
|
} catch (error) {
|
|
1538
1538
|
logger.error(`[YamlEditor] \u83B7\u53D6\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
1539
1539
|
return null;
|
|
@@ -1545,9 +1545,9 @@ var init_yaml = __esm({
|
|
|
1545
1545
|
* @param value - 要设置的值 允许的类型:`string`, `boolean`, `number`, `object`, `array`
|
|
1546
1546
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1547
1547
|
*/
|
|
1548
|
-
set(
|
|
1548
|
+
set(path37, value, isSplit = true) {
|
|
1549
1549
|
try {
|
|
1550
|
-
const _path = typeof
|
|
1550
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1551
1551
|
this.document.setIn(_path, value);
|
|
1552
1552
|
return true;
|
|
1553
1553
|
} catch (error) {
|
|
@@ -1561,11 +1561,11 @@ var init_yaml = __esm({
|
|
|
1561
1561
|
* @param value - 要添加的值
|
|
1562
1562
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1563
1563
|
*/
|
|
1564
|
-
add(
|
|
1564
|
+
add(path37, value, isSplit = true) {
|
|
1565
1565
|
try {
|
|
1566
|
-
const _path = typeof
|
|
1566
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1567
1567
|
this.document.addIn(_path, value);
|
|
1568
|
-
logger.debug(`[YamlEditor] \u5DF2\u5728 ${
|
|
1568
|
+
logger.debug(`[YamlEditor] \u5DF2\u5728 ${path37} \u6DFB\u52A0\u65B0\u7684\u503C`);
|
|
1569
1569
|
return true;
|
|
1570
1570
|
} catch (error) {
|
|
1571
1571
|
logger.error(`[YamlEditor] \u6DFB\u52A0\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1578,9 +1578,9 @@ var init_yaml = __esm({
|
|
|
1578
1578
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1579
1579
|
* @returns 是否删除成功
|
|
1580
1580
|
*/
|
|
1581
|
-
del(
|
|
1581
|
+
del(path37, isSplit = true) {
|
|
1582
1582
|
try {
|
|
1583
|
-
const _path = typeof
|
|
1583
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1584
1584
|
this.document.deleteIn(_path);
|
|
1585
1585
|
return true;
|
|
1586
1586
|
} catch (error) {
|
|
@@ -1595,9 +1595,9 @@ var init_yaml = __esm({
|
|
|
1595
1595
|
* @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
|
|
1596
1596
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1597
1597
|
*/
|
|
1598
|
-
append(
|
|
1598
|
+
append(path37, value, prepend = false, isSplit = true) {
|
|
1599
1599
|
try {
|
|
1600
|
-
const _path = typeof
|
|
1600
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1601
1601
|
let current = this.document.getIn(_path);
|
|
1602
1602
|
if (!current) {
|
|
1603
1603
|
current = new YAML.YAMLSeq();
|
|
@@ -1608,7 +1608,7 @@ var init_yaml = __esm({
|
|
|
1608
1608
|
} else {
|
|
1609
1609
|
prepend ? current.items.unshift(value) : current.add(value);
|
|
1610
1610
|
}
|
|
1611
|
-
logger.debug(`[YamlEditor] \u5DF2\u5411 ${
|
|
1611
|
+
logger.debug(`[YamlEditor] \u5DF2\u5411 ${path37} \u6570\u7EC4${prepend ? "\u5F00\u5934" : "\u672B\u5C3E"}\u6DFB\u52A0\u65B0\u5143\u7D20\uFF1A${value}`);
|
|
1612
1612
|
return true;
|
|
1613
1613
|
} catch (error) {
|
|
1614
1614
|
logger.error(`[YamlEditor] \u5411\u6570\u7EC4\u6DFB\u52A0\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1621,9 +1621,9 @@ var init_yaml = __esm({
|
|
|
1621
1621
|
* @param value - 要删除的值
|
|
1622
1622
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1623
1623
|
*/
|
|
1624
|
-
remove(
|
|
1624
|
+
remove(path37, value, isSplit = true) {
|
|
1625
1625
|
try {
|
|
1626
|
-
const _path = typeof
|
|
1626
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1627
1627
|
const current = this.document.getIn(_path);
|
|
1628
1628
|
if (!current) {
|
|
1629
1629
|
logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u5B58\u5728");
|
|
@@ -1639,7 +1639,7 @@ var init_yaml = __esm({
|
|
|
1639
1639
|
return false;
|
|
1640
1640
|
}
|
|
1641
1641
|
current.items.splice(index6, 1);
|
|
1642
|
-
logger.debug(`[YamlEditor] \u5DF2\u4ECE ${
|
|
1642
|
+
logger.debug(`[YamlEditor] \u5DF2\u4ECE ${path37} \u6570\u7EC4\u5220\u9664\u5143\u7D20\uFF1A${value}`);
|
|
1643
1643
|
return true;
|
|
1644
1644
|
} catch (error) {
|
|
1645
1645
|
logger.error(`[YamlEditor] \u4ECE\u6570\u7EC4\u5220\u9664\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1651,9 +1651,9 @@ var init_yaml = __esm({
|
|
|
1651
1651
|
* @param path - 路径,用点号分隔
|
|
1652
1652
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1653
1653
|
*/
|
|
1654
|
-
has(
|
|
1654
|
+
has(path37, isSplit = true) {
|
|
1655
1655
|
try {
|
|
1656
|
-
const _path = typeof
|
|
1656
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1657
1657
|
return this.document.hasIn(_path);
|
|
1658
1658
|
} catch (error) {
|
|
1659
1659
|
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84\u662F\u5426\u5B58\u5728\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1666,9 +1666,9 @@ var init_yaml = __esm({
|
|
|
1666
1666
|
* @param value - 要查询的值
|
|
1667
1667
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1668
1668
|
*/
|
|
1669
|
-
hasval(
|
|
1669
|
+
hasval(path37, value, isSplit = true) {
|
|
1670
1670
|
try {
|
|
1671
|
-
const _path = typeof
|
|
1671
|
+
const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1672
1672
|
const current = this.document.getIn(_path);
|
|
1673
1673
|
if (!current) return false;
|
|
1674
1674
|
if (current instanceof YAML.YAMLSeq) {
|
|
@@ -1679,7 +1679,7 @@ var init_yaml = __esm({
|
|
|
1679
1679
|
return lodash3.isEqual(current, value);
|
|
1680
1680
|
}
|
|
1681
1681
|
} catch (error) {
|
|
1682
|
-
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${
|
|
1682
|
+
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${path37} \u662F\u5426\u5305\u542B\u503C\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
1683
1683
|
return false;
|
|
1684
1684
|
}
|
|
1685
1685
|
}
|
|
@@ -1689,8 +1689,8 @@ var init_yaml = __esm({
|
|
|
1689
1689
|
* @param value - 要查询的值
|
|
1690
1690
|
* @deprecated 请使用 `hasval` 代替
|
|
1691
1691
|
*/
|
|
1692
|
-
hasVal(
|
|
1693
|
-
return this.hasval(
|
|
1692
|
+
hasVal(path37, value) {
|
|
1693
|
+
return this.hasval(path37, value);
|
|
1694
1694
|
}
|
|
1695
1695
|
/**
|
|
1696
1696
|
* 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
|
|
@@ -1735,9 +1735,9 @@ var init_yaml = __esm({
|
|
|
1735
1735
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1736
1736
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1737
1737
|
*/
|
|
1738
|
-
getpair(
|
|
1739
|
-
if (!
|
|
1740
|
-
const keys = typeof
|
|
1738
|
+
getpair(path37, isSplit = true) {
|
|
1739
|
+
if (!path37) throw new Error("path is required");
|
|
1740
|
+
const keys = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
|
|
1741
1741
|
let pair = this.document.contents;
|
|
1742
1742
|
keys.forEach((key) => {
|
|
1743
1743
|
if (isMap(pair)) {
|
|
@@ -1757,10 +1757,10 @@ var init_yaml = __esm({
|
|
|
1757
1757
|
* @param prepend - 如果为 true,则添加注释到开头,否则添加到同一行的末尾
|
|
1758
1758
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1759
1759
|
*/
|
|
1760
|
-
comment(
|
|
1761
|
-
if (!
|
|
1762
|
-
const pair = this.getpair(
|
|
1763
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1760
|
+
comment(path37, comment2, prepend = true, isSplit = true) {
|
|
1761
|
+
if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1762
|
+
const pair = this.getpair(path37, isSplit);
|
|
1763
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
|
|
1764
1764
|
comment2 = ` ${comment2}`;
|
|
1765
1765
|
if (prepend) {
|
|
1766
1766
|
pair.key.commentBefore = comment2;
|
|
@@ -1774,10 +1774,10 @@ var init_yaml = __esm({
|
|
|
1774
1774
|
* @param type - 要删除的注释类型,`before` 为注释前,`after` 为注释后,`all` 为全部
|
|
1775
1775
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1776
1776
|
*/
|
|
1777
|
-
uncomment(
|
|
1778
|
-
if (!
|
|
1779
|
-
const pair = this.getpair(
|
|
1780
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1777
|
+
uncomment(path37, type = "all", isSplit = true) {
|
|
1778
|
+
if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1779
|
+
const pair = this.getpair(path37, isSplit);
|
|
1780
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
|
|
1781
1781
|
if (type === "all") {
|
|
1782
1782
|
delete pair.key.comment;
|
|
1783
1783
|
delete pair.key.commentBefore;
|
|
@@ -1793,10 +1793,10 @@ var init_yaml = __esm({
|
|
|
1793
1793
|
* @param type - 要检查的注释类型,`before` 为注释前,`after` 为注释后
|
|
1794
1794
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1795
1795
|
*/
|
|
1796
|
-
hascomment(
|
|
1797
|
-
if (!
|
|
1798
|
-
const pair = this.getpair(
|
|
1799
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1796
|
+
hascomment(path37, type, isSplit = true) {
|
|
1797
|
+
if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1798
|
+
const pair = this.getpair(path37, isSplit);
|
|
1799
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
|
|
1800
1800
|
if (type === "before") {
|
|
1801
1801
|
return !!pair.key.commentBefore;
|
|
1802
1802
|
} else if (type === "after") {
|
|
@@ -1809,10 +1809,10 @@ var init_yaml = __esm({
|
|
|
1809
1809
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1810
1810
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1811
1811
|
*/
|
|
1812
|
-
getcomment(
|
|
1813
|
-
if (!
|
|
1814
|
-
const pair = this.getpair(
|
|
1815
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1812
|
+
getcomment(path37, isSplit = true) {
|
|
1813
|
+
if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1814
|
+
const pair = this.getpair(path37, isSplit);
|
|
1815
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
|
|
1816
1816
|
return pair.key.commentBefore || pair.key.comment;
|
|
1817
1817
|
}
|
|
1818
1818
|
/**
|
|
@@ -1824,11 +1824,11 @@ var init_yaml = __esm({
|
|
|
1824
1824
|
logger.debug("[YamlEditor] \u6587\u4EF6\u5DF2\u4FDD\u5B58");
|
|
1825
1825
|
}
|
|
1826
1826
|
};
|
|
1827
|
-
read = (
|
|
1828
|
-
const data = YAML.parse(fs5.readFileSync(
|
|
1827
|
+
read = (path37) => {
|
|
1828
|
+
const data = YAML.parse(fs5.readFileSync(path37, "utf-8"));
|
|
1829
1829
|
read.save = (options) => {
|
|
1830
1830
|
try {
|
|
1831
|
-
save(
|
|
1831
|
+
save(path37, data, typeof options === "string" ? JSON.parse(options) : options);
|
|
1832
1832
|
return true;
|
|
1833
1833
|
} catch (error) {
|
|
1834
1834
|
logger.error("[YamlEditor] \u4FDD\u5B58\u6587\u4EF6\u65F6\u51FA\u9519");
|
|
@@ -1838,23 +1838,23 @@ var init_yaml = __esm({
|
|
|
1838
1838
|
};
|
|
1839
1839
|
return data;
|
|
1840
1840
|
};
|
|
1841
|
-
write = (
|
|
1841
|
+
write = (path37, value) => {
|
|
1842
1842
|
try {
|
|
1843
|
-
fs5.writeFileSync(
|
|
1843
|
+
fs5.writeFileSync(path37, YAML.stringify(value));
|
|
1844
1844
|
return true;
|
|
1845
1845
|
} catch {
|
|
1846
1846
|
return false;
|
|
1847
1847
|
}
|
|
1848
1848
|
};
|
|
1849
|
-
save = (
|
|
1849
|
+
save = (path37, value, options) => {
|
|
1850
1850
|
if (!options) {
|
|
1851
|
-
fs5.writeFileSync(
|
|
1851
|
+
fs5.writeFileSync(path37, YAML.stringify(value));
|
|
1852
1852
|
return;
|
|
1853
1853
|
}
|
|
1854
1854
|
const editor = new YamlEditor(YAML.stringify(value));
|
|
1855
1855
|
const comment2 = typeof options === "string" ? JSON.parse(fs5.readFileSync(options, "utf8")) : options;
|
|
1856
1856
|
applyComments(editor, comment2);
|
|
1857
|
-
fs5.writeFileSync(
|
|
1857
|
+
fs5.writeFileSync(path37, editor.document.toString());
|
|
1858
1858
|
};
|
|
1859
1859
|
comment = (filePath, commentConfig) => {
|
|
1860
1860
|
const editor = new YamlEditor(filePath);
|
|
@@ -2426,6 +2426,7 @@ __export(segment_exports, {
|
|
|
2426
2426
|
customMusic: () => customMusic,
|
|
2427
2427
|
dice: () => dice,
|
|
2428
2428
|
face: () => face,
|
|
2429
|
+
file: () => file,
|
|
2429
2430
|
gift: () => gift,
|
|
2430
2431
|
image: () => image,
|
|
2431
2432
|
json: () => json2,
|
|
@@ -2449,7 +2450,7 @@ __export(segment_exports, {
|
|
|
2449
2450
|
weather: () => weather,
|
|
2450
2451
|
xml: () => xml
|
|
2451
2452
|
});
|
|
2452
|
-
var text, at, face, reply, image, video, record, json2, xml, markdown, markdownTpl, pasmsg, keyboard, button, longMsg, raw, basketball, dice, rps, bubbleFace, weather, location, share, gift, marketFace, contact, music, customMusic, node, nodeDirect;
|
|
2453
|
+
var text, at, face, reply, image, video, record, json2, xml, markdown, markdownTpl, pasmsg, keyboard, button, longMsg, raw, basketball, dice, rps, bubbleFace, weather, location, share, gift, marketFace, contact, music, customMusic, node, nodeDirect, file;
|
|
2453
2454
|
var init_segment = __esm({
|
|
2454
2455
|
"src/utils/message/segment.ts"() {
|
|
2455
2456
|
text = (text2) => {
|
|
@@ -2464,10 +2465,10 @@ var init_segment = __esm({
|
|
|
2464
2465
|
reply = (messageId) => {
|
|
2465
2466
|
return { type: "reply", messageId: String(messageId) };
|
|
2466
2467
|
};
|
|
2467
|
-
image = (
|
|
2468
|
+
image = (file2, options = {}) => {
|
|
2468
2469
|
return {
|
|
2469
2470
|
type: "image",
|
|
2470
|
-
file,
|
|
2471
|
+
file: file2,
|
|
2471
2472
|
fileType: options.fileType,
|
|
2472
2473
|
height: options?.height,
|
|
2473
2474
|
width: options?.width,
|
|
@@ -2476,20 +2477,20 @@ var init_segment = __esm({
|
|
|
2476
2477
|
subType: options?.subType
|
|
2477
2478
|
};
|
|
2478
2479
|
};
|
|
2479
|
-
video = (
|
|
2480
|
+
video = (file2, options) => {
|
|
2480
2481
|
return {
|
|
2481
2482
|
type: "video",
|
|
2482
|
-
file,
|
|
2483
|
+
file: file2,
|
|
2483
2484
|
height: options?.height,
|
|
2484
2485
|
width: options?.width,
|
|
2485
2486
|
md5: options?.md5,
|
|
2486
2487
|
name: options?.name
|
|
2487
2488
|
};
|
|
2488
2489
|
};
|
|
2489
|
-
record = (
|
|
2490
|
+
record = (file2, magic = false, options) => {
|
|
2490
2491
|
return {
|
|
2491
2492
|
type: "record",
|
|
2492
|
-
file,
|
|
2493
|
+
file: file2,
|
|
2493
2494
|
magic,
|
|
2494
2495
|
md5: options?.md5,
|
|
2495
2496
|
name: options?.name
|
|
@@ -2575,6 +2576,16 @@ var init_segment = __esm({
|
|
|
2575
2576
|
nodeDirect = (id) => {
|
|
2576
2577
|
return { type: "node", subType: "messageID", messageId: id, message_id: id };
|
|
2577
2578
|
};
|
|
2579
|
+
file = (file2, options) => {
|
|
2580
|
+
return {
|
|
2581
|
+
type: "file",
|
|
2582
|
+
file: file2,
|
|
2583
|
+
name: options?.name,
|
|
2584
|
+
hash: options?.hash,
|
|
2585
|
+
size: options?.size,
|
|
2586
|
+
fid: options?.fid
|
|
2587
|
+
};
|
|
2588
|
+
};
|
|
2578
2589
|
}
|
|
2579
2590
|
});
|
|
2580
2591
|
var createRawMessage, makeMessage, makeForward;
|
|
@@ -2598,9 +2609,9 @@ var init_message = __esm({
|
|
|
2598
2609
|
return `[${v.type}:base64://...]`;
|
|
2599
2610
|
}
|
|
2600
2611
|
case "file": {
|
|
2601
|
-
if (Buffer.isBuffer(v.file)) return `[file:Buffer://..., fid:${v.fid},
|
|
2602
|
-
if (/^http|^file/.test(v.file)) return `[file:${v.file}, fid:${v.fid},
|
|
2603
|
-
return `[file:base64://..., fid:${v.fid},
|
|
2612
|
+
if (Buffer.isBuffer(v.file)) return `[file:Buffer://..., fid:${v.fid}, hash:${v.hash}]`;
|
|
2613
|
+
if (/^http|^file/.test(v.file)) return `[file:${v.file}, fid:${v.fid}, hash:${v.hash}]`;
|
|
2614
|
+
return `[file:base64://..., fid:${v.fid}, hash:${v.hash}]`;
|
|
2604
2615
|
}
|
|
2605
2616
|
case "json":
|
|
2606
2617
|
case "xml": {
|
|
@@ -3026,6 +3037,9 @@ var init_base = __esm({
|
|
|
3026
3037
|
connectTime: Date.now()
|
|
3027
3038
|
};
|
|
3028
3039
|
}
|
|
3040
|
+
get #errMsg() {
|
|
3041
|
+
return `[adapter][${this.adapter.protocol}] \u6B64\u63A5\u53E3\u672A\u5B9E\u73B0`;
|
|
3042
|
+
}
|
|
3029
3043
|
get selfId() {
|
|
3030
3044
|
return this.account.selfId;
|
|
3031
3045
|
}
|
|
@@ -3050,7 +3064,7 @@ var init_base = __esm({
|
|
|
3050
3064
|
* @param _retryCount 重试次数 默认为0
|
|
3051
3065
|
*/
|
|
3052
3066
|
sendMsg(_contact, _elements, _retryCount) {
|
|
3053
|
-
throw new Error(
|
|
3067
|
+
throw new Error(this.#errMsg);
|
|
3054
3068
|
}
|
|
3055
3069
|
/**
|
|
3056
3070
|
* 发送长消息
|
|
@@ -3058,7 +3072,7 @@ var init_base = __esm({
|
|
|
3058
3072
|
* @param _resId 资源ID
|
|
3059
3073
|
*/
|
|
3060
3074
|
sendLongMsg(_contact, _resId) {
|
|
3061
|
-
throw new Error(
|
|
3075
|
+
throw new Error(this.#errMsg);
|
|
3062
3076
|
}
|
|
3063
3077
|
/**
|
|
3064
3078
|
* 发送合并转发消息
|
|
@@ -3067,7 +3081,7 @@ var init_base = __esm({
|
|
|
3067
3081
|
* @param _options 首层小卡片外显参数
|
|
3068
3082
|
*/
|
|
3069
3083
|
sendForwardMsg(_contact, _elements, _options) {
|
|
3070
|
-
throw new Error(
|
|
3084
|
+
throw new Error(this.#errMsg);
|
|
3071
3085
|
}
|
|
3072
3086
|
/**
|
|
3073
3087
|
* 撤回消息
|
|
@@ -3076,7 +3090,7 @@ var init_base = __esm({
|
|
|
3076
3090
|
* @returns 此接口的返回值不值得信任
|
|
3077
3091
|
*/
|
|
3078
3092
|
recallMsg(_contact, _messageId) {
|
|
3079
|
-
throw new Error(
|
|
3093
|
+
throw new Error(this.#errMsg);
|
|
3080
3094
|
}
|
|
3081
3095
|
/**
|
|
3082
3096
|
* 获取头像url
|
|
@@ -3085,7 +3099,7 @@ var init_base = __esm({
|
|
|
3085
3099
|
* @returns 头像的url地址
|
|
3086
3100
|
*/
|
|
3087
3101
|
getAvatarUrl(_userId, _size) {
|
|
3088
|
-
throw new Error(
|
|
3102
|
+
throw new Error(this.#errMsg);
|
|
3089
3103
|
}
|
|
3090
3104
|
/**
|
|
3091
3105
|
* 获取群头像url
|
|
@@ -3095,7 +3109,7 @@ var init_base = __esm({
|
|
|
3095
3109
|
* @returns 头像的url地址
|
|
3096
3110
|
*/
|
|
3097
3111
|
getGroupAvatarUrl(_groupId, _size, _history) {
|
|
3098
|
-
throw new Error(
|
|
3112
|
+
throw new Error(this.#errMsg);
|
|
3099
3113
|
}
|
|
3100
3114
|
/**
|
|
3101
3115
|
* 获取消息
|
|
@@ -3104,7 +3118,7 @@ var init_base = __esm({
|
|
|
3104
3118
|
* @returns MessageResponse对象
|
|
3105
3119
|
*/
|
|
3106
3120
|
getMsg(_contact, _messageId) {
|
|
3107
|
-
throw new Error(
|
|
3121
|
+
throw new Error(this.#errMsg);
|
|
3108
3122
|
}
|
|
3109
3123
|
/**
|
|
3110
3124
|
* 获取msgId获取历史消息
|
|
@@ -3114,7 +3128,7 @@ var init_base = __esm({
|
|
|
3114
3128
|
* @returns 包含历史消息的数组
|
|
3115
3129
|
*/
|
|
3116
3130
|
getHistoryMsg(_contact, _startMsgId, _count) {
|
|
3117
|
-
throw new Error(
|
|
3131
|
+
throw new Error(this.#errMsg);
|
|
3118
3132
|
}
|
|
3119
3133
|
/**
|
|
3120
3134
|
* 获取合并转发消息
|
|
@@ -3122,7 +3136,7 @@ var init_base = __esm({
|
|
|
3122
3136
|
* @returns 包含MessageResponse对象的数组
|
|
3123
3137
|
*/
|
|
3124
3138
|
getForwardMsg(_resId) {
|
|
3125
|
-
throw new Error(
|
|
3139
|
+
throw new Error(this.#errMsg);
|
|
3126
3140
|
}
|
|
3127
3141
|
/**
|
|
3128
3142
|
* 获取精华消息
|
|
@@ -3132,7 +3146,7 @@ var init_base = __esm({
|
|
|
3132
3146
|
* @returns EssenceMessageBody对象
|
|
3133
3147
|
*/
|
|
3134
3148
|
getGroupHighlights(_groupId, _page, _pageSize) {
|
|
3135
|
-
throw new Error(
|
|
3149
|
+
throw new Error(this.#errMsg);
|
|
3136
3150
|
}
|
|
3137
3151
|
/**
|
|
3138
3152
|
* 构造一个资源ID 即上传合并转发消息后不进行发送
|
|
@@ -3141,7 +3155,7 @@ var init_base = __esm({
|
|
|
3141
3155
|
* @description 此接口并不是所有协议端都支持的,因此在使用时请注意
|
|
3142
3156
|
*/
|
|
3143
3157
|
createResId(_contact, _elements) {
|
|
3144
|
-
throw new Error(
|
|
3158
|
+
throw new Error(this.#errMsg);
|
|
3145
3159
|
}
|
|
3146
3160
|
/**
|
|
3147
3161
|
* 设置、取消群精华消息
|
|
@@ -3150,7 +3164,7 @@ var init_base = __esm({
|
|
|
3150
3164
|
* @param _create true为添加精华消息,false为删除精华消息 默认为true
|
|
3151
3165
|
*/
|
|
3152
3166
|
setGgroupHighlights(_groupId, _messageId, _create) {
|
|
3153
|
-
throw new Error(
|
|
3167
|
+
throw new Error(this.#errMsg);
|
|
3154
3168
|
}
|
|
3155
3169
|
/**
|
|
3156
3170
|
* 发送好友赞
|
|
@@ -3159,7 +3173,7 @@ var init_base = __esm({
|
|
|
3159
3173
|
* @returns 此接口的返回值不值得信任
|
|
3160
3174
|
*/
|
|
3161
3175
|
sendLike(_targetId, _count) {
|
|
3162
|
-
throw new Error(
|
|
3176
|
+
throw new Error(this.#errMsg);
|
|
3163
3177
|
}
|
|
3164
3178
|
/**
|
|
3165
3179
|
* 群踢人
|
|
@@ -3170,7 +3184,7 @@ var init_base = __esm({
|
|
|
3170
3184
|
* @returns 此接口的返回值不值得信任
|
|
3171
3185
|
*/
|
|
3172
3186
|
groupKickMember(_groupId, _targetId, _rejectAddRequest, _kickReason) {
|
|
3173
|
-
throw new Error(
|
|
3187
|
+
throw new Error(this.#errMsg);
|
|
3174
3188
|
}
|
|
3175
3189
|
/**
|
|
3176
3190
|
* 禁言群成员
|
|
@@ -3180,7 +3194,7 @@ var init_base = __esm({
|
|
|
3180
3194
|
* @returns 此接口的返回值不值得信任
|
|
3181
3195
|
*/
|
|
3182
3196
|
setGroupMute(_groupId, _targetId, _duration) {
|
|
3183
|
-
throw new Error(
|
|
3197
|
+
throw new Error(this.#errMsg);
|
|
3184
3198
|
}
|
|
3185
3199
|
/**
|
|
3186
3200
|
* 群全员禁言
|
|
@@ -3189,7 +3203,7 @@ var init_base = __esm({
|
|
|
3189
3203
|
* @returns 此接口的返回值不值得信任
|
|
3190
3204
|
*/
|
|
3191
3205
|
setGroupAllMute(_groupId, _isBan) {
|
|
3192
|
-
throw new Error(
|
|
3206
|
+
throw new Error(this.#errMsg);
|
|
3193
3207
|
}
|
|
3194
3208
|
/**
|
|
3195
3209
|
* 设置群管理员
|
|
@@ -3199,7 +3213,7 @@ var init_base = __esm({
|
|
|
3199
3213
|
* @returns 此接口的返回值不值得信任
|
|
3200
3214
|
*/
|
|
3201
3215
|
setGroupAdmin(_groupId, _targetId, _isAdmin) {
|
|
3202
|
-
throw new Error(
|
|
3216
|
+
throw new Error(this.#errMsg);
|
|
3203
3217
|
}
|
|
3204
3218
|
/**
|
|
3205
3219
|
* 设置群名片
|
|
@@ -3209,7 +3223,7 @@ var init_base = __esm({
|
|
|
3209
3223
|
* @returns 此接口的返回值不值得信任
|
|
3210
3224
|
*/
|
|
3211
3225
|
setGroupMemberCard(_groupId, _targetId, _card) {
|
|
3212
|
-
throw new Error(
|
|
3226
|
+
throw new Error(this.#errMsg);
|
|
3213
3227
|
}
|
|
3214
3228
|
/**
|
|
3215
3229
|
* 设置群名
|
|
@@ -3218,7 +3232,7 @@ var init_base = __esm({
|
|
|
3218
3232
|
* @returns 此接口的返回值不值得信任
|
|
3219
3233
|
*/
|
|
3220
3234
|
setGroupName(_groupId, _groupName) {
|
|
3221
|
-
throw new Error(
|
|
3235
|
+
throw new Error(this.#errMsg);
|
|
3222
3236
|
}
|
|
3223
3237
|
/**
|
|
3224
3238
|
* 退出群组
|
|
@@ -3227,7 +3241,7 @@ var init_base = __esm({
|
|
|
3227
3241
|
* @returns 此接口的返回值不值得信任
|
|
3228
3242
|
*/
|
|
3229
3243
|
setGroupQuit(_groupId, _isDismiss) {
|
|
3230
|
-
throw new Error(
|
|
3244
|
+
throw new Error(this.#errMsg);
|
|
3231
3245
|
}
|
|
3232
3246
|
/**
|
|
3233
3247
|
* 设置群专属头衔 仅群主可用
|
|
@@ -3237,7 +3251,7 @@ var init_base = __esm({
|
|
|
3237
3251
|
* @returns 此接口的返回值不值得信任
|
|
3238
3252
|
*/
|
|
3239
3253
|
setGroupMemberTitle(_groupId, _targetId, _title) {
|
|
3240
|
-
throw new Error(
|
|
3254
|
+
throw new Error(this.#errMsg);
|
|
3241
3255
|
}
|
|
3242
3256
|
/**
|
|
3243
3257
|
* 获取陌生人信息 此接口数据无法保证完全正确并且无法保证数据的完整性
|
|
@@ -3245,7 +3259,7 @@ var init_base = __esm({
|
|
|
3245
3259
|
* @returns 陌生人信息数组
|
|
3246
3260
|
*/
|
|
3247
3261
|
getStrangerInfo(_targetId) {
|
|
3248
|
-
throw new Error(
|
|
3262
|
+
throw new Error(this.#errMsg);
|
|
3249
3263
|
}
|
|
3250
3264
|
/**
|
|
3251
3265
|
* 获取好友列表
|
|
@@ -3253,7 +3267,7 @@ var init_base = __esm({
|
|
|
3253
3267
|
* @returns 好友列表数组
|
|
3254
3268
|
*/
|
|
3255
3269
|
getFriendList(_refresh) {
|
|
3256
|
-
throw new Error(
|
|
3270
|
+
throw new Error(this.#errMsg);
|
|
3257
3271
|
}
|
|
3258
3272
|
/**
|
|
3259
3273
|
* 获取群信息
|
|
@@ -3262,7 +3276,7 @@ var init_base = __esm({
|
|
|
3262
3276
|
* @returns 群信息
|
|
3263
3277
|
*/
|
|
3264
3278
|
getGroupInfo(_groupId, _noCache) {
|
|
3265
|
-
throw new Error(
|
|
3279
|
+
throw new Error(this.#errMsg);
|
|
3266
3280
|
}
|
|
3267
3281
|
/**
|
|
3268
3282
|
* 获取群列表
|
|
@@ -3270,7 +3284,7 @@ var init_base = __esm({
|
|
|
3270
3284
|
* @returns 群列表数组
|
|
3271
3285
|
*/
|
|
3272
3286
|
getGroupList(_refresh) {
|
|
3273
|
-
throw new Error(
|
|
3287
|
+
throw new Error(this.#errMsg);
|
|
3274
3288
|
}
|
|
3275
3289
|
/**
|
|
3276
3290
|
* 获取群成员信息
|
|
@@ -3281,7 +3295,7 @@ var init_base = __esm({
|
|
|
3281
3295
|
* @returns 群成员信息
|
|
3282
3296
|
*/
|
|
3283
3297
|
getGroupMemberInfo(_groupId, _targetId, _refresh) {
|
|
3284
|
-
throw new Error(
|
|
3298
|
+
throw new Error(this.#errMsg);
|
|
3285
3299
|
}
|
|
3286
3300
|
/**
|
|
3287
3301
|
* 获取群成员列表
|
|
@@ -3290,7 +3304,7 @@ var init_base = __esm({
|
|
|
3290
3304
|
* @returns 群成员列表数组
|
|
3291
3305
|
*/
|
|
3292
3306
|
getGroupMemberList(_groupId, _refresh) {
|
|
3293
|
-
throw new Error(
|
|
3307
|
+
throw new Error(this.#errMsg);
|
|
3294
3308
|
}
|
|
3295
3309
|
/**
|
|
3296
3310
|
* 获取群荣誉信息
|
|
@@ -3299,7 +3313,7 @@ var init_base = __esm({
|
|
|
3299
3313
|
* @returns 群荣誉信息数组
|
|
3300
3314
|
*/
|
|
3301
3315
|
getGroupHonor(_groupId) {
|
|
3302
|
-
throw new Error(
|
|
3316
|
+
throw new Error(this.#errMsg);
|
|
3303
3317
|
}
|
|
3304
3318
|
/**
|
|
3305
3319
|
* 设置好友请求结果
|
|
@@ -3309,7 +3323,7 @@ var init_base = __esm({
|
|
|
3309
3323
|
* @returns 设置结果
|
|
3310
3324
|
*/
|
|
3311
3325
|
setFriendApplyResult(_requestId, _isApprove, _remark) {
|
|
3312
|
-
throw new Error(
|
|
3326
|
+
throw new Error(this.#errMsg);
|
|
3313
3327
|
}
|
|
3314
3328
|
/**
|
|
3315
3329
|
* 设置申请加入群请求结果
|
|
@@ -3319,7 +3333,7 @@ var init_base = __esm({
|
|
|
3319
3333
|
* @returns 此接口的返回值不值得信任
|
|
3320
3334
|
*/
|
|
3321
3335
|
setGroupApplyResult(_requestId, _isApprove, _denyReason) {
|
|
3322
|
-
throw new Error(
|
|
3336
|
+
throw new Error(this.#errMsg);
|
|
3323
3337
|
}
|
|
3324
3338
|
/**
|
|
3325
3339
|
* 设置邀请加入群请求结果
|
|
@@ -3328,7 +3342,7 @@ var init_base = __esm({
|
|
|
3328
3342
|
* @returns 此接口的返回值不值得信任
|
|
3329
3343
|
*/
|
|
3330
3344
|
setInvitedJoinGroupResult(_requestId, _isApprove) {
|
|
3331
|
-
throw new Error(
|
|
3345
|
+
throw new Error(this.#errMsg);
|
|
3332
3346
|
}
|
|
3333
3347
|
/**
|
|
3334
3348
|
* 设置消息表情回应
|
|
@@ -3338,7 +3352,7 @@ var init_base = __esm({
|
|
|
3338
3352
|
* @returns 此接口的返回值不值得信任
|
|
3339
3353
|
*/
|
|
3340
3354
|
setMsgReaction(_contact, _messageId, _faceId, _isSet) {
|
|
3341
|
-
throw new Error(
|
|
3355
|
+
throw new Error(this.#errMsg);
|
|
3342
3356
|
}
|
|
3343
3357
|
/**
|
|
3344
3358
|
* 上传群文件、私聊文件
|
|
@@ -3349,7 +3363,7 @@ var init_base = __esm({
|
|
|
3349
3363
|
* @returns 此接口的返回值不值得信任
|
|
3350
3364
|
*/
|
|
3351
3365
|
uploadFile(_contact, _file, _name, _folder) {
|
|
3352
|
-
throw new Error(
|
|
3366
|
+
throw new Error(this.#errMsg);
|
|
3353
3367
|
}
|
|
3354
3368
|
/**
|
|
3355
3369
|
* 让协议端下载文件到协议端本地
|
|
@@ -3357,7 +3371,7 @@ var init_base = __esm({
|
|
|
3357
3371
|
* @returns 下载文件的绝对路径和文件MD5
|
|
3358
3372
|
*/
|
|
3359
3373
|
downloadFile(_options) {
|
|
3360
|
-
throw new Error(
|
|
3374
|
+
throw new Error(this.#errMsg);
|
|
3361
3375
|
}
|
|
3362
3376
|
/**
|
|
3363
3377
|
* 创建群文件夹
|
|
@@ -3366,7 +3380,7 @@ var init_base = __esm({
|
|
|
3366
3380
|
* @returns 返回文件夹id和已使用空间
|
|
3367
3381
|
*/
|
|
3368
3382
|
createGroupFolder(_groupId, _name) {
|
|
3369
|
-
throw new Error(
|
|
3383
|
+
throw new Error(this.#errMsg);
|
|
3370
3384
|
}
|
|
3371
3385
|
/**
|
|
3372
3386
|
* 重命名群文件的文件夹
|
|
@@ -3376,7 +3390,7 @@ var init_base = __esm({
|
|
|
3376
3390
|
* @returns 无返回值
|
|
3377
3391
|
*/
|
|
3378
3392
|
renameGroupFolder(_groupId, _folderId, _name) {
|
|
3379
|
-
throw new Error(
|
|
3393
|
+
throw new Error(this.#errMsg);
|
|
3380
3394
|
}
|
|
3381
3395
|
/**
|
|
3382
3396
|
* 删除群文件的文件夹
|
|
@@ -3385,7 +3399,7 @@ var init_base = __esm({
|
|
|
3385
3399
|
* @returns 无返回值
|
|
3386
3400
|
*/
|
|
3387
3401
|
delGroupFolder(_groupId, _folderId) {
|
|
3388
|
-
throw new Error(
|
|
3402
|
+
throw new Error(this.#errMsg);
|
|
3389
3403
|
}
|
|
3390
3404
|
/**
|
|
3391
3405
|
* 上传群文件
|
|
@@ -3396,7 +3410,16 @@ var init_base = __esm({
|
|
|
3396
3410
|
* @returns 无返回值
|
|
3397
3411
|
*/
|
|
3398
3412
|
uploadGroupFile(_groupId, _file, _name) {
|
|
3399
|
-
throw new Error(
|
|
3413
|
+
throw new Error(this.#errMsg);
|
|
3414
|
+
}
|
|
3415
|
+
/**
|
|
3416
|
+
* 获取文件url
|
|
3417
|
+
* @param _contact 目标信息
|
|
3418
|
+
* @param _fileId 文件id
|
|
3419
|
+
* @returns 文件url
|
|
3420
|
+
*/
|
|
3421
|
+
getFileUrl(_contact, _fileId) {
|
|
3422
|
+
throw new Error(this.#errMsg);
|
|
3400
3423
|
}
|
|
3401
3424
|
/**
|
|
3402
3425
|
* 删除群文件
|
|
@@ -3406,7 +3429,7 @@ var init_base = __esm({
|
|
|
3406
3429
|
* @returns 无返回值
|
|
3407
3430
|
*/
|
|
3408
3431
|
delGroupFile(_groupId, _fileId, _busId) {
|
|
3409
|
-
throw new Error(
|
|
3432
|
+
throw new Error(this.#errMsg);
|
|
3410
3433
|
}
|
|
3411
3434
|
/**
|
|
3412
3435
|
* 获取群文件系统信息
|
|
@@ -3414,7 +3437,7 @@ var init_base = __esm({
|
|
|
3414
3437
|
* @returns 返回文件数量、文件数量上限、已使用空间和空间上限
|
|
3415
3438
|
*/
|
|
3416
3439
|
getGroupFileSystemInfo(_groupId) {
|
|
3417
|
-
throw new Error(
|
|
3440
|
+
throw new Error(this.#errMsg);
|
|
3418
3441
|
}
|
|
3419
3442
|
/**
|
|
3420
3443
|
* 获取群文件夹下文件列表
|
|
@@ -3423,7 +3446,7 @@ var init_base = __esm({
|
|
|
3423
3446
|
* @returns 返回文件和文件夹的列表
|
|
3424
3447
|
*/
|
|
3425
3448
|
getGroupFileList(_groupId, _folderId) {
|
|
3426
|
-
throw new Error(
|
|
3449
|
+
throw new Error(this.#errMsg);
|
|
3427
3450
|
}
|
|
3428
3451
|
/**
|
|
3429
3452
|
* 设置群备注
|
|
@@ -3432,14 +3455,14 @@ var init_base = __esm({
|
|
|
3432
3455
|
* @returns 此接口的返回值不值得信任
|
|
3433
3456
|
*/
|
|
3434
3457
|
setGroupRemark(_groupId, _remark) {
|
|
3435
|
-
throw new Error(
|
|
3458
|
+
throw new Error(this.#errMsg);
|
|
3436
3459
|
}
|
|
3437
3460
|
/**
|
|
3438
3461
|
* 获取陌生群信息
|
|
3439
3462
|
* @param _groupId 群号
|
|
3440
3463
|
*/
|
|
3441
3464
|
getNotJoinedGroupInfo(_groupId) {
|
|
3442
|
-
throw new Error(
|
|
3465
|
+
throw new Error(this.#errMsg);
|
|
3443
3466
|
}
|
|
3444
3467
|
/**
|
|
3445
3468
|
* 获取艾特全体成员剩余次数
|
|
@@ -3447,7 +3470,7 @@ var init_base = __esm({
|
|
|
3447
3470
|
* @returns 返回是否允许at全体成员和全群剩余次数、个人剩余次数
|
|
3448
3471
|
*/
|
|
3449
3472
|
getAtAllCount(_groupId) {
|
|
3450
|
-
throw new Error(
|
|
3473
|
+
throw new Error(this.#errMsg);
|
|
3451
3474
|
}
|
|
3452
3475
|
/**
|
|
3453
3476
|
* 获取群被禁言用户列表
|
|
@@ -3455,7 +3478,7 @@ var init_base = __esm({
|
|
|
3455
3478
|
* @returns 返回禁言用户列表
|
|
3456
3479
|
*/
|
|
3457
3480
|
getGroupMuteList(_groupId) {
|
|
3458
|
-
throw new Error(
|
|
3481
|
+
throw new Error(this.#errMsg);
|
|
3459
3482
|
}
|
|
3460
3483
|
/**
|
|
3461
3484
|
* 戳一戳用户 支持群聊和私聊
|
|
@@ -3464,28 +3487,28 @@ var init_base = __esm({
|
|
|
3464
3487
|
* @returns 此接口的返回值不值得信任
|
|
3465
3488
|
*/
|
|
3466
3489
|
pokeUser(_contact, _count) {
|
|
3467
|
-
throw new Error(
|
|
3490
|
+
throw new Error(this.#errMsg);
|
|
3468
3491
|
}
|
|
3469
3492
|
/**
|
|
3470
3493
|
* 获取 Cookies
|
|
3471
3494
|
* @param _domain The domain to get cookies from
|
|
3472
3495
|
*/
|
|
3473
3496
|
getCookies(_domain) {
|
|
3474
|
-
throw new Error(
|
|
3497
|
+
throw new Error(this.#errMsg);
|
|
3475
3498
|
}
|
|
3476
3499
|
/**
|
|
3477
3500
|
* 获取 QQ 相关接口凭证
|
|
3478
3501
|
* @param _domain The domain to get credentials from
|
|
3479
3502
|
*/
|
|
3480
3503
|
getCredentials(_domain) {
|
|
3481
|
-
throw new Error(
|
|
3504
|
+
throw new Error(this.#errMsg);
|
|
3482
3505
|
}
|
|
3483
3506
|
/**
|
|
3484
3507
|
* 获取 CSRF Token
|
|
3485
3508
|
* @param _domain The domain to get the CSRF token from
|
|
3486
3509
|
*/
|
|
3487
3510
|
getCSRFToken(_domain) {
|
|
3488
|
-
throw new Error(
|
|
3511
|
+
throw new Error(this.#errMsg);
|
|
3489
3512
|
}
|
|
3490
3513
|
/**
|
|
3491
3514
|
* 获取 HTTP Cookies
|
|
@@ -3494,7 +3517,7 @@ var init_base = __esm({
|
|
|
3494
3517
|
* @param _jumpUrl The jump url
|
|
3495
3518
|
*/
|
|
3496
3519
|
getHttpCookies(_appid, _daid, _jumpUrl) {
|
|
3497
|
-
throw new Error(
|
|
3520
|
+
throw new Error(this.#errMsg);
|
|
3498
3521
|
}
|
|
3499
3522
|
};
|
|
3500
3523
|
}
|
|
@@ -3555,6 +3578,8 @@ var init_api = __esm({
|
|
|
3555
3578
|
OB11ApiAction2["getEssenceMsgList"] = "get_essence_msg_list";
|
|
3556
3579
|
OB11ApiAction2["setEssenceMsg"] = "set_essence_msg";
|
|
3557
3580
|
OB11ApiAction2["deleteEssenceMsg"] = "delete_essence_msg";
|
|
3581
|
+
OB11ApiAction2["getGroupFileUrl"] = "get_group_file_url";
|
|
3582
|
+
OB11ApiAction2["getPrivateFileUrl"] = "get_private_file_url";
|
|
3558
3583
|
return OB11ApiAction2;
|
|
3559
3584
|
})(OB11ApiAction || {});
|
|
3560
3585
|
}
|
|
@@ -3606,6 +3631,7 @@ var init_event2 = __esm({
|
|
|
3606
3631
|
OB11NoticeType2["GroupMsgEmojiLikeLagrange"] = "reaction";
|
|
3607
3632
|
OB11NoticeType2["GroupEssence"] = "essence";
|
|
3608
3633
|
OB11NoticeType2["GroupCard"] = "group_card";
|
|
3634
|
+
OB11NoticeType2["OfflineFile"] = "offline_file";
|
|
3609
3635
|
return OB11NoticeType2;
|
|
3610
3636
|
})(OB11NoticeType || {});
|
|
3611
3637
|
OB11RequestType = /* @__PURE__ */ ((OB11RequestType2) => {
|
|
@@ -3615,62 +3641,7 @@ var init_event2 = __esm({
|
|
|
3615
3641
|
})(OB11RequestType || {});
|
|
3616
3642
|
}
|
|
3617
3643
|
});
|
|
3618
|
-
|
|
3619
|
-
const elements = [];
|
|
3620
|
-
try {
|
|
3621
|
-
for (const i of data) {
|
|
3622
|
-
switch (i.type) {
|
|
3623
|
-
case "text":
|
|
3624
|
-
elements.push(segment_exports.text(i.data.text));
|
|
3625
|
-
break;
|
|
3626
|
-
case "face":
|
|
3627
|
-
elements.push(segment_exports.face(Number(i.data.id)));
|
|
3628
|
-
break;
|
|
3629
|
-
case "image":
|
|
3630
|
-
elements.push(segment_exports.image(i.data.url || i.data.file, { fileType: i.data.type }));
|
|
3631
|
-
break;
|
|
3632
|
-
case "record":
|
|
3633
|
-
elements.push(segment_exports.record(i.data.url || i.data.file, i.data.magic === 1));
|
|
3634
|
-
break;
|
|
3635
|
-
case "video":
|
|
3636
|
-
elements.push(segment_exports.video(i.data.url || i.data.file));
|
|
3637
|
-
break;
|
|
3638
|
-
case "at":
|
|
3639
|
-
elements.push(segment_exports.at(i.data.qq, i.data.name));
|
|
3640
|
-
break;
|
|
3641
|
-
case "contact":
|
|
3642
|
-
elements.push(segment_exports.contact(i.data.type === "qq" ? "friend" : "group", i.data.id));
|
|
3643
|
-
break;
|
|
3644
|
-
case "location":
|
|
3645
|
-
elements.push(segment_exports.location(
|
|
3646
|
-
Number(i.data.lat),
|
|
3647
|
-
Number(i.data.lon),
|
|
3648
|
-
i.data.title || "",
|
|
3649
|
-
i.data.content || ""
|
|
3650
|
-
));
|
|
3651
|
-
break;
|
|
3652
|
-
case "reply":
|
|
3653
|
-
elements.push(segment_exports.reply(i.data.id));
|
|
3654
|
-
break;
|
|
3655
|
-
case "json":
|
|
3656
|
-
elements.push(segment_exports.json(i.data.data));
|
|
3657
|
-
break;
|
|
3658
|
-
case "xml":
|
|
3659
|
-
elements.push(segment_exports.xml(i.data.data));
|
|
3660
|
-
break;
|
|
3661
|
-
default: {
|
|
3662
|
-
elements.push(segment_exports.text(JSON.stringify(i)));
|
|
3663
|
-
}
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
} catch (error) {
|
|
3667
|
-
logger.error("[AdapterConvertKarin] \u8F6C\u6362\u9519\u8BEF");
|
|
3668
|
-
logger.error(error);
|
|
3669
|
-
return elements;
|
|
3670
|
-
}
|
|
3671
|
-
return elements;
|
|
3672
|
-
}
|
|
3673
|
-
var formatLogString, buildError, fileToBase64, KarinConvertAdapter;
|
|
3644
|
+
var formatLogString, buildError, AdapterConvertKarin, getFileSegment, fileToBase64, KarinConvertAdapter;
|
|
3674
3645
|
var init_convert = __esm({
|
|
3675
3646
|
"src/adapter/onebot/core/convert.ts"() {
|
|
3676
3647
|
init_message2();
|
|
@@ -3689,11 +3660,88 @@ var init_convert = __esm({
|
|
|
3689
3660
|
action: ${action}
|
|
3690
3661
|
params: ${formatLogString(request2)}`);
|
|
3691
3662
|
};
|
|
3692
|
-
|
|
3693
|
-
if (!
|
|
3663
|
+
AdapterConvertKarin = async (data, onebot, contact3) => {
|
|
3664
|
+
if (!Array.isArray(data)) return [];
|
|
3665
|
+
const elements = [];
|
|
3666
|
+
try {
|
|
3667
|
+
for (const i of data) {
|
|
3668
|
+
switch (i.type) {
|
|
3669
|
+
case "text":
|
|
3670
|
+
elements.push(segment_exports.text(i.data.text));
|
|
3671
|
+
break;
|
|
3672
|
+
case "face":
|
|
3673
|
+
elements.push(segment_exports.face(Number(i.data.id)));
|
|
3674
|
+
break;
|
|
3675
|
+
case "image":
|
|
3676
|
+
elements.push(segment_exports.image(i.data.url || i.data.file, { fileType: i.data.type }));
|
|
3677
|
+
break;
|
|
3678
|
+
case "record":
|
|
3679
|
+
elements.push(segment_exports.record(i.data.url || i.data.file, i.data.magic === 1));
|
|
3680
|
+
break;
|
|
3681
|
+
case "video":
|
|
3682
|
+
elements.push(segment_exports.video(i.data.url || i.data.file));
|
|
3683
|
+
break;
|
|
3684
|
+
case "at":
|
|
3685
|
+
elements.push(segment_exports.at(i.data.qq, i.data.name));
|
|
3686
|
+
break;
|
|
3687
|
+
case "contact":
|
|
3688
|
+
elements.push(segment_exports.contact(i.data.type === "qq" ? "friend" : "group", i.data.id));
|
|
3689
|
+
break;
|
|
3690
|
+
case "location":
|
|
3691
|
+
elements.push(segment_exports.location(
|
|
3692
|
+
Number(i.data.lat),
|
|
3693
|
+
Number(i.data.lon),
|
|
3694
|
+
i.data.title || "",
|
|
3695
|
+
i.data.content || ""
|
|
3696
|
+
));
|
|
3697
|
+
break;
|
|
3698
|
+
case "reply":
|
|
3699
|
+
elements.push(segment_exports.reply(i.data.id));
|
|
3700
|
+
break;
|
|
3701
|
+
case "json":
|
|
3702
|
+
elements.push(segment_exports.json(i.data.data));
|
|
3703
|
+
break;
|
|
3704
|
+
case "xml":
|
|
3705
|
+
elements.push(segment_exports.xml(i.data.data));
|
|
3706
|
+
break;
|
|
3707
|
+
case "file":
|
|
3708
|
+
elements.push(await getFileSegment(i.data, onebot, contact3));
|
|
3709
|
+
break;
|
|
3710
|
+
default: {
|
|
3711
|
+
elements.push(segment_exports.text(JSON.stringify(i)));
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
} catch (error) {
|
|
3716
|
+
logger.error("[AdapterConvertKarin] \u8F6C\u6362\u9519\u8BEF");
|
|
3717
|
+
logger.error(error);
|
|
3718
|
+
return elements;
|
|
3719
|
+
}
|
|
3720
|
+
return elements;
|
|
3721
|
+
};
|
|
3722
|
+
getFileSegment = async (file2, onebot, contact3) => {
|
|
3723
|
+
if ("file_name" in file2 && "file_hash" in file2) {
|
|
3724
|
+
return segment_exports.file(file2.url, {
|
|
3725
|
+
name: file2.file_name,
|
|
3726
|
+
hash: file2.file_hash,
|
|
3727
|
+
fid: file2.file_id
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3730
|
+
if (Object.keys(file2).length === 3 && "file_size" in file2 && "file_id" in file2) {
|
|
3731
|
+
const url = await onebot.getFileUrl(contact3, file2.file_id);
|
|
3732
|
+
return segment_exports.file(url, {
|
|
3733
|
+
name: file2.file,
|
|
3734
|
+
size: file2.file_size,
|
|
3735
|
+
fid: file2.file_id
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
return segment_exports.file(file2.file, { ...file2 });
|
|
3739
|
+
};
|
|
3740
|
+
fileToBase64 = (file2, url) => {
|
|
3741
|
+
if (!url || !file2.startsWith("file://")) return file2;
|
|
3694
3742
|
const list2 = ["127.0.0.1", "localhost"];
|
|
3695
3743
|
const link = new URL(url);
|
|
3696
|
-
return list2.includes(link.hostname) ?
|
|
3744
|
+
return list2.includes(link.hostname) ? file2 : `base64://${fs5.readFileSync(file2.replace("file://", "")).toString("base64")}`;
|
|
3697
3745
|
};
|
|
3698
3746
|
KarinConvertAdapter = (data, onebot) => {
|
|
3699
3747
|
const elements = [];
|
|
@@ -3886,14 +3934,14 @@ var init_error2 = __esm({
|
|
|
3886
3934
|
"src/core/internal/error.ts"() {
|
|
3887
3935
|
init_listeners();
|
|
3888
3936
|
missing = /* @__PURE__ */ new Map();
|
|
3889
|
-
loaderPlugin = (name,
|
|
3937
|
+
loaderPlugin = (name, file2, error) => {
|
|
3890
3938
|
const pkg2 = /Cannot find package '(.+?)'/.exec(error)?.[1];
|
|
3891
3939
|
if (pkg2) {
|
|
3892
3940
|
const key = `${name}.${pkg2}`;
|
|
3893
3941
|
if (missing.has(key)) return;
|
|
3894
|
-
missing.set(key, { name, file, depend: pkg2 });
|
|
3942
|
+
missing.set(key, { name, file: file2, depend: pkg2 });
|
|
3895
3943
|
} else {
|
|
3896
|
-
logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path4.basename(
|
|
3944
|
+
logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path4.basename(file2)}`)}`);
|
|
3897
3945
|
listeners.emit("error", error);
|
|
3898
3946
|
}
|
|
3899
3947
|
};
|
|
@@ -3905,8 +3953,8 @@ var init_error2 = __esm({
|
|
|
3905
3953
|
try {
|
|
3906
3954
|
if (!missing.size) return;
|
|
3907
3955
|
const msg = ["\n-----\u4F9D\u8D56\u7F3A\u5931----"];
|
|
3908
|
-
for (const [, { name, file, depend }] of missing) {
|
|
3909
|
-
msg.push(`[${name}][${path4.basename(
|
|
3956
|
+
for (const [, { name, file: file2, depend }] of missing) {
|
|
3957
|
+
msg.push(`[${name}][${path4.basename(file2)}] \u7F3A\u5C11\u4F9D\u8D56\uFF1A${logger.red(depend)}`);
|
|
3910
3958
|
}
|
|
3911
3959
|
msg.push("-------------------");
|
|
3912
3960
|
const one = missing.values().next().value;
|
|
@@ -4706,8 +4754,8 @@ var init_other = __esm({
|
|
|
4706
4754
|
case "friendRecall":
|
|
4707
4755
|
ctx3.tips = `\u64A4\u56DE\u6D88\u606F: ${ctx3.content.messageId}`;
|
|
4708
4756
|
break;
|
|
4709
|
-
case "
|
|
4710
|
-
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [
|
|
4757
|
+
case "privateFileUploaded":
|
|
4758
|
+
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [fid:${ctx3.content.fid}] [name:${ctx3.content.name}]`;
|
|
4711
4759
|
break;
|
|
4712
4760
|
case "friendIncrease":
|
|
4713
4761
|
ctx3.tips = `\u65B0\u589E\u597D\u53CB: ${ctx3.content.targetId}`;
|
|
@@ -4725,7 +4773,7 @@ var init_other = __esm({
|
|
|
4725
4773
|
ctx3.tips = `\u64A4\u56DE\u6D88\u606F: ${ctx3.content.messageId}`;
|
|
4726
4774
|
break;
|
|
4727
4775
|
case "groupFileUploaded":
|
|
4728
|
-
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [
|
|
4776
|
+
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [fid:${ctx3.content.fid}] [name:${ctx3.content.name}]`;
|
|
4729
4777
|
break;
|
|
4730
4778
|
case "groupMemberAdd":
|
|
4731
4779
|
ctx3.tips = `\u65B0\u589E\u6210\u5458: [\u64CD\u4F5C\u8005:${ctx3.content.operatorId}] [\u76EE\u6807\u6210\u5458:${ctx3.content.targetId}]`;
|
|
@@ -4778,8 +4826,15 @@ var init_other = __esm({
|
|
|
4778
4826
|
}
|
|
4779
4827
|
};
|
|
4780
4828
|
initPrint = (ctx3, type, prefix, level = "info") => {
|
|
4781
|
-
|
|
4782
|
-
|
|
4829
|
+
let idPath = "\u672A\u77E5";
|
|
4830
|
+
if (ctx3.isFriend) {
|
|
4831
|
+
idPath = ctx3.userId;
|
|
4832
|
+
} else if (ctx3.isGroup) {
|
|
4833
|
+
idPath = `${ctx3.groupId}-${ctx3.userId}`;
|
|
4834
|
+
}
|
|
4835
|
+
const nick = ctx3.sender.nick || "";
|
|
4836
|
+
ctx3.logText = `[${type}:${idPath}(${nick})]`;
|
|
4837
|
+
logger.bot(level, ctx3.selfId, `${prefix}: ${ctx3.logText} ${ctx3.tips}`);
|
|
4783
4838
|
};
|
|
4784
4839
|
deal = async (ctx3, config3) => {
|
|
4785
4840
|
for (const plugin of cache3.accept) {
|
|
@@ -6397,8 +6452,8 @@ var init_notice2 = __esm({
|
|
|
6397
6452
|
#sender;
|
|
6398
6453
|
content;
|
|
6399
6454
|
constructor(options) {
|
|
6400
|
-
super(Object.assign(options, { subEvent: "
|
|
6401
|
-
this.#subEvent = "
|
|
6455
|
+
super(Object.assign(options, { subEvent: "privateFileUploaded" }));
|
|
6456
|
+
this.#subEvent = "privateFileUploaded";
|
|
6402
6457
|
this.#contact = options.contact;
|
|
6403
6458
|
this.#sender = options.sender;
|
|
6404
6459
|
this.content = options.content;
|
|
@@ -7547,7 +7602,7 @@ var init_message5 = __esm({
|
|
|
7547
7602
|
init_convert();
|
|
7548
7603
|
init_create();
|
|
7549
7604
|
init_event3();
|
|
7550
|
-
createMessage = (event, bot) => {
|
|
7605
|
+
createMessage = async (event, bot) => {
|
|
7551
7606
|
debug("onebot:createMessage", event);
|
|
7552
7607
|
const time2 = event.time;
|
|
7553
7608
|
if (event.message_type === "private") {
|
|
@@ -7569,7 +7624,7 @@ var init_message5 = __esm({
|
|
|
7569
7624
|
messageId: event.message_id + "",
|
|
7570
7625
|
messageSeq: event.message_id,
|
|
7571
7626
|
eventId: `message:${event.message_id}`,
|
|
7572
|
-
elements: AdapterConvertKarin(event.message),
|
|
7627
|
+
elements: await AdapterConvertKarin(event.message, bot),
|
|
7573
7628
|
srcReply: (elements) => bot.sendMsg(contact3, elements)
|
|
7574
7629
|
});
|
|
7575
7630
|
return;
|
|
@@ -7582,7 +7637,7 @@ var init_message5 = __esm({
|
|
|
7582
7637
|
createGroupTempMessage({
|
|
7583
7638
|
bot,
|
|
7584
7639
|
contact: contact3,
|
|
7585
|
-
elements: AdapterConvertKarin(event.message),
|
|
7640
|
+
elements: await AdapterConvertKarin(event.message, bot),
|
|
7586
7641
|
eventId: `message:${event.message_id}`,
|
|
7587
7642
|
messageId: event.message_id + "",
|
|
7588
7643
|
messageSeq: event.message_id,
|
|
@@ -7605,7 +7660,7 @@ var init_message5 = __esm({
|
|
|
7605
7660
|
createGroupMessage({
|
|
7606
7661
|
bot,
|
|
7607
7662
|
contact: contact3,
|
|
7608
|
-
elements: AdapterConvertKarin(event.message),
|
|
7663
|
+
elements: await AdapterConvertKarin(event.message, bot),
|
|
7609
7664
|
eventId: `message:${event.message_id}`,
|
|
7610
7665
|
messageId: event.message_id + "",
|
|
7611
7666
|
messageSeq: event.message_id,
|
|
@@ -7628,6 +7683,7 @@ var init_notice3 = __esm({
|
|
|
7628
7683
|
init_event3();
|
|
7629
7684
|
init_event2();
|
|
7630
7685
|
init_create();
|
|
7686
|
+
init_convert();
|
|
7631
7687
|
createNotice = (event, bot) => {
|
|
7632
7688
|
const time2 = event.time;
|
|
7633
7689
|
if (event.notice_type === "friend_recall" /* FriendRecall */) {
|
|
@@ -7826,7 +7882,11 @@ var init_notice3 = __esm({
|
|
|
7826
7882
|
fid: event.file.id,
|
|
7827
7883
|
name: event.file.name,
|
|
7828
7884
|
size: event.file.size,
|
|
7829
|
-
subId: event.file.busid
|
|
7885
|
+
subId: event.file.busid,
|
|
7886
|
+
url: async () => {
|
|
7887
|
+
const { file: file2 } = await getFileSegment(event.file, bot, contact3);
|
|
7888
|
+
return file2;
|
|
7889
|
+
}
|
|
7830
7890
|
}
|
|
7831
7891
|
});
|
|
7832
7892
|
return;
|
|
@@ -7954,6 +8014,32 @@ var init_notice3 = __esm({
|
|
|
7954
8014
|
});
|
|
7955
8015
|
return;
|
|
7956
8016
|
}
|
|
8017
|
+
if (event.notice_type === "offline_file" /* OfflineFile */) {
|
|
8018
|
+
const userId = event.user_id + "";
|
|
8019
|
+
const contact3 = contactFriend(userId);
|
|
8020
|
+
createPrivateFileUploadedNotice({
|
|
8021
|
+
bot,
|
|
8022
|
+
eventId: `notice:${userId}.${event.time}`,
|
|
8023
|
+
rawEvent: event,
|
|
8024
|
+
time: time2,
|
|
8025
|
+
contact: contact3,
|
|
8026
|
+
sender: senderFriend(userId),
|
|
8027
|
+
srcReply: (elements) => bot.sendMsg(contact3, elements),
|
|
8028
|
+
content: {
|
|
8029
|
+
operatorId: userId,
|
|
8030
|
+
subId: 0,
|
|
8031
|
+
fid: event.file.id,
|
|
8032
|
+
name: event.file.name,
|
|
8033
|
+
size: event.file.size,
|
|
8034
|
+
expireTime: 0,
|
|
8035
|
+
url: async () => {
|
|
8036
|
+
const { file: file2 } = await getFileSegment(event.file, bot, contact3);
|
|
8037
|
+
return file2;
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
});
|
|
8041
|
+
return;
|
|
8042
|
+
}
|
|
7957
8043
|
logger.warn(`[AdapterOneBot] \u6536\u5230\u672A\u77E5\u4E8B\u4EF6: ${JSON.stringify(event)}`);
|
|
7958
8044
|
};
|
|
7959
8045
|
}
|
|
@@ -8058,24 +8144,19 @@ var init_base3 = __esm({
|
|
|
8058
8144
|
* @param str 事件字符串
|
|
8059
8145
|
*/
|
|
8060
8146
|
eventHandlers(data, str) {
|
|
8061
|
-
debug("onebot", str);
|
|
8062
8147
|
if (data.post_type === "message" /* Message */ || data.post_type === "message_sent" /* MessageSent */) {
|
|
8063
|
-
debug("onebot:message", str);
|
|
8064
8148
|
createMessage(data, this);
|
|
8065
8149
|
return;
|
|
8066
8150
|
}
|
|
8067
8151
|
if (data.post_type === "notice" /* Notice */) {
|
|
8068
|
-
debug("onebot:notice", str);
|
|
8069
8152
|
createNotice(data, this);
|
|
8070
8153
|
return;
|
|
8071
8154
|
}
|
|
8072
8155
|
if (data.post_type === "request" /* Request */) {
|
|
8073
|
-
debug("onebot:request", str);
|
|
8074
8156
|
createRequest(data, this);
|
|
8075
8157
|
return;
|
|
8076
8158
|
}
|
|
8077
8159
|
if (data.post_type === "meta_event" /* MetaEvent */) {
|
|
8078
|
-
debug("onebot:meta", str);
|
|
8079
8160
|
if (data.meta_event_type === "lifecycle") {
|
|
8080
8161
|
if (data.sub_type === "enable") {
|
|
8081
8162
|
logger.bot("debug", this.selfId, "OneBot\u542F\u7528");
|
|
@@ -8092,7 +8173,6 @@ var init_base3 = __esm({
|
|
|
8092
8173
|
return;
|
|
8093
8174
|
}
|
|
8094
8175
|
if (data.retcode) {
|
|
8095
|
-
debug("onebot:retcode", str);
|
|
8096
8176
|
const { retcode } = data;
|
|
8097
8177
|
if (retcode === 1401 || retcode === 1403) {
|
|
8098
8178
|
logger.error(`[oneBot11][\u9274\u6743\u5931\u8D25] address: ${this.adapter.address} event: ${str}`);
|
|
@@ -8100,7 +8180,6 @@ var init_base3 = __esm({
|
|
|
8100
8180
|
}
|
|
8101
8181
|
logger.bot("error", this.selfId, `\u53D1\u751F\u672A\u77E5\u9519\u8BEF: ${str}`);
|
|
8102
8182
|
}
|
|
8103
|
-
debug("onebot:unknown", str);
|
|
8104
8183
|
logger.bot("warn", this.selfId, `\u6536\u5230\u672A\u77E5\u4E8B\u4EF6: ${str}`);
|
|
8105
8184
|
}
|
|
8106
8185
|
/**
|
|
@@ -8108,7 +8187,7 @@ var init_base3 = __esm({
|
|
|
8108
8187
|
* @return karin格式消息
|
|
8109
8188
|
*/
|
|
8110
8189
|
AdapterConvertKarin(data) {
|
|
8111
|
-
return AdapterConvertKarin(data);
|
|
8190
|
+
return AdapterConvertKarin(data, this);
|
|
8112
8191
|
}
|
|
8113
8192
|
/**
|
|
8114
8193
|
* karin转onebot11
|
|
@@ -8299,7 +8378,7 @@ var init_base3 = __esm({
|
|
|
8299
8378
|
role: "unknown",
|
|
8300
8379
|
name: result.sender.nickname
|
|
8301
8380
|
},
|
|
8302
|
-
elements: this.AdapterConvertKarin(result.message)
|
|
8381
|
+
elements: await this.AdapterConvertKarin(result.message)
|
|
8303
8382
|
};
|
|
8304
8383
|
}
|
|
8305
8384
|
/**
|
|
@@ -8373,7 +8452,7 @@ var init_base3 = __esm({
|
|
|
8373
8452
|
role: v?.sender?.role || "unknown",
|
|
8374
8453
|
card: contact3.scene === "group" ? v?.sender?.card || "" : ""
|
|
8375
8454
|
},
|
|
8376
|
-
elements: this.AdapterConvertKarin(v.message)
|
|
8455
|
+
elements: await this.AdapterConvertKarin(v.message)
|
|
8377
8456
|
};
|
|
8378
8457
|
all.push(data);
|
|
8379
8458
|
}
|
|
@@ -9055,12 +9134,12 @@ var init_base3 = __esm({
|
|
|
9055
9134
|
* @param folder 父目录ID 不提供则上传到根目录 仅在群聊时有效
|
|
9056
9135
|
* @returns 此接口的返回值不值得信任
|
|
9057
9136
|
*/
|
|
9058
|
-
async uploadFile(contact3,
|
|
9137
|
+
async uploadFile(contact3, file2, name, folder) {
|
|
9059
9138
|
try {
|
|
9060
9139
|
if (contact3.scene === "group") {
|
|
9061
|
-
await this.sendApi("upload_group_file" /* uploadGroupFile */, { group_id: Number(contact3.peer), file, name, folder });
|
|
9140
|
+
await this.sendApi("upload_group_file" /* uploadGroupFile */, { group_id: Number(contact3.peer), file: file2, name, folder });
|
|
9062
9141
|
} else {
|
|
9063
|
-
await this.sendApi("upload_private_file" /* uploadPrivateFile */, { user_id: Number(contact3.peer), file, name });
|
|
9142
|
+
await this.sendApi("upload_private_file" /* uploadPrivateFile */, { user_id: Number(contact3.peer), file: file2, name });
|
|
9064
9143
|
}
|
|
9065
9144
|
return true;
|
|
9066
9145
|
} catch {
|
|
@@ -9070,14 +9149,14 @@ var init_base3 = __esm({
|
|
|
9070
9149
|
/**
|
|
9071
9150
|
* @deprecated 已废弃,请使用`uploadFile`
|
|
9072
9151
|
*/
|
|
9073
|
-
async UploadGroupFile(groupId,
|
|
9074
|
-
return this.uploadFile({ scene: "group", peer: groupId, name: "" },
|
|
9152
|
+
async UploadGroupFile(groupId, file2, name, folder) {
|
|
9153
|
+
return this.uploadFile({ scene: "group", peer: groupId, name: "" }, file2, name, folder);
|
|
9075
9154
|
}
|
|
9076
9155
|
/**
|
|
9077
9156
|
* @deprecated 已废弃,请使用`uploadFile`
|
|
9078
9157
|
*/
|
|
9079
|
-
async UploadPrivateFile(userId,
|
|
9080
|
-
return this.uploadFile({ scene: "friend", peer: userId, name: "" },
|
|
9158
|
+
async UploadPrivateFile(userId, file2, name) {
|
|
9159
|
+
return this.uploadFile({ scene: "friend", peer: userId, name: "" }, file2, name);
|
|
9081
9160
|
}
|
|
9082
9161
|
/**
|
|
9083
9162
|
* 设置、取消群精华消息
|
|
@@ -9237,6 +9316,29 @@ var init_base3 = __esm({
|
|
|
9237
9316
|
async sendForwardMessage(contact3, elements) {
|
|
9238
9317
|
return this.sendForwardMsg(contact3, elements);
|
|
9239
9318
|
}
|
|
9319
|
+
/**
|
|
9320
|
+
* 获取文件url
|
|
9321
|
+
* @param contact 目标信息
|
|
9322
|
+
* @param fid 文件id
|
|
9323
|
+
* @returns 文件url
|
|
9324
|
+
*/
|
|
9325
|
+
async getFileUrl(contact3, fid) {
|
|
9326
|
+
if (contact3.scene === "group") {
|
|
9327
|
+
const { url } = await this.sendApi(
|
|
9328
|
+
"get_group_file_url" /* getGroupFileUrl */,
|
|
9329
|
+
{ group_id: Number(contact3.peer), file_id: fid }
|
|
9330
|
+
);
|
|
9331
|
+
return url;
|
|
9332
|
+
}
|
|
9333
|
+
if (contact3.scene === "friend") {
|
|
9334
|
+
const { url } = await this.sendApi(
|
|
9335
|
+
"get_private_file_url" /* getPrivateFileUrl */,
|
|
9336
|
+
{ user_id: Number(contact3.peer), file_id: fid }
|
|
9337
|
+
);
|
|
9338
|
+
return url;
|
|
9339
|
+
}
|
|
9340
|
+
throw TypeError(`\u4E0D\u652F\u6301\u7684\u573A\u666F\u7C7B\u578B: ${contact3.scene}`);
|
|
9341
|
+
}
|
|
9240
9342
|
/**
|
|
9241
9343
|
* 发送API请求
|
|
9242
9344
|
* @param action API端点
|
|
@@ -10049,8 +10151,8 @@ var init_list = __esm({
|
|
|
10049
10151
|
dir: dir2,
|
|
10050
10152
|
id: -1,
|
|
10051
10153
|
get pkgPath() {
|
|
10052
|
-
const
|
|
10053
|
-
return fs5.existsSync(
|
|
10154
|
+
const file2 = path4.join(this.dir, "package.json");
|
|
10155
|
+
return fs5.existsSync(file2) ? file2 : "";
|
|
10054
10156
|
},
|
|
10055
10157
|
get pkgData() {
|
|
10056
10158
|
if (!this.pkgPath) return {};
|
|
@@ -10133,18 +10235,18 @@ var init_list = __esm({
|
|
|
10133
10235
|
list2.map(async (v) => {
|
|
10134
10236
|
const [type, name] = v.split(":");
|
|
10135
10237
|
if (type === "app") {
|
|
10136
|
-
const
|
|
10137
|
-
await getAppInfo(info,
|
|
10238
|
+
const file2 = path4.join(karinPathPlugins, name);
|
|
10239
|
+
await getAppInfo(info, file2, name, ext, isForce);
|
|
10138
10240
|
return;
|
|
10139
10241
|
}
|
|
10140
10242
|
if (type === "git" || type === "root") {
|
|
10141
|
-
const
|
|
10142
|
-
await getGitInfo(info,
|
|
10243
|
+
const file2 = type === "root" ? process.cwd() : path4.join(karinPathPlugins, name);
|
|
10244
|
+
await getGitInfo(info, file2, name, ext, isForce, env3);
|
|
10143
10245
|
return;
|
|
10144
10246
|
}
|
|
10145
10247
|
if (type === "npm") {
|
|
10146
|
-
const
|
|
10147
|
-
await getNpmInfo(info,
|
|
10248
|
+
const file2 = path4.join(process.cwd(), "node_modules", name);
|
|
10249
|
+
await getNpmInfo(info, file2, name, isForce, env3);
|
|
10148
10250
|
}
|
|
10149
10251
|
})
|
|
10150
10252
|
);
|
|
@@ -10173,8 +10275,9 @@ var init_list = __esm({
|
|
|
10173
10275
|
if (!v.name.startsWith("karin-plugin-")) return;
|
|
10174
10276
|
if (!fs5.existsSync(path4.join(karinPathPlugins, v.name, "package.json"))) return;
|
|
10175
10277
|
const pkg2 = await requireFile(path4.join(karinPathPlugins, v.name, "package.json"));
|
|
10176
|
-
|
|
10177
|
-
|
|
10278
|
+
const engines = pkg2?.karin?.engines?.karin || pkg2?.engines?.karin;
|
|
10279
|
+
if (engines && !satisfies(engines, process.env.KARIN_VERSION)) {
|
|
10280
|
+
const msg = `[getPlugins][git] ${v.name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${engines}\uFF0C\u5F53\u524D\u4E0D\u7B26\u5408\u8981\u6C42\uFF0C\u8DF3\u8FC7\u52A0\u8F7D\u63D2\u4EF6`;
|
|
10178
10281
|
isInit && setTimeout(() => logger.error(msg), 1e3);
|
|
10179
10282
|
return;
|
|
10180
10283
|
}
|
|
@@ -10218,13 +10321,14 @@ var init_list = __esm({
|
|
|
10218
10321
|
].filter((name) => !NPM_EXCLUDE_LIST.includes(name) && !name.startsWith("@types"));
|
|
10219
10322
|
await Promise.allSettled(
|
|
10220
10323
|
dependencies.map(async (name) => {
|
|
10221
|
-
const
|
|
10222
|
-
const pkg3 = await requireFile(
|
|
10324
|
+
const file2 = path4.join(process.cwd(), "node_modules", name, "package.json");
|
|
10325
|
+
const pkg3 = await requireFile(file2);
|
|
10223
10326
|
if (!pkg3.karin) return;
|
|
10224
|
-
|
|
10225
|
-
|
|
10327
|
+
const engines = pkg3.karin?.engines?.karin || pkg3.engines?.karin;
|
|
10328
|
+
if (engines) {
|
|
10329
|
+
if (!satisfies(engines, process.env.KARIN_VERSION)) {
|
|
10226
10330
|
isInit && logger.error(
|
|
10227
|
-
`[getPlugins][npm] ${name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${
|
|
10331
|
+
`[getPlugins][npm] ${name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${engines}\uFF0C\u5F53\u524D\u4E0D\u7B26\u5408\u8981\u6C42\uFF0C\u8DF3\u8FC7\u52A0\u8F7D\u63D2\u4EF6`
|
|
10228
10332
|
);
|
|
10229
10333
|
return;
|
|
10230
10334
|
}
|
|
@@ -10440,11 +10544,11 @@ var init_update = __esm({
|
|
|
10440
10544
|
}
|
|
10441
10545
|
};
|
|
10442
10546
|
getCommit = async (options) => {
|
|
10443
|
-
const { path:
|
|
10547
|
+
const { path: path37, count: count3 = 1, hash, branch } = options;
|
|
10444
10548
|
let cmd = `git log -${count3} --format="[%ad]%s %n" --date="format:%m-%d %H:%M"`;
|
|
10445
10549
|
if (hash) cmd = `git log ${hash}..HEAD --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
|
|
10446
10550
|
if (branch) cmd = `git log -${count3} ${branch} --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
|
|
10447
|
-
const { stdout, error } = await exec(cmd, { cwd:
|
|
10551
|
+
const { stdout, error } = await exec(cmd, { cwd: path37 });
|
|
10448
10552
|
if (error) {
|
|
10449
10553
|
throw error;
|
|
10450
10554
|
}
|
|
@@ -11188,9 +11292,9 @@ var init_fileToUrl = __esm({
|
|
|
11188
11292
|
"src/utils/system/fileToUrl.ts"() {
|
|
11189
11293
|
init_handler2();
|
|
11190
11294
|
fileToUrlHandlerKey = "fileToUrl";
|
|
11191
|
-
fileToUrl = async (type,
|
|
11295
|
+
fileToUrl = async (type, file2, filename2, args) => {
|
|
11192
11296
|
if (!handler.has(fileToUrlHandlerKey)) throw new Error("[Handler][Error]: \u6CA1\u6709\u914D\u7F6E\u6587\u4EF6\u8F6C\u6362\u4E3Aurl\u7684\u5904\u7406\u5668");
|
|
11193
|
-
return handler(fileToUrlHandlerKey, { file, type, filename: filename2, args });
|
|
11297
|
+
return handler(fileToUrlHandlerKey, { file: file2, type, filename: filename2, args });
|
|
11194
11298
|
};
|
|
11195
11299
|
}
|
|
11196
11300
|
});
|
|
@@ -11540,8 +11644,8 @@ var init_github = __esm({
|
|
|
11540
11644
|
const urlObj = new URL$1(url);
|
|
11541
11645
|
const owner = urlObj.pathname.split("/")[1];
|
|
11542
11646
|
const repo = urlObj.pathname.split("/")[2];
|
|
11543
|
-
const
|
|
11544
|
-
return { owner, repo, path:
|
|
11647
|
+
const path37 = urlObj.pathname.split("/").slice(3).join("/");
|
|
11648
|
+
return { owner, repo, path: path37 };
|
|
11545
11649
|
};
|
|
11546
11650
|
getFastGithub = async (type) => {
|
|
11547
11651
|
const list2 = [
|
|
@@ -11561,8 +11665,8 @@ var init_github = __esm({
|
|
|
11561
11665
|
isClone: false,
|
|
11562
11666
|
isRaw: true,
|
|
11563
11667
|
raw: function(url) {
|
|
11564
|
-
const { owner, repo, path:
|
|
11565
|
-
return `${this.proxy}/${owner}/${repo}/${
|
|
11668
|
+
const { owner, repo, path: path37 } = parseGithubUrl(url);
|
|
11669
|
+
return `${this.proxy}/${owner}/${repo}/${path37}`;
|
|
11566
11670
|
},
|
|
11567
11671
|
clone: function(url) {
|
|
11568
11672
|
const { owner, repo } = parseGithubUrl(url);
|
|
@@ -11574,8 +11678,8 @@ var init_github = __esm({
|
|
|
11574
11678
|
isClone: false,
|
|
11575
11679
|
isRaw: true,
|
|
11576
11680
|
raw: function(url) {
|
|
11577
|
-
const { owner, repo, path:
|
|
11578
|
-
return `${this.proxy}/${owner}/${repo}/${
|
|
11681
|
+
const { owner, repo, path: path37 } = parseGithubUrl(url);
|
|
11682
|
+
return `${this.proxy}/${owner}/${repo}/${path37}`;
|
|
11579
11683
|
},
|
|
11580
11684
|
clone: function(url) {
|
|
11581
11685
|
const { owner, repo } = parseGithubUrl(url);
|
|
@@ -12052,7 +12156,7 @@ function requireDataStream() {
|
|
|
12052
12156
|
hasRequiredDataStream = 1;
|
|
12053
12157
|
var Buffer2 = requireSafeBuffer().Buffer;
|
|
12054
12158
|
var Stream = require$$32;
|
|
12055
|
-
var
|
|
12159
|
+
var util7 = require$$5;
|
|
12056
12160
|
function DataStream(data) {
|
|
12057
12161
|
this.buffer = null;
|
|
12058
12162
|
this.writable = true;
|
|
@@ -12078,7 +12182,7 @@ function requireDataStream() {
|
|
|
12078
12182
|
}
|
|
12079
12183
|
throw new TypeError("Unexpected data type (" + typeof data + ")");
|
|
12080
12184
|
}
|
|
12081
|
-
|
|
12185
|
+
util7.inherits(DataStream, Stream);
|
|
12082
12186
|
DataStream.prototype.write = function write2(data) {
|
|
12083
12187
|
this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]);
|
|
12084
12188
|
this.emit("data", data);
|
|
@@ -12287,7 +12391,7 @@ function requireJwa() {
|
|
|
12287
12391
|
var Buffer2 = requireSafeBuffer().Buffer;
|
|
12288
12392
|
var crypto9 = require$$22;
|
|
12289
12393
|
var formatEcdsa = requireEcdsaSigFormatter();
|
|
12290
|
-
var
|
|
12394
|
+
var util7 = require$$5;
|
|
12291
12395
|
var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".';
|
|
12292
12396
|
var MSG_INVALID_SECRET = "secret must be a string or buffer";
|
|
12293
12397
|
var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer";
|
|
@@ -12367,7 +12471,7 @@ function requireJwa() {
|
|
|
12367
12471
|
}
|
|
12368
12472
|
function typeError(template2) {
|
|
12369
12473
|
var args = [].slice.call(arguments, 1);
|
|
12370
|
-
var errMsg =
|
|
12474
|
+
var errMsg = util7.format.bind(util7, template2).apply(null, args);
|
|
12371
12475
|
return new TypeError(errMsg);
|
|
12372
12476
|
}
|
|
12373
12477
|
function bufferOrString(obj) {
|
|
@@ -12513,7 +12617,7 @@ function requireSignStream() {
|
|
|
12513
12617
|
var jwa2 = requireJwa();
|
|
12514
12618
|
var Stream = require$$32;
|
|
12515
12619
|
var toString = requireTostring();
|
|
12516
|
-
var
|
|
12620
|
+
var util7 = require$$5;
|
|
12517
12621
|
function base64url(string, encoding) {
|
|
12518
12622
|
return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
12519
12623
|
}
|
|
@@ -12521,7 +12625,7 @@ function requireSignStream() {
|
|
|
12521
12625
|
encoding = encoding || "utf8";
|
|
12522
12626
|
var encodedHeader = base64url(toString(header), "binary");
|
|
12523
12627
|
var encodedPayload = base64url(toString(payload), encoding);
|
|
12524
|
-
return
|
|
12628
|
+
return util7.format("%s.%s", encodedHeader, encodedPayload);
|
|
12525
12629
|
}
|
|
12526
12630
|
function jwsSign(opts) {
|
|
12527
12631
|
var header = opts.header;
|
|
@@ -12531,7 +12635,7 @@ function requireSignStream() {
|
|
|
12531
12635
|
var algo = jwa2(header.alg);
|
|
12532
12636
|
var securedInput = jwsSecuredInput(header, payload, encoding);
|
|
12533
12637
|
var signature = algo.sign(securedInput, secretOrKey);
|
|
12534
|
-
return
|
|
12638
|
+
return util7.format("%s.%s", securedInput, signature);
|
|
12535
12639
|
}
|
|
12536
12640
|
function SignStream(opts) {
|
|
12537
12641
|
var secret = opts.secret || opts.privateKey || opts.key;
|
|
@@ -12550,7 +12654,7 @@ function requireSignStream() {
|
|
|
12550
12654
|
this.sign();
|
|
12551
12655
|
}.bind(this));
|
|
12552
12656
|
}
|
|
12553
|
-
|
|
12657
|
+
util7.inherits(SignStream, Stream);
|
|
12554
12658
|
SignStream.prototype.sign = function sign2() {
|
|
12555
12659
|
try {
|
|
12556
12660
|
var signature = jwsSign({
|
|
@@ -12582,7 +12686,7 @@ function requireVerifyStream() {
|
|
|
12582
12686
|
var jwa2 = requireJwa();
|
|
12583
12687
|
var Stream = require$$32;
|
|
12584
12688
|
var toString = requireTostring();
|
|
12585
|
-
var
|
|
12689
|
+
var util7 = require$$5;
|
|
12586
12690
|
var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
|
|
12587
12691
|
function isObject(thing) {
|
|
12588
12692
|
return Object.prototype.toString.call(thing) === "[object Object]";
|
|
@@ -12661,7 +12765,7 @@ function requireVerifyStream() {
|
|
|
12661
12765
|
this.verify();
|
|
12662
12766
|
}.bind(this));
|
|
12663
12767
|
}
|
|
12664
|
-
|
|
12768
|
+
util7.inherits(VerifyStream, Stream);
|
|
12665
12769
|
VerifyStream.prototype.verify = function verify2() {
|
|
12666
12770
|
try {
|
|
12667
12771
|
var valid2 = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer);
|
|
@@ -15886,10 +15990,10 @@ var init_env4 = __esm({
|
|
|
15886
15990
|
};
|
|
15887
15991
|
initEnv = () => {
|
|
15888
15992
|
const name = process.env.EBV_FILE;
|
|
15889
|
-
const
|
|
15993
|
+
const file2 = `${process.cwd()}/${name}`;
|
|
15890
15994
|
getEnv();
|
|
15891
|
-
watch(
|
|
15892
|
-
dotenv_default.config({ path:
|
|
15995
|
+
watch(file2, (old, data) => {
|
|
15996
|
+
dotenv_default.config({ path: file2, override: true });
|
|
15893
15997
|
process.env.RUNTIME = data.RUNTIME.value || "node";
|
|
15894
15998
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
15895
15999
|
if (old?.WS_SERVER_AUTH_KEY?.value !== data?.WS_SERVER_AUTH_KEY?.value) {
|
|
@@ -15900,7 +16004,7 @@ var init_env4 = __esm({
|
|
|
15900
16004
|
logger.warn("[hmr] HTTP\u9274\u6743\u79D8\u94A5\u5DF2\u66F4\u65B0");
|
|
15901
16005
|
updateJwt();
|
|
15902
16006
|
}
|
|
15903
|
-
const options = { file, old, data };
|
|
16007
|
+
const options = { file: file2, old, data };
|
|
15904
16008
|
listeners.emit(FILE_CHANGE, options);
|
|
15905
16009
|
listeners.emit(`${FILE_CHANGE}:${name}`, options);
|
|
15906
16010
|
}, { parser });
|
|
@@ -16006,17 +16110,17 @@ var init_admin = __esm({
|
|
|
16006
16110
|
init_env4();
|
|
16007
16111
|
init_require();
|
|
16008
16112
|
getYaml = (name, type, isRefresh) => {
|
|
16009
|
-
const
|
|
16010
|
-
if (!fs5.existsSync(
|
|
16011
|
-
throw new TypeError(`${
|
|
16113
|
+
const file2 = `${type === "user" ? configPath : defaultConfigPath}/${name}.json`;
|
|
16114
|
+
if (!fs5.existsSync(file2)) {
|
|
16115
|
+
throw new TypeError(`${file2} \u6587\u4EF6\u4E0D\u5B58\u5728`);
|
|
16012
16116
|
}
|
|
16013
|
-
return requireFileSync(
|
|
16117
|
+
return requireFileSync(file2, { force: isRefresh });
|
|
16014
16118
|
};
|
|
16015
16119
|
setYaml = (name, data) => {
|
|
16016
16120
|
if (name === "env") return setEnv(data);
|
|
16017
|
-
const
|
|
16018
|
-
if (!fs5.existsSync(
|
|
16019
|
-
fs5.writeFileSync(
|
|
16121
|
+
const file2 = `${configPath}/${name}.json`;
|
|
16122
|
+
if (!fs5.existsSync(file2)) return false;
|
|
16123
|
+
fs5.writeFileSync(file2, JSON.stringify(data, null, 2));
|
|
16020
16124
|
return true;
|
|
16021
16125
|
};
|
|
16022
16126
|
setConfig = (name, data) => {
|
|
@@ -16024,8 +16128,8 @@ var init_admin = __esm({
|
|
|
16024
16128
|
};
|
|
16025
16129
|
clearFiles = (dir2) => {
|
|
16026
16130
|
const list2 = fs5.readdirSync(dir2);
|
|
16027
|
-
list2.forEach((
|
|
16028
|
-
fs5.promises.rm(
|
|
16131
|
+
list2.forEach((file2) => {
|
|
16132
|
+
fs5.promises.rm(file2, { recursive: true, force: true });
|
|
16029
16133
|
});
|
|
16030
16134
|
};
|
|
16031
16135
|
updateLevel = (level) => {
|
|
@@ -16373,7 +16477,7 @@ var init_common = __esm({
|
|
|
16373
16477
|
fs5.mkdirSync(rootTemp, { recursive: true });
|
|
16374
16478
|
const files = getAbsPath(images, rootTemp);
|
|
16375
16479
|
const filterComplex = await buildFilterComplex(files, perRow);
|
|
16376
|
-
const inputImages = files.map((
|
|
16480
|
+
const inputImages = files.map((file2) => `-i "${file2}"`).join(" ");
|
|
16377
16481
|
const output = path4.join(rootTemp, "output.png");
|
|
16378
16482
|
const ffmpegCmd = `${inputImages} -filter_complex "${filterComplex}" -map "[out]" ${output}`;
|
|
16379
16483
|
const result = await ffmpeg(ffmpegCmd);
|
|
@@ -16393,20 +16497,20 @@ var init_common = __esm({
|
|
|
16393
16497
|
if (image2.startsWith("base64://")) {
|
|
16394
16498
|
const base642 = image2.replace(/^base64:\/\//, "");
|
|
16395
16499
|
const buffer2 = Buffer.from(base642, "base64");
|
|
16396
|
-
const
|
|
16397
|
-
fs5.writeFileSync(
|
|
16398
|
-
files.push(
|
|
16500
|
+
const file3 = path4.join(root2, `${index6}.png`);
|
|
16501
|
+
fs5.writeFileSync(file3, buffer2);
|
|
16502
|
+
files.push(file3);
|
|
16399
16503
|
return;
|
|
16400
16504
|
}
|
|
16401
16505
|
if (!fs5.existsSync(image2)) throw Error(`\u56FE\u7247\u8DEF\u5F84\u4E0D\u5B58\u5728: ${image2}`);
|
|
16402
|
-
const
|
|
16403
|
-
fs5.copyFileSync(image2,
|
|
16404
|
-
files.push(
|
|
16506
|
+
const file2 = path4.join(root2, path4.basename(image2));
|
|
16507
|
+
fs5.copyFileSync(image2, file2);
|
|
16508
|
+
files.push(file2);
|
|
16405
16509
|
});
|
|
16406
16510
|
return files;
|
|
16407
16511
|
};
|
|
16408
|
-
getImageSize = async (
|
|
16409
|
-
const { stdout } = await ffprobe(`-v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "${
|
|
16512
|
+
getImageSize = async (file2) => {
|
|
16513
|
+
const { stdout } = await ffprobe(`-v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "${file2}"`);
|
|
16410
16514
|
const [width, height] = stdout.trim().split(",").map(Number);
|
|
16411
16515
|
return { width, height };
|
|
16412
16516
|
};
|
|
@@ -16420,9 +16524,9 @@ var init_common = __esm({
|
|
|
16420
16524
|
};
|
|
16421
16525
|
buildFilterComplex = async (files, perRow) => {
|
|
16422
16526
|
const list2 = await Promise.all(
|
|
16423
|
-
files.map(async (
|
|
16424
|
-
const { width, height } = await getImageSize(
|
|
16425
|
-
return { file, width, height };
|
|
16527
|
+
files.map(async (file2) => {
|
|
16528
|
+
const { width, height } = await getImageSize(file2);
|
|
16529
|
+
return { file: file2, width, height };
|
|
16426
16530
|
})
|
|
16427
16531
|
);
|
|
16428
16532
|
const maxWidth = Math.max(...list2.map((d) => d.width));
|
|
@@ -16657,10 +16761,10 @@ var init_adapter = __esm({
|
|
|
16657
16761
|
};
|
|
16658
16762
|
initAdapter = (dir2) => {
|
|
16659
16763
|
const name = "adapter.json";
|
|
16660
|
-
const
|
|
16661
|
-
const data = requireFileSync(
|
|
16764
|
+
const file2 = `${dir2}/${name}`;
|
|
16765
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16662
16766
|
cache6 = format(data);
|
|
16663
|
-
watch(
|
|
16767
|
+
watch(file2, (old, data2) => {
|
|
16664
16768
|
cache6 = format(data2);
|
|
16665
16769
|
const options = { file: name, old, data: cache6 };
|
|
16666
16770
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16700,10 +16804,10 @@ var init_config2 = __esm({
|
|
|
16700
16804
|
init_listeners();
|
|
16701
16805
|
initConfig = (dir2) => {
|
|
16702
16806
|
const name = "config.json";
|
|
16703
|
-
const
|
|
16704
|
-
const data = requireFileSync(
|
|
16807
|
+
const file2 = `${dir2}/${name}`;
|
|
16808
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16705
16809
|
cache7 = formatObject(data);
|
|
16706
|
-
watch(
|
|
16810
|
+
watch(file2, (old, data2) => {
|
|
16707
16811
|
cache7 = formatObject(data2);
|
|
16708
16812
|
const options = { file: name, old, data: cache7 };
|
|
16709
16813
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16732,12 +16836,12 @@ var init_groups4 = __esm({
|
|
|
16732
16836
|
if (Array.isArray(obj)) return false;
|
|
16733
16837
|
return Object.keys(obj).every((key) => typeof obj[key] === "object");
|
|
16734
16838
|
};
|
|
16735
|
-
migrate = (
|
|
16839
|
+
migrate = (file2, data) => {
|
|
16736
16840
|
const list2 = [];
|
|
16737
16841
|
Object.entries(data).forEach(([key, value]) => {
|
|
16738
16842
|
list2.push({ key, ...value });
|
|
16739
16843
|
});
|
|
16740
|
-
fs5.writeFileSync(
|
|
16844
|
+
fs5.writeFileSync(file2, JSON.stringify(list2, null, 2));
|
|
16741
16845
|
logger.mark("[migrate] \u8FC1\u79FB groups.json \u914D\u7F6E\u6587\u4EF6\u6210\u529F");
|
|
16742
16846
|
return format2(list2);
|
|
16743
16847
|
};
|
|
@@ -16788,12 +16892,12 @@ var init_groups4 = __esm({
|
|
|
16788
16892
|
};
|
|
16789
16893
|
initGroups = async (dir2) => {
|
|
16790
16894
|
const name = "groups.json";
|
|
16791
|
-
const
|
|
16792
|
-
const data = requireFileSync(
|
|
16793
|
-
staticCache = isOld(data) ? migrate(
|
|
16895
|
+
const file2 = `${dir2}/${name}`;
|
|
16896
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16897
|
+
staticCache = isOld(data) ? migrate(file2, data) : format2(data);
|
|
16794
16898
|
dynamicCache = format2(data);
|
|
16795
|
-
watch(
|
|
16796
|
-
staticCache = isOld(data2) ? migrate(
|
|
16899
|
+
watch(file2, async (old, data2) => {
|
|
16900
|
+
staticCache = isOld(data2) ? migrate(file2, data2) : format2(data2);
|
|
16797
16901
|
dynamicCache = staticCache;
|
|
16798
16902
|
const options = { file: name, old, data: dynamicCache };
|
|
16799
16903
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16830,9 +16934,9 @@ var init_groups4 = __esm({
|
|
|
16830
16934
|
};
|
|
16831
16935
|
getGroupsFileData = (dir2) => {
|
|
16832
16936
|
const name = "groups.json";
|
|
16833
|
-
const
|
|
16834
|
-
const data = requireFileSync(
|
|
16835
|
-
return isOld(data) ? migrate(
|
|
16937
|
+
const file2 = `${dir2}/${name}`;
|
|
16938
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16939
|
+
return isOld(data) ? migrate(file2, data) : format2(data);
|
|
16836
16940
|
};
|
|
16837
16941
|
groups_default = initGroups;
|
|
16838
16942
|
}
|
|
@@ -16853,12 +16957,12 @@ var init_privates = __esm({
|
|
|
16853
16957
|
if (Array.isArray(obj)) return false;
|
|
16854
16958
|
return Object.keys(obj).every((key) => typeof obj[key] === "object");
|
|
16855
16959
|
};
|
|
16856
|
-
migrate2 = (
|
|
16960
|
+
migrate2 = (file2, data) => {
|
|
16857
16961
|
const list2 = [];
|
|
16858
16962
|
Object.entries(data).forEach(([key, value]) => {
|
|
16859
16963
|
list2.push({ key, ...value });
|
|
16860
16964
|
});
|
|
16861
|
-
fs5.writeFileSync(
|
|
16965
|
+
fs5.writeFileSync(file2, JSON.stringify(list2, null, 2));
|
|
16862
16966
|
logger.mark("[migrate] \u8FC1\u79FB privates.json \u914D\u7F6E\u6587\u4EF6\u6210\u529F");
|
|
16863
16967
|
return format3(list2);
|
|
16864
16968
|
};
|
|
@@ -16902,12 +17006,12 @@ var init_privates = __esm({
|
|
|
16902
17006
|
};
|
|
16903
17007
|
initPrivates = async (dir2) => {
|
|
16904
17008
|
const name = "privates.json";
|
|
16905
|
-
const
|
|
16906
|
-
const data = requireFileSync(
|
|
16907
|
-
staticCache2 = isOld2(data) ? migrate2(
|
|
17009
|
+
const file2 = `${dir2}/${name}`;
|
|
17010
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
17011
|
+
staticCache2 = isOld2(data) ? migrate2(file2, data) : format3(data);
|
|
16908
17012
|
dynamicCache2 = format3(data);
|
|
16909
|
-
watch(
|
|
16910
|
-
staticCache2 = isOld2(data2) ? migrate2(
|
|
17013
|
+
watch(file2, async (old, data2) => {
|
|
17014
|
+
staticCache2 = isOld2(data2) ? migrate2(file2, data2) : format3(data2);
|
|
16911
17015
|
dynamicCache2 = staticCache2;
|
|
16912
17016
|
const options = { file: name, old, data: dynamicCache2 };
|
|
16913
17017
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16926,9 +17030,9 @@ var init_privates = __esm({
|
|
|
16926
17030
|
};
|
|
16927
17031
|
getPrivatesFileData = (dir2) => {
|
|
16928
17032
|
const name = "privates.json";
|
|
16929
|
-
const
|
|
16930
|
-
const data = requireFileSync(
|
|
16931
|
-
return isOld2(data) ? migrate2(
|
|
17033
|
+
const file2 = `${dir2}/${name}`;
|
|
17034
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
17035
|
+
return isOld2(data) ? migrate2(file2, data) : format3(data);
|
|
16932
17036
|
};
|
|
16933
17037
|
privates_default = initPrivates;
|
|
16934
17038
|
}
|
|
@@ -17045,8 +17149,8 @@ var init_template = __esm({
|
|
|
17045
17149
|
if (options.file.startsWith("http")) {
|
|
17046
17150
|
throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
|
|
17047
17151
|
}
|
|
17048
|
-
const
|
|
17049
|
-
const tplData = fs5.readFileSync(
|
|
17152
|
+
const file2 = path4.resolve(options.file);
|
|
17153
|
+
const tplData = fs5.readFileSync(file2, "utf-8");
|
|
17050
17154
|
const renderData = template.render(tplData, options.data);
|
|
17051
17155
|
const outputPath = getOutputPath(options.file, renderData, options.name);
|
|
17052
17156
|
fs5.writeFileSync(outputPath, renderData);
|
|
@@ -17075,8 +17179,8 @@ var init_template = __esm({
|
|
|
17075
17179
|
if (options.file.startsWith("http")) {
|
|
17076
17180
|
throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
|
|
17077
17181
|
}
|
|
17078
|
-
const
|
|
17079
|
-
const tplData = fs5.readFileSync(
|
|
17182
|
+
const file2 = path4.resolve(options.file);
|
|
17183
|
+
const tplData = fs5.readFileSync(file2, "utf-8");
|
|
17080
17184
|
const renderData = template.render(tplData, options.data);
|
|
17081
17185
|
const outputPath = getOutputPath(options.file, renderData, options.file_name);
|
|
17082
17186
|
fs5.writeFileSync(outputPath, renderData);
|
|
@@ -17090,9 +17194,9 @@ var init_template = __esm({
|
|
|
17090
17194
|
delete options.data;
|
|
17091
17195
|
return options;
|
|
17092
17196
|
};
|
|
17093
|
-
getOutputPath = (
|
|
17094
|
-
const extname = path4.extname(
|
|
17095
|
-
const basename = path4.basename(
|
|
17197
|
+
getOutputPath = (file2, data, name) => {
|
|
17198
|
+
const extname = path4.extname(file2);
|
|
17199
|
+
const basename = path4.basename(file2, extname);
|
|
17096
17200
|
const fileDir = path4.join(htmlPath, name || "render");
|
|
17097
17201
|
mkdirSync(fileDir);
|
|
17098
17202
|
const contentHash = crypto.createHash("md5").update(data).digest("hex").substring(0, 8);
|
|
@@ -17115,16 +17219,16 @@ var init_template = __esm({
|
|
|
17115
17219
|
const files = await getAllFiles(htmlPath, { suffixs: [".html"], returnType: "abs" });
|
|
17116
17220
|
if (files.length === 0) return;
|
|
17117
17221
|
const EXPIRE_TIME = 10 * 60 * 1e3;
|
|
17118
|
-
for (const
|
|
17222
|
+
for (const file2 of files) {
|
|
17119
17223
|
try {
|
|
17120
|
-
const stats = await fs5.promises.stat(
|
|
17224
|
+
const stats = await fs5.promises.stat(file2);
|
|
17121
17225
|
const lastModified = stats.mtimeMs;
|
|
17122
17226
|
if (now - lastModified > EXPIRE_TIME) {
|
|
17123
|
-
await fs5.promises.unlink(
|
|
17227
|
+
await fs5.promises.unlink(file2);
|
|
17124
17228
|
count3++;
|
|
17125
17229
|
}
|
|
17126
17230
|
} catch (err) {
|
|
17127
|
-
logger.error(`[\u6587\u4EF6\u6E05\u7406] \u5904\u7406\u6587\u4EF6\u65F6\u51FA\u9519: ${
|
|
17231
|
+
logger.error(`[\u6587\u4EF6\u6E05\u7406] \u5904\u7406\u6587\u4EF6\u65F6\u51FA\u9519: ${file2}, ${err}`);
|
|
17128
17232
|
}
|
|
17129
17233
|
}
|
|
17130
17234
|
logger.mark(`[\u6587\u4EF6\u6E05\u7406] \u6E05\u7406HTML\u5B8C\u6210: ${count3}/${files.length}`);
|
|
@@ -17192,10 +17296,10 @@ var init_cache3 = __esm({
|
|
|
17192
17296
|
}
|
|
17193
17297
|
});
|
|
17194
17298
|
};
|
|
17195
|
-
renderMultiHtml = (
|
|
17299
|
+
renderMultiHtml = (file2, multiPage) => {
|
|
17196
17300
|
if (!multiPage && multiPage !== 0) multiPage = true;
|
|
17197
17301
|
return callRender({
|
|
17198
|
-
file,
|
|
17302
|
+
file: file2,
|
|
17199
17303
|
name: "render",
|
|
17200
17304
|
encoding: "base64",
|
|
17201
17305
|
multiPage,
|
|
@@ -17342,10 +17446,10 @@ var init_client2 = __esm({
|
|
|
17342
17446
|
return logger.error(`${PREFIX}\u6536\u5230\u672A\u77E5\u6D88\u606F: ${raw2}`);
|
|
17343
17447
|
}
|
|
17344
17448
|
if (options.action === "uploadFile") {
|
|
17345
|
-
const
|
|
17449
|
+
const file2 = fileURLToPath$1(options.params.path);
|
|
17346
17450
|
logger.debug(`${PREFIX}\u6536\u5230\u4E0A\u4F20\u6587\u4EF6\u8BF7\u6C42: ${options.params.path}`);
|
|
17347
|
-
if (!isPublic(
|
|
17348
|
-
logger.error(`${PREFIX}\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25: \u975E\u6CD5\u7684\u8DEF\u5F84\uFF0C${
|
|
17451
|
+
if (!isPublic(file2)) {
|
|
17452
|
+
logger.error(`${PREFIX}\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25: \u975E\u6CD5\u7684\u8DEF\u5F84\uFF0C${file2} \u6CA1\u6709\u5904\u4E8E\u5141\u8BB8\u9759\u6001\u8D44\u6E90\u76EE\u5F55\u4E0B`);
|
|
17349
17453
|
client.send(JSON.stringify({
|
|
17350
17454
|
type: "response",
|
|
17351
17455
|
action: "uploadFile",
|
|
@@ -17363,7 +17467,7 @@ var init_client2 = __esm({
|
|
|
17363
17467
|
target.toString(),
|
|
17364
17468
|
{
|
|
17365
17469
|
echo: options.echo,
|
|
17366
|
-
file: `base64://${fs5.readFileSync(
|
|
17470
|
+
file: `base64://${fs5.readFileSync(file2, "base64")}`
|
|
17367
17471
|
},
|
|
17368
17472
|
{
|
|
17369
17473
|
headers: {
|
|
@@ -17599,10 +17703,10 @@ var init_render = __esm({
|
|
|
17599
17703
|
};
|
|
17600
17704
|
initRender = (dir2) => {
|
|
17601
17705
|
const name = "render.json";
|
|
17602
|
-
const
|
|
17603
|
-
const data = requireFileSync(
|
|
17706
|
+
const file2 = `${dir2}/${name}`;
|
|
17707
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
17604
17708
|
cache9 = format4(data);
|
|
17605
|
-
watch(
|
|
17709
|
+
watch(file2, async (old, data2) => {
|
|
17606
17710
|
cache9 = format4(data2);
|
|
17607
17711
|
const wsClient = diffArray(
|
|
17608
17712
|
Array.isArray(old?.ws_client) ? old?.ws_client : [],
|
|
@@ -17794,35 +17898,35 @@ var init_check = __esm({
|
|
|
17794
17898
|
headers: { Authorization: `Bearer ${process.env.HTTP_AUTH_KEY}` },
|
|
17795
17899
|
validateStatus: () => true
|
|
17796
17900
|
});
|
|
17797
|
-
request = async (url,
|
|
17901
|
+
request = async (url, path37, method, timeout2, isPrint = true) => {
|
|
17798
17902
|
const client = createHttpClient(url, timeout2);
|
|
17799
17903
|
try {
|
|
17800
|
-
const result = await client[method](
|
|
17801
|
-
return handleResponse(result, method,
|
|
17904
|
+
const result = await client[method](path37);
|
|
17905
|
+
return handleResponse(result, method, path37, isPrint);
|
|
17802
17906
|
} catch (error) {
|
|
17803
17907
|
logger.debug(
|
|
17804
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${
|
|
17908
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${path37} - ${error?.message || "\u672A\u77E5\u9519\u8BEF"}`
|
|
17805
17909
|
);
|
|
17806
17910
|
return { code: 500, success: false };
|
|
17807
17911
|
}
|
|
17808
17912
|
};
|
|
17809
|
-
handleResponse = (result, method,
|
|
17913
|
+
handleResponse = (result, method, path37, isPrint) => {
|
|
17810
17914
|
if (result.status === 200) {
|
|
17811
17915
|
isPrint && logger.info(
|
|
17812
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${
|
|
17916
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${path37} -> ${JSON.stringify(result.data)}`
|
|
17813
17917
|
);
|
|
17814
17918
|
return { code: result.status, success: true, data: result.data };
|
|
17815
17919
|
}
|
|
17816
17920
|
if (result.status === 401) {
|
|
17817
17921
|
logger.error(
|
|
17818
|
-
tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${
|
|
17922
|
+
tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${path37} -> ${JSON.stringify(result.data)}`
|
|
17819
17923
|
);
|
|
17820
17924
|
return { code: result.status, success: false };
|
|
17821
17925
|
}
|
|
17822
|
-
const logMethod =
|
|
17926
|
+
const logMethod = path37 === "/ping" ? logger.debug : logger.error;
|
|
17823
17927
|
logMethod.call(
|
|
17824
17928
|
logger,
|
|
17825
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${
|
|
17929
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${path37} -> ${JSON.stringify(result.data)}`
|
|
17826
17930
|
);
|
|
17827
17931
|
return { code: result.status, success: false };
|
|
17828
17932
|
};
|
|
@@ -19314,7 +19418,7 @@ var init_load = __esm({
|
|
|
19314
19418
|
init_internal();
|
|
19315
19419
|
init_list();
|
|
19316
19420
|
seq = 0;
|
|
19317
|
-
pkgLoads = async (pkg2, allPromises
|
|
19421
|
+
pkgLoads = async (pkg2, allPromises) => {
|
|
19318
19422
|
pkg2.id = ++seq;
|
|
19319
19423
|
cache3.index[pkg2.id] = pkg2;
|
|
19320
19424
|
const files = [];
|
|
@@ -19324,7 +19428,17 @@ var init_load = __esm({
|
|
|
19324
19428
|
files.push(...pkg2.pkgData.karin.files);
|
|
19325
19429
|
}
|
|
19326
19430
|
await createPluginDir(pkg2.name, files);
|
|
19327
|
-
|
|
19431
|
+
if (pkg2.type !== "app") {
|
|
19432
|
+
const main3 = pkg2.type === "npm" || !isTs() ? await loadMainFile(pkg2, pkg2.pkgData?.main) : await loadMainFile(pkg2, pkg2.pkgData?.karin?.main);
|
|
19433
|
+
if (main3 && main3.KARIN_PLUGIN_INIT) {
|
|
19434
|
+
try {
|
|
19435
|
+
await main3.KARIN_PLUGIN_INIT();
|
|
19436
|
+
logger.debug(`[load][${pkg2.name}] \u63D2\u4EF6\u6267\u884CKARIN_PLUGIN_INIT\u51FD\u6570\u6210\u529F`);
|
|
19437
|
+
} catch (error) {
|
|
19438
|
+
logger.error(new Error(`[load][${pkg2.name}] \u63D2\u4EF6\u6267\u884CKARIN_PLUGIN_INIT\u51FD\u6570\u5931\u8D25`, { cause: error }));
|
|
19439
|
+
}
|
|
19440
|
+
}
|
|
19441
|
+
}
|
|
19328
19442
|
pkg2.apps.forEach((app4) => {
|
|
19329
19443
|
const promise = async () => {
|
|
19330
19444
|
const result = await pkgLoadModule(pkg2.name, app4);
|
|
@@ -19332,33 +19446,27 @@ var init_load = __esm({
|
|
|
19332
19446
|
};
|
|
19333
19447
|
allPromises.push(promise());
|
|
19334
19448
|
});
|
|
19335
|
-
if (pkg2.type !== "app") {
|
|
19336
|
-
if (pkg2.type === "npm" || !isTs()) {
|
|
19337
|
-
loadMainFile(entryPromises, pkg2, pkg2.pkgData?.main);
|
|
19338
|
-
} else {
|
|
19339
|
-
loadMainFile(entryPromises, pkg2, pkg2.pkgData?.karin?.main);
|
|
19340
|
-
}
|
|
19341
|
-
}
|
|
19342
19449
|
if (pkg2.type !== "app" && pkg2?.pkgData?.karin?.static) {
|
|
19343
19450
|
const list2 = Array.isArray(pkg2.pkgData.karin.static) ? pkg2.pkgData.karin.static : [pkg2.pkgData.karin.static];
|
|
19344
|
-
cache3.static.push(...list2.map((
|
|
19451
|
+
cache3.static.push(...list2.map((file2) => path4.resolve(pkg2.dir, file2)));
|
|
19345
19452
|
} else {
|
|
19346
19453
|
cache3.static.push(path4.resolve(pkg2.dir, "resource"));
|
|
19347
19454
|
cache3.static.push(path4.resolve(pkg2.dir, "resources"));
|
|
19348
19455
|
}
|
|
19349
19456
|
};
|
|
19350
|
-
loadMainFile = async (
|
|
19457
|
+
loadMainFile = async (pkg2, dir2) => {
|
|
19351
19458
|
if (!dir2) return;
|
|
19352
|
-
const
|
|
19353
|
-
if (fs5.existsSync(
|
|
19354
|
-
|
|
19459
|
+
const file2 = path4.join(pkg2.dir, dir2);
|
|
19460
|
+
if (fs5.existsSync(file2)) {
|
|
19461
|
+
return pkgLoadModule(pkg2.name, file2);
|
|
19355
19462
|
}
|
|
19463
|
+
return null;
|
|
19356
19464
|
};
|
|
19357
|
-
pkgLoadModule = async (name,
|
|
19358
|
-
const { status, data } = await importModule(
|
|
19465
|
+
pkgLoadModule = async (name, file2, isRefresh = false) => {
|
|
19466
|
+
const { status, data } = await importModule(file2, isRefresh);
|
|
19359
19467
|
if (status) return data;
|
|
19360
|
-
logger.debug(new Error(`\u52A0\u8F7D\u6A21\u5757\u5931\u8D25: ${name} ${
|
|
19361
|
-
errorHandler.loaderPlugin(name,
|
|
19468
|
+
logger.debug(new Error(`\u52A0\u8F7D\u6A21\u5757\u5931\u8D25: ${name} ${file2}`, { cause: data }));
|
|
19469
|
+
errorHandler.loaderPlugin(name, file2, data);
|
|
19362
19470
|
return {};
|
|
19363
19471
|
};
|
|
19364
19472
|
isType = (val, type) => {
|
|
@@ -19465,15 +19573,15 @@ var init_load = __esm({
|
|
|
19465
19573
|
});
|
|
19466
19574
|
});
|
|
19467
19575
|
};
|
|
19468
|
-
findPkgByFile = (
|
|
19469
|
-
|
|
19576
|
+
findPkgByFile = (file2) => {
|
|
19577
|
+
file2 = formatPath(file2);
|
|
19470
19578
|
return Object.values(cache3.index).find(
|
|
19471
|
-
(pkg2) => pkg2.apps.includes(
|
|
19579
|
+
(pkg2) => pkg2.apps.includes(file2) || pkg2.allApps.some((dir2) => file2.startsWith(dir2)) || /**
|
|
19472
19580
|
* 第三种情况
|
|
19473
19581
|
* - 例如karin-plugin-example文件夹为空 则需要判断pkg是否为app类型
|
|
19474
19582
|
* - 并且文件是否处于karin-plugin-example文件夹下
|
|
19475
19583
|
*/
|
|
19476
|
-
pkg2.type === "app" && path4.normalize(
|
|
19584
|
+
pkg2.type === "app" && path4.normalize(file2).startsWith(path4.normalize(pkg2.dir))
|
|
19477
19585
|
) || null;
|
|
19478
19586
|
};
|
|
19479
19587
|
pkgSort = () => {
|
|
@@ -19487,15 +19595,13 @@ var init_load = __esm({
|
|
|
19487
19595
|
};
|
|
19488
19596
|
pkgHotReload = async (type, name) => {
|
|
19489
19597
|
const allPromises = [];
|
|
19490
|
-
const entryPromises = [];
|
|
19491
19598
|
const pkg2 = await getPluginsInfo([`${type}:${name}`], true, true);
|
|
19492
19599
|
if (pkg2.length === 0) {
|
|
19493
19600
|
throw new Error(`[load][${type}:${name}] \u63D2\u4EF6\u4E0D\u5B58\u5728`);
|
|
19494
19601
|
}
|
|
19495
|
-
await pkgLoads(pkg2[0], allPromises
|
|
19496
|
-
await Promise.allSettled(
|
|
19602
|
+
await pkgLoads(pkg2[0], allPromises);
|
|
19603
|
+
await Promise.allSettled(allPromises);
|
|
19497
19604
|
allPromises.length = 0;
|
|
19498
|
-
entryPromises.length = 0;
|
|
19499
19605
|
pkgSort();
|
|
19500
19606
|
};
|
|
19501
19607
|
}
|
|
@@ -20547,19 +20653,19 @@ var init_console = __esm({
|
|
|
20547
20653
|
return createForbiddenResponse(res, "\u65E0\u6548\u7684 token");
|
|
20548
20654
|
}
|
|
20549
20655
|
}
|
|
20550
|
-
const
|
|
20656
|
+
const file2 = path4.join(consolePath, url);
|
|
20551
20657
|
try {
|
|
20552
|
-
if (!
|
|
20658
|
+
if (!file2.startsWith(consolePath)) {
|
|
20553
20659
|
return createForbiddenResponse(res, "\u975E\u6CD5\u8BF7\u6C42");
|
|
20554
20660
|
}
|
|
20555
|
-
const stats = await promises.stat(
|
|
20661
|
+
const stats = await promises.stat(file2);
|
|
20556
20662
|
if (stats.size > MAX_FILE_SIZE) {
|
|
20557
20663
|
return createPayloadTooLargeResponse(res, "\u6587\u4EF6\u8FC7\u5927");
|
|
20558
20664
|
}
|
|
20559
20665
|
} catch {
|
|
20560
20666
|
return createNotFoundResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
20561
20667
|
}
|
|
20562
|
-
const data = await promises.readFile(
|
|
20668
|
+
const data = await promises.readFile(file2);
|
|
20563
20669
|
res.setHeader("Content-Type", ALLOWED_TYPES[ext]);
|
|
20564
20670
|
res.setHeader("Content-Length", data.length);
|
|
20565
20671
|
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
@@ -20750,20 +20856,23 @@ var init_getLog = __esm({
|
|
|
20750
20856
|
activeConnections = 0;
|
|
20751
20857
|
getLogRouter = async (req, res) => {
|
|
20752
20858
|
const maxConnections = Number(process.env.LOG_API_MAX_CONNECTIONS) || 5;
|
|
20859
|
+
const MAX_CHUNK_SIZE = Number(process.env.LOG_API_MAX_CHUNK_SIZE) || 1024 * 1024;
|
|
20753
20860
|
if (activeConnections >= maxConnections) {
|
|
20754
20861
|
return createBadRequestResponse(res, "\u5F53\u524D\u8FDE\u63A5\u6570\u5DF2\u8FBE\u5230\u4E0A\u9650\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
20755
20862
|
}
|
|
20756
20863
|
activeConnections++;
|
|
20757
20864
|
const date = moment();
|
|
20758
20865
|
if (!date.isValid()) {
|
|
20866
|
+
activeConnections--;
|
|
20759
20867
|
return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
|
|
20760
20868
|
}
|
|
20761
|
-
const
|
|
20869
|
+
const file2 = path4.join(logsPath, `logger.${date.format("YYYY-MM-DD")}.log`);
|
|
20762
20870
|
res.setHeader("Content-Type", "text/event-stream; charset=utf-8");
|
|
20763
20871
|
res.setHeader("Cache-Control", "no-cache");
|
|
20764
20872
|
res.setHeader("Connection", "keep-alive");
|
|
20765
20873
|
res.setHeader("X-Accel-Buffering", "no");
|
|
20766
20874
|
let position = 0;
|
|
20875
|
+
let isStreaming = false;
|
|
20767
20876
|
const isEventSource = req.headers.accept === "text/event-stream";
|
|
20768
20877
|
const heartbeat = setInterval(() => {
|
|
20769
20878
|
if (isEventSource) {
|
|
@@ -20771,7 +20880,8 @@ var init_getLog = __esm({
|
|
|
20771
20880
|
}
|
|
20772
20881
|
}, 3e4);
|
|
20773
20882
|
const tailFile = () => {
|
|
20774
|
-
|
|
20883
|
+
if (isStreaming) return;
|
|
20884
|
+
fs5.stat(file2, (err, stats) => {
|
|
20775
20885
|
if (err) {
|
|
20776
20886
|
logger.error("\u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u72B6\u6001\u9519\u8BEF:", err);
|
|
20777
20887
|
return;
|
|
@@ -20780,25 +20890,37 @@ var init_getLog = __esm({
|
|
|
20780
20890
|
position = 0;
|
|
20781
20891
|
}
|
|
20782
20892
|
if (position < stats.size) {
|
|
20783
|
-
|
|
20893
|
+
isStreaming = true;
|
|
20894
|
+
const endPosition = Math.min(position + MAX_CHUNK_SIZE, stats.size);
|
|
20895
|
+
const stream3 = fs5.createReadStream(file2, {
|
|
20896
|
+
start: position,
|
|
20897
|
+
end: endPosition - 1,
|
|
20898
|
+
encoding: "utf-8",
|
|
20899
|
+
highWaterMark: 64 * 1024
|
|
20900
|
+
// 设置较小的缓冲区,减少内存使用
|
|
20901
|
+
});
|
|
20784
20902
|
stream3.on("data", (data) => {
|
|
20785
20903
|
const lines = data.toString().split("\n");
|
|
20786
20904
|
for (const line of lines) {
|
|
20787
|
-
if (
|
|
20788
|
-
|
|
20905
|
+
if (line) {
|
|
20906
|
+
if (isEventSource) {
|
|
20907
|
+
res.write(`data: ${line}
|
|
20789
20908
|
|
|
20790
20909
|
`);
|
|
20791
|
-
|
|
20792
|
-
|
|
20910
|
+
} else {
|
|
20911
|
+
res.write(`${line}
|
|
20793
20912
|
`);
|
|
20913
|
+
}
|
|
20794
20914
|
}
|
|
20795
20915
|
}
|
|
20796
20916
|
});
|
|
20797
20917
|
stream3.on("end", () => {
|
|
20798
|
-
position =
|
|
20918
|
+
position = endPosition;
|
|
20919
|
+
isStreaming = false;
|
|
20799
20920
|
});
|
|
20800
20921
|
stream3.on("error", (error) => {
|
|
20801
20922
|
logger.error("\u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u9519\u8BEF:", error.message);
|
|
20923
|
+
isStreaming = false;
|
|
20802
20924
|
});
|
|
20803
20925
|
}
|
|
20804
20926
|
});
|
|
@@ -20810,21 +20932,31 @@ var init_getLog = __esm({
|
|
|
20810
20932
|
clearInterval(heartbeat);
|
|
20811
20933
|
activeConnections--;
|
|
20812
20934
|
});
|
|
20935
|
+
req.on("error", () => {
|
|
20936
|
+
clearInterval(interval);
|
|
20937
|
+
clearInterval(heartbeat);
|
|
20938
|
+
activeConnections--;
|
|
20939
|
+
});
|
|
20813
20940
|
};
|
|
20814
20941
|
getLogFileListRouter = async (_, res) => {
|
|
20815
20942
|
const files = fs5.readdirSync(logsPath);
|
|
20816
|
-
const logFiles = files.filter((
|
|
20943
|
+
const logFiles = files.filter((file2) => file2.startsWith("logger.") && file2.endsWith(".log")).map((file2) => file2.replace("logger.", "").replace(".log", ""));
|
|
20817
20944
|
createSuccessResponse(res, logFiles, "\u6210\u529F");
|
|
20818
20945
|
};
|
|
20819
20946
|
getLogFileRouter = async (req, res) => {
|
|
20820
|
-
const
|
|
20821
|
-
if (!isStandardDate(
|
|
20947
|
+
const file2 = req.query.file;
|
|
20948
|
+
if (!isStandardDate(file2)) {
|
|
20822
20949
|
return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
|
|
20823
20950
|
}
|
|
20824
|
-
const filePath = path4.join(logsPath, `logger.${
|
|
20951
|
+
const filePath = path4.join(logsPath, `logger.${file2}.log`);
|
|
20825
20952
|
if (!fs5.existsSync(filePath)) {
|
|
20826
20953
|
return createBadRequestResponse(res, "\u65E5\u5FD7\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
20827
20954
|
}
|
|
20955
|
+
const stats = fs5.statSync(filePath);
|
|
20956
|
+
const FILE_SIZE_LIMIT = Number(process.env.LOG_FILE_SIZE_LIMIT) || 10 * 1024 * 1024;
|
|
20957
|
+
if (stats.size > FILE_SIZE_LIMIT) {
|
|
20958
|
+
return createBadRequestResponse(res, "\u65E5\u5FD7\u6587\u4EF6\u8FC7\u5927\uFF0C\u8BF7\u4F7F\u7528\u6D41\u5F0F\u63A5\u53E3\u83B7\u53D6\u6216\u4E0B\u8F7D\u6587\u4EF6");
|
|
20959
|
+
}
|
|
20828
20960
|
const content = fs5.readFileSync(filePath, "utf-8");
|
|
20829
20961
|
createSuccessResponse(res, content, "\u6210\u529F");
|
|
20830
20962
|
};
|
|
@@ -22640,8 +22772,8 @@ var init_uninstall = __esm({
|
|
|
22640
22772
|
continue;
|
|
22641
22773
|
}
|
|
22642
22774
|
const arr = v.split("/");
|
|
22643
|
-
const [pkg2,
|
|
22644
|
-
if (arr.length !== 2 || !pkg2 || !
|
|
22775
|
+
const [pkg2, file2] = arr;
|
|
22776
|
+
if (arr.length !== 2 || !pkg2 || !file2) {
|
|
22645
22777
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u683C\u5F0F\u9519\u8BEF`);
|
|
22646
22778
|
continue;
|
|
22647
22779
|
}
|
|
@@ -22650,17 +22782,17 @@ var init_uninstall = __esm({
|
|
|
22650
22782
|
continue;
|
|
22651
22783
|
}
|
|
22652
22784
|
const dir2 = path4.join(karinPathPlugins, pkg2);
|
|
22653
|
-
if (!fs5.existsSync(path4.join(dir2,
|
|
22785
|
+
if (!fs5.existsSync(path4.join(dir2, file2))) {
|
|
22654
22786
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u6587\u4EF6\u4E0D\u5B58\u5728`);
|
|
22655
22787
|
continue;
|
|
22656
22788
|
}
|
|
22657
|
-
const ext = path4.extname(
|
|
22789
|
+
const ext = path4.extname(file2);
|
|
22658
22790
|
if (![".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"].includes(ext)) {
|
|
22659
22791
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u9519\u8BEF\u7684\u6587\u4EF6\u7C7B\u578B`);
|
|
22660
22792
|
continue;
|
|
22661
22793
|
}
|
|
22662
22794
|
try {
|
|
22663
|
-
await fs5.promises.unlink(path4.join(dir2,
|
|
22795
|
+
await fs5.promises.unlink(path4.join(dir2, file2));
|
|
22664
22796
|
emitLog(`\u5378\u8F7D ${v} \u6210\u529F`);
|
|
22665
22797
|
} catch (error) {
|
|
22666
22798
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: ${error.message}`);
|
|
@@ -22861,8 +22993,6 @@ var init_list2 = __esm({
|
|
|
22861
22993
|
getRegistry();
|
|
22862
22994
|
}
|
|
22863
22995
|
});
|
|
22864
|
-
|
|
22865
|
-
// src/server/dependencies/manage.ts
|
|
22866
22996
|
var manageDependenciesRouter, installDependencies, removeDependencies, addDependencies;
|
|
22867
22997
|
var init_manage2 = __esm({
|
|
22868
22998
|
"src/server/dependencies/manage.ts"() {
|
|
@@ -22896,12 +23026,14 @@ var init_manage2 = __esm({
|
|
|
22896
23026
|
const args = ["install", ...packagesToInstall.split(" ")];
|
|
22897
23027
|
if (isWorkspace()) args.push("-w");
|
|
22898
23028
|
await spawnProcess("pnpm", args, {}, emitLog);
|
|
23029
|
+
logger.mark(`\u5B89\u88C5\u4F9D\u8D56 ${logger.green(packagesToInstall)} \u5B8C\u6210`);
|
|
22899
23030
|
return true;
|
|
22900
23031
|
}
|
|
22901
23032
|
);
|
|
22902
23033
|
return handleReturn2(res, true, "\u5B89\u88C5\u4EFB\u52A1\u5DF2\u521B\u5EFA", id);
|
|
22903
23034
|
} catch (error) {
|
|
22904
23035
|
logger.error("[installDependencies]", error);
|
|
23036
|
+
logger.mark(`\u5B89\u88C5\u4F9D\u8D56 ${logger.red(dependencies.join(" "))} \u5931\u8D25`);
|
|
22905
23037
|
return handleReturn2(res, false, `\u5B89\u88C5\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
22906
23038
|
}
|
|
22907
23039
|
};
|
|
@@ -22919,12 +23051,14 @@ var init_manage2 = __esm({
|
|
|
22919
23051
|
const args = ["remove", ...packagesToRemove.split(" ")];
|
|
22920
23052
|
if (isWorkspace()) args.push("-w");
|
|
22921
23053
|
await spawnProcess("pnpm", args, {}, emitLog);
|
|
23054
|
+
logger.mark(`\u5220\u9664\u4F9D\u8D56 ${logger.yellow(packagesToRemove)} \u5B8C\u6210`);
|
|
22922
23055
|
return true;
|
|
22923
23056
|
}
|
|
22924
23057
|
);
|
|
22925
23058
|
return handleReturn2(res, true, "\u5220\u9664\u4EFB\u52A1\u5DF2\u521B\u5EFA", id);
|
|
22926
23059
|
} catch (error) {
|
|
22927
23060
|
logger.error("[removeDependencies]", error);
|
|
23061
|
+
logger.mark(`\u5220\u9664\u4F9D\u8D56 ${logger.red(dependencies.join(" "))} \u5931\u8D25`);
|
|
22928
23062
|
return handleReturn2(res, false, `\u5220\u9664\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
22929
23063
|
}
|
|
22930
23064
|
};
|
|
@@ -22953,12 +23087,23 @@ var init_manage2 = __esm({
|
|
|
22953
23087
|
}
|
|
22954
23088
|
if (isWorkspace()) args.push("-w");
|
|
22955
23089
|
await spawnProcess("pnpm", args, {}, emitLog);
|
|
23090
|
+
const depDir = path4.join(process.cwd(), "packages", dependencies.name, "package.json");
|
|
23091
|
+
try {
|
|
23092
|
+
const pkg2 = JSON.parse(fs5.readFileSync(depDir, "utf-8"));
|
|
23093
|
+
if (!pkg2.peerDependencies) return true;
|
|
23094
|
+
await spawnProcess("pnpm", ["install"], {}, emitLog);
|
|
23095
|
+
} catch (error) {
|
|
23096
|
+
logger.error("[addDependencies]", error);
|
|
23097
|
+
emitLog(util5.format(error));
|
|
23098
|
+
}
|
|
23099
|
+
logger.mark(`\u65B0\u589E\u4F9D\u8D56 ${logger.green(dependencies.name)} \u5B8C\u6210`);
|
|
22956
23100
|
return true;
|
|
22957
23101
|
}
|
|
22958
23102
|
);
|
|
22959
23103
|
return handleReturn2(res, true, "\u6DFB\u52A0\u4EFB\u52A1\u5DF2\u521B\u5EFA", id);
|
|
22960
23104
|
} catch (error) {
|
|
22961
23105
|
logger.error("[addDependencies]", error);
|
|
23106
|
+
logger.mark(`\u65B0\u589E\u4F9D\u8D56 ${logger.red(dependencies.name)} \u5931\u8D25`);
|
|
22962
23107
|
return handleReturn2(res, false, `\u6DFB\u52A0\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
22963
23108
|
}
|
|
22964
23109
|
};
|
|
@@ -23253,12 +23398,12 @@ var init_config5 = __esm({
|
|
|
23253
23398
|
};
|
|
23254
23399
|
getNpmrcContentRouter = async (req, res) => {
|
|
23255
23400
|
try {
|
|
23256
|
-
const { path:
|
|
23401
|
+
const { path: path37 } = req.body;
|
|
23257
23402
|
const list2 = await getNpmConfigList();
|
|
23258
|
-
if (!list2.find((item) => item.path ===
|
|
23403
|
+
if (!list2.find((item) => item.path === path37)) {
|
|
23259
23404
|
return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
23260
23405
|
}
|
|
23261
|
-
const content = ini.read(
|
|
23406
|
+
const content = ini.read(path37);
|
|
23262
23407
|
return createSuccessResponse(res, content);
|
|
23263
23408
|
} catch (error) {
|
|
23264
23409
|
logger.error("[getNpmrcContentRouter]", error);
|
|
@@ -23285,7 +23430,7 @@ var init_config5 = __esm({
|
|
|
23285
23430
|
};
|
|
23286
23431
|
saveNpmrcRouter = async (req, res) => {
|
|
23287
23432
|
try {
|
|
23288
|
-
const { path:
|
|
23433
|
+
const { path: path37, content, baseConfig } = req.body;
|
|
23289
23434
|
const list2 = await getNpmConfigList();
|
|
23290
23435
|
const promises = [];
|
|
23291
23436
|
if (baseConfig.registry) {
|
|
@@ -23298,11 +23443,11 @@ var init_config5 = __esm({
|
|
|
23298
23443
|
promises.push(setNpmConfig("https-proxy", baseConfig["https-proxy"]));
|
|
23299
23444
|
}
|
|
23300
23445
|
await Promise.all(promises);
|
|
23301
|
-
if (
|
|
23302
|
-
if (!list2.find((item) => item.path ===
|
|
23446
|
+
if (path37 && content) {
|
|
23447
|
+
if (!list2.find((item) => item.path === path37)) {
|
|
23303
23448
|
return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
23304
23449
|
}
|
|
23305
|
-
ini.write(content,
|
|
23450
|
+
ini.write(content, path37);
|
|
23306
23451
|
}
|
|
23307
23452
|
return createSuccessResponse(res, "\u4FDD\u5B58\u6210\u529F");
|
|
23308
23453
|
} catch (error) {
|
|
@@ -23382,10 +23527,10 @@ var init_list4 = __esm({
|
|
|
23382
23527
|
});
|
|
23383
23528
|
Object.keys(map).forEach((key) => {
|
|
23384
23529
|
const files = [];
|
|
23385
|
-
Object.keys(map[key]).forEach((
|
|
23530
|
+
Object.keys(map[key]).forEach((file2) => {
|
|
23386
23531
|
files.push({
|
|
23387
|
-
fileName:
|
|
23388
|
-
command: map[key][
|
|
23532
|
+
fileName: file2,
|
|
23533
|
+
command: map[key][file2]
|
|
23389
23534
|
});
|
|
23390
23535
|
});
|
|
23391
23536
|
list2.push({
|
|
@@ -23937,8 +24082,8 @@ var init_input = __esm({
|
|
|
23937
24082
|
async getUrl(data, ext) {
|
|
23938
24083
|
const cfg = adapter();
|
|
23939
24084
|
const name = (++index5).toString();
|
|
23940
|
-
const
|
|
23941
|
-
await fs5.promises.writeFile(
|
|
24085
|
+
const file2 = path4.join(consolePath, `${name}${ext}`);
|
|
24086
|
+
await fs5.promises.writeFile(file2, await buffer(data));
|
|
23942
24087
|
if (cfg.console.isLocal) {
|
|
23943
24088
|
return `http://127.0.0.1:${process.env.HTTP_PORT}/api/v1/console/${name}${ext}`;
|
|
23944
24089
|
}
|
|
@@ -24028,8 +24173,8 @@ var init_input = __esm({
|
|
|
24028
24173
|
logger.info(`[setMsgReaction] ${contact3} ${messageId} ${faceId} ${isSet}`);
|
|
24029
24174
|
return true;
|
|
24030
24175
|
}
|
|
24031
|
-
async uploadFile(contact3,
|
|
24032
|
-
logger.info(`[uploadFile] ${contact3} ${
|
|
24176
|
+
async uploadFile(contact3, file2, name, folder) {
|
|
24177
|
+
logger.info(`[uploadFile] ${contact3} ${file2} ${name} ${folder}`);
|
|
24033
24178
|
return true;
|
|
24034
24179
|
}
|
|
24035
24180
|
};
|
|
@@ -24111,9 +24256,9 @@ var init_db = __esm({
|
|
|
24111
24256
|
stream: void 0
|
|
24112
24257
|
}
|
|
24113
24258
|
};
|
|
24114
|
-
addWrite = (name,
|
|
24259
|
+
addWrite = (name, file2, key, value) => {
|
|
24115
24260
|
if (!stream2[name].stream) {
|
|
24116
|
-
stream2[name].stream = createWriteStream(
|
|
24261
|
+
stream2[name].stream = createWriteStream(file2, {
|
|
24117
24262
|
flags: "a+",
|
|
24118
24263
|
encoding: "utf-8"
|
|
24119
24264
|
});
|
|
@@ -24122,14 +24267,14 @@ var init_db = __esm({
|
|
|
24122
24267
|
stream2[name].stream.write(`${key}="${JSON.stringify(value)}
|
|
24123
24268
|
`);
|
|
24124
24269
|
};
|
|
24125
|
-
deleteData = async (
|
|
24270
|
+
deleteData = async (file2, key) => {
|
|
24126
24271
|
try {
|
|
24127
|
-
await promises.access(
|
|
24128
|
-
const content = await promises.readFile(
|
|
24272
|
+
await promises.access(file2);
|
|
24273
|
+
const content = await promises.readFile(file2, "utf-8");
|
|
24129
24274
|
if (!content) return;
|
|
24130
24275
|
const lines = content.split("\n").filter(Boolean);
|
|
24131
24276
|
const newLines = lines.filter((line) => !line.startsWith(`${key}=`));
|
|
24132
|
-
await promises.writeFile(
|
|
24277
|
+
await promises.writeFile(file2, newLines.join("\n") + "\n");
|
|
24133
24278
|
} catch {
|
|
24134
24279
|
}
|
|
24135
24280
|
};
|
|
@@ -24158,8 +24303,8 @@ var init_db = __esm({
|
|
|
24158
24303
|
}
|
|
24159
24304
|
};
|
|
24160
24305
|
main2 = async () => {
|
|
24161
|
-
Object.values(dir).forEach(async (
|
|
24162
|
-
if (
|
|
24306
|
+
Object.values(dir).forEach(async (file2) => {
|
|
24307
|
+
if (file2 === dir.account) {
|
|
24163
24308
|
try {
|
|
24164
24309
|
await promises.access(dir.account);
|
|
24165
24310
|
} catch {
|
|
@@ -24169,11 +24314,11 @@ var init_db = __esm({
|
|
|
24169
24314
|
return;
|
|
24170
24315
|
}
|
|
24171
24316
|
try {
|
|
24172
|
-
await promises.access(
|
|
24173
|
-
if (
|
|
24317
|
+
await promises.access(file2);
|
|
24318
|
+
if (file2 === dir.frinendList) writeAccountToFriendList();
|
|
24174
24319
|
} catch {
|
|
24175
|
-
await promises.mkdir(path4.dirname(
|
|
24176
|
-
await promises.writeFile(
|
|
24320
|
+
await promises.mkdir(path4.dirname(file2), { recursive: true });
|
|
24321
|
+
await promises.writeFile(file2, "");
|
|
24177
24322
|
}
|
|
24178
24323
|
});
|
|
24179
24324
|
setInterval(() => {
|
|
@@ -24269,8 +24414,8 @@ var env2 = () => {
|
|
|
24269
24414
|
comment: "\u65E5\u5FD7\u5B9E\u65F6Api\u6700\u591A\u652F\u6301\u540C\u65F6\u8FDE\u63A5\u6570"
|
|
24270
24415
|
}
|
|
24271
24416
|
];
|
|
24272
|
-
const
|
|
24273
|
-
if (!fs5.existsSync(
|
|
24417
|
+
const file2 = `${process.cwd()}/${process.env.EBV_FILE}`;
|
|
24418
|
+
if (!fs5.existsSync(file2)) {
|
|
24274
24419
|
logger.error(logger.yellow("\u68C0\u67E5\u5230\u9879\u76EE\u914D\u7F6E\u6587\u4EF6\u7F3A\u5931\uFF0C\u6B63\u5728\u521D\u59CB\u5316..."));
|
|
24275
24420
|
const cwd = fileURLToPath$1(new URL$1("./cli/index.mjs", import.meta.url));
|
|
24276
24421
|
execSync(`node ${cwd} init`, {
|
|
@@ -24279,10 +24424,10 @@ var env2 = () => {
|
|
|
24279
24424
|
});
|
|
24280
24425
|
logger.info(logger.green("\u521D\u59CB\u5316\u6210\u529F~"));
|
|
24281
24426
|
}
|
|
24282
|
-
const content = fs5.readFileSync(
|
|
24427
|
+
const content = fs5.readFileSync(file2, "utf-8");
|
|
24283
24428
|
list2.forEach((v) => {
|
|
24284
24429
|
if (!content.includes(v.key)) {
|
|
24285
|
-
fs5.appendFileSync(
|
|
24430
|
+
fs5.appendFileSync(file2, `
|
|
24286
24431
|
${v.comment}
|
|
24287
24432
|
${v.key}=${v.value}`);
|
|
24288
24433
|
process.env[v.key] = v.value;
|
|
@@ -24319,10 +24464,10 @@ var initConfig2 = async (dir2) => {
|
|
|
24319
24464
|
return Promise.resolve();
|
|
24320
24465
|
}));
|
|
24321
24466
|
await Promise.all(Object.keys(defaultConfig).map(async (key) => {
|
|
24322
|
-
const
|
|
24323
|
-
if (fs5.existsSync(
|
|
24467
|
+
const file2 = `${dir2.configPath}/${key}.json`;
|
|
24468
|
+
if (fs5.existsSync(file2)) return;
|
|
24324
24469
|
const data = JSON.stringify(defaultConfig[key], null, 2);
|
|
24325
|
-
await fs5.promises.writeFile(
|
|
24470
|
+
await fs5.promises.writeFile(file2, data, "utf-8");
|
|
24326
24471
|
return true;
|
|
24327
24472
|
}));
|
|
24328
24473
|
initConfigCache(dir2.configPath);
|
|
@@ -24335,6 +24480,7 @@ init_check();
|
|
|
24335
24480
|
init_exit();
|
|
24336
24481
|
init_listeners();
|
|
24337
24482
|
var processHandler = () => {
|
|
24483
|
+
process.title = `karin v${process.env.KARIN_VERSION} \xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} - Karinjs`;
|
|
24338
24484
|
process.once("SIGHUP", (code) => processExit(code));
|
|
24339
24485
|
process.once("SIGINT", (code) => processExit(code));
|
|
24340
24486
|
process.once("SIGTERM", (code) => processExit(code));
|
|
@@ -24368,19 +24514,19 @@ init_load();
|
|
|
24368
24514
|
// src/plugin/admin/uninstall.ts
|
|
24369
24515
|
init_cache();
|
|
24370
24516
|
init_path();
|
|
24371
|
-
var pkgRemoveModule = async (
|
|
24372
|
-
cache3.accept = cache3.accept.filter((p) => !isPathEqual(p.file.absPath,
|
|
24373
|
-
cache3.command = cache3.command.filter((p) => !isPathEqual(p.file.absPath,
|
|
24517
|
+
var pkgRemoveModule = async (file2) => {
|
|
24518
|
+
cache3.accept = cache3.accept.filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24519
|
+
cache3.command = cache3.command.filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24374
24520
|
cache3.task = cache3.task.filter((p) => {
|
|
24375
|
-
const isEqual = isPathEqual(p.file.absPath,
|
|
24521
|
+
const isEqual = isPathEqual(p.file.absPath, file2);
|
|
24376
24522
|
if (isEqual && p.schedule) {
|
|
24377
24523
|
p.schedule.cancel();
|
|
24378
24524
|
}
|
|
24379
24525
|
return !isEqual;
|
|
24380
24526
|
});
|
|
24381
|
-
cache3.button = cache3.button.filter((p) => !isPathEqual(p.file.absPath,
|
|
24527
|
+
cache3.button = cache3.button.filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24382
24528
|
Object.keys(cache3.handler).forEach((key) => {
|
|
24383
|
-
cache3.handler[key] = cache3.handler[key].filter((p) => !isPathEqual(p.file.absPath,
|
|
24529
|
+
cache3.handler[key] = cache3.handler[key].filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24384
24530
|
});
|
|
24385
24531
|
};
|
|
24386
24532
|
|
|
@@ -24405,7 +24551,7 @@ var initPluginHmr = async () => {
|
|
|
24405
24551
|
ignoreInitial: true,
|
|
24406
24552
|
ignored: /(^|[/\\])\../
|
|
24407
24553
|
});
|
|
24408
|
-
watcher.on("add", (
|
|
24554
|
+
watcher.on("add", (file2) => handleFileChange(file2, "add")).on("change", (file2) => handleFileChange(file2, "change")).on("unlink", (file2) => handleFileChange(file2, "unlink"));
|
|
24409
24555
|
const relativePaths = Array.from(watchDirs).map((dir2) => {
|
|
24410
24556
|
return path4.relative(process.cwd(), dir2).replace(/\\/g, "/");
|
|
24411
24557
|
});
|
|
@@ -24414,18 +24560,18 @@ var initPluginHmr = async () => {
|
|
|
24414
24560
|
[hmr] ${logger.magenta("\u6B63\u5728\u76D1\u542C\u6587\u4EF6\u5939")}:
|
|
24415
24561
|
${relativePaths.join("\n")}`);
|
|
24416
24562
|
};
|
|
24417
|
-
var handleFileChange = async (
|
|
24418
|
-
const ext = path4.extname(
|
|
24563
|
+
var handleFileChange = async (file2, action) => {
|
|
24564
|
+
const ext = path4.extname(file2);
|
|
24419
24565
|
const exts = getModuleType();
|
|
24420
24566
|
if (!exts.includes(ext)) return;
|
|
24421
|
-
const absPath2 = formatPath(
|
|
24567
|
+
const absPath2 = formatPath(file2);
|
|
24422
24568
|
const pkg2 = findPkgByFile(absPath2);
|
|
24423
24569
|
if (!pkg2) return;
|
|
24424
|
-
const relativePath = path4.relative(process.cwd(),
|
|
24570
|
+
const relativePath = path4.relative(process.cwd(), file2).replace(/\\/g, "/");
|
|
24425
24571
|
logger.debug(`[hmr][${pkg2.name}] \u6587\u4EF6${action}: ${relativePath}`);
|
|
24426
24572
|
if (action === "unlink") {
|
|
24427
24573
|
pkgRemoveModule(absPath2);
|
|
24428
|
-
logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path4.basename(
|
|
24574
|
+
logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path4.basename(file2)}`);
|
|
24429
24575
|
return;
|
|
24430
24576
|
}
|
|
24431
24577
|
if (action === "change") {
|
|
@@ -24436,7 +24582,7 @@ var handleFileChange = async (file, action) => {
|
|
|
24436
24582
|
pkgCache(result, pkg2, absPath2);
|
|
24437
24583
|
pkgSort();
|
|
24438
24584
|
const actionText = action === "add" ? "\u65B0\u589E\u63D2\u4EF6" : "\u91CD\u8F7D\u5B8C\u6210";
|
|
24439
|
-
logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path4.basename(
|
|
24585
|
+
logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path4.basename(file2)}`);
|
|
24440
24586
|
} catch (error) {
|
|
24441
24587
|
logger.error(`[hmr][${pkg2.name}] \u52A0\u8F7D\u5931\u8D25:`);
|
|
24442
24588
|
logger.error(error);
|
|
@@ -24450,12 +24596,10 @@ var initPlugins = async () => {
|
|
|
24450
24596
|
logger.info(logger.green("-----------"));
|
|
24451
24597
|
logger.info("\u52A0\u8F7D\u63D2\u4EF6\u4E2D...");
|
|
24452
24598
|
const allPromises = [];
|
|
24453
|
-
const entryPromises = [];
|
|
24454
24599
|
const list2 = await getPlugins("all", true, false, true);
|
|
24455
|
-
await Promise.all(list2.map(async (pkg2) => pkgLoads(pkg2, allPromises
|
|
24456
|
-
await Promise.allSettled(
|
|
24600
|
+
await Promise.all(list2.map(async (pkg2) => pkgLoads(pkg2, allPromises)));
|
|
24601
|
+
await Promise.allSettled(allPromises);
|
|
24457
24602
|
allPromises.length = 0;
|
|
24458
|
-
entryPromises.length = 0;
|
|
24459
24603
|
pkgSort();
|
|
24460
24604
|
errorHandler.printMissing();
|
|
24461
24605
|
logger.info("\u63D2\u4EF6\u52A0\u8F7D\u5B8C\u6210");
|