llonebot-dist 7.11.2 → 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];
|
|
@@ -24804,7 +24804,10 @@ var OB11Http = class {
|
|
|
24804
24804
|
async handleRequest(c, next) {
|
|
24805
24805
|
let payload;
|
|
24806
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
|
|
24807
|
+
else {
|
|
24808
|
+
const text = await c.req.text();
|
|
24809
|
+
payload = text ? JSON.parse(text) : {};
|
|
24810
|
+
}
|
|
24808
24811
|
else payload = c.req.query();
|
|
24809
24812
|
this.ctx.logger.info("收到 HTTP 请求", c.req.url, payload);
|
|
24810
24813
|
const actionName = c.req.param("endpoint");
|
|
@@ -24980,6 +24983,7 @@ var ActionName = /* @__PURE__ */ function(ActionName) {
|
|
|
24980
24983
|
ActionName["GetDoubtFriendsAddRequest"] = "get_doubt_friends_add_request";
|
|
24981
24984
|
ActionName["SetDoubtFriendsAddRequest"] = "set_doubt_friends_add_request";
|
|
24982
24985
|
ActionName["DeleteGroupNotice"] = "_delete_group_notice";
|
|
24986
|
+
ActionName["SendPoke"] = "send_poke";
|
|
24983
24987
|
ActionName["SendLike"] = "send_like";
|
|
24984
24988
|
ActionName["GetLoginInfo"] = "get_login_info";
|
|
24985
24989
|
ActionName["GetFriendList"] = "get_friend_list";
|
|
@@ -26267,17 +26271,17 @@ var DownloadFile = class extends BaseAction {
|
|
|
26267
26271
|
const isRandomName = !payload.name;
|
|
26268
26272
|
const name = payload.name ? path.basename(payload.name) : randomUUID();
|
|
26269
26273
|
const filePath = path.join(TEMP_DIR, name);
|
|
26270
|
-
if (payload.base64) await fsPromise
|
|
26274
|
+
if (payload.base64) await fsPromise.writeFile(filePath, payload.base64, "base64");
|
|
26271
26275
|
else if (payload.url) {
|
|
26272
26276
|
const headers = this.getHeaders(payload.headers);
|
|
26273
26277
|
const res = await fetchFile(payload.url, headers);
|
|
26274
|
-
await fsPromise
|
|
26278
|
+
await fsPromise.writeFile(filePath, res.data);
|
|
26275
26279
|
} else throw new Error("不存在任何文件, 无法下载");
|
|
26276
|
-
if (fs.existsSync(filePath)) {
|
|
26280
|
+
if (fs$1.existsSync(filePath)) {
|
|
26277
26281
|
if (isRandomName) {
|
|
26278
26282
|
const md5 = await getMd5HexFromFile(filePath);
|
|
26279
26283
|
const newPath = path.join(TEMP_DIR, md5);
|
|
26280
|
-
await fsPromise
|
|
26284
|
+
await fsPromise.rename(filePath, newPath);
|
|
26281
26285
|
return { file: newPath };
|
|
26282
26286
|
}
|
|
26283
26287
|
return { file: filePath };
|
|
@@ -27176,9 +27180,12 @@ var GroupPoke = class extends BaseAction {
|
|
|
27176
27180
|
//#region src/onebot11/action/llbot/user/FriendPoke.ts
|
|
27177
27181
|
var FriendPoke = class extends BaseAction {
|
|
27178
27182
|
actionName = ActionName.FriendPoke;
|
|
27179
|
-
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
|
+
});
|
|
27180
27187
|
async _handle(payload) {
|
|
27181
|
-
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);
|
|
27182
27189
|
return null;
|
|
27183
27190
|
}
|
|
27184
27191
|
};
|
|
@@ -27916,6 +27923,21 @@ var ScanQRCode = class extends BaseAction {
|
|
|
27916
27923
|
}
|
|
27917
27924
|
};
|
|
27918
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
|
|
27919
27941
|
//#region src/onebot11/action/index.ts
|
|
27920
27942
|
function initActionMap(adapter) {
|
|
27921
27943
|
const actionHandlers = [
|
|
@@ -27968,6 +27990,7 @@ function initActionMap(adapter) {
|
|
|
27968
27990
|
new GetDoubtFriendsAddRequest(adapter),
|
|
27969
27991
|
new SetDoubtFriendsAddRequest(adapter),
|
|
27970
27992
|
new DeleteGroupNotice(adapter),
|
|
27993
|
+
new SendPoke(adapter),
|
|
27971
27994
|
new SendLike(adapter),
|
|
27972
27995
|
new GetMsg(adapter),
|
|
27973
27996
|
new GetLoginInfo$1(adapter),
|
|
@@ -29313,7 +29336,7 @@ async function decodeElement(ctx, data, quoted = false) {
|
|
|
29313
29336
|
try {
|
|
29314
29337
|
const { replayMsgSeq, replyMsgTime, sourceMsgIdInRecords, senderUidStr } = v.replyElement;
|
|
29315
29338
|
const record = data.records.find((msgRecord) => msgRecord.msgId === sourceMsgIdInRecords);
|
|
29316
|
-
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, [senderUidStr]);
|
|
29339
|
+
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, senderUidStr ? [senderUidStr] : []);
|
|
29317
29340
|
let replyMsg;
|
|
29318
29341
|
if (record && record.msgRandom !== "0") replyMsg = msgList.find((msg) => msg.msgRandom === record.msgRandom);
|
|
29319
29342
|
else replyMsg = msgList[0];
|
|
@@ -44857,7 +44880,7 @@ async function download(url, headers) {
|
|
|
44857
44880
|
return Buffer.from(bytes);
|
|
44858
44881
|
}
|
|
44859
44882
|
async function resolveMilkyUri(uri) {
|
|
44860
|
-
if (uri.startsWith("file://")) return await
|
|
44883
|
+
if (uri.startsWith("file://")) return await fs.readFile(fileURLToPath(uri));
|
|
44861
44884
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return await download(uri);
|
|
44862
44885
|
if (uri.startsWith("base64://")) return Buffer.from(uri.slice(9), "base64");
|
|
44863
44886
|
throw new Error(`Unsupported URI scheme: ${uri}`);
|
|
@@ -45816,6 +45839,7 @@ var buildOptions = function(options) {
|
|
|
45816
45839
|
for (const { value, name } of propertyNameOptions) if (value) validatePropertyName(value, name);
|
|
45817
45840
|
if (built.onDangerousProperty === null) built.onDangerousProperty = defaultOnDangerousProperty;
|
|
45818
45841
|
built.processEntities = normalizeProcessEntities(built.processEntities);
|
|
45842
|
+
built.unpairedTagsSet = new Set(built.unpairedTags);
|
|
45819
45843
|
if (built.stopNodes && Array.isArray(built.stopNodes)) built.stopNodes = built.stopNodes.map((node) => {
|
|
45820
45844
|
if (typeof node === "string" && node.startsWith("*.")) return ".." + node.substring(2);
|
|
45821
45845
|
return node;
|
|
@@ -46206,10 +46230,11 @@ var Expression = class {
|
|
|
46206
46230
|
* @param {Object} options - Configuration options
|
|
46207
46231
|
* @param {string} options.separator - Path separator (default: '.')
|
|
46208
46232
|
*/
|
|
46209
|
-
constructor(pattern, options = {}) {
|
|
46233
|
+
constructor(pattern, options = {}, data) {
|
|
46210
46234
|
this.pattern = pattern;
|
|
46211
46235
|
this.separator = options.separator || ".";
|
|
46212
46236
|
this.segments = this._parse(pattern);
|
|
46237
|
+
this.data = data;
|
|
46213
46238
|
this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
|
|
46214
46239
|
this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
|
|
46215
46240
|
this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
|
|
@@ -46339,6 +46364,179 @@ var Expression = class {
|
|
|
46339
46364
|
}
|
|
46340
46365
|
};
|
|
46341
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
|
|
46342
46540
|
//#region node_modules/path-expression-matcher/src/Matcher.js
|
|
46343
46541
|
/**
|
|
46344
46542
|
* Matcher - Tracks current path in XML/JSON tree and matches against Expressions
|
|
@@ -46378,6 +46576,9 @@ var Matcher = class {
|
|
|
46378
46576
|
this.separator = options.separator || ".";
|
|
46379
46577
|
this.path = [];
|
|
46380
46578
|
this.siblingStacks = [];
|
|
46579
|
+
this._pathStringCache = null;
|
|
46580
|
+
this._frozenPathCache = null;
|
|
46581
|
+
this._frozenSiblingsCache = null;
|
|
46381
46582
|
}
|
|
46382
46583
|
/**
|
|
46383
46584
|
* Push a new tag onto the path
|
|
@@ -46387,6 +46588,8 @@ var Matcher = class {
|
|
|
46387
46588
|
*/
|
|
46388
46589
|
push(tagName, attrValues = null, namespace = null) {
|
|
46389
46590
|
this._pathStringCache = null;
|
|
46591
|
+
this._frozenPathCache = null;
|
|
46592
|
+
this._frozenSiblingsCache = null;
|
|
46390
46593
|
if (this.path.length > 0) {
|
|
46391
46594
|
const prev = this.path[this.path.length - 1];
|
|
46392
46595
|
prev.values = void 0;
|
|
@@ -46413,8 +46616,10 @@ var Matcher = class {
|
|
|
46413
46616
|
* @returns {Object|undefined} The popped node
|
|
46414
46617
|
*/
|
|
46415
46618
|
pop() {
|
|
46416
|
-
if (this.path.length === 0) return;
|
|
46619
|
+
if (this.path.length === 0) return void 0;
|
|
46417
46620
|
this._pathStringCache = null;
|
|
46621
|
+
this._frozenPathCache = null;
|
|
46622
|
+
this._frozenSiblingsCache = null;
|
|
46418
46623
|
const node = this.path.pop();
|
|
46419
46624
|
if (this.siblingStacks.length > this.path.length + 1) this.siblingStacks.length = this.path.length + 1;
|
|
46420
46625
|
return node;
|
|
@@ -46427,7 +46632,10 @@ var Matcher = class {
|
|
|
46427
46632
|
updateCurrent(attrValues) {
|
|
46428
46633
|
if (this.path.length > 0) {
|
|
46429
46634
|
const current = this.path[this.path.length - 1];
|
|
46430
|
-
if (attrValues !== null && attrValues !== void 0)
|
|
46635
|
+
if (attrValues !== null && attrValues !== void 0) {
|
|
46636
|
+
current.values = attrValues;
|
|
46637
|
+
this._frozenPathCache = null;
|
|
46638
|
+
}
|
|
46431
46639
|
}
|
|
46432
46640
|
}
|
|
46433
46641
|
/**
|
|
@@ -46522,6 +46730,8 @@ var Matcher = class {
|
|
|
46522
46730
|
*/
|
|
46523
46731
|
reset() {
|
|
46524
46732
|
this._pathStringCache = null;
|
|
46733
|
+
this._frozenPathCache = null;
|
|
46734
|
+
this._frozenSiblingsCache = null;
|
|
46525
46735
|
this.path = [];
|
|
46526
46736
|
this.siblingStacks = [];
|
|
46527
46737
|
}
|
|
@@ -46617,6 +46827,14 @@ var Matcher = class {
|
|
|
46617
46827
|
return true;
|
|
46618
46828
|
}
|
|
46619
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
|
+
/**
|
|
46620
46838
|
* Create a snapshot of current state
|
|
46621
46839
|
* @returns {Object} State snapshot
|
|
46622
46840
|
*/
|
|
@@ -46632,6 +46850,8 @@ var Matcher = class {
|
|
|
46632
46850
|
*/
|
|
46633
46851
|
restore(snapshot) {
|
|
46634
46852
|
this._pathStringCache = null;
|
|
46853
|
+
this._frozenPathCache = null;
|
|
46854
|
+
this._frozenSiblingsCache = null;
|
|
46635
46855
|
this.path = snapshot.path.map((node) => ({ ...node }));
|
|
46636
46856
|
this.siblingStacks = snapshot.siblingStacks.map((map) => new Map(map));
|
|
46637
46857
|
}
|
|
@@ -46662,8 +46882,15 @@ var Matcher = class {
|
|
|
46662
46882
|
if (MUTATING_METHODS.has(prop)) return () => {
|
|
46663
46883
|
throw new TypeError(`Cannot call '${prop}' on a read-only Matcher. Obtain a writable instance to mutate state.`);
|
|
46664
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
|
+
}
|
|
46665
46893
|
const value = Reflect.get(target, prop, receiver);
|
|
46666
|
-
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);
|
|
46667
46894
|
if (typeof value === "function") return value.bind(target);
|
|
46668
46895
|
return value;
|
|
46669
46896
|
},
|
|
@@ -46794,13 +47021,15 @@ var OrderedObjParser = class {
|
|
|
46794
47021
|
this.matcher = new Matcher();
|
|
46795
47022
|
this.readonlyMatcher = this.matcher.readOnly();
|
|
46796
47023
|
this.isCurrentNodeStopNode = false;
|
|
46797
|
-
|
|
46798
|
-
|
|
46799
|
-
|
|
46800
|
-
|
|
46801
|
-
|
|
46802
|
-
|
|
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);
|
|
46803
47031
|
}
|
|
47032
|
+
this.stopNodeExpressionsSet.seal();
|
|
46804
47033
|
}
|
|
46805
47034
|
}
|
|
46806
47035
|
};
|
|
@@ -46825,16 +47054,17 @@ function addExternalEntities(externalEntities) {
|
|
|
46825
47054
|
* @param {boolean} escapeEntities
|
|
46826
47055
|
*/
|
|
46827
47056
|
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
47057
|
+
const options = this.options;
|
|
46828
47058
|
if (val !== void 0) {
|
|
46829
|
-
if (
|
|
47059
|
+
if (options.trimValues && !dontTrim) val = val.trim();
|
|
46830
47060
|
if (val.length > 0) {
|
|
46831
47061
|
if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
|
|
46832
|
-
const jPathOrMatcher =
|
|
46833
|
-
const newval =
|
|
47062
|
+
const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
|
|
47063
|
+
const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
|
|
46834
47064
|
if (newval === null || newval === void 0) return val;
|
|
46835
47065
|
else if (typeof newval !== typeof val || newval !== val) return newval;
|
|
46836
|
-
else if (
|
|
46837
|
-
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);
|
|
46838
47068
|
else return val;
|
|
46839
47069
|
}
|
|
46840
47070
|
}
|
|
@@ -46850,7 +47080,8 @@ function resolveNameSpace(tagname) {
|
|
|
46850
47080
|
}
|
|
46851
47081
|
var attrsRegx = /* @__PURE__ */ new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
|
|
46852
47082
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
46853
|
-
|
|
47083
|
+
const options = this.options;
|
|
47084
|
+
if (options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
46854
47085
|
const matches = getAllMatches(attrStr, attrsRegx);
|
|
46855
47086
|
const len = matches.length;
|
|
46856
47087
|
const attrs = {};
|
|
@@ -46862,7 +47093,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
|
|
|
46862
47093
|
const oldVal = matches[i][4];
|
|
46863
47094
|
if (attrName.length && oldVal !== void 0) {
|
|
46864
47095
|
let val = oldVal;
|
|
46865
|
-
if (
|
|
47096
|
+
if (options.trimValues) val = val.trim();
|
|
46866
47097
|
val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
|
|
46867
47098
|
processedVals[i] = val;
|
|
46868
47099
|
rawAttrsForMatcher[attrName] = val;
|
|
@@ -46870,32 +47101,32 @@ function buildAttributesMap(attrStr, jPath, tagName) {
|
|
|
46870
47101
|
}
|
|
46871
47102
|
}
|
|
46872
47103
|
if (hasRawAttrs && typeof jPath === "object" && jPath.updateCurrent) jPath.updateCurrent(rawAttrsForMatcher);
|
|
46873
|
-
const jPathStr =
|
|
47104
|
+
const jPathStr = options.jPath ? jPath.toString() : this.readonlyMatcher;
|
|
46874
47105
|
let hasAttrs = false;
|
|
46875
47106
|
for (let i = 0; i < len; i++) {
|
|
46876
47107
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
46877
47108
|
if (this.ignoreAttributesFn(attrName, jPathStr)) continue;
|
|
46878
|
-
let aName =
|
|
47109
|
+
let aName = options.attributeNamePrefix + attrName;
|
|
46879
47110
|
if (attrName.length) {
|
|
46880
|
-
if (
|
|
46881
|
-
aName = sanitizeName(aName,
|
|
47111
|
+
if (options.transformAttributeName) aName = options.transformAttributeName(aName);
|
|
47112
|
+
aName = sanitizeName(aName, options);
|
|
46882
47113
|
if (matches[i][4] !== void 0) {
|
|
46883
47114
|
const oldVal = processedVals[i];
|
|
46884
|
-
const newVal =
|
|
47115
|
+
const newVal = options.attributeValueProcessor(attrName, oldVal, jPathStr);
|
|
46885
47116
|
if (newVal === null || newVal === void 0) attrs[aName] = oldVal;
|
|
46886
47117
|
else if (typeof newVal !== typeof oldVal || newVal !== oldVal) attrs[aName] = newVal;
|
|
46887
|
-
else attrs[aName] = parseValue(oldVal,
|
|
47118
|
+
else attrs[aName] = parseValue(oldVal, options.parseAttributeValue, options.numberParseOptions);
|
|
46888
47119
|
hasAttrs = true;
|
|
46889
|
-
} else if (
|
|
47120
|
+
} else if (options.allowBooleanAttributes) {
|
|
46890
47121
|
attrs[aName] = true;
|
|
46891
47122
|
hasAttrs = true;
|
|
46892
47123
|
}
|
|
46893
47124
|
}
|
|
46894
47125
|
}
|
|
46895
47126
|
if (!hasAttrs) return;
|
|
46896
|
-
if (
|
|
47127
|
+
if (options.attributesGroupName) {
|
|
46897
47128
|
const attrCollection = {};
|
|
46898
|
-
attrCollection[
|
|
47129
|
+
attrCollection[options.attributesGroupName] = attrs;
|
|
46899
47130
|
return attrCollection;
|
|
46900
47131
|
}
|
|
46901
47132
|
return attrs;
|
|
@@ -46909,144 +47140,152 @@ var parseXml = function(xmlData) {
|
|
|
46909
47140
|
this.matcher.reset();
|
|
46910
47141
|
this.entityExpansionCount = 0;
|
|
46911
47142
|
this.currentExpandedLength = 0;
|
|
46912
|
-
|
|
46913
|
-
|
|
46914
|
-
|
|
46915
|
-
|
|
46916
|
-
|
|
46917
|
-
|
|
46918
|
-
|
|
46919
|
-
|
|
46920
|
-
|
|
46921
|
-
|
|
46922
|
-
|
|
46923
|
-
|
|
46924
|
-
|
|
46925
|
-
|
|
46926
|
-
|
|
46927
|
-
|
|
46928
|
-
|
|
46929
|
-
|
|
46930
|
-
|
|
46931
|
-
|
|
46932
|
-
|
|
46933
|
-
|
|
46934
|
-
|
|
46935
|
-
if (!tagData) throw new Error("Pi Tag is not closed.");
|
|
46936
|
-
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
46937
|
-
if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) {} else {
|
|
46938
|
-
const childNode = new XmlNode(tagData.tagName);
|
|
46939
|
-
childNode.add(this.options.textNodeName, "");
|
|
46940
|
-
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) childNode[":@"] = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName);
|
|
46941
|
-
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
|
46942
|
-
}
|
|
46943
|
-
i = tagData.closeIndex + 1;
|
|
46944
|
-
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
46945
|
-
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
|
|
46946
|
-
if (this.options.commentPropName) {
|
|
46947
|
-
const comment = xmlData.substring(i + 4, endIndex - 2);
|
|
46948
|
-
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
46949
|
-
currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
|
|
46950
|
-
}
|
|
46951
|
-
i = endIndex;
|
|
46952
|
-
} else if (xmlData.substr(i + 1, 2) === "!D") {
|
|
46953
|
-
const result = docTypeReader.readDocType(xmlData, i);
|
|
46954
|
-
this.docTypeEntities = result.entities;
|
|
46955
|
-
i = result.i;
|
|
46956
|
-
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
46957
|
-
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
46958
|
-
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
46959
|
-
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
46960
|
-
let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
|
|
46961
|
-
if (val == void 0) val = "";
|
|
46962
|
-
if (this.options.cdataPropName) currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
|
|
46963
|
-
else currentNode.add(this.options.textNodeName, val);
|
|
46964
|
-
i = closeIndex + 2;
|
|
46965
|
-
} else {
|
|
46966
|
-
let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
|
|
46967
|
-
if (!result) {
|
|
46968
|
-
const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlData.length, i + 50));
|
|
46969
|
-
throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
|
|
46970
|
-
}
|
|
46971
|
-
let tagName = result.tagName;
|
|
46972
|
-
const rawTagName = result.rawTagName;
|
|
46973
|
-
let tagExp = result.tagExp;
|
|
46974
|
-
let attrExpPresent = result.attrExpPresent;
|
|
46975
|
-
let closeIndex = result.closeIndex;
|
|
46976
|
-
({tagName, tagExp} = transformTagName(this.options.transformTagName, tagName, tagExp, this.options));
|
|
46977
|
-
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}`);
|
|
46978
|
-
if (currentNode && textData) {
|
|
46979
|
-
if (currentNode.tagname !== "!xml") textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
|
|
46980
|
-
}
|
|
46981
|
-
const lastTag = currentNode;
|
|
46982
|
-
if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
|
|
46983
|
-
currentNode = this.tagsNodeStack.pop();
|
|
46984
|
-
this.matcher.pop();
|
|
46985
|
-
}
|
|
46986
|
-
let isSelfClosing = false;
|
|
46987
|
-
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
46988
|
-
isSelfClosing = true;
|
|
46989
|
-
if (tagName[tagName.length - 1] === "/") {
|
|
46990
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
46991
|
-
tagExp = tagName;
|
|
46992
|
-
} else tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
46993
|
-
attrExpPresent = tagName !== tagExp;
|
|
46994
|
-
}
|
|
46995
|
-
let prefixedAttrs = null;
|
|
46996
|
-
let namespace = void 0;
|
|
46997
|
-
namespace = extractNamespace(rawTagName);
|
|
46998
|
-
if (tagName !== xmlObj.tagname) this.matcher.push(tagName, {}, namespace);
|
|
46999
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
47000
|
-
prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
|
|
47001
|
-
if (prefixedAttrs) extractRawAttributes(prefixedAttrs, this.options);
|
|
47002
|
-
}
|
|
47003
|
-
if (tagName !== xmlObj.tagname) this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher);
|
|
47004
|
-
const startIndex = i;
|
|
47005
|
-
if (this.isCurrentNodeStopNode) {
|
|
47006
|
-
let tagContent = "";
|
|
47007
|
-
if (isSelfClosing) i = result.closeIndex;
|
|
47008
|
-
else if (this.options.unpairedTags.indexOf(tagName) !== -1) i = result.closeIndex;
|
|
47009
|
-
else {
|
|
47010
|
-
const result = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
47011
|
-
if (!result) throw new Error(`Unexpected end of ${rawTagName}`);
|
|
47012
|
-
i = result.i;
|
|
47013
|
-
tagContent = result.tagContent;
|
|
47014
|
-
}
|
|
47015
|
-
const childNode = new XmlNode(tagName);
|
|
47016
|
-
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47017
|
-
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
|
+
}
|
|
47018
47166
|
this.matcher.pop();
|
|
47019
47167
|
this.isCurrentNodeStopNode = false;
|
|
47020
|
-
|
|
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;
|
|
47021
47204
|
} else {
|
|
47022
|
-
|
|
47023
|
-
|
|
47024
|
-
const
|
|
47025
|
-
|
|
47026
|
-
|
|
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();
|
|
47027
47223
|
this.matcher.pop();
|
|
47028
|
-
|
|
47029
|
-
|
|
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
|
+
}
|
|
47030
47254
|
const childNode = new XmlNode(tagName);
|
|
47031
47255
|
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47032
|
-
|
|
47256
|
+
childNode.add(options.textNodeName, tagContent);
|
|
47033
47257
|
this.matcher.pop();
|
|
47034
47258
|
this.isCurrentNodeStopNode = false;
|
|
47035
|
-
i = result.closeIndex;
|
|
47036
|
-
continue;
|
|
47037
|
-
} else {
|
|
47038
|
-
const childNode = new XmlNode(tagName);
|
|
47039
|
-
if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded");
|
|
47040
|
-
this.tagsNodeStack.push(currentNode);
|
|
47041
|
-
if (prefixedAttrs) childNode[":@"] = prefixedAttrs;
|
|
47042
47259
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
47043
|
-
|
|
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;
|
|
47044
47286
|
}
|
|
47045
|
-
textData = "";
|
|
47046
|
-
i = closeIndex;
|
|
47047
47287
|
}
|
|
47048
|
-
}
|
|
47049
|
-
else textData += xmlData[i];
|
|
47288
|
+
} else textData += xmlData[i];
|
|
47050
47289
|
return xmlObj.child;
|
|
47051
47290
|
};
|
|
47052
47291
|
function addChild(currentNode, childNode, matcher, startIndex) {
|
|
@@ -47074,7 +47313,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
|
|
|
47074
47313
|
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
47075
47314
|
if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) return val;
|
|
47076
47315
|
}
|
|
47077
|
-
for (const entityName of
|
|
47316
|
+
for (const entityName of this.docTypeEntitiesKeys) {
|
|
47078
47317
|
const entity = this.docTypeEntities[entityName];
|
|
47079
47318
|
const matches = val.match(entity.regx);
|
|
47080
47319
|
if (matches) {
|
|
@@ -47089,7 +47328,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
|
|
|
47089
47328
|
}
|
|
47090
47329
|
}
|
|
47091
47330
|
if (val.indexOf("&") === -1) return val;
|
|
47092
|
-
for (const entityName of
|
|
47331
|
+
for (const entityName of this.lastEntitiesKeys) {
|
|
47093
47332
|
const entity = this.lastEntities[entityName];
|
|
47094
47333
|
const matches = val.match(entity.regex);
|
|
47095
47334
|
if (matches) {
|
|
@@ -47099,7 +47338,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
|
|
|
47099
47338
|
val = val.replace(entity.regex, entity.val);
|
|
47100
47339
|
}
|
|
47101
47340
|
if (val.indexOf("&") === -1) return val;
|
|
47102
|
-
|
|
47341
|
+
for (const entityName of this.htmlEntitiesKeys) {
|
|
47103
47342
|
const entity = this.htmlEntities[entityName];
|
|
47104
47343
|
const matches = val.match(entity.regex);
|
|
47105
47344
|
if (matches) {
|
|
@@ -47124,10 +47363,9 @@ function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
|
|
|
47124
47363
|
* @param {Array<Expression>} stopNodeExpressions - Array of compiled Expression objects
|
|
47125
47364
|
* @param {Matcher} matcher - Current path matcher
|
|
47126
47365
|
*/
|
|
47127
|
-
function isItStopNode(
|
|
47128
|
-
if (
|
|
47129
|
-
|
|
47130
|
-
return false;
|
|
47366
|
+
function isItStopNode() {
|
|
47367
|
+
if (this.stopNodeExpressionsSet.size === 0) return false;
|
|
47368
|
+
return this.matcher.matchesAny(this.stopNodeExpressionsSet);
|
|
47131
47369
|
}
|
|
47132
47370
|
/**
|
|
47133
47371
|
* Returns the tag Expression and where it is ending handling single-double quotes situation
|
|
@@ -47136,24 +47374,30 @@ function isItStopNode(stopNodeExpressions, matcher) {
|
|
|
47136
47374
|
* @returns
|
|
47137
47375
|
*/
|
|
47138
47376
|
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
|
|
47139
|
-
let attrBoundary;
|
|
47140
|
-
|
|
47141
|
-
|
|
47142
|
-
|
|
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);
|
|
47143
47384
|
if (attrBoundary) {
|
|
47144
|
-
if (
|
|
47145
|
-
} else if (
|
|
47146
|
-
else if (
|
|
47147
|
-
if (xmlData
|
|
47148
|
-
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),
|
|
47149
47390
|
index
|
|
47150
47391
|
};
|
|
47151
47392
|
} else return {
|
|
47152
|
-
data:
|
|
47393
|
+
data: String.fromCharCode(...chars),
|
|
47153
47394
|
index
|
|
47154
47395
|
};
|
|
47155
|
-
else if (
|
|
47156
|
-
|
|
47396
|
+
else if (code === 9) {
|
|
47397
|
+
chars.push(32);
|
|
47398
|
+
continue;
|
|
47399
|
+
}
|
|
47400
|
+
chars.push(code);
|
|
47157
47401
|
}
|
|
47158
47402
|
}
|
|
47159
47403
|
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
@@ -47161,6 +47405,11 @@ function findClosingIndex(xmlData, str, i, errMsg) {
|
|
|
47161
47405
|
if (closingIndex === -1) throw new Error(errMsg);
|
|
47162
47406
|
else return closingIndex + str.length - 1;
|
|
47163
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
|
+
}
|
|
47164
47413
|
function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
47165
47414
|
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
47166
47415
|
if (!result) return;
|
|
@@ -47198,24 +47447,28 @@ function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
|
47198
47447
|
function readStopNodeData(xmlData, tagName, i) {
|
|
47199
47448
|
const startIndex = i;
|
|
47200
47449
|
let openTagCount = 1;
|
|
47201
|
-
|
|
47202
|
-
|
|
47203
|
-
|
|
47204
|
-
|
|
47205
|
-
|
|
47206
|
-
|
|
47207
|
-
|
|
47208
|
-
|
|
47209
|
-
|
|
47210
|
-
|
|
47211
|
-
|
|
47212
|
-
|
|
47213
|
-
|
|
47214
|
-
|
|
47215
|
-
|
|
47216
|
-
if (
|
|
47217
|
-
|
|
47218
|
-
|
|
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
|
+
}
|
|
47219
47472
|
}
|
|
47220
47473
|
}
|
|
47221
47474
|
}
|
|
@@ -53260,7 +53513,7 @@ var NTQQMsgApi = class extends Service2 {
|
|
|
53260
53513
|
filterSendersUid,
|
|
53261
53514
|
filterMsgToTime: filterMsgTime,
|
|
53262
53515
|
filterMsgFromTime: filterMsgTime,
|
|
53263
|
-
isReverseOrder:
|
|
53516
|
+
isReverseOrder: true,
|
|
53264
53517
|
isIncludeCurrent: true,
|
|
53265
53518
|
pageLimit: 1
|
|
53266
53519
|
}
|
|
@@ -53800,7 +54053,7 @@ var NTQQWebApi = class extends Service2 {
|
|
|
53800
54053
|
const iBatchID = Math.floor(Date.now() / 1e3);
|
|
53801
54054
|
for (let i = 0; i < filePathList.length; i++) {
|
|
53802
54055
|
const filePath = filePathList[i];
|
|
53803
|
-
const fileBuffer = await
|
|
54056
|
+
const fileBuffer = await fs.readFile(filePath);
|
|
53804
54057
|
const fileSize = fileBuffer.length;
|
|
53805
54058
|
const checksum = await getMd5HexFromFile(filePath);
|
|
53806
54059
|
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
@@ -54142,7 +54395,7 @@ async function authMiddleware(c, next) {
|
|
|
54142
54395
|
globalLoginAttempt.lockedUntil = null;
|
|
54143
54396
|
}
|
|
54144
54397
|
logAccess(clientIp, c.req.method, c.req.path, 200);
|
|
54145
|
-
next();
|
|
54398
|
+
await next();
|
|
54146
54399
|
}
|
|
54147
54400
|
//#endregion
|
|
54148
54401
|
//#region src/webui/BE/utils.ts
|
|
@@ -54761,7 +55014,6 @@ function createProxyRoutes(ctx) {
|
|
|
54761
55014
|
success: false,
|
|
54762
55015
|
message: "文件不存在"
|
|
54763
55016
|
}, 404);
|
|
54764
|
-
const ext = path$1.extname(normalizedPath).toLowerCase();
|
|
54765
55017
|
const contentType = {
|
|
54766
55018
|
".jpg": "image/jpeg",
|
|
54767
55019
|
".jpeg": "image/jpeg",
|
|
@@ -54770,7 +55022,7 @@ function createProxyRoutes(ctx) {
|
|
|
54770
55022
|
".webp": "image/webp",
|
|
54771
55023
|
".mp4": "video/mp4",
|
|
54772
55024
|
".webm": "video/webm"
|
|
54773
|
-
}[
|
|
55025
|
+
}[path$1.extname(normalizedPath).toLowerCase()] || "application/octet-stream";
|
|
54774
55026
|
c.header("Content-Type", contentType);
|
|
54775
55027
|
c.header("Cache-Control", "public, max-age=86400");
|
|
54776
55028
|
return c.body(await readFile(normalizedPath));
|
|
@@ -55482,7 +55734,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
55482
55734
|
if (optionPath) filename = optionPath;
|
|
55483
55735
|
else try {
|
|
55484
55736
|
filename = tryDecodeURI(c.req.path);
|
|
55485
|
-
if (/(?:^|[\/\\])
|
|
55737
|
+
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) throw new Error();
|
|
55486
55738
|
} catch {
|
|
55487
55739
|
await options.onNotFound?.(c.req.path, c);
|
|
55488
55740
|
return next();
|
|
@@ -55585,7 +55837,7 @@ var WebUIServer = class extends Service2 {
|
|
|
55585
55837
|
});
|
|
55586
55838
|
}
|
|
55587
55839
|
initServer() {
|
|
55588
|
-
this.app.use("/api", authMiddleware);
|
|
55840
|
+
this.app.use("/api/*", authMiddleware);
|
|
55589
55841
|
this.app.route("/api", createConfigRoutes(this.ctx));
|
|
55590
55842
|
this.app.route("/api", createLoginRoutes(this.ctx));
|
|
55591
55843
|
this.app.route("/api", createDashboardRoutes(this.ctx));
|
|
@@ -56026,7 +56278,7 @@ var package_exports = /* @__PURE__ */ __exportAll({
|
|
|
56026
56278
|
var name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, engines, package_default;
|
|
56027
56279
|
var init_package = __esmMin((() => {
|
|
56028
56280
|
name = "nodemailer";
|
|
56029
|
-
version = "8.0.
|
|
56281
|
+
version = "8.0.5";
|
|
56030
56282
|
description = "Easy as cake e-mail sending from your Node.js applications";
|
|
56031
56283
|
main = "lib/nodemailer.js";
|
|
56032
56284
|
scripts = {
|
|
@@ -56049,10 +56301,10 @@ var init_package = __esmMin((() => {
|
|
|
56049
56301
|
bugs = { "url": "https://github.com/nodemailer/nodemailer/issues" };
|
|
56050
56302
|
homepage = "https://nodemailer.com/";
|
|
56051
56303
|
devDependencies = {
|
|
56052
|
-
"@aws-sdk/client-sesv2": "3.
|
|
56304
|
+
"@aws-sdk/client-sesv2": "3.1025.0",
|
|
56053
56305
|
"bunyan": "1.8.15",
|
|
56054
56306
|
"c8": "11.0.0",
|
|
56055
|
-
"eslint": "10.0
|
|
56307
|
+
"eslint": "10.2.0",
|
|
56056
56308
|
"eslint-config-prettier": "10.1.8",
|
|
56057
56309
|
"globals": "17.4.0",
|
|
56058
56310
|
"libbase64": "1.3.0",
|
|
@@ -56062,7 +56314,7 @@ var init_package = __esmMin((() => {
|
|
|
56062
56314
|
"prettier": "3.8.1",
|
|
56063
56315
|
"proxy": "1.0.2",
|
|
56064
56316
|
"proxy-test-server": "1.0.0",
|
|
56065
|
-
"smtp-server": "3.18.
|
|
56317
|
+
"smtp-server": "3.18.3"
|
|
56066
56318
|
};
|
|
56067
56319
|
engines = { "node": ">=6.0.0" };
|
|
56068
56320
|
package_default = {
|
|
@@ -56326,7 +56578,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
56326
56578
|
var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
56327
56579
|
var urllib$2 = __require("url");
|
|
56328
56580
|
var util$1 = __require("util");
|
|
56329
|
-
var fs$
|
|
56581
|
+
var fs$5 = __require("fs");
|
|
56330
56582
|
var nmfetch = require_fetch();
|
|
56331
56583
|
var dns$1 = __require("dns");
|
|
56332
56584
|
var net$4 = __require("net");
|
|
@@ -56662,7 +56914,7 @@ var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
56662
56914
|
const parsedDataUri = module.exports.parseDataURI(content.path || content.href);
|
|
56663
56915
|
if (!parsedDataUri || !parsedDataUri.data) return callback(null, Buffer.from(0));
|
|
56664
56916
|
return callback(null, parsedDataUri.data);
|
|
56665
|
-
} else if (content.path) return resolveStream(fs$
|
|
56917
|
+
} else if (content.path) return resolveStream(fs$5.createReadStream(content.path), callback);
|
|
56666
56918
|
}
|
|
56667
56919
|
if (typeof data[key].content === "string" && ![
|
|
56668
56920
|
"utf8",
|
|
@@ -60488,7 +60740,7 @@ var require_le_unix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
60488
60740
|
//#region node_modules/nodemailer/lib/mime-node/index.js
|
|
60489
60741
|
var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
60490
60742
|
var crypto$9 = __require("crypto");
|
|
60491
|
-
var fs$
|
|
60743
|
+
var fs$4 = __require("fs");
|
|
60492
60744
|
var punycode = require_punycode();
|
|
60493
60745
|
var { PassThrough: PassThrough$2 } = __require("stream");
|
|
60494
60746
|
var shared = require_shared();
|
|
@@ -61197,7 +61449,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61197
61449
|
});
|
|
61198
61450
|
return contentStream;
|
|
61199
61451
|
}
|
|
61200
|
-
return fs$
|
|
61452
|
+
return fs$4.createReadStream(content.path);
|
|
61201
61453
|
}
|
|
61202
61454
|
if (content && typeof content.href === "string") {
|
|
61203
61455
|
if (this.disableUrlAccess) {
|
|
@@ -62035,7 +62287,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62035
62287
|
var RelaxedBody = require_relaxed_body();
|
|
62036
62288
|
var sign = require_sign();
|
|
62037
62289
|
var { PassThrough: PassThrough$1 } = __require("stream");
|
|
62038
|
-
var fs$
|
|
62290
|
+
var fs$3 = __require("fs");
|
|
62039
62291
|
var path$2 = __require("path");
|
|
62040
62292
|
var crypto$6 = __require("crypto");
|
|
62041
62293
|
var DKIM_ALGO = "sha256";
|
|
@@ -62068,10 +62320,10 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62068
62320
|
}
|
|
62069
62321
|
cleanup() {
|
|
62070
62322
|
if (!this.cache || !this.cachePath) return;
|
|
62071
|
-
fs$
|
|
62323
|
+
fs$3.unlink(this.cachePath, () => false);
|
|
62072
62324
|
}
|
|
62073
62325
|
createReadCache() {
|
|
62074
|
-
this.cache = fs$
|
|
62326
|
+
this.cache = fs$3.createReadStream(this.cachePath);
|
|
62075
62327
|
this.cache.once("error", (err) => {
|
|
62076
62328
|
this.cleanup();
|
|
62077
62329
|
this.output.emit("error", err);
|
|
@@ -62117,7 +62369,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62117
62369
|
}
|
|
62118
62370
|
createWriteCache() {
|
|
62119
62371
|
this.output.usingCache = true;
|
|
62120
|
-
this.cache = fs$
|
|
62372
|
+
this.cache = fs$3.createWriteStream(this.cachePath);
|
|
62121
62373
|
this.cache.once("error", (err) => {
|
|
62122
62374
|
this.cleanup();
|
|
62123
62375
|
this.relaxedBody.unpipe(this.cache);
|
|
@@ -62877,6 +63129,22 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
62877
63129
|
var DNS_TIMEOUT = 30 * 1e3;
|
|
62878
63130
|
var TEARDOWN_NOOP = () => {};
|
|
62879
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
|
+
/**
|
|
62880
63148
|
* Generates a SMTP connection object
|
|
62881
63149
|
*
|
|
62882
63150
|
* Optional options object takes the following possible properties:
|
|
@@ -62916,7 +63184,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
62916
63184
|
this.servername = this.options.servername ? this.options.servername : !net$1.isIP(this.host) ? this.host : false;
|
|
62917
63185
|
this.allowInternalNetworkInterfaces = this.options.allowInternalNetworkInterfaces || false;
|
|
62918
63186
|
if (typeof this.options.secure === "undefined" && this.port === 465) this.secureConnection = true;
|
|
62919
|
-
this.name = this.options.name || this._getHostname();
|
|
63187
|
+
this.name = (this.options.name || this._getHostname()).toString().replace(/[\r\n]+/g, "");
|
|
62920
63188
|
this.logger = shared.getLogger(this.options, {
|
|
62921
63189
|
component: this.options.component || "smtp-connection",
|
|
62922
63190
|
sid: this.id
|
|
@@ -63468,8 +63736,8 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
63468
63736
|
_onClose() {
|
|
63469
63737
|
let serverResponse = false;
|
|
63470
63738
|
if (this._remainder && this._remainder.trim()) {
|
|
63471
|
-
|
|
63472
|
-
this.
|
|
63739
|
+
this.lastServerResponse = serverResponse = decodeServerResponse(this._remainder.trim());
|
|
63740
|
+
if (this.options.debug || this.options.transactionLog) this.logger.debug({ tnx: "server" }, serverResponse);
|
|
63473
63741
|
}
|
|
63474
63742
|
this.logger.info({ tnx: "network" }, "Connection closed");
|
|
63475
63743
|
if (this.upgrading && !this._destroyed) return this._onError(/* @__PURE__ */ new Error("Connection closed unexpectedly"), "ETLS", serverResponse, "CONN");
|
|
@@ -63544,7 +63812,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
63544
63812
|
*/
|
|
63545
63813
|
_processResponse() {
|
|
63546
63814
|
if (!this._responseQueue.length) return false;
|
|
63547
|
-
let str = this.lastServerResponse = (this._responseQueue.shift() || "").toString();
|
|
63815
|
+
let str = this.lastServerResponse = decodeServerResponse((this._responseQueue.shift() || "").toString());
|
|
63548
63816
|
if (/^\d+-/.test(str.split("\n").pop())) return;
|
|
63549
63817
|
if (this.options.debug || this.options.transactionLog) this.logger.debug({ tnx: "server" }, str.replace(/\r?\n$/, ""));
|
|
63550
63818
|
if (!str.trim()) setImmediate(() => this._processResponse());
|