egg 4.1.0-beta.20 → 4.1.0-beta.21
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/dist/agent.d.ts +3 -17
- package/dist/agent.js +7 -11
- package/dist/app/extend/context.d.ts +180 -12
- package/dist/app/extend/context.js +259 -3
- package/dist/app/extend/helper.d.ts +37 -12
- package/dist/app/extend/helper.js +43 -5
- package/dist/app/extend/request.d.ts +132 -12
- package/dist/app/extend/request.js +265 -4
- package/dist/app/extend/response.d.ts +25 -2
- package/dist/app/extend/response.js +34 -3
- package/dist/app/middleware/body_parser.d.ts +2 -2
- package/dist/app/middleware/body_parser.js +3 -7
- package/dist/app/middleware/meta.d.ts +10 -12
- package/dist/app/middleware/meta.js +19 -13
- package/dist/app/middleware/notfound.d.ts +7 -12
- package/dist/app/middleware/notfound.js +28 -25
- package/dist/app/middleware/override_method.d.ts +2 -2
- package/dist/app/middleware/override_method.js +3 -7
- package/dist/app/middleware/site_file.d.ts +9 -12
- package/dist/app/middleware/site_file.js +52 -37
- package/dist/config/config.default.d.ts +2 -16
- package/dist/config/config.default.js +375 -282
- package/dist/config/config.local.d.ts +5 -7
- package/dist/config/config.local.js +9 -6
- package/dist/config/config.unittest.d.ts +5 -7
- package/dist/config/config.unittest.js +8 -9
- package/dist/config/plugin.d.ts +120 -122
- package/dist/config/plugin.js +121 -53
- package/dist/index.d.ts +66 -13
- package/dist/index.js +70 -30
- package/dist/lib/agent.d.ts +19 -12
- package/dist/lib/agent.js +48 -22
- package/dist/lib/application.d.ts +56 -12
- package/dist/lib/application.js +261 -23
- package/dist/lib/core/base_context_class.d.ts +18 -12
- package/dist/lib/core/base_context_class.js +17 -4
- package/dist/lib/core/base_context_logger.d.ts +36 -12
- package/dist/lib/core/base_context_logger.js +60 -3
- package/dist/lib/core/base_hook_class.d.ts +11 -12
- package/dist/lib/core/base_hook_class.js +22 -3
- package/dist/lib/core/context_httpclient.d.ts +17 -12
- package/dist/lib/core/context_httpclient.js +26 -3
- package/dist/lib/core/httpclient.d.ts +14 -12
- package/dist/lib/core/httpclient.js +39 -3
- package/dist/lib/core/logger.d.ts +3 -17
- package/dist/lib/core/logger.js +37 -3
- package/dist/lib/core/messenger/IMessenger.d.ts +50 -2
- package/dist/lib/core/messenger/IMessenger.js +2 -1
- package/dist/lib/core/messenger/base.d.ts +8 -13
- package/dist/lib/core/messenger/base.js +28 -17
- package/dist/lib/core/messenger/index.d.ts +7 -12
- package/dist/lib/core/messenger/index.js +10 -17
- package/dist/lib/core/messenger/ipc.d.ts +55 -68
- package/dist/lib/core/messenger/ipc.js +151 -17
- package/dist/lib/core/messenger/local.d.ts +56 -69
- package/dist/lib/core/messenger/local.js +128 -17
- package/dist/lib/core/utils.d.ts +2 -5
- package/dist/lib/core/utils.js +70 -3
- package/dist/lib/egg.d.ts +285 -12
- package/dist/lib/egg.js +582 -17
- package/dist/lib/error/CookieLimitExceedError.d.ts +5 -2
- package/dist/lib/error/CookieLimitExceedError.js +12 -3
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +5 -2
- package/dist/lib/error/MessageUnhandledRejectionError.js +12 -3
- package/dist/lib/error/index.d.ts +2 -4
- package/dist/lib/error/index.js +3 -5
- package/dist/lib/loader/AgentWorkerLoader.d.ts +12 -3
- package/dist/lib/loader/AgentWorkerLoader.js +20 -4
- package/dist/lib/loader/AppWorkerLoader.d.ts +17 -3
- package/dist/lib/loader/AppWorkerLoader.js +39 -4
- package/dist/lib/loader/EggApplicationLoader.d.ts +4 -2
- package/dist/lib/loader/EggApplicationLoader.js +4 -3
- package/dist/lib/loader/index.d.ts +3 -5
- package/dist/lib/loader/index.js +4 -6
- package/dist/lib/start.d.ts +24 -12
- package/dist/lib/start.js +46 -27
- package/dist/lib/types.d.ts +281 -12
- package/dist/lib/types.js +31 -4
- package/dist/lib/types.plugin.d.ts +12 -1
- package/dist/lib/types.plugin.js +14 -3
- package/dist/lib/utils.d.ts +2 -5
- package/dist/lib/utils.js +14 -3
- package/dist/urllib.d.ts +1 -1
- package/dist/urllib.js +2 -3
- package/package.json +23 -23
- package/dist/AgentWorkerLoader-DG_hAClt.d.ts +0 -17
- package/dist/AgentWorkerLoader-D_hceBRW.js +0 -24
- package/dist/AppWorkerLoader-CAtxJvGl.js +0 -37
- package/dist/AppWorkerLoader-CT875rYM.d.ts +0 -22
- package/dist/CookieLimitExceedError-CAW0HYJw.d.ts +0 -8
- package/dist/CookieLimitExceedError-DLGakbeu.js +0 -15
- package/dist/EggApplicationLoader-CMe1VQt1.js +0 -7
- package/dist/EggApplicationLoader-PnIvd5oV.d.ts +0 -8
- package/dist/IMessenger-C9g6ypSI.d.ts +0 -54
- package/dist/MessageUnhandledRejectionError-Lq5fWw24.d.ts +0 -8
- package/dist/MessageUnhandledRejectionError-oD_E1Ewl.js +0 -15
- package/dist/agent-BfFWeJj4.js +0 -55
- package/dist/application-DVwFQSa9.js +0 -208
- package/dist/base-KLVtlzUD.d.ts +0 -12
- package/dist/base_context_class-Xc1OZql9.js +0 -19
- package/dist/base_context_logger-CZU59PGA.js +0 -58
- package/dist/base_hook_class-D0Gu2p8r.js +0 -26
- package/dist/base_hook_class-R8A8gm1s.d.ts +0 -1109
- package/dist/context-D1Wg7CXs.js +0 -244
- package/dist/context_httpclient-BpRMdJhf.js +0 -29
- package/dist/egg-DVo5e_lr.js +0 -800
- package/dist/error-BYo_LRnd.js +0 -1
- package/dist/helper-B3PKMPXq.js +0 -47
- package/dist/httpclient-C1QPc_R7.js +0 -36
- package/dist/index-CUPkUUOR.d.ts +0 -1
- package/dist/index-CkgLZdB4.d.ts +0 -1
- package/dist/loader-3myZ-rpm.js +0 -1
- package/dist/logger-C4tIcO3S.js +0 -31
- package/dist/request-Cy_1DlaX.js +0 -225
- package/dist/response-CDeQ9Sx2.js +0 -36
- package/dist/response-DlNYDj00.d.ts +0 -29
- package/dist/src-BuOjXSrB.js +0 -3
- package/dist/start-4E84z796.js +0 -35
- package/dist/types-dKSyDnVp.js +0 -32
- package/dist/types.plugin-B2v0K0I8.js +0 -14
- package/dist/types.plugin-C3D5I7VD.d.ts +0 -12
- package/dist/utils-B1Rjsoi9.js +0 -48
- package/dist/utils-BDoYg6z6.js +0 -14
package/dist/lib/types.plugin.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// import plugin types only, avoid circular dependency
|
|
2
|
+
import '@eggjs/development/types';
|
|
3
|
+
import '@eggjs/i18n/types';
|
|
4
|
+
import '@eggjs/jsonp/types';
|
|
5
|
+
import '@eggjs/logrotator/types';
|
|
6
|
+
import '@eggjs/multipart/types';
|
|
7
|
+
import '@eggjs/onerror/types';
|
|
8
|
+
import '@eggjs/schedule/types';
|
|
9
|
+
import '@eggjs/security/types';
|
|
10
|
+
import '@eggjs/session/types';
|
|
11
|
+
import '@eggjs/static/types';
|
|
12
|
+
import '@eggjs/view/types';
|
|
13
|
+
import '@eggjs/watcher/types';
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMucGx1Z2luLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi90eXBlcy5wbHVnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsc0RBQXNEO0FBRXRELE9BQU8sMEJBQTBCLENBQUM7QUFDbEMsT0FBTyxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLG9CQUFvQixDQUFDO0FBQzVCLE9BQU8seUJBQXlCLENBQUM7QUFDakMsT0FBTyx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sdUJBQXVCLENBQUM7QUFDL0IsT0FBTyx1QkFBdUIsQ0FBQztBQUMvQixPQUFPLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLHNCQUFzQixDQUFDIn0=
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare function
|
|
3
|
-
declare function getSourceFile(filename: string): string;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { getSourceDirname, getSourceFile };
|
|
1
|
+
export declare function getSourceDirname(): string;
|
|
2
|
+
export declare function getSourceFile(filename: string): string;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
export function getSourceDirname() {
|
|
4
|
+
if (typeof __dirname !== 'undefined') {
|
|
5
|
+
return path.dirname(__dirname);
|
|
6
|
+
}
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
return path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
10
|
+
}
|
|
11
|
+
export function getSourceFile(filename) {
|
|
12
|
+
return path.join(getSourceDirname(), filename);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sSUFBSSxNQUFNLFdBQVcsQ0FBQztBQUM3QixPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRXpDLE1BQU0sVUFBVSxnQkFBZ0I7SUFDOUIsSUFBSSxPQUFPLFNBQVMsS0FBSyxXQUFXLEVBQUUsQ0FBQztRQUNyQyxPQUFPLElBQUksQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUNELDZEQUE2RDtJQUM3RCxhQUFhO0lBQ2IsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3BFLENBQUM7QUFFRCxNQUFNLFVBQVUsYUFBYSxDQUFDLFFBQWdCO0lBQzVDLE9BQU8sSUFBSSxDQUFDLElBQUksQ0FBQyxnQkFBZ0IsRUFBRSxFQUFFLFFBQVEsQ0FBQyxDQUFDO0FBQ2pELENBQUMifQ==
|
package/dist/urllib.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from 'urllib';
|
package/dist/urllib.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
|
|
3
|
-
export { };
|
|
1
|
+
export * from 'urllib';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsbGliLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3VybGxpYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFFBQVEsQ0FBQyJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egg",
|
|
3
|
-
"version": "4.1.0-beta.
|
|
3
|
+
"version": "4.1.0-beta.21",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22.18.0"
|
|
6
6
|
},
|
|
@@ -86,23 +86,23 @@
|
|
|
86
86
|
"type-fest": "^5.0.1",
|
|
87
87
|
"urllib": "^4.8.2",
|
|
88
88
|
"utility": "^2.5.0",
|
|
89
|
-
"@eggjs/cluster": "4.0.0-beta.
|
|
90
|
-
"@eggjs/cookies": "4.0.0-beta.
|
|
91
|
-
"@eggjs/
|
|
92
|
-
"@eggjs/extend2": "5.0.0-beta.
|
|
93
|
-
"@eggjs/
|
|
94
|
-
"@eggjs/
|
|
95
|
-
"@eggjs/
|
|
96
|
-
"@eggjs/
|
|
97
|
-
"@eggjs/
|
|
98
|
-
"@eggjs/schedule": "6.0.0-beta.
|
|
99
|
-
"@eggjs/
|
|
100
|
-
"@eggjs/
|
|
101
|
-
"@eggjs/
|
|
102
|
-
"@eggjs/
|
|
103
|
-
"@eggjs/utils": "5.0.0-beta.
|
|
104
|
-
"@eggjs/view": "4.0.0-beta.
|
|
105
|
-
"@eggjs/watcher": "5.0.0-beta.
|
|
89
|
+
"@eggjs/cluster": "4.0.0-beta.21",
|
|
90
|
+
"@eggjs/cookies": "4.0.0-beta.21",
|
|
91
|
+
"@eggjs/core": "7.0.0-beta.21",
|
|
92
|
+
"@eggjs/extend2": "5.0.0-beta.21",
|
|
93
|
+
"@eggjs/i18n": "4.0.0-beta.21",
|
|
94
|
+
"@eggjs/jsonp": "4.0.0-beta.21",
|
|
95
|
+
"@eggjs/development": "5.0.0-beta.21",
|
|
96
|
+
"@eggjs/logrotator": "5.0.0-beta.21",
|
|
97
|
+
"@eggjs/onerror": "4.0.0-beta.21",
|
|
98
|
+
"@eggjs/schedule": "6.0.0-beta.21",
|
|
99
|
+
"@eggjs/security": "5.0.0-beta.21",
|
|
100
|
+
"@eggjs/multipart": "5.0.0-beta.21",
|
|
101
|
+
"@eggjs/session": "5.0.0-beta.21",
|
|
102
|
+
"@eggjs/static": "4.0.0-beta.21",
|
|
103
|
+
"@eggjs/utils": "5.0.0-beta.21",
|
|
104
|
+
"@eggjs/view": "4.0.0-beta.21",
|
|
105
|
+
"@eggjs/watcher": "5.0.0-beta.21"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
108
|
"@types/koa-bodyparser": "^4.3.12",
|
|
@@ -119,10 +119,10 @@
|
|
|
119
119
|
"spy": "^1.0.0",
|
|
120
120
|
"tsdown": "^0.15.4",
|
|
121
121
|
"typescript": "^5.9.3",
|
|
122
|
-
"@eggjs/koa": "3.1.0-beta.
|
|
123
|
-
"@eggjs/supertest": "9.0.0-beta.
|
|
124
|
-
"@eggjs/
|
|
125
|
-
"@eggjs/
|
|
122
|
+
"@eggjs/koa": "3.1.0-beta.21",
|
|
123
|
+
"@eggjs/supertest": "9.0.0-beta.21",
|
|
124
|
+
"@eggjs/mock": "7.0.0-beta.21",
|
|
125
|
+
"@eggjs/tracer": "4.0.0-beta.21"
|
|
126
126
|
},
|
|
127
127
|
"repository": {
|
|
128
128
|
"type": "git",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"scripts": {
|
|
138
138
|
"lint": "oxlint",
|
|
139
139
|
"typecheck": "tsc --noEmit",
|
|
140
|
-
"build": "tsdown",
|
|
140
|
+
"build": "tsdown && rimraf dist && tsc -b --clean && tsc && cp src/config/favicon.png dist/config/favicon.png",
|
|
141
141
|
"test": "vitest run"
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EggApplicationLoader } from "./EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/loader/AgentWorkerLoader.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Agent worker process loader
|
|
7
|
-
* @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
|
|
8
|
-
*/
|
|
9
|
-
declare class AgentWorkerLoader extends EggApplicationLoader {
|
|
10
|
-
/**
|
|
11
|
-
* loadPlugin first, then loadConfig
|
|
12
|
-
*/
|
|
13
|
-
loadConfig(): Promise<void>;
|
|
14
|
-
load(): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { AgentWorkerLoader };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { EggApplicationLoader } from "./EggApplicationLoader-CMe1VQt1.js";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/loader/AgentWorkerLoader.ts
|
|
4
|
-
/**
|
|
5
|
-
* Agent worker process loader
|
|
6
|
-
* @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
|
|
7
|
-
*/
|
|
8
|
-
var AgentWorkerLoader = class extends EggApplicationLoader {
|
|
9
|
-
/**
|
|
10
|
-
* loadPlugin first, then loadConfig
|
|
11
|
-
*/
|
|
12
|
-
async loadConfig() {
|
|
13
|
-
await this.loadPlugin();
|
|
14
|
-
await super.loadConfig();
|
|
15
|
-
}
|
|
16
|
-
async load() {
|
|
17
|
-
await this.loadAgentExtend();
|
|
18
|
-
await this.loadContextExtend();
|
|
19
|
-
await this.loadCustomAgent();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { AgentWorkerLoader };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { EggApplicationLoader } from "./EggApplicationLoader-CMe1VQt1.js";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/loader/AppWorkerLoader.ts
|
|
4
|
-
/**
|
|
5
|
-
* App worker process Loader, will load plugins
|
|
6
|
-
* @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
|
|
7
|
-
*/
|
|
8
|
-
var AppWorkerLoader = class extends EggApplicationLoader {
|
|
9
|
-
/**
|
|
10
|
-
* loadPlugin first, then loadConfig
|
|
11
|
-
* @since 1.0.0
|
|
12
|
-
*/
|
|
13
|
-
async loadConfig() {
|
|
14
|
-
await this.loadPlugin();
|
|
15
|
-
await super.loadConfig();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Load all directories in convention
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
async load() {
|
|
22
|
-
await this.loadApplicationExtend();
|
|
23
|
-
await this.loadRequestExtend();
|
|
24
|
-
await this.loadResponseExtend();
|
|
25
|
-
await this.loadContextExtend();
|
|
26
|
-
await this.loadHelperExtend();
|
|
27
|
-
await this.loadCustomLoader();
|
|
28
|
-
await this.loadCustomApp();
|
|
29
|
-
await this.loadService();
|
|
30
|
-
await this.loadMiddleware();
|
|
31
|
-
await this.loadController();
|
|
32
|
-
await this.loadRouter();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { AppWorkerLoader };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { EggApplicationLoader } from "./EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/loader/AppWorkerLoader.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* App worker process Loader, will load plugins
|
|
7
|
-
* @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
|
|
8
|
-
*/
|
|
9
|
-
declare class AppWorkerLoader extends EggApplicationLoader {
|
|
10
|
-
/**
|
|
11
|
-
* loadPlugin first, then loadConfig
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
*/
|
|
14
|
-
loadConfig(): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Load all directories in convention
|
|
17
|
-
* @since 1.0.0
|
|
18
|
-
*/
|
|
19
|
-
load(): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { AppWorkerLoader };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/lib/error/CookieLimitExceedError.ts
|
|
2
|
-
var CookieLimitExceedError = class extends Error {
|
|
3
|
-
key;
|
|
4
|
-
cookie;
|
|
5
|
-
constructor(key, cookie) {
|
|
6
|
-
super(`cookie ${key}'s length(${cookie.length}) exceed the limit(4093)`);
|
|
7
|
-
this.name = this.constructor.name;
|
|
8
|
-
this.key = key;
|
|
9
|
-
this.cookie = cookie;
|
|
10
|
-
Error.captureStackTrace(this, this.constructor);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { CookieLimitExceedError };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/core/messenger/IMessenger.d.ts
|
|
4
|
-
interface IMessenger extends EventEmitter {
|
|
5
|
-
/**
|
|
6
|
-
* Send message to all agent and app
|
|
7
|
-
* @param {String} action - message key
|
|
8
|
-
* @param {Object} data - message value
|
|
9
|
-
* @return {Messenger} this
|
|
10
|
-
*/
|
|
11
|
-
broadcast(action: string, data?: unknown): IMessenger;
|
|
12
|
-
/**
|
|
13
|
-
* send message to the specified process
|
|
14
|
-
* @param {String} workerId - the workerId of the receiver
|
|
15
|
-
* @param {String} action - message key
|
|
16
|
-
* @param {Object} data - message value
|
|
17
|
-
* @return {Messenger} this
|
|
18
|
-
*/
|
|
19
|
-
sendTo(workerId: string, action: string, data?: unknown): IMessenger;
|
|
20
|
-
/**
|
|
21
|
-
* send message to one app worker by random
|
|
22
|
-
* - if it's running in agent, it will send to one of app workers
|
|
23
|
-
* - if it's running in app, it will send to agent
|
|
24
|
-
* @param {String} action - message key
|
|
25
|
-
* @param {Object} data - message value
|
|
26
|
-
* @return {Messenger} this
|
|
27
|
-
*/
|
|
28
|
-
sendRandom(action: string, data?: unknown): IMessenger;
|
|
29
|
-
/**
|
|
30
|
-
* send message to app
|
|
31
|
-
* @param {String} action - message key
|
|
32
|
-
* @param {Object} data - message value
|
|
33
|
-
* @return {Messenger} this
|
|
34
|
-
*/
|
|
35
|
-
sendToApp(action: string, data?: unknown): IMessenger;
|
|
36
|
-
/**
|
|
37
|
-
* send message to agent
|
|
38
|
-
* @param {String} action - message key
|
|
39
|
-
* @param {Object} data - message value
|
|
40
|
-
* @return {Messenger} this
|
|
41
|
-
*/
|
|
42
|
-
sendToAgent(action: string, data?: unknown): IMessenger;
|
|
43
|
-
/**
|
|
44
|
-
* @param {String} action - message key
|
|
45
|
-
* @param {Object} data - message value
|
|
46
|
-
* @param {String} to - let master know how to send message
|
|
47
|
-
* @return {Messenger} this
|
|
48
|
-
*/
|
|
49
|
-
send(action: string, data: unknown, to?: string): IMessenger;
|
|
50
|
-
close(): void;
|
|
51
|
-
onMessage(message: any): void;
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { IMessenger };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/lib/error/MessageUnhandledRejectionError.d.ts
|
|
2
|
-
declare class MessageUnhandledRejectionError extends Error {
|
|
3
|
-
event: string | symbol;
|
|
4
|
-
args: any[];
|
|
5
|
-
constructor(err: Error, event: string | symbol, ...args: any[]);
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { MessageUnhandledRejectionError };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/lib/error/MessageUnhandledRejectionError.ts
|
|
2
|
-
var MessageUnhandledRejectionError = class extends Error {
|
|
3
|
-
event;
|
|
4
|
-
args;
|
|
5
|
-
constructor(err, event, ...args) {
|
|
6
|
-
super(`event: ${String(event)}, error: ${err.message}`, { cause: err });
|
|
7
|
-
this.name = this.constructor.name;
|
|
8
|
-
this.event = event;
|
|
9
|
-
this.args = args;
|
|
10
|
-
Error.captureStackTrace(this, this.constructor);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { MessageUnhandledRejectionError };
|
package/dist/agent-BfFWeJj4.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { EggApplicationCore } from "./egg-DVo5e_lr.js";
|
|
2
|
-
import { AgentWorkerLoader } from "./AgentWorkerLoader-D_hceBRW.js";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/agent.ts
|
|
5
|
-
const EGG_LOADER = Symbol.for("egg#loader");
|
|
6
|
-
/**
|
|
7
|
-
* Singleton instance in Agent Worker, extend {@link EggApplicationCore}
|
|
8
|
-
* @augments EggApplicationCore
|
|
9
|
-
*/
|
|
10
|
-
var Agent = class extends EggApplicationCore {
|
|
11
|
-
#agentAliveHandler;
|
|
12
|
-
/**
|
|
13
|
-
* @class
|
|
14
|
-
* @param {Object} options - see {@link EggApplicationCore}
|
|
15
|
-
*/
|
|
16
|
-
constructor(options) {
|
|
17
|
-
super({
|
|
18
|
-
...options,
|
|
19
|
-
type: "agent"
|
|
20
|
-
});
|
|
21
|
-
this.#agentAliveHandler = setInterval(() => {
|
|
22
|
-
this.coreLogger.info("[]");
|
|
23
|
-
}, 1440 * 60 * 1e3);
|
|
24
|
-
}
|
|
25
|
-
get [EGG_LOADER]() {
|
|
26
|
-
return AgentWorkerLoader;
|
|
27
|
-
}
|
|
28
|
-
_wrapMessenger() {
|
|
29
|
-
for (const methodName of [
|
|
30
|
-
"broadcast",
|
|
31
|
-
"sendTo",
|
|
32
|
-
"sendToApp",
|
|
33
|
-
"sendToAgent",
|
|
34
|
-
"sendRandom"
|
|
35
|
-
]) wrapMethod(methodName, this.messenger, this.coreLogger);
|
|
36
|
-
function wrapMethod(methodName, messenger, logger) {
|
|
37
|
-
const originMethod = messenger[methodName];
|
|
38
|
-
messenger[methodName] = function(...args) {
|
|
39
|
-
const stack = (/* @__PURE__ */ new Error()).stack.split("\n").slice(1).join("\n");
|
|
40
|
-
logger.warn("agent can't call %s before server started\n%s", methodName, stack);
|
|
41
|
-
originMethod.apply(this, args);
|
|
42
|
-
};
|
|
43
|
-
messenger.prependOnceListener("egg-ready", () => {
|
|
44
|
-
messenger[methodName] = originMethod;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async close() {
|
|
49
|
-
clearInterval(this.#agentAliveHandler);
|
|
50
|
-
await super.close();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
export { Agent };
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { CookieLimitExceedError } from "./CookieLimitExceedError-DLGakbeu.js";
|
|
2
|
-
import { EggApplicationCore } from "./egg-DVo5e_lr.js";
|
|
3
|
-
import { AppWorkerLoader } from "./AppWorkerLoader-CAtxJvGl.js";
|
|
4
|
-
import { Helper } from "./helper-B3PKMPXq.js";
|
|
5
|
-
import { utils } from "@eggjs/core";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { assign } from "utility";
|
|
8
|
-
import fs from "node:fs";
|
|
9
|
-
import http from "node:http";
|
|
10
|
-
import { isGeneratorFunction } from "is-type-of";
|
|
11
|
-
import { Socket } from "node:net";
|
|
12
|
-
import { graceful } from "graceful";
|
|
13
|
-
|
|
14
|
-
//#region src/lib/application.ts
|
|
15
|
-
const EGG_LOADER = Symbol.for("egg#loader");
|
|
16
|
-
const DEFAULT_BAD_REQUEST_HTML = `<html>
|
|
17
|
-
<head><title>400 Bad Request</title></head>
|
|
18
|
-
<body bgcolor="white">
|
|
19
|
-
<center><h1>400 Bad Request</h1></center>
|
|
20
|
-
<hr><center>❤</center>
|
|
21
|
-
</body>
|
|
22
|
-
</html>`;
|
|
23
|
-
const DEFAULT_BAD_REQUEST_RESPONSE = `HTTP/1.1 400 Bad Request\r\nContent-Length: ${Buffer.byteLength(DEFAULT_BAD_REQUEST_HTML)}\r\n\r\n${DEFAULT_BAD_REQUEST_HTML}`;
|
|
24
|
-
function escapeHeaderValue(value) {
|
|
25
|
-
return /[\r\n]/.test(value) ? value.replace(/[\r\n]+[ \t]*/g, "") : value;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Singleton instance in App Worker, extend {@link EggApplicationCore}
|
|
29
|
-
* @augments EggApplicationCore
|
|
30
|
-
*/
|
|
31
|
-
var Application = class extends EggApplicationCore {
|
|
32
|
-
server;
|
|
33
|
-
#locals = {};
|
|
34
|
-
/**
|
|
35
|
-
* reference to {@link Helper}
|
|
36
|
-
* @member {Helper} Application#Helper
|
|
37
|
-
*/
|
|
38
|
-
Helper = Helper;
|
|
39
|
-
/**
|
|
40
|
-
* @class
|
|
41
|
-
* @param {Object} options - see {@link EggApplicationCore}
|
|
42
|
-
*/
|
|
43
|
-
constructor(options) {
|
|
44
|
-
super({
|
|
45
|
-
...options,
|
|
46
|
-
type: "application"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async load() {
|
|
50
|
-
await super.load();
|
|
51
|
-
this.#warnConfusedConfig();
|
|
52
|
-
this.#bindEvents();
|
|
53
|
-
}
|
|
54
|
-
get [EGG_LOADER]() {
|
|
55
|
-
return AppWorkerLoader;
|
|
56
|
-
}
|
|
57
|
-
#responseRaw(socket, raw) {
|
|
58
|
-
if (!socket?.writable) return;
|
|
59
|
-
if (!raw) return socket.end(DEFAULT_BAD_REQUEST_RESPONSE);
|
|
60
|
-
const body = raw.body == null ? DEFAULT_BAD_REQUEST_HTML : raw.body;
|
|
61
|
-
const headers = raw.headers || {};
|
|
62
|
-
const status = raw.status || 400;
|
|
63
|
-
let responseHeaderLines = "";
|
|
64
|
-
const firstLine = `HTTP/1.1 ${status} ${http.STATUS_CODES[status] || "Unknown"}`;
|
|
65
|
-
for (const key of Object.keys(headers)) {
|
|
66
|
-
if (key.toLowerCase() === "content-length") {
|
|
67
|
-
delete headers[key];
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
responseHeaderLines += `${key}: ${escapeHeaderValue(headers[key])}\r\n`;
|
|
71
|
-
}
|
|
72
|
-
responseHeaderLines += `Content-Length: ${Buffer.byteLength(body)}\r\n`;
|
|
73
|
-
socket.end(`${firstLine}\r\n${responseHeaderLines}\r\n${body.toString()}`);
|
|
74
|
-
}
|
|
75
|
-
onClientError(err, socket) {
|
|
76
|
-
if (err.rawPacket) this.logger.warn("[egg:application] A client (%s:%d) error [%s] occurred: %s", socket.remoteAddress, socket.remotePort, err.code, err.message);
|
|
77
|
-
if (typeof this.config.onClientError === "function") utils.callFn(this.config.onClientError, [
|
|
78
|
-
err,
|
|
79
|
-
socket,
|
|
80
|
-
this
|
|
81
|
-
]).then((ret) => {
|
|
82
|
-
this.#responseRaw(socket, ret || {});
|
|
83
|
-
}).catch((err$1) => {
|
|
84
|
-
this.logger.error(err$1);
|
|
85
|
-
this.#responseRaw(socket);
|
|
86
|
-
});
|
|
87
|
-
else this.#responseRaw(socket);
|
|
88
|
-
}
|
|
89
|
-
onServer(server) {
|
|
90
|
-
this.server = server;
|
|
91
|
-
const serverGracefulIgnoreCode = this.config.serverGracefulIgnoreCode || [];
|
|
92
|
-
graceful({
|
|
93
|
-
server: [server],
|
|
94
|
-
error: (err, throwErrorCount) => {
|
|
95
|
-
const originMessage = err.message;
|
|
96
|
-
if (originMessage) Object.defineProperty(err, "message", {
|
|
97
|
-
get() {
|
|
98
|
-
return `${originMessage} (uncaughtException throw ${throwErrorCount} times on pid: ${process.pid})`;
|
|
99
|
-
},
|
|
100
|
-
configurable: true,
|
|
101
|
-
enumerable: false
|
|
102
|
-
});
|
|
103
|
-
this.coreLogger.error(err);
|
|
104
|
-
},
|
|
105
|
-
ignoreCode: serverGracefulIgnoreCode
|
|
106
|
-
});
|
|
107
|
-
server.on("clientError", (err, socket) => this.onClientError(err, socket));
|
|
108
|
-
if (typeof this.config.serverTimeout === "number") server.setTimeout(this.config.serverTimeout);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* global locals for view
|
|
112
|
-
* @member {Object} Application#locals
|
|
113
|
-
* @see Context#locals
|
|
114
|
-
*/
|
|
115
|
-
get locals() {
|
|
116
|
-
return this.#locals;
|
|
117
|
-
}
|
|
118
|
-
set locals(val) {
|
|
119
|
-
assign(this.#locals, val);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* save routers to `run/router.json`
|
|
123
|
-
* @private
|
|
124
|
-
*/
|
|
125
|
-
dumpConfig() {
|
|
126
|
-
super.dumpConfig();
|
|
127
|
-
const rundir = this.config.rundir;
|
|
128
|
-
const FULLPATH = this.loader.FileLoader.FULLPATH;
|
|
129
|
-
try {
|
|
130
|
-
const dumpRouterFile = path.join(rundir, "router.json");
|
|
131
|
-
const routers = [];
|
|
132
|
-
for (const layer of this.router.stack) routers.push({
|
|
133
|
-
name: layer.name,
|
|
134
|
-
methods: layer.methods,
|
|
135
|
-
paramNames: layer.paramNames,
|
|
136
|
-
path: layer.path,
|
|
137
|
-
regexp: layer.regexp.toString(),
|
|
138
|
-
stack: layer.stack.map((stack) => stack[FULLPATH] || stack._name || stack.name || "anonymous")
|
|
139
|
-
});
|
|
140
|
-
fs.writeFileSync(dumpRouterFile, JSON.stringify(routers, null, 2));
|
|
141
|
-
} catch (err) {
|
|
142
|
-
this.coreLogger.warn(`dumpConfig router.json error: ${err.message}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Run async function in the background
|
|
147
|
-
* @see Context#runInBackground
|
|
148
|
-
* @param {Function} scope - the first args is an anonymous ctx
|
|
149
|
-
*/
|
|
150
|
-
runInBackground(scope, req) {
|
|
151
|
-
const ctx = this.createAnonymousContext(req);
|
|
152
|
-
if (!scope.name) Reflect.set(scope, "_name", utils.getCalleeFromStack(true));
|
|
153
|
-
this.ctxStorage.run(ctx, () => {
|
|
154
|
-
return ctx.runInBackground(scope);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* secret key for Application
|
|
159
|
-
* @member {String} Application#keys
|
|
160
|
-
*/
|
|
161
|
-
get keys() {
|
|
162
|
-
if (!this._keys) {
|
|
163
|
-
if (!this.config.keys) {
|
|
164
|
-
if (this.config.env === "local" || this.config.env === "unittest") {
|
|
165
|
-
const configPath = path.join(this.config.baseDir, "config/config.default.js");
|
|
166
|
-
console.error("Cookie need secret key to sign and encrypt.");
|
|
167
|
-
console.error("Please add `config.keys` in %s", configPath);
|
|
168
|
-
}
|
|
169
|
-
throw new Error("Please set config.keys first");
|
|
170
|
-
}
|
|
171
|
-
this._keys = this.config.keys.split(",").map((s) => s.trim());
|
|
172
|
-
}
|
|
173
|
-
return this._keys;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* @deprecated keep compatible with egg 3.x
|
|
177
|
-
*/
|
|
178
|
-
toAsyncFunction(fn) {
|
|
179
|
-
if (isGeneratorFunction(fn)) throw new Error("Generator function is not supported");
|
|
180
|
-
return fn;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* bind app's events
|
|
184
|
-
*
|
|
185
|
-
* @private
|
|
186
|
-
*/
|
|
187
|
-
#bindEvents() {
|
|
188
|
-
this.on("cookieLimitExceed", ({ name, value, ctx }) => {
|
|
189
|
-
const err = new CookieLimitExceedError(name, value);
|
|
190
|
-
ctx.coreLogger.error(err);
|
|
191
|
-
});
|
|
192
|
-
this.once("server", (server) => this.onServer(server));
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* warn when confused configurations are present
|
|
196
|
-
*
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
#warnConfusedConfig() {
|
|
200
|
-
const confusedConfigurations = this.config.confusedConfigurations;
|
|
201
|
-
Object.keys(confusedConfigurations).forEach((key) => {
|
|
202
|
-
if (this.config[key] !== void 0) this.logger.warn("[egg:application] Unexpected config key `%o` exists, Please use `%o` instead.", key, confusedConfigurations[key]);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
//#endregion
|
|
208
|
-
export { Application };
|
package/dist/base-KLVtlzUD.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EggApplicationCore } from "./base_hook_class-R8A8gm1s.js";
|
|
2
|
-
import { EventEmitter, captureRejectionSymbol } from "node:events";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/core/messenger/base.d.ts
|
|
5
|
-
declare class BaseMessenger extends EventEmitter {
|
|
6
|
-
protected readonly egg: EggApplicationCore;
|
|
7
|
-
constructor(egg: EggApplicationCore);
|
|
8
|
-
[captureRejectionSymbol](err: Error, event: string | symbol, ...args: any[]): void;
|
|
9
|
-
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { BaseMessenger };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BaseContextLogger } from "./base_context_logger-CZU59PGA.js";
|
|
2
|
-
import { BaseContextClass } from "@eggjs/core";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/core/base_context_class.ts
|
|
5
|
-
/**
|
|
6
|
-
* BaseContextClass is a base class that can be extended,
|
|
7
|
-
* it's instantiated in context level,
|
|
8
|
-
* {@link Helper}, {@link Service} is extending it.
|
|
9
|
-
*/
|
|
10
|
-
var BaseContextClass$1 = class extends BaseContextClass {
|
|
11
|
-
#logger;
|
|
12
|
-
get logger() {
|
|
13
|
-
if (!this.#logger) this.#logger = new BaseContextLogger(this.ctx, this.pathName);
|
|
14
|
-
return this.#logger;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { BaseContextClass$1 as BaseContextClass };
|