ee-core 4.1.3 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +65 -65
- package/app/application.d.ts +5 -5
- package/app/application.js +30 -30
- package/app/boot.d.ts +5 -5
- package/app/boot.js +80 -80
- package/app/dir.d.ts +1 -1
- package/app/dir.js +26 -26
- package/app/events.d.ts +14 -14
- package/app/events.js +55 -55
- package/app/index.d.ts +2 -2
- package/app/index.js +6 -6
- package/config/config_loader.d.ts +13 -13
- package/config/config_loader.js +65 -65
- package/config/default_config.d.ts +95 -95
- package/config/default_config.js +111 -111
- package/config/index.d.ts +28 -28
- package/config/index.js +24 -24
- package/const/channel.d.ts +16 -16
- package/const/channel.js +27 -27
- package/controller/controller_loader.d.ts +9 -9
- package/controller/controller_loader.js +77 -77
- package/controller/index.d.ts +2 -2
- package/controller/index.js +24 -24
- package/core/index.d.ts +2 -2
- package/core/index.js +11 -11
- package/core/loader/file_loader.d.ts +66 -66
- package/core/loader/file_loader.js +211 -211
- package/core/utils/index.d.ts +12 -12
- package/core/utils/index.js +83 -83
- package/core/utils/timing.d.ts +22 -22
- package/core/utils/timing.js +78 -78
- package/cross/cross.d.ts +19 -19
- package/cross/cross.js +151 -151
- package/cross/crossProcess.d.ts +29 -29
- package/cross/crossProcess.js +172 -172
- package/cross/index.d.ts +2 -2
- package/cross/index.js +8 -8
- package/electron/app/index.d.ts +5 -5
- package/electron/app/index.js +48 -48
- package/electron/index.d.ts +3 -3
- package/electron/index.js +15 -15
- package/electron/window/index.d.ts +6 -6
- package/electron/window/index.js +268 -268
- package/exception/index.d.ts +9 -9
- package/exception/index.js +100 -100
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.d.ts +1 -1
- package/html/index.js +10 -10
- package/index.d.ts +2 -2
- package/index.js +6 -6
- package/jobs/child/app.d.ts +1 -1
- package/jobs/child/app.js +69 -69
- package/jobs/child/index.d.ts +13 -13
- package/jobs/child/index.js +85 -85
- package/jobs/child/jobProcess.d.ts +16 -16
- package/jobs/child/jobProcess.js +133 -133
- package/jobs/child-pool/index.d.ts +26 -26
- package/jobs/child-pool/index.js +190 -190
- package/jobs/index.d.ts +3 -3
- package/jobs/index.js +6 -6
- package/jobs/load-balancer/algorithm/index.d.ts +4 -4
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.d.ts +2 -2
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.d.ts +8 -8
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.d.ts +96 -96
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.d.ts +16 -16
- package/jobs/load-balancer/scheduler.js +31 -31
- package/loader/index.d.ts +9 -9
- package/loader/index.js +99 -98
- package/log/index.d.ts +5 -5
- package/log/index.js +85 -85
- package/log/logger.d.ts +1 -1
- package/log/logger.js +94 -94
- package/message/childMessage.d.ts +10 -10
- package/message/childMessage.js +43 -43
- package/message/index.d.ts +3 -3
- package/message/index.js +9 -9
- package/package.json +42 -42
- package/ps/index.d.ts +39 -39
- package/ps/index.js +294 -294
- package/socket/httpServer.d.ts +8 -8
- package/socket/httpServer.js +199 -199
- package/socket/index.d.ts +10 -10
- package/socket/index.js +64 -64
- package/socket/ipcServer.d.ts +9 -9
- package/socket/ipcServer.js +105 -105
- package/socket/socketServer.d.ts +10 -10
- package/socket/socketServer.js +81 -81
- package/storage/index.d.ts +4 -4
- package/storage/index.js +6 -6
- package/storage/sqliteStorage.d.ts +16 -16
- package/storage/sqliteStorage.js +123 -123
- package/tsconfig.json +13 -13
- package/utils/extend.d.ts +2 -2
- package/utils/extend.js +77 -77
- package/utils/helper.d.ts +14 -14
- package/utils/helper.js +206 -206
- package/utils/index.d.ts +10 -10
- package/utils/index.js +167 -167
- package/utils/ip.d.ts +2 -2
- package/utils/ip.js +221 -221
- package/utils/is.d.ts +14 -14
- package/utils/is.js +111 -111
- package/utils/json.d.ts +5 -5
- package/utils/json.js +79 -79
- package/utils/pargv.d.ts +3 -3
- package/utils/pargv.js +267 -267
- package/utils/port/index.d.ts +1 -1
- package/utils/port/index.js +125 -125
- package/utils/wrap.d.ts +4 -4
- package/utils/wrap.js +40 -40
package/utils/index.js
CHANGED
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const os = require("os");
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const { exec, execSync } = require('child_process');
|
|
7
|
-
const { createHash } = require('crypto');
|
|
8
|
-
const { getBaseDir } = require('../ps');
|
|
9
|
-
const { readSync } = require('./json');
|
|
10
|
-
const is = require('./is');
|
|
11
|
-
|
|
12
|
-
// machine id
|
|
13
|
-
const { platform } = process;
|
|
14
|
-
const win32RegBinPath = {
|
|
15
|
-
native: '%windir%\\System32',
|
|
16
|
-
mixed: '%windir%\\sysnative\\cmd.exe /c %windir%\\System32'
|
|
17
|
-
};
|
|
18
|
-
const MachineGuid = {
|
|
19
|
-
darwin: 'ioreg -rd1 -c IOPlatformExpertDevice',
|
|
20
|
-
win32: `${win32RegBinPath[_isWindowsProcessMixedOrNativeArchitecture()]}\\REG.exe ` +
|
|
21
|
-
'QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography ' +
|
|
22
|
-
'/v MachineGuid',
|
|
23
|
-
linux: '( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :',
|
|
24
|
-
freebsd: 'kenv -q smbios.system.uuid || sysctl -n kern.hostuuid'
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// 获取项目根目录package.json
|
|
28
|
-
function getPackage() {
|
|
29
|
-
const json = readSync(path.join(getBaseDir(), 'package.json'));
|
|
30
|
-
|
|
31
|
-
return json;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Get the first proper MAC address
|
|
35
|
-
// iface: If provided, restrict MAC address fetching to this interface
|
|
36
|
-
function getMAC(iface) {
|
|
37
|
-
const zeroRegex = /(?:[0]{1,2}[:-]){5}[0]{1,2}/;
|
|
38
|
-
const list = os.networkInterfaces();
|
|
39
|
-
if (iface) {
|
|
40
|
-
const parts = list[iface];
|
|
41
|
-
if (!parts) {
|
|
42
|
-
throw new Error(`interface ${iface} was not found`);
|
|
43
|
-
}
|
|
44
|
-
for (const part of parts) {
|
|
45
|
-
if (zeroRegex.test(part.mac) === false) {
|
|
46
|
-
return part.mac;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
throw new Error(`interface ${iface} had no valid mac addresses`);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
for (const [key, parts] of Object.entries(list)) {
|
|
53
|
-
// for some reason beyond me, this is needed to satisfy typescript
|
|
54
|
-
// fix https://github.com/bevry/getmac/issues/100
|
|
55
|
-
if (!parts)
|
|
56
|
-
continue;
|
|
57
|
-
for (const part of parts) {
|
|
58
|
-
if (zeroRegex.test(part.mac) === false) {
|
|
59
|
-
return part.mac;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
throw new Error('failed to get the MAC address');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Check if the input is a valid MAC address
|
|
68
|
-
function isMAC(macAddress) {
|
|
69
|
-
const macRegex = /(?:[a-z0-9]{1,2}[:-]){5}[a-z0-9]{1,2}/i;
|
|
70
|
-
return macRegex.test(macAddress);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function isFileProtocol(protocol) {
|
|
74
|
-
return protocol == 'file://';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function isWebProtocol(protocol) {
|
|
78
|
-
return ['http://', 'https://'].includes(protocol);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function isJsProject(baseDir) {
|
|
82
|
-
const entryFile1 = path.join(baseDir, 'electron/main.js');
|
|
83
|
-
const entryFile2 = path.join(baseDir, 'electron/index.js');
|
|
84
|
-
if (fs.existsSync(entryFile1) || fs.existsSync(entryFile2)) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// get machine id
|
|
91
|
-
function machineIdSync(original) {
|
|
92
|
-
let id = _expose(execSync(MachineGuid[platform]).toString());
|
|
93
|
-
return original ? id : _hash(id);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// get machine id (promise)
|
|
97
|
-
// original <Boolean>, If true return original value of machine id, otherwise return hashed value (sha-256), default: false
|
|
98
|
-
function machineId(original) {
|
|
99
|
-
return new Promise((resolve, reject) => {
|
|
100
|
-
return exec(MachineGuid[platform], {}, (err, stdout, stderr) => {
|
|
101
|
-
if (err) {
|
|
102
|
-
return reject(
|
|
103
|
-
new Error(`Error while obtaining machine id: ${err.stack}`)
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
let id = _expose(stdout.toString());
|
|
107
|
-
return resolve(original ? id : _hash(id));
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function _isWindowsProcessMixedOrNativeArchitecture() {
|
|
113
|
-
// detect if the node binary is the same arch as the Windows OS.
|
|
114
|
-
// or if this is 32 bit node on 64 bit windows.
|
|
115
|
-
if(process.platform !== 'win32') {
|
|
116
|
-
return '';
|
|
117
|
-
}
|
|
118
|
-
if( process.arch === 'ia32' && process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') ) {
|
|
119
|
-
return 'mixed';
|
|
120
|
-
}
|
|
121
|
-
return 'native';
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function _hash(guid) {
|
|
125
|
-
return createHash('sha256').update(guid).digest('hex');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function _expose(result) {
|
|
129
|
-
switch (platform) {
|
|
130
|
-
case 'darwin':
|
|
131
|
-
return result
|
|
132
|
-
.split('IOPlatformUUID')[1]
|
|
133
|
-
.split('\n')[0].replace(/\=|\s+|\"/ig, '')
|
|
134
|
-
.toLowerCase();
|
|
135
|
-
case 'win32':
|
|
136
|
-
return result
|
|
137
|
-
.toString()
|
|
138
|
-
.split('REG_SZ')[1]
|
|
139
|
-
.replace(/\r+|\n+|\s+/ig, '')
|
|
140
|
-
.toLowerCase();
|
|
141
|
-
case 'linux':
|
|
142
|
-
return result
|
|
143
|
-
.toString()
|
|
144
|
-
.replace(/\r+|\n+|\s+/ig, '')
|
|
145
|
-
.toLowerCase();
|
|
146
|
-
case 'freebsd':
|
|
147
|
-
return result
|
|
148
|
-
.toString()
|
|
149
|
-
.replace(/\r+|\n+|\s+/ig, '')
|
|
150
|
-
.toLowerCase();
|
|
151
|
-
default:
|
|
152
|
-
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
module.exports = {
|
|
157
|
-
getPackage,
|
|
158
|
-
getMAC,
|
|
159
|
-
isMAC,
|
|
160
|
-
isFileProtocol,
|
|
161
|
-
isWebProtocol,
|
|
162
|
-
isJsProject,
|
|
163
|
-
machineIdSync,
|
|
164
|
-
machineId,
|
|
165
|
-
is
|
|
166
|
-
}
|
|
167
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const os = require("os");
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const { exec, execSync } = require('child_process');
|
|
7
|
+
const { createHash } = require('crypto');
|
|
8
|
+
const { getBaseDir } = require('../ps');
|
|
9
|
+
const { readSync } = require('./json');
|
|
10
|
+
const is = require('./is');
|
|
11
|
+
|
|
12
|
+
// machine id
|
|
13
|
+
const { platform } = process;
|
|
14
|
+
const win32RegBinPath = {
|
|
15
|
+
native: '%windir%\\System32',
|
|
16
|
+
mixed: '%windir%\\sysnative\\cmd.exe /c %windir%\\System32'
|
|
17
|
+
};
|
|
18
|
+
const MachineGuid = {
|
|
19
|
+
darwin: 'ioreg -rd1 -c IOPlatformExpertDevice',
|
|
20
|
+
win32: `${win32RegBinPath[_isWindowsProcessMixedOrNativeArchitecture()]}\\REG.exe ` +
|
|
21
|
+
'QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography ' +
|
|
22
|
+
'/v MachineGuid',
|
|
23
|
+
linux: '( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :',
|
|
24
|
+
freebsd: 'kenv -q smbios.system.uuid || sysctl -n kern.hostuuid'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// 获取项目根目录package.json
|
|
28
|
+
function getPackage() {
|
|
29
|
+
const json = readSync(path.join(getBaseDir(), 'package.json'));
|
|
30
|
+
|
|
31
|
+
return json;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Get the first proper MAC address
|
|
35
|
+
// iface: If provided, restrict MAC address fetching to this interface
|
|
36
|
+
function getMAC(iface) {
|
|
37
|
+
const zeroRegex = /(?:[0]{1,2}[:-]){5}[0]{1,2}/;
|
|
38
|
+
const list = os.networkInterfaces();
|
|
39
|
+
if (iface) {
|
|
40
|
+
const parts = list[iface];
|
|
41
|
+
if (!parts) {
|
|
42
|
+
throw new Error(`interface ${iface} was not found`);
|
|
43
|
+
}
|
|
44
|
+
for (const part of parts) {
|
|
45
|
+
if (zeroRegex.test(part.mac) === false) {
|
|
46
|
+
return part.mac;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`interface ${iface} had no valid mac addresses`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
for (const [key, parts] of Object.entries(list)) {
|
|
53
|
+
// for some reason beyond me, this is needed to satisfy typescript
|
|
54
|
+
// fix https://github.com/bevry/getmac/issues/100
|
|
55
|
+
if (!parts)
|
|
56
|
+
continue;
|
|
57
|
+
for (const part of parts) {
|
|
58
|
+
if (zeroRegex.test(part.mac) === false) {
|
|
59
|
+
return part.mac;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
throw new Error('failed to get the MAC address');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Check if the input is a valid MAC address
|
|
68
|
+
function isMAC(macAddress) {
|
|
69
|
+
const macRegex = /(?:[a-z0-9]{1,2}[:-]){5}[a-z0-9]{1,2}/i;
|
|
70
|
+
return macRegex.test(macAddress);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isFileProtocol(protocol) {
|
|
74
|
+
return protocol == 'file://';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isWebProtocol(protocol) {
|
|
78
|
+
return ['http://', 'https://'].includes(protocol);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isJsProject(baseDir) {
|
|
82
|
+
const entryFile1 = path.join(baseDir, 'electron/main.js');
|
|
83
|
+
const entryFile2 = path.join(baseDir, 'electron/index.js');
|
|
84
|
+
if (fs.existsSync(entryFile1) || fs.existsSync(entryFile2)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// get machine id
|
|
91
|
+
function machineIdSync(original) {
|
|
92
|
+
let id = _expose(execSync(MachineGuid[platform]).toString());
|
|
93
|
+
return original ? id : _hash(id);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// get machine id (promise)
|
|
97
|
+
// original <Boolean>, If true return original value of machine id, otherwise return hashed value (sha-256), default: false
|
|
98
|
+
function machineId(original) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
return exec(MachineGuid[platform], {}, (err, stdout, stderr) => {
|
|
101
|
+
if (err) {
|
|
102
|
+
return reject(
|
|
103
|
+
new Error(`Error while obtaining machine id: ${err.stack}`)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
let id = _expose(stdout.toString());
|
|
107
|
+
return resolve(original ? id : _hash(id));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function _isWindowsProcessMixedOrNativeArchitecture() {
|
|
113
|
+
// detect if the node binary is the same arch as the Windows OS.
|
|
114
|
+
// or if this is 32 bit node on 64 bit windows.
|
|
115
|
+
if(process.platform !== 'win32') {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
if( process.arch === 'ia32' && process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') ) {
|
|
119
|
+
return 'mixed';
|
|
120
|
+
}
|
|
121
|
+
return 'native';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _hash(guid) {
|
|
125
|
+
return createHash('sha256').update(guid).digest('hex');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function _expose(result) {
|
|
129
|
+
switch (platform) {
|
|
130
|
+
case 'darwin':
|
|
131
|
+
return result
|
|
132
|
+
.split('IOPlatformUUID')[1]
|
|
133
|
+
.split('\n')[0].replace(/\=|\s+|\"/ig, '')
|
|
134
|
+
.toLowerCase();
|
|
135
|
+
case 'win32':
|
|
136
|
+
return result
|
|
137
|
+
.toString()
|
|
138
|
+
.split('REG_SZ')[1]
|
|
139
|
+
.replace(/\r+|\n+|\s+/ig, '')
|
|
140
|
+
.toLowerCase();
|
|
141
|
+
case 'linux':
|
|
142
|
+
return result
|
|
143
|
+
.toString()
|
|
144
|
+
.replace(/\r+|\n+|\s+/ig, '')
|
|
145
|
+
.toLowerCase();
|
|
146
|
+
case 'freebsd':
|
|
147
|
+
return result
|
|
148
|
+
.toString()
|
|
149
|
+
.replace(/\r+|\n+|\s+/ig, '')
|
|
150
|
+
.toLowerCase();
|
|
151
|
+
default:
|
|
152
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = {
|
|
157
|
+
getPackage,
|
|
158
|
+
getMAC,
|
|
159
|
+
isMAC,
|
|
160
|
+
isFileProtocol,
|
|
161
|
+
isWebProtocol,
|
|
162
|
+
isJsProject,
|
|
163
|
+
machineIdSync,
|
|
164
|
+
machineId,
|
|
165
|
+
is
|
|
166
|
+
}
|
|
167
|
+
|
package/utils/ip.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function publicIpv4(options: any): Promise<any>;
|
|
2
|
-
export declare function publicIpv6(options: any): Promise<any>;
|
|
1
|
+
export declare function publicIpv4(options: any): Promise<any>;
|
|
2
|
+
export declare function publicIpv6(options: any): Promise<any>;
|