ee-core 2.12.0 → 4.0.0-beta.1
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/app/application.js +31 -0
- package/app/boot.js +81 -0
- package/app/dir.js +27 -0
- package/app/events.js +56 -0
- package/app/index.js +7 -0
- package/config/config_loader.js +19 -23
- package/config/default_config.js +110 -0
- package/config/index.js +20 -37
- package/const/channel.js +26 -16
- package/const/index.js +0 -4
- package/controller/controller_loader.js +78 -0
- package/controller/index.js +18 -19
- package/core/index.js +6 -5
- package/core/{lib/loader → loader}/file_loader.js +39 -156
- package/core/utils/index.js +83 -0
- package/core/{lib/utils → utils}/timing.js +3 -2
- package/cross/cross.js +152 -0
- package/cross/index.js +6 -181
- package/cross/spawnProcess.js +34 -51
- package/electron/app/index.js +38 -54
- package/electron/index.js +13 -17
- package/electron/window/index.js +260 -65
- package/exception/index.js +34 -32
- package/html/index.js +7 -10
- package/index.js +4 -52
- package/jobs/child/app.js +10 -10
- package/jobs/child/forkProcess.js +29 -45
- package/jobs/child/index.js +13 -10
- package/jobs/child-pool/index.js +13 -11
- package/jobs/index.js +2 -4
- package/loader/index.js +91 -143
- package/log/index.js +74 -57
- package/log/logger.js +75 -80
- package/message/childMessage.js +13 -13
- package/message/index.js +7 -16
- package/package.json +2 -2
- package/ps/index.js +136 -229
- package/socket/httpServer.js +46 -43
- package/socket/index.js +52 -69
- package/socket/ipcServer.js +80 -94
- package/socket/socketServer.js +31 -24
- package/storage/index.js +5 -37
- package/storage/sqliteStorage.js +18 -18
- package/utils/extend.js +10 -5
- package/utils/helper.js +38 -42
- package/utils/index.js +40 -23
- package/utils/ip.js +5 -45
- package/utils/is.js +107 -141
- package/utils/json.js +15 -7
- package/utils/pargv.js +5 -1
- package/utils/{get-port → port}/index.js +4 -26
- package/utils/wrap.js +8 -3
- package/addon/index.js +0 -35
- package/addon/window/index.js +0 -99
- package/bin/tools.js +0 -8
- package/config/cache.js +0 -62
- package/config/config.default.js +0 -331
- package/controller/baseContextClass.js +0 -25
- package/core/lib/ee.js +0 -216
- package/core/lib/loader/context_loader.js +0 -106
- package/core/lib/loader/ee_loader.js +0 -435
- package/core/lib/loader/mixin/addon.js +0 -32
- package/core/lib/loader/mixin/config.js +0 -130
- package/core/lib/loader/mixin/controller.js +0 -125
- package/core/lib/loader/mixin/service.js +0 -28
- package/core/lib/utils/base_context_class.js +0 -34
- package/core/lib/utils/function.js +0 -30
- package/core/lib/utils/index.js +0 -133
- package/core/lib/utils/sequencify.js +0 -59
- package/ee/appLoader.js +0 -48
- package/ee/application.js +0 -101
- package/ee/baseApp.js +0 -99
- package/ee/eeApp.js +0 -406
- package/ee/index.js +0 -58
- package/electron/window/winState.js +0 -186
- package/httpclient/index.js +0 -161
- package/jobs/baseJobClass.js +0 -16
- package/jobs/renderer/index.js +0 -141
- package/jobs/renderer/loadView.js +0 -41
- package/jobs/unification.js +0 -64
- package/main/index.js +0 -57
- package/old-utils/index.js +0 -91
- package/services/baseContextClass.js +0 -24
- package/services/index.js +0 -41
- package/socket/io.js +0 -28
- package/storage/jsondb/adapters/Base.js +0 -23
- package/storage/jsondb/adapters/FileSync.js +0 -64
- package/storage/jsondb/main.js +0 -55
- package/storage/jsondbStorage.js +0 -196
- package/utils/co.js +0 -237
- package/utils/copyto.js +0 -161
- package/utils/depd/index.js +0 -538
- package/utils/depd/lib/browser/index.js +0 -77
- package/utils/get-port/index.d.ts +0 -64
- package/utils/time/index.js +0 -20
- package/utils/time/ms.js +0 -162
package/electron/window/index.js
CHANGED
|
@@ -1,74 +1,269 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('ee-core:electron:window');
|
|
1
4
|
const is = require('is-type-of');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const axios = require('axios');
|
|
7
|
+
const { BrowserWindow } = require('electron');
|
|
8
|
+
const { getConfig } = require('../../config');
|
|
9
|
+
const { eventBus, WindowReady } = require('../../app/events');
|
|
10
|
+
const { env, isDev, getBaseDir } = require('../../ps');
|
|
11
|
+
const { loadFile } = require('../../loader');
|
|
12
|
+
const { isFileProtocol } = require('../../utils');
|
|
13
|
+
const { getHtmlFilepath } = require('../../html');
|
|
14
|
+
const { fileIsExist, sleep } = require('../../utils/helper');
|
|
15
|
+
const { coreLogger } = require('../../log');
|
|
16
|
+
const { extend } = require('../../utils/extend');
|
|
17
|
+
const { cross } = require('../../cross');
|
|
18
|
+
|
|
19
|
+
const Instance = {
|
|
20
|
+
mainWindow: null,
|
|
21
|
+
closeAndQuit: true,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// getMainWindow
|
|
25
|
+
function getMainWindow() {
|
|
26
|
+
return Instance.mainWindow;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Create the main application window
|
|
30
|
+
function createMainWindow() {
|
|
31
|
+
const { openDevTools, windowsOption } = getConfig();
|
|
32
|
+
const win = new BrowserWindow(windowsOption);
|
|
33
|
+
Instance.mainWindow = win;
|
|
16
34
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this[EEMainWindow] = win;
|
|
36
|
-
|
|
37
|
-
// 菜单显示/隐藏
|
|
38
|
-
if (config.openAppMenu === 'dev-show' && Ps.isProd()) {
|
|
39
|
-
Menu.setApplicationMenu(null);
|
|
40
|
-
} else if (config.openAppMenu === false) {
|
|
41
|
-
Menu.setApplicationMenu(null);
|
|
42
|
-
} else {
|
|
43
|
-
// nothing
|
|
35
|
+
// DevTools
|
|
36
|
+
if (is.object(openDevTools)) {
|
|
37
|
+
win.webContents.openDevTools(openDevTools);
|
|
38
|
+
} else if (openDevTools === true) {
|
|
39
|
+
win.webContents.openDevTools({
|
|
40
|
+
mode: 'bottom'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
eventBus.emitLifecycle(WindowReady);
|
|
45
|
+
return win;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// restored window
|
|
49
|
+
function restoreMainWindow() {
|
|
50
|
+
if (Instance.mainWindow) {
|
|
51
|
+
if (Instance.mainWindow.isMinimized()) {
|
|
52
|
+
Instance.mainWindow.restore();
|
|
44
53
|
}
|
|
54
|
+
Instance.mainWindow.show();
|
|
55
|
+
Instance.mainWindow.focus();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
// Set the flag for exiting after close all windows
|
|
60
|
+
function setCloseAndQuit(flag) {
|
|
61
|
+
Instance.closeAndQuit = flag;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getCloseAndQuit() {
|
|
65
|
+
return Instance.closeAndQuit;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// load server
|
|
69
|
+
// type: remote | single
|
|
70
|
+
async function loadServer() {
|
|
71
|
+
let type = 'spa';
|
|
72
|
+
let url = '';
|
|
73
|
+
const { remote, mainServer } = getConfig();
|
|
74
|
+
const win = getMainWindow();
|
|
75
|
+
|
|
76
|
+
// remote model
|
|
77
|
+
if (remote.enable == true) {
|
|
78
|
+
type = 'remote';
|
|
79
|
+
url = remote.url;
|
|
80
|
+
loadMainUrl(type, url);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 开发环境
|
|
85
|
+
if (isDev()) {
|
|
86
|
+
let url;
|
|
87
|
+
let load = 'url';
|
|
88
|
+
|
|
89
|
+
const binFile = path.join(getBaseDir(), "./cmd/bin.js");
|
|
90
|
+
const binConfig = loadFile(binFile);
|
|
91
|
+
const { dev } = binConfig;
|
|
92
|
+
// tips: match with ee-bin
|
|
93
|
+
const frontendConf = extend(true, {
|
|
94
|
+
protocol: 'http://',
|
|
95
|
+
hostname: 'localhost',
|
|
96
|
+
port: 8080,
|
|
97
|
+
indexPath: 'index.html',
|
|
98
|
+
}, dev.frontend);
|
|
99
|
+
const electronConf = extend(true, {
|
|
100
|
+
loadingPage: '/public/html/loading.html',
|
|
101
|
+
}, dev.electron);
|
|
102
|
+
|
|
103
|
+
url = frontendConf.protocol + frontendConf.hostname + ':' + frontendConf.port;
|
|
104
|
+
if (isFileProtocol(frontendConf.protocol)) {
|
|
105
|
+
url = path.join(getBaseDir(), frontendConf.directory, frontendConf.indexPath);
|
|
106
|
+
load = 'file';
|
|
55
107
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
108
|
+
|
|
109
|
+
// Check if UI serve is started, load a boot page first
|
|
110
|
+
if (load == 'url') {
|
|
111
|
+
// loading page
|
|
112
|
+
let lp = getHtmlFilepath('boot.html');
|
|
113
|
+
if (electronConf.hasOwnProperty('loadingPage') && electronConf.loadingPage != '') {
|
|
114
|
+
lp = path.join(getBaseDir(), electronConf.loadingPage);
|
|
115
|
+
}
|
|
116
|
+
_loadingPage(lp);
|
|
117
|
+
|
|
118
|
+
// check frontend is ready
|
|
119
|
+
const retryTimes = frontendConf.force === true ? 3 : 60;
|
|
120
|
+
let count = 0;
|
|
121
|
+
let frontendReady = false;
|
|
122
|
+
while(!frontendReady && count < retryTimes){
|
|
123
|
+
await sleep(1 * 1000);
|
|
124
|
+
try {
|
|
125
|
+
await axios({
|
|
126
|
+
method: 'get',
|
|
127
|
+
url,
|
|
128
|
+
timeout: 1000,
|
|
129
|
+
proxy: false,
|
|
130
|
+
headers: {
|
|
131
|
+
'Accept': 'text/html, application/json, text/plain, */*',
|
|
132
|
+
},
|
|
133
|
+
//responseType: 'text',
|
|
134
|
+
});
|
|
135
|
+
frontendReady = true;
|
|
136
|
+
} catch(err) {
|
|
137
|
+
// console.warn(err.stack)
|
|
138
|
+
}
|
|
139
|
+
count++;
|
|
140
|
+
}
|
|
141
|
+
debug('it takes %d seconds to start the frontend', count);
|
|
142
|
+
|
|
143
|
+
if (frontendReady == false && frontendConf.force !== true) {
|
|
144
|
+
const bootFailurePage = getHtmlFilepath('failure.html');
|
|
145
|
+
win.loadFile(bootFailurePage);
|
|
146
|
+
coreLogger.error(`[ee-core] Please check the ${url} !`);
|
|
147
|
+
return;
|
|
67
148
|
}
|
|
68
|
-
this[EEMainWindow].show();
|
|
69
|
-
this[EEMainWindow].focus();
|
|
70
149
|
}
|
|
150
|
+
|
|
151
|
+
loadMainUrl(type, url, load);
|
|
152
|
+
return;
|
|
71
153
|
}
|
|
72
|
-
};
|
|
73
154
|
|
|
74
|
-
|
|
155
|
+
// 生产环境
|
|
156
|
+
// cross takeover web
|
|
157
|
+
if (mainServer.takeover.length > 0) {
|
|
158
|
+
await crossTakeover()
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 主进程
|
|
163
|
+
url = path.join(getBaseDir(), mainServer.indexPath);
|
|
164
|
+
loadMainUrl(type, url, 'file');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 主服务
|
|
169
|
+
* @params load <string> value: "url" 、 "file"
|
|
170
|
+
*/
|
|
171
|
+
function loadMainUrl(type, url, load = 'url') {
|
|
172
|
+
const { mainServer } = getConfig();
|
|
173
|
+
const mainWindow = getMainWindow();
|
|
174
|
+
coreLogger.info('[ee-core] Env: %s, Type: %s', env(), type);
|
|
175
|
+
coreLogger.info('[ee-core] App running at: %s', url);
|
|
176
|
+
if (load == 'file') {
|
|
177
|
+
mainWindow.loadFile(url, mainServer.options)
|
|
178
|
+
.then()
|
|
179
|
+
.catch((err)=>{
|
|
180
|
+
coreLogger.error(`[ee-core] Please check the ${url} !`);
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
mainWindow.loadURL(url, mainServer.options)
|
|
184
|
+
.then()
|
|
185
|
+
.catch((err)=>{
|
|
186
|
+
coreLogger.error(`[ee-core] Please check the ${url} !`);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// loading page
|
|
192
|
+
function _loadingPage(name) {
|
|
193
|
+
if (!fileIsExist(name)) {
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
const win = getMainWindow();
|
|
197
|
+
win.loadFile(name);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* cross takeover web
|
|
202
|
+
*/
|
|
203
|
+
async function crossTakeover() {
|
|
204
|
+
const crossConf = getConfig().cross;
|
|
205
|
+
const mainConf = getConfig().mainServer;
|
|
206
|
+
|
|
207
|
+
// loading page
|
|
208
|
+
if (mainConf.loadingPage.length > 0) {
|
|
209
|
+
const lp = path.join(getBaseDir, mainConf.loadingPage);
|
|
210
|
+
_loadingPage(lp);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// cross service url
|
|
214
|
+
const service = mainConf.takeover;
|
|
215
|
+
if (!crossConf.hasOwnProperty(service)) {
|
|
216
|
+
throw new Error(`[ee-core] Please Check the value of mainServer.takeover in the config file !`);
|
|
217
|
+
}
|
|
218
|
+
// check service
|
|
219
|
+
if (crossConf[service].enable != true) {
|
|
220
|
+
throw new Error(`[ee-core] Please Check the value of cross.${service} enable is true !`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const entityName = crossConf[service].name;
|
|
224
|
+
const url = cross.getUrl(entityName);
|
|
225
|
+
|
|
226
|
+
// 循环检查
|
|
227
|
+
let count = 0;
|
|
228
|
+
let serviceReady = false;
|
|
229
|
+
const times = isDev() ? 20 : 100;
|
|
230
|
+
const sleeptime = isDev() ? 1000 : 200;
|
|
231
|
+
while(!serviceReady && count < times){
|
|
232
|
+
await sleep(sleeptime);
|
|
233
|
+
try {
|
|
234
|
+
await axios({
|
|
235
|
+
method: 'get',
|
|
236
|
+
url,
|
|
237
|
+
timeout: 100,
|
|
238
|
+
proxy: false,
|
|
239
|
+
headers: {
|
|
240
|
+
'Accept': 'text/html, application/json, text/plain, */*',
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
serviceReady = true;
|
|
244
|
+
} catch(err) {
|
|
245
|
+
// console.warn(err.stack)
|
|
246
|
+
}
|
|
247
|
+
count++;
|
|
248
|
+
}
|
|
249
|
+
debug('it takes %d seconds to start the cross serivce', count * sleeptime);
|
|
250
|
+
|
|
251
|
+
if (serviceReady == false) {
|
|
252
|
+
const bootFailurePage = getHtmlFilepath('cross-failure.html');
|
|
253
|
+
const mainWindow = getMainWindow();
|
|
254
|
+
mainWindow.loadFile(bootFailurePage);
|
|
255
|
+
throw new Error(`[ee-core] Please check cross service [${service}] ${url} !`)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
coreLogger.info(`[ee-core] cross service [${service}] is started successfully`);
|
|
259
|
+
loadMainUrl('spa', url);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
module.exports = {
|
|
263
|
+
getMainWindow,
|
|
264
|
+
createMainWindow,
|
|
265
|
+
restoreMainWindow,
|
|
266
|
+
setCloseAndQuit,
|
|
267
|
+
getCloseAndQuit,
|
|
268
|
+
loadServer
|
|
269
|
+
};
|
package/exception/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { coreLogger } = require('../log');
|
|
4
|
+
const { isForkedChild, isRenderer, isDev, isMain } = require('../ps');
|
|
5
|
+
const { getConfig } = require('../config');
|
|
6
|
+
const { childMessage } = require('../message');
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* 捕获异常
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
function loadException() {
|
|
12
|
+
uncaughtExceptionHandler();
|
|
13
|
+
unhandledRejectionHandler();
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* 当进程上抛出异常而没有被捕获时触发该事件,并且使异常静默。
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
function uncaughtExceptionHandler() {
|
|
18
20
|
process.on('uncaughtException', function(err) {
|
|
19
21
|
if (!(err instanceof Error)) {
|
|
20
22
|
err = new Error(String(err));
|
|
@@ -24,7 +26,7 @@ exports.uncaughtExceptionHandler = function() {
|
|
|
24
26
|
err.name = 'unhandledExceptionError';
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
coreLogger.error(err);
|
|
28
30
|
|
|
29
31
|
_devError(err);
|
|
30
32
|
|
|
@@ -35,21 +37,20 @@ exports.uncaughtExceptionHandler = function() {
|
|
|
35
37
|
/**
|
|
36
38
|
* 当进程上抛出异常而没有被捕获时触发该事件。
|
|
37
39
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// });
|
|
40
|
+
function uncaughtExceptionMonitorHandler() {
|
|
41
|
+
process.on('uncaughtExceptionMonitor', function(err, origin) {
|
|
42
|
+
if (!(err instanceof Error)) {
|
|
43
|
+
err = new Error(String(err));
|
|
44
|
+
}
|
|
45
|
+
coreLogger.error('uncaughtExceptionMonitor:',err);
|
|
46
|
+
});
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* 当promise中reject的异常在同步任务中没有使用catch捕获就会触发该事件,
|
|
50
51
|
* 即便是在异步情况下使用了catch也会触发该事件
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
function unhandledRejectionHandler() {
|
|
53
54
|
process.on('unhandledRejection', function(err) {
|
|
54
55
|
if (!(err instanceof Error)) {
|
|
55
56
|
const newError = new Error(String(err));
|
|
@@ -64,11 +65,8 @@ exports.unhandledRejectionHandler = function() {
|
|
|
64
65
|
if (err.name === 'Error') {
|
|
65
66
|
err.name = 'unhandledRejectionError';
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
-
Log.coreLogger.error(err);
|
|
69
|
-
|
|
68
|
+
coreLogger.error(err);
|
|
70
69
|
_devError(err);
|
|
71
|
-
|
|
72
70
|
_exit();
|
|
73
71
|
});
|
|
74
72
|
}
|
|
@@ -77,8 +75,8 @@ exports.unhandledRejectionHandler = function() {
|
|
|
77
75
|
* 如果是子进程,发送错误到主进程控制台
|
|
78
76
|
*/
|
|
79
77
|
function _devError (err) {
|
|
80
|
-
if (
|
|
81
|
-
|
|
78
|
+
if (isForkedChild() && isDev()) {
|
|
79
|
+
childMessage.sendErrorToTerminal(err);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
|
|
@@ -86,16 +84,13 @@ function _devError (err) {
|
|
|
86
84
|
* 捕获异常后是否退出
|
|
87
85
|
*/
|
|
88
86
|
function _exit () {
|
|
89
|
-
|
|
90
|
-
if (!cfg) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
87
|
+
const { mainExit, childExit, rendererExit } = getConfig().exception;
|
|
93
88
|
|
|
94
|
-
if (
|
|
89
|
+
if (isMain() && mainExit == true) {
|
|
95
90
|
_delayExit();
|
|
96
|
-
} else if (
|
|
91
|
+
} else if (isForkedChild() && childExit == true) {
|
|
97
92
|
_delayExit();
|
|
98
|
-
} else if (
|
|
93
|
+
} else if (isRenderer() && rendererExit == true) {
|
|
99
94
|
_delayExit();
|
|
100
95
|
} else {
|
|
101
96
|
// other
|
|
@@ -110,4 +105,11 @@ function _delayExit() {
|
|
|
110
105
|
setTimeout(() => {
|
|
111
106
|
process.exit();
|
|
112
107
|
}, 1500)
|
|
113
|
-
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = {
|
|
111
|
+
loadException,
|
|
112
|
+
uncaughtExceptionHandler,
|
|
113
|
+
unhandledRejectionHandler,
|
|
114
|
+
uncaughtExceptionMonitorHandler
|
|
115
|
+
};
|
package/html/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getFilepath(name){
|
|
8
|
-
const pagePath = path.join(__dirname, name);
|
|
9
|
-
return pagePath;
|
|
10
|
-
},
|
|
11
|
-
|
|
3
|
+
// Html
|
|
4
|
+
function getHtmlFilepath(name){
|
|
5
|
+
const pagePath = path.join(__dirname, name);
|
|
6
|
+
return pagePath;
|
|
12
7
|
}
|
|
13
8
|
|
|
14
|
-
module.exports =
|
|
9
|
+
module.exports = {
|
|
10
|
+
getHtmlFilepath
|
|
11
|
+
};
|
package/index.js
CHANGED
|
@@ -1,55 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* @namespace EeCore
|
|
3
|
-
*/
|
|
1
|
+
'use strict';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
* @member {ElectronEgg} EeCore#Index
|
|
7
|
-
* @since 1.0.0
|
|
8
|
-
*/
|
|
9
|
-
const ElectronEgg = require('./main');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @member {app} EeCore#app
|
|
13
|
-
* @since 1.0.0
|
|
14
|
-
*/
|
|
15
|
-
const EE = require('./ee');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @member {Controller} EeCore#Controller
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
const Controller = require('./controller/baseContextClass');
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @member {Service} EeCore#Service
|
|
25
|
-
* @since 1.0.0
|
|
26
|
-
*/
|
|
27
|
-
const Service = require('./services/baseContextClass');
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @member {Storage}
|
|
31
|
-
* @since 1.0.0
|
|
32
|
-
*/
|
|
33
|
-
const Storage = require('./storage');
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @member {Utils}
|
|
37
|
-
* @since 1.0.0
|
|
38
|
-
*/
|
|
39
|
-
const Utils = require('./old-utils');
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @member {Socket}
|
|
43
|
-
* @since 1.0.0
|
|
44
|
-
*/
|
|
45
|
-
const Socket = require('./socket');
|
|
3
|
+
const { ElectronEgg } = require('./app');
|
|
46
4
|
|
|
47
5
|
module.exports = {
|
|
48
|
-
ElectronEgg
|
|
49
|
-
|
|
50
|
-
Controller,
|
|
51
|
-
Service,
|
|
52
|
-
Storage,
|
|
53
|
-
Socket,
|
|
54
|
-
Utils
|
|
55
|
-
};
|
|
6
|
+
ElectronEgg
|
|
7
|
+
}
|
package/jobs/child/app.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
const is = require('is-type-of');
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
const { loadException } = require('ee-core/exception');
|
|
4
|
+
const { requireFile } = require('ee-core/loader');
|
|
5
|
+
const { coreLogger } = require('ee-core/log');
|
|
6
|
+
const { isBytecodeClass } = require('ee-core/core/utils');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
loadException();
|
|
9
9
|
const commands = ['run'];
|
|
10
10
|
|
|
11
11
|
class ChildApp {
|
|
@@ -20,7 +20,7 @@ class ChildApp {
|
|
|
20
20
|
_initEvents() {
|
|
21
21
|
process.on('message', this._handleMessage.bind(this));
|
|
22
22
|
process.once('exit', (code) => {
|
|
23
|
-
|
|
23
|
+
coreLogger.info(`[ee-core] [jobs/child] received a exit from main-process, code:${code}, pid:${process.pid}`);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -37,7 +37,7 @@ class ChildApp {
|
|
|
37
37
|
break;
|
|
38
38
|
default:
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
coreLogger.info(`[ee-core] [jobs/child] received a message from main-process, message: ${JSON.stringify(m)}`);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -45,8 +45,8 @@ class ChildApp {
|
|
|
45
45
|
*/
|
|
46
46
|
run(msg = {}) {
|
|
47
47
|
const {jobPath, jobParams, jobFunc, jobFuncParams} = msg;
|
|
48
|
-
let mod =
|
|
49
|
-
if (is.class(mod) ||
|
|
48
|
+
let mod = requireFile(jobPath);
|
|
49
|
+
if (is.class(mod) || isBytecodeClass(mod)) {
|
|
50
50
|
if (!this.jobMap.has(jobPath)) {
|
|
51
51
|
const instance = new mod(...jobParams);
|
|
52
52
|
instance.handle(...jobParams);
|
|
@@ -58,7 +58,7 @@ class ChildApp {
|
|
|
58
58
|
|
|
59
59
|
} else if (is.function(mod)) {
|
|
60
60
|
mod(jobParams);
|
|
61
|
-
}
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|