ee-core 2.11.1 → 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 +66 -0
- package/config/default_config.js +110 -0
- package/config/index.js +21 -83
- 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 +9 -9
- 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 -144
- package/log/index.js +74 -57
- package/log/logger.js +76 -84
- package/message/childMessage.js +12 -13
- package/message/index.js +7 -16
- package/package.json +2 -2
- package/ps/index.js +137 -223
- 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 -42
- 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 -100
- package/ee/baseApp.js +0 -104
- package/ee/eeApp.js +0 -409
- 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/utils/helper.js
CHANGED
|
@@ -2,10 +2,9 @@ const fs = require('fs');
|
|
|
2
2
|
const mkdirp = require('mkdirp');
|
|
3
3
|
const convert = require('koa-convert');
|
|
4
4
|
const is = require('is-type-of');
|
|
5
|
-
const co = require('./co');
|
|
6
5
|
const path = require('path');
|
|
7
6
|
const chalk = require('chalk');
|
|
8
|
-
const
|
|
7
|
+
const { parseArgv } = require('./pargv');
|
|
9
8
|
|
|
10
9
|
const _basePath = process.cwd();
|
|
11
10
|
|
|
@@ -17,7 +16,7 @@ const _basePath = process.cwd();
|
|
|
17
16
|
* @param {Boolean} isImediate - 是否需要立即调用
|
|
18
17
|
* @param {type} args - 回调函数传入参数
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
function fnDebounce() {
|
|
21
20
|
const fnObject = {};
|
|
22
21
|
let timer;
|
|
23
22
|
|
|
@@ -43,25 +42,19 @@ exports.fnDebounce = function() {
|
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
exports.getRandomString = function() {
|
|
45
|
+
// 随机10位字符串
|
|
46
|
+
function getRandomString() {
|
|
50
47
|
return Math.random().toString(36).substring(2);
|
|
51
48
|
};
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*/
|
|
56
|
-
exports.mkdir = function(filepath, opt = {}) {
|
|
50
|
+
// 创建文件夹
|
|
51
|
+
function mkdir(filepath, opt = {}) {
|
|
57
52
|
mkdirp.sync(filepath, opt);
|
|
58
53
|
return
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*/
|
|
64
|
-
exports.chmodPath = function(path, mode) {
|
|
56
|
+
// 修改文件权限
|
|
57
|
+
function chmodPath(path, mode) {
|
|
65
58
|
let files = [];
|
|
66
59
|
if (fs.existsSync(path)) {
|
|
67
60
|
files = fs.readdirSync(path);
|
|
@@ -77,10 +70,8 @@ exports.chmodPath = function(path, mode) {
|
|
|
77
70
|
}
|
|
78
71
|
};
|
|
79
72
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*/
|
|
83
|
-
exports.compareVersion = function (v1, v2) {
|
|
73
|
+
// 版本号比较
|
|
74
|
+
function compareVersion(v1, v2) {
|
|
84
75
|
v1 = v1.split('.')
|
|
85
76
|
v2 = v2.split('.')
|
|
86
77
|
const len = Math.max(v1.length, v2.length)
|
|
@@ -106,24 +97,12 @@ exports.compareVersion = function (v1, v2) {
|
|
|
106
97
|
return 0
|
|
107
98
|
}
|
|
108
99
|
|
|
109
|
-
|
|
110
|
-
* 执行一个函数
|
|
111
|
-
*/
|
|
112
|
-
exports.callFn = async function (fn, args, ctx) {
|
|
113
|
-
args = args || [];
|
|
114
|
-
if (!is.function(fn)) return;
|
|
115
|
-
if (is.generatorFunction(fn)) fn = co.wrap(fn);
|
|
116
|
-
return ctx ? fn.call(ctx, ...args) : fn(...args);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.middleware = function (fn) {
|
|
100
|
+
function middleware(fn) {
|
|
120
101
|
return is.generatorFunction(fn) ? convert(fn) : fn;
|
|
121
102
|
}
|
|
122
103
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*/
|
|
126
|
-
exports.stringify = function(obj, ignore = []) {
|
|
104
|
+
// 序列化对象
|
|
105
|
+
function stringify(obj, ignore = []) {
|
|
127
106
|
const result = {};
|
|
128
107
|
Object.keys(obj).forEach(key => {
|
|
129
108
|
if (!ignore.includes(key)) {
|
|
@@ -136,7 +115,7 @@ exports.stringify = function(obj, ignore = []) {
|
|
|
136
115
|
/**
|
|
137
116
|
* 是否有效值
|
|
138
117
|
*/
|
|
139
|
-
|
|
118
|
+
function validValue(value) {
|
|
140
119
|
return (
|
|
141
120
|
value !== undefined &&
|
|
142
121
|
value !== null &&
|
|
@@ -144,7 +123,7 @@ exports.validValue = function(value) {
|
|
|
144
123
|
);
|
|
145
124
|
}
|
|
146
125
|
|
|
147
|
-
|
|
126
|
+
function checkConfig(prop) {
|
|
148
127
|
const filepath = path.join(_basePath, prop);
|
|
149
128
|
if (fs.existsSync(filepath)) {
|
|
150
129
|
return true;
|
|
@@ -153,7 +132,7 @@ exports.checkConfig = function(prop) {
|
|
|
153
132
|
return false;
|
|
154
133
|
}
|
|
155
134
|
|
|
156
|
-
|
|
135
|
+
function loadConfig(prop) {
|
|
157
136
|
const configFile = prop;
|
|
158
137
|
const filepath = path.join(_basePath, configFile);
|
|
159
138
|
if (!fs.existsSync(filepath)) {
|
|
@@ -171,11 +150,11 @@ exports.loadConfig = function(prop) {
|
|
|
171
150
|
return ret || {};
|
|
172
151
|
};
|
|
173
152
|
|
|
174
|
-
|
|
153
|
+
function sleep(ms) {
|
|
175
154
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
176
155
|
};
|
|
177
156
|
|
|
178
|
-
|
|
157
|
+
function replaceArgsValue(argv, key, value) {
|
|
179
158
|
key = key + "=";
|
|
180
159
|
for (let i = 0; i < argv.length; i++) {
|
|
181
160
|
let item = argv[i];
|
|
@@ -191,8 +170,8 @@ exports.replaceArgsValue = function(argv, key, value) {
|
|
|
191
170
|
return argv;
|
|
192
171
|
};
|
|
193
172
|
|
|
194
|
-
|
|
195
|
-
const argvObj =
|
|
173
|
+
function getValueFromArgv(argv, key) {
|
|
174
|
+
const argvObj = parseArgv(argv);
|
|
196
175
|
if (argvObj.hasOwnProperty(key)) {
|
|
197
176
|
return argvObj[key];
|
|
198
177
|
}
|
|
@@ -213,9 +192,26 @@ exports.getValueFromArgv = function(argv, key) {
|
|
|
213
192
|
return value;
|
|
214
193
|
};
|
|
215
194
|
|
|
216
|
-
|
|
195
|
+
function fileIsExist(filepath) {
|
|
217
196
|
if (fs.existsSync(filepath) && fs.statSync(filepath).isFile()) {
|
|
218
197
|
return true;
|
|
219
198
|
}
|
|
220
199
|
return false;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
module.exports = {
|
|
203
|
+
fnDebounce,
|
|
204
|
+
getRandomString,
|
|
205
|
+
mkdir,
|
|
206
|
+
chmodPath,
|
|
207
|
+
compareVersion,
|
|
208
|
+
middleware,
|
|
209
|
+
stringify,
|
|
210
|
+
validValue,
|
|
211
|
+
checkConfig,
|
|
212
|
+
loadConfig,
|
|
213
|
+
sleep,
|
|
214
|
+
replaceArgsValue,
|
|
215
|
+
getValueFromArgv,
|
|
216
|
+
fileIsExist
|
|
221
217
|
};
|
package/utils/index.js
CHANGED
|
@@ -5,8 +5,9 @@ const path = require('path');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const { exec, execSync } = require('child_process');
|
|
7
7
|
const { createHash } = require('crypto');
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const { getBaseDir } = require('../ps');
|
|
9
|
+
const { readSync } = require('./json');
|
|
10
|
+
const is = require('./is');
|
|
10
11
|
|
|
11
12
|
// machine id
|
|
12
13
|
const { platform } = process;
|
|
@@ -16,7 +17,7 @@ const win32RegBinPath = {
|
|
|
16
17
|
};
|
|
17
18
|
const MachineGuid = {
|
|
18
19
|
darwin: 'ioreg -rd1 -c IOPlatformExpertDevice',
|
|
19
|
-
win32: `${win32RegBinPath[
|
|
20
|
+
win32: `${win32RegBinPath[_isWindowsProcessMixedOrNativeArchitecture()]}\\REG.exe ` +
|
|
20
21
|
'QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography ' +
|
|
21
22
|
'/v MachineGuid',
|
|
22
23
|
linux: '( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :',
|
|
@@ -26,8 +27,8 @@ const MachineGuid = {
|
|
|
26
27
|
/**
|
|
27
28
|
* 获取项目根目录package.json
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
-
const json =
|
|
30
|
+
function getPackage() {
|
|
31
|
+
const json = readSync(path.join(getBaseDir(), 'package.json'));
|
|
31
32
|
|
|
32
33
|
return json;
|
|
33
34
|
};
|
|
@@ -36,7 +37,7 @@ exports.getPackage = function() {
|
|
|
36
37
|
* Get the first proper MAC address
|
|
37
38
|
* @param iface If provided, restrict MAC address fetching to this interface
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
function getMAC(iface) {
|
|
40
41
|
const zeroRegex = /(?:[0]{1,2}[:-]){5}[0]{1,2}/;
|
|
41
42
|
const list = os.networkInterfaces();
|
|
42
43
|
if (iface) {
|
|
@@ -70,17 +71,23 @@ exports.getMAC = function(iface) {
|
|
|
70
71
|
/**
|
|
71
72
|
* Check if the input is a valid MAC address
|
|
72
73
|
*/
|
|
73
|
-
|
|
74
|
+
function isMAC(macAddress) {
|
|
74
75
|
const macRegex = /(?:[a-z0-9]{1,2}[:-]){5}[a-z0-9]{1,2}/i;
|
|
75
76
|
return macRegex.test(macAddress);
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
function isFileProtocol(protocol) {
|
|
80
|
+
return protocol == 'file://';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isWebProtocol(protocol) {
|
|
84
|
+
return ['http://', 'https://'].includes(protocol);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isJsProject(baseDir) {
|
|
88
|
+
const entryFile1 = path.join(baseDir, 'electron/main.js');
|
|
89
|
+
const entryFile2 = path.join(baseDir, 'electron/index.js');
|
|
90
|
+
if (fs.existsSync(entryFile1) || fs.existsSync(entryFile2)) {
|
|
84
91
|
return true;
|
|
85
92
|
}
|
|
86
93
|
return false;
|
|
@@ -89,16 +96,16 @@ exports.isEncrypt = function(basePath) {
|
|
|
89
96
|
/**
|
|
90
97
|
* get machine id
|
|
91
98
|
*/
|
|
92
|
-
|
|
93
|
-
let id =
|
|
94
|
-
return original ? id :
|
|
99
|
+
function machineIdSync(original) {
|
|
100
|
+
let id = _expose(execSync(MachineGuid[platform]).toString());
|
|
101
|
+
return original ? id : _hash(id);
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
/**
|
|
98
105
|
* get machine id (promise)
|
|
99
106
|
* original <Boolean>, If true return original value of machine id, otherwise return hashed value (sha-256), default: false
|
|
100
107
|
*/
|
|
101
|
-
|
|
108
|
+
function machineId(original) {
|
|
102
109
|
return new Promise((resolve, reject) => {
|
|
103
110
|
return exec(MachineGuid[platform], {}, (err, stdout, stderr) => {
|
|
104
111
|
if (err) {
|
|
@@ -106,13 +113,13 @@ exports.machineId = function(original) {
|
|
|
106
113
|
new Error(`Error while obtaining machine id: ${err.stack}`)
|
|
107
114
|
);
|
|
108
115
|
}
|
|
109
|
-
let id =
|
|
110
|
-
return resolve(original ? id :
|
|
116
|
+
let id = _expose(stdout.toString());
|
|
117
|
+
return resolve(original ? id : _hash(id));
|
|
111
118
|
});
|
|
112
119
|
});
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
function
|
|
122
|
+
function _isWindowsProcessMixedOrNativeArchitecture() {
|
|
116
123
|
// detect if the node binary is the same arch as the Windows OS.
|
|
117
124
|
// or if this is 32 bit node on 64 bit windows.
|
|
118
125
|
if(process.platform !== 'win32') {
|
|
@@ -124,11 +131,11 @@ function isWindowsProcessMixedOrNativeArchitecture() {
|
|
|
124
131
|
return 'native';
|
|
125
132
|
}
|
|
126
133
|
|
|
127
|
-
function
|
|
134
|
+
function _hash(guid) {
|
|
128
135
|
return createHash('sha256').update(guid).digest('hex');
|
|
129
136
|
}
|
|
130
137
|
|
|
131
|
-
function
|
|
138
|
+
function _expose(result) {
|
|
132
139
|
switch (platform) {
|
|
133
140
|
case 'darwin':
|
|
134
141
|
return result
|
|
@@ -156,5 +163,15 @@ function expose(result) {
|
|
|
156
163
|
}
|
|
157
164
|
}
|
|
158
165
|
|
|
159
|
-
|
|
166
|
+
module.exports = {
|
|
167
|
+
getPackage,
|
|
168
|
+
getMAC,
|
|
169
|
+
isMAC,
|
|
170
|
+
isFileProtocol,
|
|
171
|
+
isWebProtocol,
|
|
172
|
+
isJsProject,
|
|
173
|
+
machineIdSync,
|
|
174
|
+
machineId,
|
|
175
|
+
is
|
|
176
|
+
}
|
|
160
177
|
|
package/utils/ip.js
CHANGED
|
@@ -128,7 +128,7 @@ const queryHttps = (version, options) => {
|
|
|
128
128
|
try {
|
|
129
129
|
const gotPromise = hc.request(url, requestOptions);
|
|
130
130
|
gotPromise.cancel = () => {
|
|
131
|
-
//
|
|
131
|
+
// ..
|
|
132
132
|
}
|
|
133
133
|
cancel = gotPromise.cancel;
|
|
134
134
|
|
|
@@ -178,9 +178,7 @@ const queryAll = (version, options) => {
|
|
|
178
178
|
return promise;
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
* 查询 public ipv4
|
|
183
|
-
*/
|
|
181
|
+
// 查询 public ipv4
|
|
184
182
|
function publicIpv4(options) {
|
|
185
183
|
options = {
|
|
186
184
|
...defaults,
|
|
@@ -198,9 +196,7 @@ function publicIpv4(options) {
|
|
|
198
196
|
return queryAll('v4', options);
|
|
199
197
|
}
|
|
200
198
|
|
|
201
|
-
|
|
202
|
-
* 查询public ipv6
|
|
203
|
-
*/
|
|
199
|
+
// 查询public ipv6
|
|
204
200
|
function publicIpv6(options) {
|
|
205
201
|
options = {
|
|
206
202
|
...defaults,
|
|
@@ -218,44 +214,8 @@ function publicIpv6(options) {
|
|
|
218
214
|
return queryAll('v6', options);
|
|
219
215
|
}
|
|
220
216
|
|
|
221
|
-
|
|
222
|
-
* todo 未来趋势是ipv6优先,以后再放开
|
|
223
|
-
*/
|
|
224
|
-
const publicIp = createPublicIp(publicIpv4, publicIpv6);
|
|
225
|
-
function createPublicIp(publicIpv4, publicIpv6) {
|
|
226
|
-
return function publicIp(options) {
|
|
227
|
-
const ipv4Promise = publicIpv4(options);
|
|
228
|
-
const ipv6Promise = publicIpv6(options);
|
|
229
|
-
|
|
230
|
-
const promise = (async () => {
|
|
231
|
-
try {
|
|
232
|
-
const ipv6 = await ipv6Promise;
|
|
233
|
-
ipv4Promise.cancel();
|
|
234
|
-
return ipv6;
|
|
235
|
-
} catch (ipv6Error) {
|
|
236
|
-
//Log.coreLogger.error('[ee-core] [utils/ip] publicIp ipv6Error:', ipv6Error);
|
|
237
|
-
try {
|
|
238
|
-
return await ipv4Promise;
|
|
239
|
-
} catch (ipv4Error) {
|
|
240
|
-
//Log.coreLogger.error('[ee-core] [utils/ip] publicIp ipv4Error:', ipv4Error);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
})();
|
|
244
|
-
|
|
245
|
-
promise.cancel = () => {
|
|
246
|
-
ipv4Promise.cancel();
|
|
247
|
-
ipv6Promise.cancel();
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
return promise;
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const IP = {
|
|
255
|
-
//publicIp,
|
|
217
|
+
module.exports = {
|
|
256
218
|
publicIpv4,
|
|
257
219
|
publicIpv6
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
module.exports = IP;
|
|
220
|
+
};
|
|
261
221
|
|
package/utils/is.js
CHANGED
|
@@ -1,146 +1,112 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
// Checks if we are in renderer process
|
|
4
|
+
function renderer () {
|
|
5
|
+
return process.type === 'renderer'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Checks if we are in main process
|
|
9
|
+
function main() {
|
|
10
|
+
return process.type === 'browser'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Checks if we are under Mac OS
|
|
14
|
+
function osx() {
|
|
15
|
+
return process.platform === 'darwin'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Checks if we are under Mac OS
|
|
19
|
+
function macOS() {
|
|
20
|
+
return osx()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Checks if we are under Windows OS
|
|
24
|
+
function windows() {
|
|
25
|
+
return process.platform === 'win32'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Checks if we are under Linux OS
|
|
29
|
+
function linux() {
|
|
30
|
+
return process.platform === 'linux'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Checks if we are the processor's arch is x86
|
|
34
|
+
function x86() {
|
|
35
|
+
return process.arch === 'ia32'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Checks if we are the processor's arch is x64
|
|
39
|
+
function x64() {
|
|
40
|
+
return process.arch === 'x64'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Checks if the app is running in a sandbox on macOS
|
|
44
|
+
function sandbox() {
|
|
45
|
+
return 'APP_SANDBOX_CONTAINER_ID' in process.env
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Checks if the app is running as a Mac App Store build
|
|
49
|
+
function mas() {
|
|
50
|
+
return process.mas === true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Checks if the app is running as a Windows Store (appx) build
|
|
54
|
+
function windowsStore() {
|
|
55
|
+
return process.windowsStore === true
|
|
56
|
+
}
|
|
7
57
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Checks if we are the processor's arch is x86
|
|
34
|
-
x86() {
|
|
35
|
-
return process.arch === 'ia32'
|
|
36
|
-
},
|
|
37
|
-
// Checks if we are the processor's arch is x64
|
|
38
|
-
x64() {
|
|
39
|
-
return process.arch === 'x64'
|
|
40
|
-
},
|
|
41
|
-
// Checks if the app is running in a sandbox on macOS
|
|
42
|
-
sandbox() {
|
|
43
|
-
return 'APP_SANDBOX_CONTAINER_ID' in process.env
|
|
44
|
-
},
|
|
45
|
-
// Checks if the app is running as a Mac App Store build
|
|
46
|
-
mas() {
|
|
47
|
-
return process.mas === true
|
|
48
|
-
},
|
|
49
|
-
// Checks if the app is running as a Windows Store (appx) build
|
|
50
|
-
windowsStore() {
|
|
51
|
-
return process.windowsStore === true
|
|
52
|
-
},
|
|
53
|
-
// checks if all the 'is functions' passed as arguments are true
|
|
54
|
-
all() {
|
|
55
|
-
const isFunctions = new Array(arguments.length)
|
|
56
|
-
for (var i = 0; i < isFunctions.length; i++) {
|
|
57
|
-
isFunctions[i] = arguments[i]
|
|
58
|
-
}
|
|
59
|
-
if (!isFunctions.length) return
|
|
60
|
-
for (i = 0; i < isFunctions.length; i++) {
|
|
61
|
-
if (!isFunctions[i]()) return false
|
|
62
|
-
}
|
|
63
|
-
return true
|
|
64
|
-
},
|
|
65
|
-
// checks if all the 'is functions' passed as arguments are false
|
|
66
|
-
none() {
|
|
67
|
-
const isFunctions = new Array(arguments.length)
|
|
68
|
-
for (var i = 0; i < isFunctions.length; i++) {
|
|
69
|
-
isFunctions[i] = arguments[i]
|
|
70
|
-
}
|
|
71
|
-
if (!isFunctions.length) return
|
|
72
|
-
for (i = 0; i < isFunctions.length; i++) {
|
|
73
|
-
if (isFunctions[i]()) return false
|
|
74
|
-
}
|
|
75
|
-
return true
|
|
76
|
-
},
|
|
77
|
-
// returns true if one of the 'is functions' passed as argument is true
|
|
78
|
-
one() {
|
|
79
|
-
const isFunctions = new Array(arguments.length)
|
|
80
|
-
for (var i = 0; i < isFunctions.length; i++) {
|
|
81
|
-
isFunctions[i] = arguments[i]
|
|
82
|
-
}
|
|
83
|
-
if (!isFunctions.length) return
|
|
84
|
-
for (i = 0; i < isFunctions.length; i++) {
|
|
85
|
-
if (isFunctions[i]()) return true
|
|
86
|
-
}
|
|
87
|
-
return false
|
|
88
|
-
},
|
|
89
|
-
// checks the if the given release is the same of the OS
|
|
90
|
-
release(requested) {
|
|
91
|
-
if (this.osx()) {
|
|
92
|
-
return requested === this._osxRelease()
|
|
93
|
-
} else if (this.windows()) {
|
|
94
|
-
requested = requested.split('.')
|
|
95
|
-
const actual = release().split('.')
|
|
96
|
-
if (requested.length === 2) {
|
|
97
|
-
return `${actual[0]}.${actual[1]}` === `${requested[0]}.${requested[1]}`
|
|
98
|
-
}
|
|
99
|
-
return `${actual[0]}.${actual[1]}.${actual[2]}` === `${requested[0]}.${requested[1]}.${requested[2]}`
|
|
100
|
-
} else {
|
|
101
|
-
// Not implemented for Linux yet
|
|
102
|
-
return null
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
// checks if the given release is greater than the current OS release
|
|
106
|
-
gtRelease(requested) {
|
|
107
|
-
if (this.osx()) {
|
|
108
|
-
return gt(requested, this._osxRelease())
|
|
109
|
-
} else if (this.windows()) {
|
|
110
|
-
requested = requested.split('.')
|
|
111
|
-
const actual = release().split('.')
|
|
112
|
-
if (requested.length === 2) {
|
|
113
|
-
return gt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
|
|
114
|
-
}
|
|
115
|
-
return gt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
|
|
116
|
-
} else {
|
|
117
|
-
// Not implemented for Linux yet
|
|
118
|
-
return null
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
// checks if the given release is less than the current OS release
|
|
122
|
-
ltRelease(requested) {
|
|
123
|
-
if (this.osx()) {
|
|
124
|
-
return lt(requested, this._osxRelease())
|
|
125
|
-
} else if (this.windows()) {
|
|
126
|
-
requested = requested.split('.')
|
|
127
|
-
const actual = release().split('.')
|
|
128
|
-
if (requested.length === 2) {
|
|
129
|
-
return lt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
|
|
130
|
-
}
|
|
131
|
-
return lt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
|
|
132
|
-
} else {
|
|
133
|
-
// Not implemented for Linux yet
|
|
134
|
-
return null
|
|
135
|
-
}
|
|
136
|
-
},
|
|
58
|
+
// checks if all the 'is functions' passed as arguments are true
|
|
59
|
+
function all() {
|
|
60
|
+
const isFunctions = new Array(arguments.length)
|
|
61
|
+
for (var i = 0; i < isFunctions.length; i++) {
|
|
62
|
+
isFunctions[i] = arguments[i]
|
|
63
|
+
}
|
|
64
|
+
if (!isFunctions.length) return
|
|
65
|
+
for (i = 0; i < isFunctions.length; i++) {
|
|
66
|
+
if (!isFunctions[i]()) return false
|
|
67
|
+
}
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// checks if all the 'is functions' passed as arguments are false
|
|
72
|
+
function none() {
|
|
73
|
+
const isFunctions = new Array(arguments.length)
|
|
74
|
+
for (var i = 0; i < isFunctions.length; i++) {
|
|
75
|
+
isFunctions[i] = arguments[i]
|
|
76
|
+
}
|
|
77
|
+
if (!isFunctions.length) return
|
|
78
|
+
for (i = 0; i < isFunctions.length; i++) {
|
|
79
|
+
if (isFunctions[i]()) return false
|
|
80
|
+
}
|
|
81
|
+
return true
|
|
82
|
+
}
|
|
137
83
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
84
|
+
// returns true if one of the 'is functions' passed as argument is true
|
|
85
|
+
function one() {
|
|
86
|
+
const isFunctions = new Array(arguments.length)
|
|
87
|
+
for (var i = 0; i < isFunctions.length; i++) {
|
|
88
|
+
isFunctions[i] = arguments[i]
|
|
89
|
+
}
|
|
90
|
+
if (!isFunctions.length) return
|
|
91
|
+
for (i = 0; i < isFunctions.length; i++) {
|
|
92
|
+
if (isFunctions[i]()) return true
|
|
93
|
+
}
|
|
94
|
+
return false
|
|
144
95
|
}
|
|
145
96
|
|
|
146
|
-
module.exports =
|
|
97
|
+
module.exports = {
|
|
98
|
+
renderer,
|
|
99
|
+
main,
|
|
100
|
+
osx,
|
|
101
|
+
macOS,
|
|
102
|
+
windows,
|
|
103
|
+
linux,
|
|
104
|
+
x86,
|
|
105
|
+
x64,
|
|
106
|
+
sandbox,
|
|
107
|
+
mas,
|
|
108
|
+
windowsStore,
|
|
109
|
+
all,
|
|
110
|
+
none,
|
|
111
|
+
one,
|
|
112
|
+
};
|