egg 4.1.0-beta.11 → 4.1.0-beta.14

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.
@@ -25,7 +25,7 @@ declare class Response extends Response$1 {
25
25
  */
26
26
  set realStatus(status: number);
27
27
  }
28
- declare module '@eggjs/core' {
28
+ declare module 'egg' {
29
29
  interface Response {
30
30
  get realStatus(): number;
31
31
  set realStatus(status: number);
@@ -1,4 +1,4 @@
1
- import { EggAppInfo, PartialEggConfig } from "../lib/types.js";
1
+ import { EggConfigFactory } from "../lib/types.js";
2
2
 
3
3
  //#region src/config/config.default.d.ts
4
4
 
@@ -7,6 +7,6 @@ import { EggAppInfo, PartialEggConfig } from "../lib/types.js";
7
7
  * @class Config
8
8
  * @since 1.0.0
9
9
  */
10
- declare const _default: (appInfo: EggAppInfo) => PartialEggConfig;
10
+ declare const _default: EggConfigFactory;
11
11
  //#endregion
12
12
  export { _default as default };
@@ -1,4 +1,4 @@
1
- import { defineConfig } from "../lib/types.js";
1
+ import { defineConfigFactory } from "../lib/types.js";
2
2
  import "../index.js";
3
3
  import path from "node:path";
4
4
  import { pathToFileURL } from "node:url";
@@ -9,7 +9,7 @@ import { pathToFileURL } from "node:url";
9
9
  * @class Config
10
10
  * @since 1.0.0
11
11
  */
12
- var config_default_default = defineConfig((appInfo) => {
12
+ var config_default_default = defineConfigFactory((appInfo) => {
13
13
  const config = {
14
14
  env: appInfo.env,
15
15
  name: appInfo.name,
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import Helper from "./app/extend/helper.js";
5
5
  import { Application } from "./lib/application.js";
6
6
  import { EggContextHttpClient as HttpClient, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse } from "./lib/core/httpclient.js";
7
7
  import Context from "./app/extend/context.js";
8
- import { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggConfigFactory, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, PartialDeep, PartialEggConfig, PowerPartial, RequestObjectBody, defineConfig } from "./lib/types.js";
8
+ import { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggConfigFactory, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, PartialDeep, PartialEggConfig, PowerPartial, RequestObjectBody, defineConfig, defineConfigFactory } from "./lib/types.js";
9
9
  import { ContextHttpClient } from "./lib/core/context_httpclient.js";
10
10
  import { EggApplicationCore, EggApplicationCoreOptions, EggContext, IBoot as ILifecycleBoot, MiddlewareFunc, Next, Request, Response, Router } from "./lib/egg.js";
11
11
  import { BaseContextClass } from "./lib/core/base_context_class.js";
@@ -16,4 +16,4 @@ import { BaseHookClass } from "./lib/core/base_hook_class.js";
16
16
  import { Singleton, SingletonCreateMethod, SingletonOptions } from "@eggjs/core";
17
17
  import { EggLogger, LoggerLevel } from "egg-logger";
18
18
  export * from "@eggjs/cluster";
19
- export { Agent, AgentWorkerLoader, AppWorkerLoader, Application, BaseContextClass, BaseHookClass as Boot, ClientErrorResponse, Context, ContextHttpClient, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggApplicationCore, EggApplicationCoreOptions, EggConfigFactory, EggContext, HttpClient as EggContextHttpClient, HttpClient as EggHttpClient, HttpClient, EggEnvType, type EggLogger, EggLoggerConfig, EggPlugin, EggPluginItem, Helper, type Helper as IHelper, HttpClientConfig, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse, ILifecycleBoot as IBoot, ILifecycleBoot, IEggPluginItem, type LoggerLevel, MessageUnhandledRejectionError, MiddlewareFunc, Next, PartialDeep, PartialEggConfig, PowerPartial, Request, RequestObjectBody, Response, Router, type SingleModeAgent, type SingleModeApplication, Singleton, type SingletonCreateMethod, type SingletonOptions, StartEggOptions, defineConfig, startEgg as start, startEgg };
19
+ export { Agent, AgentWorkerLoader, AppWorkerLoader, Application, BaseContextClass, BaseHookClass as Boot, ClientErrorResponse, Context, ContextHttpClient, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggApplicationCore, EggApplicationCoreOptions, EggConfigFactory, EggContext, HttpClient as EggContextHttpClient, HttpClient as EggHttpClient, HttpClient, EggEnvType, type EggLogger, EggLoggerConfig, EggPlugin, EggPluginItem, Helper, type Helper as IHelper, HttpClientConfig, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse, ILifecycleBoot as IBoot, ILifecycleBoot, IEggPluginItem, type LoggerLevel, MessageUnhandledRejectionError, MiddlewareFunc, Next, PartialDeep, PartialEggConfig, PowerPartial, Request, RequestObjectBody, Response, Router, type SingleModeAgent, type SingleModeApplication, Singleton, type SingletonCreateMethod, type SingletonOptions, StartEggOptions, defineConfig, defineConfigFactory, startEgg as start, startEgg };
package/dist/index.js CHANGED
@@ -12,10 +12,10 @@ import "./lib/loader/index.js";
12
12
  import { Agent } from "./lib/agent.js";
13
13
  import Helper from "./app/extend/helper.js";
14
14
  import { Application } from "./lib/application.js";
15
- import { defineConfig } from "./lib/types.js";
15
+ import { defineConfig, defineConfigFactory } from "./lib/types.js";
16
16
  import { startEgg } from "./lib/start.js";
17
17
  import { Singleton } from "@eggjs/core";
18
18
 
19
19
  export * from "@eggjs/cluster"
20
20
 
21
- export { Agent, AgentWorkerLoader, AppWorkerLoader, Application, BaseContextClass, BaseHookClass as Boot, Context, ContextHttpClient, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, EggApplicationCore, Helper, HttpClient, MessageUnhandledRejectionError, Request, Response, Router, Singleton, defineConfig, startEgg as start, startEgg };
21
+ export { Agent, AgentWorkerLoader, AppWorkerLoader, Application, BaseContextClass, BaseHookClass as Boot, Context, ContextHttpClient, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, EggApplicationCore, Helper, HttpClient, MessageUnhandledRejectionError, Request, Response, Router, Singleton, defineConfig, defineConfigFactory, startEgg as start, startEgg };
@@ -8,6 +8,7 @@ import { BaseMessenger } from "./base.js";
8
8
  * Communication between app worker and agent worker by IPC channel
9
9
  */
10
10
  declare class Messenger extends BaseMessenger implements IMessenger {
11
+ #private;
11
12
  readonly pid: string;
12
13
  opids: string[];
13
14
  constructor(egg: EggApplicationCore);
@@ -19,7 +19,8 @@ var Messenger = class extends BaseMessenger {
19
19
  this.opids = workerIds.map((workerId) => String(workerId));
20
20
  });
21
21
  this.onMessage = this.onMessage.bind(this);
22
- process.on("message", this.onMessage);
22
+ if (this.egg.options.mode === "all-in-one-process") process.on("sendmessage-to-self", this.onMessage);
23
+ else process.on("message", this.onMessage);
23
24
  if (!workerThreads.isMainThread) workerThreads.parentPort.on("message", this.onMessage);
24
25
  }
25
26
  /**
@@ -43,12 +44,13 @@ var Messenger = class extends BaseMessenger {
43
44
  */
44
45
  sendTo(workerId, action, data) {
45
46
  debug("[%s:%s] send %s with %j to workerId:%s", this.egg.type, this.pid, action, data, workerId);
46
- sendmessage(process, {
47
+ const message = {
47
48
  action,
48
49
  data,
49
50
  receiverPid: String(workerId),
50
51
  receiverWorkerId: String(workerId)
51
- });
52
+ };
53
+ this.#sendMessage(message);
52
54
  return this;
53
55
  }
54
56
  /**
@@ -98,13 +100,19 @@ var Messenger = class extends BaseMessenger {
98
100
  * @return {Messenger} this
99
101
  */
100
102
  send(action, data, to) {
101
- sendmessage(process, {
103
+ debug("send message %s with %j to %s", action, data, to);
104
+ this.#sendMessage({
102
105
  action,
103
106
  data,
104
107
  to
105
108
  });
106
109
  return this;
107
110
  }
111
+ #sendMessage(message) {
112
+ debug("[%s:%s] send message %j, mode: %s", this.egg.type, this.pid, message, this.egg.options.mode);
113
+ if (this.egg.options.mode === "all-in-one-process") process.emit("sendmessage-to-self", message);
114
+ else sendmessage(process, message);
115
+ }
108
116
  onMessage(message) {
109
117
  if (typeof message?.action === "string") {
110
118
  debug("[%s:%s] got message %s with %j, receiverWorkerId: %s", this.egg.type, this.pid, message.action, message.data, message.receiverWorkerId ?? message.receiverPid);
package/dist/lib/egg.d.ts CHANGED
@@ -17,7 +17,7 @@ import { Cookies } from "@eggjs/cookies";
17
17
  //#region src/lib/egg.d.ts
18
18
  declare const EGG_PATH: unique symbol;
19
19
  interface EggApplicationCoreOptions extends Omit<EggCoreOptions, 'baseDir'> {
20
- mode?: 'cluster' | 'single';
20
+ mode?: 'cluster' | 'single' | 'all-in-one-process';
21
21
  clusterPort?: number;
22
22
  baseDir?: string;
23
23
  }
@@ -7,18 +7,6 @@ import { EggAppConfig as EggAppConfig$1, EggAppInfo, FileLoaderOptions } from "@
7
7
  import { EggLoggerOptions, EggLoggersOptions } from "egg-logger";
8
8
  import { RequestOptions } from "urllib";
9
9
  import { Socket } from "node:net";
10
- import "@eggjs/watcher";
11
- import "@eggjs/development";
12
- import "@eggjs/jsonp";
13
- import "@eggjs/i18n";
14
- import "@eggjs/static";
15
- import "@eggjs/security";
16
- import "@eggjs/schedule";
17
- import "@eggjs/session";
18
- import "@eggjs/onerror";
19
- import "@eggjs/logrotator";
20
- import "@eggjs/multipart";
21
- import "@eggjs/view";
22
10
  import { PartialDeep } from "type-fest";
23
11
 
24
12
  //#region src/lib/types.d.ts
@@ -93,20 +81,27 @@ type EggConfigFactory = (appInfo: EggAppInfo) => PartialEggConfig;
93
81
  /**
94
82
  * Define configuration with type safety
95
83
  * @example
84
+ * ```ts
96
85
  * import { defineConfig } from 'egg';
97
86
  *
98
87
  * export default defineConfig({
99
88
  * keys: 'my-keys',
100
89
  * middleware: []
101
90
  * });
102
- *
103
- * // or with function
104
- * export default defineConfig((appInfo) => ({
91
+ * ```
92
+ */
93
+ declare function defineConfig(config: PartialEggConfig): PartialEggConfig;
94
+ /**
95
+ * Define configuration factory function with type safety
96
+ * @example
97
+ * ```ts
98
+ * export default defineConfigFactory((appInfo): PartialEggConfig => ({
105
99
  * keys: appInfo.name + '_keys',
106
100
  * middleware: []
107
101
  * }));
102
+ * ```
108
103
  */
109
- declare function defineConfig<T extends PartialEggConfig | EggConfigFactory>(config: T): T;
104
+ declare function defineConfigFactory(configFactory: EggConfigFactory): EggConfigFactory;
110
105
  interface EggAppConfig extends EggAppConfig$1 {
111
106
  workerStartTimeout: number;
112
107
  baseDir: string;
@@ -284,4 +279,4 @@ interface EggPlugin {
284
279
  view?: EggPluginItem;
285
280
  }
286
281
  //#endregion
287
- export { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, type EggAppInfo, EggConfigFactory, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, type PartialDeep, PartialEggConfig, PowerPartial, RequestObjectBody, defineConfig };
282
+ export { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, type EggAppInfo, EggConfigFactory, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, type PartialDeep, PartialEggConfig, PowerPartial, RequestObjectBody, defineConfig, defineConfigFactory };
package/dist/lib/types.js CHANGED
@@ -1,36 +1,34 @@
1
- import "@eggjs/watcher";
2
- import "@eggjs/development";
3
- import "@eggjs/jsonp";
4
- import "@eggjs/i18n";
5
- import "@eggjs/static";
6
- import "@eggjs/security";
7
- import "@eggjs/schedule";
8
- import "@eggjs/session";
9
- import "@eggjs/onerror";
10
- import "@eggjs/logrotator";
11
- import "@eggjs/multipart";
12
- import "@eggjs/view";
1
+ import "./types.plugin.js";
13
2
 
14
3
  //#region src/lib/types.ts
15
4
  /**
16
5
  * Define configuration with type safety
17
6
  * @example
7
+ * ```ts
18
8
  * import { defineConfig } from 'egg';
19
9
  *
20
10
  * export default defineConfig({
21
11
  * keys: 'my-keys',
22
12
  * middleware: []
23
13
  * });
24
- *
25
- * // or with function
26
- * export default defineConfig((appInfo) => ({
14
+ * ```
15
+ */
16
+ function defineConfig(config) {
17
+ return config;
18
+ }
19
+ /**
20
+ * Define configuration factory function with type safety
21
+ * @example
22
+ * ```ts
23
+ * export default defineConfigFactory((appInfo): PartialEggConfig => ({
27
24
  * keys: appInfo.name + '_keys',
28
25
  * middleware: []
29
26
  * }));
27
+ * ```
30
28
  */
31
- function defineConfig(config) {
32
- return config;
29
+ function defineConfigFactory(configFactory) {
30
+ return configFactory;
33
31
  }
34
32
 
35
33
  //#endregion
36
- export { defineConfig };
34
+ export { defineConfig, defineConfigFactory };
@@ -0,0 +1,4 @@
1
+ import "@eggjs/i18n";
2
+ import "@eggjs/multipart";
3
+ import "@eggjs/view";
4
+ import "@eggjs/watcher";
@@ -0,0 +1,6 @@
1
+ import "@eggjs/i18n";
2
+ import "@eggjs/multipart";
3
+ import "@eggjs/view";
4
+ import "@eggjs/watcher";
5
+
6
+ export { };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "4.1.0-beta.11",
3
+ "version": "4.1.0-beta.14",
4
4
  "engines": {
5
- "node": ">= 20.19.0"
5
+ "node": ">=22.18.0"
6
6
  },
7
7
  "publishConfig": {
8
8
  "access": "public",
@@ -52,6 +52,7 @@
52
52
  "./lib/loader/EggApplicationLoader": "./dist/lib/loader/EggApplicationLoader.js",
53
53
  "./lib/start": "./dist/lib/start.js",
54
54
  "./lib/types": "./dist/lib/types.js",
55
+ "./lib/types.plugin": "./dist/lib/types.plugin.js",
55
56
  "./lib/utils": "./dist/lib/utils.js",
56
57
  "./urllib": "./dist/urllib.js",
57
58
  "./package.json": "./package.json"
@@ -71,20 +72,11 @@
71
72
  "egg"
72
73
  ],
73
74
  "dependencies": {
74
- "@eggjs/cookies": "^3.1.0",
75
75
  "@eggjs/i18n": "^3.0.1",
76
- "@eggjs/jsonp": "^3.0.0",
77
- "@eggjs/logrotator": "^4.0.0",
78
76
  "@eggjs/multipart": "^4.0.0",
79
- "@eggjs/onerror": "^3.0.0",
80
- "@eggjs/schedule": "^5.0.2",
81
- "@eggjs/security": "^4.0.0",
82
- "@eggjs/session": "^4.0.1",
83
- "@eggjs/static": "^3.0.0",
84
77
  "@eggjs/view": "^3.0.1",
85
78
  "circular-json-for-egg": "^1.0.0",
86
79
  "cluster-client": "^3.7.0",
87
- "egg-errors": "^2.3.2",
88
80
  "egg-logger": "^3.5.0",
89
81
  "graceful": "^2.0.0",
90
82
  "humanize-ms": "^2.0.0",
@@ -95,18 +87,25 @@
95
87
  "performance-ms": "^1.1.0",
96
88
  "sendmessage": "^3.0.1",
97
89
  "type-fest": "^5.0.1",
98
- "urllib": "^4.6.11",
90
+ "urllib": "^4.8.2",
99
91
  "utility": "^2.5.0",
100
- "@eggjs/cluster": "3.1.0-beta.11",
101
- "@eggjs/core": "6.6.0-beta.11",
102
- "@eggjs/development": "4.1.0-beta.11",
103
- "@eggjs/extend2": "4.1.0-beta.11",
104
- "@eggjs/utils": "4.5.0-beta.11",
105
- "@eggjs/watcher": "4.1.0-beta.11"
92
+ "@eggjs/cookies": "4.0.0-beta.14",
93
+ "@eggjs/core": "7.0.0-beta.14",
94
+ "@eggjs/cluster": "4.0.0-beta.14",
95
+ "@eggjs/extend2": "5.0.0-beta.14",
96
+ "@eggjs/jsonp": "4.0.0-beta.14",
97
+ "@eggjs/logrotator": "5.0.0-beta.14",
98
+ "@eggjs/schedule": "6.0.0-beta.14",
99
+ "@eggjs/onerror": "4.0.0-beta.14",
100
+ "@eggjs/security": "5.0.0-beta.14",
101
+ "@eggjs/session": "5.0.0-beta.14",
102
+ "@eggjs/static": "4.0.0-beta.14",
103
+ "@eggjs/utils": "5.0.0-beta.14",
104
+ "@eggjs/development": "5.0.0-beta.14",
105
+ "@eggjs/watcher": "5.0.0-beta.14"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@types/koa-bodyparser": "^4.3.12",
109
- "@types/node": "24.5.2",
110
109
  "address": "2",
111
110
  "assert-file": "1",
112
111
  "coffee": "5",
@@ -116,16 +115,15 @@
116
115
  "formstream": "^1.5.1",
117
116
  "koa-static": "^5.0.0",
118
117
  "mm": "^4.0.2",
119
- "pedding": "^2.0.1",
120
118
  "runscript": "^2.0.1",
121
119
  "sdk-base": "^5.0.1",
122
120
  "spy": "^1.0.0",
123
121
  "tsd": "^0.33.0",
124
122
  "tsdown": "^0.15.4",
125
123
  "typescript": "5.9.2",
126
- "@eggjs/koa": "3.1.0-beta.11",
127
- "@eggjs/mock": "6.1.0-beta.11",
128
- "@eggjs/supertest": "8.3.0-beta.11"
124
+ "@eggjs/koa": "3.1.0-beta.14",
125
+ "@eggjs/mock": "7.0.0-beta.14",
126
+ "@eggjs/supertest": "9.0.0-beta.14"
129
127
  },
130
128
  "repository": {
131
129
  "type": "git",