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.
- 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 +152 -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 -99
- 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 +11 -10
- package/utils/index.js +198 -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/cross/crossProcess.js
CHANGED
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const EventEmitter = require('events');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const crossSpawn = require('cross-spawn');
|
|
6
|
-
const { coreLogger } = require('../log');
|
|
7
|
-
const { getExtraResourcesDir, isPackaged, isDev, getBaseDir } = require('../ps');
|
|
8
|
-
const { Events } = require('../const/channel');
|
|
9
|
-
const { getRandomString, getValueFromArgv } = require('../utils/helper');
|
|
10
|
-
const { is } = require('../utils');
|
|
11
|
-
const { parseArgv } = require('../utils/pargv');
|
|
12
|
-
const { app: electronApp } = require('electron');
|
|
13
|
-
const tkill = require('tree-kill');
|
|
14
|
-
|
|
15
|
-
class CrossProcess {
|
|
16
|
-
constructor(host, opt = {}) {
|
|
17
|
-
this.emitter = new EventEmitter();
|
|
18
|
-
this.host = host;
|
|
19
|
-
this.child = undefined;
|
|
20
|
-
this.pid = 0;
|
|
21
|
-
this.port = 0;
|
|
22
|
-
this.name = "";
|
|
23
|
-
this.config = {};
|
|
24
|
-
this._init(opt);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 初始化子进程
|
|
29
|
-
*/
|
|
30
|
-
_init(options = {}) {
|
|
31
|
-
const { targetConf, port } = options;
|
|
32
|
-
this.config = targetConf;
|
|
33
|
-
this.port = port;
|
|
34
|
-
|
|
35
|
-
// 该名称如果在childrenMap重复,会被重写
|
|
36
|
-
this.name = targetConf.name;
|
|
37
|
-
|
|
38
|
-
// Launch executable program
|
|
39
|
-
let cmdPath = '';
|
|
40
|
-
let cmdArgs = targetConf.args;
|
|
41
|
-
let execDir = getExtraResourcesDir();
|
|
42
|
-
let standardOutput = ['inherit', 'inherit', 'inherit', 'ipc'];
|
|
43
|
-
if (isPackaged()) {
|
|
44
|
-
standardOutput = ['ignore', 'ignore', 'ignore', 'ipc'];
|
|
45
|
-
}
|
|
46
|
-
if (targetConf.stdio) {
|
|
47
|
-
standardOutput = targetConf.stdio;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const { cmd, directory } = targetConf;
|
|
51
|
-
// use cmd first
|
|
52
|
-
if (cmd) {
|
|
53
|
-
if (!directory) {
|
|
54
|
-
throw new Error(`[ee-core] [cross] The config [directory] attribute does not exist`);
|
|
55
|
-
}
|
|
56
|
-
cmdPath = cmd;
|
|
57
|
-
if (!path.isAbsolute(cmd) && !isDev()) {
|
|
58
|
-
cmdPath = path.join(getExtraResourcesDir(), cmd);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
cmdPath = path.join(getExtraResourcesDir(), targetConf.name);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// windows
|
|
65
|
-
if (is.windows() && path.extname(cmdPath) != '.exe') {
|
|
66
|
-
// Complete the executable program extension
|
|
67
|
-
// notice: python.exe may bring up the App Store
|
|
68
|
-
if (targetConf.windowsExtname === true || !isDev()) {
|
|
69
|
-
cmdPath += ".exe";
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// executable program directory
|
|
74
|
-
if (directory && path.isAbsolute(directory)) {
|
|
75
|
-
execDir = directory;
|
|
76
|
-
} else if (directory && !path.isAbsolute(directory)) {
|
|
77
|
-
if (isDev()) {
|
|
78
|
-
execDir = path.join(getBaseDir(), directory);
|
|
79
|
-
} else {
|
|
80
|
-
execDir = path.join(getExtraResourcesDir(), directory);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
execDir = getExtraResourcesDir();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
coreLogger.info(`[ee-core] [cross/run] cmd: ${cmdPath}, args: ${cmdArgs}`);
|
|
87
|
-
const coreProcess = crossSpawn(cmdPath, cmdArgs, {
|
|
88
|
-
stdio: standardOutput,
|
|
89
|
-
detached: false,
|
|
90
|
-
cwd: execDir,
|
|
91
|
-
maxBuffer: 1024 * 1024 * 1024
|
|
92
|
-
});
|
|
93
|
-
this.child = coreProcess;
|
|
94
|
-
this.pid = coreProcess.pid;
|
|
95
|
-
|
|
96
|
-
coreProcess.on('exit', (code, signal) => {
|
|
97
|
-
let data = {
|
|
98
|
-
pid: this.pid
|
|
99
|
-
}
|
|
100
|
-
this.host.emitter.emit(Events.childProcessExit, data);
|
|
101
|
-
// Child process closed: The child process was killed externally or an internal error caused the application to stop, resulting in the application exiting
|
|
102
|
-
coreLogger.info(`[ee-core] [corss/process] received a exit from child-process, code:${code}, signal:${signal}, pid:${this.pid}, cmd:${cmdPath}, args: ${cmdArgs}`);
|
|
103
|
-
this._exitElectron();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
coreProcess.on('error', (err) => {
|
|
107
|
-
let data = {
|
|
108
|
-
pid: this.pid
|
|
109
|
-
}
|
|
110
|
-
this.host.emitter.emit(Events.childProcessError, data);
|
|
111
|
-
coreLogger.error(`[ee-core] [corss/process] received a error from child-process, error: ${err}, pid:${this.pid}`);
|
|
112
|
-
this._exitElectron();
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* kill
|
|
118
|
-
*/
|
|
119
|
-
kill(timeout = 1000) {
|
|
120
|
-
tkill(this.pid, 'SIGINT', (err) => {
|
|
121
|
-
if (err) {
|
|
122
|
-
coreLogger.error(`[ee-core] [corss/process] kill cross-process, error: ${err}, pid:${this.pid}`);
|
|
123
|
-
tkill(this.pid, 'SIGKILL');
|
|
124
|
-
}
|
|
125
|
-
setTimeout(() => {
|
|
126
|
-
this._exitElectron();
|
|
127
|
-
}, timeout)
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
getUrl() {
|
|
132
|
-
const ssl = getValueFromArgv(this.config.args, 'ssl');
|
|
133
|
-
let hostname = getValueFromArgv(this.config.args, 'hostname')
|
|
134
|
-
let protocol = 'http://';
|
|
135
|
-
if (ssl && (ssl == 'true' || ssl == '1')) {
|
|
136
|
-
protocol = 'https://';
|
|
137
|
-
}
|
|
138
|
-
hostname = hostname ? hostname : '127.0.0.1';
|
|
139
|
-
const url = protocol + hostname + ":" + this.port;
|
|
140
|
-
|
|
141
|
-
return url;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
getArgsObj() {
|
|
145
|
-
const obj = parseArgv(this.config.args);
|
|
146
|
-
return obj;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
setPort(port) {
|
|
150
|
-
this.port = parseInt(port);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
_generateId() {
|
|
154
|
-
const rid = getRandomString();
|
|
155
|
-
return `node:${this.pid}:${rid}`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* exit electron
|
|
160
|
-
*/
|
|
161
|
-
_exitElectron(timeout = 1000) {
|
|
162
|
-
if (this.config.appExit) {
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
// 主进程退出
|
|
165
|
-
electronApp.quit();
|
|
166
|
-
}, timeout)
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
module.exports = {
|
|
172
|
-
CrossProcess
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EventEmitter = require('events');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const crossSpawn = require('cross-spawn');
|
|
6
|
+
const { coreLogger } = require('../log');
|
|
7
|
+
const { getExtraResourcesDir, isPackaged, isDev, getBaseDir } = require('../ps');
|
|
8
|
+
const { Events } = require('../const/channel');
|
|
9
|
+
const { getRandomString, getValueFromArgv } = require('../utils/helper');
|
|
10
|
+
const { is } = require('../utils');
|
|
11
|
+
const { parseArgv } = require('../utils/pargv');
|
|
12
|
+
const { app: electronApp } = require('electron');
|
|
13
|
+
const tkill = require('tree-kill');
|
|
14
|
+
|
|
15
|
+
class CrossProcess {
|
|
16
|
+
constructor(host, opt = {}) {
|
|
17
|
+
this.emitter = new EventEmitter();
|
|
18
|
+
this.host = host;
|
|
19
|
+
this.child = undefined;
|
|
20
|
+
this.pid = 0;
|
|
21
|
+
this.port = 0;
|
|
22
|
+
this.name = "";
|
|
23
|
+
this.config = {};
|
|
24
|
+
this._init(opt);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 初始化子进程
|
|
29
|
+
*/
|
|
30
|
+
_init(options = {}) {
|
|
31
|
+
const { targetConf, port } = options;
|
|
32
|
+
this.config = targetConf;
|
|
33
|
+
this.port = port;
|
|
34
|
+
|
|
35
|
+
// 该名称如果在childrenMap重复,会被重写
|
|
36
|
+
this.name = targetConf.name;
|
|
37
|
+
|
|
38
|
+
// Launch executable program
|
|
39
|
+
let cmdPath = '';
|
|
40
|
+
let cmdArgs = targetConf.args;
|
|
41
|
+
let execDir = getExtraResourcesDir();
|
|
42
|
+
let standardOutput = ['inherit', 'inherit', 'inherit', 'ipc'];
|
|
43
|
+
if (isPackaged()) {
|
|
44
|
+
standardOutput = ['ignore', 'ignore', 'ignore', 'ipc'];
|
|
45
|
+
}
|
|
46
|
+
if (targetConf.stdio) {
|
|
47
|
+
standardOutput = targetConf.stdio;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { cmd, directory } = targetConf;
|
|
51
|
+
// use cmd first
|
|
52
|
+
if (cmd) {
|
|
53
|
+
if (!directory) {
|
|
54
|
+
throw new Error(`[ee-core] [cross] The config [directory] attribute does not exist`);
|
|
55
|
+
}
|
|
56
|
+
cmdPath = cmd;
|
|
57
|
+
if (!path.isAbsolute(cmd) && !isDev()) {
|
|
58
|
+
cmdPath = path.join(getExtraResourcesDir(), cmd);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
cmdPath = path.join(getExtraResourcesDir(), targetConf.name);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// windows
|
|
65
|
+
if (is.windows() && path.extname(cmdPath) != '.exe') {
|
|
66
|
+
// Complete the executable program extension
|
|
67
|
+
// notice: python.exe may bring up the App Store
|
|
68
|
+
if (targetConf.windowsExtname === true || !isDev()) {
|
|
69
|
+
cmdPath += ".exe";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// executable program directory
|
|
74
|
+
if (directory && path.isAbsolute(directory)) {
|
|
75
|
+
execDir = directory;
|
|
76
|
+
} else if (directory && !path.isAbsolute(directory)) {
|
|
77
|
+
if (isDev()) {
|
|
78
|
+
execDir = path.join(getBaseDir(), directory);
|
|
79
|
+
} else {
|
|
80
|
+
execDir = path.join(getExtraResourcesDir(), directory);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
execDir = getExtraResourcesDir();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
coreLogger.info(`[ee-core] [cross/run] cmd: ${cmdPath}, args: ${cmdArgs}`);
|
|
87
|
+
const coreProcess = crossSpawn(cmdPath, cmdArgs, {
|
|
88
|
+
stdio: standardOutput,
|
|
89
|
+
detached: false,
|
|
90
|
+
cwd: execDir,
|
|
91
|
+
maxBuffer: 1024 * 1024 * 1024
|
|
92
|
+
});
|
|
93
|
+
this.child = coreProcess;
|
|
94
|
+
this.pid = coreProcess.pid;
|
|
95
|
+
|
|
96
|
+
coreProcess.on('exit', (code, signal) => {
|
|
97
|
+
let data = {
|
|
98
|
+
pid: this.pid
|
|
99
|
+
}
|
|
100
|
+
this.host.emitter.emit(Events.childProcessExit, data);
|
|
101
|
+
// Child process closed: The child process was killed externally or an internal error caused the application to stop, resulting in the application exiting
|
|
102
|
+
coreLogger.info(`[ee-core] [corss/process] received a exit from child-process, code:${code}, signal:${signal}, pid:${this.pid}, cmd:${cmdPath}, args: ${cmdArgs}`);
|
|
103
|
+
this._exitElectron();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
coreProcess.on('error', (err) => {
|
|
107
|
+
let data = {
|
|
108
|
+
pid: this.pid
|
|
109
|
+
}
|
|
110
|
+
this.host.emitter.emit(Events.childProcessError, data);
|
|
111
|
+
coreLogger.error(`[ee-core] [corss/process] received a error from child-process, error: ${err}, pid:${this.pid}`);
|
|
112
|
+
this._exitElectron();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* kill
|
|
118
|
+
*/
|
|
119
|
+
kill(timeout = 1000) {
|
|
120
|
+
tkill(this.pid, 'SIGINT', (err) => {
|
|
121
|
+
if (err) {
|
|
122
|
+
coreLogger.error(`[ee-core] [corss/process] kill cross-process, error: ${err}, pid:${this.pid}`);
|
|
123
|
+
tkill(this.pid, 'SIGKILL');
|
|
124
|
+
}
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
this._exitElectron();
|
|
127
|
+
}, timeout)
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getUrl() {
|
|
132
|
+
const ssl = getValueFromArgv(this.config.args, 'ssl');
|
|
133
|
+
let hostname = getValueFromArgv(this.config.args, 'hostname')
|
|
134
|
+
let protocol = 'http://';
|
|
135
|
+
if (ssl && (ssl == 'true' || ssl == '1')) {
|
|
136
|
+
protocol = 'https://';
|
|
137
|
+
}
|
|
138
|
+
hostname = hostname ? hostname : '127.0.0.1';
|
|
139
|
+
const url = protocol + hostname + ":" + this.port;
|
|
140
|
+
|
|
141
|
+
return url;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getArgsObj() {
|
|
145
|
+
const obj = parseArgv(this.config.args);
|
|
146
|
+
return obj;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
setPort(port) {
|
|
150
|
+
this.port = parseInt(port);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_generateId() {
|
|
154
|
+
const rid = getRandomString();
|
|
155
|
+
return `node:${this.pid}:${rid}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* exit electron
|
|
160
|
+
*/
|
|
161
|
+
_exitElectron(timeout = 1000) {
|
|
162
|
+
if (this.config.appExit) {
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
// 主进程退出
|
|
165
|
+
electronApp.quit();
|
|
166
|
+
}, timeout)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = {
|
|
172
|
+
CrossProcess
|
|
173
173
|
};
|
package/cross/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Cross, cross } from "./cross";
|
|
2
|
-
export { Cross, cross };
|
|
1
|
+
import { Cross, cross } from "./cross";
|
|
2
|
+
export { Cross, cross };
|
package/cross/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { Cross, cross} = require('./cross');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
Cross,
|
|
7
|
-
cross
|
|
8
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { Cross, cross} = require('./cross');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
Cross,
|
|
7
|
+
cross
|
|
8
|
+
};
|
package/electron/app/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 创建electron应用
|
|
3
|
-
*/
|
|
4
|
-
export declare function createElectron(): void;
|
|
5
|
-
export { electronApp };
|
|
1
|
+
/**
|
|
2
|
+
* 创建electron应用
|
|
3
|
+
*/
|
|
4
|
+
export declare function createElectron(): void;
|
|
5
|
+
export { electronApp };
|
package/electron/app/index.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { app: electronApp } = require('electron');
|
|
4
|
-
const { coreLogger } = require('../../log');
|
|
5
|
-
const { is } = require('../../utils');
|
|
6
|
-
const { cross } = require('../../cross');
|
|
7
|
-
const { createMainWindow, setCloseAndQuit, loadServer } = require('../window');
|
|
8
|
-
const { eventBus, ElectronAppReady, BeforeClose, Preload } = require('../../app/events');
|
|
9
|
-
const { getConfig } = require('../../config');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 创建electron应用
|
|
13
|
-
*/
|
|
14
|
-
function createElectron() {
|
|
15
|
-
const { singleLock } = getConfig();
|
|
16
|
-
// 允许多个实例
|
|
17
|
-
const gotTheLock = electronApp.requestSingleInstanceLock();
|
|
18
|
-
if (singleLock && !gotTheLock) {
|
|
19
|
-
electronApp.quit();
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
electronApp.whenReady().then(() => {
|
|
24
|
-
createMainWindow();
|
|
25
|
-
eventBus.emitLifecycle(Preload);
|
|
26
|
-
loadServer();
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
electronApp.on('window-all-closed', () => {
|
|
30
|
-
if (!is.macOS()) {
|
|
31
|
-
coreLogger.info('[ee-core] [lib/eeApp] window-all-closed quit');
|
|
32
|
-
electronApp.quit();
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
electronApp.on('before-quit', () => {
|
|
37
|
-
setCloseAndQuit(true);
|
|
38
|
-
eventBus.emitLifecycle(BeforeClose);
|
|
39
|
-
cross.killAll();
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
eventBus.emitLifecycle(ElectronAppReady);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = {
|
|
46
|
-
electronApp,
|
|
47
|
-
createElectron,
|
|
48
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { app: electronApp } = require('electron');
|
|
4
|
+
const { coreLogger } = require('../../log');
|
|
5
|
+
const { is } = require('../../utils');
|
|
6
|
+
const { cross } = require('../../cross');
|
|
7
|
+
const { createMainWindow, setCloseAndQuit, loadServer } = require('../window');
|
|
8
|
+
const { eventBus, ElectronAppReady, BeforeClose, Preload } = require('../../app/events');
|
|
9
|
+
const { getConfig } = require('../../config');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 创建electron应用
|
|
13
|
+
*/
|
|
14
|
+
function createElectron() {
|
|
15
|
+
const { singleLock } = getConfig();
|
|
16
|
+
// 允许多个实例
|
|
17
|
+
const gotTheLock = electronApp.requestSingleInstanceLock();
|
|
18
|
+
if (singleLock && !gotTheLock) {
|
|
19
|
+
electronApp.quit();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
electronApp.whenReady().then(() => {
|
|
24
|
+
createMainWindow();
|
|
25
|
+
eventBus.emitLifecycle(Preload);
|
|
26
|
+
loadServer();
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
electronApp.on('window-all-closed', () => {
|
|
30
|
+
if (!is.macOS()) {
|
|
31
|
+
coreLogger.info('[ee-core] [lib/eeApp] window-all-closed quit');
|
|
32
|
+
electronApp.quit();
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
electronApp.on('before-quit', () => {
|
|
37
|
+
setCloseAndQuit(true);
|
|
38
|
+
eventBus.emitLifecycle(BeforeClose);
|
|
39
|
+
cross.killAll();
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
eventBus.emitLifecycle(ElectronAppReady);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
electronApp,
|
|
47
|
+
createElectron,
|
|
48
|
+
};
|
package/electron/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { getMainWindow, setCloseAndQuit, getCloseAndQuit } from "./window";
|
|
2
|
-
export declare function loadElectron(): void;
|
|
3
|
-
export { getMainWindow, setCloseAndQuit, getCloseAndQuit };
|
|
1
|
+
import { getMainWindow, setCloseAndQuit, getCloseAndQuit } from "./window";
|
|
2
|
+
export declare function loadElectron(): void;
|
|
3
|
+
export { getMainWindow, setCloseAndQuit, getCloseAndQuit };
|
package/electron/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { createElectron } = require("./app");
|
|
4
|
-
const { getMainWindow, setCloseAndQuit, getCloseAndQuit } = require("./window");
|
|
5
|
-
|
|
6
|
-
// load socket server
|
|
7
|
-
function loadElectron() {
|
|
8
|
-
createElectron();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
loadElectron,
|
|
13
|
-
getMainWindow,
|
|
14
|
-
setCloseAndQuit,
|
|
15
|
-
getCloseAndQuit
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createElectron } = require("./app");
|
|
4
|
+
const { getMainWindow, setCloseAndQuit, getCloseAndQuit } = require("./window");
|
|
5
|
+
|
|
6
|
+
// load socket server
|
|
7
|
+
function loadElectron() {
|
|
8
|
+
createElectron();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
loadElectron,
|
|
13
|
+
getMainWindow,
|
|
14
|
+
setCloseAndQuit,
|
|
15
|
+
getCloseAndQuit
|
|
16
16
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function getMainWindow(): any;
|
|
2
|
-
export declare function createMainWindow(): any;
|
|
3
|
-
export declare function restoreMainWindow(): void;
|
|
4
|
-
export declare function setCloseAndQuit(flag: any): void;
|
|
5
|
-
export declare function getCloseAndQuit(): boolean;
|
|
6
|
-
export declare function loadServer(): Promise<void>;
|
|
1
|
+
export declare function getMainWindow(): any;
|
|
2
|
+
export declare function createMainWindow(): any;
|
|
3
|
+
export declare function restoreMainWindow(): void;
|
|
4
|
+
export declare function setCloseAndQuit(flag: any): void;
|
|
5
|
+
export declare function getCloseAndQuit(): boolean;
|
|
6
|
+
export declare function loadServer(): Promise<void>;
|