ee-core 4.1.4 → 4.1.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.
Files changed (131) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -65
  3. package/app/application.d.ts +5 -5
  4. package/app/application.js +30 -30
  5. package/app/boot.d.ts +5 -5
  6. package/app/boot.js +80 -80
  7. package/app/dir.d.ts +1 -1
  8. package/app/dir.js +26 -26
  9. package/app/events.d.ts +14 -14
  10. package/app/events.js +55 -55
  11. package/app/index.d.ts +2 -2
  12. package/app/index.js +6 -6
  13. package/config/config_loader.d.ts +13 -13
  14. package/config/config_loader.js +65 -65
  15. package/config/default_config.d.ts +95 -95
  16. package/config/default_config.js +111 -111
  17. package/config/index.d.ts +28 -28
  18. package/config/index.js +24 -24
  19. package/const/channel.d.ts +16 -16
  20. package/const/channel.js +27 -27
  21. package/controller/controller_loader.d.ts +9 -9
  22. package/controller/controller_loader.js +77 -77
  23. package/controller/index.d.ts +2 -2
  24. package/controller/index.js +24 -24
  25. package/core/index.d.ts +2 -2
  26. package/core/index.js +11 -11
  27. package/core/loader/file_loader.d.ts +66 -66
  28. package/core/loader/file_loader.js +211 -211
  29. package/core/utils/index.d.ts +12 -12
  30. package/core/utils/index.js +83 -83
  31. package/core/utils/timing.d.ts +22 -22
  32. package/core/utils/timing.js +78 -78
  33. package/cross/cross.d.ts +19 -19
  34. package/cross/cross.js +152 -151
  35. package/cross/crossProcess.d.ts +29 -29
  36. package/cross/crossProcess.js +172 -172
  37. package/cross/index.d.ts +2 -2
  38. package/cross/index.js +8 -8
  39. package/electron/app/index.d.ts +5 -5
  40. package/electron/app/index.js +48 -48
  41. package/electron/index.d.ts +3 -3
  42. package/electron/index.js +15 -15
  43. package/electron/window/index.d.ts +6 -6
  44. package/electron/window/index.js +268 -268
  45. package/exception/index.d.ts +9 -9
  46. package/exception/index.js +100 -100
  47. package/html/boot.html +98 -98
  48. package/html/cross-failure.html +28 -28
  49. package/html/failure.html +28 -28
  50. package/html/index.d.ts +1 -1
  51. package/html/index.js +10 -10
  52. package/index.d.ts +2 -2
  53. package/index.js +6 -6
  54. package/jobs/child/app.d.ts +1 -1
  55. package/jobs/child/app.js +69 -69
  56. package/jobs/child/index.d.ts +13 -13
  57. package/jobs/child/index.js +85 -85
  58. package/jobs/child/jobProcess.d.ts +16 -16
  59. package/jobs/child/jobProcess.js +133 -133
  60. package/jobs/child-pool/index.d.ts +26 -26
  61. package/jobs/child-pool/index.js +190 -190
  62. package/jobs/index.d.ts +3 -3
  63. package/jobs/index.js +6 -6
  64. package/jobs/load-balancer/algorithm/index.d.ts +4 -4
  65. package/jobs/load-balancer/algorithm/index.js +11 -11
  66. package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
  67. package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
  68. package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
  69. package/jobs/load-balancer/algorithm/polling.js +11 -11
  70. package/jobs/load-balancer/algorithm/random.d.ts +2 -2
  71. package/jobs/load-balancer/algorithm/random.js +9 -9
  72. package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
  73. package/jobs/load-balancer/algorithm/specify.js +14 -14
  74. package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
  75. package/jobs/load-balancer/algorithm/weights.js +21 -21
  76. package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
  77. package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
  78. package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
  79. package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
  80. package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
  81. package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
  82. package/jobs/load-balancer/consts.d.ts +8 -8
  83. package/jobs/load-balancer/consts.js +9 -9
  84. package/jobs/load-balancer/index.d.ts +96 -96
  85. package/jobs/load-balancer/index.js +201 -201
  86. package/jobs/load-balancer/scheduler.d.ts +16 -16
  87. package/jobs/load-balancer/scheduler.js +31 -31
  88. package/loader/index.d.ts +9 -9
  89. package/loader/index.js +99 -99
  90. package/log/index.d.ts +5 -5
  91. package/log/index.js +85 -85
  92. package/log/logger.d.ts +1 -1
  93. package/log/logger.js +94 -94
  94. package/message/childMessage.d.ts +10 -10
  95. package/message/childMessage.js +43 -43
  96. package/message/index.d.ts +3 -3
  97. package/message/index.js +9 -9
  98. package/package.json +42 -42
  99. package/ps/index.d.ts +39 -39
  100. package/ps/index.js +294 -294
  101. package/socket/httpServer.d.ts +8 -8
  102. package/socket/httpServer.js +199 -199
  103. package/socket/index.d.ts +10 -10
  104. package/socket/index.js +64 -64
  105. package/socket/ipcServer.d.ts +9 -9
  106. package/socket/ipcServer.js +105 -105
  107. package/socket/socketServer.d.ts +10 -10
  108. package/socket/socketServer.js +81 -81
  109. package/storage/index.d.ts +4 -4
  110. package/storage/index.js +6 -6
  111. package/storage/sqliteStorage.d.ts +16 -16
  112. package/storage/sqliteStorage.js +123 -123
  113. package/tsconfig.json +13 -13
  114. package/utils/extend.d.ts +2 -2
  115. package/utils/extend.js +77 -77
  116. package/utils/helper.d.ts +14 -14
  117. package/utils/helper.js +206 -206
  118. package/utils/index.d.ts +11 -10
  119. package/utils/index.js +198 -167
  120. package/utils/ip.d.ts +2 -2
  121. package/utils/ip.js +221 -221
  122. package/utils/is.d.ts +14 -14
  123. package/utils/is.js +111 -111
  124. package/utils/json.d.ts +5 -5
  125. package/utils/json.js +79 -79
  126. package/utils/pargv.d.ts +3 -3
  127. package/utils/pargv.js +267 -267
  128. package/utils/port/index.d.ts +1 -1
  129. package/utils/port/index.js +125 -125
  130. package/utils/wrap.d.ts +4 -4
  131. package/utils/wrap.js +40 -40
package/ps/index.js CHANGED
@@ -1,295 +1,295 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const is = require('../utils/is');
5
-
6
- // 当前进程的所有env
7
- function allEnv() {
8
- return process.env;
9
- }
10
-
11
- // 当前环境 - local | prod
12
- function env() {
13
- return process.env.EE_ENV;
14
- }
15
-
16
- // 是否生产环境
17
- function isProd() {
18
- return (process.env.EE_ENV === 'prod');
19
- }
20
-
21
- // 是否为开发环境
22
- function isDev() {
23
- if (process.env.EE_ENV === 'dev' || process.env.EE_ENV === 'local') {
24
- return true;
25
- }
26
-
27
- return false;
28
- };
29
-
30
- // 是否为渲染进程
31
- function isRenderer() {
32
- return (typeof process === 'undefined' ||
33
- !process ||
34
- process.type === 'renderer');
35
- };
36
-
37
- // 是否为主进程
38
- function isMain() {
39
- return ( typeof process !== 'undefined' &&
40
- process.type === 'browser');
41
- };
42
-
43
- // 是否为node子进程
44
- function isForkedChild() {
45
- return (Number(process.env.ELECTRON_RUN_AS_NODE) === 1);
46
- };
47
-
48
- // 当前进程类型
49
- function processType() {
50
- let type = '';
51
- if (isMain()) {
52
- type = 'browser';
53
- } else if (isRenderer()) {
54
- type = 'renderer';
55
- } else if (isForkedChild()) {
56
- type = 'child';
57
- }
58
-
59
- return type;
60
- };
61
-
62
- // app name
63
- function appName() {
64
- return process.env.EE_APP_NAME;
65
- }
66
-
67
- // app version
68
- function appVersion() {
69
- return process.env.EE_APP_VERSION;
70
- }
71
-
72
- // 获取数据存储路径
73
- function getDataDir() {
74
- const base = isDev() ? getBaseDir() : getUserHomeHiddenAppDir();
75
- const dataDir = path.join(base, 'data');
76
- return dataDir;
77
- }
78
-
79
- // 获取日志存储路径
80
- function getLogDir() {
81
- const base = isDev() ? getBaseDir() : getUserHomeHiddenAppDir();
82
- const dir = path.join(base, 'logs');
83
- return dir;
84
- }
85
-
86
- // 获取bundle文件路径
87
- function getBundleDir(basePath) {
88
- const base = basePath || process.cwd();
89
- const dir = path.join(base, 'public', 'electron');
90
- return dir;
91
- }
92
-
93
- // 获取electron 源码文件路径
94
- function getElectronCodeDir(basePath) {
95
- const base = basePath || process.cwd();
96
- const dir = path.join(base, 'electron');
97
- return dir;
98
- }
99
-
100
- // 获取frontend 源码文件路径
101
- function getFrontendCodeDir(basePath) {
102
- const base = basePath || process.cwd();
103
- const dir = path.join(base, 'frontend');
104
- return dir;
105
- }
106
-
107
- // 获取base目录
108
- function getBaseDir() {
109
- return process.env.EE_BASE_DIR;
110
- }
111
-
112
- // 获取electron目录
113
- function getElectronDir() {
114
- return process.env.EE_ELECTRON_DIR;
115
- }
116
-
117
- // 获取public目录
118
- function getPublicDir() {
119
- const dir = path.join(getBaseDir(), "public");
120
- return dir;
121
- }
122
-
123
- // 获取 额外资源目录
124
- function getExtraResourcesDir() {
125
- const execDir = getExecDir();
126
- const packaged = isPackaged();
127
-
128
- // 资源路径不同
129
- let dir = '';
130
- if (packaged) {
131
- // 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
132
- // windows和MacOs不一样
133
- dir = path.join(execDir, "resources", "extraResources");
134
- if (is.macOS()) {
135
- dir = path.join(execDir, "..", "Resources", "extraResources");
136
- }
137
- } else {
138
- // 打包前
139
- dir = path.join(execDir, "build", "extraResources");
140
- }
141
- return dir;
142
- }
143
-
144
- // 获取root目录 (dev-项目根目录,pro-app user data目录)
145
- function getRootDir() {
146
- const appDir = isDev() ? getBaseDir() : getAppUserDataDir();
147
- return appDir;
148
- }
149
-
150
- // 获取 appUserData目录
151
- function getAppUserDataDir() {
152
- return process.env.EE_APP_USER_DATA;
153
- }
154
-
155
- // 获取 exec目录
156
- function getExecDir() {
157
- return process.env.EE_EXEC_DIR;
158
- }
159
-
160
- // 获取操作系统用户目录
161
- function getUserHomeDir() {
162
- return process.env.EE_USER_HOME;
163
- }
164
-
165
- // 获取用户家目录中的隐藏的app目录
166
- function getUserHomeHiddenAppDir() {
167
- const appnameDir = "." + appName();
168
- const dir = path.join(getUserHomeDir(), appnameDir);
169
- return dir;
170
- }
171
-
172
- // 获取用户家目录中的app目录
173
- function getUserHomeAppDir() {
174
- const appnameDir = appName();
175
- const dir = path.join(getUserHomeDir(), appnameDir);
176
- return dir;
177
- }
178
-
179
- // 获取内置socket端口
180
- function getSocketPort() {
181
- return parseInt(process.env.EE_SOCKET_PORT) || 0;
182
- }
183
-
184
- // 获取内置http端口
185
- function getHttpPort() {
186
- return parseInt(process.env.EE_HTTP_PORT) || 0;
187
- }
188
-
189
- // 是否打包
190
- function isPackaged() {
191
- return process.env.EE_IS_PACKAGED === 'true';
192
- }
193
-
194
- // 进程退出
195
- function exit(code = 0) {
196
- return process.exit(code);
197
- }
198
-
199
- // 格式化message
200
- function makeMessage(msg = {}) {
201
- let message = Object.assign({
202
- channel: '',
203
- event: '',
204
- data: {}
205
- }, msg);
206
-
207
- return message;
208
- }
209
-
210
- // 退出ChildJob进程
211
- function exitChildJob(code = 0) {
212
- try {
213
- let args = JSON.parse(process.argv[2]);
214
- if (args.type == 'childJob') {
215
- process.exit(code);
216
- }
217
- } catch (e) {
218
- process.exit(code);
219
- }
220
- }
221
-
222
- // 任务类型 ChildJob
223
- function isChildJob() {
224
- try {
225
- let args = JSON.parse(process.argv[2]);
226
- if (args.type == 'childJob') {
227
- return true;
228
- }
229
- } catch (e) {
230
- return false;
231
- }
232
- }
233
-
234
- // 任务类型 ChildPoolJob
235
- function isChildPoolJob() {
236
- try {
237
- let args = JSON.parse(process.argv[2]);
238
- if (args.type == 'childPoolJob') {
239
- return true;
240
- }
241
- } catch (e) {
242
- return false;
243
- }
244
- }
245
-
246
- // Get cmd parameter by name
247
- function getArgumentByName(name, args) {
248
- if (!args) {
249
- args = process.argv;
250
- }
251
- for (let i = 0; i < args.length; i++) {
252
- const item = args[i];
253
- const prefixKey = `--${name}=`;
254
- if (item.indexOf(prefixKey) !== -1) {
255
- return item.substring(prefixKey.length);
256
- }
257
- }
258
- }
259
-
260
- module.exports = {
261
- allEnv,
262
- env,
263
- isProd,
264
- isDev,
265
- isRenderer,
266
- isMain,
267
- isForkedChild,
268
- processType,
269
- appName,
270
- appVersion,
271
- getDataDir,
272
- getLogDir,
273
- getBundleDir,
274
- getElectronCodeDir,
275
- getFrontendCodeDir,
276
- getRootDir,
277
- getBaseDir,
278
- getElectronDir,
279
- getPublicDir,
280
- getExtraResourcesDir,
281
- getAppUserDataDir,
282
- getExecDir,
283
- getUserHomeDir,
284
- getUserHomeAppDir,
285
- getUserHomeHiddenAppDir,
286
- getSocketPort,
287
- getHttpPort,
288
- isPackaged,
289
- exit,
290
- makeMessage,
291
- exitChildJob,
292
- isChildJob,
293
- isChildPoolJob,
294
- getArgumentByName
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const is = require('../utils/is');
5
+
6
+ // 当前进程的所有env
7
+ function allEnv() {
8
+ return process.env;
9
+ }
10
+
11
+ // 当前环境 - local | prod
12
+ function env() {
13
+ return process.env.EE_ENV;
14
+ }
15
+
16
+ // 是否生产环境
17
+ function isProd() {
18
+ return (process.env.EE_ENV === 'prod');
19
+ }
20
+
21
+ // 是否为开发环境
22
+ function isDev() {
23
+ if (process.env.EE_ENV === 'dev' || process.env.EE_ENV === 'local') {
24
+ return true;
25
+ }
26
+
27
+ return false;
28
+ };
29
+
30
+ // 是否为渲染进程
31
+ function isRenderer() {
32
+ return (typeof process === 'undefined' ||
33
+ !process ||
34
+ process.type === 'renderer');
35
+ };
36
+
37
+ // 是否为主进程
38
+ function isMain() {
39
+ return ( typeof process !== 'undefined' &&
40
+ process.type === 'browser');
41
+ };
42
+
43
+ // 是否为node子进程
44
+ function isForkedChild() {
45
+ return (Number(process.env.ELECTRON_RUN_AS_NODE) === 1);
46
+ };
47
+
48
+ // 当前进程类型
49
+ function processType() {
50
+ let type = '';
51
+ if (isMain()) {
52
+ type = 'browser';
53
+ } else if (isRenderer()) {
54
+ type = 'renderer';
55
+ } else if (isForkedChild()) {
56
+ type = 'child';
57
+ }
58
+
59
+ return type;
60
+ };
61
+
62
+ // app name
63
+ function appName() {
64
+ return process.env.EE_APP_NAME;
65
+ }
66
+
67
+ // app version
68
+ function appVersion() {
69
+ return process.env.EE_APP_VERSION;
70
+ }
71
+
72
+ // 获取数据存储路径
73
+ function getDataDir() {
74
+ const base = isDev() ? getBaseDir() : getUserHomeHiddenAppDir();
75
+ const dataDir = path.join(base, 'data');
76
+ return dataDir;
77
+ }
78
+
79
+ // 获取日志存储路径
80
+ function getLogDir() {
81
+ const base = isDev() ? getBaseDir() : getUserHomeHiddenAppDir();
82
+ const dir = path.join(base, 'logs');
83
+ return dir;
84
+ }
85
+
86
+ // 获取bundle文件路径
87
+ function getBundleDir(basePath) {
88
+ const base = basePath || process.cwd();
89
+ const dir = path.join(base, 'public', 'electron');
90
+ return dir;
91
+ }
92
+
93
+ // 获取electron 源码文件路径
94
+ function getElectronCodeDir(basePath) {
95
+ const base = basePath || process.cwd();
96
+ const dir = path.join(base, 'electron');
97
+ return dir;
98
+ }
99
+
100
+ // 获取frontend 源码文件路径
101
+ function getFrontendCodeDir(basePath) {
102
+ const base = basePath || process.cwd();
103
+ const dir = path.join(base, 'frontend');
104
+ return dir;
105
+ }
106
+
107
+ // 获取base目录
108
+ function getBaseDir() {
109
+ return process.env.EE_BASE_DIR;
110
+ }
111
+
112
+ // 获取electron目录
113
+ function getElectronDir() {
114
+ return process.env.EE_ELECTRON_DIR;
115
+ }
116
+
117
+ // 获取public目录
118
+ function getPublicDir() {
119
+ const dir = path.join(getBaseDir(), "public");
120
+ return dir;
121
+ }
122
+
123
+ // 获取 额外资源目录
124
+ function getExtraResourcesDir() {
125
+ const execDir = getExecDir();
126
+ const packaged = isPackaged();
127
+
128
+ // 资源路径不同
129
+ let dir = '';
130
+ if (packaged) {
131
+ // 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
132
+ // windows和MacOs不一样
133
+ dir = path.join(execDir, "resources", "extraResources");
134
+ if (is.macOS()) {
135
+ dir = path.join(execDir, "..", "Resources", "extraResources");
136
+ }
137
+ } else {
138
+ // 打包前
139
+ dir = path.join(execDir, "build", "extraResources");
140
+ }
141
+ return dir;
142
+ }
143
+
144
+ // 获取root目录 (dev-项目根目录,pro-app user data目录)
145
+ function getRootDir() {
146
+ const appDir = isDev() ? getBaseDir() : getAppUserDataDir();
147
+ return appDir;
148
+ }
149
+
150
+ // 获取 appUserData目录
151
+ function getAppUserDataDir() {
152
+ return process.env.EE_APP_USER_DATA;
153
+ }
154
+
155
+ // 获取 exec目录
156
+ function getExecDir() {
157
+ return process.env.EE_EXEC_DIR;
158
+ }
159
+
160
+ // 获取操作系统用户目录
161
+ function getUserHomeDir() {
162
+ return process.env.EE_USER_HOME;
163
+ }
164
+
165
+ // 获取用户家目录中的隐藏的app目录
166
+ function getUserHomeHiddenAppDir() {
167
+ const appnameDir = "." + appName();
168
+ const dir = path.join(getUserHomeDir(), appnameDir);
169
+ return dir;
170
+ }
171
+
172
+ // 获取用户家目录中的app目录
173
+ function getUserHomeAppDir() {
174
+ const appnameDir = appName();
175
+ const dir = path.join(getUserHomeDir(), appnameDir);
176
+ return dir;
177
+ }
178
+
179
+ // 获取内置socket端口
180
+ function getSocketPort() {
181
+ return parseInt(process.env.EE_SOCKET_PORT) || 0;
182
+ }
183
+
184
+ // 获取内置http端口
185
+ function getHttpPort() {
186
+ return parseInt(process.env.EE_HTTP_PORT) || 0;
187
+ }
188
+
189
+ // 是否打包
190
+ function isPackaged() {
191
+ return process.env.EE_IS_PACKAGED === 'true';
192
+ }
193
+
194
+ // 进程退出
195
+ function exit(code = 0) {
196
+ return process.exit(code);
197
+ }
198
+
199
+ // 格式化message
200
+ function makeMessage(msg = {}) {
201
+ let message = Object.assign({
202
+ channel: '',
203
+ event: '',
204
+ data: {}
205
+ }, msg);
206
+
207
+ return message;
208
+ }
209
+
210
+ // 退出ChildJob进程
211
+ function exitChildJob(code = 0) {
212
+ try {
213
+ let args = JSON.parse(process.argv[2]);
214
+ if (args.type == 'childJob') {
215
+ process.exit(code);
216
+ }
217
+ } catch (e) {
218
+ process.exit(code);
219
+ }
220
+ }
221
+
222
+ // 任务类型 ChildJob
223
+ function isChildJob() {
224
+ try {
225
+ let args = JSON.parse(process.argv[2]);
226
+ if (args.type == 'childJob') {
227
+ return true;
228
+ }
229
+ } catch (e) {
230
+ return false;
231
+ }
232
+ }
233
+
234
+ // 任务类型 ChildPoolJob
235
+ function isChildPoolJob() {
236
+ try {
237
+ let args = JSON.parse(process.argv[2]);
238
+ if (args.type == 'childPoolJob') {
239
+ return true;
240
+ }
241
+ } catch (e) {
242
+ return false;
243
+ }
244
+ }
245
+
246
+ // Get cmd parameter by name
247
+ function getArgumentByName(name, args) {
248
+ if (!args) {
249
+ args = process.argv;
250
+ }
251
+ for (let i = 0; i < args.length; i++) {
252
+ const item = args[i];
253
+ const prefixKey = `--${name}=`;
254
+ if (item.indexOf(prefixKey) !== -1) {
255
+ return item.substring(prefixKey.length);
256
+ }
257
+ }
258
+ }
259
+
260
+ module.exports = {
261
+ allEnv,
262
+ env,
263
+ isProd,
264
+ isDev,
265
+ isRenderer,
266
+ isMain,
267
+ isForkedChild,
268
+ processType,
269
+ appName,
270
+ appVersion,
271
+ getDataDir,
272
+ getLogDir,
273
+ getBundleDir,
274
+ getElectronCodeDir,
275
+ getFrontendCodeDir,
276
+ getRootDir,
277
+ getBaseDir,
278
+ getElectronDir,
279
+ getPublicDir,
280
+ getExtraResourcesDir,
281
+ getAppUserDataDir,
282
+ getExecDir,
283
+ getUserHomeDir,
284
+ getUserHomeAppDir,
285
+ getUserHomeHiddenAppDir,
286
+ getSocketPort,
287
+ getHttpPort,
288
+ isPackaged,
289
+ exit,
290
+ makeMessage,
291
+ exitChildJob,
292
+ isChildJob,
293
+ isChildPoolJob,
294
+ getArgumentByName
295
295
  }
@@ -1,8 +1,8 @@
1
- export declare class HttpServer {
2
- config: any;
3
- httpApp: any;
4
- init(): Promise<void>;
5
- _create(): void;
6
- _dispatch(ctx: any, next: any): Promise<void>;
7
- getHttpApp(): any;
8
- }
1
+ export declare class HttpServer {
2
+ config: any;
3
+ httpApp: any;
4
+ init(): Promise<void>;
5
+ _create(): void;
6
+ _dispatch(ctx: any, next: any): Promise<void>;
7
+ getHttpApp(): any;
8
+ }