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/httpclient/index.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
const Agent = require('agentkeepalive');
|
|
2
|
-
const HttpsAgent = require('agentkeepalive').HttpsAgent;
|
|
3
|
-
const urllib = require('urllib');
|
|
4
|
-
const { FrameworkBaseError } = require('egg-errors');
|
|
5
|
-
const Conf = require('../config/cache');
|
|
6
|
-
const Log = require('../log');
|
|
7
|
-
const Time = require('../utils/time');
|
|
8
|
-
|
|
9
|
-
class HttpClientError extends FrameworkBaseError {
|
|
10
|
-
get module() {
|
|
11
|
-
return 'httpclient';
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class HttpClient extends urllib.HttpClient2 {
|
|
16
|
-
constructor(options = {}) {
|
|
17
|
-
|
|
18
|
-
if (Object.keys(options).length == 0) {
|
|
19
|
-
options = Conf.getValue('httpclient');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const config = Object.assign({
|
|
23
|
-
enableDNSCache: false,
|
|
24
|
-
dnsCacheLookupInterval: 10000,
|
|
25
|
-
dnsCacheMaxLength: 1000,
|
|
26
|
-
request: {
|
|
27
|
-
timeout: 5000,
|
|
28
|
-
},
|
|
29
|
-
httpAgent: {
|
|
30
|
-
keepAlive: true,
|
|
31
|
-
freeSocketTimeout: 4000,
|
|
32
|
-
maxSockets: Number.MAX_SAFE_INTEGER,
|
|
33
|
-
maxFreeSockets: 256,
|
|
34
|
-
},
|
|
35
|
-
httpsAgent: {
|
|
36
|
-
keepAlive: true,
|
|
37
|
-
freeSocketTimeout: 4000,
|
|
38
|
-
maxSockets: Number.MAX_SAFE_INTEGER,
|
|
39
|
-
maxFreeSockets: 256,
|
|
40
|
-
},
|
|
41
|
-
}, options);
|
|
42
|
-
|
|
43
|
-
normalizeConfig(config);
|
|
44
|
-
|
|
45
|
-
super({
|
|
46
|
-
defaultArgs: config.request,
|
|
47
|
-
agent: new Agent(config.httpAgent),
|
|
48
|
-
httpsAgent: new HttpsAgent(config.httpsAgent),
|
|
49
|
-
});
|
|
50
|
-
this.config = config;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
request(url, args, callback) {
|
|
54
|
-
if (typeof args === 'function') {
|
|
55
|
-
callback = args;
|
|
56
|
-
args = null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
args = args || {};
|
|
60
|
-
|
|
61
|
-
// the callback style
|
|
62
|
-
if (callback) {
|
|
63
|
-
//this.app.deprecate('[httpclient] We now support async for this function, so callback isn\'t recommended.');
|
|
64
|
-
super.request(url, args)
|
|
65
|
-
.then(result => process.nextTick(() => callback(null, result.data, result.res)))
|
|
66
|
-
.catch(err => process.nextTick(() => callback(err)));
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// the Promise style
|
|
71
|
-
return super.request(url, args)
|
|
72
|
-
.catch(err => {
|
|
73
|
-
if (err.code === 'ENETUNREACH') {
|
|
74
|
-
throw HttpClientError.create(err.message, err.code);
|
|
75
|
-
}
|
|
76
|
-
throw err;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
curl(url, args, callback) {
|
|
81
|
-
return this.request(url, args, callback);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
requestThunk(url, args) {
|
|
85
|
-
//this.app.deprecate('[httpclient] Please use `request()` instead of `requestThunk()`');
|
|
86
|
-
return callback => {
|
|
87
|
-
this.request(url, args, (err, data, res) => {
|
|
88
|
-
if (err) {
|
|
89
|
-
return callback(err);
|
|
90
|
-
}
|
|
91
|
-
callback(null, {
|
|
92
|
-
data,
|
|
93
|
-
status: res.status,
|
|
94
|
-
headers: res.headers,
|
|
95
|
-
res,
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function normalizeConfig(httpConfig) {
|
|
103
|
-
const config = httpConfig;
|
|
104
|
-
|
|
105
|
-
// compatibility
|
|
106
|
-
if (typeof config.keepAlive === 'boolean') {
|
|
107
|
-
config.httpAgent.keepAlive = config.keepAlive;
|
|
108
|
-
config.httpsAgent.keepAlive = config.keepAlive;
|
|
109
|
-
}
|
|
110
|
-
if (config.timeout) {
|
|
111
|
-
config.timeout = Time.ms(config.timeout);
|
|
112
|
-
config.httpAgent.timeout = config.timeout;
|
|
113
|
-
config.httpsAgent.timeout = config.timeout;
|
|
114
|
-
}
|
|
115
|
-
// compatibility httpclient.freeSocketKeepAliveTimeout => httpclient.freeSocketTimeout
|
|
116
|
-
if (config.freeSocketKeepAliveTimeout && !config.freeSocketTimeout) {
|
|
117
|
-
config.freeSocketTimeout = config.freeSocketKeepAliveTimeout;
|
|
118
|
-
delete config.freeSocketKeepAliveTimeout;
|
|
119
|
-
}
|
|
120
|
-
if (config.freeSocketTimeout) {
|
|
121
|
-
config.freeSocketTimeout = Time.ms(config.freeSocketTimeout);
|
|
122
|
-
config.httpAgent.freeSocketTimeout = config.freeSocketTimeout;
|
|
123
|
-
config.httpsAgent.freeSocketTimeout = config.freeSocketTimeout;
|
|
124
|
-
} else {
|
|
125
|
-
// compatibility agent.freeSocketKeepAliveTimeout
|
|
126
|
-
if (config.httpAgent.freeSocketKeepAliveTimeout && !config.httpAgent.freeSocketTimeout) {
|
|
127
|
-
config.httpAgent.freeSocketTimeout = config.httpAgent.freeSocketKeepAliveTimeout;
|
|
128
|
-
delete config.httpAgent.freeSocketKeepAliveTimeout;
|
|
129
|
-
}
|
|
130
|
-
if (config.httpsAgent.freeSocketKeepAliveTimeout && !config.httpsAgent.freeSocketTimeout) {
|
|
131
|
-
config.httpsAgent.freeSocketTimeout = config.httpsAgent.freeSocketKeepAliveTimeout;
|
|
132
|
-
delete config.httpsAgent.freeSocketKeepAliveTimeout;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (typeof config.maxSockets === 'number') {
|
|
137
|
-
config.httpAgent.maxSockets = config.maxSockets;
|
|
138
|
-
config.httpsAgent.maxSockets = config.maxSockets;
|
|
139
|
-
}
|
|
140
|
-
if (typeof config.maxFreeSockets === 'number') {
|
|
141
|
-
config.httpAgent.maxFreeSockets = config.maxFreeSockets;
|
|
142
|
-
config.httpsAgent.maxFreeSockets = config.maxFreeSockets;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (config.httpAgent.timeout < 30000) {
|
|
146
|
-
Log.coreLogger.warn('[ee-core] [httpclient] config.httpclient.httpAgent.timeout(%s) can\'t below 30000, auto reset to 30000',
|
|
147
|
-
config.httpAgent.timeout);
|
|
148
|
-
config.httpAgent.timeout = 30000;
|
|
149
|
-
}
|
|
150
|
-
if (config.httpsAgent.timeout < 30000) {
|
|
151
|
-
Log.coreLogger.warn('[ee-core] [httpclient] config.httpclient.httpsAgent.timeout(%s) can\'t below 30000, auto reset to 30000',
|
|
152
|
-
config.httpsAgent.timeout);
|
|
153
|
-
config.httpsAgent.timeout = 30000;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (typeof config.request.timeout === 'string') {
|
|
157
|
-
config.request.timeout = Time.ms(config.request.timeout);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
module.exports = HttpClient;
|
package/jobs/baseJobClass.js
DELETED
package/jobs/renderer/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
const { BrowserWindow } = require('electron');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const LoadView = require('./loadView');
|
|
4
|
-
const Loader = require('../../loader');
|
|
5
|
-
|
|
6
|
-
class RendererJob {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* constructor
|
|
10
|
-
* @param {String} name - job name
|
|
11
|
-
* @param {String} filepath - filepath to file
|
|
12
|
-
* @param {Object} options - options to create BrowserWindow
|
|
13
|
-
*/
|
|
14
|
-
constructor(name, filepath, opt = {}) {
|
|
15
|
-
// TODO Object.assign 只能单层对象结构,多层的对象会直接覆盖
|
|
16
|
-
let options = Object.assign({
|
|
17
|
-
show: false,
|
|
18
|
-
webPreferences: {
|
|
19
|
-
webSecurity: true,
|
|
20
|
-
nodeIntegration: true,
|
|
21
|
-
contextIsolation: false,
|
|
22
|
-
//enableRemoteModule: true
|
|
23
|
-
}
|
|
24
|
-
}, opt);
|
|
25
|
-
|
|
26
|
-
this.subWin = new BrowserWindow(options);
|
|
27
|
-
|
|
28
|
-
this.jobReady = false;
|
|
29
|
-
this.exec = Loader.getFullpath(filepath);;
|
|
30
|
-
this.name = name;
|
|
31
|
-
this.listeners = [];
|
|
32
|
-
this.callbacks = [];
|
|
33
|
-
this.fails = [];
|
|
34
|
-
this.id = this.subWin.id;
|
|
35
|
-
this.webSecurity = options.webPreferences.webSecurity;
|
|
36
|
-
|
|
37
|
-
// this.callbacks.push(() => {
|
|
38
|
-
// MessageChannel.registry(name, this.id, this.subWin.webContents.getOSProcessId());
|
|
39
|
-
// });
|
|
40
|
-
|
|
41
|
-
// job state listener
|
|
42
|
-
this.subWin.webContents.on('did-finish-load', this._didFinishLoad);
|
|
43
|
-
this.subWin.webContents.on('did-fail-load', this._didFailLoad);
|
|
44
|
-
|
|
45
|
-
// load job
|
|
46
|
-
this._loadJob(this.exec);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 显示开发者工具栏
|
|
51
|
-
*/
|
|
52
|
-
openDevTools() {
|
|
53
|
-
this.subWin.webContents.openDevTools({
|
|
54
|
-
mode: 'undocked'
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 窗口加载完成,即业务代码执行完毕
|
|
60
|
-
*/
|
|
61
|
-
_didFinishLoad = () => {
|
|
62
|
-
this.jobReady = true;
|
|
63
|
-
this.callbacks.forEach(callback => {
|
|
64
|
-
callback(this.id);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 窗口加载失败,即业务运行失败
|
|
70
|
-
*/
|
|
71
|
-
_didFailLoad = (error) => {
|
|
72
|
-
this.jobReady = false;
|
|
73
|
-
this.fails.forEach(handle => {
|
|
74
|
-
handle(error.toString());
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* 加载任务
|
|
81
|
-
*/
|
|
82
|
-
_loadJob(filepath) {
|
|
83
|
-
if (!this.webSecurity) {
|
|
84
|
-
this._loadURLUnsafe(filepath);
|
|
85
|
-
} else {
|
|
86
|
-
this._loadURLSafe(filepath);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 安全的脚本注入
|
|
92
|
-
*/
|
|
93
|
-
_loadURLSafe(filepath) {
|
|
94
|
-
return new Promise((resolve, reject) => {
|
|
95
|
-
fs.readFile(filepath, { encoding: 'utf-8' }, (err, buffer) => {
|
|
96
|
-
if (err) {
|
|
97
|
-
reject(err);
|
|
98
|
-
this._didFailLoad(err);
|
|
99
|
-
return console.error(err);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let param = {
|
|
103
|
-
webSecurity: true,
|
|
104
|
-
script: buffer.toString(),
|
|
105
|
-
title: `${this.name} job`,
|
|
106
|
-
base: filepath
|
|
107
|
-
}
|
|
108
|
-
const viewData = LoadView(param);
|
|
109
|
-
|
|
110
|
-
this.subWin.loadURL(viewData)
|
|
111
|
-
.then(resolve)
|
|
112
|
-
.catch(err => {
|
|
113
|
-
reject(err);
|
|
114
|
-
this._didFailLoad(err);
|
|
115
|
-
console.error(err);
|
|
116
|
-
});
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 不安全的脚本注入
|
|
123
|
-
*/
|
|
124
|
-
_loadURLUnsafe(filepath) {
|
|
125
|
-
let param = {
|
|
126
|
-
webSecurity: false,
|
|
127
|
-
src: this.exec,
|
|
128
|
-
title: `${this.name} job`,
|
|
129
|
-
base: filepath
|
|
130
|
-
}
|
|
131
|
-
const viewData = LoadView(param);
|
|
132
|
-
|
|
133
|
-
this.subWin.loadURL(viewData)
|
|
134
|
-
.catch(err => {
|
|
135
|
-
this._didFailLoad(err);
|
|
136
|
-
console.error(err);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
module.exports = RendererJob;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//require('bytenode');
|
|
2
|
-
const Ps = require('../../ps');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* loadView 生成BrowserWindow的html content
|
|
6
|
-
*/
|
|
7
|
-
const loadView = function (opt = {}) {
|
|
8
|
-
const webSecurity = opt.webSecurity;
|
|
9
|
-
const src = opt.src;
|
|
10
|
-
const title = opt.title;
|
|
11
|
-
const script = opt.script;
|
|
12
|
-
|
|
13
|
-
//const scriptUrl = new URL('eefile://' + src);
|
|
14
|
-
const scriptUrl = 'eefile://' + src;
|
|
15
|
-
console.log('[ee-core:job] scriptUrl: ', scriptUrl);
|
|
16
|
-
|
|
17
|
-
// 脚本内容
|
|
18
|
-
//const scriptBytenode = Ps.isDev() ? '' : `<script> require('bytenode') </script>`;
|
|
19
|
-
const scriptContent = webSecurity ? `<script> ${ script } </script>` : `<script src='${scriptUrl}'></script>`;
|
|
20
|
-
|
|
21
|
-
// html内容
|
|
22
|
-
const htmlContent = (`
|
|
23
|
-
<!DOCTYPE html>
|
|
24
|
-
<html>
|
|
25
|
-
<head>
|
|
26
|
-
<title>${title}</title>
|
|
27
|
-
<meta charset="UTF-8">
|
|
28
|
-
</head>
|
|
29
|
-
<body>
|
|
30
|
-
${scriptContent}
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|
|
33
|
-
`);
|
|
34
|
-
|
|
35
|
-
const DataURI = 'data:text/html;charset=UTF-8,';
|
|
36
|
-
const data = DataURI + encodeURIComponent(htmlContent);
|
|
37
|
-
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
module.exports = loadView;
|
package/jobs/unification.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const RendererJob = require('./renderer');
|
|
4
|
-
const ChildJob = require('./child/pool');
|
|
5
|
-
const Ps = require('../ps');
|
|
6
|
-
const Loader = require('../loader');
|
|
7
|
-
|
|
8
|
-
class Jobs {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.type;
|
|
11
|
-
this.dev;
|
|
12
|
-
this.path;
|
|
13
|
-
this.instance;
|
|
14
|
-
this.child;
|
|
15
|
-
this.childOptions;
|
|
16
|
-
this.renderer;
|
|
17
|
-
this.winOptions;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 创建 job
|
|
22
|
-
*/
|
|
23
|
-
create (name, opt = {}) {
|
|
24
|
-
this.type = opt.type || 'child';
|
|
25
|
-
this.dev = opt.dev || false;
|
|
26
|
-
this.winOptions = opt.winOptions || {};
|
|
27
|
-
this.childOptions = opt.childOptions || {};
|
|
28
|
-
this.path = opt.path || null;
|
|
29
|
-
|
|
30
|
-
const isAbsolute = path.isAbsolute(this.path);
|
|
31
|
-
if (!isAbsolute) {
|
|
32
|
-
this.path = path.join(Ps.getBaseDir(), this.path);
|
|
33
|
-
}
|
|
34
|
-
const filepath = Loader.resolveModule(this.path);
|
|
35
|
-
|
|
36
|
-
if (!fs.existsSync(filepath)) {
|
|
37
|
-
throw new Error(`[ee-core] [jobs-create] file ${this.path} not exists`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.path = filepath;
|
|
41
|
-
if (this.type == 'child') {
|
|
42
|
-
this.instance = new ChildJob(name, filepath, this.childOptions);
|
|
43
|
-
this.child = this.instance;
|
|
44
|
-
} else if (this.type == 'renderer') {
|
|
45
|
-
this.instance = new RendererJob(name, filepath, this.winOptions);
|
|
46
|
-
this.renderer = this.instance;
|
|
47
|
-
|
|
48
|
-
if (this.dev) {
|
|
49
|
-
this.openDevTools();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 显示开发者工具栏(仅支持 RendererJob)
|
|
58
|
-
*/
|
|
59
|
-
openDevTools () {
|
|
60
|
-
this.instance.openDevTools();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
module.exports = Jobs;
|
package/main/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const { app } = require('electron');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const Utils = require('../utils');
|
|
5
|
-
const Ps = require('../ps');
|
|
6
|
-
const EE = require('../ee');
|
|
7
|
-
const UtilsCore = require('../core/lib/utils');
|
|
8
|
-
const Loader = require('../loader');
|
|
9
|
-
const UtilsPargv = require('../utils/pargv');
|
|
10
|
-
|
|
11
|
-
class ElectronEgg {
|
|
12
|
-
|
|
13
|
-
constructor(mode) {
|
|
14
|
-
this.mode = mode || 'framework';
|
|
15
|
-
this._create();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* create ElectronEgg app
|
|
20
|
-
*/
|
|
21
|
-
_create() {
|
|
22
|
-
if (!Ps.verifyMode(this.mode)) {
|
|
23
|
-
throw new Error(`The mode supports only (framework | module) !`);
|
|
24
|
-
}
|
|
25
|
-
Ps.initMode(this.mode);
|
|
26
|
-
|
|
27
|
-
// env 可能为空
|
|
28
|
-
const argsObj = UtilsPargv(process.argv);
|
|
29
|
-
let isDev = false;
|
|
30
|
-
if ( argsObj['env'] == 'development' || argsObj['env'] === 'dev' || argsObj['env'] === 'local' ) {
|
|
31
|
-
isDev = true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// module mode
|
|
35
|
-
if (Ps.isModuleMode()) {
|
|
36
|
-
const { Application } = EE;
|
|
37
|
-
new Application();
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let baseDir = path.join(app.getAppPath(), 'electron');
|
|
42
|
-
if (!isDev && Utils.isEncrypt(app.getAppPath())) {
|
|
43
|
-
baseDir = Ps.getEncryptDir(app.getAppPath());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const indexFile = path.join(baseDir, 'index');
|
|
47
|
-
const indexModulePath = Loader.resolveModule(indexFile);
|
|
48
|
-
if (!fs.existsSync(indexModulePath)) {
|
|
49
|
-
throw new Error(`The ${indexFile} file does not exist`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const EEApp = UtilsCore.loadFile(indexModulePath);
|
|
53
|
-
EE.app = new EEApp();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = ElectronEgg;
|
package/old-utils/index.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 该模块不在增加新功能,请使用 /module/utils/index 模块
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const UtilsJson = require('../utils/json');
|
|
7
|
-
const UtilsPs = require('../ps');
|
|
8
|
-
const UtilsHelper = require('../utils/helper');
|
|
9
|
-
const Copy = require('../utils/copyto');
|
|
10
|
-
const Conf = require('../config');
|
|
11
|
-
const Channel = require('../const/channel');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* other module
|
|
15
|
-
*/
|
|
16
|
-
Copy(UtilsPs)
|
|
17
|
-
.and(UtilsHelper)
|
|
18
|
-
.to(exports);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 获取项目根目录package.json
|
|
22
|
-
*/
|
|
23
|
-
exports.getPackage = function() {
|
|
24
|
-
const json = UtilsJson.readSync(path.join(this.getHomeDir(), 'package.json'));
|
|
25
|
-
|
|
26
|
-
return json;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 获取 ee配置
|
|
31
|
-
*/
|
|
32
|
-
exports.getEeConfig = function() {
|
|
33
|
-
const config = Conf.all();
|
|
34
|
-
|
|
35
|
-
return config;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 获取 app version
|
|
40
|
-
*/
|
|
41
|
-
exports.getAppVersion = function() {
|
|
42
|
-
const v = Conf.all().appVersion;
|
|
43
|
-
return v;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 获取 插件配置
|
|
48
|
-
*/
|
|
49
|
-
exports.getAddonConfig = function() {
|
|
50
|
-
const cfg = Conf.all().addons;
|
|
51
|
-
return cfg;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 获取 mainServer配置
|
|
56
|
-
*/
|
|
57
|
-
exports.getMainServerConfig = function() {
|
|
58
|
-
const cfg = Conf.all().mainServer;
|
|
59
|
-
return cfg;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 获取 httpServer配置
|
|
64
|
-
*/
|
|
65
|
-
exports.getHttpServerConfig = function() {
|
|
66
|
-
const cfg = Conf.all().httpServer;
|
|
67
|
-
return cfg;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 获取 socketServer配置
|
|
72
|
-
*/
|
|
73
|
-
exports.getSocketServerConfig = function() {
|
|
74
|
-
const cfg = Conf.all().socketServer;
|
|
75
|
-
return cfg;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 获取 socketio port
|
|
80
|
-
*/
|
|
81
|
-
exports.getSocketPort = function() {
|
|
82
|
-
const port = Conf.all().socketServer.port;
|
|
83
|
-
return parseInt(port);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 获取 socket channel
|
|
88
|
-
*/
|
|
89
|
-
exports.getSocketChannel = function() {
|
|
90
|
-
return Channel.socketIo.partySoftware;
|
|
91
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* BaseContextClass is a base class that can be extended,
|
|
5
|
-
*/
|
|
6
|
-
class BaseContextClass {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @class
|
|
10
|
-
* @param {Context} ctx - context instance
|
|
11
|
-
* @since 1.1.0
|
|
12
|
-
*/
|
|
13
|
-
constructor(ctx) {
|
|
14
|
-
|
|
15
|
-
// todo 兼容旧版本,后续废弃ctx
|
|
16
|
-
if (typeof ctx === 'object') {
|
|
17
|
-
this.app = ctx;
|
|
18
|
-
this.config = ctx.config;
|
|
19
|
-
this.service = ctx.service;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = BaseContextClass;
|
package/services/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const EE = require('../ee');
|
|
2
|
-
|
|
3
|
-
const Services = {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 获取 all addon instances
|
|
7
|
-
*/
|
|
8
|
-
all() {
|
|
9
|
-
const { CoreApp } = EE;
|
|
10
|
-
if (!CoreApp) {
|
|
11
|
-
throw new Error('An unknown error or Services cannot be used by the jobs!');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const instances = CoreApp.service || null;
|
|
15
|
-
if (!instances) {
|
|
16
|
-
throw new Error('Services not exists or do not call directly at the top!');
|
|
17
|
-
};
|
|
18
|
-
return instances;
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 获取 addon instance
|
|
23
|
-
*/
|
|
24
|
-
get(name) {
|
|
25
|
-
const instances = this.all();
|
|
26
|
-
|
|
27
|
-
const actions = name.split('.');
|
|
28
|
-
let obj = instances;
|
|
29
|
-
actions.forEach(key => {
|
|
30
|
-
obj = obj[key];
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (!obj) {
|
|
34
|
-
throw new Error(`Service class '${name}' not exists or do not call directly at the top!`);
|
|
35
|
-
};
|
|
36
|
-
return obj;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
module.exports = Services;
|
package/socket/io.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 该文件将废弃
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const IoServer = require('socket.io');
|
|
8
|
-
const IoClient = require('socket.io-client');
|
|
9
|
-
//const socketServer = require('./socketServer');
|
|
10
|
-
// const socketClient = require('./socketClient');
|
|
11
|
-
const Koa = require('koa');
|
|
12
|
-
|
|
13
|
-
const EeSocket = {
|
|
14
|
-
getServer: () => {
|
|
15
|
-
//return socketServer.getInstance();
|
|
16
|
-
},
|
|
17
|
-
getClient: () => {
|
|
18
|
-
//return socketClient.getInstance();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
IoServer,
|
|
25
|
-
IoClient,
|
|
26
|
-
EeSocket,
|
|
27
|
-
Koa
|
|
28
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
class Base {
|
|
2
|
-
constructor(source) {
|
|
3
|
-
this.source = source
|
|
4
|
-
this.defaultValue = {}
|
|
5
|
-
this.serialize = this._stringify
|
|
6
|
-
this.deserialize = JSON.parse
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
_canDeserialized(obj) {
|
|
10
|
-
try {
|
|
11
|
-
this.deserialize(obj)
|
|
12
|
-
return true
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return false
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_stringify(obj) {
|
|
19
|
-
return JSON.stringify(obj, null, 2)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = Base
|