@plasosdk/plaso-electron-sdk 1.3.14 → 1.3.15
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/CHANGELOG.md +13 -13
- package/README.md +772 -751
- package/index.html +275 -275
- package/index.js +6 -6
- package/js/macro.js +88 -86
- package/js/main.js +34 -34
- package/js/render.js +434 -420
- package/js/util.js +109 -109
- package/package.json +28 -28
- package/scripts/getConfig.js +16 -16
- package/scripts/install.js +165 -165
- package/scripts/logger.js +138 -138
package/js/util.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
function versionComp(newVersion, oldVersion) {
|
|
2
|
-
const newVersionList = (newVersion || '0').split('.');
|
|
3
|
-
const oldVersionList = (oldVersion || '0').split('.');
|
|
4
|
-
const length = newVersionList.length > oldVersionList.length ? newVersionList.length : oldVersionList.length;
|
|
5
|
-
for (let i = 0; i < length; i++) {
|
|
6
|
-
const newVersionValue = newVersionList[i] == undefined ? 0 : parseInt(newVersionList[i]);
|
|
7
|
-
const oldVersionValue = oldVersionList[i] == undefined ? 0 : parseInt(oldVersionList[i]);
|
|
8
|
-
const res = newVersionValue - oldVersionValue;
|
|
9
|
-
if (res !== 0) {
|
|
10
|
-
return res;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getElectronRemote() {
|
|
17
|
-
let _remote;
|
|
18
|
-
try {
|
|
19
|
-
_remote = window.require('electron').remote;
|
|
20
|
-
if (!_remote) {
|
|
21
|
-
_remote = window.require('@electron/remote');
|
|
22
|
-
}
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.error(e);
|
|
25
|
-
}
|
|
26
|
-
return _remote;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function parseUrlParams(url) {
|
|
30
|
-
const params = {};
|
|
31
|
-
const queryString = url.indexOf('?') > -1 ? url.split('?')[1] : url;
|
|
32
|
-
|
|
33
|
-
if (!queryString) return params;
|
|
34
|
-
|
|
35
|
-
queryString.split('&').forEach((pair) => {
|
|
36
|
-
const [key, value] = pair.split('=');
|
|
37
|
-
let decodedValue = decodeURIComponent(value || '');
|
|
38
|
-
if (decodedValue === 'true' || decodedValue === 'false') {
|
|
39
|
-
decodedValue = decodedValue === 'true';
|
|
40
|
-
} else if (
|
|
41
|
-
typeof decodedValue === 'string' &&
|
|
42
|
-
decodedValue.length > 0 &&
|
|
43
|
-
!isNaN(Number(decodedValue)) &&
|
|
44
|
-
Number(decodedValue) !== undefined &&
|
|
45
|
-
!decodedValue?.includes?.('.')
|
|
46
|
-
) {
|
|
47
|
-
decodedValue = Number(decodedValue);
|
|
48
|
-
}
|
|
49
|
-
params[key] = decodedValue;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return params;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getEnvironment(url) {
|
|
56
|
-
let host = (url ?? location.host)
|
|
57
|
-
.replace('wwwr', 'www')
|
|
58
|
-
.replace('devai', 'dev')
|
|
59
|
-
.replace('testai', 'test')
|
|
60
|
-
.replace('itestai', 'itest')
|
|
61
|
-
.replace('bai', 'b')
|
|
62
|
-
.replace('ai-cdn', 'www')
|
|
63
|
-
.replace('ai.', 'www.')
|
|
64
|
-
.toLocaleUpperCase();
|
|
65
|
-
const httpIndex = host.indexOf('://');
|
|
66
|
-
if (httpIndex > -1) {
|
|
67
|
-
host = host.substring(httpIndex + 3);
|
|
68
|
-
}
|
|
69
|
-
const index = host.indexOf('.');
|
|
70
|
-
let environment = '';
|
|
71
|
-
//先根据url判断环境。这里single页面访问会用到
|
|
72
|
-
if (/^192\.|^127\.|localhost/.test(host)) {
|
|
73
|
-
environment = 'local';
|
|
74
|
-
} else {
|
|
75
|
-
environment = host.substring(0, index);
|
|
76
|
-
}
|
|
77
|
-
return environment?.toLowerCase();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 获取当前BrowserWindow实例
|
|
82
|
-
*/
|
|
83
|
-
function getCurrentWindow() {
|
|
84
|
-
const remote = getElectronRemote();
|
|
85
|
-
if (remote) {
|
|
86
|
-
return remote.getCurrentWindow();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 获取窗口所属的屏幕(当应用跨屏幕时,应该属于占用面积超过一半的那块屏幕)
|
|
92
|
-
*/
|
|
93
|
-
function getDisplayMatching() {
|
|
94
|
-
const remote = getElectronRemote();
|
|
95
|
-
const currentWindow = getCurrentWindow();
|
|
96
|
-
if (remote && currentWindow) {
|
|
97
|
-
const { screen } = remote;
|
|
98
|
-
const currentWindowBounds = currentWindow.getBounds();
|
|
99
|
-
return screen.getDisplayMatching(currentWindowBounds);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
module.exports = {
|
|
104
|
-
versionComp,
|
|
105
|
-
getElectronRemote,
|
|
106
|
-
parseUrlParams,
|
|
107
|
-
getEnvironment,
|
|
108
|
-
getDisplayMatching,
|
|
109
|
-
};
|
|
1
|
+
function versionComp(newVersion, oldVersion) {
|
|
2
|
+
const newVersionList = (newVersion || '0').split('.');
|
|
3
|
+
const oldVersionList = (oldVersion || '0').split('.');
|
|
4
|
+
const length = newVersionList.length > oldVersionList.length ? newVersionList.length : oldVersionList.length;
|
|
5
|
+
for (let i = 0; i < length; i++) {
|
|
6
|
+
const newVersionValue = newVersionList[i] == undefined ? 0 : parseInt(newVersionList[i]);
|
|
7
|
+
const oldVersionValue = oldVersionList[i] == undefined ? 0 : parseInt(oldVersionList[i]);
|
|
8
|
+
const res = newVersionValue - oldVersionValue;
|
|
9
|
+
if (res !== 0) {
|
|
10
|
+
return res;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getElectronRemote() {
|
|
17
|
+
let _remote;
|
|
18
|
+
try {
|
|
19
|
+
_remote = window.require('electron').remote;
|
|
20
|
+
if (!_remote) {
|
|
21
|
+
_remote = window.require('@electron/remote');
|
|
22
|
+
}
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error(e);
|
|
25
|
+
}
|
|
26
|
+
return _remote;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseUrlParams(url) {
|
|
30
|
+
const params = {};
|
|
31
|
+
const queryString = url.indexOf('?') > -1 ? url.split('?')[1] : url;
|
|
32
|
+
|
|
33
|
+
if (!queryString) return params;
|
|
34
|
+
|
|
35
|
+
queryString.split('&').forEach((pair) => {
|
|
36
|
+
const [key, value] = pair.split('=');
|
|
37
|
+
let decodedValue = decodeURIComponent(value || '');
|
|
38
|
+
if (decodedValue === 'true' || decodedValue === 'false') {
|
|
39
|
+
decodedValue = decodedValue === 'true';
|
|
40
|
+
} else if (
|
|
41
|
+
typeof decodedValue === 'string' &&
|
|
42
|
+
decodedValue.length > 0 &&
|
|
43
|
+
!isNaN(Number(decodedValue)) &&
|
|
44
|
+
Number(decodedValue) !== undefined &&
|
|
45
|
+
!decodedValue?.includes?.('.')
|
|
46
|
+
) {
|
|
47
|
+
decodedValue = Number(decodedValue);
|
|
48
|
+
}
|
|
49
|
+
params[key] = decodedValue;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return params;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getEnvironment(url) {
|
|
56
|
+
let host = (url ?? location.host)
|
|
57
|
+
.replace('wwwr', 'www')
|
|
58
|
+
.replace('devai', 'dev')
|
|
59
|
+
.replace('testai', 'test')
|
|
60
|
+
.replace('itestai', 'itest')
|
|
61
|
+
.replace('bai', 'b')
|
|
62
|
+
.replace('ai-cdn', 'www')
|
|
63
|
+
.replace('ai.', 'www.')
|
|
64
|
+
.toLocaleUpperCase();
|
|
65
|
+
const httpIndex = host.indexOf('://');
|
|
66
|
+
if (httpIndex > -1) {
|
|
67
|
+
host = host.substring(httpIndex + 3);
|
|
68
|
+
}
|
|
69
|
+
const index = host.indexOf('.');
|
|
70
|
+
let environment = '';
|
|
71
|
+
//先根据url判断环境。这里single页面访问会用到
|
|
72
|
+
if (/^192\.|^127\.|localhost/.test(host)) {
|
|
73
|
+
environment = 'local';
|
|
74
|
+
} else {
|
|
75
|
+
environment = host.substring(0, index);
|
|
76
|
+
}
|
|
77
|
+
return environment?.toLowerCase();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 获取当前BrowserWindow实例
|
|
82
|
+
*/
|
|
83
|
+
function getCurrentWindow() {
|
|
84
|
+
const remote = getElectronRemote();
|
|
85
|
+
if (remote) {
|
|
86
|
+
return remote.getCurrentWindow();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 获取窗口所属的屏幕(当应用跨屏幕时,应该属于占用面积超过一半的那块屏幕)
|
|
92
|
+
*/
|
|
93
|
+
function getDisplayMatching() {
|
|
94
|
+
const remote = getElectronRemote();
|
|
95
|
+
const currentWindow = getCurrentWindow();
|
|
96
|
+
if (remote && currentWindow) {
|
|
97
|
+
const { screen } = remote;
|
|
98
|
+
const currentWindowBounds = currentWindow.getBounds();
|
|
99
|
+
return screen.getDisplayMatching(currentWindowBounds);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module.exports = {
|
|
104
|
+
versionComp,
|
|
105
|
+
getElectronRemote,
|
|
106
|
+
parseUrlParams,
|
|
107
|
+
getEnvironment,
|
|
108
|
+
getDisplayMatching,
|
|
109
|
+
};
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@plasosdk/plaso-electron-sdk",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "伯索课堂Electron SDK",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"start": "electron .",
|
|
8
|
-
"install": "node ./scripts/install.js",
|
|
9
|
-
"release": "npm version patch && npm publish && git push --follow-tags",
|
|
10
|
-
"release:minor": "npm version minor && npm publish && git push --follow-tags",
|
|
11
|
-
"release:major": "npm version major && npm publish && git push --follow-tags"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"plaso",
|
|
15
|
-
"sdk",
|
|
16
|
-
"electron",
|
|
17
|
-
"classroom"
|
|
18
|
-
],
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@plasosdk/screenshot": "^1.3.4",
|
|
21
|
-
"@plasosdk/winproxy": "^1.1.7",
|
|
22
|
-
"adm-zip": "^0.5.16",
|
|
23
|
-
"fs-extra": "^11.1.1",
|
|
24
|
-
"minimist": "^1.2.5"
|
|
25
|
-
},
|
|
26
|
-
"author": "",
|
|
27
|
-
"license": "ISC"
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@plasosdk/plaso-electron-sdk",
|
|
3
|
+
"version": "1.3.15",
|
|
4
|
+
"description": "伯索课堂Electron SDK",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "electron .",
|
|
8
|
+
"install": "node ./scripts/install.js",
|
|
9
|
+
"release": "npm version patch && npm publish && git push --follow-tags",
|
|
10
|
+
"release:minor": "npm version minor && npm publish && git push --follow-tags",
|
|
11
|
+
"release:major": "npm version major && npm publish && git push --follow-tags"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"plaso",
|
|
15
|
+
"sdk",
|
|
16
|
+
"electron",
|
|
17
|
+
"classroom"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@plasosdk/screenshot": "^1.3.4",
|
|
21
|
+
"@plasosdk/winproxy": "^1.1.7",
|
|
22
|
+
"adm-zip": "^0.5.16",
|
|
23
|
+
"fs-extra": "^11.1.1",
|
|
24
|
+
"minimist": "^1.2.5"
|
|
25
|
+
},
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "ISC"
|
|
28
|
+
}
|
package/scripts/getConfig.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
const getConfig = () => {
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { version } = require(path.join(__dirname, '../package.json'));
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const platform = process.env.npm_config_plaso_electron_sdk_platform || os.platform();
|
|
7
|
-
const arch = process.env.npm_config_plaso_electron_sdk_arch || os.arch();
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
platform,
|
|
11
|
-
arch,
|
|
12
|
-
packageVersion: version,
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = getConfig;
|
|
1
|
+
|
|
2
|
+
const getConfig = () => {
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { version } = require(path.join(__dirname, '../package.json'));
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const platform = process.env.npm_config_plaso_electron_sdk_platform || os.platform();
|
|
7
|
+
const arch = process.env.npm_config_plaso_electron_sdk_arch || os.arch();
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
platform,
|
|
11
|
+
arch,
|
|
12
|
+
packageVersion: version,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = getConfig;
|
package/scripts/install.js
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
|
-
const https = require('https');
|
|
6
|
-
const { exec, execSync } = require('child_process');
|
|
7
|
-
|
|
8
|
-
const AdmZip = require('adm-zip');
|
|
9
|
-
|
|
10
|
-
const getConfig = require('./getConfig');
|
|
11
|
-
|
|
12
|
-
const LogFormatter = require('./logger');
|
|
13
|
-
const logger = new LogFormatter();
|
|
14
|
-
|
|
15
|
-
const minimist = require('minimist');
|
|
16
|
-
const { INIT_CWD } = minimist(process.argv.slice(2), {
|
|
17
|
-
string: ['INIT_CWD'],
|
|
18
|
-
default: {},
|
|
19
|
-
});
|
|
20
|
-
logger.info(`pass INIT_CWD ${INIT_CWD}`);
|
|
21
|
-
|
|
22
|
-
const { platform, packageVersion, arch } = getConfig();
|
|
23
|
-
|
|
24
|
-
const AGORA_ELECTRON_SDK_V4_VERSION = '4.2.7-build.127-rc.3';
|
|
25
|
-
|
|
26
|
-
const agora_electron_sdk_v4_x32_in_win32 = `npm install agora-electron-sdk@${AGORA_ELECTRON_SDK_V4_VERSION} --agora_electron_sdk_arch=ia32 --agora_electron_sdk_platform=win32 --global-style --no-save --no-package-lock`;
|
|
27
|
-
const agora_electron_sdk_v4_x64_in_win32 = `npm install agora-electron-sdk@${AGORA_ELECTRON_SDK_V4_VERSION} --agora_electron_sdk_arch=x64 --agora_electron_sdk_platform=win32 --global-style --no-save --no-package-lock`;
|
|
28
|
-
const agora_electron_sdk_v4_in_darwin = `npm install agora-electron-sdk@${AGORA_ELECTRON_SDK_V4_VERSION} --agora_electron_sdk_arch=x64 --agora_electron_sdk_platform=darwin --global-style --no-save --no-package-lock`;
|
|
29
|
-
|
|
30
|
-
const TRTC_ELECTRON_SDK_VERSION = '11.8.112-beta.6';
|
|
31
|
-
|
|
32
|
-
const trtc_electron_sdk_x32_in_win32 = `npm install trtc-electron-sdk@${TRTC_ELECTRON_SDK_VERSION} --trtc_electron_arch=ia32 --trtc_electron_platform=win32 --global-style --no-save --no-package-lock --legacy-peer-deps`;
|
|
33
|
-
const trtc_electron_sdk_x64_in_win32 = `npm install trtc-electron-sdk@${TRTC_ELECTRON_SDK_VERSION} --trtc_electron_arch=x64 --trtc_electron_platform=win32 --global-style --no-save --no-package-lock --legacy-peer-deps`;
|
|
34
|
-
const trtc_electron_sdk_in_darwin = `npm install trtc-electron-sdk@${TRTC_ELECTRON_SDK_VERSION} --trtc_electron_arch=x64 --trtc_electron_platform=darwin --global-style --no-save --no-package-lock --legacy-peer-deps`;
|
|
35
|
-
|
|
36
|
-
const PLATFORM_TYPE = {
|
|
37
|
-
DARWIN: 'darwin',
|
|
38
|
-
WIN32: 'win32',
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const ARCH_TYPE = {
|
|
42
|
-
X64: 'x64',
|
|
43
|
-
IA32: 'ia32',
|
|
44
|
-
ARM64: 'arm64',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const electron_sdk_plugins_dir = 'https://wwwr.plaso.cn/static/cdn/electron-sdk-plugins/';
|
|
48
|
-
|
|
49
|
-
const getPluginsZipName = () => {
|
|
50
|
-
let flameshotZipName = 'flameshot_win.zip';
|
|
51
|
-
let lameZipName = 'lame_win.zip';
|
|
52
|
-
const plasoALDZipName = 'PlasoALD_3.0.zip';
|
|
53
|
-
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
54
|
-
lameZipName = 'lame_mac_x64.zip';
|
|
55
|
-
if (arch.includes('arm')) {
|
|
56
|
-
flameshotZipName = 'flameshot_mac_arm64.zip';
|
|
57
|
-
} else {
|
|
58
|
-
flameshotZipName = 'flameshot_mac_x64.zip';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return { flameshotZipName, lameZipName, plasoALDZipName };
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const installCb = (url, reInstallCb, error, stdout, stderr) => {
|
|
65
|
-
logger.info(`installCb 信息: ${url}, ${error?.message}, ${stdout}, ${stderr}`);
|
|
66
|
-
if (error?.message) {
|
|
67
|
-
reInstallCb?.();
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const npmInstall = () => {
|
|
72
|
-
let agora_electron_sdk_v4 = agora_electron_sdk_v4_x32_in_win32;
|
|
73
|
-
let trtc_electron_sdk = trtc_electron_sdk_x32_in_win32;
|
|
74
|
-
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
75
|
-
agora_electron_sdk_v4 = agora_electron_sdk_v4_in_darwin;
|
|
76
|
-
trtc_electron_sdk = trtc_electron_sdk_in_darwin;
|
|
77
|
-
} else if (arch === ARCH_TYPE.X64) {
|
|
78
|
-
agora_electron_sdk_v4 = agora_electron_sdk_v4_x64_in_win32;
|
|
79
|
-
trtc_electron_sdk = trtc_electron_sdk_x64_in_win32;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
let installAgoraNumber = 0;
|
|
83
|
-
const installAgora = () => {
|
|
84
|
-
installAgoraNumber++;
|
|
85
|
-
if (installAgoraNumber > 3) return;
|
|
86
|
-
exec(agora_electron_sdk_v4, async (error, stdout, stderr) => {
|
|
87
|
-
installCb(agora_electron_sdk_v4, installAgora, error, stdout, stderr);
|
|
88
|
-
if (!error?.message) {
|
|
89
|
-
const oldAgoraV4Path = path.join(__dirname, '../node_modules', 'agora-electron-sdk');
|
|
90
|
-
const newAgoraV4Path = path.join(__dirname, '../lib', 'agora-v4');
|
|
91
|
-
try {
|
|
92
|
-
fs.removeSync(newAgoraV4Path);
|
|
93
|
-
fs.moveSync(oldAgoraV4Path, newAgoraV4Path, { overwrite: true });
|
|
94
|
-
} catch (error) {
|
|
95
|
-
logger.error('移动agora_electron_sdk_v4失败', error.message);
|
|
96
|
-
}
|
|
97
|
-
logger.info('移动agora_electron_sdk_v4成功');
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
installAgora();
|
|
102
|
-
|
|
103
|
-
let installTrtcNumber = 0;
|
|
104
|
-
const installTrtc = () => {
|
|
105
|
-
installTrtcNumber++;
|
|
106
|
-
if (installTrtcNumber > 3) return;
|
|
107
|
-
exec(trtc_electron_sdk, (error, stdout, stderr) => {
|
|
108
|
-
installCb(trtc_electron_sdk, installTrtc, error, stdout, stderr);
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
// installTrtc();
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const downloadFile = (zipFileName, localDir) => {
|
|
115
|
-
const remoteZipFilePath = `${electron_sdk_plugins_dir}${zipFileName}`;
|
|
116
|
-
const localZipFilePath = path.join(localDir, zipFileName);
|
|
117
|
-
logger.info(`will download ${zipFileName} to ${localZipFilePath}`);
|
|
118
|
-
https
|
|
119
|
-
.get(remoteZipFilePath, (response) => {
|
|
120
|
-
const file = fs.createWriteStream(localZipFilePath);
|
|
121
|
-
response.pipe(file);
|
|
122
|
-
file.on('finish', () => {
|
|
123
|
-
file.close(() => {
|
|
124
|
-
logger.info(`文件${zipFileName}写入完成`);
|
|
125
|
-
// 解压缩
|
|
126
|
-
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
127
|
-
execSync(`unzip -o ${localZipFilePath} -d ${localDir}`);
|
|
128
|
-
} else {
|
|
129
|
-
const zip = new AdmZip(localZipFilePath);
|
|
130
|
-
zip.extractAllTo(localDir, true);
|
|
131
|
-
}
|
|
132
|
-
if (fs.existsSync(path.join(localDir, '__MACOSX'))) {
|
|
133
|
-
fs.rmdir(path.join(localDir, '__MACOSX'), { recursive: true, force: true });
|
|
134
|
-
}
|
|
135
|
-
fs.unlink(localZipFilePath, () => {});
|
|
136
|
-
logger.info(`文件${zipFileName}解压完成`);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
})
|
|
140
|
-
.on('error', (err) => {
|
|
141
|
-
// 删除不完整的文件
|
|
142
|
-
fs.unlink(localZipFilePath, () => {});
|
|
143
|
-
logger.error(`download ${zipFileName} failed, delete it`, err.message);
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const downloadPrebuild = async () => {
|
|
148
|
-
logger.info('Package Version: %s', packageVersion);
|
|
149
|
-
logger.info('Platform: %s', platform);
|
|
150
|
-
if (arch) logger.info('Arch: %s', arch);
|
|
151
|
-
|
|
152
|
-
npmInstall();
|
|
153
|
-
|
|
154
|
-
const { flameshotZipName, plasoALDZipName } = getPluginsZipName();
|
|
155
|
-
const localPluginsDir = path.join(__dirname, '../lib');
|
|
156
|
-
if (!fs.existsSync(localPluginsDir)) {
|
|
157
|
-
fs.mkdirSync(localPluginsDir);
|
|
158
|
-
}
|
|
159
|
-
downloadFile(flameshotZipName, localPluginsDir);
|
|
160
|
-
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
161
|
-
downloadFile(plasoALDZipName, localPluginsDir);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
downloadPrebuild();
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const https = require('https');
|
|
6
|
+
const { exec, execSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const AdmZip = require('adm-zip');
|
|
9
|
+
|
|
10
|
+
const getConfig = require('./getConfig');
|
|
11
|
+
|
|
12
|
+
const LogFormatter = require('./logger');
|
|
13
|
+
const logger = new LogFormatter();
|
|
14
|
+
|
|
15
|
+
const minimist = require('minimist');
|
|
16
|
+
const { INIT_CWD } = minimist(process.argv.slice(2), {
|
|
17
|
+
string: ['INIT_CWD'],
|
|
18
|
+
default: {},
|
|
19
|
+
});
|
|
20
|
+
logger.info(`pass INIT_CWD ${INIT_CWD}`);
|
|
21
|
+
|
|
22
|
+
const { platform, packageVersion, arch } = getConfig();
|
|
23
|
+
|
|
24
|
+
const AGORA_ELECTRON_SDK_V4_VERSION = '4.2.7-build.127-rc.3';
|
|
25
|
+
|
|
26
|
+
const agora_electron_sdk_v4_x32_in_win32 = `npm install agora-electron-sdk@${AGORA_ELECTRON_SDK_V4_VERSION} --agora_electron_sdk_arch=ia32 --agora_electron_sdk_platform=win32 --global-style --no-save --no-package-lock`;
|
|
27
|
+
const agora_electron_sdk_v4_x64_in_win32 = `npm install agora-electron-sdk@${AGORA_ELECTRON_SDK_V4_VERSION} --agora_electron_sdk_arch=x64 --agora_electron_sdk_platform=win32 --global-style --no-save --no-package-lock`;
|
|
28
|
+
const agora_electron_sdk_v4_in_darwin = `npm install agora-electron-sdk@${AGORA_ELECTRON_SDK_V4_VERSION} --agora_electron_sdk_arch=x64 --agora_electron_sdk_platform=darwin --global-style --no-save --no-package-lock`;
|
|
29
|
+
|
|
30
|
+
const TRTC_ELECTRON_SDK_VERSION = '11.8.112-beta.6';
|
|
31
|
+
|
|
32
|
+
const trtc_electron_sdk_x32_in_win32 = `npm install trtc-electron-sdk@${TRTC_ELECTRON_SDK_VERSION} --trtc_electron_arch=ia32 --trtc_electron_platform=win32 --global-style --no-save --no-package-lock --legacy-peer-deps`;
|
|
33
|
+
const trtc_electron_sdk_x64_in_win32 = `npm install trtc-electron-sdk@${TRTC_ELECTRON_SDK_VERSION} --trtc_electron_arch=x64 --trtc_electron_platform=win32 --global-style --no-save --no-package-lock --legacy-peer-deps`;
|
|
34
|
+
const trtc_electron_sdk_in_darwin = `npm install trtc-electron-sdk@${TRTC_ELECTRON_SDK_VERSION} --trtc_electron_arch=x64 --trtc_electron_platform=darwin --global-style --no-save --no-package-lock --legacy-peer-deps`;
|
|
35
|
+
|
|
36
|
+
const PLATFORM_TYPE = {
|
|
37
|
+
DARWIN: 'darwin',
|
|
38
|
+
WIN32: 'win32',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ARCH_TYPE = {
|
|
42
|
+
X64: 'x64',
|
|
43
|
+
IA32: 'ia32',
|
|
44
|
+
ARM64: 'arm64',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const electron_sdk_plugins_dir = 'https://wwwr.plaso.cn/static/cdn/electron-sdk-plugins/';
|
|
48
|
+
|
|
49
|
+
const getPluginsZipName = () => {
|
|
50
|
+
let flameshotZipName = 'flameshot_win.zip';
|
|
51
|
+
let lameZipName = 'lame_win.zip';
|
|
52
|
+
const plasoALDZipName = 'PlasoALD_3.0.zip';
|
|
53
|
+
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
54
|
+
lameZipName = 'lame_mac_x64.zip';
|
|
55
|
+
if (arch.includes('arm')) {
|
|
56
|
+
flameshotZipName = 'flameshot_mac_arm64.zip';
|
|
57
|
+
} else {
|
|
58
|
+
flameshotZipName = 'flameshot_mac_x64.zip';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { flameshotZipName, lameZipName, plasoALDZipName };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const installCb = (url, reInstallCb, error, stdout, stderr) => {
|
|
65
|
+
logger.info(`installCb 信息: ${url}, ${error?.message}, ${stdout}, ${stderr}`);
|
|
66
|
+
if (error?.message) {
|
|
67
|
+
reInstallCb?.();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const npmInstall = () => {
|
|
72
|
+
let agora_electron_sdk_v4 = agora_electron_sdk_v4_x32_in_win32;
|
|
73
|
+
let trtc_electron_sdk = trtc_electron_sdk_x32_in_win32;
|
|
74
|
+
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
75
|
+
agora_electron_sdk_v4 = agora_electron_sdk_v4_in_darwin;
|
|
76
|
+
trtc_electron_sdk = trtc_electron_sdk_in_darwin;
|
|
77
|
+
} else if (arch === ARCH_TYPE.X64) {
|
|
78
|
+
agora_electron_sdk_v4 = agora_electron_sdk_v4_x64_in_win32;
|
|
79
|
+
trtc_electron_sdk = trtc_electron_sdk_x64_in_win32;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let installAgoraNumber = 0;
|
|
83
|
+
const installAgora = () => {
|
|
84
|
+
installAgoraNumber++;
|
|
85
|
+
if (installAgoraNumber > 3) return;
|
|
86
|
+
exec(agora_electron_sdk_v4, async (error, stdout, stderr) => {
|
|
87
|
+
installCb(agora_electron_sdk_v4, installAgora, error, stdout, stderr);
|
|
88
|
+
if (!error?.message) {
|
|
89
|
+
const oldAgoraV4Path = path.join(__dirname, '../node_modules', 'agora-electron-sdk');
|
|
90
|
+
const newAgoraV4Path = path.join(__dirname, '../lib', 'agora-v4');
|
|
91
|
+
try {
|
|
92
|
+
fs.removeSync(newAgoraV4Path);
|
|
93
|
+
fs.moveSync(oldAgoraV4Path, newAgoraV4Path, { overwrite: true });
|
|
94
|
+
} catch (error) {
|
|
95
|
+
logger.error('移动agora_electron_sdk_v4失败', error.message);
|
|
96
|
+
}
|
|
97
|
+
logger.info('移动agora_electron_sdk_v4成功');
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
installAgora();
|
|
102
|
+
|
|
103
|
+
let installTrtcNumber = 0;
|
|
104
|
+
const installTrtc = () => {
|
|
105
|
+
installTrtcNumber++;
|
|
106
|
+
if (installTrtcNumber > 3) return;
|
|
107
|
+
exec(trtc_electron_sdk, (error, stdout, stderr) => {
|
|
108
|
+
installCb(trtc_electron_sdk, installTrtc, error, stdout, stderr);
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
// installTrtc();
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const downloadFile = (zipFileName, localDir) => {
|
|
115
|
+
const remoteZipFilePath = `${electron_sdk_plugins_dir}${zipFileName}`;
|
|
116
|
+
const localZipFilePath = path.join(localDir, zipFileName);
|
|
117
|
+
logger.info(`will download ${zipFileName} to ${localZipFilePath}`);
|
|
118
|
+
https
|
|
119
|
+
.get(remoteZipFilePath, (response) => {
|
|
120
|
+
const file = fs.createWriteStream(localZipFilePath);
|
|
121
|
+
response.pipe(file);
|
|
122
|
+
file.on('finish', () => {
|
|
123
|
+
file.close(() => {
|
|
124
|
+
logger.info(`文件${zipFileName}写入完成`);
|
|
125
|
+
// 解压缩
|
|
126
|
+
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
127
|
+
execSync(`unzip -o ${localZipFilePath} -d ${localDir}`);
|
|
128
|
+
} else {
|
|
129
|
+
const zip = new AdmZip(localZipFilePath);
|
|
130
|
+
zip.extractAllTo(localDir, true);
|
|
131
|
+
}
|
|
132
|
+
if (fs.existsSync(path.join(localDir, '__MACOSX'))) {
|
|
133
|
+
fs.rmdir(path.join(localDir, '__MACOSX'), { recursive: true, force: true });
|
|
134
|
+
}
|
|
135
|
+
fs.unlink(localZipFilePath, () => {});
|
|
136
|
+
logger.info(`文件${zipFileName}解压完成`);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
.on('error', (err) => {
|
|
141
|
+
// 删除不完整的文件
|
|
142
|
+
fs.unlink(localZipFilePath, () => {});
|
|
143
|
+
logger.error(`download ${zipFileName} failed, delete it`, err.message);
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const downloadPrebuild = async () => {
|
|
148
|
+
logger.info('Package Version: %s', packageVersion);
|
|
149
|
+
logger.info('Platform: %s', platform);
|
|
150
|
+
if (arch) logger.info('Arch: %s', arch);
|
|
151
|
+
|
|
152
|
+
npmInstall();
|
|
153
|
+
|
|
154
|
+
const { flameshotZipName, plasoALDZipName } = getPluginsZipName();
|
|
155
|
+
const localPluginsDir = path.join(__dirname, '../lib');
|
|
156
|
+
if (!fs.existsSync(localPluginsDir)) {
|
|
157
|
+
fs.mkdirSync(localPluginsDir);
|
|
158
|
+
}
|
|
159
|
+
downloadFile(flameshotZipName, localPluginsDir);
|
|
160
|
+
if (platform === PLATFORM_TYPE.DARWIN) {
|
|
161
|
+
downloadFile(plasoALDZipName, localPluginsDir);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
downloadPrebuild();
|