@maiyunnet/kebab 2.0.16 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/index.d.ts +1 -1
- package/index.js +16 -18
- package/lib/buffer.js +4 -11
- package/lib/captcha.js +6 -44
- package/lib/consistent.js +8 -51
- package/lib/core.d.ts +4 -4
- package/lib/core.js +70 -132
- package/lib/crypto.js +43 -99
- package/lib/db.d.ts +5 -5
- package/lib/db.js +31 -68
- package/lib/dns.d.ts +1 -1
- package/lib/dns.js +12 -50
- package/lib/fs.js +26 -81
- package/lib/jwt.d.ts +3 -3
- package/lib/jwt.js +9 -50
- package/lib/kv.d.ts +4 -4
- package/lib/kv.js +31 -69
- package/lib/lan.js +4 -41
- package/lib/net/cacert.pem +78 -2
- package/lib/net/formdata.js +5 -42
- package/lib/net/request.d.ts +2 -2
- package/lib/net/request.js +3 -42
- package/lib/net/response.d.ts +1 -1
- package/lib/net/response.js +1 -5
- package/lib/net.d.ts +5 -5
- package/lib/net.js +24 -73
- package/lib/s3.d.ts +1 -1
- package/lib/s3.js +20 -59
- package/lib/scan.d.ts +3 -3
- package/lib/scan.js +10 -50
- package/lib/session.d.ts +3 -3
- package/lib/session.js +9 -46
- package/lib/sql.d.ts +2 -2
- package/lib/sql.js +9 -50
- package/lib/ssh/sftp.js +5 -46
- package/lib/ssh/shell.js +2 -39
- package/lib/ssh.d.ts +2 -2
- package/lib/ssh.js +5 -43
- package/lib/text.d.ts +1 -1
- package/lib/text.js +40 -104
- package/lib/time.d.ts +1 -1
- package/lib/time.js +10 -50
- package/lib/turnstile.d.ts +1 -1
- package/lib/turnstile.js +6 -43
- package/lib/ws.d.ts +2 -2
- package/lib/ws.js +14 -56
- package/lib/zip.d.ts +1 -1
- package/lib/zip.js +6 -47
- package/lib/zlib.js +17 -68
- package/main.js +6 -44
- package/package.json +9 -8
- package/sys/child.js +10 -45
- package/sys/cmd.js +8 -43
- package/sys/ctr.d.ts +5 -5
- package/sys/ctr.js +9 -47
- package/sys/master.js +11 -46
- package/sys/mod.d.ts +9 -5
- package/sys/mod.js +9 -43
- package/sys/route.d.ts +2 -2
- package/sys/route.js +24 -64
- package/types/index.d.ts +1 -0
- package/www/example/ctr/main.d.ts +1 -1
- package/www/example/ctr/main.js +2 -38
- package/www/example/ctr/middle.d.ts +2 -2
- package/www/example/ctr/middle.js +2 -38
- package/www/example/ctr/test.d.ts +2 -2
- package/www/example/ctr/test.js +65 -72
- package/www/example/mod/test.d.ts +2 -2
- package/www/example/mod/test.js +4 -42
- package/www/example/mod/testdata.d.ts +1 -1
- package/www/example/mod/testdata.js +3 -8
- package/www/example/ws/mproxy.d.ts +1 -1
- package/www/example/ws/mproxy.js +6 -41
- package/www/example/ws/rproxy.d.ts +1 -1
- package/www/example/ws/rproxy.js +5 -40
- package/www/example/ws/rsocket.d.ts +1 -1
- package/www/example/ws/rsocket.js +5 -40
- package/www/example/ws/test.d.ts +1 -1
- package/www/example/ws/test.js +7 -42
- package/eslint.config.js +0 -22
package/lib/turnstile.js
CHANGED
|
@@ -1,60 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.EFACTORY = void 0;
|
|
37
|
-
exports.verify = verify;
|
|
38
1
|
/**
|
|
39
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
40
3
|
* Date: 2025-6-11
|
|
41
4
|
* Last: 2025-6-11 21:50:31
|
|
42
5
|
*/
|
|
43
|
-
|
|
6
|
+
import * as tc from 'tencentcloud-sdk-nodejs';
|
|
44
7
|
// --- 库和定义 ---
|
|
45
|
-
|
|
46
|
-
|
|
8
|
+
import * as lNet from '../lib/net.js';
|
|
9
|
+
import * as lText from '../lib/text.js';
|
|
47
10
|
/**
|
|
48
11
|
* 0. CloudFlare:https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
|
|
49
12
|
* 1. 腾讯云:https://cloud.tencent.com/document/product/1110/36926
|
|
50
13
|
*/
|
|
51
14
|
/** --- 厂家 --- */
|
|
52
|
-
var EFACTORY;
|
|
15
|
+
export var EFACTORY;
|
|
53
16
|
(function (EFACTORY) {
|
|
54
17
|
EFACTORY[EFACTORY["CLOUDFLARE"] = 0] = "CLOUDFLARE";
|
|
55
18
|
EFACTORY[EFACTORY["TENCENT"] = 1] = "TENCENT";
|
|
56
|
-
})(EFACTORY || (
|
|
57
|
-
async function verify(ctr, opt) {
|
|
19
|
+
})(EFACTORY || (EFACTORY = {}));
|
|
20
|
+
export async function verify(ctr, opt) {
|
|
58
21
|
const config = ctr.getPrototype('_config');
|
|
59
22
|
switch (opt.factory) {
|
|
60
23
|
case EFACTORY.CLOUDFLARE: {
|
package/lib/ws.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as http from 'http';
|
|
7
7
|
import * as net from 'net';
|
|
8
|
-
import * as types from '
|
|
9
|
-
import * as sCtr from '
|
|
8
|
+
import * as types from '../types/index.js';
|
|
9
|
+
import * as sCtr from '../sys/ctr.js';
|
|
10
10
|
/** --- 一般用 SIMPLE --- */
|
|
11
11
|
export declare enum EFrameReceiveMode {
|
|
12
12
|
STANDARD = 0,
|
package/lib/ws.js
CHANGED
|
@@ -1,59 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Socket = exports.EOpcode = exports.EFrameReceiveMode = void 0;
|
|
37
|
-
exports.connect = connect;
|
|
38
|
-
exports.createServer = createServer;
|
|
39
|
-
exports.mproxy = mproxy;
|
|
40
|
-
exports.rproxy = rproxy;
|
|
41
|
-
exports.rsocket = rsocket;
|
|
42
|
-
const net = __importStar(require("net"));
|
|
1
|
+
import * as net from 'net';
|
|
43
2
|
// --- 第三方 ---
|
|
44
|
-
|
|
3
|
+
import * as liws from '@litert/websocket';
|
|
45
4
|
// --- 库 ---
|
|
46
|
-
|
|
47
|
-
|
|
5
|
+
import * as lText from '../lib/text.js';
|
|
6
|
+
import * as lNet from '../lib/net.js';
|
|
48
7
|
/** --- 一般用 SIMPLE --- */
|
|
49
|
-
var EFrameReceiveMode;
|
|
8
|
+
export var EFrameReceiveMode;
|
|
50
9
|
(function (EFrameReceiveMode) {
|
|
51
10
|
EFrameReceiveMode[EFrameReceiveMode["STANDARD"] = 0] = "STANDARD";
|
|
52
11
|
EFrameReceiveMode[EFrameReceiveMode["LITE"] = 1] = "LITE";
|
|
53
12
|
EFrameReceiveMode[EFrameReceiveMode["SIMPLE"] = 2] = "SIMPLE";
|
|
54
|
-
})(EFrameReceiveMode || (
|
|
13
|
+
})(EFrameReceiveMode || (EFrameReceiveMode = {}));
|
|
55
14
|
/** --- OPCODE --- */
|
|
56
|
-
var EOpcode;
|
|
15
|
+
export var EOpcode;
|
|
57
16
|
(function (EOpcode) {
|
|
58
17
|
EOpcode[EOpcode["CONTINUATION"] = 0] = "CONTINUATION";
|
|
59
18
|
EOpcode[EOpcode["TEXT"] = 1] = "TEXT";
|
|
@@ -61,9 +20,9 @@ var EOpcode;
|
|
|
61
20
|
EOpcode[EOpcode["CLOSE"] = 8] = "CLOSE";
|
|
62
21
|
EOpcode[EOpcode["PING"] = 9] = "PING";
|
|
63
22
|
EOpcode[EOpcode["PONG"] = 10] = "PONG";
|
|
64
|
-
})(EOpcode || (
|
|
23
|
+
})(EOpcode || (EOpcode = {}));
|
|
65
24
|
const liwsServer = liws.createServer();
|
|
66
|
-
class Socket {
|
|
25
|
+
export class Socket {
|
|
67
26
|
constructor(request, socket, options = {}) {
|
|
68
27
|
/** --- 还未开启监听时来的数据将存在这里 --- */
|
|
69
28
|
this._waitMsg = [];
|
|
@@ -305,13 +264,12 @@ class Socket {
|
|
|
305
264
|
}
|
|
306
265
|
}
|
|
307
266
|
}
|
|
308
|
-
exports.Socket = Socket;
|
|
309
267
|
/**
|
|
310
268
|
* --- 创建一个 ws 客户端发起 ws 请求 ---
|
|
311
269
|
* @param u 以 ws, wss 开头的地址
|
|
312
270
|
* @param opt 参数
|
|
313
271
|
*/
|
|
314
|
-
function connect(u, opt = {}) {
|
|
272
|
+
export function connect(u, opt = {}) {
|
|
315
273
|
const s = new Socket();
|
|
316
274
|
return s.connect(u, opt);
|
|
317
275
|
}
|
|
@@ -320,7 +278,7 @@ function connect(u, opt = {}) {
|
|
|
320
278
|
* @param request Http 请求端
|
|
321
279
|
* @param socket 响应双向 socket
|
|
322
280
|
*/
|
|
323
|
-
function createServer(request, socket, options = {}) {
|
|
281
|
+
export function createServer(request, socket, options = {}) {
|
|
324
282
|
return new Socket(request, socket, options);
|
|
325
283
|
}
|
|
326
284
|
/**
|
|
@@ -405,7 +363,7 @@ function bindPipe(s1, s2) {
|
|
|
405
363
|
* @param auth 校验字符串,读取 get 的 auth 和本参数做比对
|
|
406
364
|
* @param opt 参数
|
|
407
365
|
*/
|
|
408
|
-
async function mproxy(ctr, auth, opt = {}) {
|
|
366
|
+
export async function mproxy(ctr, auth, opt = {}) {
|
|
409
367
|
const req = ctr.getPrototype('_req');
|
|
410
368
|
/** --- 请求端产生的双向 socket --- */
|
|
411
369
|
const socket = ctr.getPrototype('_socket');
|
|
@@ -434,7 +392,7 @@ async function mproxy(ctr, auth, opt = {}) {
|
|
|
434
392
|
* @param url 反代真实请求地址,如有 get 需要自行添加
|
|
435
393
|
* @param opt 参数
|
|
436
394
|
*/
|
|
437
|
-
async function rproxy(ctr, url, opt = {}) {
|
|
395
|
+
export async function rproxy(ctr, url, opt = {}) {
|
|
438
396
|
const req = ctr.getPrototype('_req');
|
|
439
397
|
/** --- 请求端产生的双向 socket --- */
|
|
440
398
|
const socket = ctr.getPrototype('_socket');
|
|
@@ -456,7 +414,7 @@ async function rproxy(ctr, url, opt = {}) {
|
|
|
456
414
|
* @param port 反代真实请求端口
|
|
457
415
|
* @param opt 参数
|
|
458
416
|
*/
|
|
459
|
-
async function rsocket(ctr, host, port) {
|
|
417
|
+
export async function rsocket(ctr, host, port) {
|
|
460
418
|
return new Promise(resolve => {
|
|
461
419
|
/** --- 请求端产生的双向 ws --- */
|
|
462
420
|
const ws = ctr.getPrototype('_socket');
|
package/lib/zip.d.ts
CHANGED
package/lib/zip.js
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Zip = void 0;
|
|
40
|
-
exports.get = get;
|
|
41
|
-
const jszip_1 = __importDefault(require("jszip"));
|
|
42
|
-
const mime = __importStar(require("@litert/mime"));
|
|
43
|
-
const lText = __importStar(require("~/lib/text"));
|
|
1
|
+
import jszip from 'jszip';
|
|
2
|
+
import * as mime from '@litert/mime';
|
|
3
|
+
import * as lText from '../lib/text.js';
|
|
44
4
|
/**
|
|
45
5
|
* --- 本库主要用于读取 zip,请尽量不要用来写入 zip,尤其是大文件 zip ---
|
|
46
6
|
*/
|
|
47
|
-
class Zip {
|
|
7
|
+
export class Zip {
|
|
48
8
|
constructor(zip) {
|
|
49
9
|
/** --- 当前路径,以 / 开头以 / 结尾 --- */
|
|
50
10
|
this._path = '/';
|
|
@@ -429,13 +389,12 @@ class Zip {
|
|
|
429
389
|
});
|
|
430
390
|
}
|
|
431
391
|
}
|
|
432
|
-
exports.Zip = Zip;
|
|
433
392
|
/**
|
|
434
393
|
* --- 获取 zip 对象 ---
|
|
435
394
|
* @param data 对象数据
|
|
436
395
|
*/
|
|
437
|
-
async function get(data) {
|
|
438
|
-
const z = (
|
|
396
|
+
export async function get(data) {
|
|
397
|
+
const z = jszip();
|
|
439
398
|
try {
|
|
440
399
|
if (data) {
|
|
441
400
|
await z.loadAsync(data);
|
package/lib/zlib.js
CHANGED
|
@@ -1,100 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createGzip = createGzip;
|
|
37
|
-
exports.createGunzip = createGunzip;
|
|
38
|
-
exports.createDeflate = createDeflate;
|
|
39
|
-
exports.createInflate = createInflate;
|
|
40
|
-
exports.createBrotliCompress = createBrotliCompress;
|
|
41
|
-
exports.createBrotliDecompress = createBrotliDecompress;
|
|
42
|
-
exports.createCompress = createCompress;
|
|
43
|
-
exports.createDecompress = createDecompress;
|
|
44
|
-
exports.gzip = gzip;
|
|
45
|
-
exports.gunzip = gunzip;
|
|
46
|
-
exports.deflate = deflate;
|
|
47
|
-
exports.inflate = inflate;
|
|
48
|
-
exports.brotliCompress = brotliCompress;
|
|
49
|
-
exports.brotliDecompress = brotliDecompress;
|
|
50
|
-
exports.compress = compress;
|
|
51
|
-
exports.decompress = decompress;
|
|
52
1
|
/**
|
|
53
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
54
3
|
* Date: 2019-4-9 16:00:55
|
|
55
4
|
* Last: 2020-03-20 14:45:47, 2022-09-13 13:43:32
|
|
56
5
|
*/
|
|
57
|
-
|
|
6
|
+
import * as zlib from 'zlib';
|
|
58
7
|
/**
|
|
59
8
|
* --- 创建 Gzip 对象 ---
|
|
60
9
|
* @param options 选项
|
|
61
10
|
*/
|
|
62
|
-
function createGzip(options = {}) {
|
|
11
|
+
export function createGzip(options = {}) {
|
|
63
12
|
options.level ??= 7;
|
|
64
13
|
return zlib.createGzip(options);
|
|
65
14
|
}
|
|
66
15
|
/**
|
|
67
16
|
* --- 创建 Gzip 解压对象 ---
|
|
68
17
|
*/
|
|
69
|
-
function createGunzip() {
|
|
18
|
+
export function createGunzip() {
|
|
70
19
|
return zlib.createGunzip();
|
|
71
20
|
}
|
|
72
21
|
/**
|
|
73
22
|
* --- 创建 Deflate 对象 ---
|
|
74
23
|
* @param options 选项
|
|
75
24
|
*/
|
|
76
|
-
function createDeflate(options = {}) {
|
|
25
|
+
export function createDeflate(options = {}) {
|
|
77
26
|
options.level ??= 7;
|
|
78
27
|
return zlib.createDeflate(options);
|
|
79
28
|
}
|
|
80
29
|
/**
|
|
81
30
|
* --- 创建 Deflate 解压对象 ---
|
|
82
31
|
*/
|
|
83
|
-
function createInflate() {
|
|
32
|
+
export function createInflate() {
|
|
84
33
|
return zlib.createInflate();
|
|
85
34
|
}
|
|
86
35
|
/**
|
|
87
36
|
* --- 创建 Brotli 压缩对象 ---
|
|
88
37
|
* @param options 选项
|
|
89
38
|
*/
|
|
90
|
-
function createBrotliCompress(options = {}) {
|
|
39
|
+
export function createBrotliCompress(options = {}) {
|
|
91
40
|
options.level ??= 7;
|
|
92
41
|
return zlib.createBrotliCompress(options);
|
|
93
42
|
}
|
|
94
43
|
/**
|
|
95
44
|
* --- 创建 Brotli 解压对象 ---
|
|
96
45
|
*/
|
|
97
|
-
function createBrotliDecompress() {
|
|
46
|
+
export function createBrotliDecompress() {
|
|
98
47
|
return zlib.createBrotliDecompress();
|
|
99
48
|
}
|
|
100
49
|
/**
|
|
@@ -102,7 +51,7 @@ function createBrotliDecompress() {
|
|
|
102
51
|
* @param types 用 , 间隔的字符串,如 gzip,deflate
|
|
103
52
|
* @param options 选项
|
|
104
53
|
*/
|
|
105
|
-
function createCompress(types, options = {}) {
|
|
54
|
+
export function createCompress(types, options = {}) {
|
|
106
55
|
options.level ??= 7;
|
|
107
56
|
const type = getTypeByTypes(types);
|
|
108
57
|
if (!type) {
|
|
@@ -135,7 +84,7 @@ function createCompress(types, options = {}) {
|
|
|
135
84
|
* @param types 用 , 间隔的字符串,如 gzip,deflate
|
|
136
85
|
* @param options 选项
|
|
137
86
|
*/
|
|
138
|
-
function createDecompress(types) {
|
|
87
|
+
export function createDecompress(types) {
|
|
139
88
|
const type = getTypeByTypes(types);
|
|
140
89
|
if (!type) {
|
|
141
90
|
return null;
|
|
@@ -167,7 +116,7 @@ function createDecompress(types) {
|
|
|
167
116
|
* @param buffer 段
|
|
168
117
|
* @param options 选项
|
|
169
118
|
*/
|
|
170
|
-
function gzip(buffer, options = {}) {
|
|
119
|
+
export function gzip(buffer, options = {}) {
|
|
171
120
|
options.level ??= 7;
|
|
172
121
|
return new Promise(function (resolve) {
|
|
173
122
|
zlib.gzip(buffer, options, function (error, result) {
|
|
@@ -184,7 +133,7 @@ function gzip(buffer, options = {}) {
|
|
|
184
133
|
* Gzip 解压一段
|
|
185
134
|
* @param buffer 段
|
|
186
135
|
*/
|
|
187
|
-
function gunzip(buffer) {
|
|
136
|
+
export function gunzip(buffer) {
|
|
188
137
|
return new Promise(function (resolve) {
|
|
189
138
|
zlib.gunzip(buffer, function (error, result) {
|
|
190
139
|
if (error) {
|
|
@@ -201,7 +150,7 @@ function gunzip(buffer) {
|
|
|
201
150
|
* @param buffer 段
|
|
202
151
|
* @param options 选项
|
|
203
152
|
*/
|
|
204
|
-
function deflate(buffer, options = {}) {
|
|
153
|
+
export function deflate(buffer, options = {}) {
|
|
205
154
|
options.level ??= 7;
|
|
206
155
|
return new Promise(function (resolve) {
|
|
207
156
|
zlib.deflate(buffer, options, function (error, result) {
|
|
@@ -218,7 +167,7 @@ function deflate(buffer, options = {}) {
|
|
|
218
167
|
* Deflate 解压一段
|
|
219
168
|
* @param buffer 段
|
|
220
169
|
*/
|
|
221
|
-
function inflate(buffer) {
|
|
170
|
+
export function inflate(buffer) {
|
|
222
171
|
return new Promise(function (resolve) {
|
|
223
172
|
zlib.inflate(buffer, function (error, result) {
|
|
224
173
|
if (error) {
|
|
@@ -235,7 +184,7 @@ function inflate(buffer) {
|
|
|
235
184
|
* @param buffer 段
|
|
236
185
|
* @param options 选项
|
|
237
186
|
*/
|
|
238
|
-
function brotliCompress(buffer, options = {}) {
|
|
187
|
+
export function brotliCompress(buffer, options = {}) {
|
|
239
188
|
options.level ??= 7;
|
|
240
189
|
return new Promise(function (resolve) {
|
|
241
190
|
zlib.brotliCompress(buffer, options, function (error, result) {
|
|
@@ -252,7 +201,7 @@ function brotliCompress(buffer, options = {}) {
|
|
|
252
201
|
* Brotli 解压一段
|
|
253
202
|
* @param buffer 段
|
|
254
203
|
*/
|
|
255
|
-
function brotliDecompress(buffer) {
|
|
204
|
+
export function brotliDecompress(buffer) {
|
|
256
205
|
return new Promise(function (resolve) {
|
|
257
206
|
zlib.brotliDecompress(buffer, function (error, result) {
|
|
258
207
|
if (error) {
|
|
@@ -270,7 +219,7 @@ function brotliDecompress(buffer) {
|
|
|
270
219
|
* @param buffer 段
|
|
271
220
|
* @param options 选项
|
|
272
221
|
*/
|
|
273
|
-
async function compress(types, buffer, options) {
|
|
222
|
+
export async function compress(types, buffer, options) {
|
|
274
223
|
if (!buffer) {
|
|
275
224
|
return null;
|
|
276
225
|
}
|
|
@@ -306,7 +255,7 @@ async function compress(types, buffer, options) {
|
|
|
306
255
|
* @param types 用,间隔的字符串,如 gzip,deflate
|
|
307
256
|
* @param buffer 段
|
|
308
257
|
*/
|
|
309
|
-
async function decompress(types, buffer) {
|
|
258
|
+
export async function decompress(types, buffer) {
|
|
310
259
|
if (!buffer) {
|
|
311
260
|
return null;
|
|
312
261
|
}
|
package/main.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
3
2
|
/**
|
|
4
3
|
* Project: Kebab, User: JianSuoQiYue
|
|
@@ -6,58 +5,21 @@
|
|
|
6
5
|
* Last: 2020-3-6 22:19:37, 2022-3-30 01:01:22, 2022-9-27 16:11:40, 2025-6-13 12:56:18
|
|
7
6
|
*/
|
|
8
7
|
// git config core.ignorecase false
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
-
var ownKeys = function(o) {
|
|
27
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
-
var ar = [];
|
|
29
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
return ownKeys(o);
|
|
33
|
-
};
|
|
34
|
-
return function (mod) {
|
|
35
|
-
if (mod && mod.__esModule) return mod;
|
|
36
|
-
var result = {};
|
|
37
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
-
__setModuleDefault(result, mod);
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
|
-
})();
|
|
42
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
const cluster_1 = __importDefault(require("cluster"));
|
|
8
|
+
import cluster from 'cluster';
|
|
47
9
|
// --- 虽然框架本身不用,但是业务侧会用到,所以这个库不能删 ---
|
|
48
|
-
|
|
10
|
+
import 'ts-alias-loader';
|
|
49
11
|
// --- 初始化 ---
|
|
50
12
|
// --- 一定要分别隔离加载 Master 和 Child 代码,防止执行串了 ---
|
|
51
|
-
if (
|
|
13
|
+
if (cluster.isPrimary) {
|
|
52
14
|
if (process.argv.length > 2) {
|
|
53
15
|
// --- 传入的命令方式启动,则执行 RPC 相关命令 ---
|
|
54
|
-
|
|
16
|
+
import('./sys/cmd.js');
|
|
55
17
|
}
|
|
56
18
|
else {
|
|
57
19
|
// --- 正常启动 ---
|
|
58
|
-
|
|
20
|
+
import('./sys/master.js');
|
|
59
21
|
}
|
|
60
22
|
}
|
|
61
23
|
else {
|
|
62
|
-
|
|
24
|
+
import('./sys/child.js');
|
|
63
25
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maiyunnet/kebab",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"kebab",
|
|
7
8
|
"node",
|
|
@@ -14,8 +15,8 @@
|
|
|
14
15
|
"kebab": "./bin/kebab.js"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@aws-sdk/client-s3": "^3.
|
|
18
|
-
"@aws-sdk/lib-storage": "^3.
|
|
18
|
+
"@aws-sdk/client-s3": "^3.888.0",
|
|
19
|
+
"@aws-sdk/lib-storage": "^3.888.0",
|
|
19
20
|
"@litert/http-client": "^1.1.2",
|
|
20
21
|
"@litert/mime": "^0.1.3",
|
|
21
22
|
"@litert/redis": "^3.0.5",
|
|
@@ -23,17 +24,17 @@
|
|
|
23
24
|
"@types/ssh2": "^1.15.5",
|
|
24
25
|
"ejs": "^3.1.10",
|
|
25
26
|
"jszip": "^3.10.1",
|
|
26
|
-
"mysql2": "^3.14.
|
|
27
|
-
"ssh2": "^1.
|
|
27
|
+
"mysql2": "^3.14.5",
|
|
28
|
+
"ssh2": "^1.17.0",
|
|
28
29
|
"svg-captcha": "^1.4.0",
|
|
29
|
-
"tencentcloud-sdk-nodejs": "^4.1.
|
|
30
|
+
"tencentcloud-sdk-nodejs": "^4.1.116",
|
|
30
31
|
"ts-alias-loader": "^0.1.5"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@litert/eslint-plugin-rules": "^0.3.1",
|
|
34
35
|
"@types/ejs": "^3.1.5",
|
|
35
|
-
"@types/node": "^24.0
|
|
36
|
+
"@types/node": "^24.5.0",
|
|
36
37
|
"tsc-alias": "^1.8.16",
|
|
37
|
-
"typescript": "^5.
|
|
38
|
+
"typescript": "^5.9.2"
|
|
38
39
|
}
|
|
39
40
|
}
|
package/sys/child.js
CHANGED
|
@@ -1,55 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
1
|
/**
|
|
37
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
38
3
|
* Date: 2019-5-3 23:54
|
|
39
4
|
* Last: 2020-3-31 15:01:07, 2020-4-9 22:28:50, 2022-07-22 14:19:46, 2022-9-29 22:11:07, 2023-5-1 18:26:57, 2024-1-12 13:32:00, 2024-3-4 16:49:19
|
|
40
5
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
6
|
+
import * as http2 from 'http2';
|
|
7
|
+
import * as tls from 'tls';
|
|
8
|
+
import * as http from 'http';
|
|
9
|
+
import * as crypto from 'crypto';
|
|
45
10
|
// --- 库和定义 ---
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
11
|
+
import * as fs from '../lib/fs.js';
|
|
12
|
+
import * as lCore from '../lib/core.js';
|
|
13
|
+
import * as lText from '../lib/text.js';
|
|
14
|
+
import * as sCtr from '../sys/ctr.js';
|
|
15
|
+
import * as kebab from '../index.js';
|
|
51
16
|
// --- 初始化 ---
|
|
52
|
-
|
|
17
|
+
import * as sRoute from '../sys/route.js';
|
|
53
18
|
/** --- 10 秒往主线程发送一次心跳的 Timer --- */
|
|
54
19
|
const hbTimer = setInterval(function () {
|
|
55
20
|
if (!process.connected || !process.send) {
|