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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Wallace Gao
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Wallace Gao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,66 +1,66 @@
1
- ### introduction
2
-
3
- Powerful electron third party module, offering **100+ API**
4
-
5
- [introduction](https://www.kaka996.com/pages/85c531/)
6
-
7
- [中文文档](https://www.kaka996.com/pages/85c531/)
8
-
9
- ### module list
10
-
11
- #### addon
12
- plug-in module
13
-
14
- #### bin
15
- Command line module.
16
-
17
- #### config
18
- Configuration Module
19
-
20
- #### const
21
- Define the universal constants used in the framework.
22
-
23
- #### controller
24
- Controller module
25
-
26
- #### ee
27
- EE module
28
-
29
- #### electron
30
- The electric function encapsulated by the framework will provide APIs in this module.
31
-
32
- #### exception
33
- Capture exception modules.
34
-
35
- #### httpclient
36
- HTTP client.
37
-
38
- #### jobs
39
- Jobs module.
40
-
41
- #### loader
42
- loader module
43
-
44
- #### log
45
- log module
46
-
47
- #### message
48
- Message module. Sending messages between the main process and child processes.
49
-
50
- #### ps
51
- Process tool class module.
52
-
53
- #### services
54
- services module
55
-
56
- #### socket
57
- Provide socket communication function.
58
-
59
- #### storage
60
- Storage module. Provide JSON database and sqlite database.
61
-
62
- #### tools
63
- Script module. Encrypt and move resources.
64
-
65
- #### utils
1
+ ### introduction
2
+
3
+ Powerful electron third party module, offering **100+ API**
4
+
5
+ [introduction](https://www.kaka996.com/pages/85c531/)
6
+
7
+ [中文文档](https://www.kaka996.com/pages/85c531/)
8
+
9
+ ### module list
10
+
11
+ #### addon
12
+ plug-in module
13
+
14
+ #### bin
15
+ Command line module.
16
+
17
+ #### config
18
+ Configuration Module
19
+
20
+ #### const
21
+ Define the universal constants used in the framework.
22
+
23
+ #### controller
24
+ Controller module
25
+
26
+ #### ee
27
+ EE module
28
+
29
+ #### electron
30
+ The electric function encapsulated by the framework will provide APIs in this module.
31
+
32
+ #### exception
33
+ Capture exception modules.
34
+
35
+ #### httpclient
36
+ HTTP client.
37
+
38
+ #### jobs
39
+ Jobs module.
40
+
41
+ #### loader
42
+ loader module
43
+
44
+ #### log
45
+ log module
46
+
47
+ #### message
48
+ Message module. Sending messages between the main process and child processes.
49
+
50
+ #### ps
51
+ Process tool class module.
52
+
53
+ #### services
54
+ services module
55
+
56
+ #### socket
57
+ Provide socket communication function.
58
+
59
+ #### storage
60
+ Storage module. Provide JSON database and sqlite database.
61
+
62
+ #### tools
63
+ Script module. Encrypt and move resources.
64
+
65
+ #### utils
66
66
  Tool library module.
@@ -1,5 +1,5 @@
1
- export declare class Appliaction {
2
- register(eventName: string, handler: Function): void;
3
- run(): void;
4
- }
5
- export declare const app: Appliaction;
1
+ export declare class Appliaction {
2
+ register(eventName: string, handler: Function): void;
3
+ run(): void;
4
+ }
5
+ export declare const app: Appliaction;
@@ -1,31 +1,31 @@
1
- 'use strict';
2
-
3
- const debug = require('debug')('ee-core:app:appliaction');
4
- const { loadController } = require('../controller');
5
- const { eventBus, Ready } = require('./events');
6
- const { loadSocket } = require('../socket');
7
- const { loadElectron } = require('../electron');
8
-
9
- class Appliaction {
10
- constructor() {
11
-
12
- }
13
-
14
- register(eventName, handler) {
15
- return eventBus.register(eventName, handler);
16
- }
17
-
18
- run() {
19
- loadController();
20
- loadSocket();
21
- eventBus.emitLifecycle(Ready);
22
- loadElectron();
23
- }
24
- }
25
-
26
- const app = new Appliaction();
27
-
28
- module.exports = {
29
- Appliaction,
30
- app,
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('ee-core:app:appliaction');
4
+ const { loadController } = require('../controller');
5
+ const { eventBus, Ready } = require('./events');
6
+ const { loadSocket } = require('../socket');
7
+ const { loadElectron } = require('../electron');
8
+
9
+ class Appliaction {
10
+ constructor() {
11
+
12
+ }
13
+
14
+ register(eventName, handler) {
15
+ return eventBus.register(eventName, handler);
16
+ }
17
+
18
+ run() {
19
+ loadController();
20
+ loadSocket();
21
+ eventBus.emitLifecycle(Ready);
22
+ loadElectron();
23
+ }
24
+ }
25
+
26
+ const app = new Appliaction();
27
+
28
+ module.exports = {
29
+ Appliaction,
30
+ app,
31
31
  };
package/app/boot.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export declare class ElectronEgg {
2
- init(): void;
3
- register(eventName: string, handler: Function): void;
4
- run(): void;
5
- }
1
+ export declare class ElectronEgg {
2
+ init(): void;
3
+ register(eventName: string, handler: Function): void;
4
+ run(): void;
5
+ }
package/app/boot.js CHANGED
@@ -1,81 +1,81 @@
1
- 'use strict';
2
-
3
- const debug = require('debug')('ee-core:app:boot');
4
- const path = require('path');
5
- const { loadException } = require('../exception');
6
- const { electronApp } = require('../electron/app');
7
- const { getArgumentByName, getBundleDir, getElectronCodeDir } = require('../ps');
8
- const { loadConfig } = require('../config');
9
- const { loadLog } = require('../log');
10
- const { app } = require('./application');
11
- const { loadDir } = require('./dir');
12
-
13
- class ElectronEgg {
14
- constructor() {
15
- const baseDir = electronApp.getAppPath();
16
- const { env } = process;
17
- const environmet = getArgumentByName('env') || 'prod';
18
- const debugging = getArgumentByName('debuger') == 'true'? true : false;
19
-
20
- // Debugging source code
21
- let electronDir = getBundleDir(baseDir);
22
- if (debugging) {
23
- electronDir = getElectronCodeDir(baseDir);
24
- }
25
-
26
- const options = {
27
- env: environmet,
28
- baseDir,
29
- electronDir,
30
- appName: electronApp.getName(),
31
- userHome: electronApp.getPath('home'),
32
- appData: electronApp.getPath('appData'),
33
- appUserData: electronApp.getPath('userData'),
34
- appVersion: electronApp.getVersion(),
35
- isPackaged: electronApp.isPackaged,
36
- execDir: baseDir,
37
- }
38
-
39
- // exec directory (exe dmg dep) for prod
40
- if (environmet == 'prod' && options.isPackaged) {
41
- options.execDir = path.dirname(electronApp.getPath('exe'));
42
- }
43
-
44
- // normalize env
45
- env.EE_ENV = environmet;
46
- env.EE_APP_NAME = options.appName;
47
- env.EE_APP_VERSION = options.appVersion;
48
- env.EE_BASE_DIR = options.baseDir;
49
- env.EE_ELECTRON_DIR = options.electronDir;
50
- env.EE_USER_HOME = options.userHome;
51
- env.EE_APP_DATA = options.appData;
52
- env.EE_APP_USER_DATA = options.appUserData;
53
- env.EE_EXEC_DIR = options.execDir;
54
- env.EE_IS_PACKAGED = options.isPackaged;
55
- env.EE_SOCKET_PORT = null;
56
- env.EE_HTTP_PORT = null;
57
- debug('[constructor] options:%j', options)
58
-
59
- this.init();
60
- }
61
-
62
- init() {
63
- // basic functions
64
- loadException();
65
- loadConfig();
66
- loadDir();
67
- loadLog();
68
- }
69
-
70
- register(eventName, handler) {
71
- return app.register(eventName, handler);
72
- }
73
-
74
- run() {
75
- app.run();
76
- }
77
- }
78
-
79
- module.exports = {
80
- ElectronEgg,
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('ee-core:app:boot');
4
+ const path = require('path');
5
+ const { loadException } = require('../exception');
6
+ const { electronApp } = require('../electron/app');
7
+ const { getArgumentByName, getBundleDir, getElectronCodeDir } = require('../ps');
8
+ const { loadConfig } = require('../config');
9
+ const { loadLog } = require('../log');
10
+ const { app } = require('./application');
11
+ const { loadDir } = require('./dir');
12
+
13
+ class ElectronEgg {
14
+ constructor() {
15
+ const baseDir = electronApp.getAppPath();
16
+ const { env } = process;
17
+ const environmet = getArgumentByName('env') || 'prod';
18
+ const debugging = getArgumentByName('debuger') == 'true'? true : false;
19
+
20
+ // Debugging source code
21
+ let electronDir = getBundleDir(baseDir);
22
+ if (debugging) {
23
+ electronDir = getElectronCodeDir(baseDir);
24
+ }
25
+
26
+ const options = {
27
+ env: environmet,
28
+ baseDir,
29
+ electronDir,
30
+ appName: electronApp.getName(),
31
+ userHome: electronApp.getPath('home'),
32
+ appData: electronApp.getPath('appData'),
33
+ appUserData: electronApp.getPath('userData'),
34
+ appVersion: electronApp.getVersion(),
35
+ isPackaged: electronApp.isPackaged,
36
+ execDir: baseDir,
37
+ }
38
+
39
+ // exec directory (exe dmg dep) for prod
40
+ if (environmet == 'prod' && options.isPackaged) {
41
+ options.execDir = path.dirname(electronApp.getPath('exe'));
42
+ }
43
+
44
+ // normalize env
45
+ env.EE_ENV = environmet;
46
+ env.EE_APP_NAME = options.appName;
47
+ env.EE_APP_VERSION = options.appVersion;
48
+ env.EE_BASE_DIR = options.baseDir;
49
+ env.EE_ELECTRON_DIR = options.electronDir;
50
+ env.EE_USER_HOME = options.userHome;
51
+ env.EE_APP_DATA = options.appData;
52
+ env.EE_APP_USER_DATA = options.appUserData;
53
+ env.EE_EXEC_DIR = options.execDir;
54
+ env.EE_IS_PACKAGED = options.isPackaged;
55
+ env.EE_SOCKET_PORT = null;
56
+ env.EE_HTTP_PORT = null;
57
+ debug('[constructor] options:%j', options)
58
+
59
+ this.init();
60
+ }
61
+
62
+ init() {
63
+ // basic functions
64
+ loadException();
65
+ loadConfig();
66
+ loadDir();
67
+ loadLog();
68
+ }
69
+
70
+ register(eventName, handler) {
71
+ return app.register(eventName, handler);
72
+ }
73
+
74
+ run() {
75
+ app.run();
76
+ }
77
+ }
78
+
79
+ module.exports = {
80
+ ElectronEgg,
81
81
  };
package/app/dir.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function loadDir(): void;
1
+ export declare function loadDir(): void;
package/app/dir.js CHANGED
@@ -1,27 +1,27 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const { getUserHomeHiddenAppDir, getLogDir, getDataDir } = require('../ps');
5
- const { mkdir } = require('../utils/helper');
6
- function loadDir() {
7
- initDir();
8
- }
9
-
10
- function initDir() {
11
- const homeHiddenAppDir = getUserHomeHiddenAppDir();
12
- if (!fs.existsSync(homeHiddenAppDir)) {
13
- mkdir(homeHiddenAppDir, { mode: 0o755 });
14
- }
15
- const dataDir = getDataDir();
16
- if (!fs.existsSync(dataDir)) {
17
- mkdir(dataDir, { mode: 0o755 });
18
- }
19
- const logDir = getLogDir();
20
- if (!fs.existsSync(logDir)) {
21
- mkdir(logDir, { mode: 0o755 });
22
- }
23
- }
24
-
25
- module.exports = {
26
- loadDir
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const { getUserHomeHiddenAppDir, getLogDir, getDataDir } = require('../ps');
5
+ const { mkdir } = require('../utils/helper');
6
+ function loadDir() {
7
+ initDir();
8
+ }
9
+
10
+ function initDir() {
11
+ const homeHiddenAppDir = getUserHomeHiddenAppDir();
12
+ if (!fs.existsSync(homeHiddenAppDir)) {
13
+ mkdir(homeHiddenAppDir, { mode: 0o755 });
14
+ }
15
+ const dataDir = getDataDir();
16
+ if (!fs.existsSync(dataDir)) {
17
+ mkdir(dataDir, { mode: 0o755 });
18
+ }
19
+ const logDir = getLogDir();
20
+ if (!fs.existsSync(logDir)) {
21
+ mkdir(logDir, { mode: 0o755 });
22
+ }
23
+ }
24
+
25
+ module.exports = {
26
+ loadDir
27
27
  };
package/app/events.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export declare class EventBus {
2
- lifecycleEvents: {};
3
- eventsMap: {};
4
- register(eventName: string, handler: Function): void;
5
- emitLifecycle(eventName: string, ...args: any[]): void;
6
- on(eventName: string, handler: Function): void;
7
- emit(eventName: string, ...args: any[]): void;
8
- }
9
- export declare const eventBus: EventBus;
10
- export declare const Ready: "ready";
11
- export declare const ElectronAppReady: "electron-app-ready";
12
- export declare const WindowReady: "window-ready";
13
- export declare const Preload: "preload";
14
- export declare const BeforeClose: "before-close";
1
+ export declare class EventBus {
2
+ lifecycleEvents: {};
3
+ eventsMap: {};
4
+ register(eventName: string, handler: Function): void;
5
+ emitLifecycle(eventName: string, ...args: any[]): void;
6
+ on(eventName: string, handler: Function): void;
7
+ emit(eventName: string, ...args: any[]): void;
8
+ }
9
+ export declare const eventBus: EventBus;
10
+ export declare const Ready: "ready";
11
+ export declare const ElectronAppReady: "electron-app-ready";
12
+ export declare const WindowReady: "window-ready";
13
+ export declare const Preload: "preload";
14
+ export declare const BeforeClose: "before-close";
package/app/events.js CHANGED
@@ -1,56 +1,56 @@
1
- 'use strict';
2
-
3
- const Ready = "ready";
4
- const ElectronAppReady = "electron-app-ready";
5
- const WindowReady = "window-ready";
6
- const BeforeClose = "before-close";
7
- const Preload = "preload";
8
-
9
- class EventBus {
10
- constructor() {
11
- this.lifecycleEvents = {};
12
- this.eventsMap = {};
13
- }
14
-
15
- // add lifecycle event
16
- register(eventName, handler) {
17
- if (!this.lifecycleEvents[eventName]) {
18
- this.lifecycleEvents[eventName] = handler;
19
- }
20
- }
21
-
22
- // call lifecycle event
23
- emitLifecycle(eventName, ...args) {
24
- const eventFn = this.lifecycleEvents[eventName];
25
- if (eventFn) {
26
- eventFn(...args);
27
- }
28
- }
29
-
30
- // add listener
31
- on(eventName, handler) {
32
- if (!this.eventsMap[eventName]) {
33
- this.eventsMap[eventName] = handler;
34
- }
35
- }
36
-
37
- // emit listener
38
- emit(eventName, ...args) {
39
- const eventFn = this.eventsMap[eventName];
40
- if (eventFn) {
41
- eventFn(...args);
42
- }
43
- }
44
- }
45
-
46
- const eventBus = new EventBus();
47
-
48
- module.exports = {
49
- EventBus,
50
- eventBus,
51
- Ready,
52
- ElectronAppReady,
53
- WindowReady,
54
- Preload,
55
- BeforeClose
1
+ 'use strict';
2
+
3
+ const Ready = "ready";
4
+ const ElectronAppReady = "electron-app-ready";
5
+ const WindowReady = "window-ready";
6
+ const BeforeClose = "before-close";
7
+ const Preload = "preload";
8
+
9
+ class EventBus {
10
+ constructor() {
11
+ this.lifecycleEvents = {};
12
+ this.eventsMap = {};
13
+ }
14
+
15
+ // add lifecycle event
16
+ register(eventName, handler) {
17
+ if (!this.lifecycleEvents[eventName]) {
18
+ this.lifecycleEvents[eventName] = handler;
19
+ }
20
+ }
21
+
22
+ // call lifecycle event
23
+ emitLifecycle(eventName, ...args) {
24
+ const eventFn = this.lifecycleEvents[eventName];
25
+ if (eventFn) {
26
+ eventFn(...args);
27
+ }
28
+ }
29
+
30
+ // add listener
31
+ on(eventName, handler) {
32
+ if (!this.eventsMap[eventName]) {
33
+ this.eventsMap[eventName] = handler;
34
+ }
35
+ }
36
+
37
+ // emit listener
38
+ emit(eventName, ...args) {
39
+ const eventFn = this.eventsMap[eventName];
40
+ if (eventFn) {
41
+ eventFn(...args);
42
+ }
43
+ }
44
+ }
45
+
46
+ const eventBus = new EventBus();
47
+
48
+ module.exports = {
49
+ EventBus,
50
+ eventBus,
51
+ Ready,
52
+ ElectronAppReady,
53
+ WindowReady,
54
+ Preload,
55
+ BeforeClose
56
56
  };
package/app/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { ElectronEgg };
2
- import { ElectronEgg } from "./boot";
1
+ export { ElectronEgg };
2
+ import { ElectronEgg } from "./boot";
package/app/index.js CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';
2
-
3
- const { ElectronEgg } = require('./boot');
4
-
5
- module.exports = {
6
- ElectronEgg,
1
+ 'use strict';
2
+
3
+ const { ElectronEgg } = require('./boot');
4
+
5
+ module.exports = {
6
+ ElectronEgg,
7
7
  };
@@ -1,13 +1,13 @@
1
- import { Timing } from "../core/utils/timing";
2
- import { EEConfig } from "./default_config";
3
- export declare class ConfigLoader {
4
- timing: Timing;
5
- /**
6
- * Load config/config.xxx.js
7
- */
8
- load(): EEConfig;
9
- _AppConfig(): EEConfig;
10
- _loadConfig(dirpath: string, filename: string): EEConfig;
11
- }
12
-
13
-
1
+ import { Timing } from "../core/utils/timing";
2
+ import { EEConfig } from "./default_config";
3
+ export declare class ConfigLoader {
4
+ timing: Timing;
5
+ /**
6
+ * Load config/config.xxx.js
7
+ */
8
+ load(): EEConfig;
9
+ _AppConfig(): EEConfig;
10
+ _loadConfig(dirpath: string, filename: string): EEConfig;
11
+ }
12
+
13
+