ee-core 4.1.2 → 4.1.4
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/LICENSE +21 -21
- package/README.md +65 -65
- package/app/application.d.ts +5 -5
- package/app/application.js +30 -30
- package/app/boot.d.ts +5 -5
- package/app/boot.js +80 -80
- package/app/dir.d.ts +1 -1
- package/app/dir.js +26 -26
- package/app/events.d.ts +14 -14
- package/app/events.js +55 -55
- package/app/index.d.ts +2 -2
- package/app/index.js +6 -6
- package/config/config_loader.d.ts +13 -13
- package/config/config_loader.js +65 -65
- package/config/default_config.d.ts +95 -95
- package/config/default_config.js +111 -111
- package/config/index.d.ts +28 -28
- package/config/index.js +24 -24
- package/const/channel.d.ts +16 -16
- package/const/channel.js +27 -27
- package/controller/controller_loader.d.ts +9 -9
- package/controller/controller_loader.js +77 -77
- package/controller/index.d.ts +2 -2
- package/controller/index.js +24 -24
- package/core/index.d.ts +2 -2
- package/core/index.js +11 -11
- package/core/loader/file_loader.d.ts +66 -66
- package/core/loader/file_loader.js +211 -211
- package/core/utils/index.d.ts +12 -12
- package/core/utils/index.js +83 -83
- package/core/utils/timing.d.ts +22 -22
- package/core/utils/timing.js +78 -78
- package/cross/cross.d.ts +19 -19
- package/cross/cross.js +151 -151
- package/cross/crossProcess.d.ts +29 -29
- package/cross/crossProcess.js +172 -172
- package/cross/index.d.ts +2 -2
- package/cross/index.js +8 -8
- package/electron/app/index.d.ts +5 -5
- package/electron/app/index.js +48 -48
- package/electron/index.d.ts +3 -3
- package/electron/index.js +15 -15
- package/electron/window/index.d.ts +6 -6
- package/electron/window/index.js +268 -268
- package/exception/index.d.ts +9 -9
- package/exception/index.js +100 -100
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.d.ts +1 -1
- package/html/index.js +10 -10
- package/index.d.ts +2 -2
- package/index.js +6 -6
- package/jobs/child/app.d.ts +1 -1
- package/jobs/child/app.js +69 -69
- package/jobs/child/index.d.ts +13 -13
- package/jobs/child/index.js +85 -85
- package/jobs/child/jobProcess.d.ts +16 -16
- package/jobs/child/jobProcess.js +133 -133
- package/jobs/child-pool/index.d.ts +26 -26
- package/jobs/child-pool/index.js +190 -190
- package/jobs/index.d.ts +3 -3
- package/jobs/index.js +6 -6
- package/jobs/load-balancer/algorithm/index.d.ts +4 -4
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.d.ts +2 -2
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.d.ts +8 -8
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.d.ts +96 -96
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.d.ts +16 -16
- package/jobs/load-balancer/scheduler.js +31 -31
- package/loader/index.d.ts +9 -9
- package/loader/index.js +99 -98
- package/log/index.d.ts +5 -5
- package/log/index.js +85 -85
- package/log/logger.d.ts +1 -1
- package/log/logger.js +94 -94
- package/message/childMessage.d.ts +10 -10
- package/message/childMessage.js +43 -43
- package/message/index.d.ts +3 -3
- package/message/index.js +9 -9
- package/package.json +42 -42
- package/ps/index.d.ts +39 -39
- package/ps/index.js +294 -294
- package/socket/httpServer.d.ts +8 -8
- package/socket/httpServer.js +199 -199
- package/socket/index.d.ts +10 -10
- package/socket/index.js +64 -64
- package/socket/ipcServer.d.ts +9 -9
- package/socket/ipcServer.js +105 -105
- package/socket/socketServer.d.ts +10 -10
- package/socket/socketServer.js +81 -81
- package/storage/index.d.ts +4 -4
- package/storage/index.js +6 -6
- package/storage/sqliteStorage.d.ts +16 -16
- package/storage/sqliteStorage.js +123 -123
- package/tsconfig.json +13 -13
- package/utils/extend.d.ts +2 -2
- package/utils/extend.js +77 -77
- package/utils/helper.d.ts +14 -14
- package/utils/helper.js +206 -206
- package/utils/index.d.ts +10 -10
- package/utils/index.js +167 -167
- package/utils/ip.d.ts +2 -2
- package/utils/ip.js +221 -221
- package/utils/is.d.ts +14 -14
- package/utils/is.js +111 -111
- package/utils/json.d.ts +5 -5
- package/utils/json.js +79 -79
- package/utils/pargv.d.ts +3 -3
- package/utils/pargv.js +267 -267
- package/utils/port/index.d.ts +1 -1
- package/utils/port/index.js +125 -125
- package/utils/wrap.d.ts +4 -4
- 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.
|
package/app/application.d.ts
CHANGED
|
@@ -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;
|
package/app/application.js
CHANGED
|
@@ -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
|
+
|