@maiyunnet/kebab 9.1.4 → 9.2.1
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/doc/kebab-rag.md +2237 -437
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/buffer.d.ts +5 -0
- package/lib/buffer.js +13 -0
- package/lib/cookie.d.ts +44 -0
- package/lib/cookie.js +216 -0
- package/lib/core.d.ts +3 -2
- package/lib/core.js +15 -12
- package/lib/dns.d.ts +1 -1
- package/lib/dns.js +4 -6
- package/lib/net/request.d.ts +2 -1
- package/lib/net.d.ts +3 -38
- package/lib/net.js +6 -219
- package/lib/socket.d.ts +4 -3
- package/lib/turnstile.js +2 -2
- package/lib/undici/formdata.d.ts +83 -0
- package/lib/undici/formdata.js +166 -0
- package/lib/undici/request.d.ts +86 -0
- package/lib/undici/request.js +120 -0
- package/lib/undici/response.d.ts +39 -0
- package/lib/undici/response.js +111 -0
- package/lib/undici.d.ts +174 -0
- package/lib/undici.js +595 -0
- package/lib/ws.d.ts +6 -5
- package/lib/ws.js +9 -9
- package/package.json +3 -2
- package/sys/master.js +23 -13
- package/sys/route.js +5 -2
- package/www/example/ctr/middle.js +3 -2
- package/www/example/ctr/test.d.ts +32 -0
- package/www/example/ctr/test.js +526 -4
- package/www/example/route.json +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maiyunnet/kebab",
|
|
3
|
-
"version": "9.1
|
|
3
|
+
"version": "9.2.1",
|
|
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": [
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"ssh2": "^1.17.0",
|
|
53
53
|
"svg-captcha": "^1.4.0",
|
|
54
54
|
"tailwind-merge": "^3.5.0",
|
|
55
|
-
"tencentcloud-sdk-nodejs": "^4.1.199"
|
|
55
|
+
"tencentcloud-sdk-nodejs": "^4.1.199",
|
|
56
|
+
"undici": "^8.1.0"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@litert/eslint-plugin-rules": "^0.3.1",
|
package/sys/master.js
CHANGED
|
@@ -546,19 +546,26 @@ function startFileWatcher() {
|
|
|
546
546
|
* --- 监听指定目录的文件变化 ---
|
|
547
547
|
* @param dir 要监听的目录路径
|
|
548
548
|
*/
|
|
549
|
-
const watchDir = (dir) => {
|
|
549
|
+
const watchDir = async (dir) => {
|
|
550
|
+
if (!await lFs.isDir(dir)) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
550
553
|
try {
|
|
551
|
-
fs.watch(dir, { 'recursive': true }, (eventType, filename) => {
|
|
554
|
+
const watcher = fs.watch(dir, { 'recursive': true }, (eventType, filename) => {
|
|
552
555
|
if (!filename) {
|
|
553
556
|
return;
|
|
554
557
|
}
|
|
558
|
+
const formatName = filename.replace(/\\/g, '/');
|
|
555
559
|
// --- 仅关注 .js 文件和 .json 配置文件的变更 ---
|
|
556
|
-
if (!
|
|
557
|
-
!
|
|
560
|
+
if (!formatName.endsWith('.js') &&
|
|
561
|
+
!formatName.endsWith('.json')) {
|
|
558
562
|
return;
|
|
559
563
|
}
|
|
560
|
-
// ---
|
|
561
|
-
if (
|
|
564
|
+
// --- 忽略日志目录、临时目录、git 目录和 node_modules ---
|
|
565
|
+
if (formatName.includes('log/') ||
|
|
566
|
+
formatName.includes('ftmp/') ||
|
|
567
|
+
formatName.includes('node_modules/') ||
|
|
568
|
+
formatName.includes('.git/')) {
|
|
562
569
|
return;
|
|
563
570
|
}
|
|
564
571
|
// --- 防抖:500ms 内多次变化只触发一次 ---
|
|
@@ -571,7 +578,7 @@ function startFileWatcher() {
|
|
|
571
578
|
return;
|
|
572
579
|
}
|
|
573
580
|
restarting = true;
|
|
574
|
-
lCore.display(`[HMR] File changed: ${
|
|
581
|
+
lCore.display(`[HMR] File changed: ${formatName}, reloading workers...`);
|
|
575
582
|
(async () => {
|
|
576
583
|
// --- 为所有子进程发送 stop 信息并重启 ---
|
|
577
584
|
for (const pid in workerList) {
|
|
@@ -589,20 +596,23 @@ function startFileWatcher() {
|
|
|
589
596
|
});
|
|
590
597
|
}, 500);
|
|
591
598
|
});
|
|
599
|
+
watcher.on('error', (err) => {
|
|
600
|
+
lCore.display(`[HMR] Watcher error on ${dir}:`, err);
|
|
601
|
+
});
|
|
592
602
|
lCore.display(`[HMR] Watching directory: ${dir}`);
|
|
593
603
|
}
|
|
594
|
-
catch {
|
|
595
|
-
lCore.display(`[HMR] Cannot watch directory: ${dir}
|
|
604
|
+
catch (err) {
|
|
605
|
+
lCore.display(`[HMR] Cannot watch directory: ${dir}`, err);
|
|
596
606
|
}
|
|
597
607
|
};
|
|
598
608
|
// --- 监听 www/ 目录(用户项目代码)---
|
|
599
|
-
watchDir(kebab.WWW_CWD);
|
|
609
|
+
watchDir(kebab.WWW_CWD).catch(() => { });
|
|
600
610
|
// --- 监听 ind/ 目录(独立任务代码)---
|
|
601
|
-
watchDir(kebab.IND_CWD);
|
|
611
|
+
watchDir(kebab.IND_CWD).catch(() => { });
|
|
602
612
|
// --- 监听 lib/ 目录(用户自定义库)---
|
|
603
|
-
watchDir(kebab.LIB_CWD);
|
|
613
|
+
watchDir(kebab.LIB_CWD).catch(() => { });
|
|
604
614
|
// --- 监听 mod/ 目录(用户模型)---
|
|
605
|
-
watchDir(kebab.MOD_CWD);
|
|
615
|
+
watchDir(kebab.MOD_CWD).catch(() => { });
|
|
606
616
|
}
|
|
607
617
|
run().catch(function (e) {
|
|
608
618
|
lCore.display('[master] ------ [Process fatal Error] ------');
|
package/sys/route.js
CHANGED
|
@@ -12,7 +12,8 @@ import * as lFs from '#kebab/lib/fs.js';
|
|
|
12
12
|
import * as lZlib from '#kebab/lib/zlib.js';
|
|
13
13
|
import * as lCore from '#kebab/lib/core.js';
|
|
14
14
|
import * as lText from '#kebab/lib/text.js';
|
|
15
|
-
import * as
|
|
15
|
+
import * as lNetResponse from '#kebab/lib/net/response.js';
|
|
16
|
+
import * as lUndiciResponse from '#kebab/lib/undici/response.js';
|
|
16
17
|
import * as lWs from '#kebab/lib/ws.js';
|
|
17
18
|
import * as lLang from '#kebab/lib/lang.js';
|
|
18
19
|
import * as sCtr from './ctr.js';
|
|
@@ -600,7 +601,9 @@ export async function run(data) {
|
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
603
|
}
|
|
603
|
-
else if (rtn instanceof stream.Readable ||
|
|
604
|
+
else if (rtn instanceof stream.Readable ||
|
|
605
|
+
rtn instanceof lNetResponse.Response ||
|
|
606
|
+
rtn instanceof lUndiciResponse.Response) {
|
|
604
607
|
// --- 返回的是流,那就以管道的形式输出 ---
|
|
605
608
|
const stm = rtn instanceof stream.Readable ? rtn : rtn.getStream();
|
|
606
609
|
if (!stm) {
|
|
@@ -3,11 +3,12 @@ import * as sCtr from '#kebab/sys/ctr.js';
|
|
|
3
3
|
export default class extends sCtr.Ctr {
|
|
4
4
|
async onReqStart() {
|
|
5
5
|
if (await lNet.rproxy(this, {
|
|
6
|
-
'test/net-rproxy/': 'https://cdn.jsdelivr.net/npm/deskrt@2.0.10/'
|
|
6
|
+
'test/net-rproxy/': 'https://cdn.jsdelivr.net/npm/deskrt@2.0.10/',
|
|
7
|
+
'test/undici-rproxy/': 'https://cdn.jsdelivr.net/npm/deskrt@2.0.10/'
|
|
7
8
|
})) {
|
|
8
9
|
return -1;
|
|
9
10
|
}
|
|
10
|
-
if (this._config.const.path === 'test/net-mproxy1') {
|
|
11
|
+
if (this._config.const.path === 'test/net-mproxy1' || this._config.const.path === 'test/undici-mproxy1') {
|
|
11
12
|
return 0;
|
|
12
13
|
}
|
|
13
14
|
return 1;
|
|
@@ -93,6 +93,38 @@ export default class extends sCtr.Ctr {
|
|
|
93
93
|
netGetResponseJson(): Promise<string>;
|
|
94
94
|
getResponseJson1(): any[];
|
|
95
95
|
getResponseJson2(): any[];
|
|
96
|
+
undici(): Promise<string>;
|
|
97
|
+
undiciPipe(): Promise<kebab.Json>;
|
|
98
|
+
undiciPost(): Promise<kebab.Json>;
|
|
99
|
+
undiciPost1(): string;
|
|
100
|
+
undiciPostString(): Promise<string>;
|
|
101
|
+
undiciPostString1(): kebab.Json[];
|
|
102
|
+
undiciOpen(): Promise<kebab.Json>;
|
|
103
|
+
undiciFormTest(): Promise<string>;
|
|
104
|
+
undiciUpload(): Promise<string>;
|
|
105
|
+
undiciUpload1(): Promise<string>;
|
|
106
|
+
undiciCookie(): Promise<string>;
|
|
107
|
+
undiciCookie1(): string;
|
|
108
|
+
undiciCookie2(): string;
|
|
109
|
+
undiciSave(): Promise<string>;
|
|
110
|
+
undiciFollow(): Promise<string>;
|
|
111
|
+
undiciFollow1(): void;
|
|
112
|
+
undiciFollow2(): kebab.Json;
|
|
113
|
+
undiciReuse(): Promise<string>;
|
|
114
|
+
undiciError(): Promise<string>;
|
|
115
|
+
undiciHosts(): Promise<string>;
|
|
116
|
+
undiciMproxy(): Promise<string | boolean>;
|
|
117
|
+
undiciMproxy1(): Promise<string | boolean>;
|
|
118
|
+
undiciMproxy2(): any[];
|
|
119
|
+
undiciFilterheaders(): string;
|
|
120
|
+
undiciFetch(): Promise<string | boolean>;
|
|
121
|
+
undiciFetch1(): any[];
|
|
122
|
+
undiciGetResponseJson(): Promise<string>;
|
|
123
|
+
undiciGetResponseJson1(): any[];
|
|
124
|
+
undiciGetResponseJson2(): any[];
|
|
125
|
+
/** --- 测试 ProxyAgent --- */
|
|
126
|
+
private readonly _undiciProxyAgent;
|
|
127
|
+
undiciProxy(): Promise<string>;
|
|
96
128
|
scan(): Promise<kebab.Json>;
|
|
97
129
|
scan1(): Promise<kebab.Json>;
|
|
98
130
|
scan2(): Promise<kebab.Json>;
|