llonebot-dist 7.12.1 → 7.12.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 +1022 -248
- package/llbot.js.map +1 -1
- package/package.json +1 -1
- package/webui/assets/{index-CW4srXaj.css → index-BvJQpqZQ.css} +1 -1
- package/webui/assets/{index-CuYVu9u0.js → index-XoTA3kAm.js} +4 -4
- package/webui/index.html +2 -2
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +11 -4
package/llbot.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import * as path$4 from "node:path";
|
|
3
|
-
import path, { dirname } from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import fs, {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import fs$1, { appendFile, appendFileSync, createReadStream as createReadStream$1, existsSync as existsSync$1, mkdirSync, promises, stat as stat$1, watch } from "node:fs";
|
|
3
|
+
import path, { dirname, join } from "node:path";
|
|
4
|
+
import fs, { access, copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
|
|
5
|
+
import fs$1, { existsSync } from "fs";
|
|
6
|
+
import * as fs$6 from "node:fs";
|
|
7
|
+
import fs$2, { appendFile, appendFileSync, createReadStream, existsSync as existsSync$1, mkdirSync, promises, stat as stat$1, statSync, watch } from "node:fs";
|
|
9
8
|
import os from "node:os";
|
|
10
9
|
import { Binary, Time, camelize, clone, deduplicate, deepEqual, defineProperty, difference, filterKeys, hyphenate, is, isNonNullable, isNullable, isPlainObject, makeArray, mapValues, noop, omit, pick, remove, valueMap } from "cosmokit";
|
|
11
10
|
import { Exporter, Factory } from "reggol";
|
|
12
|
-
import path$1
|
|
11
|
+
import path$1 from "path";
|
|
13
12
|
import { networkInterfaces } from "os";
|
|
14
13
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
14
|
import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
@@ -17,17 +16,15 @@ import { constants } from "node:buffer";
|
|
|
17
16
|
import crypto$1, { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
18
17
|
import * as fileType from "file-type";
|
|
19
18
|
import { decode, encode, getDuration, getWavFileInfo, isSilk, isWav } from "silk-wasm";
|
|
20
|
-
import { createServer } from "http";
|
|
21
|
-
import { Http2ServerRequest, constants as constants$1 } from "http2";
|
|
22
|
-
import
|
|
19
|
+
import http, { STATUS_CODES, createServer, request } from "node:http";
|
|
20
|
+
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
21
|
+
import { Readable, Transform } from "node:stream";
|
|
23
22
|
import { deflateSync, gunzipSync, gzipSync, inflateSync } from "node:zlib";
|
|
24
|
-
import fsPromise
|
|
25
|
-
import http, { STATUS_CODES, request } from "node:http";
|
|
23
|
+
import fsPromise, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
|
|
26
24
|
import { inspect, isDeepStrictEqual } from "node:util";
|
|
27
|
-
import { Transform } from "node:stream";
|
|
28
25
|
import net, { connect } from "node:net";
|
|
29
26
|
import https from "node:https";
|
|
30
|
-
import { versions } from "process";
|
|
27
|
+
import { versions } from "node:process";
|
|
31
28
|
//#region \0rolldown/runtime.js
|
|
32
29
|
var __create$2 = Object.create;
|
|
33
30
|
var __defProp$9 = Object.defineProperty;
|
|
@@ -36,7 +33,7 @@ var __getOwnPropNames$2 = Object.getOwnPropertyNames;
|
|
|
36
33
|
var __getProtoOf = Object.getPrototypeOf;
|
|
37
34
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
38
35
|
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
39
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
40
37
|
var __exportAll = (all, no_symbols) => {
|
|
41
38
|
let target = {};
|
|
42
39
|
for (var name in all) __defProp$9(target, name, {
|
|
@@ -1623,6 +1620,9 @@ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1623
1620
|
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1624
1621
|
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
|
|
1625
1622
|
},
|
|
1623
|
+
/**
|
|
1624
|
+
* A very naive priority queue implementation.
|
|
1625
|
+
*/
|
|
1626
1626
|
PriorityQueue: {
|
|
1627
1627
|
make: function(opts) {
|
|
1628
1628
|
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
@@ -1635,6 +1635,10 @@ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1635
1635
|
default_sorter: function(a, b) {
|
|
1636
1636
|
return a.cost - b.cost;
|
|
1637
1637
|
},
|
|
1638
|
+
/**
|
|
1639
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1640
|
+
* is at the front of the queue.
|
|
1641
|
+
*/
|
|
1638
1642
|
push: function(value, cost) {
|
|
1639
1643
|
var item = {
|
|
1640
1644
|
value,
|
|
@@ -1643,6 +1647,9 @@ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1643
1647
|
this.queue.push(item);
|
|
1644
1648
|
this.queue.sort(this.sorter);
|
|
1645
1649
|
},
|
|
1650
|
+
/**
|
|
1651
|
+
* Return the highest priority element in the queue.
|
|
1652
|
+
*/
|
|
1646
1653
|
pop: function() {
|
|
1647
1654
|
return this.queue.shift();
|
|
1648
1655
|
},
|
|
@@ -3509,7 +3516,8 @@ var require_packer_async = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3509
3516
|
var Packer = require_packer();
|
|
3510
3517
|
var PackerAsync = module.exports = function(opt) {
|
|
3511
3518
|
Stream$2.call(this);
|
|
3512
|
-
|
|
3519
|
+
let options = opt || {};
|
|
3520
|
+
this._packer = new Packer(options);
|
|
3513
3521
|
this._deflate = this._packer.createDeflate();
|
|
3514
3522
|
this.readable = true;
|
|
3515
3523
|
};
|
|
@@ -3964,7 +3972,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3964
3972
|
//#endregion
|
|
3965
3973
|
//#region node_modules/qrcode/lib/renderer/png.js
|
|
3966
3974
|
var require_png = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3967
|
-
var fs$
|
|
3975
|
+
var fs$11 = __require("fs");
|
|
3968
3976
|
var PNG = require_png$1().PNG;
|
|
3969
3977
|
var Utils = require_utils$1();
|
|
3970
3978
|
exports.render = function render(qrData, options) {
|
|
@@ -4016,7 +4024,7 @@ var require_png = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4016
4024
|
called = true;
|
|
4017
4025
|
cb.apply(null, args);
|
|
4018
4026
|
};
|
|
4019
|
-
const stream = fs$
|
|
4027
|
+
const stream = fs$11.createWriteStream(path);
|
|
4020
4028
|
stream.on("error", done);
|
|
4021
4029
|
stream.on("close", done);
|
|
4022
4030
|
exports.renderToFileStream(stream, qrData, options);
|
|
@@ -6506,20 +6514,20 @@ var MsgType = /* @__PURE__ */ function(MsgType) {
|
|
|
6506
6514
|
//#region src/ntqqapi/types/notify.ts
|
|
6507
6515
|
var GroupNotifyType = /* @__PURE__ */ function(GroupNotifyType) {
|
|
6508
6516
|
GroupNotifyType[GroupNotifyType["InvitedByMember"] = 1] = "InvitedByMember";
|
|
6509
|
-
GroupNotifyType[GroupNotifyType["RefuseInvited"] =
|
|
6510
|
-
GroupNotifyType[GroupNotifyType["RefusedByAdminiStrator"] =
|
|
6511
|
-
GroupNotifyType[GroupNotifyType["AgreedTojoinDirect"] =
|
|
6512
|
-
GroupNotifyType[GroupNotifyType["InvitedNeedAdminiStratorPass"] =
|
|
6513
|
-
GroupNotifyType[GroupNotifyType["AgreedToJoinByAdminiStrator"] =
|
|
6514
|
-
GroupNotifyType[GroupNotifyType["RequestJoinNeedAdminiStratorPass"] =
|
|
6515
|
-
GroupNotifyType[GroupNotifyType["SetAdmin"] =
|
|
6516
|
-
GroupNotifyType[GroupNotifyType["KickMemberNotifyAdmin"] =
|
|
6517
|
-
GroupNotifyType[GroupNotifyType["KickMemberNotifyKicked"] =
|
|
6518
|
-
GroupNotifyType[GroupNotifyType["MemberLeaveNotifyAdmin"] =
|
|
6519
|
-
GroupNotifyType[GroupNotifyType["CancelAdminNotifyCanceled"] =
|
|
6520
|
-
GroupNotifyType[GroupNotifyType["CancelAdminNotifyAdmin"] =
|
|
6521
|
-
GroupNotifyType[GroupNotifyType["TransferGroupNotifyOldowner"] =
|
|
6522
|
-
GroupNotifyType[GroupNotifyType["TransferGroupNotifyAdmin"] =
|
|
6517
|
+
GroupNotifyType[GroupNotifyType["RefuseInvited"] = 1 + GroupNotifyType["InvitedByMember"]] = "RefuseInvited";
|
|
6518
|
+
GroupNotifyType[GroupNotifyType["RefusedByAdminiStrator"] = 1 + GroupNotifyType["RefuseInvited"]] = "RefusedByAdminiStrator";
|
|
6519
|
+
GroupNotifyType[GroupNotifyType["AgreedTojoinDirect"] = 1 + GroupNotifyType["RefusedByAdminiStrator"]] = "AgreedTojoinDirect";
|
|
6520
|
+
GroupNotifyType[GroupNotifyType["InvitedNeedAdminiStratorPass"] = 1 + GroupNotifyType["AgreedTojoinDirect"]] = "InvitedNeedAdminiStratorPass";
|
|
6521
|
+
GroupNotifyType[GroupNotifyType["AgreedToJoinByAdminiStrator"] = 1 + GroupNotifyType["InvitedNeedAdminiStratorPass"]] = "AgreedToJoinByAdminiStrator";
|
|
6522
|
+
GroupNotifyType[GroupNotifyType["RequestJoinNeedAdminiStratorPass"] = 1 + GroupNotifyType["AgreedToJoinByAdminiStrator"]] = "RequestJoinNeedAdminiStratorPass";
|
|
6523
|
+
GroupNotifyType[GroupNotifyType["SetAdmin"] = 1 + GroupNotifyType["RequestJoinNeedAdminiStratorPass"]] = "SetAdmin";
|
|
6524
|
+
GroupNotifyType[GroupNotifyType["KickMemberNotifyAdmin"] = 1 + GroupNotifyType["SetAdmin"]] = "KickMemberNotifyAdmin";
|
|
6525
|
+
GroupNotifyType[GroupNotifyType["KickMemberNotifyKicked"] = 1 + GroupNotifyType["KickMemberNotifyAdmin"]] = "KickMemberNotifyKicked";
|
|
6526
|
+
GroupNotifyType[GroupNotifyType["MemberLeaveNotifyAdmin"] = 1 + GroupNotifyType["KickMemberNotifyKicked"]] = "MemberLeaveNotifyAdmin";
|
|
6527
|
+
GroupNotifyType[GroupNotifyType["CancelAdminNotifyCanceled"] = 1 + GroupNotifyType["MemberLeaveNotifyAdmin"]] = "CancelAdminNotifyCanceled";
|
|
6528
|
+
GroupNotifyType[GroupNotifyType["CancelAdminNotifyAdmin"] = 1 + GroupNotifyType["CancelAdminNotifyCanceled"]] = "CancelAdminNotifyAdmin";
|
|
6529
|
+
GroupNotifyType[GroupNotifyType["TransferGroupNotifyOldowner"] = 1 + GroupNotifyType["CancelAdminNotifyAdmin"]] = "TransferGroupNotifyOldowner";
|
|
6530
|
+
GroupNotifyType[GroupNotifyType["TransferGroupNotifyAdmin"] = 1 + GroupNotifyType["TransferGroupNotifyOldowner"]] = "TransferGroupNotifyAdmin";
|
|
6523
6531
|
return GroupNotifyType;
|
|
6524
6532
|
}({});
|
|
6525
6533
|
var GroupNotifyStatus = /* @__PURE__ */ function(GroupNotifyStatus) {
|
|
@@ -6614,7 +6622,7 @@ async function logSummaryMessage(ctx, message) {
|
|
|
6614
6622
|
var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6615
6623
|
module.exports = isexe;
|
|
6616
6624
|
isexe.sync = sync;
|
|
6617
|
-
var fs$
|
|
6625
|
+
var fs$10 = __require("fs");
|
|
6618
6626
|
function checkPathExt(path, options) {
|
|
6619
6627
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
6620
6628
|
if (!pathext) return true;
|
|
@@ -6631,12 +6639,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6631
6639
|
return checkPathExt(path, options);
|
|
6632
6640
|
}
|
|
6633
6641
|
function isexe(path, options, cb) {
|
|
6634
|
-
fs$
|
|
6642
|
+
fs$10.stat(path, function(er, stat) {
|
|
6635
6643
|
cb(er, er ? false : checkStat(stat, path, options));
|
|
6636
6644
|
});
|
|
6637
6645
|
}
|
|
6638
6646
|
function sync(path, options) {
|
|
6639
|
-
return checkStat(fs$
|
|
6647
|
+
return checkStat(fs$10.statSync(path), path, options);
|
|
6640
6648
|
}
|
|
6641
6649
|
}));
|
|
6642
6650
|
//#endregion
|
|
@@ -6644,14 +6652,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6644
6652
|
var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6645
6653
|
module.exports = isexe;
|
|
6646
6654
|
isexe.sync = sync;
|
|
6647
|
-
var fs$
|
|
6655
|
+
var fs$9 = __require("fs");
|
|
6648
6656
|
function isexe(path, options, cb) {
|
|
6649
|
-
fs$
|
|
6657
|
+
fs$9.stat(path, function(er, stat) {
|
|
6650
6658
|
cb(er, er ? false : checkStat(stat, options));
|
|
6651
6659
|
});
|
|
6652
6660
|
}
|
|
6653
6661
|
function sync(path, options) {
|
|
6654
|
-
return checkStat(fs$
|
|
6662
|
+
return checkStat(fs$9.statSync(path), options);
|
|
6655
6663
|
}
|
|
6656
6664
|
function checkStat(stat, options) {
|
|
6657
6665
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -6832,11 +6840,30 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6832
6840
|
var utils = module.exports = {
|
|
6833
6841
|
isWindows,
|
|
6834
6842
|
streamRegexp,
|
|
6843
|
+
/**
|
|
6844
|
+
* Copy an object keys into another one
|
|
6845
|
+
*
|
|
6846
|
+
* @param {Object} source source object
|
|
6847
|
+
* @param {Object} dest destination object
|
|
6848
|
+
* @private
|
|
6849
|
+
*/
|
|
6835
6850
|
copy: function(source, dest) {
|
|
6836
6851
|
Object.keys(source).forEach(function(key) {
|
|
6837
6852
|
dest[key] = source[key];
|
|
6838
6853
|
});
|
|
6839
6854
|
},
|
|
6855
|
+
/**
|
|
6856
|
+
* Create an argument list
|
|
6857
|
+
*
|
|
6858
|
+
* Returns a function that adds new arguments to the list.
|
|
6859
|
+
* It also has the following methods:
|
|
6860
|
+
* - clear() empties the argument list
|
|
6861
|
+
* - get() returns the argument list
|
|
6862
|
+
* - find(arg, count) finds 'arg' in the list and return the following 'count' items, or undefined if not found
|
|
6863
|
+
* - remove(arg, count) remove 'arg' in the list as well as the following 'count' items
|
|
6864
|
+
*
|
|
6865
|
+
* @private
|
|
6866
|
+
*/
|
|
6840
6867
|
args: function() {
|
|
6841
6868
|
var list = [];
|
|
6842
6869
|
var argfunc = function() {
|
|
@@ -6864,6 +6891,20 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6864
6891
|
};
|
|
6865
6892
|
return argfunc;
|
|
6866
6893
|
},
|
|
6894
|
+
/**
|
|
6895
|
+
* Generate filter strings
|
|
6896
|
+
*
|
|
6897
|
+
* @param {String[]|Object[]} filters filter specifications. When using objects,
|
|
6898
|
+
* each must have the following properties:
|
|
6899
|
+
* @param {String} filters.filter filter name
|
|
6900
|
+
* @param {String|Array} [filters.inputs] (array of) input stream specifier(s) for the filter,
|
|
6901
|
+
* defaults to ffmpeg automatically choosing the first unused matching streams
|
|
6902
|
+
* @param {String|Array} [filters.outputs] (array of) output stream specifier(s) for the filter,
|
|
6903
|
+
* defaults to ffmpeg automatically assigning the output to the output file
|
|
6904
|
+
* @param {Object|String|Array} [filters.options] filter options, can be omitted to not set any options
|
|
6905
|
+
* @return String[]
|
|
6906
|
+
* @private
|
|
6907
|
+
*/
|
|
6867
6908
|
makeFilterStrings: function(filters) {
|
|
6868
6909
|
return filters.map(function(filterSpec) {
|
|
6869
6910
|
if (typeof filterSpec === "string") return filterSpec;
|
|
@@ -6892,6 +6933,15 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6892
6933
|
return filterString;
|
|
6893
6934
|
});
|
|
6894
6935
|
},
|
|
6936
|
+
/**
|
|
6937
|
+
* Search for an executable
|
|
6938
|
+
*
|
|
6939
|
+
* Uses 'which' or 'where' depending on platform
|
|
6940
|
+
*
|
|
6941
|
+
* @param {String} name executable name
|
|
6942
|
+
* @param {Function} callback callback with signature (err, path)
|
|
6943
|
+
* @private
|
|
6944
|
+
*/
|
|
6895
6945
|
which: function(name, callback) {
|
|
6896
6946
|
if (name in whichCache) return callback(null, whichCache[name]);
|
|
6897
6947
|
which(name, function(err, result) {
|
|
@@ -6899,6 +6949,13 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6899
6949
|
callback(null, whichCache[name] = result);
|
|
6900
6950
|
});
|
|
6901
6951
|
},
|
|
6952
|
+
/**
|
|
6953
|
+
* Convert a [[hh:]mm:]ss[.xxx] timemark into seconds
|
|
6954
|
+
*
|
|
6955
|
+
* @param {String} timemark timemark string
|
|
6956
|
+
* @return Number
|
|
6957
|
+
* @private
|
|
6958
|
+
*/
|
|
6902
6959
|
timemarkToSeconds: function(timemark) {
|
|
6903
6960
|
if (typeof timemark === "number") return timemark;
|
|
6904
6961
|
if (timemark.indexOf(":") === -1 && timemark.indexOf(".") >= 0) return Number(timemark);
|
|
@@ -6908,6 +6965,16 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6908
6965
|
if (parts.length) secs += Number(parts.pop()) * 3600;
|
|
6909
6966
|
return secs;
|
|
6910
6967
|
},
|
|
6968
|
+
/**
|
|
6969
|
+
* Extract codec data from ffmpeg stderr and emit 'codecData' event if appropriate
|
|
6970
|
+
* Call it with an initially empty codec object once with each line of stderr output until it returns true
|
|
6971
|
+
*
|
|
6972
|
+
* @param {FfmpegCommand} command event emitter
|
|
6973
|
+
* @param {String} stderrLine ffmpeg stderr output line
|
|
6974
|
+
* @param {Object} codecObject object used to accumulate codec data between calls
|
|
6975
|
+
* @return {Boolean} true if codec data is complete (and event was emitted), false otherwise
|
|
6976
|
+
* @private
|
|
6977
|
+
*/
|
|
6911
6978
|
extractCodecData: function(command, stderrLine, codecsObject) {
|
|
6912
6979
|
var inputPattern = /Input #[0-9]+, ([^ ]+),/;
|
|
6913
6980
|
var durPattern = /Duration\: ([^,]+)/;
|
|
@@ -6947,6 +7014,13 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6947
7014
|
}
|
|
6948
7015
|
return false;
|
|
6949
7016
|
},
|
|
7017
|
+
/**
|
|
7018
|
+
* Extract progress data from ffmpeg stderr and emit 'progress' event if appropriate
|
|
7019
|
+
*
|
|
7020
|
+
* @param {FfmpegCommand} command event emitter
|
|
7021
|
+
* @param {String} stderrLine ffmpeg stderr data
|
|
7022
|
+
* @private
|
|
7023
|
+
*/
|
|
6950
7024
|
extractProgress: function(command, stderrLine) {
|
|
6951
7025
|
var progress = parseProgressLine(stderrLine);
|
|
6952
7026
|
if (progress) {
|
|
@@ -6964,6 +7038,13 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6964
7038
|
command.emit("progress", ret);
|
|
6965
7039
|
}
|
|
6966
7040
|
},
|
|
7041
|
+
/**
|
|
7042
|
+
* Extract error message(s) from ffmpeg stderr
|
|
7043
|
+
*
|
|
7044
|
+
* @param {String} stderr ffmpeg stderr data
|
|
7045
|
+
* @return {String}
|
|
7046
|
+
* @private
|
|
7047
|
+
*/
|
|
6967
7048
|
extractError: function(stderr) {
|
|
6968
7049
|
return stderr.split(nlRegexp).reduce(function(messages, message) {
|
|
6969
7050
|
if (message.charAt(0) === " " || message.charAt(0) === "[") return [];
|
|
@@ -6973,6 +7054,15 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6973
7054
|
}
|
|
6974
7055
|
}, []).join("\n");
|
|
6975
7056
|
},
|
|
7057
|
+
/**
|
|
7058
|
+
* Creates a line ring buffer object with the following methods:
|
|
7059
|
+
* - append(str) : appends a string or buffer
|
|
7060
|
+
* - get() : returns the whole string
|
|
7061
|
+
* - close() : prevents further append() calls and does a last call to callbacks
|
|
7062
|
+
* - callback(cb) : calls cb for each line (incl. those already in the ring)
|
|
7063
|
+
*
|
|
7064
|
+
* @param {Number} maxLines maximum number of lines to store (<= 0 for unlimited)
|
|
7065
|
+
*/
|
|
6976
7066
|
linesRing: function(maxLines) {
|
|
6977
7067
|
var cbs = [];
|
|
6978
7068
|
var lines = [];
|
|
@@ -9061,7 +9151,7 @@ var require_processor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9061
9151
|
//#endregion
|
|
9062
9152
|
//#region node_modules/fluent-ffmpeg/lib/capabilities.js
|
|
9063
9153
|
var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9064
|
-
var fs$
|
|
9154
|
+
var fs$8 = __require("fs");
|
|
9065
9155
|
var path$7 = __require("path");
|
|
9066
9156
|
var async = require_async();
|
|
9067
9157
|
var utils = require_utils();
|
|
@@ -9137,7 +9227,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9137
9227
|
proto._getFfmpegPath = function(callback) {
|
|
9138
9228
|
if ("ffmpegPath" in cache) return callback(null, cache.ffmpegPath);
|
|
9139
9229
|
async.waterfall([function(cb) {
|
|
9140
|
-
if (process.env.FFMPEG_PATH) fs$
|
|
9230
|
+
if (process.env.FFMPEG_PATH) fs$8.exists(process.env.FFMPEG_PATH, function(exists) {
|
|
9141
9231
|
if (exists) cb(null, process.env.FFMPEG_PATH);
|
|
9142
9232
|
else cb(null, "");
|
|
9143
9233
|
});
|
|
@@ -9168,7 +9258,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9168
9258
|
if ("ffprobePath" in cache) return callback(null, cache.ffprobePath);
|
|
9169
9259
|
async.waterfall([
|
|
9170
9260
|
function(cb) {
|
|
9171
|
-
if (process.env.FFPROBE_PATH) fs$
|
|
9261
|
+
if (process.env.FFPROBE_PATH) fs$8.exists(process.env.FFPROBE_PATH, function(exists) {
|
|
9172
9262
|
cb(null, exists ? process.env.FFPROBE_PATH : "");
|
|
9173
9263
|
});
|
|
9174
9264
|
else cb(null, "");
|
|
@@ -9186,7 +9276,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9186
9276
|
else if (ffmpeg.length) {
|
|
9187
9277
|
var name = utils.isWindows ? "ffprobe.exe" : "ffprobe";
|
|
9188
9278
|
var ffprobe = path$7.join(path$7.dirname(ffmpeg), name);
|
|
9189
|
-
fs$
|
|
9279
|
+
fs$8.exists(ffprobe, function(exists) {
|
|
9190
9280
|
cb(null, exists ? ffprobe : "");
|
|
9191
9281
|
});
|
|
9192
9282
|
} else cb(null, "");
|
|
@@ -9211,14 +9301,14 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9211
9301
|
if ("flvtoolPath" in cache) return callback(null, cache.flvtoolPath);
|
|
9212
9302
|
async.waterfall([
|
|
9213
9303
|
function(cb) {
|
|
9214
|
-
if (process.env.FLVMETA_PATH) fs$
|
|
9304
|
+
if (process.env.FLVMETA_PATH) fs$8.exists(process.env.FLVMETA_PATH, function(exists) {
|
|
9215
9305
|
cb(null, exists ? process.env.FLVMETA_PATH : "");
|
|
9216
9306
|
});
|
|
9217
9307
|
else cb(null, "");
|
|
9218
9308
|
},
|
|
9219
9309
|
function(flvtool, cb) {
|
|
9220
9310
|
if (flvtool.length) return cb(null, flvtool);
|
|
9221
|
-
if (process.env.FLVTOOL2_PATH) fs$
|
|
9311
|
+
if (process.env.FLVTOOL2_PATH) fs$8.exists(process.env.FLVTOOL2_PATH, function(exists) {
|
|
9222
9312
|
cb(null, exists ? process.env.FLVTOOL2_PATH : "");
|
|
9223
9313
|
});
|
|
9224
9314
|
else cb(null, "");
|
|
@@ -9723,7 +9813,7 @@ var require_ffprobe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9723
9813
|
//#endregion
|
|
9724
9814
|
//#region node_modules/fluent-ffmpeg/lib/recipes.js
|
|
9725
9815
|
var require_recipes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9726
|
-
var fs$
|
|
9816
|
+
var fs$7 = __require("fs");
|
|
9727
9817
|
var path$6 = __require("path");
|
|
9728
9818
|
var PassThrough$4 = __require("stream").PassThrough;
|
|
9729
9819
|
var async = require_async();
|
|
@@ -9929,8 +10019,8 @@ var require_recipes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9929
10019
|
next(null, filenames);
|
|
9930
10020
|
},
|
|
9931
10021
|
function createDirectory(filenames, next) {
|
|
9932
|
-
fs$
|
|
9933
|
-
if (!exists) fs$
|
|
10022
|
+
fs$7.exists(config.folder, function(exists) {
|
|
10023
|
+
if (!exists) fs$7.mkdir(config.folder, function(err) {
|
|
9934
10024
|
if (err) next(err);
|
|
9935
10025
|
else next(null, filenames);
|
|
9936
10026
|
});
|
|
@@ -10178,7 +10268,7 @@ function setFFMpegPath(ffmpegPath) {
|
|
|
10178
10268
|
path.join(import.meta.dirname, "ffmpeg.exe"),
|
|
10179
10269
|
process.env["FFMPEG_PATH"] || ""
|
|
10180
10270
|
];
|
|
10181
|
-
for (const p of paths) if (fs$
|
|
10271
|
+
for (const p of paths) if (fs$2.existsSync(p)) {
|
|
10182
10272
|
import_fluent_ffmpeg.default.setFfmpegPath(p);
|
|
10183
10273
|
console.log("set ffmpeg successfully", p);
|
|
10184
10274
|
break;
|
|
@@ -11292,7 +11382,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
|
|
|
11292
11382
|
};
|
|
11293
11383
|
//#endregion
|
|
11294
11384
|
//#region src/version.ts
|
|
11295
|
-
var version$2 = "7.12.
|
|
11385
|
+
var version$2 = "7.12.3";
|
|
11296
11386
|
//#endregion
|
|
11297
11387
|
//#region node_modules/sift/es5m/index.js
|
|
11298
11388
|
/******************************************************************************
|
|
@@ -11726,7 +11816,8 @@ var $In = function(_super) {
|
|
|
11726
11816
|
}
|
|
11727
11817
|
$In.prototype.init = function() {
|
|
11728
11818
|
var _this = this;
|
|
11729
|
-
|
|
11819
|
+
var params = Array.isArray(this.params) ? this.params : [this.params];
|
|
11820
|
+
this._testers = params.map(function(value) {
|
|
11730
11821
|
if (containsOperation(value, _this.options)) throw new Error("cannot nest $ under ".concat(_this.name.toLowerCase()));
|
|
11731
11822
|
return createTester(value, _this.options.compare);
|
|
11732
11823
|
});
|
|
@@ -12123,7 +12214,7 @@ var OB11WebSocket = class {
|
|
|
12123
12214
|
} catch (e) {
|
|
12124
12215
|
this.ctx.logger.error("发送生命周期失败", e);
|
|
12125
12216
|
}
|
|
12126
|
-
const disposeHeartBeat = this.ctx.
|
|
12217
|
+
const disposeHeartBeat = this.ctx.interval(() => {
|
|
12127
12218
|
const event = new OB11HeartbeatEvent(selfInfo.online, true, this.config.heartInterval);
|
|
12128
12219
|
if (!matchEventFilter(this.config.filter, event)) return;
|
|
12129
12220
|
this.reply(socket, event);
|
|
@@ -12245,7 +12336,7 @@ var OB11WebSocketReverse = class {
|
|
|
12245
12336
|
this.wsClient.on("ping", () => {
|
|
12246
12337
|
this.wsClient?.pong();
|
|
12247
12338
|
});
|
|
12248
|
-
const disposeHeartBeat = this.ctx.
|
|
12339
|
+
const disposeHeartBeat = this.ctx.interval(() => {
|
|
12249
12340
|
if (this.wsClient) {
|
|
12250
12341
|
const event = new OB11HeartbeatEvent(selfInfo.online, true, this.config.heartInterval);
|
|
12251
12342
|
if (!matchEventFilter(this.config.filter, event)) return;
|
|
@@ -12255,7 +12346,7 @@ var OB11WebSocketReverse = class {
|
|
|
12255
12346
|
this.wsClient.on("close", (code) => {
|
|
12256
12347
|
disposeHeartBeat();
|
|
12257
12348
|
this.ctx.logger.info(`The websocket connection: ${this.config.url} closed, code ${code}${this.activated ? ", trying reconnecting..." : ""}`);
|
|
12258
|
-
if (this.activated) this.ctx.
|
|
12349
|
+
if (this.activated) this.ctx.timeout(() => this.tryConnect(), 3e3);
|
|
12259
12350
|
});
|
|
12260
12351
|
}
|
|
12261
12352
|
};
|
|
@@ -16951,7 +17042,7 @@ var processQueue = async () => {
|
|
|
16951
17042
|
const promises = queue.splice(0, concurrency).map(async ({ filePath, resolve, reject }) => {
|
|
16952
17043
|
let handle;
|
|
16953
17044
|
try {
|
|
16954
|
-
handle = await fs$
|
|
17045
|
+
handle = await fs$6.promises.open(path$4.resolve(filePath), "r");
|
|
16955
17046
|
} catch (err) {
|
|
16956
17047
|
return reject(err);
|
|
16957
17048
|
}
|
|
@@ -16998,7 +17089,7 @@ function checkUriType(uri) {
|
|
|
16998
17089
|
if (uri.startsWith("data:")) return { type: FileUriType.DataURL };
|
|
16999
17090
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return { type: FileUriType.RemoteURL };
|
|
17000
17091
|
if (uri.startsWith("file://")) return { type: FileUriType.FileURL };
|
|
17001
|
-
if (fs$
|
|
17092
|
+
if (fs$2.existsSync(uri)) return { type: FileUriType.Path };
|
|
17002
17093
|
return { type: FileUriType.Unknown };
|
|
17003
17094
|
}
|
|
17004
17095
|
async function fetchFile(url, headersInit) {
|
|
@@ -17028,7 +17119,7 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17028
17119
|
const { type } = checkUriType(uri);
|
|
17029
17120
|
if (type === FileUriType.FileURL) {
|
|
17030
17121
|
const filePath = fileURLToPath(uri);
|
|
17031
|
-
if (!fs$
|
|
17122
|
+
if (!fs$2.existsSync(filePath)) return {
|
|
17032
17123
|
success: false,
|
|
17033
17124
|
errMsg: "路径不存在",
|
|
17034
17125
|
fileName: "",
|
|
@@ -17054,12 +17145,12 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17054
17145
|
const res = await fetchFile(uri);
|
|
17055
17146
|
let fileName = randomUUID();
|
|
17056
17147
|
let filePath = path.join(TEMP_DIR, fileName);
|
|
17057
|
-
await
|
|
17148
|
+
await fs.writeFile(filePath, res.data);
|
|
17058
17149
|
if (needExt) {
|
|
17059
17150
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
|
|
17060
17151
|
fileName += `.${ext}`;
|
|
17061
17152
|
const newPath = `${filePath}.${ext}`;
|
|
17062
|
-
await
|
|
17153
|
+
await fs.rename(filePath, newPath);
|
|
17063
17154
|
filePath = newPath;
|
|
17064
17155
|
}
|
|
17065
17156
|
return {
|
|
@@ -17082,11 +17173,11 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17082
17173
|
let filename = randomUUID();
|
|
17083
17174
|
let filePath = path.join(TEMP_DIR, filename);
|
|
17084
17175
|
const base64 = uri.replace(/^base64:\/\//, "");
|
|
17085
|
-
await
|
|
17176
|
+
await fs.writeFile(filePath, base64, "base64");
|
|
17086
17177
|
if (needExt) {
|
|
17087
17178
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
|
|
17088
17179
|
filename += `.${ext}`;
|
|
17089
|
-
await
|
|
17180
|
+
await fs.rename(filePath, `${filePath}.${ext}`);
|
|
17090
17181
|
filePath = `${filePath}.${ext}`;
|
|
17091
17182
|
}
|
|
17092
17183
|
return {
|
|
@@ -17103,11 +17194,11 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17103
17194
|
let filename = randomUUID();
|
|
17104
17195
|
const [, _type, base64] = capture;
|
|
17105
17196
|
let filePath = path.join(TEMP_DIR, filename);
|
|
17106
|
-
await
|
|
17197
|
+
await fs.writeFile(filePath, base64, "base64");
|
|
17107
17198
|
if (needExt) {
|
|
17108
17199
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
|
|
17109
17200
|
filename += `.${ext}`;
|
|
17110
|
-
await
|
|
17201
|
+
await fs.rename(filePath, `${filePath}.${ext}`);
|
|
17111
17202
|
filePath = `${filePath}.${ext}`;
|
|
17112
17203
|
}
|
|
17113
17204
|
return {
|
|
@@ -17165,13 +17256,13 @@ async function getImageSize(path) {
|
|
|
17165
17256
|
}
|
|
17166
17257
|
async function getMd5HexFromFile(filePath) {
|
|
17167
17258
|
const hash = createHash("md5");
|
|
17168
|
-
const stream = fs$
|
|
17259
|
+
const stream = fs$2.createReadStream(filePath);
|
|
17169
17260
|
for await (const chunk of stream) hash.update(chunk);
|
|
17170
17261
|
return hash.digest("hex");
|
|
17171
17262
|
}
|
|
17172
17263
|
async function getSha1HexFromFile(filePath) {
|
|
17173
17264
|
const hash = createHash("sha1");
|
|
17174
|
-
const stream = fs$
|
|
17265
|
+
const stream = fs$2.createReadStream(filePath);
|
|
17175
17266
|
for await (const chunk of stream) hash.update(chunk);
|
|
17176
17267
|
return hash.digest("hex");
|
|
17177
17268
|
}
|
|
@@ -17180,13 +17271,13 @@ function getMd5BufferFromBuffer(buf) {
|
|
|
17180
17271
|
}
|
|
17181
17272
|
async function getMd5BufferFromFile(filePath) {
|
|
17182
17273
|
const hash = createHash("md5");
|
|
17183
|
-
const stream = fs$
|
|
17274
|
+
const stream = fs$2.createReadStream(filePath);
|
|
17184
17275
|
for await (const chunk of stream) hash.update(chunk);
|
|
17185
17276
|
return hash.digest();
|
|
17186
17277
|
}
|
|
17187
17278
|
async function getSha1BufferFromFile(filePath) {
|
|
17188
17279
|
const hash = createHash("sha1");
|
|
17189
|
-
const stream = fs$
|
|
17280
|
+
const stream = fs$2.createReadStream(filePath);
|
|
17190
17281
|
for await (const chunk of stream) hash.update(chunk);
|
|
17191
17282
|
return hash.digest();
|
|
17192
17283
|
}
|
|
@@ -17422,7 +17513,7 @@ async function calculateSha1StreamBytes(filePath) {
|
|
|
17422
17513
|
let bytesRead = 0;
|
|
17423
17514
|
let nextBlockBoundary = blockSize;
|
|
17424
17515
|
const byteArrayList = [];
|
|
17425
|
-
const readable = fs$
|
|
17516
|
+
const readable = fs$2.createReadStream(filePath);
|
|
17426
17517
|
for await (const chunk of readable) {
|
|
17427
17518
|
let buf;
|
|
17428
17519
|
if (tail.length > 0) {
|
|
@@ -17447,7 +17538,7 @@ async function calculateSha1StreamBytes(filePath) {
|
|
|
17447
17538
|
}
|
|
17448
17539
|
async function readAndHash10M(filePath) {
|
|
17449
17540
|
const maxSize = 10002432;
|
|
17450
|
-
const fd = await
|
|
17541
|
+
const fd = await fs.open(filePath, "r");
|
|
17451
17542
|
const buffer = Buffer.allocUnsafe(maxSize);
|
|
17452
17543
|
const { bytesRead } = await fd.read(buffer, 0, maxSize, 0);
|
|
17453
17544
|
await fd.close();
|
|
@@ -17489,13 +17580,13 @@ var TriSha1 = class {
|
|
|
17489
17580
|
};
|
|
17490
17581
|
async function calculateTriSha1(filePath, fileSize) {
|
|
17491
17582
|
const hash = new TriSha1(fileSize);
|
|
17492
|
-
const stream = fs$
|
|
17583
|
+
const stream = fs$2.createReadStream(filePath);
|
|
17493
17584
|
for await (const chunk of stream) hash.update(chunk);
|
|
17494
17585
|
return hash.finalize();
|
|
17495
17586
|
}
|
|
17496
17587
|
var defaultVideoThumb = Buffer.from("/9j/4AAQSkZJRgABAQAAAQABAAD//gAXR2VuZXJhdGVkIGJ5IFNuaXBhc3Rl/9sAhAAKBwcIBwYKCAgICwoKCw4YEA4NDQ4dFRYRGCMfJSQiHyIhJis3LyYpNCkhIjBBMTQ5Oz4+PiUuRElDPEg3PT47AQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCAF/APADAREAAhEBAxEB/8QBogAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+foBAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKCxEAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDiAayNxwagBwNAC5oAM0xBmgBM0ANJoAjY0AQsaBkTGgCM0DEpAFAC0AFMBaACgAoEJTASgQlACUwCgQ4UAOFADhQA4UAOFADxQIkBqDQUGgBwagBQaBC5pgGaAELUAMLUARs1AETGgBhNAxhoASkAUALQIKYxaBBQAUwEoAQ0CEoASmAUAOoEKKAHCgBwoAeKAHigQ7NZmoZpgLmgBd1Ahd1ABupgNLUAMLUAMY0AMJoAYaAENACUCCgAoAWgAoAWgBKYCUAJQISgApgLQAooEOFACigB4oAeKBDxQAVmaiZpgGaAFzQAbqAE3UAIWpgNJoAYTQIaaAEoAQ0CEoASgBaACgBaACmAUAJQAlAgoAKYC0AKKBCigB4FADgKBDwKAHigBuazNRM0DEzTAM0AJmgAzQAhNAhpNACGmA2gQlACUCEoAKACgBaAFpgFACUAJQAUCCmAUALQIcBQA4CgB4FADgKBDhQA4UAMzWZqNzTGJQAZoATNABmgBKAEoEIaYCUCEoASgQlABQAtABQAtMBKACgAoEFABimAYoEKBQA4CgB4FADwKBDgKAFFADhQBCazNhKAEpgFACUAFACUAFAhDTAbQISgAoEJQAUALQAtMAoAKADFABigQYoAMUALimIUCgBwFAh4FADgKAHUALQAtAENZmwlACUwEoAKAEoAKACgQlMBpoEJQAUCCgBcUAFABTAXFAC4oAMUAGKBBigAxQIKYCigQ8UAOFADhQAtAC0ALQBDWZqJQMSgBKYBQAlABQISgBKYCGgQlAC0CCgBcUAFABTAUCkA7FMAxQAYoEJQAUCCmAooEOFADxQA4UAFAC0ALQBDWZqJQAlACUxhQAlABQIKAEoASmISgBcUCCgBaACgBcUAKBQAuKYC0CEoAQ0AJQISmAooEPFADhQA4UALQAtAC0AQ1maiUAFACUAJTAKAEoAKAEoAMUxBigAxQIWgAoAKAFAoAWgBaYBQIQ0ANNACUCCmIUUAOFADxQA4UALQAtABQBFWZqFACUAFACYpgFACUAFACUAFAgxTEFABQAUALQAooAWgAoAKYDTQIaaAEpiCgQ4UAOFAh4oGOFAC0ALSAKYEdZmglABQAUDDFACUwEoASgAoAKBBQIKYBQAUALQAtAC0AJQAhpgNJoENJoATNMQCgQ8UCHigB4oAWgYtABQAUAMrM0CgAoAKADFACUxiUAJQAlAgoAKYgoAKACgYtAC0AFAhDTAQmgBhNAhpNACZpiFBoEPFAEi0CHigB1ABQAUDEoAbWZoFABQAtABTAQ0ANNAxDQAlAhaAEpiCgAoGFAC0AFABmgBCaYhpNADCaBDSaBBmgABpiJFNAEimgB4NADqAFzQAlACE0AJWZoFAC0AFAC0wEIoAaaAG0AJQAUCCgApjCgAoAKADNABmgBpNMQ0mgBpNAhhNAgzQAoNADwaAHqaAJAaBDgaYC5oATNACZoAWszQKACgBaBDqYCGgBpoAYaBiUCCgBKYBQMKACgAoAM0AITQIaTQA0mmA0mgQ3NAhKAHCgBwNADwaAHg0AOBpiFzQAZoATNAD6zNAoAKAFoEOpgBoAaaAGGmAw0AJmgAzQMM0AGaADNABmgBM0AITQIaTQAhNMQw0AJQIKAFFADhQA4GgBwNADs0xC5oAM0CDNAEtZmoUCCgBaAHUwCgBppgRtQAw0ANzQAZoAM0AGaADNABmgBKAEoAQ0ANNMQhoEJQAlMBaQDgaAFBoAcDTAdmgQuaADNAgzQBPWZqFAgoAWgBaYC0CGmmBG1AyM0ANJoATNACZoAXNABmgAzQAUAJQAhoAQ0xDTQISmAUALQAUgHA0AKDTAdmgQuaBBQAtAFiszQKACgBaAFFMAoEIaYEbUDI2oAYaAEoASgAzQAuaACgAoAKAENMQ00AJTEFAhKACgAoAXNACg0AOBoAWgQtAC0AWazNAoAKACgBaYBQIQ0AMNMYw0AMIoAbQAlMAoAKACgAzSAKYhKAENACUxBQIKACgBKACgBaAHCgQ4UALQAUAWqzNAoAKACgApgFACGgQ00xjTQAwigBCKAG4pgJQAlABQAUCCgBKACgBKYgoEFABQISgAoAWgBRQA4UALQAUCLdZmoUAFABQAlMAoASgBDQA00wENACYoATFMBpFADSKAEoEJQAUAFABQAlMQtAgoASgQUAJQAUAKKAHCgBaBBQBbrM1CgAoAKACmAUAJQAlADaYBQAlACYpgIRQA0igBpFAhtABQAUAFMAoEFABQIKAEoASgQUALQAooAWgQUAW81mbC0CCgApgFACUAIaAEpgJQAUAFABQAhFMBpFADSKAGkUCExQAYoAMUAGKADFMQYoAMUCExSATFABQIKYBQAtABQIt5qDYM0ALmgQtIApgIaAENADaACmAlAC0ALQAUwGkUANIoAaRQAmKBBigAxQAYoAMUAGKBBigBMUAJigQmKAExTAKBC0AFAFnNQaig0AKDQAtAgoASgBDQAlMBKACgAFADhQAtMBCKAGkUAIRQAmKADFABigQmKADFACYoAXFABigQmKAExQAmKBCYpgJigAoAnzUGgZoAcDQAuaBC0AJQAhoASmAlABQAtADhQAtMAoATFACEUAJigAxQAYoATFAhMUAFABQAuKADFABigBpWgBCKBCYpgJigB+ag0DNADgaBDgaAFzQITNACUAJTAKACgBRQAopgOoAWgBKAEoAKACgAoASgBpoEJQAooAWgBaBhigBMUCEIoAQigBMUAJSLCgBQaBDgaQC5oEFACUwCgBKACmAtADhQA4UALQAUAJQAUAJQAUAJQAhoENoAWgBRQAooGLQAUAGKAGkUAIRQIZSKEoGKKBDhQAUCCgAoAKBBQAUwFoGKKAHCgBaACgAoASgAoASgBCaAEoEJmgAoAUGgBQaAHZoGFABQAUANoAjpDEoAWgBaAFoEFACUALQAUCCmAUAOFAxRQAtAC0AJQAUAJQAmaBDSaAEzQAmaYBmgBQaAHA0gFzQAuaBhmgAzQAlAEdIYUALQAtAgoAKAEoEFAC0AFMAoAUUDFFAC0ALQAUAJQAhoENNACE0wEoATNABmgBc0ALmgBc0gDNAC5oATNABmgBKRQlACigB1AgoASgQlABTAWgBKACgBaBi0ALQAZoAM0AFACGgQ00wENACUAJQAUCFzQMM0ALmgAzQAZoAM0AGaQC0igoAUUALQIWgBDQISmAUAFACUAFABQAuaBi5oAM0AGaBBmgBKAEpgIaAG0AJQAUCFoAM0DDNAC5oATNABmgAzQBJUlBQAooAWgQtACGmIaaACgAoASgBKACgBc0DCgQUAGaADNABTASgBDQAlACUAFAgoAKBhQAUAFABQAlAE1SUFAxRQIWgQtMBDQIQ0AJQAlAhKBiUAFABmgBc0AGaADNABTAKACgBKAEoASgQlABQAUAFAC0AFACUAFAE1SaBQAUCHCgQtMBKBCUAJQISgBDQA00DEzQAuaADNMBc0AGaADNABQAUAJQAlABQISgAoAKACgBaACgBKAEoAnqTQSgBRQIcKBC0xCUAJQISgBKAENADDQAmaYwzQAuaADNAC0AFABQAUAFAhKACgBKACgAoAWgAoELQAlAxKAJqk0EoAWgQooELTEFADaBCUABoENNMY00ANNAwzQAZoAXNAC0AFAC0CFoASgAoASgBKACgAoAWgQtABQAUANNAyWpNAoAKBCimIWgQUCEoASmIQ0ANNADTQMaaAEoGLmgAzQAtADhQIWgBaACgQhoASgYlACUALQIWgBaACgBKAENAyWpNBKYBQIcKBC0CEoEJTAKBCUANNADDQMQ0ANoGFAC5oAUGgBwNAhRQIWgBaAENACGgBtAwoAKAFzQIXNABmgAoAQ0DJKRoJQAtAhRQSLQIKYCUCCgBDQA00AMNAxpoGNoAM0AGaAFBoAcDQIcKBDqACgBDQAhoAQ0DEoAKADNAC5oEGaBhmgAoAkpGgUCCgQooELQIKYhKACgBKAGmgBpoGMNAxDQAlAwzQIUUAOFAhwoAcKBC0AJQAhoGNNACUAFABQAZoAXNABQAUAS0ixKACgQoNAhaYgoEFACUABoAaaAGmgYw0DENAxtABQAooEOFADhQIcKAFoASgBDQAhoGJQAUAFACUALQIKBi0CJDSLEoATNAhc0CHZpiCgQUAJQIKBjTQAhoGNNAxpoATFABigBQKAHCgBwoAWgAoAKACgBKAEoASgAoASgBaAAUAOoEONIoaTQAZoAUGmIUGgQtAgzQISgAoAQ0DGmgYlAxKACgAxQAtACigBRQAtAxaACgAoATFABigBCKAG0CEoAWgBRTAUUAf//Z", "base64");
|
|
17497
17588
|
async function getVideoInfo(filePath) {
|
|
17498
|
-
const size = fs$
|
|
17589
|
+
const size = fs$2.statSync(filePath).size;
|
|
17499
17590
|
return new Promise((resolve, reject) => {
|
|
17500
17591
|
(0, import_fluent_ffmpeg.default)(filePath).ffprobe((err, metadata) => {
|
|
17501
17592
|
if (err) reject(err);
|
|
@@ -17572,7 +17663,7 @@ function convert(ctx, input, options, outputPath) {
|
|
|
17572
17663
|
});
|
|
17573
17664
|
}
|
|
17574
17665
|
async function encodeSilk(ctx, filePath) {
|
|
17575
|
-
const file = await
|
|
17666
|
+
const file = await fs.readFile(filePath);
|
|
17576
17667
|
if (!isSilk(file)) {
|
|
17577
17668
|
ctx.logger.info(`语音文件${filePath}需要转换成silk`);
|
|
17578
17669
|
let result;
|
|
@@ -17591,7 +17682,7 @@ async function encodeSilk(ctx, filePath) {
|
|
|
17591
17682
|
"-f s16le"
|
|
17592
17683
|
] }), 24e3);
|
|
17593
17684
|
const pttPath = path.join(TEMP_DIR, randomUUID());
|
|
17594
|
-
await
|
|
17685
|
+
await fs.writeFile(pttPath, result.data);
|
|
17595
17686
|
ctx.logger.info(`语音文件${filePath}转换成功!`, pttPath, `时长:`, result.duration);
|
|
17596
17687
|
return {
|
|
17597
17688
|
converted: true,
|
|
@@ -17614,11 +17705,11 @@ async function encodeSilk(ctx, filePath) {
|
|
|
17614
17705
|
}
|
|
17615
17706
|
}
|
|
17616
17707
|
async function decodeSilk(ctx, inputFilePath, outFormat) {
|
|
17617
|
-
const { data } = await decode(await
|
|
17708
|
+
const { data } = await decode(await fs.readFile(inputFilePath), 24e3);
|
|
17618
17709
|
const tmpPath = path.join(TEMP_DIR, path.basename(inputFilePath));
|
|
17619
17710
|
const outFilePath = tmpPath + `.${outFormat}`;
|
|
17620
17711
|
const pcmFilePath = tmpPath + ".pcm";
|
|
17621
|
-
await
|
|
17712
|
+
await fs.writeFile(pcmFilePath, data);
|
|
17622
17713
|
return convert(ctx, pcmFilePath, { input: [
|
|
17623
17714
|
"-f s16le",
|
|
17624
17715
|
"-ar 24000",
|
|
@@ -20295,6 +20386,27 @@ var streamSSE = (c, cb, onError) => {
|
|
|
20295
20386
|
return c.newResponse(stream.responseReadable);
|
|
20296
20387
|
};
|
|
20297
20388
|
//#endregion
|
|
20389
|
+
//#region node_modules/hono/dist/helper/websocket/index.js
|
|
20390
|
+
var defineWebSocketHelper = (handler) => {
|
|
20391
|
+
return ((...args) => {
|
|
20392
|
+
if (typeof args[0] === "function") {
|
|
20393
|
+
const [createEvents, options] = args;
|
|
20394
|
+
return async function upgradeWebSocket(c, next) {
|
|
20395
|
+
const result = await handler(c, await createEvents(c), options);
|
|
20396
|
+
if (result) return result;
|
|
20397
|
+
await next();
|
|
20398
|
+
};
|
|
20399
|
+
} else {
|
|
20400
|
+
const [c, events, options] = args;
|
|
20401
|
+
return (async () => {
|
|
20402
|
+
const upgraded = await handler(c, events, options);
|
|
20403
|
+
if (!upgraded) throw new Error("Failed to upgrade WebSocket");
|
|
20404
|
+
return upgraded;
|
|
20405
|
+
})();
|
|
20406
|
+
}
|
|
20407
|
+
});
|
|
20408
|
+
};
|
|
20409
|
+
//#endregion
|
|
20298
20410
|
//#region node_modules/@hono/node-server/dist/index.mjs
|
|
20299
20411
|
var RequestError = class extends Error {
|
|
20300
20412
|
constructor(message, options) {
|
|
@@ -20302,6 +20414,22 @@ var RequestError = class extends Error {
|
|
|
20302
20414
|
this.name = "RequestError";
|
|
20303
20415
|
}
|
|
20304
20416
|
};
|
|
20417
|
+
var reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
|
|
20418
|
+
var reDotSegment = /\/\.\.?(?:[/?#]|$)/;
|
|
20419
|
+
var reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
|
|
20420
|
+
var buildUrl = (scheme, host, incomingUrl) => {
|
|
20421
|
+
const url = `${scheme}://${host}${incomingUrl}`;
|
|
20422
|
+
if (!reValidHost.test(host)) {
|
|
20423
|
+
const urlObj = new URL(url);
|
|
20424
|
+
if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
|
|
20425
|
+
return urlObj.href;
|
|
20426
|
+
} else if (incomingUrl.length === 0) return url + "/";
|
|
20427
|
+
else {
|
|
20428
|
+
if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
|
|
20429
|
+
if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
|
|
20430
|
+
return url;
|
|
20431
|
+
}
|
|
20432
|
+
};
|
|
20305
20433
|
var toRequestError = (e) => {
|
|
20306
20434
|
if (e instanceof RequestError) return e;
|
|
20307
20435
|
return new RequestError(e.message, { cause: e });
|
|
@@ -20309,17 +20437,21 @@ var toRequestError = (e) => {
|
|
|
20309
20437
|
var GlobalRequest = global.Request;
|
|
20310
20438
|
var Request$1 = class extends GlobalRequest {
|
|
20311
20439
|
constructor(input, options) {
|
|
20312
|
-
if (typeof input === "object" && getRequestCache in input)
|
|
20313
|
-
|
|
20440
|
+
if (typeof input === "object" && getRequestCache in input) {
|
|
20441
|
+
const hasReplacementBody = options !== void 0 && "body" in options && options.body != null;
|
|
20442
|
+
if (input[bodyConsumedDirectlyKey] && !hasReplacementBody) throw new TypeError("Cannot construct a Request with a Request object that has already been used.");
|
|
20443
|
+
input = input[getRequestCache]();
|
|
20444
|
+
}
|
|
20445
|
+
if (typeof (options?.body)?.getReader !== "undefined") options.duplex ??= "half";
|
|
20314
20446
|
super(input, options);
|
|
20315
20447
|
}
|
|
20316
20448
|
};
|
|
20317
20449
|
var newHeadersFromIncoming = (incoming) => {
|
|
20318
20450
|
const headerRecord = [];
|
|
20319
20451
|
const rawHeaders = incoming.rawHeaders;
|
|
20320
|
-
for (let i = 0
|
|
20321
|
-
const
|
|
20322
|
-
if (key.charCodeAt(0) !== 58) headerRecord.push([key,
|
|
20452
|
+
for (let i = 0, len = rawHeaders.length; i < len; i += 2) {
|
|
20453
|
+
const key = rawHeaders[i];
|
|
20454
|
+
if (key.charCodeAt(0) !== 58) headerRecord.push([key, rawHeaders[i + 1]]);
|
|
20323
20455
|
}
|
|
20324
20456
|
return new Headers(headerRecord);
|
|
20325
20457
|
};
|
|
@@ -20361,11 +20493,158 @@ var getRequestCache = Symbol("getRequestCache");
|
|
|
20361
20493
|
var requestCache = Symbol("requestCache");
|
|
20362
20494
|
var incomingKey = Symbol("incomingKey");
|
|
20363
20495
|
var urlKey = Symbol("urlKey");
|
|
20496
|
+
var methodKey = Symbol("methodKey");
|
|
20364
20497
|
var headersKey = Symbol("headersKey");
|
|
20365
20498
|
var abortControllerKey = Symbol("abortControllerKey");
|
|
20499
|
+
var getAbortController = Symbol("getAbortController");
|
|
20500
|
+
var abortRequest = Symbol("abortRequest");
|
|
20501
|
+
var bodyBufferKey = Symbol("bodyBuffer");
|
|
20502
|
+
var bodyReadPromiseKey = Symbol("bodyReadPromise");
|
|
20503
|
+
var bodyConsumedDirectlyKey = Symbol("bodyConsumedDirectly");
|
|
20504
|
+
var bodyLockReaderKey = Symbol("bodyLockReader");
|
|
20505
|
+
var abortReasonKey = Symbol("abortReason");
|
|
20506
|
+
var newBodyUnusableError = () => {
|
|
20507
|
+
return /* @__PURE__ */ new TypeError("Body is unusable");
|
|
20508
|
+
};
|
|
20509
|
+
var rejectBodyUnusable = () => {
|
|
20510
|
+
return Promise.reject(newBodyUnusableError());
|
|
20511
|
+
};
|
|
20512
|
+
var textDecoder = new TextDecoder();
|
|
20513
|
+
var consumeBodyDirectOnce = (request) => {
|
|
20514
|
+
if (request[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
|
|
20515
|
+
request[bodyConsumedDirectlyKey] = true;
|
|
20516
|
+
};
|
|
20517
|
+
var toArrayBuffer = (buf) => {
|
|
20518
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
20519
|
+
};
|
|
20520
|
+
var contentType = (request) => {
|
|
20521
|
+
return (request[headersKey] ||= newHeadersFromIncoming(request[incomingKey])).get("content-type") || "";
|
|
20522
|
+
};
|
|
20523
|
+
var methodTokenRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
20524
|
+
var normalizeIncomingMethod = (method) => {
|
|
20525
|
+
if (typeof method !== "string" || method.length === 0) return "GET";
|
|
20526
|
+
switch (method) {
|
|
20527
|
+
case "DELETE":
|
|
20528
|
+
case "GET":
|
|
20529
|
+
case "HEAD":
|
|
20530
|
+
case "OPTIONS":
|
|
20531
|
+
case "POST":
|
|
20532
|
+
case "PUT": return method;
|
|
20533
|
+
}
|
|
20534
|
+
const upper = method.toUpperCase();
|
|
20535
|
+
switch (upper) {
|
|
20536
|
+
case "DELETE":
|
|
20537
|
+
case "GET":
|
|
20538
|
+
case "HEAD":
|
|
20539
|
+
case "OPTIONS":
|
|
20540
|
+
case "POST":
|
|
20541
|
+
case "PUT": return upper;
|
|
20542
|
+
default: return method;
|
|
20543
|
+
}
|
|
20544
|
+
};
|
|
20545
|
+
var validateDirectReadMethod = (method) => {
|
|
20546
|
+
if (!methodTokenRegExp.test(method)) return /* @__PURE__ */ new TypeError(`'${method}' is not a valid HTTP method.`);
|
|
20547
|
+
const normalized = method.toUpperCase();
|
|
20548
|
+
if (normalized === "CONNECT" || normalized === "TRACK" || normalized === "TRACE" && method !== "TRACE") return /* @__PURE__ */ new TypeError(`'${method}' HTTP method is unsupported.`);
|
|
20549
|
+
};
|
|
20550
|
+
var readBodyWithFastPath = (request, method, fromBuffer) => {
|
|
20551
|
+
if (request[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
|
|
20552
|
+
const methodName = request.method;
|
|
20553
|
+
if (methodName === "GET" || methodName === "HEAD") return request[getRequestCache]()[method]();
|
|
20554
|
+
const methodValidationError = validateDirectReadMethod(methodName);
|
|
20555
|
+
if (methodValidationError) return Promise.reject(methodValidationError);
|
|
20556
|
+
if (request[requestCache]) {
|
|
20557
|
+
if (methodName !== "TRACE") return request[requestCache][method]();
|
|
20558
|
+
}
|
|
20559
|
+
const alreadyUsedError = consumeBodyDirectOnce(request);
|
|
20560
|
+
if (alreadyUsedError) return alreadyUsedError;
|
|
20561
|
+
const raw = readRawBodyIfAvailable(request);
|
|
20562
|
+
if (raw) {
|
|
20563
|
+
const result = Promise.resolve(fromBuffer(raw, request));
|
|
20564
|
+
request[bodyBufferKey] = void 0;
|
|
20565
|
+
return result;
|
|
20566
|
+
}
|
|
20567
|
+
return readBodyDirect(request).then((buf) => {
|
|
20568
|
+
const result = fromBuffer(buf, request);
|
|
20569
|
+
request[bodyBufferKey] = void 0;
|
|
20570
|
+
return result;
|
|
20571
|
+
});
|
|
20572
|
+
};
|
|
20573
|
+
var readRawBodyIfAvailable = (request) => {
|
|
20574
|
+
const incoming = request[incomingKey];
|
|
20575
|
+
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) return incoming.rawBody;
|
|
20576
|
+
};
|
|
20577
|
+
var readBodyDirect = (request) => {
|
|
20578
|
+
if (request[bodyBufferKey]) return Promise.resolve(request[bodyBufferKey]);
|
|
20579
|
+
if (request[bodyReadPromiseKey]) return request[bodyReadPromiseKey];
|
|
20580
|
+
const incoming = request[incomingKey];
|
|
20581
|
+
if (Readable.isDisturbed(incoming)) return rejectBodyUnusable();
|
|
20582
|
+
const promise = new Promise((resolve, reject) => {
|
|
20583
|
+
const chunks = [];
|
|
20584
|
+
let settled = false;
|
|
20585
|
+
const finish = (callback) => {
|
|
20586
|
+
if (settled) return;
|
|
20587
|
+
settled = true;
|
|
20588
|
+
cleanup();
|
|
20589
|
+
callback();
|
|
20590
|
+
};
|
|
20591
|
+
const onData = (chunk) => {
|
|
20592
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
20593
|
+
};
|
|
20594
|
+
const onEnd = () => {
|
|
20595
|
+
finish(() => {
|
|
20596
|
+
const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
|
|
20597
|
+
request[bodyBufferKey] = buffer;
|
|
20598
|
+
resolve(buffer);
|
|
20599
|
+
});
|
|
20600
|
+
};
|
|
20601
|
+
const onError = (error) => {
|
|
20602
|
+
finish(() => {
|
|
20603
|
+
reject(error);
|
|
20604
|
+
});
|
|
20605
|
+
};
|
|
20606
|
+
const onClose = () => {
|
|
20607
|
+
if (incoming.readableEnded) {
|
|
20608
|
+
onEnd();
|
|
20609
|
+
return;
|
|
20610
|
+
}
|
|
20611
|
+
finish(() => {
|
|
20612
|
+
if (incoming.errored) {
|
|
20613
|
+
reject(incoming.errored);
|
|
20614
|
+
return;
|
|
20615
|
+
}
|
|
20616
|
+
const reason = request[abortReasonKey];
|
|
20617
|
+
if (reason !== void 0) {
|
|
20618
|
+
reject(reason instanceof Error ? reason : new Error(String(reason)));
|
|
20619
|
+
return;
|
|
20620
|
+
}
|
|
20621
|
+
reject(/* @__PURE__ */ new Error("Client connection prematurely closed."));
|
|
20622
|
+
});
|
|
20623
|
+
};
|
|
20624
|
+
const cleanup = () => {
|
|
20625
|
+
incoming.off("data", onData);
|
|
20626
|
+
incoming.off("end", onEnd);
|
|
20627
|
+
incoming.off("error", onError);
|
|
20628
|
+
incoming.off("close", onClose);
|
|
20629
|
+
request[bodyReadPromiseKey] = void 0;
|
|
20630
|
+
};
|
|
20631
|
+
incoming.on("data", onData);
|
|
20632
|
+
incoming.on("end", onEnd);
|
|
20633
|
+
incoming.on("error", onError);
|
|
20634
|
+
incoming.on("close", onClose);
|
|
20635
|
+
queueMicrotask(() => {
|
|
20636
|
+
if (settled) return;
|
|
20637
|
+
if (incoming.readableEnded) onEnd();
|
|
20638
|
+
else if (incoming.errored) onError(incoming.errored);
|
|
20639
|
+
else if (incoming.destroyed) onClose();
|
|
20640
|
+
});
|
|
20641
|
+
});
|
|
20642
|
+
request[bodyReadPromiseKey] = promise;
|
|
20643
|
+
return promise;
|
|
20644
|
+
};
|
|
20366
20645
|
var requestPrototype = {
|
|
20367
20646
|
get method() {
|
|
20368
|
-
return this[
|
|
20647
|
+
return this[methodKey];
|
|
20369
20648
|
},
|
|
20370
20649
|
get url() {
|
|
20371
20650
|
return this[urlKey];
|
|
@@ -20373,18 +20652,57 @@ var requestPrototype = {
|
|
|
20373
20652
|
get headers() {
|
|
20374
20653
|
return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
|
|
20375
20654
|
},
|
|
20376
|
-
[
|
|
20377
|
-
this[
|
|
20655
|
+
[abortRequest](reason) {
|
|
20656
|
+
if (this[abortReasonKey] === void 0) this[abortReasonKey] = reason;
|
|
20657
|
+
const abortController = this[abortControllerKey];
|
|
20658
|
+
if (abortController && !abortController.signal.aborted) abortController.abort(reason);
|
|
20659
|
+
},
|
|
20660
|
+
[getAbortController]() {
|
|
20661
|
+
this[abortControllerKey] ||= new AbortController();
|
|
20662
|
+
if (this[abortReasonKey] !== void 0 && !this[abortControllerKey].signal.aborted) this[abortControllerKey].abort(this[abortReasonKey]);
|
|
20378
20663
|
return this[abortControllerKey];
|
|
20379
20664
|
},
|
|
20380
20665
|
[getRequestCache]() {
|
|
20381
|
-
this[
|
|
20382
|
-
|
|
20666
|
+
const abortController = this[getAbortController]();
|
|
20667
|
+
if (this[requestCache]) return this[requestCache];
|
|
20668
|
+
const method = this.method;
|
|
20669
|
+
if (this[bodyConsumedDirectlyKey] && !(method === "GET" || method === "HEAD")) {
|
|
20670
|
+
this[bodyBufferKey] = void 0;
|
|
20671
|
+
const init = {
|
|
20672
|
+
method: method === "TRACE" ? "GET" : method,
|
|
20673
|
+
headers: this.headers,
|
|
20674
|
+
signal: abortController.signal
|
|
20675
|
+
};
|
|
20676
|
+
if (method !== "TRACE") {
|
|
20677
|
+
init.body = new ReadableStream({ start(c) {
|
|
20678
|
+
c.close();
|
|
20679
|
+
} });
|
|
20680
|
+
init.duplex = "half";
|
|
20681
|
+
}
|
|
20682
|
+
const req = new Request$1(this[urlKey], init);
|
|
20683
|
+
if (method === "TRACE") Object.defineProperty(req, "method", { get() {
|
|
20684
|
+
return "TRACE";
|
|
20685
|
+
} });
|
|
20686
|
+
return this[requestCache] = req;
|
|
20687
|
+
}
|
|
20688
|
+
return this[requestCache] = newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], abortController);
|
|
20689
|
+
},
|
|
20690
|
+
get body() {
|
|
20691
|
+
if (!this[bodyConsumedDirectlyKey]) return this[getRequestCache]().body;
|
|
20692
|
+
const request = this[getRequestCache]();
|
|
20693
|
+
if (!this[bodyLockReaderKey] && request.body) this[bodyLockReaderKey] = request.body.getReader();
|
|
20694
|
+
return request.body;
|
|
20695
|
+
},
|
|
20696
|
+
get bodyUsed() {
|
|
20697
|
+
if (this[bodyConsumedDirectlyKey]) return true;
|
|
20698
|
+
if (this[requestCache]) return this[requestCache].bodyUsed;
|
|
20699
|
+
return false;
|
|
20383
20700
|
}
|
|
20384
20701
|
};
|
|
20702
|
+
Object.defineProperty(requestPrototype, "signal", { get() {
|
|
20703
|
+
return this[getAbortController]().signal;
|
|
20704
|
+
} });
|
|
20385
20705
|
[
|
|
20386
|
-
"body",
|
|
20387
|
-
"bodyUsed",
|
|
20388
20706
|
"cache",
|
|
20389
20707
|
"credentials",
|
|
20390
20708
|
"destination",
|
|
@@ -20393,25 +20711,37 @@ var requestPrototype = {
|
|
|
20393
20711
|
"redirect",
|
|
20394
20712
|
"referrer",
|
|
20395
20713
|
"referrerPolicy",
|
|
20396
|
-
"signal",
|
|
20397
20714
|
"keepalive"
|
|
20398
20715
|
].forEach((k) => {
|
|
20399
20716
|
Object.defineProperty(requestPrototype, k, { get() {
|
|
20400
20717
|
return this[getRequestCache]()[k];
|
|
20401
20718
|
} });
|
|
20402
20719
|
});
|
|
20403
|
-
[
|
|
20404
|
-
"arrayBuffer",
|
|
20405
|
-
"blob",
|
|
20406
|
-
"clone",
|
|
20407
|
-
"formData",
|
|
20408
|
-
"json",
|
|
20409
|
-
"text"
|
|
20410
|
-
].forEach((k) => {
|
|
20720
|
+
["clone", "formData"].forEach((k) => {
|
|
20411
20721
|
Object.defineProperty(requestPrototype, k, { value: function() {
|
|
20722
|
+
if (this[bodyConsumedDirectlyKey]) {
|
|
20723
|
+
if (k === "clone") throw newBodyUnusableError();
|
|
20724
|
+
return rejectBodyUnusable();
|
|
20725
|
+
}
|
|
20412
20726
|
return this[getRequestCache]()[k]();
|
|
20413
20727
|
} });
|
|
20414
20728
|
});
|
|
20729
|
+
Object.defineProperty(requestPrototype, "text", { value: function() {
|
|
20730
|
+
return readBodyWithFastPath(this, "text", (buf) => textDecoder.decode(buf));
|
|
20731
|
+
} });
|
|
20732
|
+
Object.defineProperty(requestPrototype, "arrayBuffer", { value: function() {
|
|
20733
|
+
return readBodyWithFastPath(this, "arrayBuffer", (buf) => toArrayBuffer(buf));
|
|
20734
|
+
} });
|
|
20735
|
+
Object.defineProperty(requestPrototype, "blob", { value: function() {
|
|
20736
|
+
return readBodyWithFastPath(this, "blob", (buf, request) => {
|
|
20737
|
+
const type = contentType(request);
|
|
20738
|
+
return new Response(buf, type ? { headers: { "content-type": type } } : void 0).blob();
|
|
20739
|
+
});
|
|
20740
|
+
} });
|
|
20741
|
+
Object.defineProperty(requestPrototype, "json", { value: function() {
|
|
20742
|
+
if (this[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
|
|
20743
|
+
return this.text().then(JSON.parse);
|
|
20744
|
+
} });
|
|
20415
20745
|
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
20416
20746
|
return `Request (lightweight) ${inspectFn({
|
|
20417
20747
|
method: this.method,
|
|
@@ -20427,6 +20757,7 @@ Object.setPrototypeOf(requestPrototype, Request$1.prototype);
|
|
|
20427
20757
|
var newRequest = (incoming, defaultHostname) => {
|
|
20428
20758
|
const req = Object.create(requestPrototype);
|
|
20429
20759
|
req[incomingKey] = incoming;
|
|
20760
|
+
req[methodKey] = normalizeIncomingMethod(incoming.method);
|
|
20430
20761
|
const incomingUrl = incoming.url || "";
|
|
20431
20762
|
if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
|
|
20432
20763
|
if (incoming instanceof Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
|
|
@@ -20444,16 +20775,20 @@ var newRequest = (incoming, defaultHostname) => {
|
|
|
20444
20775
|
scheme = incoming.scheme;
|
|
20445
20776
|
if (!(scheme === "http" || scheme === "https")) throw new RequestError("Unsupported scheme");
|
|
20446
20777
|
} else scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
|
|
20447
|
-
|
|
20448
|
-
|
|
20449
|
-
|
|
20778
|
+
try {
|
|
20779
|
+
req[urlKey] = buildUrl(scheme, host, incomingUrl);
|
|
20780
|
+
} catch (e) {
|
|
20781
|
+
if (e instanceof RequestError) throw e;
|
|
20782
|
+
else throw new RequestError("Invalid URL", { cause: e });
|
|
20783
|
+
}
|
|
20450
20784
|
return req;
|
|
20451
20785
|
};
|
|
20786
|
+
var defaultContentType = "text/plain; charset=UTF-8";
|
|
20452
20787
|
var responseCache = Symbol("responseCache");
|
|
20453
20788
|
var getResponseCache = Symbol("getResponseCache");
|
|
20454
20789
|
var cacheKey = Symbol("cache");
|
|
20455
20790
|
var GlobalResponse = global.Response;
|
|
20456
|
-
var
|
|
20791
|
+
var Response$1 = class Response$1 {
|
|
20457
20792
|
#body;
|
|
20458
20793
|
#init;
|
|
20459
20794
|
[getResponseCache]() {
|
|
@@ -20463,7 +20798,7 @@ var Response2 = class _Response {
|
|
|
20463
20798
|
constructor(body, init) {
|
|
20464
20799
|
let headers;
|
|
20465
20800
|
this.#body = body;
|
|
20466
|
-
if (init instanceof
|
|
20801
|
+
if (init instanceof Response$1) {
|
|
20467
20802
|
const cachedGlobalResponse = init[responseCache];
|
|
20468
20803
|
if (cachedGlobalResponse) {
|
|
20469
20804
|
this.#init = cachedGlobalResponse;
|
|
@@ -20474,16 +20809,16 @@ var Response2 = class _Response {
|
|
|
20474
20809
|
headers = new Headers(init.#init.headers);
|
|
20475
20810
|
}
|
|
20476
20811
|
} else this.#init = init;
|
|
20477
|
-
if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
|
|
20812
|
+
if (body == null || typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
|
|
20478
20813
|
init?.status || 200,
|
|
20479
|
-
body,
|
|
20814
|
+
body ?? null,
|
|
20480
20815
|
headers || init?.headers
|
|
20481
20816
|
];
|
|
20482
20817
|
}
|
|
20483
20818
|
get headers() {
|
|
20484
20819
|
const cache = this[cacheKey];
|
|
20485
20820
|
if (cache) {
|
|
20486
|
-
if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || { "content-type":
|
|
20821
|
+
if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || (cache[1] === null ? void 0 : { "content-type": defaultContentType }));
|
|
20487
20822
|
return cache[2];
|
|
20488
20823
|
}
|
|
20489
20824
|
return this[getResponseCache]().headers;
|
|
@@ -20505,7 +20840,7 @@ var Response2 = class _Response {
|
|
|
20505
20840
|
"type",
|
|
20506
20841
|
"url"
|
|
20507
20842
|
].forEach((k) => {
|
|
20508
|
-
Object.defineProperty(
|
|
20843
|
+
Object.defineProperty(Response$1.prototype, k, { get() {
|
|
20509
20844
|
return this[getResponseCache]()[k];
|
|
20510
20845
|
} });
|
|
20511
20846
|
});
|
|
@@ -20517,11 +20852,11 @@ var Response2 = class _Response {
|
|
|
20517
20852
|
"json",
|
|
20518
20853
|
"text"
|
|
20519
20854
|
].forEach((k) => {
|
|
20520
|
-
Object.defineProperty(
|
|
20855
|
+
Object.defineProperty(Response$1.prototype, k, { value: function() {
|
|
20521
20856
|
return this[getResponseCache]()[k]();
|
|
20522
20857
|
} });
|
|
20523
20858
|
});
|
|
20524
|
-
Object.defineProperty(
|
|
20859
|
+
Object.defineProperty(Response$1.prototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
20525
20860
|
return `Response (lightweight) ${inspectFn({
|
|
20526
20861
|
status: this.status,
|
|
20527
20862
|
headers: this.headers,
|
|
@@ -20532,8 +20867,51 @@ Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custo
|
|
|
20532
20867
|
depth: depth == null ? null : depth - 1
|
|
20533
20868
|
})}`;
|
|
20534
20869
|
} });
|
|
20535
|
-
Object.setPrototypeOf(
|
|
20536
|
-
Object.setPrototypeOf(
|
|
20870
|
+
Object.setPrototypeOf(Response$1, GlobalResponse);
|
|
20871
|
+
Object.setPrototypeOf(Response$1.prototype, GlobalResponse.prototype);
|
|
20872
|
+
var validRedirectUrl = /^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/;
|
|
20873
|
+
var parseRedirectUrl = (url) => {
|
|
20874
|
+
if (url instanceof URL) return url.href;
|
|
20875
|
+
if (validRedirectUrl.test(url)) return url;
|
|
20876
|
+
return new URL(url).href;
|
|
20877
|
+
};
|
|
20878
|
+
var validRedirectStatuses = new Set([
|
|
20879
|
+
301,
|
|
20880
|
+
302,
|
|
20881
|
+
303,
|
|
20882
|
+
307,
|
|
20883
|
+
308
|
|
20884
|
+
]);
|
|
20885
|
+
Object.defineProperty(Response$1, "redirect", {
|
|
20886
|
+
value: function redirect(url, status = 302) {
|
|
20887
|
+
if (!validRedirectStatuses.has(status)) throw new RangeError("Invalid status code");
|
|
20888
|
+
return new Response$1(null, {
|
|
20889
|
+
status,
|
|
20890
|
+
headers: { location: parseRedirectUrl(url) }
|
|
20891
|
+
});
|
|
20892
|
+
},
|
|
20893
|
+
writable: true,
|
|
20894
|
+
configurable: true
|
|
20895
|
+
});
|
|
20896
|
+
Object.defineProperty(Response$1, "json", {
|
|
20897
|
+
value: function json(data, init) {
|
|
20898
|
+
const body = JSON.stringify(data);
|
|
20899
|
+
if (body === void 0) throw new TypeError("The data is not JSON serializable");
|
|
20900
|
+
const initHeaders = init?.headers;
|
|
20901
|
+
let headers;
|
|
20902
|
+
if (initHeaders) {
|
|
20903
|
+
headers = new Headers(initHeaders);
|
|
20904
|
+
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
20905
|
+
} else headers = { "content-type": "application/json" };
|
|
20906
|
+
return new Response$1(body, {
|
|
20907
|
+
status: init?.status ?? 200,
|
|
20908
|
+
statusText: init?.statusText,
|
|
20909
|
+
headers
|
|
20910
|
+
});
|
|
20911
|
+
},
|
|
20912
|
+
writable: true,
|
|
20913
|
+
configurable: true
|
|
20914
|
+
});
|
|
20537
20915
|
async function readWithoutBlocking(readPromise) {
|
|
20538
20916
|
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
|
|
20539
20917
|
}
|
|
@@ -20569,18 +20947,18 @@ function writeFromReadableStream(stream, writable) {
|
|
|
20569
20947
|
else if (writable.destroyed) return;
|
|
20570
20948
|
return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
|
|
20571
20949
|
}
|
|
20572
|
-
var buildOutgoingHttpHeaders = (headers) => {
|
|
20950
|
+
var buildOutgoingHttpHeaders = (headers, defaultContentType) => {
|
|
20573
20951
|
const res = {};
|
|
20574
20952
|
if (!(headers instanceof Headers)) headers = new Headers(headers ?? void 0);
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20953
|
+
if (headers.has("set-cookie")) {
|
|
20954
|
+
const cookies = [];
|
|
20955
|
+
for (const [k, v] of headers) if (k === "set-cookie") cookies.push(v);
|
|
20956
|
+
else res[k] = v;
|
|
20957
|
+
if (cookies.length > 0) res["set-cookie"] = cookies;
|
|
20958
|
+
} else for (const [k, v] of headers) res[k] = v;
|
|
20959
|
+
if (defaultContentType) res["content-type"] ??= defaultContentType;
|
|
20580
20960
|
return res;
|
|
20581
20961
|
};
|
|
20582
|
-
var X_ALREADY_SENT = "x-hono-already-sent";
|
|
20583
|
-
if (typeof global.crypto === "undefined") global.crypto = crypto$2;
|
|
20584
20962
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
20585
20963
|
var incomingDraining = Symbol("incomingDraining");
|
|
20586
20964
|
var DRAIN_TIMEOUT_MS = 500;
|
|
@@ -20618,6 +20996,20 @@ var drainIncoming = (incoming) => {
|
|
|
20618
20996
|
incoming.on("error", cleanup);
|
|
20619
20997
|
incoming.resume();
|
|
20620
20998
|
};
|
|
20999
|
+
var makeCloseHandler = (req, incoming, outgoing, needsBodyCleanup) => () => {
|
|
21000
|
+
if (incoming.errored) req[abortRequest](incoming.errored.toString());
|
|
21001
|
+
else if (!outgoing.writableFinished) req[abortRequest]("Client connection prematurely closed.");
|
|
21002
|
+
if (needsBodyCleanup && !incoming.readableEnded) setTimeout(() => {
|
|
21003
|
+
if (!incoming.readableEnded) setTimeout(() => {
|
|
21004
|
+
drainIncoming(incoming);
|
|
21005
|
+
});
|
|
21006
|
+
});
|
|
21007
|
+
};
|
|
21008
|
+
var isImmediateCacheableResponse = (res) => {
|
|
21009
|
+
if (!(cacheKey in res)) return false;
|
|
21010
|
+
const body = res[cacheKey][1];
|
|
21011
|
+
return body === null || typeof body === "string" || body instanceof Uint8Array;
|
|
21012
|
+
};
|
|
20621
21013
|
var handleRequestError = () => new Response(null, { status: 400 });
|
|
20622
21014
|
var handleFetchError = (e) => new Response(null, { status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500 });
|
|
20623
21015
|
var handleResponseError = (e, outgoing) => {
|
|
@@ -20635,15 +21027,44 @@ var flushHeaders = (outgoing) => {
|
|
|
20635
21027
|
};
|
|
20636
21028
|
var responseViaCache = async (res, outgoing) => {
|
|
20637
21029
|
let [status, body, header] = res[cacheKey];
|
|
21030
|
+
if (!header) {
|
|
21031
|
+
if (body === null) {
|
|
21032
|
+
outgoing.writeHead(status);
|
|
21033
|
+
outgoing.end();
|
|
21034
|
+
} else if (typeof body === "string") {
|
|
21035
|
+
outgoing.writeHead(status, {
|
|
21036
|
+
"Content-Type": defaultContentType,
|
|
21037
|
+
"Content-Length": Buffer.byteLength(body)
|
|
21038
|
+
});
|
|
21039
|
+
outgoing.end(body);
|
|
21040
|
+
} else if (body instanceof Uint8Array) {
|
|
21041
|
+
outgoing.writeHead(status, {
|
|
21042
|
+
"Content-Type": defaultContentType,
|
|
21043
|
+
"Content-Length": body.byteLength
|
|
21044
|
+
});
|
|
21045
|
+
outgoing.end(body);
|
|
21046
|
+
} else if (body instanceof Blob) {
|
|
21047
|
+
outgoing.writeHead(status, {
|
|
21048
|
+
"Content-Type": defaultContentType,
|
|
21049
|
+
"Content-Length": body.size
|
|
21050
|
+
});
|
|
21051
|
+
outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
21052
|
+
} else {
|
|
21053
|
+
outgoing.writeHead(status, { "Content-Type": defaultContentType });
|
|
21054
|
+
flushHeaders(outgoing);
|
|
21055
|
+
await writeFromReadableStream(body, outgoing)?.catch((e) => handleResponseError(e, outgoing));
|
|
21056
|
+
}
|
|
21057
|
+
outgoing[outgoingEnded]?.();
|
|
21058
|
+
return;
|
|
21059
|
+
}
|
|
20638
21060
|
let hasContentLength = false;
|
|
20639
|
-
if (
|
|
20640
|
-
else if (header instanceof Headers) {
|
|
21061
|
+
if (header instanceof Headers) {
|
|
20641
21062
|
hasContentLength = header.has("content-length");
|
|
20642
|
-
header = buildOutgoingHttpHeaders(header);
|
|
21063
|
+
header = buildOutgoingHttpHeaders(header, body === null ? void 0 : defaultContentType);
|
|
20643
21064
|
} else if (Array.isArray(header)) {
|
|
20644
21065
|
const headerObj = new Headers(header);
|
|
20645
21066
|
hasContentLength = headerObj.has("content-length");
|
|
20646
|
-
header = buildOutgoingHttpHeaders(headerObj);
|
|
21067
|
+
header = buildOutgoingHttpHeaders(headerObj, body === null ? void 0 : defaultContentType);
|
|
20647
21068
|
} else for (const key in header) if (key.length === 14 && key.toLowerCase() === "content-length") {
|
|
20648
21069
|
hasContentLength = true;
|
|
20649
21070
|
break;
|
|
@@ -20654,7 +21075,8 @@ var responseViaCache = async (res, outgoing) => {
|
|
|
20654
21075
|
else if (body instanceof Blob) header["Content-Length"] = body.size;
|
|
20655
21076
|
}
|
|
20656
21077
|
outgoing.writeHead(status, header);
|
|
20657
|
-
if (
|
|
21078
|
+
if (body == null) outgoing.end();
|
|
21079
|
+
else if (typeof body === "string" || body instanceof Uint8Array) outgoing.end(body);
|
|
20658
21080
|
else if (body instanceof Blob) outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
20659
21081
|
else {
|
|
20660
21082
|
flushHeaders(outgoing);
|
|
@@ -20673,7 +21095,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
20673
21095
|
}
|
|
20674
21096
|
else res = await res.catch(handleFetchError);
|
|
20675
21097
|
if (cacheKey in res) return responseViaCache(res, outgoing);
|
|
20676
|
-
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
|
|
21098
|
+
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers, res.body === null ? void 0 : defaultContentType);
|
|
20677
21099
|
if (res.body) {
|
|
20678
21100
|
const reader = res.body.getReader();
|
|
20679
21101
|
const values = [];
|
|
@@ -20713,7 +21135,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
20713
21135
|
if (values.length === 0) flushHeaders(outgoing);
|
|
20714
21136
|
await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
|
|
20715
21137
|
}
|
|
20716
|
-
} else if (resHeaderRecord[
|
|
21138
|
+
} else if (resHeaderRecord["x-hono-already-sent"]) {} else {
|
|
20717
21139
|
outgoing.writeHead(res.status, resHeaderRecord);
|
|
20718
21140
|
outgoing.end();
|
|
20719
21141
|
}
|
|
@@ -20723,47 +21145,45 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
20723
21145
|
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
20724
21146
|
if (options.overrideGlobalObjects !== false && global.Request !== Request$1) {
|
|
20725
21147
|
Object.defineProperty(global, "Request", { value: Request$1 });
|
|
20726
|
-
Object.defineProperty(global, "Response", { value:
|
|
21148
|
+
Object.defineProperty(global, "Response", { value: Response$1 });
|
|
20727
21149
|
}
|
|
20728
21150
|
return async (incoming, outgoing) => {
|
|
20729
21151
|
let res, req;
|
|
21152
|
+
let needsBodyCleanup = false;
|
|
21153
|
+
let closeHandlerAttached = false;
|
|
21154
|
+
const ensureCloseHandler = () => {
|
|
21155
|
+
if (!req || closeHandlerAttached) return;
|
|
21156
|
+
closeHandlerAttached = true;
|
|
21157
|
+
outgoing.on("close", makeCloseHandler(req, incoming, outgoing, needsBodyCleanup));
|
|
21158
|
+
};
|
|
20730
21159
|
try {
|
|
20731
21160
|
req = newRequest(incoming, options.hostname);
|
|
20732
|
-
|
|
20733
|
-
if (
|
|
21161
|
+
needsBodyCleanup = autoCleanupIncoming && !(incoming.method === "GET" || incoming.method === "HEAD");
|
|
21162
|
+
if (needsBodyCleanup) {
|
|
20734
21163
|
incoming[wrapBodyStream] = true;
|
|
20735
|
-
incoming.on("end", () => {
|
|
20736
|
-
incomingEnded = true;
|
|
20737
|
-
});
|
|
20738
21164
|
if (incoming instanceof Http2ServerRequest) outgoing[outgoingEnded] = () => {
|
|
20739
|
-
if (!
|
|
20740
|
-
if (!
|
|
20741
|
-
|
|
21165
|
+
if (!incoming.readableEnded) setTimeout(() => {
|
|
21166
|
+
if (!incoming.readableEnded) setTimeout(() => {
|
|
21167
|
+
incoming.destroy();
|
|
21168
|
+
outgoing.destroy();
|
|
20742
21169
|
});
|
|
20743
21170
|
});
|
|
20744
21171
|
};
|
|
20745
|
-
outgoing.on("finish", () => {
|
|
20746
|
-
if (!incomingEnded) drainIncoming(incoming);
|
|
20747
|
-
});
|
|
20748
21172
|
}
|
|
20749
|
-
outgoing.on("close", () => {
|
|
20750
|
-
if (req[abortControllerKey]) {
|
|
20751
|
-
if (incoming.errored) req[abortControllerKey].abort(incoming.errored.toString());
|
|
20752
|
-
else if (!outgoing.writableFinished) req[abortControllerKey].abort("Client connection prematurely closed.");
|
|
20753
|
-
}
|
|
20754
|
-
if (!incomingEnded) setTimeout(() => {
|
|
20755
|
-
if (!incomingEnded) setTimeout(() => {
|
|
20756
|
-
drainIncoming(incoming);
|
|
20757
|
-
});
|
|
20758
|
-
});
|
|
20759
|
-
});
|
|
20760
21173
|
res = fetchCallback(req, {
|
|
20761
21174
|
incoming,
|
|
20762
21175
|
outgoing
|
|
20763
21176
|
});
|
|
20764
|
-
if (
|
|
21177
|
+
if (!isPromise(res) && isImmediateCacheableResponse(res)) {
|
|
21178
|
+
if (needsBodyCleanup && !incoming.readableEnded) outgoing.once("finish", () => {
|
|
21179
|
+
if (!incoming.readableEnded) drainIncoming(incoming);
|
|
21180
|
+
});
|
|
21181
|
+
return responseViaCache(res, outgoing);
|
|
21182
|
+
}
|
|
21183
|
+
ensureCloseHandler();
|
|
20765
21184
|
} catch (e) {
|
|
20766
21185
|
if (!res) if (options.errorHandler) {
|
|
21186
|
+
ensureCloseHandler();
|
|
20767
21187
|
res = await options.errorHandler(req ? e : toRequestError(e));
|
|
20768
21188
|
if (!res) return;
|
|
20769
21189
|
} else if (!req) res = handleRequestError();
|
|
@@ -20777,6 +21197,160 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
20777
21197
|
}
|
|
20778
21198
|
};
|
|
20779
21199
|
};
|
|
21200
|
+
/**
|
|
21201
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
|
21202
|
+
*/
|
|
21203
|
+
var CloseEvent$1 = globalThis.CloseEvent ?? class extends Event {
|
|
21204
|
+
#eventInitDict;
|
|
21205
|
+
constructor(type, eventInitDict = {}) {
|
|
21206
|
+
super(type, eventInitDict);
|
|
21207
|
+
this.#eventInitDict = eventInitDict;
|
|
21208
|
+
}
|
|
21209
|
+
get wasClean() {
|
|
21210
|
+
return this.#eventInitDict.wasClean ?? false;
|
|
21211
|
+
}
|
|
21212
|
+
get code() {
|
|
21213
|
+
return this.#eventInitDict.code ?? 0;
|
|
21214
|
+
}
|
|
21215
|
+
get reason() {
|
|
21216
|
+
return this.#eventInitDict.reason ?? "";
|
|
21217
|
+
}
|
|
21218
|
+
};
|
|
21219
|
+
var generateConnectionSymbol$1 = () => Symbol("connection");
|
|
21220
|
+
var CONNECTION_SYMBOL_KEY$1 = Symbol("CONNECTION_SYMBOL_KEY");
|
|
21221
|
+
var WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
|
|
21222
|
+
var rejectUpgradeRequest = (socket, status) => {
|
|
21223
|
+
socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\nConnection: close\r
|
|
21224
|
+
Content-Length: 0\r
|
|
21225
|
+
\r
|
|
21226
|
+
`);
|
|
21227
|
+
};
|
|
21228
|
+
var createUpgradeRequest = (request) => {
|
|
21229
|
+
const protocol = request.socket.encrypted ? "https" : "http";
|
|
21230
|
+
const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
|
|
21231
|
+
const headers = new Headers();
|
|
21232
|
+
for (const key in request.headers) {
|
|
21233
|
+
const value = request.headers[key];
|
|
21234
|
+
if (!value) continue;
|
|
21235
|
+
headers.append(key, Array.isArray(value) ? value[0] : value);
|
|
21236
|
+
}
|
|
21237
|
+
return new Request(url, { headers });
|
|
21238
|
+
};
|
|
21239
|
+
var setupWebSocket = (options) => {
|
|
21240
|
+
const { server, fetchCallback, wss } = options;
|
|
21241
|
+
const waiterMap = /* @__PURE__ */ new Map();
|
|
21242
|
+
wss.on("connection", (ws, request) => {
|
|
21243
|
+
const waiter = waiterMap.get(request);
|
|
21244
|
+
if (waiter) {
|
|
21245
|
+
waiter.resolve(ws);
|
|
21246
|
+
waiterMap.delete(request);
|
|
21247
|
+
}
|
|
21248
|
+
});
|
|
21249
|
+
const waitForWebSocket = (request, connectionSymbol) => {
|
|
21250
|
+
return new Promise((resolve) => {
|
|
21251
|
+
waiterMap.set(request, {
|
|
21252
|
+
resolve,
|
|
21253
|
+
connectionSymbol
|
|
21254
|
+
});
|
|
21255
|
+
});
|
|
21256
|
+
};
|
|
21257
|
+
server.on("upgrade", async (request, socket, head) => {
|
|
21258
|
+
if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
|
|
21259
|
+
const env = {
|
|
21260
|
+
incoming: request,
|
|
21261
|
+
outgoing: void 0,
|
|
21262
|
+
wss,
|
|
21263
|
+
[WAIT_FOR_WEBSOCKET_SYMBOL]: waitForWebSocket
|
|
21264
|
+
};
|
|
21265
|
+
let status = 400;
|
|
21266
|
+
try {
|
|
21267
|
+
const response = await fetchCallback(createUpgradeRequest(request), env);
|
|
21268
|
+
if (response instanceof Response) status = response.status;
|
|
21269
|
+
} catch {
|
|
21270
|
+
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
|
|
21271
|
+
return;
|
|
21272
|
+
}
|
|
21273
|
+
const waiter = waiterMap.get(request);
|
|
21274
|
+
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY$1]) {
|
|
21275
|
+
waiterMap.delete(request);
|
|
21276
|
+
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, status);
|
|
21277
|
+
return;
|
|
21278
|
+
}
|
|
21279
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
21280
|
+
wss.emit("connection", ws, request);
|
|
21281
|
+
});
|
|
21282
|
+
});
|
|
21283
|
+
server.on("close", () => {
|
|
21284
|
+
wss.close();
|
|
21285
|
+
});
|
|
21286
|
+
};
|
|
21287
|
+
defineWebSocketHelper(async (c, events, options) => {
|
|
21288
|
+
if (c.req.header("upgrade")?.toLowerCase() !== "websocket") return;
|
|
21289
|
+
const env = c.env;
|
|
21290
|
+
const waitForWebSocket = env[WAIT_FOR_WEBSOCKET_SYMBOL];
|
|
21291
|
+
if (!waitForWebSocket || !env.incoming) return new Response(null, { status: 500 });
|
|
21292
|
+
const connectionSymbol = generateConnectionSymbol$1();
|
|
21293
|
+
env[CONNECTION_SYMBOL_KEY$1] = connectionSymbol;
|
|
21294
|
+
(async () => {
|
|
21295
|
+
const ws = await waitForWebSocket(env.incoming, connectionSymbol);
|
|
21296
|
+
const messagesReceivedInStarting = [];
|
|
21297
|
+
const bufferMessage = (data, isBinary) => {
|
|
21298
|
+
messagesReceivedInStarting.push([data, isBinary]);
|
|
21299
|
+
};
|
|
21300
|
+
ws.on("message", bufferMessage);
|
|
21301
|
+
const ctx = {
|
|
21302
|
+
binaryType: "arraybuffer",
|
|
21303
|
+
close(code, reason) {
|
|
21304
|
+
ws.close(code, reason);
|
|
21305
|
+
},
|
|
21306
|
+
protocol: ws.protocol,
|
|
21307
|
+
raw: ws,
|
|
21308
|
+
get readyState() {
|
|
21309
|
+
return ws.readyState;
|
|
21310
|
+
},
|
|
21311
|
+
send(source, opts) {
|
|
21312
|
+
ws.send(source, { compress: opts?.compress });
|
|
21313
|
+
},
|
|
21314
|
+
url: new URL(c.req.url)
|
|
21315
|
+
};
|
|
21316
|
+
try {
|
|
21317
|
+
events?.onOpen?.(new Event("open"), ctx);
|
|
21318
|
+
} catch (e) {
|
|
21319
|
+
(options?.onError ?? console.error)(e);
|
|
21320
|
+
}
|
|
21321
|
+
const handleMessage = (data, isBinary) => {
|
|
21322
|
+
const datas = Array.isArray(data) ? data : [data];
|
|
21323
|
+
for (const data of datas) try {
|
|
21324
|
+
events?.onMessage?.(new MessageEvent("message", { data: isBinary ? data instanceof ArrayBuffer ? data : data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) : data.toString("utf-8") }), ctx);
|
|
21325
|
+
} catch (e) {
|
|
21326
|
+
(options?.onError ?? console.error)(e);
|
|
21327
|
+
}
|
|
21328
|
+
};
|
|
21329
|
+
ws.off("message", bufferMessage);
|
|
21330
|
+
for (const message of messagesReceivedInStarting) handleMessage(...message);
|
|
21331
|
+
ws.on("message", (data, isBinary) => {
|
|
21332
|
+
handleMessage(data, isBinary);
|
|
21333
|
+
});
|
|
21334
|
+
ws.on("close", (code, reason) => {
|
|
21335
|
+
try {
|
|
21336
|
+
events?.onClose?.(new CloseEvent$1("close", {
|
|
21337
|
+
code,
|
|
21338
|
+
reason: reason.toString()
|
|
21339
|
+
}), ctx);
|
|
21340
|
+
} catch (e) {
|
|
21341
|
+
(options?.onError ?? console.error)(e);
|
|
21342
|
+
}
|
|
21343
|
+
});
|
|
21344
|
+
ws.on("error", (error) => {
|
|
21345
|
+
try {
|
|
21346
|
+
events?.onError?.(new ErrorEvent("error", { error }), ctx);
|
|
21347
|
+
} catch (e) {
|
|
21348
|
+
(options?.onError ?? console.error)(e);
|
|
21349
|
+
}
|
|
21350
|
+
});
|
|
21351
|
+
})();
|
|
21352
|
+
return new Response();
|
|
21353
|
+
});
|
|
20780
21354
|
var createAdaptorServer = (options) => {
|
|
20781
21355
|
const fetchCallback = options.fetch;
|
|
20782
21356
|
const requestListener = getRequestListener(fetchCallback, {
|
|
@@ -20784,7 +21358,16 @@ var createAdaptorServer = (options) => {
|
|
|
20784
21358
|
overrideGlobalObjects: options.overrideGlobalObjects,
|
|
20785
21359
|
autoCleanupIncoming: options.autoCleanupIncoming
|
|
20786
21360
|
});
|
|
20787
|
-
|
|
21361
|
+
const server = (options.createServer || createServer)(options.serverOptions || {}, requestListener);
|
|
21362
|
+
if (options.websocket && options.websocket.server) {
|
|
21363
|
+
if (options.websocket.server.options.noServer !== true) throw new Error("WebSocket server must be created with { noServer: true } option");
|
|
21364
|
+
setupWebSocket({
|
|
21365
|
+
server,
|
|
21366
|
+
fetchCallback,
|
|
21367
|
+
wss: options.websocket.server
|
|
21368
|
+
});
|
|
21369
|
+
}
|
|
21370
|
+
return server;
|
|
20788
21371
|
};
|
|
20789
21372
|
var serve = (options, listeningListener) => {
|
|
20790
21373
|
const server = createAdaptorServer(options);
|
|
@@ -20839,8 +21422,9 @@ var OB11Http = class {
|
|
|
20839
21422
|
return new Promise((resolve) => {
|
|
20840
21423
|
if (this.server) {
|
|
20841
21424
|
this.ctx.logger.info("OneBot V11 HTTP Server closing...");
|
|
20842
|
-
this.server
|
|
20843
|
-
|
|
21425
|
+
const server = this.server;
|
|
21426
|
+
server.closeAllConnections();
|
|
21427
|
+
server.close((err) => {
|
|
20844
21428
|
if (err) this.ctx.logger.error(`OneBot V11 HTTP Server closing ${err}`);
|
|
20845
21429
|
else this.ctx.logger.info("OneBot V11 HTTP Server closed");
|
|
20846
21430
|
this.server = void 0;
|
|
@@ -20925,7 +21509,7 @@ var OB11HttpPost = class {
|
|
|
20925
21509
|
}
|
|
20926
21510
|
start() {
|
|
20927
21511
|
this.activated = this.config.enable;
|
|
20928
|
-
if (this.config.enableHeart && !this.disposeInterval) this.disposeInterval = this.ctx.
|
|
21512
|
+
if (this.config.enableHeart && !this.disposeInterval) this.disposeInterval = this.ctx.interval(() => {
|
|
20929
21513
|
this.emitEvent(new OB11HeartbeatEvent(selfInfo.online, true, this.config.heartInterval));
|
|
20930
21514
|
}, this.config.heartInterval);
|
|
20931
21515
|
}
|
|
@@ -21082,6 +21666,8 @@ var ActionName = /* @__PURE__ */ function(ActionName) {
|
|
|
21082
21666
|
ActionName["SetDoubtFriendsAddRequest"] = "set_doubt_friends_add_request";
|
|
21083
21667
|
ActionName["DeleteGroupNotice"] = "_delete_group_notice";
|
|
21084
21668
|
ActionName["SendPoke"] = "send_poke";
|
|
21669
|
+
ActionName["SetInputStatus"] = "set_input_status";
|
|
21670
|
+
ActionName["GetGroupAlbumMediaList"] = "get_group_album_media_list";
|
|
21085
21671
|
ActionName["SendLike"] = "send_like";
|
|
21086
21672
|
ActionName["GetLoginInfo"] = "get_login_info";
|
|
21087
21673
|
ActionName["GetFriendList"] = "get_friend_list";
|
|
@@ -21158,15 +21744,24 @@ var GetMsg = class extends BaseAction {
|
|
|
21158
21744
|
async _handle(payload, config) {
|
|
21159
21745
|
const msgInfo = await this.ctx.store.getMsgInfoByShortId(+payload.message_id);
|
|
21160
21746
|
if (!msgInfo) throw new Error("消息不存在");
|
|
21161
|
-
let
|
|
21162
|
-
|
|
21163
|
-
|
|
21164
|
-
|
|
21165
|
-
|
|
21166
|
-
|
|
21747
|
+
let status = "normal";
|
|
21748
|
+
let msg;
|
|
21749
|
+
const res = await this.ctx.ntMsgApi.getMsgsByMsgId(msgInfo.peer, [msgInfo.msgId]);
|
|
21750
|
+
if (res.msgList.length === 0 || res.msgList[0].elements[0].grayTipElement?.revokeElement) {
|
|
21751
|
+
const msgCache = this.ctx.store.getMsgCache(msgInfo.msgId);
|
|
21752
|
+
if (msgCache) {
|
|
21753
|
+
msg = msgCache;
|
|
21754
|
+
status = "deleted";
|
|
21755
|
+
} else if (res.msgList.length === 0) throw new Error("无法获取该消息");
|
|
21756
|
+
else {
|
|
21757
|
+
msg = res.msgList[0];
|
|
21758
|
+
status = "deleted";
|
|
21759
|
+
}
|
|
21760
|
+
} else msg = res.msgList[0];
|
|
21167
21761
|
const retMsg = await OB11Entities.message(this.ctx, msg, void 0, void 0, config);
|
|
21168
21762
|
if (!retMsg) throw new Error("消息为空");
|
|
21169
21763
|
retMsg.real_id = retMsg.message_seq;
|
|
21764
|
+
retMsg.status = status;
|
|
21170
21765
|
return retMsg;
|
|
21171
21766
|
}
|
|
21172
21767
|
};
|
|
@@ -23259,7 +23854,8 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23259
23854
|
"forward",
|
|
23260
23855
|
"node",
|
|
23261
23856
|
"video",
|
|
23262
|
-
"file"
|
|
23857
|
+
"file",
|
|
23858
|
+
"at"
|
|
23263
23859
|
];
|
|
23264
23860
|
results;
|
|
23265
23861
|
children;
|
|
@@ -23290,7 +23886,7 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23290
23886
|
}
|
|
23291
23887
|
async flush() {
|
|
23292
23888
|
if (this.children.length === 0 && !this.content) return;
|
|
23293
|
-
const nick = this.name
|
|
23889
|
+
const nick = this.name ?? selfInfo.nick;
|
|
23294
23890
|
if (this.news.length < 4) this.news.push({ text: `${nick}: ${this.preview}` });
|
|
23295
23891
|
this.results.push({
|
|
23296
23892
|
routingHead: {
|
|
@@ -23536,7 +24132,7 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23536
24132
|
} });
|
|
23537
24133
|
} else {
|
|
23538
24134
|
const data = await this.ctx.ntFileApi.uploadC2CFile(this.peer.peerUid, path, fileName);
|
|
23539
|
-
|
|
24135
|
+
const extra = Msg.FileExtra.encode({ file: {
|
|
23540
24136
|
fileType: 0,
|
|
23541
24137
|
fileUuid: data.fileId,
|
|
23542
24138
|
fileMd5: data.file10MMd5,
|
|
@@ -23547,8 +24143,25 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23547
24143
|
expireTime: Math.floor(Date.now() / 1e3 + 10080 * 60),
|
|
23548
24144
|
fileIdCrcMedia: data.crcMedia
|
|
23549
24145
|
} });
|
|
24146
|
+
this.content = extra;
|
|
23550
24147
|
}
|
|
23551
24148
|
this.preview += `[文件] ${fileName}`;
|
|
24149
|
+
} else if (type === OB11MessageDataType.At) {
|
|
24150
|
+
if (!this.isGroup) return;
|
|
24151
|
+
let str;
|
|
24152
|
+
if (isNonNullable(data.name)) str = `@${data.name}`;
|
|
24153
|
+
else if (data.qq === "all") str = "@全体成员";
|
|
24154
|
+
else {
|
|
24155
|
+
const uid = await this.ctx.ntUserApi.getUidByUin(data.qq, this.isGroup ? this.peer.peerUid : void 0);
|
|
24156
|
+
try {
|
|
24157
|
+
const info = await this.ctx.ntGroupApi.getGroupMember(this.peer.peerUid, uid, false, 50);
|
|
24158
|
+
str = `@${info.cardName || info.nick}`;
|
|
24159
|
+
} catch (e) {
|
|
24160
|
+
str = `@${(await this.ctx.ntUserApi.getUserSimpleInfo(uid)).coreInfo.nick}`;
|
|
24161
|
+
}
|
|
24162
|
+
}
|
|
24163
|
+
this.children.push({ text: { str } });
|
|
24164
|
+
this.preview += str;
|
|
23552
24165
|
}
|
|
23553
24166
|
}
|
|
23554
24167
|
async render(segments) {
|
|
@@ -24236,17 +24849,17 @@ var DownloadFile = class extends BaseAction {
|
|
|
24236
24849
|
const isRandomName = !payload.name;
|
|
24237
24850
|
const name = payload.name ? path.basename(payload.name) : randomUUID();
|
|
24238
24851
|
const filePath = path.join(TEMP_DIR, name);
|
|
24239
|
-
if (payload.base64) await fsPromise
|
|
24852
|
+
if (payload.base64) await fsPromise.writeFile(filePath, payload.base64, "base64");
|
|
24240
24853
|
else if (payload.url) {
|
|
24241
24854
|
const headers = this.getHeaders(payload.headers);
|
|
24242
24855
|
const res = await fetchFile(payload.url, headers);
|
|
24243
|
-
await fsPromise
|
|
24856
|
+
await fsPromise.writeFile(filePath, res.data);
|
|
24244
24857
|
} else throw new Error("不存在任何文件, 无法下载");
|
|
24245
|
-
if (fs.existsSync(filePath)) {
|
|
24858
|
+
if (fs$1.existsSync(filePath)) {
|
|
24246
24859
|
if (isRandomName) {
|
|
24247
24860
|
const md5 = await getMd5HexFromFile(filePath);
|
|
24248
24861
|
const newPath = path.join(TEMP_DIR, md5);
|
|
24249
|
-
await fsPromise
|
|
24862
|
+
await fsPromise.rename(filePath, newPath);
|
|
24250
24863
|
return { file: newPath };
|
|
24251
24864
|
}
|
|
24252
24865
|
return { file: filePath };
|
|
@@ -25903,6 +26516,43 @@ var SendPoke = class extends BaseAction {
|
|
|
25903
26516
|
}
|
|
25904
26517
|
};
|
|
25905
26518
|
//#endregion
|
|
26519
|
+
//#region src/onebot11/action/llbot/user/SetInputStatus.ts
|
|
26520
|
+
var SetInputStatus = class extends BaseAction {
|
|
26521
|
+
actionName = ActionName.SetInputStatus;
|
|
26522
|
+
payloadSchema = lib_default$1.object({
|
|
26523
|
+
user_id: lib_default$1.union([Number, String]).required(),
|
|
26524
|
+
event_type: lib_default$1.union([Number, String]).required()
|
|
26525
|
+
});
|
|
26526
|
+
async _handle(payload) {
|
|
26527
|
+
const uin = payload.user_id.toString();
|
|
26528
|
+
const uid = await this.ctx.ntUserApi.getUidByUin(uin);
|
|
26529
|
+
if (!uid) throw new Error("无法获取用户信息");
|
|
26530
|
+
const result = await this.ctx.ntMsgApi.sendShowInputStatusReq(ChatType.C2C, +payload.event_type, uid);
|
|
26531
|
+
if (result.result !== 0) throw new Error(result.errMsg);
|
|
26532
|
+
return null;
|
|
26533
|
+
}
|
|
26534
|
+
};
|
|
26535
|
+
//#endregion
|
|
26536
|
+
//#region src/onebot11/action/llbot/group/GroupAlbum/GetGroupAlbumMediaList.ts
|
|
26537
|
+
var GetGroupAlbumMediaList = class extends BaseAction {
|
|
26538
|
+
actionName = ActionName.GetGroupAlbumMediaList;
|
|
26539
|
+
payloadSchema = lib_default$1.object({
|
|
26540
|
+
group_id: lib_default$1.union([Number, String]).required(),
|
|
26541
|
+
album_id: lib_default$1.string().required(),
|
|
26542
|
+
attach_info: lib_default$1.string()
|
|
26543
|
+
});
|
|
26544
|
+
async _handle(payload) {
|
|
26545
|
+
const res = await this.ctx.ntGroupApi.getGroupAlbumMediaList(payload.group_id.toString(), payload.album_id, payload.attach_info);
|
|
26546
|
+
if (res.response.result !== 0) throw new Error(res.response.errMs);
|
|
26547
|
+
return pick(res.response, [
|
|
26548
|
+
"album",
|
|
26549
|
+
"media_list",
|
|
26550
|
+
"next_attach_info",
|
|
26551
|
+
"next_has_more"
|
|
26552
|
+
]);
|
|
26553
|
+
}
|
|
26554
|
+
};
|
|
26555
|
+
//#endregion
|
|
25906
26556
|
//#region src/onebot11/action/index.ts
|
|
25907
26557
|
function initActionMap(adapter) {
|
|
25908
26558
|
const actionHandlers = [
|
|
@@ -25956,6 +26606,8 @@ function initActionMap(adapter) {
|
|
|
25956
26606
|
new SetDoubtFriendsAddRequest(adapter),
|
|
25957
26607
|
new DeleteGroupNotice(adapter),
|
|
25958
26608
|
new SendPoke(adapter),
|
|
26609
|
+
new SetInputStatus(adapter),
|
|
26610
|
+
new GetGroupAlbumMediaList(adapter),
|
|
25959
26611
|
new SendLike(adapter),
|
|
25960
26612
|
new GetMsg(adapter),
|
|
25961
26613
|
new GetLoginInfo$1(adapter),
|
|
@@ -26202,7 +26854,8 @@ var Onebot11Adapter = class extends Service {
|
|
|
26202
26854
|
"app",
|
|
26203
26855
|
"logger",
|
|
26204
26856
|
"pmhq",
|
|
26205
|
-
"timer"
|
|
26857
|
+
"timer",
|
|
26858
|
+
"config"
|
|
26206
26859
|
];
|
|
26207
26860
|
connect;
|
|
26208
26861
|
actionMap;
|
|
@@ -28214,27 +28867,6 @@ var handlers = {
|
|
|
28214
28867
|
deleteFriend
|
|
28215
28868
|
};
|
|
28216
28869
|
//#endregion
|
|
28217
|
-
//#region node_modules/hono/dist/helper/websocket/index.js
|
|
28218
|
-
var defineWebSocketHelper = (handler) => {
|
|
28219
|
-
return ((...args) => {
|
|
28220
|
-
if (typeof args[0] === "function") {
|
|
28221
|
-
const [createEvents, options] = args;
|
|
28222
|
-
return async function upgradeWebSocket(c, next) {
|
|
28223
|
-
const result = await handler(c, await createEvents(c), options);
|
|
28224
|
-
if (result) return result;
|
|
28225
|
-
await next();
|
|
28226
|
-
};
|
|
28227
|
-
} else {
|
|
28228
|
-
const [c, events, options] = args;
|
|
28229
|
-
return (async () => {
|
|
28230
|
-
const upgraded = await handler(c, events, options);
|
|
28231
|
-
if (!upgraded) throw new Error("Failed to upgrade WebSocket");
|
|
28232
|
-
return upgraded;
|
|
28233
|
-
})();
|
|
28234
|
-
}
|
|
28235
|
-
});
|
|
28236
|
-
};
|
|
28237
|
-
//#endregion
|
|
28238
28870
|
//#region node_modules/@hono/node-ws/dist/index.js
|
|
28239
28871
|
/**
|
|
28240
28872
|
* @link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
|
@@ -42900,7 +43532,7 @@ async function download(url, headers) {
|
|
|
42900
43532
|
return Buffer.from(bytes);
|
|
42901
43533
|
}
|
|
42902
43534
|
async function resolveMilkyUri(uri) {
|
|
42903
|
-
if (uri.startsWith("file://")) return await
|
|
43535
|
+
if (uri.startsWith("file://")) return await fs.readFile(fileURLToPath(uri));
|
|
42904
43536
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return await download(uri);
|
|
42905
43537
|
if (uri.startsWith("base64://")) return Buffer.from(uri.slice(9), "base64");
|
|
42906
43538
|
throw new Error(`Unsupported URI scheme: ${uri}`);
|
|
@@ -43257,7 +43889,7 @@ var ForwardMessageEncoder = class ForwardMessageEncoder {
|
|
|
43257
43889
|
}
|
|
43258
43890
|
async flush() {
|
|
43259
43891
|
if (this.children.length === 0) return;
|
|
43260
|
-
const nick = this.name
|
|
43892
|
+
const nick = this.name ?? selfInfo.nick;
|
|
43261
43893
|
if (this.news.length < 4) this.news.push({ text: `${nick}: ${this.preview}` });
|
|
43262
43894
|
this.results.push({
|
|
43263
43895
|
routingHead: {
|
|
@@ -45775,7 +46407,7 @@ function getIgnoreAttributesFn(ignoreAttributes) {
|
|
|
45775
46407
|
return () => false;
|
|
45776
46408
|
}
|
|
45777
46409
|
//#endregion
|
|
45778
|
-
//#region node_modules/path-expression-matcher/src/Expression.js
|
|
46410
|
+
//#region node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js
|
|
45779
46411
|
/**
|
|
45780
46412
|
* Expression - Parses and stores a tag pattern expression
|
|
45781
46413
|
*
|
|
@@ -45927,7 +46559,7 @@ var Expression = class {
|
|
|
45927
46559
|
}
|
|
45928
46560
|
};
|
|
45929
46561
|
//#endregion
|
|
45930
|
-
//#region node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
46562
|
+
//#region node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
45931
46563
|
/**
|
|
45932
46564
|
* ExpressionSet - An indexed collection of Expressions for efficient bulk matching
|
|
45933
46565
|
*
|
|
@@ -46100,7 +46732,7 @@ var ExpressionSet = class {
|
|
|
46100
46732
|
}
|
|
46101
46733
|
};
|
|
46102
46734
|
//#endregion
|
|
46103
|
-
//#region node_modules/path-expression-matcher/src/Matcher.js
|
|
46735
|
+
//#region node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js
|
|
46104
46736
|
/**
|
|
46105
46737
|
* MatcherView - A lightweight read-only view over a Matcher's internal state.
|
|
46106
46738
|
*
|
|
@@ -47288,11 +47920,7 @@ async function transformIncomingSegments(ctx, message) {
|
|
|
47288
47920
|
type: "video",
|
|
47289
47921
|
data: {
|
|
47290
47922
|
resource_id: element.videoElement.fileUuid,
|
|
47291
|
-
temp_url: await ctx.ntFileApi.
|
|
47292
|
-
chatType: message.chatType,
|
|
47293
|
-
peerUid: message.peerUid,
|
|
47294
|
-
guildId: message.guildId
|
|
47295
|
-
}, message.msgId, element.elementId),
|
|
47923
|
+
temp_url: await ctx.ntFileApi.getVideoUrlByPacket(element.videoElement.fileUuid, message.chatType === ChatType.Group),
|
|
47296
47924
|
width: element.videoElement.thumbWidth,
|
|
47297
47925
|
height: element.videoElement.thumbHeight,
|
|
47298
47926
|
duration: element.videoElement.fileTime
|
|
@@ -51829,6 +52457,7 @@ var RkeyManager = class {
|
|
|
51829
52457
|
private_rkey: "",
|
|
51830
52458
|
expired_time: 0
|
|
51831
52459
|
};
|
|
52460
|
+
pull;
|
|
51832
52461
|
constructor(ctx, serverUrl) {
|
|
51833
52462
|
this.ctx = ctx;
|
|
51834
52463
|
this.serverUrl = serverUrl;
|
|
@@ -51845,6 +52474,9 @@ var RkeyManager = class {
|
|
|
51845
52474
|
return (/* @__PURE__ */ new Date()).getTime() / 1e3 > this.rkeyData.expired_time;
|
|
51846
52475
|
}
|
|
51847
52476
|
async refreshRkey() {
|
|
52477
|
+
if (this.pull) return this.pull;
|
|
52478
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
52479
|
+
this.pull = promise;
|
|
51848
52480
|
try {
|
|
51849
52481
|
const { privateRKey, groupRKey, expiredTime } = await this.ctx.pmhq.getRKey();
|
|
51850
52482
|
this.rkeyData = {
|
|
@@ -51852,14 +52484,14 @@ var RkeyManager = class {
|
|
|
51852
52484
|
group_rkey: groupRKey,
|
|
51853
52485
|
expired_time: expiredTime
|
|
51854
52486
|
};
|
|
52487
|
+
resolve();
|
|
52488
|
+
this.pull = void 0;
|
|
51855
52489
|
this.ctx.logger.info(`发包获取rkey成功, private:${privateRKey}, group:${groupRKey}`);
|
|
51856
52490
|
} catch (e) {
|
|
51857
52491
|
this.ctx.logger.warn(`发包获取rkey失败 ${e},开始获取远程rkey`);
|
|
51858
|
-
|
|
51859
|
-
|
|
51860
|
-
|
|
51861
|
-
this.ctx.logger.error("获取远程rkey失败", e);
|
|
51862
|
-
}
|
|
52492
|
+
this.rkeyData = await this.fetchServerRkey();
|
|
52493
|
+
resolve();
|
|
52494
|
+
this.pull = void 0;
|
|
51863
52495
|
}
|
|
51864
52496
|
}
|
|
51865
52497
|
async fetchServerRkey() {
|
|
@@ -52292,7 +52924,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52292
52924
|
const trans = {
|
|
52293
52925
|
uin: selfInfo.uin,
|
|
52294
52926
|
cmd: 1005,
|
|
52295
|
-
readable: createReadStream
|
|
52927
|
+
readable: createReadStream(filePath, { highWaterMark: maxBlockSize }),
|
|
52296
52928
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52297
52929
|
size: index.info.fileSize,
|
|
52298
52930
|
ticket: highwaySession.sigSession,
|
|
@@ -52312,7 +52944,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52312
52944
|
const trans = {
|
|
52313
52945
|
uin: selfInfo.uin,
|
|
52314
52946
|
cmd: 1006,
|
|
52315
|
-
readable: createReadStream
|
|
52947
|
+
readable: createReadStream(thumbPath, { highWaterMark: maxBlockSize }),
|
|
52316
52948
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52317
52949
|
size: index.info.fileSize,
|
|
52318
52950
|
ticket: highwaySession.sigSession,
|
|
@@ -52341,7 +52973,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52341
52973
|
const trans = {
|
|
52342
52974
|
uin: selfInfo.uin,
|
|
52343
52975
|
cmd: 1001,
|
|
52344
|
-
readable: createReadStream
|
|
52976
|
+
readable: createReadStream(filePath, { highWaterMark: maxBlockSize }),
|
|
52345
52977
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52346
52978
|
size: index.info.fileSize,
|
|
52347
52979
|
ticket: highwaySession.sigSession,
|
|
@@ -52361,7 +52993,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52361
52993
|
const trans = {
|
|
52362
52994
|
uin: selfInfo.uin,
|
|
52363
52995
|
cmd: 1002,
|
|
52364
|
-
readable: createReadStream
|
|
52996
|
+
readable: createReadStream(thumbPath, { highWaterMark: maxBlockSize }),
|
|
52365
52997
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52366
52998
|
size: index.info.fileSize,
|
|
52367
52999
|
ticket: highwaySession.sigSession,
|
|
@@ -52420,7 +53052,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52420
53052
|
const trans = {
|
|
52421
53053
|
uin: selfInfo.uin,
|
|
52422
53054
|
cmd: 71,
|
|
52423
|
-
readable: createReadStream
|
|
53055
|
+
readable: createReadStream(filePath, { highWaterMark: 1024 * 1024 }),
|
|
52424
53056
|
sum: result.md5,
|
|
52425
53057
|
size: result.fileSize,
|
|
52426
53058
|
ticket: highwaySession.sigSession,
|
|
@@ -52477,7 +53109,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52477
53109
|
const trans = {
|
|
52478
53110
|
uin: selfInfo.uin,
|
|
52479
53111
|
cmd: 95,
|
|
52480
|
-
readable: createReadStream
|
|
53112
|
+
readable: createReadStream(filePath, { highWaterMark: 1024 * 1024 }),
|
|
52481
53113
|
sum: result.md5CheckSum,
|
|
52482
53114
|
size: result.fileSize,
|
|
52483
53115
|
ticket: highwaySession.sigSession,
|
|
@@ -52631,7 +53263,7 @@ var NTQQGroupApi = class extends Service {
|
|
|
52631
53263
|
async getGroupMembers(groupCode, forceFetch = true) {
|
|
52632
53264
|
return await this.ctx.pmhq.invoke(NTMethod.GROUP_MEMBERS, [groupCode, forceFetch]);
|
|
52633
53265
|
}
|
|
52634
|
-
async getGroupMember(groupCode, uid, forceUpdate = false) {
|
|
53266
|
+
async getGroupMember(groupCode, uid, forceUpdate = false, timeout = 15e3) {
|
|
52635
53267
|
return (await this.ctx.pmhq.invoke("nodeIKernelGroupService/getMemberInfo", [
|
|
52636
53268
|
groupCode,
|
|
52637
53269
|
[uid],
|
|
@@ -52640,7 +53272,8 @@ var NTQQGroupApi = class extends Service {
|
|
|
52640
53272
|
resultCmd: "nodeIKernelGroupListener/onMemberInfoChange",
|
|
52641
53273
|
resultCb: (result) => {
|
|
52642
53274
|
return result[0] === groupCode && result[2].has(uid);
|
|
52643
|
-
}
|
|
53275
|
+
},
|
|
53276
|
+
timeout
|
|
52644
53277
|
}))[2].get(uid);
|
|
52645
53278
|
}
|
|
52646
53279
|
async getSingleScreenNotifies(doubt, number, startSeq = "") {
|
|
@@ -52866,7 +53499,7 @@ var NTQQGroupApi = class extends Service {
|
|
|
52866
53499
|
async getGroupShutUpMemberList(groupCode) {
|
|
52867
53500
|
return (await this.ctx.pmhq.invoke("nodeIKernelGroupService/getGroupShutUpMemberList", [groupCode], {
|
|
52868
53501
|
resultCmd: "nodeIKernelGroupListener/onShutUpMemberListChanged",
|
|
52869
|
-
resultCb: (payload) => payload[0] === groupCode
|
|
53502
|
+
resultCb: (payload) => payload[0] === groupCode || payload[0] === "0"
|
|
52870
53503
|
}))[1];
|
|
52871
53504
|
}
|
|
52872
53505
|
async renameGroupFolder(groupId, folderId, newFolderName) {
|
|
@@ -52934,6 +53567,17 @@ var NTQQGroupApi = class extends Service {
|
|
|
52934
53567
|
}
|
|
52935
53568
|
});
|
|
52936
53569
|
}
|
|
53570
|
+
async getGroupAlbumMediaList(groupCode, albumId, attachInfo = "") {
|
|
53571
|
+
return await this.ctx.pmhq.invoke("nodeIKernelAlbumService/getMediaList", [{
|
|
53572
|
+
qun_id: groupCode,
|
|
53573
|
+
attach_info: attachInfo,
|
|
53574
|
+
seq: 0,
|
|
53575
|
+
request_time_line: { request_invoke_time: "0" },
|
|
53576
|
+
album_id: albumId,
|
|
53577
|
+
lloc: "",
|
|
53578
|
+
batch_id: ""
|
|
53579
|
+
}]);
|
|
53580
|
+
}
|
|
52937
53581
|
};
|
|
52938
53582
|
//#endregion
|
|
52939
53583
|
//#region src/ntqqapi/api/login.ts
|
|
@@ -53302,6 +53946,13 @@ var NTQQMsgApi = class extends Service {
|
|
|
53302
53946
|
async setContactLocalTop(peer, isTop) {
|
|
53303
53947
|
return await this.ctx.pmhq.invoke("nodeIKernelMsgService/setContactLocalTop", [peer, isTop]);
|
|
53304
53948
|
}
|
|
53949
|
+
async sendShowInputStatusReq(chatType, eventType, toUid) {
|
|
53950
|
+
return await this.ctx.pmhq.invoke("nodeIKernelMsgService/sendShowInputStatusReq", [
|
|
53951
|
+
chatType,
|
|
53952
|
+
eventType,
|
|
53953
|
+
toUid
|
|
53954
|
+
]);
|
|
53955
|
+
}
|
|
53305
53956
|
};
|
|
53306
53957
|
//#endregion
|
|
53307
53958
|
//#region src/common/utils/request.ts
|
|
@@ -53712,7 +54363,7 @@ var NTQQWebApi = class extends Service {
|
|
|
53712
54363
|
const iBatchID = Math.floor(Date.now() / 1e3);
|
|
53713
54364
|
for (let i = 0; i < filePathList.length; i++) {
|
|
53714
54365
|
const filePath = filePathList[i];
|
|
53715
|
-
const fileBuffer = await
|
|
54366
|
+
const fileBuffer = await fs.readFile(filePath);
|
|
53716
54367
|
const fileSize = fileBuffer.length;
|
|
53717
54368
|
const checksum = await getMd5HexFromFile(filePath);
|
|
53718
54369
|
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
@@ -55185,7 +55836,7 @@ var Config = class extends Service {
|
|
|
55185
55836
|
this.logger.info("配置文件位于", this.configPath);
|
|
55186
55837
|
this.config = this.get();
|
|
55187
55838
|
if (this.configPath) {
|
|
55188
|
-
fs$
|
|
55839
|
+
fs$2.watchFile(this.configPath, {
|
|
55189
55840
|
persistent: true,
|
|
55190
55841
|
interval: 1e3
|
|
55191
55842
|
}, () => {
|
|
@@ -55203,7 +55854,7 @@ var Config = class extends Service {
|
|
|
55203
55854
|
}
|
|
55204
55855
|
getDefaultConfig() {
|
|
55205
55856
|
const _defaultConfig = { ...defaultConfig };
|
|
55206
|
-
const defaultConfigFromFile = fs$
|
|
55857
|
+
const defaultConfigFromFile = fs$2.readFileSync(this.defaultConfigPath, "utf-8");
|
|
55207
55858
|
try {
|
|
55208
55859
|
const parsedDefaultConfig = import_dist.default.parse(defaultConfigFromFile);
|
|
55209
55860
|
Object.assign(_defaultConfig, parsedDefaultConfig);
|
|
@@ -55214,12 +55865,12 @@ var Config = class extends Service {
|
|
|
55214
55865
|
}
|
|
55215
55866
|
reloadConfig() {
|
|
55216
55867
|
if (!this.configPath) return this.getDefaultConfig();
|
|
55217
|
-
if (!fs$
|
|
55868
|
+
if (!fs$2.existsSync(this.configPath)) {
|
|
55218
55869
|
this.config = this.getDefaultConfig();
|
|
55219
55870
|
this.set(this.config);
|
|
55220
55871
|
return this.config;
|
|
55221
55872
|
} else {
|
|
55222
|
-
const data = fs$
|
|
55873
|
+
const data = fs$2.readFileSync(this.configPath, "utf-8");
|
|
55223
55874
|
let jsonData = defaultConfig;
|
|
55224
55875
|
try {
|
|
55225
55876
|
jsonData = import_dist.default.parse(data);
|
|
@@ -55245,7 +55896,7 @@ var Config = class extends Service {
|
|
|
55245
55896
|
writeConfig(config) {
|
|
55246
55897
|
if (!this.configPath) return;
|
|
55247
55898
|
this.watch = false;
|
|
55248
|
-
fs$
|
|
55899
|
+
fs$2.writeFileSync(this.configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
55249
55900
|
setTimeout(() => {
|
|
55250
55901
|
this.watch = true;
|
|
55251
55902
|
}, 1500);
|
|
@@ -55351,13 +56002,13 @@ var WebUITokenUtil = class {
|
|
|
55351
56002
|
}
|
|
55352
56003
|
getToken() {
|
|
55353
56004
|
if (!this.token) {
|
|
55354
|
-
if (fs$
|
|
56005
|
+
if (fs$2.existsSync(this.tokenPath)) this.token = fs$2.readFileSync(this.tokenPath, "utf-8").trim();
|
|
55355
56006
|
}
|
|
55356
56007
|
return this.token;
|
|
55357
56008
|
}
|
|
55358
56009
|
setToken(token) {
|
|
55359
56010
|
this.token = token.trim();
|
|
55360
|
-
fs$
|
|
56011
|
+
fs$2.writeFileSync(this.tokenPath, token, "utf-8");
|
|
55361
56012
|
}
|
|
55362
56013
|
};
|
|
55363
56014
|
var webuiTokenUtil = new WebUITokenUtil(path.join(DATA_DIR, "webui_token.txt"));
|
|
@@ -56777,7 +57428,7 @@ var tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
|
56777
57428
|
var serveStatic = (options = { root: "" }) => {
|
|
56778
57429
|
const root = options.root || "";
|
|
56779
57430
|
const optionPath = options.path;
|
|
56780
|
-
if (root !== "" && !existsSync(root)) console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
|
|
57431
|
+
if (root !== "" && !existsSync$1(root)) console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
|
|
56781
57432
|
return async (c, next) => {
|
|
56782
57433
|
if (c.finalized) return next();
|
|
56783
57434
|
let filename;
|
|
@@ -57633,7 +58284,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
57633
58284
|
var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
57634
58285
|
var urllib$2 = __require("url");
|
|
57635
58286
|
var util$1 = __require("util");
|
|
57636
|
-
var fs$
|
|
58287
|
+
var fs$5 = __require("fs");
|
|
57637
58288
|
var nmfetch = require_fetch();
|
|
57638
58289
|
var dns$1 = __require("dns");
|
|
57639
58290
|
var net$4 = __require("net");
|
|
@@ -57969,7 +58620,7 @@ var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
57969
58620
|
const parsedDataUri = module.exports.parseDataURI(content.path || content.href);
|
|
57970
58621
|
if (!parsedDataUri || !parsedDataUri.data) return callback(null, Buffer.from(0));
|
|
57971
58622
|
return callback(null, parsedDataUri.data);
|
|
57972
|
-
} else if (content.path) return resolveStream(fs$
|
|
58623
|
+
} else if (content.path) return resolveStream(fs$5.createReadStream(content.path), callback);
|
|
57973
58624
|
}
|
|
57974
58625
|
if (typeof data[key].content === "string" && ![
|
|
57975
58626
|
"utf8",
|
|
@@ -60864,7 +61515,19 @@ var require_punycode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
60864
61515
|
});
|
|
60865
61516
|
};
|
|
60866
61517
|
module.exports = {
|
|
61518
|
+
/**
|
|
61519
|
+
* A string representing the current Punycode.js version number.
|
|
61520
|
+
* @memberOf punycode
|
|
61521
|
+
* @type String
|
|
61522
|
+
*/
|
|
60867
61523
|
version: "2.3.1",
|
|
61524
|
+
/**
|
|
61525
|
+
* An object of methods to convert from JavaScript's internal character
|
|
61526
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
61527
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
61528
|
+
* @memberOf punycode
|
|
61529
|
+
* @type Object
|
|
61530
|
+
*/
|
|
60868
61531
|
ucs2: {
|
|
60869
61532
|
decode: ucs2decode,
|
|
60870
61533
|
encode: ucs2encode
|
|
@@ -61137,13 +61800,38 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61137
61800
|
var qp = require_qp();
|
|
61138
61801
|
var mimeTypes = require_mime_types();
|
|
61139
61802
|
module.exports = {
|
|
61803
|
+
/**
|
|
61804
|
+
* Checks if a value is plaintext string (uses only printable 7bit chars)
|
|
61805
|
+
*
|
|
61806
|
+
* @param {String} value String to be tested
|
|
61807
|
+
* @returns {Boolean} true if it is a plaintext string
|
|
61808
|
+
*/
|
|
61140
61809
|
isPlainText(value, isParam) {
|
|
61141
61810
|
return typeof value === "string" && !(isParam ? /[\x00-\x08\x0b\x0c\x0e-\x1f"\u0080-\uFFFF]/ : /[\x00-\x08\x0b\x0c\x0e-\x1f\u0080-\uFFFF]/).test(value);
|
|
61142
61811
|
},
|
|
61812
|
+
/**
|
|
61813
|
+
* Checks if a multi line string containes lines longer than the selected value.
|
|
61814
|
+
*
|
|
61815
|
+
* Useful when detecting if a mail message needs any processing at all –
|
|
61816
|
+
* if only plaintext characters are used and lines are short, then there is
|
|
61817
|
+
* no need to encode the values in any way. If the value is plaintext but has
|
|
61818
|
+
* longer lines then allowed, then use format=flowed
|
|
61819
|
+
*
|
|
61820
|
+
* @param {Number} lineLength Max line length to check for
|
|
61821
|
+
* @returns {Boolean} Returns true if there is at least one line longer than lineLength chars
|
|
61822
|
+
*/
|
|
61143
61823
|
hasLongerLines(str, lineLength) {
|
|
61144
61824
|
if (str.length > 128 * 1024) return true;
|
|
61145
61825
|
return new RegExp("^.{" + (lineLength + 1) + ",}", "m").test(str);
|
|
61146
61826
|
},
|
|
61827
|
+
/**
|
|
61828
|
+
* Encodes a string or an Buffer to an UTF-8 MIME Word (rfc2047)
|
|
61829
|
+
*
|
|
61830
|
+
* @param {String|Buffer} data String to be encoded
|
|
61831
|
+
* @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
|
|
61832
|
+
* @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
|
|
61833
|
+
* @return {String} Single or several mime words joined together
|
|
61834
|
+
*/
|
|
61147
61835
|
encodeWord(data, mimeWordEncoding, maxLength) {
|
|
61148
61836
|
mimeWordEncoding = (mimeWordEncoding || "Q").toString().toUpperCase().trim().charAt(0);
|
|
61149
61837
|
maxLength = maxLength || 0;
|
|
@@ -61179,6 +61867,15 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61179
61867
|
else if (mimeWordEncoding === "B") encodedStr = base64.encode(data);
|
|
61180
61868
|
return "=?" + toCharset + "?" + mimeWordEncoding + "?" + encodedStr + (encodedStr.substr(-2) === "?=" ? "" : "?=");
|
|
61181
61869
|
},
|
|
61870
|
+
/**
|
|
61871
|
+
* Finds word sequences with non ascii text and converts these to mime words
|
|
61872
|
+
*
|
|
61873
|
+
* @param {String} value String to be encoded
|
|
61874
|
+
* @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
|
|
61875
|
+
* @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
|
|
61876
|
+
* @param {Boolean} [encodeAll=false] If true and the value needs encoding then encodes entire string, not just the smallest match
|
|
61877
|
+
* @return {String} String with possible mime words
|
|
61878
|
+
*/
|
|
61182
61879
|
encodeWords(value, mimeWordEncoding, maxLength, encodeAll) {
|
|
61183
61880
|
maxLength = maxLength || 0;
|
|
61184
61881
|
const firstMatch = value.match(/(?:^|\s)([^\s]*["\u0080-\uFFFF])/);
|
|
@@ -61190,6 +61887,13 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61190
61887
|
const endIndex = lastMatch.index + (lastMatch[1] || "").length;
|
|
61191
61888
|
return (startIndex ? value.substr(0, startIndex) : "") + this.encodeWord(value.substring(startIndex, endIndex), mimeWordEncoding || "Q", maxLength) + (endIndex < value.length ? value.substr(endIndex) : "");
|
|
61192
61889
|
},
|
|
61890
|
+
/**
|
|
61891
|
+
* Joins parsed header value together as 'value; param1=value1; param2=value2'
|
|
61892
|
+
* PS: We are following RFC 822 for the list of special characters that we need to keep in quotes.
|
|
61893
|
+
* Refer: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
|
|
61894
|
+
* @param {Object} structured Parsed header value
|
|
61895
|
+
* @return {String} joined header value
|
|
61896
|
+
*/
|
|
61193
61897
|
buildHeaderValue(structured) {
|
|
61194
61898
|
const paramsArray = [];
|
|
61195
61899
|
Object.keys(structured.params || {}).forEach((param) => {
|
|
@@ -61203,6 +61907,21 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61203
61907
|
});
|
|
61204
61908
|
return structured.value + (paramsArray.length ? "; " + paramsArray.join("; ") : "");
|
|
61205
61909
|
},
|
|
61910
|
+
/**
|
|
61911
|
+
* Encodes a string or an Buffer to an UTF-8 Parameter Value Continuation encoding (rfc2231)
|
|
61912
|
+
* Useful for splitting long parameter values.
|
|
61913
|
+
*
|
|
61914
|
+
* For example
|
|
61915
|
+
* title="unicode string"
|
|
61916
|
+
* becomes
|
|
61917
|
+
* title*0*=utf-8''unicode
|
|
61918
|
+
* title*1*=%20string
|
|
61919
|
+
*
|
|
61920
|
+
* @param {String|Buffer} data String to be encoded
|
|
61921
|
+
* @param {Number} [maxLength=50] Max length for generated chunks
|
|
61922
|
+
* @param {String} [fromCharset='UTF-8'] Source sharacter set
|
|
61923
|
+
* @return {Array} A list of encoded keys and headers
|
|
61924
|
+
*/
|
|
61206
61925
|
buildHeaderParam(key, data, maxLength) {
|
|
61207
61926
|
const list = [];
|
|
61208
61927
|
let encodedStr = typeof data === "string" ? data : (data || "").toString();
|
|
@@ -61279,6 +61998,21 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61279
61998
|
value: item.line
|
|
61280
61999
|
}));
|
|
61281
62000
|
},
|
|
62001
|
+
/**
|
|
62002
|
+
* Parses a header value with key=value arguments into a structured
|
|
62003
|
+
* object.
|
|
62004
|
+
*
|
|
62005
|
+
* parseHeaderValue('content-type: text/plain; CHARSET='UTF-8'') ->
|
|
62006
|
+
* {
|
|
62007
|
+
* 'value': 'text/plain',
|
|
62008
|
+
* 'params': {
|
|
62009
|
+
* 'charset': 'UTF-8'
|
|
62010
|
+
* }
|
|
62011
|
+
* }
|
|
62012
|
+
*
|
|
62013
|
+
* @param {String} str Header value
|
|
62014
|
+
* @return {Object} Header value as a parsed structure
|
|
62015
|
+
*/
|
|
61282
62016
|
parseHeaderValue(str) {
|
|
61283
62017
|
const response = {
|
|
61284
62018
|
value: false,
|
|
@@ -61351,8 +62085,31 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61351
62085
|
});
|
|
61352
62086
|
return response;
|
|
61353
62087
|
},
|
|
62088
|
+
/**
|
|
62089
|
+
* Returns file extension for a content type string. If no suitable extensions
|
|
62090
|
+
* are found, 'bin' is used as the default extension
|
|
62091
|
+
*
|
|
62092
|
+
* @param {String} mimeType Content type to be checked for
|
|
62093
|
+
* @return {String} File extension
|
|
62094
|
+
*/
|
|
61354
62095
|
detectExtension: (mimeType) => mimeTypes.detectExtension(mimeType),
|
|
62096
|
+
/**
|
|
62097
|
+
* Returns content type for a file extension. If no suitable content types
|
|
62098
|
+
* are found, 'application/octet-stream' is used as the default content type
|
|
62099
|
+
*
|
|
62100
|
+
* @param {String} extension Extension to be checked for
|
|
62101
|
+
* @return {String} File extension
|
|
62102
|
+
*/
|
|
61355
62103
|
detectMimeType: (extension) => mimeTypes.detectMimeType(extension),
|
|
62104
|
+
/**
|
|
62105
|
+
* Folds long lines, useful for folding header lines (afterSpace=false) and
|
|
62106
|
+
* flowed text (afterSpace=true)
|
|
62107
|
+
*
|
|
62108
|
+
* @param {String} str String to be folded
|
|
62109
|
+
* @param {Number} [lineLength=76] Maximum length of a line
|
|
62110
|
+
* @param {Boolean} afterSpace If true, leave a space in th end of a line
|
|
62111
|
+
* @return {String} String with folded lines
|
|
62112
|
+
*/
|
|
61356
62113
|
foldLines(str, lineLength, afterSpace) {
|
|
61357
62114
|
str = (str || "").toString();
|
|
61358
62115
|
lineLength = lineLength || 76;
|
|
@@ -61379,6 +62136,13 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61379
62136
|
}
|
|
61380
62137
|
return result;
|
|
61381
62138
|
},
|
|
62139
|
+
/**
|
|
62140
|
+
* Splits a mime encoded string. Needed for dividing mime words into smaller chunks
|
|
62141
|
+
*
|
|
62142
|
+
* @param {String} str Mime encoded string to be split up
|
|
62143
|
+
* @param {Number} maxlen Maximum length of characters for one part (minimum 12)
|
|
62144
|
+
* @return {Array} Split string
|
|
62145
|
+
*/
|
|
61382
62146
|
splitMimeEncodedString: (str, maxlen) => {
|
|
61383
62147
|
const lines = [];
|
|
61384
62148
|
let curLine, match, chr, done;
|
|
@@ -61794,8 +62558,8 @@ var require_le_unix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61794
62558
|
//#endregion
|
|
61795
62559
|
//#region node_modules/nodemailer/lib/mime-node/index.js
|
|
61796
62560
|
var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
61797
|
-
var crypto$
|
|
61798
|
-
var fs$
|
|
62561
|
+
var crypto$8 = __require("crypto");
|
|
62562
|
+
var fs$4 = __require("fs");
|
|
61799
62563
|
var punycode = require_punycode();
|
|
61800
62564
|
var { PassThrough: PassThrough$2 } = __require("stream");
|
|
61801
62565
|
var shared = require_shared();
|
|
@@ -61825,7 +62589,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61825
62589
|
/**
|
|
61826
62590
|
* shared part of the unique multipart boundary
|
|
61827
62591
|
*/
|
|
61828
|
-
this.baseBoundary = options.baseBoundary || crypto$
|
|
62592
|
+
this.baseBoundary = options.baseBoundary || crypto$8.randomBytes(8).toString("hex");
|
|
61829
62593
|
this.boundaryPrefix = options.boundaryPrefix || "--_NmP";
|
|
61830
62594
|
this.disableFileAccess = !!options.disableFileAccess;
|
|
61831
62595
|
this.disableUrlAccess = !!options.disableUrlAccess;
|
|
@@ -62504,7 +63268,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62504
63268
|
});
|
|
62505
63269
|
return contentStream;
|
|
62506
63270
|
}
|
|
62507
|
-
return fs$
|
|
63271
|
+
return fs$4.createReadStream(content.path);
|
|
62508
63272
|
}
|
|
62509
63273
|
if (content && typeof content.href === "string") {
|
|
62510
63274
|
if (this.disableUrlAccess) {
|
|
@@ -62712,7 +63476,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62712
63476
|
2,
|
|
62713
63477
|
2,
|
|
62714
63478
|
6
|
|
62715
|
-
].reduce((prev, len) => prev + "-" + crypto$
|
|
63479
|
+
].reduce((prev, len) => prev + "-" + crypto$8.randomBytes(len).toString("hex"), crypto$8.randomBytes(4).toString("hex")) + "@" + (this.getEnvelope().from || this.hostname || "localhost").split("@").pop() + ">";
|
|
62716
63480
|
}
|
|
62717
63481
|
};
|
|
62718
63482
|
}));
|
|
@@ -63177,14 +63941,14 @@ var require_message_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
63177
63941
|
//#region node_modules/nodemailer/lib/dkim/relaxed-body.js
|
|
63178
63942
|
var require_relaxed_body = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63179
63943
|
var { Transform: Transform$2 } = __require("stream");
|
|
63180
|
-
var crypto$
|
|
63944
|
+
var crypto$7 = __require("crypto");
|
|
63181
63945
|
var RelaxedBody = class extends Transform$2 {
|
|
63182
63946
|
constructor(options) {
|
|
63183
63947
|
super();
|
|
63184
63948
|
options = options || {};
|
|
63185
63949
|
this.chunkBuffer = [];
|
|
63186
63950
|
this.chunkBufferLen = 0;
|
|
63187
|
-
this.bodyHash = crypto$
|
|
63951
|
+
this.bodyHash = crypto$7.createHash(options.hashAlgo || "sha1");
|
|
63188
63952
|
this.remainder = "";
|
|
63189
63953
|
this.byteLength = 0;
|
|
63190
63954
|
this.debug = options.debug;
|
|
@@ -63263,7 +64027,7 @@ var require_relaxed_body = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63263
64027
|
var require_sign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63264
64028
|
var punycode = require_punycode();
|
|
63265
64029
|
var mimeFuncs = require_mime_funcs();
|
|
63266
|
-
var crypto$
|
|
64030
|
+
var crypto$6 = __require("crypto");
|
|
63267
64031
|
/**
|
|
63268
64032
|
* Returns DKIM signature header line
|
|
63269
64033
|
*
|
|
@@ -63280,7 +64044,7 @@ var require_sign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63280
64044
|
const canonicalizedHeaderData = relaxedHeaders(headers, options.headerFieldNames || "From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive", options.skipFields);
|
|
63281
64045
|
const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
|
|
63282
64046
|
canonicalizedHeaderData.headers += "dkim-signature:" + relaxedHeaderLine(dkimHeader);
|
|
63283
|
-
const signer = crypto$
|
|
64047
|
+
const signer = crypto$6.createSign(("rsa-" + hashAlgo).toUpperCase());
|
|
63284
64048
|
signer.update(canonicalizedHeaderData.headers);
|
|
63285
64049
|
let signature;
|
|
63286
64050
|
try {
|
|
@@ -63342,9 +64106,9 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63342
64106
|
var RelaxedBody = require_relaxed_body();
|
|
63343
64107
|
var sign = require_sign();
|
|
63344
64108
|
var { PassThrough: PassThrough$1 } = __require("stream");
|
|
63345
|
-
var fs$
|
|
64109
|
+
var fs$3 = __require("fs");
|
|
63346
64110
|
var path$2 = __require("path");
|
|
63347
|
-
var crypto$
|
|
64111
|
+
var crypto$5 = __require("crypto");
|
|
63348
64112
|
var DKIM_ALGO = "sha256";
|
|
63349
64113
|
var MAX_MESSAGE_SIZE = 2 * 1024 * 1024;
|
|
63350
64114
|
var DKIMSigner = class {
|
|
@@ -63357,7 +64121,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63357
64121
|
this.chunks = [];
|
|
63358
64122
|
this.chunklen = 0;
|
|
63359
64123
|
this.readPos = 0;
|
|
63360
|
-
this.cachePath = this.cacheDir ? path$2.join(this.cacheDir, "message." + Date.now() + "-" + crypto$
|
|
64124
|
+
this.cachePath = this.cacheDir ? path$2.join(this.cacheDir, "message." + Date.now() + "-" + crypto$5.randomBytes(14).toString("hex")) : false;
|
|
63361
64125
|
this.cache = false;
|
|
63362
64126
|
this.headers = false;
|
|
63363
64127
|
this.bodyHash = false;
|
|
@@ -63375,10 +64139,10 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63375
64139
|
}
|
|
63376
64140
|
cleanup() {
|
|
63377
64141
|
if (!this.cache || !this.cachePath) return;
|
|
63378
|
-
fs$
|
|
64142
|
+
fs$3.unlink(this.cachePath, () => false);
|
|
63379
64143
|
}
|
|
63380
64144
|
createReadCache() {
|
|
63381
|
-
this.cache = fs$
|
|
64145
|
+
this.cache = fs$3.createReadStream(this.cachePath);
|
|
63382
64146
|
this.cache.once("error", (err) => {
|
|
63383
64147
|
this.cleanup();
|
|
63384
64148
|
this.output.emit("error", err);
|
|
@@ -63424,7 +64188,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63424
64188
|
}
|
|
63425
64189
|
createWriteCache() {
|
|
63426
64190
|
this.output.usingCache = true;
|
|
63427
|
-
this.cache = fs$
|
|
64191
|
+
this.cache = fs$3.createWriteStream(this.cachePath);
|
|
63428
64192
|
this.cache.once("error", (err) => {
|
|
63429
64193
|
this.cleanup();
|
|
63430
64194
|
this.relaxedBody.unpipe(this.cache);
|
|
@@ -63816,7 +64580,7 @@ var require_mailer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63816
64580
|
var MailMessage = require_mail_message();
|
|
63817
64581
|
var net$2 = __require("net");
|
|
63818
64582
|
var dns = __require("dns");
|
|
63819
|
-
var crypto$
|
|
64583
|
+
var crypto$4 = __require("crypto");
|
|
63820
64584
|
/**
|
|
63821
64585
|
* Creates an object for exposing the Mail API
|
|
63822
64586
|
*
|
|
@@ -64065,7 +64829,7 @@ var require_mailer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64065
64829
|
if (err) return callback(err);
|
|
64066
64830
|
let cidCounter = 0;
|
|
64067
64831
|
html = (html || "").toString().replace(/(<img\b[^<>]{0,1024} src\s{0,20}=[\s"']{0,20})(data:([^;]+);[^"'>\s]+)/gi, (match, prefix, dataUri, mimeType) => {
|
|
64068
|
-
const cid = crypto$
|
|
64832
|
+
const cid = crypto$4.randomBytes(10).toString("hex") + "@localhost";
|
|
64069
64833
|
if (!mail.data.attachments) mail.data.attachments = [];
|
|
64070
64834
|
if (!Array.isArray(mail.data.attachments)) mail.data.attachments = [].concat(mail.data.attachments || []);
|
|
64071
64835
|
mail.data.attachments.push({
|
|
@@ -64174,7 +64938,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
64174
64938
|
var net$1 = __require("net");
|
|
64175
64939
|
var tls = __require("tls");
|
|
64176
64940
|
var os$1 = __require("os");
|
|
64177
|
-
var crypto$
|
|
64941
|
+
var crypto$3 = __require("crypto");
|
|
64178
64942
|
var DataStream = require_data_stream();
|
|
64179
64943
|
var { PassThrough } = __require("stream");
|
|
64180
64944
|
var shared = require_shared();
|
|
@@ -64229,7 +64993,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
64229
64993
|
var SMTPConnection = class extends EventEmitter$4 {
|
|
64230
64994
|
constructor(options) {
|
|
64231
64995
|
super(options);
|
|
64232
|
-
this.id = crypto$
|
|
64996
|
+
this.id = crypto$3.randomBytes(8).toString("base64").replace(/\W/g, "");
|
|
64233
64997
|
this.stage = "init";
|
|
64234
64998
|
this.options = options || {};
|
|
64235
64999
|
this.secureConnection = !!this.options.secure;
|
|
@@ -65177,7 +65941,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
65177
65941
|
const challengeMatch = str.match(/^334\s+(.+)$/);
|
|
65178
65942
|
if (!challengeMatch) return callback(this._formatError("Invalid login sequence while waiting for server challenge string", "EAUTH", str, "AUTH CRAM-MD5"));
|
|
65179
65943
|
const base64decoded = Buffer.from(challengeMatch[1], "base64").toString("ascii");
|
|
65180
|
-
const hmacMD5 = crypto$
|
|
65944
|
+
const hmacMD5 = crypto$3.createHmac("md5", this._auth.credentials.pass);
|
|
65181
65945
|
hmacMD5.update(base64decoded);
|
|
65182
65946
|
const prepended = this._auth.credentials.user + " " + hmacMD5.digest("hex");
|
|
65183
65947
|
this._responseActions.push((str) => {
|
|
@@ -65403,7 +66167,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
65403
66167
|
var require_xoauth2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
65404
66168
|
var { Stream } = __require("stream");
|
|
65405
66169
|
var nmfetch = require_fetch();
|
|
65406
|
-
var crypto$
|
|
66170
|
+
var crypto$2 = __require("crypto");
|
|
65407
66171
|
var shared = require_shared();
|
|
65408
66172
|
var errors = require_errors();
|
|
65409
66173
|
/**
|
|
@@ -65719,7 +66483,7 @@ var require_xoauth2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
65719
66483
|
*/
|
|
65720
66484
|
jwtSignRS256(payload) {
|
|
65721
66485
|
payload = ["{\"alg\":\"RS256\",\"typ\":\"JWT\"}", JSON.stringify(payload)].map((val) => this.toBase64URL(val)).join(".");
|
|
65722
|
-
const signature = crypto$
|
|
66486
|
+
const signature = crypto$2.createSign("RSA-SHA256").update(payload).sign(this.options.privateKey);
|
|
65723
66487
|
return payload + "." + this.toBase64URL(signature);
|
|
65724
66488
|
}
|
|
65725
66489
|
};
|
|
@@ -68326,7 +69090,6 @@ var PMHQBase = class extends Service {
|
|
|
68326
69090
|
super(ctx, "pmhq");
|
|
68327
69091
|
this.ctx = ctx;
|
|
68328
69092
|
this.logger = ctx.logger("pmhq");
|
|
68329
|
-
this.logger.info(process.argv);
|
|
68330
69093
|
const { pmhqHost, pmhqPort } = this.getPMHQHostPort();
|
|
68331
69094
|
this.httpUrl = `http://${pmhqHost}:${pmhqPort}/`;
|
|
68332
69095
|
this.wsUrl = `ws://${pmhqHost}:${pmhqPort}/ws`;
|
|
@@ -68584,6 +69347,15 @@ var PMHQBase = class extends Service {
|
|
|
68584
69347
|
});
|
|
68585
69348
|
this.call(funcName, args, timeout).then((r) => {
|
|
68586
69349
|
firstResult = r;
|
|
69350
|
+
if (options.onCallResult) {
|
|
69351
|
+
const result = options.onCallResult(r);
|
|
69352
|
+
if (result !== void 0) {
|
|
69353
|
+
resolve(result);
|
|
69354
|
+
this.removeReceiveHook(hookId);
|
|
69355
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
69356
|
+
return;
|
|
69357
|
+
}
|
|
69358
|
+
}
|
|
68587
69359
|
if (r && Object.hasOwn(r, "result") && +r.result !== 0) {
|
|
68588
69360
|
const displayReq = inspect(args, {
|
|
68589
69361
|
depth: 10,
|
|
@@ -69632,7 +70404,7 @@ async function onLoad() {
|
|
|
69632
70404
|
if (!existsSync$1(LOG_DIR)) mkdirSync(LOG_DIR);
|
|
69633
70405
|
if (!existsSync$1(TEMP_DIR)) mkdirSync(TEMP_DIR);
|
|
69634
70406
|
const ctx = new Context$1();
|
|
69635
|
-
ctx.plugin(index_default$3);
|
|
70407
|
+
ctx.plugin(index_default$3, { bufferSize: 0 });
|
|
69636
70408
|
ctx.plugin(index_default);
|
|
69637
70409
|
ctx.plugin(Config);
|
|
69638
70410
|
ctx.plugin(PMHQ);
|
|
@@ -69665,7 +70437,7 @@ async function onLoad() {
|
|
|
69665
70437
|
ctx.plugin(EmailNotificationService);
|
|
69666
70438
|
};
|
|
69667
70439
|
const isDocker = isDockerEnvironment();
|
|
69668
|
-
let
|
|
70440
|
+
let lastQrCodeTime = 0;
|
|
69669
70441
|
const printLoginQrCode = async () => {
|
|
69670
70442
|
try {
|
|
69671
70443
|
const data = await ctx.ntLoginApi.getLoginQrCode();
|
|
@@ -69697,8 +70469,9 @@ async function onLoad() {
|
|
|
69697
70469
|
return;
|
|
69698
70470
|
}
|
|
69699
70471
|
if (!pmhqSelfInfo.online) {
|
|
69700
|
-
|
|
69701
|
-
|
|
70472
|
+
const now = Date.now();
|
|
70473
|
+
if (isDocker && now - lastQrCodeTime > 12e4) {
|
|
70474
|
+
lastQrCodeTime = now;
|
|
69702
70475
|
printLoginQrCode();
|
|
69703
70476
|
}
|
|
69704
70477
|
setTimeout(checkLogin, 1e3);
|
|
@@ -69727,6 +70500,7 @@ async function onLoad() {
|
|
|
69727
70500
|
ctx.inject(["logger"], (ctx) => {
|
|
69728
70501
|
ctx.logger.exporter(new Log(ctx, true));
|
|
69729
70502
|
ctx.logger.info(`LLBot ${version$2}`);
|
|
70503
|
+
ctx.logger.info(process.argv);
|
|
69730
70504
|
});
|
|
69731
70505
|
ctx.inject([
|
|
69732
70506
|
"pmhq",
|