ee-core 2.9.2-beta.1 → 2.10.0

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 (103) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -65
  3. package/addon/index.js +34 -34
  4. package/addon/window/index.js +98 -98
  5. package/bin/tools.js +8 -8
  6. package/config/cache.js +41 -38
  7. package/config/config.default.js +331 -330
  8. package/config/index.js +75 -73
  9. package/const/channel.js +17 -17
  10. package/const/index.js +8 -8
  11. package/controller/baseContextClass.js +34 -34
  12. package/controller/index.js +34 -34
  13. package/core/index.js +10 -10
  14. package/core/lib/ee.js +216 -216
  15. package/core/lib/loader/context_loader.js +106 -106
  16. package/core/lib/loader/ee_loader.js +435 -435
  17. package/core/lib/loader/file_loader.js +326 -326
  18. package/core/lib/loader/mixin/addon.js +32 -32
  19. package/core/lib/loader/mixin/config.js +130 -130
  20. package/core/lib/loader/mixin/controller.js +125 -125
  21. package/core/lib/loader/mixin/service.js +28 -28
  22. package/core/lib/utils/base_context_class.js +34 -34
  23. package/core/lib/utils/function.js +30 -30
  24. package/core/lib/utils/index.js +133 -133
  25. package/core/lib/utils/sequencify.js +59 -59
  26. package/core/lib/utils/timing.js +77 -77
  27. package/cross/index.js +183 -183
  28. package/cross/spawnProcess.js +183 -183
  29. package/ee/appLoader.js +48 -48
  30. package/ee/application.js +99 -99
  31. package/ee/baseApp.js +103 -102
  32. package/ee/eeApp.js +408 -408
  33. package/ee/index.js +57 -57
  34. package/electron/app/index.js +64 -58
  35. package/electron/index.js +19 -19
  36. package/electron/window/index.js +73 -73
  37. package/electron/window/winState.js +186 -186
  38. package/exception/index.js +112 -112
  39. package/html/boot.html +98 -98
  40. package/html/cross-failure.html +28 -28
  41. package/html/failure.html +28 -28
  42. package/html/index.js +13 -13
  43. package/httpclient/index.js +161 -161
  44. package/index.js +54 -54
  45. package/jobs/baseJobClass.js +16 -16
  46. package/jobs/child/app.js +65 -65
  47. package/jobs/child/forkProcess.js +145 -145
  48. package/jobs/child/index.js +82 -82
  49. package/jobs/child-pool/index.js +213 -213
  50. package/jobs/index.js +8 -8
  51. package/jobs/load-balancer/algorithm/index.js +11 -11
  52. package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
  53. package/jobs/load-balancer/algorithm/polling.js +11 -11
  54. package/jobs/load-balancer/algorithm/random.js +9 -9
  55. package/jobs/load-balancer/algorithm/specify.js +14 -14
  56. package/jobs/load-balancer/algorithm/weights.js +21 -21
  57. package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
  58. package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
  59. package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
  60. package/jobs/load-balancer/consts.js +9 -9
  61. package/jobs/load-balancer/index.js +201 -201
  62. package/jobs/load-balancer/scheduler.js +31 -31
  63. package/jobs/renderer/index.js +141 -141
  64. package/jobs/renderer/loadView.js +40 -40
  65. package/jobs/unification.js +63 -63
  66. package/loader/index.js +172 -172
  67. package/log/index.js +68 -68
  68. package/log/logger.js +86 -80
  69. package/main/index.js +56 -56
  70. package/message/childMessage.js +54 -54
  71. package/message/index.js +18 -18
  72. package/old-utils/index.js +91 -91
  73. package/package.json +38 -38
  74. package/ps/index.js +371 -371
  75. package/services/baseContextClass.js +34 -34
  76. package/services/index.js +40 -40
  77. package/socket/httpServer.js +147 -147
  78. package/socket/index.js +81 -81
  79. package/socket/io.js +27 -27
  80. package/socket/ipcServer.js +112 -112
  81. package/socket/socketServer.js +69 -65
  82. package/storage/index.js +38 -38
  83. package/storage/jsondb/adapters/Base.js +23 -23
  84. package/storage/jsondb/adapters/FileSync.js +64 -52
  85. package/storage/jsondb/main.js +55 -42
  86. package/storage/jsondbStorage.js +195 -195
  87. package/storage/sqliteStorage.js +123 -123
  88. package/utils/co.js +237 -237
  89. package/utils/copyto.js +160 -160
  90. package/utils/depd/index.js +538 -538
  91. package/utils/depd/lib/browser/index.js +77 -77
  92. package/utils/extend.js +73 -73
  93. package/utils/get-port/index.d.ts +64 -64
  94. package/utils/get-port/index.js +148 -148
  95. package/utils/helper.js +220 -220
  96. package/utils/index.js +160 -160
  97. package/utils/ip.js +261 -261
  98. package/utils/is.js +145 -145
  99. package/utils/json.js +72 -72
  100. package/utils/pargv.js +263 -263
  101. package/utils/time/index.js +19 -19
  102. package/utils/time/ms.js +162 -162
  103. package/utils/wrap.js +35 -35
package/main/index.js CHANGED
@@ -1,57 +1,57 @@
1
- const { app } = require('electron');
2
- const path = require('path');
3
- const fs = require('fs');
4
- const Utils = require('../utils');
5
- const Ps = require('../ps');
6
- const EE = require('../ee');
7
- const UtilsCore = require('../core/lib/utils');
8
- const Loader = require('../loader');
9
- const UtilsPargv = require('../utils/pargv');
10
-
11
- class ElectronEgg {
12
-
13
- constructor(mode) {
14
- this.mode = mode || 'framework';
15
- this._create();
16
- }
17
-
18
- /**
19
- * create ElectronEgg app
20
- */
21
- _create() {
22
- if (!Ps.verifyMode(this.mode)) {
23
- throw new Error(`The mode supports only (framework | module) !`);
24
- }
25
- Ps.initMode(this.mode);
26
-
27
- // env 可能为空
28
- const argsObj = UtilsPargv(process.argv);
29
- let isDev = false;
30
- if ( argsObj['env'] == 'development' || argsObj['env'] === 'dev' || argsObj['env'] === 'local' ) {
31
- isDev = true;
32
- }
33
-
34
- // module mode
35
- if (Ps.isModuleMode()) {
36
- const { Application } = EE;
37
- new Application();
38
- return;
39
- }
40
-
41
- let baseDir = path.join(app.getAppPath(), 'electron');
42
- if (!isDev && Utils.isEncrypt(app.getAppPath())) {
43
- baseDir = Ps.getEncryptDir(app.getAppPath());
44
- }
45
-
46
- let indexFile = path.join(baseDir, 'index');
47
- indexFile = Loader.resolveModule(indexFile);
48
- if (!fs.existsSync(indexFile)) {
49
- throw new Error(`The ${indexFile} file does not exist`);
50
- }
51
-
52
- const EEApp = UtilsCore.loadFile(indexFile);
53
- EE.app = new EEApp();
54
- }
55
- }
56
-
1
+ const { app } = require('electron');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const Utils = require('../utils');
5
+ const Ps = require('../ps');
6
+ const EE = require('../ee');
7
+ const UtilsCore = require('../core/lib/utils');
8
+ const Loader = require('../loader');
9
+ const UtilsPargv = require('../utils/pargv');
10
+
11
+ class ElectronEgg {
12
+
13
+ constructor(mode) {
14
+ this.mode = mode || 'framework';
15
+ this._create();
16
+ }
17
+
18
+ /**
19
+ * create ElectronEgg app
20
+ */
21
+ _create() {
22
+ if (!Ps.verifyMode(this.mode)) {
23
+ throw new Error(`The mode supports only (framework | module) !`);
24
+ }
25
+ Ps.initMode(this.mode);
26
+
27
+ // env 可能为空
28
+ const argsObj = UtilsPargv(process.argv);
29
+ let isDev = false;
30
+ if ( argsObj['env'] == 'development' || argsObj['env'] === 'dev' || argsObj['env'] === 'local' ) {
31
+ isDev = true;
32
+ }
33
+
34
+ // module mode
35
+ if (Ps.isModuleMode()) {
36
+ const { Application } = EE;
37
+ new Application();
38
+ return;
39
+ }
40
+
41
+ let baseDir = path.join(app.getAppPath(), 'electron');
42
+ if (!isDev && Utils.isEncrypt(app.getAppPath())) {
43
+ baseDir = Ps.getEncryptDir(app.getAppPath());
44
+ }
45
+
46
+ let indexFile = path.join(baseDir, 'index');
47
+ indexFile = Loader.resolveModule(indexFile);
48
+ if (!fs.existsSync(indexFile)) {
49
+ throw new Error(`The ${indexFile} file does not exist`);
50
+ }
51
+
52
+ const EEApp = UtilsCore.loadFile(indexFile);
53
+ EE.app = new EEApp();
54
+ }
55
+ }
56
+
57
57
  module.exports = ElectronEgg;
@@ -1,54 +1,54 @@
1
- const Channel = require('../const/channel');
2
-
3
- class ChildMessage {
4
- constructor() {
5
- // ...
6
- }
7
-
8
- /**
9
- * 向主进程发消息
10
- */
11
- sendToMain(eventName, params = {}) {
12
- let receiver = Channel.receiver.childJob;
13
- return this.send(eventName, params, receiver);
14
- }
15
-
16
- /**
17
- * 向主进程发消息
18
- */
19
- send(eventName, params = {}, receiver) {
20
- let eventReceiver = receiver || Channel.receiver.forkProcess;
21
- let message = {
22
- channel: Channel.process.sendToMain,
23
- eventReceiver,
24
- event: eventName,
25
- data: params,
26
- }
27
-
28
- return process.send(message);
29
- }
30
-
31
- /**
32
- * 进程退出
33
- */
34
- exit(code = 0) {
35
- return process.exit(code);
36
- }
37
-
38
- /**
39
- * 发送错误到控制台
40
- */
41
- sendErrorToTerminal(err) {
42
- let errTips = (err && typeof err == 'object') ? err.toString() : '';
43
- errTips += ' Error !!! Please See file ee-core.log or ee-error-xxx.log for details !'
44
- let message = {
45
- channel: Channel.process.showException,
46
- data: errTips
47
- }
48
- process.send(message);
49
- }
50
- }
51
-
52
-
53
-
54
- module.exports = ChildMessage;
1
+ const Channel = require('../const/channel');
2
+
3
+ class ChildMessage {
4
+ constructor() {
5
+ // ...
6
+ }
7
+
8
+ /**
9
+ * 向主进程发消息
10
+ */
11
+ sendToMain(eventName, params = {}) {
12
+ let receiver = Channel.receiver.childJob;
13
+ return this.send(eventName, params, receiver);
14
+ }
15
+
16
+ /**
17
+ * 向主进程发消息
18
+ */
19
+ send(eventName, params = {}, receiver) {
20
+ let eventReceiver = receiver || Channel.receiver.forkProcess;
21
+ let message = {
22
+ channel: Channel.process.sendToMain,
23
+ eventReceiver,
24
+ event: eventName,
25
+ data: params,
26
+ }
27
+
28
+ return process.send(message);
29
+ }
30
+
31
+ /**
32
+ * 进程退出
33
+ */
34
+ exit(code = 0) {
35
+ return process.exit(code);
36
+ }
37
+
38
+ /**
39
+ * 发送错误到控制台
40
+ */
41
+ sendErrorToTerminal(err) {
42
+ let errTips = (err && typeof err == 'object') ? err.toString() : '';
43
+ errTips += ' Error !!! Please See file ee-core.log or ee-error-xxx.log for details !'
44
+ let message = {
45
+ channel: Channel.process.showException,
46
+ data: errTips
47
+ }
48
+ process.send(message);
49
+ }
50
+ }
51
+
52
+
53
+
54
+ module.exports = ChildMessage;
package/message/index.js CHANGED
@@ -1,19 +1,19 @@
1
- const ChildMessage = require('./childMessage');
2
- const EEChildMessage = Symbol('EeCore#Module#ChildMessage');
3
-
4
- const message = {
5
-
6
- /**
7
- * childMessage
8
- */
9
- get childMessage() {
10
- if (!this[EEChildMessage]) {
11
- this[EEChildMessage] = new ChildMessage();
12
- }
13
-
14
- return this[EEChildMessage] || null;
15
- },
16
-
17
- };
18
-
1
+ const ChildMessage = require('./childMessage');
2
+ const EEChildMessage = Symbol('EeCore#Module#ChildMessage');
3
+
4
+ const message = {
5
+
6
+ /**
7
+ * childMessage
8
+ */
9
+ get childMessage() {
10
+ if (!this[EEChildMessage]) {
11
+ this[EEChildMessage] = new ChildMessage();
12
+ }
13
+
14
+ return this[EEChildMessage] || null;
15
+ },
16
+
17
+ };
18
+
19
19
  module.exports = message;
@@ -1,91 +1,91 @@
1
- /**
2
- * 该模块不在增加新功能,请使用 /module/utils/index 模块
3
- */
4
-
5
- const path = require('path');
6
- const UtilsJson = require('../utils/json');
7
- const UtilsPs = require('../ps');
8
- const UtilsHelper = require('../utils/helper');
9
- const Copy = require('../utils/copyto');
10
- const Conf = require('../config');
11
- const Channel = require('../const/channel');
12
-
13
- /**
14
- * other module
15
- */
16
- Copy(UtilsPs)
17
- .and(UtilsHelper)
18
- .to(exports);
19
-
20
- /**
21
- * 获取项目根目录package.json
22
- */
23
- exports.getPackage = function() {
24
- const json = UtilsJson.readSync(path.join(this.getHomeDir(), 'package.json'));
25
-
26
- return json;
27
- };
28
-
29
- /**
30
- * 获取 ee配置
31
- */
32
- exports.getEeConfig = function() {
33
- const config = Conf.all();
34
-
35
- return config;
36
- }
37
-
38
- /**
39
- * 获取 app version
40
- */
41
- exports.getAppVersion = function() {
42
- const v = Conf.all().appVersion;
43
- return v;
44
- }
45
-
46
- /**
47
- * 获取 插件配置
48
- */
49
- exports.getAddonConfig = function() {
50
- const cfg = Conf.all().addons;
51
- return cfg;
52
- }
53
-
54
- /**
55
- * 获取 mainServer配置
56
- */
57
- exports.getMainServerConfig = function() {
58
- const cfg = Conf.all().mainServer;
59
- return cfg;
60
- }
61
-
62
- /**
63
- * 获取 httpServer配置
64
- */
65
- exports.getHttpServerConfig = function() {
66
- const cfg = Conf.all().httpServer;
67
- return cfg;
68
- }
69
-
70
- /**
71
- * 获取 socketServer配置
72
- */
73
- exports.getSocketServerConfig = function() {
74
- const cfg = Conf.all().socketServer;
75
- return cfg;
76
- }
77
-
78
- /**
79
- * 获取 socketio port
80
- */
81
- exports.getSocketPort = function() {
82
- const port = Conf.all().socketServer.port;
83
- return parseInt(port);
84
- }
85
-
86
- /**
87
- * 获取 socket channel
88
- */
89
- exports.getSocketChannel = function() {
90
- return Channel.socketIo.partySoftware;
91
- }
1
+ /**
2
+ * 该模块不在增加新功能,请使用 /module/utils/index 模块
3
+ */
4
+
5
+ const path = require('path');
6
+ const UtilsJson = require('../utils/json');
7
+ const UtilsPs = require('../ps');
8
+ const UtilsHelper = require('../utils/helper');
9
+ const Copy = require('../utils/copyto');
10
+ const Conf = require('../config');
11
+ const Channel = require('../const/channel');
12
+
13
+ /**
14
+ * other module
15
+ */
16
+ Copy(UtilsPs)
17
+ .and(UtilsHelper)
18
+ .to(exports);
19
+
20
+ /**
21
+ * 获取项目根目录package.json
22
+ */
23
+ exports.getPackage = function() {
24
+ const json = UtilsJson.readSync(path.join(this.getHomeDir(), 'package.json'));
25
+
26
+ return json;
27
+ };
28
+
29
+ /**
30
+ * 获取 ee配置
31
+ */
32
+ exports.getEeConfig = function() {
33
+ const config = Conf.all();
34
+
35
+ return config;
36
+ }
37
+
38
+ /**
39
+ * 获取 app version
40
+ */
41
+ exports.getAppVersion = function() {
42
+ const v = Conf.all().appVersion;
43
+ return v;
44
+ }
45
+
46
+ /**
47
+ * 获取 插件配置
48
+ */
49
+ exports.getAddonConfig = function() {
50
+ const cfg = Conf.all().addons;
51
+ return cfg;
52
+ }
53
+
54
+ /**
55
+ * 获取 mainServer配置
56
+ */
57
+ exports.getMainServerConfig = function() {
58
+ const cfg = Conf.all().mainServer;
59
+ return cfg;
60
+ }
61
+
62
+ /**
63
+ * 获取 httpServer配置
64
+ */
65
+ exports.getHttpServerConfig = function() {
66
+ const cfg = Conf.all().httpServer;
67
+ return cfg;
68
+ }
69
+
70
+ /**
71
+ * 获取 socketServer配置
72
+ */
73
+ exports.getSocketServerConfig = function() {
74
+ const cfg = Conf.all().socketServer;
75
+ return cfg;
76
+ }
77
+
78
+ /**
79
+ * 获取 socketio port
80
+ */
81
+ exports.getSocketPort = function() {
82
+ const port = Conf.all().socketServer.port;
83
+ return parseInt(port);
84
+ }
85
+
86
+ /**
87
+ * 获取 socket channel
88
+ */
89
+ exports.getSocketChannel = function() {
90
+ return Channel.socketIo.partySoftware;
91
+ }
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
- {
2
- "name": "ee-core",
3
- "version": "2.9.2-beta.1",
4
- "description": "ee core",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "",
10
- "license": "ISC",
11
- "bin": {
12
- "ee-core": "./bin/tools.js"
13
- },
14
- "dependencies": {
15
- "agentkeepalive": "^4.2.0",
16
- "bytenode": "^1.3.6",
17
- "chalk": "^4.1.2",
18
- "cross-spawn": "^7.0.3",
19
- "dayjs": "^1.11.7",
20
- "debug": "^4.3.3",
21
- "egg-errors": "^2.3.0",
22
- "egg-logger": "^2.7.1",
23
- "globby": "^10.0.0",
24
- "is-type-of": "^1.2.1",
25
- "koa": "^2.13.4",
26
- "koa-body": "^5.0.0",
27
- "koa-convert": "^2.0.0",
28
- "koa-static": "^5.0.0",
29
- "koa2-cors": "^2.0.6",
30
- "lodash": "^4.17.21",
31
- "mkdirp": "^2.1.3",
32
- "semver": "^7.3.8",
33
- "serialize-javascript": "^6.0.1",
34
- "socket.io": "^4.6.1",
35
- "socket.io-client": "^4.6.1",
36
- "urllib": "^2.38.0"
37
- }
38
- }
1
+ {
2
+ "name": "ee-core",
3
+ "version": "2.10.0",
4
+ "description": "ee core",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "bin": {
12
+ "ee-core": "./bin/tools.js"
13
+ },
14
+ "dependencies": {
15
+ "agentkeepalive": "^4.2.0",
16
+ "bytenode": "^1.3.6",
17
+ "chalk": "^4.1.2",
18
+ "cross-spawn": "^7.0.3",
19
+ "dayjs": "^1.11.7",
20
+ "debug": "^4.3.3",
21
+ "egg-errors": "^2.3.0",
22
+ "egg-logger": "^2.7.1",
23
+ "globby": "^10.0.0",
24
+ "is-type-of": "^1.2.1",
25
+ "koa": "^2.13.4",
26
+ "koa-body": "^5.0.0",
27
+ "koa-convert": "^2.0.0",
28
+ "koa-static": "^5.0.0",
29
+ "koa2-cors": "^2.0.6",
30
+ "lodash": "^4.17.21",
31
+ "mkdirp": "^2.1.3",
32
+ "semver": "^7.3.8",
33
+ "serialize-javascript": "^6.0.1",
34
+ "socket.io": "^4.6.1",
35
+ "socket.io-client": "^4.6.1",
36
+ "urllib": "^2.38.0"
37
+ }
38
+ }