llonebot-dist 7.11.1 → 7.11.3
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/llbot.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import * as path$9 from "node:path";
|
|
3
3
|
import path, { dirname, resolve } from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import fs, { createReadStream, existsSync, statSync } from "fs";
|
|
4
|
+
import fs, { access, copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
|
|
5
|
+
import fs$1, { createReadStream, existsSync, statSync } from "fs";
|
|
6
6
|
import { Readable } from "stream";
|
|
7
7
|
import { Binary, Time, camelize, clone, deduplicate, deepEqual, defineProperty, difference, filterKeys, hyphenate, is, isNonNullable, isNullable, isPlainObject, makeArray, mapValues, noop, omit, pick, remove, valueMap } from "cosmokit";
|
|
8
8
|
import Logger from "reggol";
|
|
9
|
-
import * as fs$
|
|
10
|
-
import fs$
|
|
9
|
+
import * as fs$10 from "node:fs";
|
|
10
|
+
import fs$2, { appendFile, appendFileSync, createReadStream as createReadStream$1, existsSync as existsSync$1, mkdirSync, promises, stat as stat$1, watch } from "node:fs";
|
|
11
11
|
import os from "node:os";
|
|
12
12
|
import crypto$1, { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
13
13
|
import * as fileType from "file-type";
|
|
@@ -16,7 +16,7 @@ import { inspect, isDeepStrictEqual } from "node:util";
|
|
|
16
16
|
import path$1, { join } from "path";
|
|
17
17
|
import { networkInterfaces } from "os";
|
|
18
18
|
import { decode, encode, getDuration, getWavFileInfo, isSilk, isWav } from "silk-wasm";
|
|
19
|
-
import fsPromise
|
|
19
|
+
import fsPromise, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
|
|
20
20
|
import { deflateSync, gunzipSync, gzipSync, inflateSync } from "node:zlib";
|
|
21
21
|
import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
22
22
|
import { constants } from "node:buffer";
|
|
@@ -3964,7 +3964,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3964
3964
|
//#endregion
|
|
3965
3965
|
//#region node_modules/qrcode/lib/renderer/png.js
|
|
3966
3966
|
var require_png = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3967
|
-
var fs$
|
|
3967
|
+
var fs$11 = __require("fs");
|
|
3968
3968
|
var PNG = require_png$1().PNG;
|
|
3969
3969
|
var Utils = require_utils$1();
|
|
3970
3970
|
exports.render = function render(qrData, options) {
|
|
@@ -4016,7 +4016,7 @@ var require_png = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4016
4016
|
called = true;
|
|
4017
4017
|
cb.apply(null, args);
|
|
4018
4018
|
};
|
|
4019
|
-
const stream = fs$
|
|
4019
|
+
const stream = fs$11.createWriteStream(path);
|
|
4020
4020
|
stream.on("error", done);
|
|
4021
4021
|
stream.on("close", done);
|
|
4022
4022
|
exports.renderToFileStream(stream, qrData, options);
|
|
@@ -6370,7 +6370,7 @@ var Log = class {
|
|
|
6370
6370
|
record: (record) => {
|
|
6371
6371
|
const dateTime = new Date(record.timestamp);
|
|
6372
6372
|
const dateTimeStr = `${dateTime.getFullYear()}-${(dateTime.getMonth() + 1).toString().padStart(2, "0")}-${dateTime.getDate().toString().padStart(2, "0")} ${dateTime.getHours().toString().padStart(2, "0")}:${dateTime.getMinutes().toString().padStart(2, "0")}:${dateTime.getSeconds().toString().padStart(2, "0")}`;
|
|
6373
|
-
let content = `${dateTimeStr} | ${record.content}\n
|
|
6373
|
+
let content = `${dateTimeStr} | ${record.content}\n`;
|
|
6374
6374
|
console.log(content);
|
|
6375
6375
|
const logRecord = {
|
|
6376
6376
|
timestamp: record.timestamp,
|
|
@@ -6382,7 +6382,7 @@ var Log = class {
|
|
|
6382
6382
|
if (logCache.length > LOG_CACHE_SIZE) logCache.shift();
|
|
6383
6383
|
ctx.parallel("llob/log", logRecord);
|
|
6384
6384
|
if (!enable) return;
|
|
6385
|
-
content = `[${record.type}] | ${content}`;
|
|
6385
|
+
content = `[${record.type}] | ${content}\n`;
|
|
6386
6386
|
if (currentSize >= MAX_FILE_SIZE || currentEntries >= MAX_ENTRIES) rotate();
|
|
6387
6387
|
appendFile(currentFile, content, noop);
|
|
6388
6388
|
currentEntries++;
|
|
@@ -8499,10 +8499,10 @@ var Misc;
|
|
|
8499
8499
|
//#region src/ntqqapi/native/pmhq/mixins/friend.ts
|
|
8500
8500
|
function FriendMixin(Base) {
|
|
8501
8501
|
return class extends Base {
|
|
8502
|
-
async sendFriendPoke(
|
|
8502
|
+
async sendFriendPoke(friendUin, toUin) {
|
|
8503
8503
|
const body = Oidb.SendPokeReq.encode({
|
|
8504
|
-
toUin
|
|
8505
|
-
friendUin
|
|
8504
|
+
toUin,
|
|
8505
|
+
friendUin
|
|
8506
8506
|
});
|
|
8507
8507
|
const data = Oidb.Base.encode({
|
|
8508
8508
|
command: 3795,
|
|
@@ -9576,7 +9576,7 @@ var processQueue = async () => {
|
|
|
9576
9576
|
const promises = queue.splice(0, concurrency).map(async ({ filePath, resolve, reject }) => {
|
|
9577
9577
|
let handle;
|
|
9578
9578
|
try {
|
|
9579
|
-
handle = await fs$
|
|
9579
|
+
handle = await fs$10.promises.open(path$9.resolve(filePath), "r");
|
|
9580
9580
|
} catch (err) {
|
|
9581
9581
|
return reject(err);
|
|
9582
9582
|
}
|
|
@@ -9623,7 +9623,7 @@ function checkUriType(uri) {
|
|
|
9623
9623
|
if (uri.startsWith("data:")) return { type: FileUriType.DataURL };
|
|
9624
9624
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return { type: FileUriType.RemoteURL };
|
|
9625
9625
|
if (uri.startsWith("file://")) return { type: FileUriType.FileURL };
|
|
9626
|
-
if (fs$
|
|
9626
|
+
if (fs$2.existsSync(uri)) return { type: FileUriType.Path };
|
|
9627
9627
|
return { type: FileUriType.Unknown };
|
|
9628
9628
|
}
|
|
9629
9629
|
async function fetchFile(url, headersInit) {
|
|
@@ -9653,7 +9653,7 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
9653
9653
|
const { type } = checkUriType(uri);
|
|
9654
9654
|
if (type === FileUriType.FileURL) {
|
|
9655
9655
|
const filePath = fileURLToPath(uri);
|
|
9656
|
-
if (!fs$
|
|
9656
|
+
if (!fs$2.existsSync(filePath)) return {
|
|
9657
9657
|
success: false,
|
|
9658
9658
|
errMsg: "路径不存在",
|
|
9659
9659
|
fileName: "",
|
|
@@ -9679,12 +9679,12 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
9679
9679
|
const res = await fetchFile(uri);
|
|
9680
9680
|
let fileName = randomUUID();
|
|
9681
9681
|
let filePath = path.join(TEMP_DIR, fileName);
|
|
9682
|
-
await
|
|
9682
|
+
await fs.writeFile(filePath, res.data);
|
|
9683
9683
|
if (needExt) {
|
|
9684
9684
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
|
|
9685
9685
|
fileName += `.${ext}`;
|
|
9686
9686
|
const newPath = `${filePath}.${ext}`;
|
|
9687
|
-
await
|
|
9687
|
+
await fs.rename(filePath, newPath);
|
|
9688
9688
|
filePath = newPath;
|
|
9689
9689
|
}
|
|
9690
9690
|
return {
|
|
@@ -9707,11 +9707,11 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
9707
9707
|
let filename = randomUUID();
|
|
9708
9708
|
let filePath = path.join(TEMP_DIR, filename);
|
|
9709
9709
|
const base64 = uri.replace(/^base64:\/\//, "");
|
|
9710
|
-
await
|
|
9710
|
+
await fs.writeFile(filePath, base64, "base64");
|
|
9711
9711
|
if (needExt) {
|
|
9712
9712
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
|
|
9713
9713
|
filename += `.${ext}`;
|
|
9714
|
-
await
|
|
9714
|
+
await fs.rename(filePath, `${filePath}.${ext}`);
|
|
9715
9715
|
filePath = `${filePath}.${ext}`;
|
|
9716
9716
|
}
|
|
9717
9717
|
return {
|
|
@@ -9728,11 +9728,11 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
9728
9728
|
let filename = randomUUID();
|
|
9729
9729
|
const [, _type, base64] = capture;
|
|
9730
9730
|
let filePath = path.join(TEMP_DIR, filename);
|
|
9731
|
-
await
|
|
9731
|
+
await fs.writeFile(filePath, base64, "base64");
|
|
9732
9732
|
if (needExt) {
|
|
9733
9733
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
|
|
9734
9734
|
filename += `.${ext}`;
|
|
9735
|
-
await
|
|
9735
|
+
await fs.rename(filePath, `${filePath}.${ext}`);
|
|
9736
9736
|
filePath = `${filePath}.${ext}`;
|
|
9737
9737
|
}
|
|
9738
9738
|
return {
|
|
@@ -9790,13 +9790,13 @@ async function getImageSize(path) {
|
|
|
9790
9790
|
}
|
|
9791
9791
|
async function getMd5HexFromFile(filePath) {
|
|
9792
9792
|
const hash = createHash("md5");
|
|
9793
|
-
const stream = fs$
|
|
9793
|
+
const stream = fs$2.createReadStream(filePath);
|
|
9794
9794
|
for await (const chunk of stream) hash.update(chunk);
|
|
9795
9795
|
return hash.digest("hex");
|
|
9796
9796
|
}
|
|
9797
9797
|
async function getSha1HexFromFile(filePath) {
|
|
9798
9798
|
const hash = createHash("sha1");
|
|
9799
|
-
const stream = fs$
|
|
9799
|
+
const stream = fs$2.createReadStream(filePath);
|
|
9800
9800
|
for await (const chunk of stream) hash.update(chunk);
|
|
9801
9801
|
return hash.digest("hex");
|
|
9802
9802
|
}
|
|
@@ -9805,13 +9805,13 @@ function getMd5BufferFromBuffer(buf) {
|
|
|
9805
9805
|
}
|
|
9806
9806
|
async function getMd5BufferFromFile(filePath) {
|
|
9807
9807
|
const hash = createHash("md5");
|
|
9808
|
-
const stream = fs$
|
|
9808
|
+
const stream = fs$2.createReadStream(filePath);
|
|
9809
9809
|
for await (const chunk of stream) hash.update(chunk);
|
|
9810
9810
|
return hash.digest();
|
|
9811
9811
|
}
|
|
9812
9812
|
async function getSha1BufferFromFile(filePath) {
|
|
9813
9813
|
const hash = createHash("sha1");
|
|
9814
|
-
const stream = fs$
|
|
9814
|
+
const stream = fs$2.createReadStream(filePath);
|
|
9815
9815
|
for await (const chunk of stream) hash.update(chunk);
|
|
9816
9816
|
return hash.digest();
|
|
9817
9817
|
}
|
|
@@ -10047,7 +10047,7 @@ async function calculateSha1StreamBytes(filePath) {
|
|
|
10047
10047
|
let bytesRead = 0;
|
|
10048
10048
|
let nextBlockBoundary = blockSize;
|
|
10049
10049
|
const byteArrayList = [];
|
|
10050
|
-
const readable = fs$
|
|
10050
|
+
const readable = fs$2.createReadStream(filePath);
|
|
10051
10051
|
for await (const chunk of readable) {
|
|
10052
10052
|
let buf;
|
|
10053
10053
|
if (tail.length > 0) {
|
|
@@ -10072,7 +10072,7 @@ async function calculateSha1StreamBytes(filePath) {
|
|
|
10072
10072
|
}
|
|
10073
10073
|
async function readAndHash10M(filePath) {
|
|
10074
10074
|
const maxSize = 10002432;
|
|
10075
|
-
const fd = await
|
|
10075
|
+
const fd = await fs.open(filePath, "r");
|
|
10076
10076
|
const buffer = Buffer.allocUnsafe(maxSize);
|
|
10077
10077
|
const { bytesRead } = await fd.read(buffer, 0, maxSize, 0);
|
|
10078
10078
|
await fd.close();
|
|
@@ -10114,7 +10114,7 @@ var TriSha1 = class {
|
|
|
10114
10114
|
};
|
|
10115
10115
|
async function calculateTriSha1(filePath, fileSize) {
|
|
10116
10116
|
const hash = new TriSha1(fileSize);
|
|
10117
|
-
const stream = fs$
|
|
10117
|
+
const stream = fs$2.createReadStream(filePath);
|
|
10118
10118
|
for await (const chunk of stream) hash.update(chunk);
|
|
10119
10119
|
return hash.finalize();
|
|
10120
10120
|
}
|
|
@@ -11378,7 +11378,7 @@ var ConfigUtil = class {
|
|
|
11378
11378
|
console.log("配置文件位于", this.configPath);
|
|
11379
11379
|
this.config = this.getConfig();
|
|
11380
11380
|
if (this.configPath) {
|
|
11381
|
-
fs$
|
|
11381
|
+
fs$2.watchFile(this.configPath, {
|
|
11382
11382
|
persistent: true,
|
|
11383
11383
|
interval: 1e3
|
|
11384
11384
|
}, () => {
|
|
@@ -11395,7 +11395,7 @@ var ConfigUtil = class {
|
|
|
11395
11395
|
}
|
|
11396
11396
|
getDefaultConfig() {
|
|
11397
11397
|
const _defaultConfig = { ...defaultConfig };
|
|
11398
|
-
const defaultConfigFromFile = fs$
|
|
11398
|
+
const defaultConfigFromFile = fs$2.readFileSync(this.defaultConfigPath, "utf-8");
|
|
11399
11399
|
try {
|
|
11400
11400
|
const parsedDefaultConfig = import_dist.default.parse(defaultConfigFromFile);
|
|
11401
11401
|
Object.assign(_defaultConfig, parsedDefaultConfig);
|
|
@@ -11406,12 +11406,12 @@ var ConfigUtil = class {
|
|
|
11406
11406
|
}
|
|
11407
11407
|
reloadConfig() {
|
|
11408
11408
|
if (!this.configPath) return this.getDefaultConfig();
|
|
11409
|
-
if (!fs$
|
|
11409
|
+
if (!fs$2.existsSync(this.configPath)) {
|
|
11410
11410
|
this.config = this.getDefaultConfig();
|
|
11411
11411
|
this.setConfig(this.config);
|
|
11412
11412
|
return this.config;
|
|
11413
11413
|
} else {
|
|
11414
|
-
const data = fs$
|
|
11414
|
+
const data = fs$2.readFileSync(this.configPath, "utf-8");
|
|
11415
11415
|
let jsonData = defaultConfig;
|
|
11416
11416
|
try {
|
|
11417
11417
|
jsonData = import_dist.default.parse(data);
|
|
@@ -11437,7 +11437,7 @@ var ConfigUtil = class {
|
|
|
11437
11437
|
writeConfig(config) {
|
|
11438
11438
|
if (!this.configPath) return;
|
|
11439
11439
|
this.watch = false;
|
|
11440
|
-
fs$
|
|
11440
|
+
fs$2.writeFileSync(this.configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
11441
11441
|
setTimeout(() => {
|
|
11442
11442
|
this.watch = true;
|
|
11443
11443
|
}, 1500);
|
|
@@ -11549,13 +11549,13 @@ var WebUITokenUtil = class {
|
|
|
11549
11549
|
}
|
|
11550
11550
|
getToken() {
|
|
11551
11551
|
if (!this.token) {
|
|
11552
|
-
if (fs$
|
|
11552
|
+
if (fs$2.existsSync(this.tokenPath)) this.token = fs$2.readFileSync(this.tokenPath, "utf-8").trim();
|
|
11553
11553
|
}
|
|
11554
11554
|
return this.token;
|
|
11555
11555
|
}
|
|
11556
11556
|
setToken(token) {
|
|
11557
11557
|
this.token = token.trim();
|
|
11558
|
-
fs$
|
|
11558
|
+
fs$2.writeFileSync(this.tokenPath, token, "utf-8");
|
|
11559
11559
|
}
|
|
11560
11560
|
};
|
|
11561
11561
|
var webuiTokenUtil = new WebUITokenUtil(path.join(DATA_DIR, "webui_token.txt"));
|
|
@@ -11564,13 +11564,13 @@ var webuiTokenUtil = new WebUITokenUtil(path.join(DATA_DIR, "webui_token.txt"));
|
|
|
11564
11564
|
var logFileName = `llbot-${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN")}.log`.replace(/\//g, "-").replace(/:/g, "-");
|
|
11565
11565
|
//#endregion
|
|
11566
11566
|
//#region src/version.ts
|
|
11567
|
-
var version$2 = "7.11.
|
|
11567
|
+
var version$2 = "7.11.3";
|
|
11568
11568
|
//#endregion
|
|
11569
11569
|
//#region node_modules/isexe/windows.js
|
|
11570
11570
|
var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11571
11571
|
module.exports = isexe;
|
|
11572
11572
|
isexe.sync = sync;
|
|
11573
|
-
var fs$
|
|
11573
|
+
var fs$9 = __require("fs");
|
|
11574
11574
|
function checkPathExt(path, options) {
|
|
11575
11575
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
11576
11576
|
if (!pathext) return true;
|
|
@@ -11587,12 +11587,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11587
11587
|
return checkPathExt(path, options);
|
|
11588
11588
|
}
|
|
11589
11589
|
function isexe(path, options, cb) {
|
|
11590
|
-
fs$
|
|
11590
|
+
fs$9.stat(path, function(er, stat) {
|
|
11591
11591
|
cb(er, er ? false : checkStat(stat, path, options));
|
|
11592
11592
|
});
|
|
11593
11593
|
}
|
|
11594
11594
|
function sync(path, options) {
|
|
11595
|
-
return checkStat(fs$
|
|
11595
|
+
return checkStat(fs$9.statSync(path), path, options);
|
|
11596
11596
|
}
|
|
11597
11597
|
}));
|
|
11598
11598
|
//#endregion
|
|
@@ -11600,14 +11600,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11600
11600
|
var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11601
11601
|
module.exports = isexe;
|
|
11602
11602
|
isexe.sync = sync;
|
|
11603
|
-
var fs$
|
|
11603
|
+
var fs$8 = __require("fs");
|
|
11604
11604
|
function isexe(path, options, cb) {
|
|
11605
|
-
fs$
|
|
11605
|
+
fs$8.stat(path, function(er, stat) {
|
|
11606
11606
|
cb(er, er ? false : checkStat(stat, options));
|
|
11607
11607
|
});
|
|
11608
11608
|
}
|
|
11609
11609
|
function sync(path, options) {
|
|
11610
|
-
return checkStat(fs$
|
|
11610
|
+
return checkStat(fs$8.statSync(path), options);
|
|
11611
11611
|
}
|
|
11612
11612
|
function checkStat(stat, options) {
|
|
11613
11613
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -14017,7 +14017,7 @@ var require_processor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14017
14017
|
//#endregion
|
|
14018
14018
|
//#region node_modules/fluent-ffmpeg/lib/capabilities.js
|
|
14019
14019
|
var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
14020
|
-
var fs$
|
|
14020
|
+
var fs$7 = __require("fs");
|
|
14021
14021
|
var path$6 = __require("path");
|
|
14022
14022
|
var async = require_async();
|
|
14023
14023
|
var utils = require_utils();
|
|
@@ -14093,7 +14093,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14093
14093
|
proto._getFfmpegPath = function(callback) {
|
|
14094
14094
|
if ("ffmpegPath" in cache) return callback(null, cache.ffmpegPath);
|
|
14095
14095
|
async.waterfall([function(cb) {
|
|
14096
|
-
if (process.env.FFMPEG_PATH) fs$
|
|
14096
|
+
if (process.env.FFMPEG_PATH) fs$7.exists(process.env.FFMPEG_PATH, function(exists) {
|
|
14097
14097
|
if (exists) cb(null, process.env.FFMPEG_PATH);
|
|
14098
14098
|
else cb(null, "");
|
|
14099
14099
|
});
|
|
@@ -14124,7 +14124,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14124
14124
|
if ("ffprobePath" in cache) return callback(null, cache.ffprobePath);
|
|
14125
14125
|
async.waterfall([
|
|
14126
14126
|
function(cb) {
|
|
14127
|
-
if (process.env.FFPROBE_PATH) fs$
|
|
14127
|
+
if (process.env.FFPROBE_PATH) fs$7.exists(process.env.FFPROBE_PATH, function(exists) {
|
|
14128
14128
|
cb(null, exists ? process.env.FFPROBE_PATH : "");
|
|
14129
14129
|
});
|
|
14130
14130
|
else cb(null, "");
|
|
@@ -14142,7 +14142,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14142
14142
|
else if (ffmpeg.length) {
|
|
14143
14143
|
var name = utils.isWindows ? "ffprobe.exe" : "ffprobe";
|
|
14144
14144
|
var ffprobe = path$6.join(path$6.dirname(ffmpeg), name);
|
|
14145
|
-
fs$
|
|
14145
|
+
fs$7.exists(ffprobe, function(exists) {
|
|
14146
14146
|
cb(null, exists ? ffprobe : "");
|
|
14147
14147
|
});
|
|
14148
14148
|
} else cb(null, "");
|
|
@@ -14167,14 +14167,14 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14167
14167
|
if ("flvtoolPath" in cache) return callback(null, cache.flvtoolPath);
|
|
14168
14168
|
async.waterfall([
|
|
14169
14169
|
function(cb) {
|
|
14170
|
-
if (process.env.FLVMETA_PATH) fs$
|
|
14170
|
+
if (process.env.FLVMETA_PATH) fs$7.exists(process.env.FLVMETA_PATH, function(exists) {
|
|
14171
14171
|
cb(null, exists ? process.env.FLVMETA_PATH : "");
|
|
14172
14172
|
});
|
|
14173
14173
|
else cb(null, "");
|
|
14174
14174
|
},
|
|
14175
14175
|
function(flvtool, cb) {
|
|
14176
14176
|
if (flvtool.length) return cb(null, flvtool);
|
|
14177
|
-
if (process.env.FLVTOOL2_PATH) fs$
|
|
14177
|
+
if (process.env.FLVTOOL2_PATH) fs$7.exists(process.env.FLVTOOL2_PATH, function(exists) {
|
|
14178
14178
|
cb(null, exists ? process.env.FLVTOOL2_PATH : "");
|
|
14179
14179
|
});
|
|
14180
14180
|
else cb(null, "");
|
|
@@ -14679,7 +14679,7 @@ var require_ffprobe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14679
14679
|
//#endregion
|
|
14680
14680
|
//#region node_modules/fluent-ffmpeg/lib/recipes.js
|
|
14681
14681
|
var require_recipes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
14682
|
-
var fs$
|
|
14682
|
+
var fs$6 = __require("fs");
|
|
14683
14683
|
var path$5 = __require("path");
|
|
14684
14684
|
var PassThrough$4 = __require("stream").PassThrough;
|
|
14685
14685
|
var async = require_async();
|
|
@@ -14885,8 +14885,8 @@ var require_recipes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14885
14885
|
next(null, filenames);
|
|
14886
14886
|
},
|
|
14887
14887
|
function createDirectory(filenames, next) {
|
|
14888
|
-
fs$
|
|
14889
|
-
if (!exists) fs$
|
|
14888
|
+
fs$6.exists(config.folder, function(exists) {
|
|
14889
|
+
if (!exists) fs$6.mkdir(config.folder, function(err) {
|
|
14890
14890
|
if (err) next(err);
|
|
14891
14891
|
else next(null, filenames);
|
|
14892
14892
|
});
|
|
@@ -15130,7 +15130,7 @@ var import_fluent_ffmpeg = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
|
|
|
15130
15130
|
})))(), 1);
|
|
15131
15131
|
var defaultVideoThumb = Buffer.from("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", "base64");
|
|
15132
15132
|
async function getVideoInfo(filePath) {
|
|
15133
|
-
const size = fs$
|
|
15133
|
+
const size = fs$2.statSync(filePath).size;
|
|
15134
15134
|
return new Promise((resolve, reject) => {
|
|
15135
15135
|
(0, import_fluent_ffmpeg.default)(filePath).ffprobe((err, metadata) => {
|
|
15136
15136
|
if (err) reject(err);
|
|
@@ -15207,7 +15207,7 @@ function convert(ctx, input, options, outputPath) {
|
|
|
15207
15207
|
});
|
|
15208
15208
|
}
|
|
15209
15209
|
async function encodeSilk(ctx, filePath) {
|
|
15210
|
-
const file = await
|
|
15210
|
+
const file = await fs.readFile(filePath);
|
|
15211
15211
|
if (!isSilk(file)) {
|
|
15212
15212
|
ctx.logger.info(`语音文件${filePath}需要转换成silk`);
|
|
15213
15213
|
let result;
|
|
@@ -15226,7 +15226,7 @@ async function encodeSilk(ctx, filePath) {
|
|
|
15226
15226
|
"-f s16le"
|
|
15227
15227
|
] }), 24e3);
|
|
15228
15228
|
const pttPath = path.join(TEMP_DIR, randomUUID());
|
|
15229
|
-
await
|
|
15229
|
+
await fs.writeFile(pttPath, result.data);
|
|
15230
15230
|
ctx.logger.info(`语音文件${filePath}转换成功!`, pttPath, `时长:`, result.duration);
|
|
15231
15231
|
return {
|
|
15232
15232
|
converted: true,
|
|
@@ -15249,11 +15249,11 @@ async function encodeSilk(ctx, filePath) {
|
|
|
15249
15249
|
}
|
|
15250
15250
|
}
|
|
15251
15251
|
async function decodeSilk(ctx, inputFilePath, outFormat) {
|
|
15252
|
-
const { data } = await decode(await
|
|
15252
|
+
const { data } = await decode(await fs.readFile(inputFilePath), 24e3);
|
|
15253
15253
|
const tmpPath = path.join(TEMP_DIR, path.basename(inputFilePath));
|
|
15254
15254
|
const outFilePath = tmpPath + `.${outFormat}`;
|
|
15255
15255
|
const pcmFilePath = tmpPath + ".pcm";
|
|
15256
|
-
await
|
|
15256
|
+
await fs.writeFile(pcmFilePath, data);
|
|
15257
15257
|
return convert(ctx, pcmFilePath, { input: [
|
|
15258
15258
|
"-f s16le",
|
|
15259
15259
|
"-ar 24000",
|
|
@@ -16437,7 +16437,7 @@ function setFFMpegPath(ffmpegPath) {
|
|
|
16437
16437
|
path.join(import.meta.dirname, "ffmpeg.exe"),
|
|
16438
16438
|
process.env["FFMPEG_PATH"] || ""
|
|
16439
16439
|
];
|
|
16440
|
-
for (const p of paths) if (fs$
|
|
16440
|
+
for (const p of paths) if (fs$2.existsSync(p)) {
|
|
16441
16441
|
import_fluent_ffmpeg.default.setFfmpegPath(p);
|
|
16442
16442
|
console.log("set ffmpeg successfully", p);
|
|
16443
16443
|
break;
|
|
@@ -17003,7 +17003,7 @@ async function transformIncomingSegments$1(ctx, message, rootMsgID, peer) {
|
|
|
17003
17003
|
try {
|
|
17004
17004
|
const { replayMsgSeq, replyMsgTime, sourceMsgIdInRecords, senderUidStr } = replyElement;
|
|
17005
17005
|
const record = message.records.find((msgRecord) => msgRecord.msgId === sourceMsgIdInRecords);
|
|
17006
|
-
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, [senderUidStr]);
|
|
17006
|
+
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, senderUidStr ? [senderUidStr] : []);
|
|
17007
17007
|
let replyMsg;
|
|
17008
17008
|
if (record && record.msgRandom !== "0") replyMsg = msgList.find((msg) => msg.msgRandom === record.msgRandom);
|
|
17009
17009
|
else if (msgList.length > 0) replyMsg = msgList[0];
|
|
@@ -24802,7 +24802,13 @@ var OB11Http = class {
|
|
|
24802
24802
|
else await next();
|
|
24803
24803
|
}
|
|
24804
24804
|
async handleRequest(c, next) {
|
|
24805
|
-
|
|
24805
|
+
let payload;
|
|
24806
|
+
if (c.req.method === "POST") if (c.req.header("Content-Type")?.includes("application/x-www-form-urlencoded")) payload = await c.req.parseBody();
|
|
24807
|
+
else {
|
|
24808
|
+
const text = await c.req.text();
|
|
24809
|
+
payload = text ? JSON.parse(text) : {};
|
|
24810
|
+
}
|
|
24811
|
+
else payload = c.req.query();
|
|
24806
24812
|
this.ctx.logger.info("收到 HTTP 请求", c.req.url, payload);
|
|
24807
24813
|
const actionName = c.req.param("endpoint");
|
|
24808
24814
|
const action = this.config.actionMap.get(actionName);
|
|
@@ -24977,6 +24983,7 @@ var ActionName = /* @__PURE__ */ function(ActionName) {
|
|
|
24977
24983
|
ActionName["GetDoubtFriendsAddRequest"] = "get_doubt_friends_add_request";
|
|
24978
24984
|
ActionName["SetDoubtFriendsAddRequest"] = "set_doubt_friends_add_request";
|
|
24979
24985
|
ActionName["DeleteGroupNotice"] = "_delete_group_notice";
|
|
24986
|
+
ActionName["SendPoke"] = "send_poke";
|
|
24980
24987
|
ActionName["SendLike"] = "send_like";
|
|
24981
24988
|
ActionName["GetLoginInfo"] = "get_login_info";
|
|
24982
24989
|
ActionName["GetFriendList"] = "get_friend_list";
|
|
@@ -26264,17 +26271,17 @@ var DownloadFile = class extends BaseAction {
|
|
|
26264
26271
|
const isRandomName = !payload.name;
|
|
26265
26272
|
const name = payload.name ? path.basename(payload.name) : randomUUID();
|
|
26266
26273
|
const filePath = path.join(TEMP_DIR, name);
|
|
26267
|
-
if (payload.base64) await fsPromise
|
|
26274
|
+
if (payload.base64) await fsPromise.writeFile(filePath, payload.base64, "base64");
|
|
26268
26275
|
else if (payload.url) {
|
|
26269
26276
|
const headers = this.getHeaders(payload.headers);
|
|
26270
26277
|
const res = await fetchFile(payload.url, headers);
|
|
26271
|
-
await fsPromise
|
|
26278
|
+
await fsPromise.writeFile(filePath, res.data);
|
|
26272
26279
|
} else throw new Error("不存在任何文件, 无法下载");
|
|
26273
|
-
if (fs.existsSync(filePath)) {
|
|
26280
|
+
if (fs$1.existsSync(filePath)) {
|
|
26274
26281
|
if (isRandomName) {
|
|
26275
26282
|
const md5 = await getMd5HexFromFile(filePath);
|
|
26276
26283
|
const newPath = path.join(TEMP_DIR, md5);
|
|
26277
|
-
await fsPromise
|
|
26284
|
+
await fsPromise.rename(filePath, newPath);
|
|
26278
26285
|
return { file: newPath };
|
|
26279
26286
|
}
|
|
26280
26287
|
return { file: filePath };
|
|
@@ -27173,9 +27180,12 @@ var GroupPoke = class extends BaseAction {
|
|
|
27173
27180
|
//#region src/onebot11/action/llbot/user/FriendPoke.ts
|
|
27174
27181
|
var FriendPoke = class extends BaseAction {
|
|
27175
27182
|
actionName = ActionName.FriendPoke;
|
|
27176
|
-
payloadSchema = lib_default$1.object({
|
|
27183
|
+
payloadSchema = lib_default$1.object({
|
|
27184
|
+
user_id: lib_default$1.union([Number, String]).required(),
|
|
27185
|
+
target_id: lib_default$1.union([Number, String])
|
|
27186
|
+
});
|
|
27177
27187
|
async _handle(payload) {
|
|
27178
|
-
await this.ctx.app.pmhq.sendFriendPoke(+payload.user_id);
|
|
27188
|
+
await this.ctx.app.pmhq.sendFriendPoke(+payload.user_id, payload.target_id ? +payload.target_id : +payload.user_id);
|
|
27179
27189
|
return null;
|
|
27180
27190
|
}
|
|
27181
27191
|
};
|
|
@@ -27913,6 +27923,21 @@ var ScanQRCode = class extends BaseAction {
|
|
|
27913
27923
|
}
|
|
27914
27924
|
};
|
|
27915
27925
|
//#endregion
|
|
27926
|
+
//#region src/onebot11/action/llbot/msg/SendPoke.ts
|
|
27927
|
+
var SendPoke = class extends BaseAction {
|
|
27928
|
+
actionName = ActionName.SendPoke;
|
|
27929
|
+
payloadSchema = lib_default$1.object({
|
|
27930
|
+
group_id: lib_default$1.union([Number, String]),
|
|
27931
|
+
user_id: lib_default$1.union([Number, String]).required(),
|
|
27932
|
+
target_id: lib_default$1.union([Number, String])
|
|
27933
|
+
});
|
|
27934
|
+
async _handle(payload) {
|
|
27935
|
+
if (payload.group_id) await this.ctx.app.pmhq.sendGroupPoke(+payload.group_id, +payload.user_id);
|
|
27936
|
+
else await this.ctx.app.pmhq.sendFriendPoke(+payload.user_id, payload.target_id ? +payload.target_id : +payload.user_id);
|
|
27937
|
+
return null;
|
|
27938
|
+
}
|
|
27939
|
+
};
|
|
27940
|
+
//#endregion
|
|
27916
27941
|
//#region src/onebot11/action/index.ts
|
|
27917
27942
|
function initActionMap(adapter) {
|
|
27918
27943
|
const actionHandlers = [
|
|
@@ -27965,6 +27990,7 @@ function initActionMap(adapter) {
|
|
|
27965
27990
|
new GetDoubtFriendsAddRequest(adapter),
|
|
27966
27991
|
new SetDoubtFriendsAddRequest(adapter),
|
|
27967
27992
|
new DeleteGroupNotice(adapter),
|
|
27993
|
+
new SendPoke(adapter),
|
|
27968
27994
|
new SendLike(adapter),
|
|
27969
27995
|
new GetMsg(adapter),
|
|
27970
27996
|
new GetLoginInfo$1(adapter),
|
|
@@ -29310,7 +29336,7 @@ async function decodeElement(ctx, data, quoted = false) {
|
|
|
29310
29336
|
try {
|
|
29311
29337
|
const { replayMsgSeq, replyMsgTime, sourceMsgIdInRecords, senderUidStr } = v.replyElement;
|
|
29312
29338
|
const record = data.records.find((msgRecord) => msgRecord.msgId === sourceMsgIdInRecords);
|
|
29313
|
-
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, [senderUidStr]);
|
|
29339
|
+
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, senderUidStr ? [senderUidStr] : []);
|
|
29314
29340
|
let replyMsg;
|
|
29315
29341
|
if (record && record.msgRandom !== "0") replyMsg = msgList.find((msg) => msg.msgRandom === record.msgRandom);
|
|
29316
29342
|
else replyMsg = msgList[0];
|
|
@@ -44519,7 +44545,7 @@ discriminatedUnion("event_type", [
|
|
|
44519
44545
|
data: GroupFileUploadEvent
|
|
44520
44546
|
}).describe("群文件上传事件")
|
|
44521
44547
|
]).describe("事件");
|
|
44522
|
-
var milkyVersion = "1.2.0
|
|
44548
|
+
var milkyVersion = "1.2.0".split(".").slice(0, 2).join(".");
|
|
44523
44549
|
var CachedApiBase = object({ no_cache: ZBooleanWithDefault(false).describe("是否强制不使用缓存") });
|
|
44524
44550
|
var GetLoginInfoOutput = object({
|
|
44525
44551
|
uin: ZUin.describe("登录 QQ 号"),
|
|
@@ -44854,7 +44880,7 @@ async function download(url, headers) {
|
|
|
44854
44880
|
return Buffer.from(bytes);
|
|
44855
44881
|
}
|
|
44856
44882
|
async function resolveMilkyUri(uri) {
|
|
44857
|
-
if (uri.startsWith("file://")) return await
|
|
44883
|
+
if (uri.startsWith("file://")) return await fs.readFile(fileURLToPath(uri));
|
|
44858
44884
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return await download(uri);
|
|
44859
44885
|
if (uri.startsWith("base64://")) return Buffer.from(uri.slice(9), "base64");
|
|
44860
44886
|
throw new Error(`Unsupported URI scheme: ${uri}`);
|
|
@@ -45813,6 +45839,7 @@ var buildOptions = function(options) {
|
|
|
45813
45839
|
for (const { value, name } of propertyNameOptions) if (value) validatePropertyName(value, name);
|
|
45814
45840
|
if (built.onDangerousProperty === null) built.onDangerousProperty = defaultOnDangerousProperty;
|
|
45815
45841
|
built.processEntities = normalizeProcessEntities(built.processEntities);
|
|
45842
|
+
built.unpairedTagsSet = new Set(built.unpairedTags);
|
|
45816
45843
|
if (built.stopNodes && Array.isArray(built.stopNodes)) built.stopNodes = built.stopNodes.map((node) => {
|
|
45817
45844
|
if (typeof node === "string" && node.startsWith("*.")) return ".." + node.substring(2);
|
|
45818
45845
|
return node;
|
|
@@ -46203,10 +46230,11 @@ var Expression = class {
|
|
|
46203
46230
|
* @param {Object} options - Configuration options
|
|
46204
46231
|
* @param {string} options.separator - Path separator (default: '.')
|
|
46205
46232
|
*/
|
|
46206
|
-
constructor(pattern, options = {}) {
|
|
46233
|
+
constructor(pattern, options = {}, data) {
|
|
46207
46234
|
this.pattern = pattern;
|
|
46208
46235
|
this.separator = options.separator || ".";
|
|
46209
46236
|
this.segments = this._parse(pattern);
|
|
46237
|
+
this.data = data;
|
|
46210
46238
|
this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
|
|
46211
46239
|
this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
|
|
46212
46240
|
this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
|
|
@@ -46336,6 +46364,179 @@ var Expression = class {
|
|
|
46336
46364
|
}
|
|
46337
46365
|
};
|
|
46338
46366
|
//#endregion
|
|
46367
|
+
//#region node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
46368
|
+
/**
|
|
46369
|
+
* ExpressionSet - An indexed collection of Expressions for efficient bulk matching
|
|
46370
|
+
*
|
|
46371
|
+
* Instead of iterating all expressions on every tag, ExpressionSet pre-indexes
|
|
46372
|
+
* them at insertion time by depth and terminal tag name. At match time, only
|
|
46373
|
+
* the relevant bucket is evaluated — typically reducing checks from O(E) to O(1)
|
|
46374
|
+
* lookup plus O(small bucket) matches.
|
|
46375
|
+
*
|
|
46376
|
+
* Three buckets are maintained:
|
|
46377
|
+
* - `_byDepthAndTag` — exact depth + exact tag name (tightest, used first)
|
|
46378
|
+
* - `_wildcardByDepth` — exact depth + wildcard tag `*` (depth-matched only)
|
|
46379
|
+
* - `_deepWildcards` — expressions containing `..` (cannot be depth-indexed)
|
|
46380
|
+
*
|
|
46381
|
+
* @example
|
|
46382
|
+
* import { Expression, ExpressionSet } from 'fast-xml-tagger';
|
|
46383
|
+
*
|
|
46384
|
+
* // Build once at config time
|
|
46385
|
+
* const stopNodes = new ExpressionSet();
|
|
46386
|
+
* stopNodes.add(new Expression('root.users.user'));
|
|
46387
|
+
* stopNodes.add(new Expression('root.config.setting'));
|
|
46388
|
+
* stopNodes.add(new Expression('..script'));
|
|
46389
|
+
*
|
|
46390
|
+
* // Query on every tag — hot path
|
|
46391
|
+
* if (stopNodes.matchesAny(matcher)) { ... }
|
|
46392
|
+
*/
|
|
46393
|
+
var ExpressionSet = class {
|
|
46394
|
+
constructor() {
|
|
46395
|
+
/** @type {Map<string, import('./Expression.js').default[]>} depth:tag → expressions */
|
|
46396
|
+
this._byDepthAndTag = /* @__PURE__ */ new Map();
|
|
46397
|
+
/** @type {Map<number, import('./Expression.js').default[]>} depth → wildcard-tag expressions */
|
|
46398
|
+
this._wildcardByDepth = /* @__PURE__ */ new Map();
|
|
46399
|
+
/** @type {import('./Expression.js').default[]} expressions containing deep wildcard (..) */
|
|
46400
|
+
this._deepWildcards = [];
|
|
46401
|
+
/** @type {Set<string>} pattern strings already added — used for deduplication */
|
|
46402
|
+
this._patterns = /* @__PURE__ */ new Set();
|
|
46403
|
+
/** @type {boolean} whether the set is sealed against further additions */
|
|
46404
|
+
this._sealed = false;
|
|
46405
|
+
}
|
|
46406
|
+
/**
|
|
46407
|
+
* Add an Expression to the set.
|
|
46408
|
+
* Duplicate patterns (same pattern string) are silently ignored.
|
|
46409
|
+
*
|
|
46410
|
+
* @param {import('./Expression.js').default} expression - A pre-constructed Expression instance
|
|
46411
|
+
* @returns {this} for chaining
|
|
46412
|
+
* @throws {TypeError} if called after seal()
|
|
46413
|
+
*
|
|
46414
|
+
* @example
|
|
46415
|
+
* set.add(new Expression('root.users.user'));
|
|
46416
|
+
* set.add(new Expression('..script'));
|
|
46417
|
+
*/
|
|
46418
|
+
add(expression) {
|
|
46419
|
+
if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");
|
|
46420
|
+
if (this._patterns.has(expression.pattern)) return this;
|
|
46421
|
+
this._patterns.add(expression.pattern);
|
|
46422
|
+
if (expression.hasDeepWildcard()) {
|
|
46423
|
+
this._deepWildcards.push(expression);
|
|
46424
|
+
return this;
|
|
46425
|
+
}
|
|
46426
|
+
const depth = expression.length;
|
|
46427
|
+
const tag = expression.segments[expression.segments.length - 1]?.tag;
|
|
46428
|
+
if (!tag || tag === "*") {
|
|
46429
|
+
if (!this._wildcardByDepth.has(depth)) this._wildcardByDepth.set(depth, []);
|
|
46430
|
+
this._wildcardByDepth.get(depth).push(expression);
|
|
46431
|
+
} else {
|
|
46432
|
+
const key = `${depth}:${tag}`;
|
|
46433
|
+
if (!this._byDepthAndTag.has(key)) this._byDepthAndTag.set(key, []);
|
|
46434
|
+
this._byDepthAndTag.get(key).push(expression);
|
|
46435
|
+
}
|
|
46436
|
+
return this;
|
|
46437
|
+
}
|
|
46438
|
+
/**
|
|
46439
|
+
* Add multiple expressions at once.
|
|
46440
|
+
*
|
|
46441
|
+
* @param {import('./Expression.js').default[]} expressions - Array of Expression instances
|
|
46442
|
+
* @returns {this} for chaining
|
|
46443
|
+
*
|
|
46444
|
+
* @example
|
|
46445
|
+
* set.addAll([
|
|
46446
|
+
* new Expression('root.users.user'),
|
|
46447
|
+
* new Expression('root.config.setting'),
|
|
46448
|
+
* ]);
|
|
46449
|
+
*/
|
|
46450
|
+
addAll(expressions) {
|
|
46451
|
+
for (const expr of expressions) this.add(expr);
|
|
46452
|
+
return this;
|
|
46453
|
+
}
|
|
46454
|
+
/**
|
|
46455
|
+
* Check whether a pattern string is already present in the set.
|
|
46456
|
+
*
|
|
46457
|
+
* @param {import('./Expression.js').default} expression
|
|
46458
|
+
* @returns {boolean}
|
|
46459
|
+
*/
|
|
46460
|
+
has(expression) {
|
|
46461
|
+
return this._patterns.has(expression.pattern);
|
|
46462
|
+
}
|
|
46463
|
+
/**
|
|
46464
|
+
* Number of expressions in the set.
|
|
46465
|
+
* @type {number}
|
|
46466
|
+
*/
|
|
46467
|
+
get size() {
|
|
46468
|
+
return this._patterns.size;
|
|
46469
|
+
}
|
|
46470
|
+
/**
|
|
46471
|
+
* Seal the set against further modifications.
|
|
46472
|
+
* Useful to prevent accidental mutations after config is built.
|
|
46473
|
+
* Calling add() or addAll() on a sealed set throws a TypeError.
|
|
46474
|
+
*
|
|
46475
|
+
* @returns {this}
|
|
46476
|
+
*/
|
|
46477
|
+
seal() {
|
|
46478
|
+
this._sealed = true;
|
|
46479
|
+
return this;
|
|
46480
|
+
}
|
|
46481
|
+
/**
|
|
46482
|
+
* Whether the set has been sealed.
|
|
46483
|
+
* @type {boolean}
|
|
46484
|
+
*/
|
|
46485
|
+
get isSealed() {
|
|
46486
|
+
return this._sealed;
|
|
46487
|
+
}
|
|
46488
|
+
/**
|
|
46489
|
+
* Test whether the matcher's current path matches any expression in the set.
|
|
46490
|
+
*
|
|
46491
|
+
* Evaluation order (cheapest → most expensive):
|
|
46492
|
+
* 1. Exact depth + tag bucket — O(1) lookup, typically 0–2 expressions
|
|
46493
|
+
* 2. Depth-only wildcard bucket — O(1) lookup, rare
|
|
46494
|
+
* 3. Deep-wildcard list — always checked, but usually small
|
|
46495
|
+
*
|
|
46496
|
+
* @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
|
|
46497
|
+
* @returns {boolean} true if any expression matches the current path
|
|
46498
|
+
*
|
|
46499
|
+
* @example
|
|
46500
|
+
* if (stopNodes.matchesAny(matcher)) {
|
|
46501
|
+
* // handle stop node
|
|
46502
|
+
* }
|
|
46503
|
+
*/
|
|
46504
|
+
matchesAny(matcher) {
|
|
46505
|
+
return this.findMatch(matcher) !== null;
|
|
46506
|
+
}
|
|
46507
|
+
/**
|
|
46508
|
+
* Find and return the first Expression that matches the matcher's current path.
|
|
46509
|
+
*
|
|
46510
|
+
* Uses the same evaluation order as matchesAny (cheapest → most expensive):
|
|
46511
|
+
* 1. Exact depth + tag bucket
|
|
46512
|
+
* 2. Depth-only wildcard bucket
|
|
46513
|
+
* 3. Deep-wildcard list
|
|
46514
|
+
*
|
|
46515
|
+
* @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
|
|
46516
|
+
* @returns {import('./Expression.js').default | null} the first matching Expression, or null
|
|
46517
|
+
*
|
|
46518
|
+
* @example
|
|
46519
|
+
* const expr = stopNodes.findMatch(matcher);
|
|
46520
|
+
* if (expr) {
|
|
46521
|
+
* // access expr.config, expr.pattern, etc.
|
|
46522
|
+
* }
|
|
46523
|
+
*/
|
|
46524
|
+
findMatch(matcher) {
|
|
46525
|
+
const depth = matcher.getDepth();
|
|
46526
|
+
const exactKey = `${depth}:${matcher.getCurrentTag()}`;
|
|
46527
|
+
const exactBucket = this._byDepthAndTag.get(exactKey);
|
|
46528
|
+
if (exactBucket) {
|
|
46529
|
+
for (let i = 0; i < exactBucket.length; i++) if (matcher.matches(exactBucket[i])) return exactBucket[i];
|
|
46530
|
+
}
|
|
46531
|
+
const wildcardBucket = this._wildcardByDepth.get(depth);
|
|
46532
|
+
if (wildcardBucket) {
|
|
46533
|
+
for (let i = 0; i < wildcardBucket.length; i++) if (matcher.matches(wildcardBucket[i])) return wildcardBucket[i];
|
|
46534
|
+
}
|
|
46535
|
+
for (let i = 0; i < this._deepWildcards.length; i++) if (matcher.matches(this._deepWildcards[i])) return this._deepWildcards[i];
|
|
46536
|
+
return null;
|
|
46537
|
+
}
|
|
46538
|
+
};
|
|
46539
|
+
//#endregion
|
|
46339
46540
|
//#region node_modules/path-expression-matcher/src/Matcher.js
|
|
46340
46541
|
/**
|
|
46341
46542
|
* Matcher - Tracks current path in XML/JSON tree and matches against Expressions
|
|
@@ -46375,6 +46576,9 @@ var Matcher = class {
|
|
|
46375
46576
|
this.separator = options.separator || ".";
|
|
46376
46577
|
this.path = [];
|
|
46377
46578
|
this.siblingStacks = [];
|
|
46579
|
+
this._pathStringCache = null;
|
|
46580
|
+
this._frozenPathCache = null;
|
|
46581
|
+
this._frozenSiblingsCache = null;
|
|
46378
46582
|
}
|
|
46379
46583
|
/**
|
|
46380
46584
|
* Push a new tag onto the path
|
|
@@ -46384,6 +46588,8 @@ var Matcher = class {
|
|
|
46384
46588
|
*/
|
|
46385
46589
|
push(tagName, attrValues = null, namespace = null) {
|
|
46386
46590
|
this._pathStringCache = null;
|
|
46591
|
+
this._frozenPathCache = null;
|
|
46592
|
+
this._frozenSiblingsCache = null;
|
|
46387
46593
|
if (this.path.length > 0) {
|
|
46388
46594
|
const prev = this.path[this.path.length - 1];
|
|
46389
46595
|
prev.values = void 0;
|
|
@@ -46410,8 +46616,10 @@ var Matcher = class {
|
|
|
46410
46616
|
* @returns {Object|undefined} The popped node
|
|
46411
46617
|
*/
|
|
46412
46618
|
pop() {
|
|
46413
|
-
if (this.path.length === 0) return;
|
|
46619
|
+
if (this.path.length === 0) return void 0;
|
|
46414
46620
|
this._pathStringCache = null;
|
|
46621
|
+
this._frozenPathCache = null;
|
|
46622
|
+
this._frozenSiblingsCache = null;
|
|
46415
46623
|
const node = this.path.pop();
|
|
46416
46624
|
if (this.siblingStacks.length > this.path.length + 1) this.siblingStacks.length = this.path.length + 1;
|
|
46417
46625
|
return node;
|
|
@@ -46424,7 +46632,10 @@ var Matcher = class {
|
|
|
46424
46632
|
updateCurrent(attrValues) {
|
|
46425
46633
|
if (this.path.length > 0) {
|
|
46426
46634
|
const current = this.path[this.path.length - 1];
|
|
46427
|
-
if (attrValues !== null && attrValues !== void 0)
|
|
46635
|
+
if (attrValues !== null && attrValues !== void 0) {
|
|
46636
|
+
current.values = attrValues;
|
|
46637
|
+
this._frozenPathCache = null;
|
|
46638
|
+
}
|
|
46428
46639
|
}
|
|
46429
46640
|
}
|
|
46430
46641
|
/**
|
|
@@ -46519,6 +46730,8 @@ var Matcher = class {
|
|
|
46519
46730
|
*/
|
|
46520
46731
|
reset() {
|
|
46521
46732
|
this._pathStringCache = null;
|
|
46733
|
+
this._frozenPathCache = null;
|
|
46734
|
+
this._frozenSiblingsCache = null;
|
|
46522
46735
|
this.path = [];
|
|
46523
46736
|
this.siblingStacks = [];
|
|
46524
46737
|
}
|
|
@@ -46614,6 +46827,14 @@ var Matcher = class {
|
|
|
46614
46827
|
return true;
|
|
46615
46828
|
}
|
|
46616
46829
|
/**
|
|
46830
|
+
* Match any expression in the given set against the current path.
|
|
46831
|
+
* @param {ExpressionSet} exprSet - The set of expressions to match against.
|
|
46832
|
+
* @returns {boolean} - True if any expression in the set matches the current path, false otherwise.
|
|
46833
|
+
*/
|
|
46834
|
+
matchesAny(exprSet) {
|
|
46835
|
+
return exprSet.matchesAny(this);
|
|
46836
|
+
}
|
|
46837
|
+
/**
|
|
46617
46838
|
* Create a snapshot of current state
|
|
46618
46839
|
* @returns {Object} State snapshot
|
|
46619
46840
|
*/
|
|
@@ -46629,6 +46850,8 @@ var Matcher = class {
|
|
|
46629
46850
|
*/
|
|
46630
46851
|
restore(snapshot) {
|
|
46631
46852
|
this._pathStringCache = null;
|
|
46853
|
+
this._frozenPathCache = null;
|
|
46854
|
+
this._frozenSiblingsCache = null;
|
|
46632
46855
|
this.path = snapshot.path.map((node) => ({ ...node }));
|
|
46633
46856
|
this.siblingStacks = snapshot.siblingStacks.map((map) => new Map(map));
|
|
46634
46857
|
}
|
|
@@ -46659,8 +46882,15 @@ var Matcher = class {
|
|
|
46659
46882
|
if (MUTATING_METHODS.has(prop)) return () => {
|
|
46660
46883
|
throw new TypeError(`Cannot call '${prop}' on a read-only Matcher. Obtain a writable instance to mutate state.`);
|
|
46661
46884
|
};
|
|
46885
|
+
if (prop === "path") {
|
|
46886
|
+
if (target._frozenPathCache === null) target._frozenPathCache = Object.freeze(target.path.map((node) => Object.freeze({ ...node })));
|
|
46887
|
+
return target._frozenPathCache;
|
|
46888
|
+
}
|
|
46889
|
+
if (prop === "siblingStacks") {
|
|
46890
|
+
if (target._frozenSiblingsCache === null) target._frozenSiblingsCache = Object.freeze(target.siblingStacks.map((map) => Object.freeze(new Map(map))));
|
|
46891
|
+
return target._frozenSiblingsCache;
|
|
46892
|
+
}
|
|
46662
46893
|
const value = Reflect.get(target, prop, receiver);
|
|
46663
|
-
if (prop === "path" || prop === "siblingStacks") return Object.freeze(Array.isArray(value) ? value.map((item) => item instanceof Map ? Object.freeze(new Map(item)) : Object.freeze({ ...item })) : value);
|
|
46664
46894
|
if (typeof value === "function") return value.bind(target);
|
|
46665
46895
|
return value;
|
|
46666
46896
|
},
|
|
@@ -46791,13 +47021,15 @@ var OrderedObjParser = class {
|
|
|
46791
47021
|
this.matcher = new Matcher();
|
|
46792
47022
|
this.readonlyMatcher = this.matcher.readOnly();
|
|
46793
47023
|
this.isCurrentNodeStopNode = false;
|
|
46794
|
-
|
|
46795
|
-
|
|
46796
|
-
|
|
46797
|
-
|
|
46798
|
-
|
|
46799
|
-
|
|
47024
|
+
this.stopNodeExpressionsSet = new ExpressionSet();
|
|
47025
|
+
const stopNodesOpts = this.options.stopNodes;
|
|
47026
|
+
if (stopNodesOpts && stopNodesOpts.length > 0) {
|
|
47027
|
+
for (let i = 0; i < stopNodesOpts.length; i++) {
|
|
47028
|
+
const stopNodeExp = stopNodesOpts[i];
|
|
47029
|
+
if (typeof stopNodeExp === "string") this.stopNodeExpressionsSet.add(new Expression(stopNodeExp));
|
|
47030
|
+
else if (stopNodeExp instanceof Expression) this.stopNodeExpressionsSet.add(stopNodeExp);
|
|
46800
47031
|
}
|
|
47032
|
+
this.stopNodeExpressionsSet.seal();
|
|
46801
47033
|
}
|
|
46802
47034
|
}
|
|
46803
47035
|
};
|
|
@@ -46822,16 +47054,17 @@ function addExternalEntities(externalEntities) {
|
|
|
46822
47054
|
* @param {boolean} escapeEntities
|
|
46823
47055
|
*/
|
|
46824
47056
|
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
47057
|
+
const options = this.options;
|
|
46825
47058
|
if (val !== void 0) {
|
|
46826
|
-
if (
|
|
47059
|
+
if (options.trimValues && !dontTrim) val = val.trim();
|
|
46827
47060
|
if (val.length > 0) {
|
|
46828
47061
|
if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
|
|
46829
|
-
const jPathOrMatcher =
|
|
46830
|
-
const newval =
|
|
47062
|
+
const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
|
|
47063
|
+
const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
|
|
46831
47064
|
if (newval === null || newval === void 0) return val;
|
|
46832
47065
|
else if (typeof newval !== typeof val || newval !== val) return newval;
|
|
46833
|
-
else if (
|
|
46834
|
-
else if (val.trim() === val) return parseValue(val,
|
|
47066
|
+
else if (options.trimValues) return parseValue(val, options.parseTagValue, options.numberParseOptions);
|
|
47067
|
+
else if (val.trim() === val) return parseValue(val, options.parseTagValue, options.numberParseOptions);
|
|
46835
47068
|
else return val;
|
|
46836
47069
|
}
|
|
46837
47070
|
}
|
|
@@ -46847,7 +47080,8 @@ function resolveNameSpace(tagname) {
|
|
|
46847
47080
|
}
|
|
46848
47081
|
var attrsRegx = /* @__PURE__ */ new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
|
|
46849
47082
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
46850
|
-
|
|
47083
|
+
const options = this.options;
|
|
47084
|
+
if (options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
46851
47085
|
const matches = getAllMatches(attrStr, attrsRegx);
|
|
46852
47086
|
const len = matches.length;
|
|
46853
47087
|
const attrs = {};
|
|
@@ -46859,7 +47093,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
|
|
|
46859
47093
|
const oldVal = matches[i][4];
|
|
46860
47094
|
if (attrName.length && oldVal !== void 0) {
|
|
46861
47095
|
let val = oldVal;
|
|
46862
|
-
if (
|
|
47096
|
+
if (options.trimValues) val = val.trim();
|
|
46863
47097
|
val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
|
|
46864
47098
|
processedVals[i] = val;
|
|
46865
47099
|
rawAttrsForMatcher[attrName] = val;
|
|
@@ -46867,32 +47101,32 @@ function buildAttributesMap(attrStr, jPath, tagName) {
|
|
|
46867
47101
|
}
|
|
46868
47102
|
}
|
|
46869
47103
|
if (hasRawAttrs && typeof jPath === "object" && jPath.updateCurrent) jPath.updateCurrent(rawAttrsForMatcher);
|
|
46870
|
-
const jPathStr =
|
|
47104
|
+
const jPathStr = options.jPath ? jPath.toString() : this.readonlyMatcher;
|
|
46871
47105
|
let hasAttrs = false;
|
|
46872
47106
|
for (let i = 0; i < len; i++) {
|
|
46873
47107
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
46874
47108
|
if (this.ignoreAttributesFn(attrName, jPathStr)) continue;
|
|
46875
|
-
let aName =
|
|
47109
|
+
let aName = options.attributeNamePrefix + attrName;
|
|
46876
47110
|
if (attrName.length) {
|
|
46877
|
-
if (
|
|
46878
|
-
aName = sanitizeName(aName,
|
|
47111
|
+
if (options.transformAttributeName) aName = options.transformAttributeName(aName);
|
|
47112
|
+
aName = sanitizeName(aName, options);
|
|
46879
47113
|
if (matches[i][4] !== void 0) {
|
|
46880
47114
|
const oldVal = processedVals[i];
|
|
46881
|
-
const newVal =
|
|
47115
|
+
const newVal = options.attributeValueProcessor(attrName, oldVal, jPathStr);
|
|
46882
47116
|
if (newVal === null || newVal === void 0) attrs[aName] = oldVal;
|
|
46883
47117
|
else if (typeof newVal !== typeof oldVal || newVal !== oldVal) attrs[aName] = newVal;
|
|
46884
|
-
else attrs[aName] = parseValue(oldVal,
|
|
47118
|
+
else attrs[aName] = parseValue(oldVal, options.parseAttributeValue, options.numberParseOptions);
|
|
46885
47119
|
hasAttrs = true;
|
|
46886
|
-
} else if (
|
|
47120
|
+
} else if (options.allowBooleanAttributes) {
|
|
46887
47121
|
attrs[aName] = true;
|
|
46888
47122
|
hasAttrs = true;
|
|
46889
47123
|
}
|
|
46890
47124
|
}
|
|
46891
47125
|
}
|
|
46892
47126
|
if (!hasAttrs) return;
|
|
46893
|
-
if (
|
|
47127
|
+
if (options.attributesGroupName) {
|
|
46894
47128
|
const attrCollection = {};
|
|
46895
|
-
attrCollection[
|
|
47129
|
+
attrCollection[options.attributesGroupName] = attrs;
|
|
46896
47130
|
return attrCollection;
|
|
46897
47131
|
}
|
|
46898
47132
|
return attrs;
|
|
@@ -46906,144 +47140,152 @@ var parseXml = function(xmlData) {
|
|
|
46906
47140
|
this.matcher.reset();
|
|
46907
47141
|
this.entityExpansionCount = 0;
|
|
46908
47142
|
this.currentExpandedLength = 0;
|
|
46909
|
-
|
|
46910
|
-
|
|
46911
|
-
|
|
46912
|
-
|
|
46913
|
-
|
|
46914
|
-
|
|
46915
|
-
|
|
46916
|
-
|
|
46917
|
-
|
|
46918
|
-
|
|
46919
|
-
|
|
46920
|
-
|
|
46921
|
-
|
|
46922
|
-
|
|
46923
|
-
|
|
46924
|
-
|
|
46925
|
-
|
|
46926
|
-
|
|
46927
|
-
|
|
46928
|
-
|
|
46929
|
-
|
|
46930
|
-
|
|
46931
|
-
|
|
46932
|
-
if (!tagData) throw new Error("Pi Tag is not closed.");
|
|
46933
|
-
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
46934
|
-
if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) {} else {
|
|
46935
|
-
const childNode = new XmlNode(tagData.tagName);
|
|
46936
|
-
childNode.add(this.options.textNodeName, "");
|
|
46937
|
-
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) childNode[":@"] = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName);
|
|
46938
|
-
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
|
46939
|
-
}
|
|
46940
|
-
i = tagData.closeIndex + 1;
|
|
46941
|
-
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
46942
|
-
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
|
|
46943
|
-
if (this.options.commentPropName) {
|
|
46944
|
-
const comment = xmlData.substring(i + 4, endIndex - 2);
|
|
46945
|
-
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
46946
|
-
currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
|
|
46947
|
-
}
|
|
46948
|
-
i = endIndex;
|
|
46949
|
-
} else if (xmlData.substr(i + 1, 2) === "!D") {
|
|
46950
|
-
const result = docTypeReader.readDocType(xmlData, i);
|
|
46951
|
-
this.docTypeEntities = result.entities;
|
|
46952
|
-
i = result.i;
|
|
46953
|
-
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
46954
|
-
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
46955
|
-
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
46956
|
-
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
46957
|
-
let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
|
|
46958
|
-
if (val == void 0) val = "";
|
|
46959
|
-
if (this.options.cdataPropName) currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
|
|
46960
|
-
else currentNode.add(this.options.textNodeName, val);
|
|
46961
|
-
i = closeIndex + 2;
|
|
46962
|
-
} else {
|
|
46963
|
-
let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
|
|
46964
|
-
if (!result) {
|
|
46965
|
-
const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlData.length, i + 50));
|
|
46966
|
-
throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
|
|
46967
|
-
}
|
|
46968
|
-
let tagName = result.tagName;
|
|
46969
|
-
const rawTagName = result.rawTagName;
|
|
46970
|
-
let tagExp = result.tagExp;
|
|
46971
|
-
let attrExpPresent = result.attrExpPresent;
|
|
46972
|
-
let closeIndex = result.closeIndex;
|
|
46973
|
-
({tagName, tagExp} = transformTagName(this.options.transformTagName, tagName, tagExp, this.options));
|
|
46974
|
-
if (this.options.strictReservedNames && (tagName === this.options.commentPropName || tagName === this.options.cdataPropName || tagName === this.options.textNodeName || tagName === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${tagName}`);
|
|
46975
|
-
if (currentNode && textData) {
|
|
46976
|
-
if (currentNode.tagname !== "!xml") textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
|
|
46977
|
-
}
|
|
46978
|
-
const lastTag = currentNode;
|
|
46979
|
-
if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
|
|
46980
|
-
currentNode = this.tagsNodeStack.pop();
|
|
46981
|
-
this.matcher.pop();
|
|
46982
|
-
}
|
|
46983
|
-
let isSelfClosing = false;
|
|
46984
|
-
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
46985
|
-
isSelfClosing = true;
|
|
46986
|
-
if (tagName[tagName.length - 1] === "/") {
|
|
46987
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
46988
|
-
tagExp = tagName;
|
|
46989
|
-
} else tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
46990
|
-
attrExpPresent = tagName !== tagExp;
|
|
46991
|
-
}
|
|
46992
|
-
let prefixedAttrs = null;
|
|
46993
|
-
let namespace = void 0;
|
|
46994
|
-
namespace = extractNamespace(rawTagName);
|
|
46995
|
-
if (tagName !== xmlObj.tagname) this.matcher.push(tagName, {}, namespace);
|
|
46996
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
46997
|
-
prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
|
|
46998
|
-
if (prefixedAttrs) extractRawAttributes(prefixedAttrs, this.options);
|
|
46999
|
-
}
|
|
47000
|
-
if (tagName !== xmlObj.tagname) this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher);
|
|
47001
|
-
const startIndex = i;
|
|
47002
|
-
if (this.isCurrentNodeStopNode) {
|
|
47003
|
-
let tagContent = "";
|
|
47004
|
-
if (isSelfClosing) i = result.closeIndex;
|
|
47005
|
-
else if (this.options.unpairedTags.indexOf(tagName) !== -1) i = result.closeIndex;
|
|
47006
|
-
else {
|
|
47007
|
-
const result = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
47008
|
-
if (!result) throw new Error(`Unexpected end of ${rawTagName}`);
|
|
47009
|
-
i = result.i;
|
|
47010
|
-
tagContent = result.tagContent;
|
|
47011
|
-
}
|
|
47012
|
-
const childNode = new XmlNode(tagName);
|
|
47013
|
-
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47014
|
-
childNode.add(this.options.textNodeName, tagContent);
|
|
47143
|
+
this.docTypeEntitiesKeys = [];
|
|
47144
|
+
this.lastEntitiesKeys = Object.keys(this.lastEntities);
|
|
47145
|
+
this.htmlEntitiesKeys = this.options.htmlEntities ? Object.keys(this.htmlEntities) : [];
|
|
47146
|
+
const options = this.options;
|
|
47147
|
+
const docTypeReader = new DocTypeReader(options.processEntities);
|
|
47148
|
+
const xmlLen = xmlData.length;
|
|
47149
|
+
for (let i = 0; i < xmlLen; i++) if (xmlData[i] === "<") {
|
|
47150
|
+
const c1 = xmlData.charCodeAt(i + 1);
|
|
47151
|
+
if (c1 === 47) {
|
|
47152
|
+
const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
|
|
47153
|
+
let tagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
47154
|
+
if (options.removeNSPrefix) {
|
|
47155
|
+
const colonIndex = tagName.indexOf(":");
|
|
47156
|
+
if (colonIndex !== -1) tagName = tagName.substr(colonIndex + 1);
|
|
47157
|
+
}
|
|
47158
|
+
tagName = transformTagName(options.transformTagName, tagName, "", options).tagName;
|
|
47159
|
+
if (currentNode) textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
47160
|
+
const lastTagName = this.matcher.getCurrentTag();
|
|
47161
|
+
if (tagName && options.unpairedTagsSet.has(tagName)) throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
|
|
47162
|
+
if (lastTagName && options.unpairedTagsSet.has(lastTagName)) {
|
|
47163
|
+
this.matcher.pop();
|
|
47164
|
+
this.tagsNodeStack.pop();
|
|
47165
|
+
}
|
|
47015
47166
|
this.matcher.pop();
|
|
47016
47167
|
this.isCurrentNodeStopNode = false;
|
|
47017
|
-
|
|
47168
|
+
currentNode = this.tagsNodeStack.pop();
|
|
47169
|
+
textData = "";
|
|
47170
|
+
i = closeIndex;
|
|
47171
|
+
} else if (c1 === 63) {
|
|
47172
|
+
let tagData = readTagExp(xmlData, i, false, "?>");
|
|
47173
|
+
if (!tagData) throw new Error("Pi Tag is not closed.");
|
|
47174
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
47175
|
+
if (options.ignoreDeclaration && tagData.tagName === "?xml" || options.ignorePiTags) {} else {
|
|
47176
|
+
const childNode = new XmlNode(tagData.tagName);
|
|
47177
|
+
childNode.add(options.textNodeName, "");
|
|
47178
|
+
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) childNode[":@"] = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName);
|
|
47179
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
|
47180
|
+
}
|
|
47181
|
+
i = tagData.closeIndex + 1;
|
|
47182
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
|
|
47183
|
+
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
|
|
47184
|
+
if (options.commentPropName) {
|
|
47185
|
+
const comment = xmlData.substring(i + 4, endIndex - 2);
|
|
47186
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
47187
|
+
currentNode.add(options.commentPropName, [{ [options.textNodeName]: comment }]);
|
|
47188
|
+
}
|
|
47189
|
+
i = endIndex;
|
|
47190
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 68) {
|
|
47191
|
+
const result = docTypeReader.readDocType(xmlData, i);
|
|
47192
|
+
this.docTypeEntities = result.entities;
|
|
47193
|
+
this.docTypeEntitiesKeys = Object.keys(this.docTypeEntities) || [];
|
|
47194
|
+
i = result.i;
|
|
47195
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
|
|
47196
|
+
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
47197
|
+
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
47198
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
47199
|
+
let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
|
|
47200
|
+
if (val == void 0) val = "";
|
|
47201
|
+
if (options.cdataPropName) currentNode.add(options.cdataPropName, [{ [options.textNodeName]: tagExp }]);
|
|
47202
|
+
else currentNode.add(options.textNodeName, val);
|
|
47203
|
+
i = closeIndex + 2;
|
|
47018
47204
|
} else {
|
|
47019
|
-
|
|
47020
|
-
|
|
47021
|
-
const
|
|
47022
|
-
|
|
47023
|
-
|
|
47205
|
+
let result = readTagExp(xmlData, i, options.removeNSPrefix);
|
|
47206
|
+
if (!result) {
|
|
47207
|
+
const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlLen, i + 50));
|
|
47208
|
+
throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
|
|
47209
|
+
}
|
|
47210
|
+
let tagName = result.tagName;
|
|
47211
|
+
const rawTagName = result.rawTagName;
|
|
47212
|
+
let tagExp = result.tagExp;
|
|
47213
|
+
let attrExpPresent = result.attrExpPresent;
|
|
47214
|
+
let closeIndex = result.closeIndex;
|
|
47215
|
+
({tagName, tagExp} = transformTagName(options.transformTagName, tagName, tagExp, options));
|
|
47216
|
+
if (options.strictReservedNames && (tagName === options.commentPropName || tagName === options.cdataPropName || tagName === options.textNodeName || tagName === options.attributesGroupName)) throw new Error(`Invalid tag name: ${tagName}`);
|
|
47217
|
+
if (currentNode && textData) {
|
|
47218
|
+
if (currentNode.tagname !== "!xml") textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
|
|
47219
|
+
}
|
|
47220
|
+
const lastTag = currentNode;
|
|
47221
|
+
if (lastTag && options.unpairedTagsSet.has(lastTag.tagname)) {
|
|
47222
|
+
currentNode = this.tagsNodeStack.pop();
|
|
47024
47223
|
this.matcher.pop();
|
|
47025
|
-
|
|
47026
|
-
|
|
47224
|
+
}
|
|
47225
|
+
let isSelfClosing = false;
|
|
47226
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
47227
|
+
isSelfClosing = true;
|
|
47228
|
+
if (tagName[tagName.length - 1] === "/") {
|
|
47229
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
47230
|
+
tagExp = tagName;
|
|
47231
|
+
} else tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
47232
|
+
attrExpPresent = tagName !== tagExp;
|
|
47233
|
+
}
|
|
47234
|
+
let prefixedAttrs = null;
|
|
47235
|
+
let namespace = void 0;
|
|
47236
|
+
namespace = extractNamespace(rawTagName);
|
|
47237
|
+
if (tagName !== xmlObj.tagname) this.matcher.push(tagName, {}, namespace);
|
|
47238
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
47239
|
+
prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
|
|
47240
|
+
if (prefixedAttrs) extractRawAttributes(prefixedAttrs, options);
|
|
47241
|
+
}
|
|
47242
|
+
if (tagName !== xmlObj.tagname) this.isCurrentNodeStopNode = this.isItStopNode();
|
|
47243
|
+
const startIndex = i;
|
|
47244
|
+
if (this.isCurrentNodeStopNode) {
|
|
47245
|
+
let tagContent = "";
|
|
47246
|
+
if (isSelfClosing) i = result.closeIndex;
|
|
47247
|
+
else if (options.unpairedTagsSet.has(tagName)) i = result.closeIndex;
|
|
47248
|
+
else {
|
|
47249
|
+
const result = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
47250
|
+
if (!result) throw new Error(`Unexpected end of ${rawTagName}`);
|
|
47251
|
+
i = result.i;
|
|
47252
|
+
tagContent = result.tagContent;
|
|
47253
|
+
}
|
|
47027
47254
|
const childNode = new XmlNode(tagName);
|
|
47028
47255
|
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47029
|
-
|
|
47256
|
+
childNode.add(options.textNodeName, tagContent);
|
|
47030
47257
|
this.matcher.pop();
|
|
47031
47258
|
this.isCurrentNodeStopNode = false;
|
|
47032
|
-
i = result.closeIndex;
|
|
47033
|
-
continue;
|
|
47034
|
-
} else {
|
|
47035
|
-
const childNode = new XmlNode(tagName);
|
|
47036
|
-
if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded");
|
|
47037
|
-
this.tagsNodeStack.push(currentNode);
|
|
47038
|
-
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47039
47259
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
47040
|
-
|
|
47260
|
+
} else {
|
|
47261
|
+
if (isSelfClosing) {
|
|
47262
|
+
({tagName, tagExp} = transformTagName(options.transformTagName, tagName, tagExp, options));
|
|
47263
|
+
const childNode = new XmlNode(tagName);
|
|
47264
|
+
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47265
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
47266
|
+
this.matcher.pop();
|
|
47267
|
+
this.isCurrentNodeStopNode = false;
|
|
47268
|
+
} else if (options.unpairedTagsSet.has(tagName)) {
|
|
47269
|
+
const childNode = new XmlNode(tagName);
|
|
47270
|
+
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47271
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
47272
|
+
this.matcher.pop();
|
|
47273
|
+
this.isCurrentNodeStopNode = false;
|
|
47274
|
+
i = result.closeIndex;
|
|
47275
|
+
continue;
|
|
47276
|
+
} else {
|
|
47277
|
+
const childNode = new XmlNode(tagName);
|
|
47278
|
+
if (this.tagsNodeStack.length > options.maxNestedTags) throw new Error("Maximum nested tags exceeded");
|
|
47279
|
+
this.tagsNodeStack.push(currentNode);
|
|
47280
|
+
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47281
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
47282
|
+
currentNode = childNode;
|
|
47283
|
+
}
|
|
47284
|
+
textData = "";
|
|
47285
|
+
i = closeIndex;
|
|
47041
47286
|
}
|
|
47042
|
-
textData = "";
|
|
47043
|
-
i = closeIndex;
|
|
47044
47287
|
}
|
|
47045
|
-
}
|
|
47046
|
-
else textData += xmlData[i];
|
|
47288
|
+
} else textData += xmlData[i];
|
|
47047
47289
|
return xmlObj.child;
|
|
47048
47290
|
};
|
|
47049
47291
|
function addChild(currentNode, childNode, matcher, startIndex) {
|
|
@@ -47071,7 +47313,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
|
|
|
47071
47313
|
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
47072
47314
|
if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) return val;
|
|
47073
47315
|
}
|
|
47074
|
-
for (const entityName of
|
|
47316
|
+
for (const entityName of this.docTypeEntitiesKeys) {
|
|
47075
47317
|
const entity = this.docTypeEntities[entityName];
|
|
47076
47318
|
const matches = val.match(entity.regx);
|
|
47077
47319
|
if (matches) {
|
|
@@ -47086,7 +47328,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
|
|
|
47086
47328
|
}
|
|
47087
47329
|
}
|
|
47088
47330
|
if (val.indexOf("&") === -1) return val;
|
|
47089
|
-
for (const entityName of
|
|
47331
|
+
for (const entityName of this.lastEntitiesKeys) {
|
|
47090
47332
|
const entity = this.lastEntities[entityName];
|
|
47091
47333
|
const matches = val.match(entity.regex);
|
|
47092
47334
|
if (matches) {
|
|
@@ -47096,7 +47338,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
|
|
|
47096
47338
|
val = val.replace(entity.regex, entity.val);
|
|
47097
47339
|
}
|
|
47098
47340
|
if (val.indexOf("&") === -1) return val;
|
|
47099
|
-
|
|
47341
|
+
for (const entityName of this.htmlEntitiesKeys) {
|
|
47100
47342
|
const entity = this.htmlEntities[entityName];
|
|
47101
47343
|
const matches = val.match(entity.regex);
|
|
47102
47344
|
if (matches) {
|
|
@@ -47121,10 +47363,9 @@ function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
|
|
|
47121
47363
|
* @param {Array<Expression>} stopNodeExpressions - Array of compiled Expression objects
|
|
47122
47364
|
* @param {Matcher} matcher - Current path matcher
|
|
47123
47365
|
*/
|
|
47124
|
-
function isItStopNode(
|
|
47125
|
-
if (
|
|
47126
|
-
|
|
47127
|
-
return false;
|
|
47366
|
+
function isItStopNode() {
|
|
47367
|
+
if (this.stopNodeExpressionsSet.size === 0) return false;
|
|
47368
|
+
return this.matcher.matchesAny(this.stopNodeExpressionsSet);
|
|
47128
47369
|
}
|
|
47129
47370
|
/**
|
|
47130
47371
|
* Returns the tag Expression and where it is ending handling single-double quotes situation
|
|
@@ -47133,24 +47374,30 @@ function isItStopNode(stopNodeExpressions, matcher) {
|
|
|
47133
47374
|
* @returns
|
|
47134
47375
|
*/
|
|
47135
47376
|
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
|
|
47136
|
-
let attrBoundary;
|
|
47137
|
-
|
|
47138
|
-
|
|
47139
|
-
|
|
47377
|
+
let attrBoundary = 0;
|
|
47378
|
+
const chars = [];
|
|
47379
|
+
const len = xmlData.length;
|
|
47380
|
+
const closeCode0 = closingChar.charCodeAt(0);
|
|
47381
|
+
const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
|
|
47382
|
+
for (let index = i; index < len; index++) {
|
|
47383
|
+
const code = xmlData.charCodeAt(index);
|
|
47140
47384
|
if (attrBoundary) {
|
|
47141
|
-
if (
|
|
47142
|
-
} else if (
|
|
47143
|
-
else if (
|
|
47144
|
-
if (xmlData
|
|
47145
|
-
data:
|
|
47385
|
+
if (code === attrBoundary) attrBoundary = 0;
|
|
47386
|
+
} else if (code === 34 || code === 39) attrBoundary = code;
|
|
47387
|
+
else if (code === closeCode0) if (closeCode1 !== -1) {
|
|
47388
|
+
if (xmlData.charCodeAt(index + 1) === closeCode1) return {
|
|
47389
|
+
data: String.fromCharCode(...chars),
|
|
47146
47390
|
index
|
|
47147
47391
|
};
|
|
47148
47392
|
} else return {
|
|
47149
|
-
data:
|
|
47393
|
+
data: String.fromCharCode(...chars),
|
|
47150
47394
|
index
|
|
47151
47395
|
};
|
|
47152
|
-
else if (
|
|
47153
|
-
|
|
47396
|
+
else if (code === 9) {
|
|
47397
|
+
chars.push(32);
|
|
47398
|
+
continue;
|
|
47399
|
+
}
|
|
47400
|
+
chars.push(code);
|
|
47154
47401
|
}
|
|
47155
47402
|
}
|
|
47156
47403
|
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
@@ -47158,6 +47405,11 @@ function findClosingIndex(xmlData, str, i, errMsg) {
|
|
|
47158
47405
|
if (closingIndex === -1) throw new Error(errMsg);
|
|
47159
47406
|
else return closingIndex + str.length - 1;
|
|
47160
47407
|
}
|
|
47408
|
+
function findClosingChar(xmlData, char, i, errMsg) {
|
|
47409
|
+
const closingIndex = xmlData.indexOf(char, i);
|
|
47410
|
+
if (closingIndex === -1) throw new Error(errMsg);
|
|
47411
|
+
return closingIndex;
|
|
47412
|
+
}
|
|
47161
47413
|
function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
47162
47414
|
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
47163
47415
|
if (!result) return;
|
|
@@ -47195,24 +47447,28 @@ function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
|
47195
47447
|
function readStopNodeData(xmlData, tagName, i) {
|
|
47196
47448
|
const startIndex = i;
|
|
47197
47449
|
let openTagCount = 1;
|
|
47198
|
-
|
|
47199
|
-
|
|
47200
|
-
|
|
47201
|
-
|
|
47202
|
-
|
|
47203
|
-
|
|
47204
|
-
|
|
47205
|
-
|
|
47206
|
-
|
|
47207
|
-
|
|
47208
|
-
|
|
47209
|
-
|
|
47210
|
-
|
|
47211
|
-
|
|
47212
|
-
|
|
47213
|
-
if (
|
|
47214
|
-
|
|
47215
|
-
|
|
47450
|
+
const xmllen = xmlData.length;
|
|
47451
|
+
for (; i < xmllen; i++) if (xmlData[i] === "<") {
|
|
47452
|
+
const c1 = xmlData.charCodeAt(i + 1);
|
|
47453
|
+
if (c1 === 47) {
|
|
47454
|
+
const closeIndex = findClosingChar(xmlData, ">", i, `${tagName} is not closed`);
|
|
47455
|
+
if (xmlData.substring(i + 2, closeIndex).trim() === tagName) {
|
|
47456
|
+
openTagCount--;
|
|
47457
|
+
if (openTagCount === 0) return {
|
|
47458
|
+
tagContent: xmlData.substring(startIndex, i),
|
|
47459
|
+
i: closeIndex
|
|
47460
|
+
};
|
|
47461
|
+
}
|
|
47462
|
+
i = closeIndex;
|
|
47463
|
+
} else if (c1 === 63) i = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
|
|
47464
|
+
else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) i = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
|
|
47465
|
+
else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) i = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
|
47466
|
+
else {
|
|
47467
|
+
const tagData = readTagExp(xmlData, i, ">");
|
|
47468
|
+
if (tagData) {
|
|
47469
|
+
if ((tagData && tagData.tagName) === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") openTagCount++;
|
|
47470
|
+
i = tagData.closeIndex;
|
|
47471
|
+
}
|
|
47216
47472
|
}
|
|
47217
47473
|
}
|
|
47218
47474
|
}
|
|
@@ -53257,7 +53513,7 @@ var NTQQMsgApi = class extends Service2 {
|
|
|
53257
53513
|
filterSendersUid,
|
|
53258
53514
|
filterMsgToTime: filterMsgTime,
|
|
53259
53515
|
filterMsgFromTime: filterMsgTime,
|
|
53260
|
-
isReverseOrder:
|
|
53516
|
+
isReverseOrder: true,
|
|
53261
53517
|
isIncludeCurrent: true,
|
|
53262
53518
|
pageLimit: 1
|
|
53263
53519
|
}
|
|
@@ -53797,7 +54053,7 @@ var NTQQWebApi = class extends Service2 {
|
|
|
53797
54053
|
const iBatchID = Math.floor(Date.now() / 1e3);
|
|
53798
54054
|
for (let i = 0; i < filePathList.length; i++) {
|
|
53799
54055
|
const filePath = filePathList[i];
|
|
53800
|
-
const fileBuffer = await
|
|
54056
|
+
const fileBuffer = await fs.readFile(filePath);
|
|
53801
54057
|
const fileSize = fileBuffer.length;
|
|
53802
54058
|
const checksum = await getMd5HexFromFile(filePath);
|
|
53803
54059
|
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
@@ -54139,7 +54395,7 @@ async function authMiddleware(c, next) {
|
|
|
54139
54395
|
globalLoginAttempt.lockedUntil = null;
|
|
54140
54396
|
}
|
|
54141
54397
|
logAccess(clientIp, c.req.method, c.req.path, 200);
|
|
54142
|
-
next();
|
|
54398
|
+
await next();
|
|
54143
54399
|
}
|
|
54144
54400
|
//#endregion
|
|
54145
54401
|
//#region src/webui/BE/utils.ts
|
|
@@ -54758,7 +55014,6 @@ function createProxyRoutes(ctx) {
|
|
|
54758
55014
|
success: false,
|
|
54759
55015
|
message: "文件不存在"
|
|
54760
55016
|
}, 404);
|
|
54761
|
-
const ext = path$1.extname(normalizedPath).toLowerCase();
|
|
54762
55017
|
const contentType = {
|
|
54763
55018
|
".jpg": "image/jpeg",
|
|
54764
55019
|
".jpeg": "image/jpeg",
|
|
@@ -54767,7 +55022,7 @@ function createProxyRoutes(ctx) {
|
|
|
54767
55022
|
".webp": "image/webp",
|
|
54768
55023
|
".mp4": "video/mp4",
|
|
54769
55024
|
".webm": "video/webm"
|
|
54770
|
-
}[
|
|
55025
|
+
}[path$1.extname(normalizedPath).toLowerCase()] || "application/octet-stream";
|
|
54771
55026
|
c.header("Content-Type", contentType);
|
|
54772
55027
|
c.header("Cache-Control", "public, max-age=86400");
|
|
54773
55028
|
return c.body(await readFile(normalizedPath));
|
|
@@ -55479,7 +55734,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
55479
55734
|
if (optionPath) filename = optionPath;
|
|
55480
55735
|
else try {
|
|
55481
55736
|
filename = tryDecodeURI(c.req.path);
|
|
55482
|
-
if (/(?:^|[\/\\])
|
|
55737
|
+
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) throw new Error();
|
|
55483
55738
|
} catch {
|
|
55484
55739
|
await options.onNotFound?.(c.req.path, c);
|
|
55485
55740
|
return next();
|
|
@@ -55582,7 +55837,7 @@ var WebUIServer = class extends Service2 {
|
|
|
55582
55837
|
});
|
|
55583
55838
|
}
|
|
55584
55839
|
initServer() {
|
|
55585
|
-
this.app.use("/api", authMiddleware);
|
|
55840
|
+
this.app.use("/api/*", authMiddleware);
|
|
55586
55841
|
this.app.route("/api", createConfigRoutes(this.ctx));
|
|
55587
55842
|
this.app.route("/api", createLoginRoutes(this.ctx));
|
|
55588
55843
|
this.app.route("/api", createDashboardRoutes(this.ctx));
|
|
@@ -56023,7 +56278,7 @@ var package_exports = /* @__PURE__ */ __exportAll({
|
|
|
56023
56278
|
var name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, engines, package_default;
|
|
56024
56279
|
var init_package = __esmMin((() => {
|
|
56025
56280
|
name = "nodemailer";
|
|
56026
|
-
version = "8.0.
|
|
56281
|
+
version = "8.0.5";
|
|
56027
56282
|
description = "Easy as cake e-mail sending from your Node.js applications";
|
|
56028
56283
|
main = "lib/nodemailer.js";
|
|
56029
56284
|
scripts = {
|
|
@@ -56046,10 +56301,10 @@ var init_package = __esmMin((() => {
|
|
|
56046
56301
|
bugs = { "url": "https://github.com/nodemailer/nodemailer/issues" };
|
|
56047
56302
|
homepage = "https://nodemailer.com/";
|
|
56048
56303
|
devDependencies = {
|
|
56049
|
-
"@aws-sdk/client-sesv2": "3.
|
|
56304
|
+
"@aws-sdk/client-sesv2": "3.1025.0",
|
|
56050
56305
|
"bunyan": "1.8.15",
|
|
56051
56306
|
"c8": "11.0.0",
|
|
56052
|
-
"eslint": "10.0
|
|
56307
|
+
"eslint": "10.2.0",
|
|
56053
56308
|
"eslint-config-prettier": "10.1.8",
|
|
56054
56309
|
"globals": "17.4.0",
|
|
56055
56310
|
"libbase64": "1.3.0",
|
|
@@ -56059,7 +56314,7 @@ var init_package = __esmMin((() => {
|
|
|
56059
56314
|
"prettier": "3.8.1",
|
|
56060
56315
|
"proxy": "1.0.2",
|
|
56061
56316
|
"proxy-test-server": "1.0.0",
|
|
56062
|
-
"smtp-server": "3.18.
|
|
56317
|
+
"smtp-server": "3.18.3"
|
|
56063
56318
|
};
|
|
56064
56319
|
engines = { "node": ">=6.0.0" };
|
|
56065
56320
|
package_default = {
|
|
@@ -56323,7 +56578,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
56323
56578
|
var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
56324
56579
|
var urllib$2 = __require("url");
|
|
56325
56580
|
var util$1 = __require("util");
|
|
56326
|
-
var fs$
|
|
56581
|
+
var fs$5 = __require("fs");
|
|
56327
56582
|
var nmfetch = require_fetch();
|
|
56328
56583
|
var dns$1 = __require("dns");
|
|
56329
56584
|
var net$4 = __require("net");
|
|
@@ -56659,7 +56914,7 @@ var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
56659
56914
|
const parsedDataUri = module.exports.parseDataURI(content.path || content.href);
|
|
56660
56915
|
if (!parsedDataUri || !parsedDataUri.data) return callback(null, Buffer.from(0));
|
|
56661
56916
|
return callback(null, parsedDataUri.data);
|
|
56662
|
-
} else if (content.path) return resolveStream(fs$
|
|
56917
|
+
} else if (content.path) return resolveStream(fs$5.createReadStream(content.path), callback);
|
|
56663
56918
|
}
|
|
56664
56919
|
if (typeof data[key].content === "string" && ![
|
|
56665
56920
|
"utf8",
|
|
@@ -60485,7 +60740,7 @@ var require_le_unix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
60485
60740
|
//#region node_modules/nodemailer/lib/mime-node/index.js
|
|
60486
60741
|
var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
60487
60742
|
var crypto$9 = __require("crypto");
|
|
60488
|
-
var fs$
|
|
60743
|
+
var fs$4 = __require("fs");
|
|
60489
60744
|
var punycode = require_punycode();
|
|
60490
60745
|
var { PassThrough: PassThrough$2 } = __require("stream");
|
|
60491
60746
|
var shared = require_shared();
|
|
@@ -61194,7 +61449,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61194
61449
|
});
|
|
61195
61450
|
return contentStream;
|
|
61196
61451
|
}
|
|
61197
|
-
return fs$
|
|
61452
|
+
return fs$4.createReadStream(content.path);
|
|
61198
61453
|
}
|
|
61199
61454
|
if (content && typeof content.href === "string") {
|
|
61200
61455
|
if (this.disableUrlAccess) {
|
|
@@ -62032,7 +62287,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62032
62287
|
var RelaxedBody = require_relaxed_body();
|
|
62033
62288
|
var sign = require_sign();
|
|
62034
62289
|
var { PassThrough: PassThrough$1 } = __require("stream");
|
|
62035
|
-
var fs$
|
|
62290
|
+
var fs$3 = __require("fs");
|
|
62036
62291
|
var path$2 = __require("path");
|
|
62037
62292
|
var crypto$6 = __require("crypto");
|
|
62038
62293
|
var DKIM_ALGO = "sha256";
|
|
@@ -62065,10 +62320,10 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62065
62320
|
}
|
|
62066
62321
|
cleanup() {
|
|
62067
62322
|
if (!this.cache || !this.cachePath) return;
|
|
62068
|
-
fs$
|
|
62323
|
+
fs$3.unlink(this.cachePath, () => false);
|
|
62069
62324
|
}
|
|
62070
62325
|
createReadCache() {
|
|
62071
|
-
this.cache = fs$
|
|
62326
|
+
this.cache = fs$3.createReadStream(this.cachePath);
|
|
62072
62327
|
this.cache.once("error", (err) => {
|
|
62073
62328
|
this.cleanup();
|
|
62074
62329
|
this.output.emit("error", err);
|
|
@@ -62114,7 +62369,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62114
62369
|
}
|
|
62115
62370
|
createWriteCache() {
|
|
62116
62371
|
this.output.usingCache = true;
|
|
62117
|
-
this.cache = fs$
|
|
62372
|
+
this.cache = fs$3.createWriteStream(this.cachePath);
|
|
62118
62373
|
this.cache.once("error", (err) => {
|
|
62119
62374
|
this.cleanup();
|
|
62120
62375
|
this.relaxedBody.unpipe(this.cache);
|
|
@@ -62874,6 +63129,22 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
62874
63129
|
var DNS_TIMEOUT = 30 * 1e3;
|
|
62875
63130
|
var TEARDOWN_NOOP = () => {};
|
|
62876
63131
|
/**
|
|
63132
|
+
* Re-interpret a server response stored in fake 8-bit byte-container form
|
|
63133
|
+
* (the result of chunk.toString('binary') in _onData) as UTF-8.
|
|
63134
|
+
*
|
|
63135
|
+
* Server reply text has no formally defined charset (RFC 5321 §4.2.1), but
|
|
63136
|
+
* modern MTAs commonly use UTF-8. The byte-container plumbing in _onData is
|
|
63137
|
+
* required to reassemble multi-byte sequences split across socket chunks;
|
|
63138
|
+
* this helper performs the actual decode at the line boundary, falling back
|
|
63139
|
+
* to the byte-container form when the bytes are not valid UTF-8 so that
|
|
63140
|
+
* legacy 8-bit replies are still recoverable byte-for-byte.
|
|
63141
|
+
*/
|
|
63142
|
+
function decodeServerResponse(str) {
|
|
63143
|
+
if (!str) return str;
|
|
63144
|
+
const utf8 = Buffer.from(str, "binary").toString("utf8");
|
|
63145
|
+
return utf8.includes("�") ? str : utf8;
|
|
63146
|
+
}
|
|
63147
|
+
/**
|
|
62877
63148
|
* Generates a SMTP connection object
|
|
62878
63149
|
*
|
|
62879
63150
|
* Optional options object takes the following possible properties:
|
|
@@ -62913,7 +63184,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
62913
63184
|
this.servername = this.options.servername ? this.options.servername : !net$1.isIP(this.host) ? this.host : false;
|
|
62914
63185
|
this.allowInternalNetworkInterfaces = this.options.allowInternalNetworkInterfaces || false;
|
|
62915
63186
|
if (typeof this.options.secure === "undefined" && this.port === 465) this.secureConnection = true;
|
|
62916
|
-
this.name = this.options.name || this._getHostname();
|
|
63187
|
+
this.name = (this.options.name || this._getHostname()).toString().replace(/[\r\n]+/g, "");
|
|
62917
63188
|
this.logger = shared.getLogger(this.options, {
|
|
62918
63189
|
component: this.options.component || "smtp-connection",
|
|
62919
63190
|
sid: this.id
|
|
@@ -63465,8 +63736,8 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
63465
63736
|
_onClose() {
|
|
63466
63737
|
let serverResponse = false;
|
|
63467
63738
|
if (this._remainder && this._remainder.trim()) {
|
|
63468
|
-
|
|
63469
|
-
this.
|
|
63739
|
+
this.lastServerResponse = serverResponse = decodeServerResponse(this._remainder.trim());
|
|
63740
|
+
if (this.options.debug || this.options.transactionLog) this.logger.debug({ tnx: "server" }, serverResponse);
|
|
63470
63741
|
}
|
|
63471
63742
|
this.logger.info({ tnx: "network" }, "Connection closed");
|
|
63472
63743
|
if (this.upgrading && !this._destroyed) return this._onError(/* @__PURE__ */ new Error("Connection closed unexpectedly"), "ETLS", serverResponse, "CONN");
|
|
@@ -63541,7 +63812,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
63541
63812
|
*/
|
|
63542
63813
|
_processResponse() {
|
|
63543
63814
|
if (!this._responseQueue.length) return false;
|
|
63544
|
-
let str = this.lastServerResponse = (this._responseQueue.shift() || "").toString();
|
|
63815
|
+
let str = this.lastServerResponse = decodeServerResponse((this._responseQueue.shift() || "").toString());
|
|
63545
63816
|
if (/^\d+-/.test(str.split("\n").pop())) return;
|
|
63546
63817
|
if (this.options.debug || this.options.transactionLog) this.logger.debug({ tnx: "server" }, str.replace(/\r?\n$/, ""));
|
|
63547
63818
|
if (!str.trim()) setImmediate(() => this._processResponse());
|