@maiyunnet/kebab 3.2.3 → 3.2.5
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/index.d.ts +3 -3
- package/index.js +1 -1
- package/lib/s3.d.ts +1 -1
- package/lib/ws.d.ts +3 -4
- package/lib/ws.js +26 -26
- package/package.json +8 -8
- package/sys/ctr.d.ts +5 -1
- package/sys/ctr.js +6 -0
- package/sys/route.js +12 -5
package/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
6
6
|
*/
|
|
7
7
|
/** --- 当前系统版本号 --- */
|
|
8
|
-
export declare const VER = "3.2.
|
|
8
|
+
export declare const VER = "3.2.5";
|
|
9
9
|
/** --- 框架根目录,以 / 结尾 --- */
|
|
10
10
|
export declare const ROOT_PATH: string;
|
|
11
11
|
export declare const LIB_PATH: string;
|
|
@@ -159,10 +159,10 @@ export interface IConfigConst {
|
|
|
159
159
|
}
|
|
160
160
|
/** --- 虚拟机配置对象 --- */
|
|
161
161
|
export interface IVhost {
|
|
162
|
-
readonly 'name'
|
|
162
|
+
readonly 'name'?: string;
|
|
163
163
|
readonly 'domains': string[];
|
|
164
164
|
readonly 'root': string;
|
|
165
|
-
readonly 'remark'
|
|
165
|
+
readonly 'remark'?: string;
|
|
166
166
|
}
|
|
167
167
|
/** --- 上传的文件信息对象 --- */
|
|
168
168
|
export interface IPostFile {
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '3.2.
|
|
9
|
+
export const VER = '3.2.5';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/s3.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare class S3 {
|
|
|
60
60
|
* @param key 对象路径
|
|
61
61
|
* @param bucket bucket 名
|
|
62
62
|
*/
|
|
63
|
-
getObject(key: string, bucket?: string): Promise<
|
|
63
|
+
getObject(key: string, bucket?: string): Promise<any>;
|
|
64
64
|
/**
|
|
65
65
|
* --- 删除对象 ---
|
|
66
66
|
* @param key 对象路径
|
package/lib/ws.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
3
3
|
* Date: 2019-6-2 20:42
|
|
4
|
-
* Last: 2020-4-9 22:33:11, 2022-09-13 13:32:01, 2022-12-30 19:13:07, 2024-2-6 23:53:45, 2024-12-23 01:33:16, 2025-1-28 21:05:51, 2025-9-23 12:27:48
|
|
4
|
+
* Last: 2020-4-9 22:33:11, 2022-09-13 13:32:01, 2022-12-30 19:13:07, 2024-2-6 23:53:45, 2024-12-23 01:33:16, 2025-1-28 21:05:51, 2025-9-23 12:27:48, 2025-10-4 23:20:32
|
|
5
5
|
*/
|
|
6
6
|
import * as http from 'http';
|
|
7
7
|
import * as net from 'net';
|
|
@@ -104,15 +104,14 @@ export declare class Socket {
|
|
|
104
104
|
/** --- 绑定监听 --- */
|
|
105
105
|
on(event: 'message', cb: (msg: {
|
|
106
106
|
'opcode': EOpcode;
|
|
107
|
-
'
|
|
108
|
-
'data': Buffer | string;
|
|
107
|
+
'data': Buffer;
|
|
109
108
|
}) => void | Promise<void>): this;
|
|
110
109
|
on(event: 'error', cb: (error: any) => void | Promise<void>): this;
|
|
111
110
|
on(event: 'drain' | 'close' | 'end', cb: () => void | Promise<void>): this;
|
|
112
111
|
end(): void;
|
|
113
112
|
destroy(): void;
|
|
114
113
|
/** --- 发送文本 --- */
|
|
115
|
-
writeText(data: string): boolean;
|
|
114
|
+
writeText(data: Buffer | string | Array<Buffer | string>): boolean;
|
|
116
115
|
/** --- 发送结果对象字符串 --- */
|
|
117
116
|
writeResult(data: kebab.Json): boolean;
|
|
118
117
|
/** --- 发送二进制 --- */
|
package/lib/ws.js
CHANGED
|
@@ -20,7 +20,9 @@ export var EOpcode;
|
|
|
20
20
|
EOpcode[EOpcode["PING"] = 9] = "PING";
|
|
21
21
|
EOpcode[EOpcode["PONG"] = 10] = "PONG";
|
|
22
22
|
})(EOpcode || (EOpcode = {}));
|
|
23
|
-
const liwsServer = liws.createServer(
|
|
23
|
+
const liwsServer = liws.createServer({
|
|
24
|
+
'frameReceiveMode': EFrameReceiveMode.SIMPLE,
|
|
25
|
+
});
|
|
24
26
|
export class Socket {
|
|
25
27
|
constructor(request, socket, options = {}) {
|
|
26
28
|
/** --- 还未开启监听时来的数据将存在这里 --- */
|
|
@@ -137,17 +139,17 @@ export class Socket {
|
|
|
137
139
|
/** --- 创建成功后第一时间绑定事件 --- */
|
|
138
140
|
_bindEvent() {
|
|
139
141
|
this._ws.on('message', msg => {
|
|
140
|
-
(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
})
|
|
142
|
+
if (msg.opcode === EOpcode.CLOSE) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (!('data' in msg)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const buf = Buffer.concat(msg.data);
|
|
149
|
+
this._on.message({
|
|
150
|
+
'opcode': msg.opcode,
|
|
151
|
+
'data': buf,
|
|
152
|
+
});
|
|
151
153
|
}).on('drain', () => {
|
|
152
154
|
this._on.drain();
|
|
153
155
|
}).on('error', (e) => {
|
|
@@ -277,17 +279,16 @@ export function createServer(request, socket, options = {}) {
|
|
|
277
279
|
* @param s2 第二个 socket
|
|
278
280
|
*/
|
|
279
281
|
function bindPipe(s1, s2) {
|
|
280
|
-
return new Promise(
|
|
282
|
+
return new Promise(resolve => {
|
|
281
283
|
// --- 监听发送端的 ---
|
|
282
284
|
s1.on('message', (msg) => {
|
|
283
285
|
switch (msg.opcode) {
|
|
284
|
-
case EOpcode.TEXT:
|
|
286
|
+
case EOpcode.TEXT: {
|
|
287
|
+
s2.writeText(msg.data.toString());
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
285
290
|
case EOpcode.BINARY: {
|
|
286
|
-
|
|
287
|
-
s2.writeText(msg.data);
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
s2.writeBinary(msg.buffer);
|
|
291
|
+
s2.writeBinary(msg.data);
|
|
291
292
|
break;
|
|
292
293
|
}
|
|
293
294
|
case EOpcode.CLOSE: {
|
|
@@ -314,13 +315,12 @@ function bindPipe(s1, s2) {
|
|
|
314
315
|
// --- 监听远程端的 ---
|
|
315
316
|
s2.on('message', (msg) => {
|
|
316
317
|
switch (msg.opcode) {
|
|
317
|
-
case EOpcode.TEXT:
|
|
318
|
+
case EOpcode.TEXT: {
|
|
319
|
+
s1.writeText(msg.data.toString());
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
318
322
|
case EOpcode.BINARY: {
|
|
319
|
-
|
|
320
|
-
s1.writeText(msg.data);
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
s1.writeBinary(msg.buffer);
|
|
323
|
+
s1.writeBinary(msg.data);
|
|
324
324
|
break;
|
|
325
325
|
}
|
|
326
326
|
case EOpcode.CLOSE: {
|
|
@@ -423,7 +423,7 @@ export async function rsocket(ctr, host, port) {
|
|
|
423
423
|
switch (msg.opcode) {
|
|
424
424
|
case EOpcode.TEXT:
|
|
425
425
|
case EOpcode.BINARY: {
|
|
426
|
-
socket.write(msg.
|
|
426
|
+
socket.write(msg.data);
|
|
427
427
|
break;
|
|
428
428
|
}
|
|
429
429
|
case EOpcode.CLOSE: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maiyunnet/kebab",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -19,25 +19,25 @@
|
|
|
19
19
|
"#kebab/*": "./*"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aws-sdk/client-s3": "^3.
|
|
23
|
-
"@aws-sdk/lib-storage": "^3.
|
|
22
|
+
"@aws-sdk/client-s3": "^3.901.0",
|
|
23
|
+
"@aws-sdk/lib-storage": "^3.903.0",
|
|
24
24
|
"@litert/http-client": "^1.1.2",
|
|
25
25
|
"@litert/mime": "^0.1.3",
|
|
26
26
|
"@litert/redis": "^3.0.5",
|
|
27
|
-
"@litert/websocket": "^0.2.
|
|
27
|
+
"@litert/websocket": "^0.2.4",
|
|
28
28
|
"@types/ssh2": "^1.15.5",
|
|
29
29
|
"ejs": "^3.1.10",
|
|
30
30
|
"jszip": "^3.10.1",
|
|
31
|
-
"mysql2": "^3.15.
|
|
31
|
+
"mysql2": "^3.15.1",
|
|
32
32
|
"ssh2": "^1.17.0",
|
|
33
33
|
"svg-captcha": "^1.4.0",
|
|
34
|
-
"tencentcloud-sdk-nodejs": "^4.1.
|
|
34
|
+
"tencentcloud-sdk-nodejs": "^4.1.126"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@litert/eslint-plugin-rules": "^0.3.1",
|
|
38
38
|
"@types/ejs": "^3.1.5",
|
|
39
|
-
"@types/node": "^24.
|
|
39
|
+
"@types/node": "^24.7.0",
|
|
40
40
|
"tsc-alias": "^1.8.16",
|
|
41
|
-
"typescript": "^5.9.
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/sys/ctr.d.ts
CHANGED
|
@@ -124,6 +124,10 @@ export declare class Ctr {
|
|
|
124
124
|
* --- WebSocket 下连接恢复可写入状态后会调用此事件,可重写此方法 ---
|
|
125
125
|
*/
|
|
126
126
|
onDrain(): void | Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* --- WebSocket 下连接被 end 后会自动被调用的事件,可重写此方法 ---
|
|
129
|
+
*/
|
|
130
|
+
onEnd(): void | Promise<void>;
|
|
127
131
|
/**
|
|
128
132
|
* --- WebSocket 下连接被终止后会自动被调用的事件,可重写此方法 ---
|
|
129
133
|
*/
|
|
@@ -231,7 +235,7 @@ export declare class Ctr {
|
|
|
231
235
|
* --- 发送 socket 文本 ---
|
|
232
236
|
* @param data 要发送的信息
|
|
233
237
|
*/
|
|
234
|
-
protected _writeText(data: string): boolean;
|
|
238
|
+
protected _writeText(data: Buffer | string | Array<Buffer | string>): boolean;
|
|
235
239
|
/**
|
|
236
240
|
* --- 发送结果对象文本 ---
|
|
237
241
|
* @param data 要发送的结果对象,如 [0, 'Failed.']
|
package/sys/ctr.js
CHANGED
package/sys/route.js
CHANGED
|
@@ -274,7 +274,7 @@ export async function run(data) {
|
|
|
274
274
|
wsSocket.on('message', async function (msg) {
|
|
275
275
|
switch (msg.opcode) {
|
|
276
276
|
case ws.EOpcode.CLOSE: {
|
|
277
|
-
const r = await cctr['onMessage'](msg.
|
|
277
|
+
const r = await cctr['onMessage'](msg.data, msg.opcode);
|
|
278
278
|
if (r === false) {
|
|
279
279
|
break;
|
|
280
280
|
}
|
|
@@ -282,7 +282,7 @@ export async function run(data) {
|
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
case ws.EOpcode.PING: {
|
|
285
|
-
const r = await cctr['onMessage'](msg.
|
|
285
|
+
const r = await cctr['onMessage'](msg.data, msg.opcode);
|
|
286
286
|
if (r === false) {
|
|
287
287
|
break;
|
|
288
288
|
}
|
|
@@ -292,11 +292,11 @@ export async function run(data) {
|
|
|
292
292
|
case ws.EOpcode.BINARY:
|
|
293
293
|
case ws.EOpcode.TEXT: {
|
|
294
294
|
try {
|
|
295
|
-
const r = await cctr['onMessage'](msg.
|
|
295
|
+
const r = await cctr['onMessage'](msg.data, msg.opcode);
|
|
296
296
|
if (r === false) {
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
|
-
const wrtn = await cctr['onData'](msg.data, msg.opcode);
|
|
299
|
+
const wrtn = await cctr['onData'](msg.opcode === ws.EOpcode.TEXT ? msg.data.toString() : msg.data, msg.opcode);
|
|
300
300
|
if (wrtn === false) {
|
|
301
301
|
wsSocket.end();
|
|
302
302
|
return;
|
|
@@ -339,6 +339,13 @@ export async function run(data) {
|
|
|
339
339
|
}
|
|
340
340
|
}).on('error', (e) => {
|
|
341
341
|
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
342
|
+
}).on('end', async () => {
|
|
343
|
+
try {
|
|
344
|
+
await cctr['onEnd']();
|
|
345
|
+
}
|
|
346
|
+
catch (e) {
|
|
347
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
348
|
+
}
|
|
342
349
|
}).on('close', async () => {
|
|
343
350
|
try {
|
|
344
351
|
await cctr['onClose']();
|
|
@@ -476,7 +483,7 @@ export async function run(data) {
|
|
|
476
483
|
return true;
|
|
477
484
|
}
|
|
478
485
|
// --- 检测 action 是否存在,以及排除内部方法 ---
|
|
479
|
-
if (pathRight.startsWith('_') || pathRight === 'onUpgrade' || pathRight === 'onLoad' || pathRight === 'onData' || pathRight === 'onDrain' || pathRight === 'onClose' || pathRight === 'setPrototype' || pathRight === 'getPrototype' || pathRight === 'getAuthorization') {
|
|
486
|
+
if (pathRight.startsWith('_') || pathRight === 'onUpgrade' || pathRight === 'onLoad' || pathRight === 'onData' || pathRight === 'onDrain' || pathRight === 'onEnd' || pathRight === 'onClose' || pathRight === 'setPrototype' || pathRight === 'getPrototype' || pathRight === 'getAuthorization') {
|
|
480
487
|
// --- _ 开头的 action 是内部方法,不允许访问 ---
|
|
481
488
|
if (config.route['#404']) {
|
|
482
489
|
data.res.setHeader('location', lText.urlResolve(config.const.urlBase, config.route['#404']));
|