trtc-electron-sdk 10.3.112-beta.7 → 10.3.112-beta.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "10.3.112-beta.7",
3
+ "version": "10.3.112-beta.9",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",
@@ -1,6 +1,7 @@
1
1
  module.exports.Platform = {
2
- MACOS: 'mac',
2
+ MACOS: 'mac', // mac-x64
3
+ MACOS_ARM: 'mac-arm64',
3
4
  WINDOWS32: 'win32',
4
5
  WINDOWS64: 'win64',
5
6
  UNSUPPORTED: 'unsupported'
6
- };
7
+ };
@@ -12,6 +12,7 @@ const {
12
12
  detectOwnVersion,
13
13
  detectOwnName,
14
14
  } = require('./utils');
15
+ const { Platform } = require('./constant');
15
16
 
16
17
  const buildDownloadInfo = () => {
17
18
  const configArgv = Object.assign({}, readCliArgv(), readArgvFromNpmEnv());
@@ -28,22 +29,25 @@ const buildDownloadInfo = () => {
28
29
 
29
30
  // generate download url
30
31
  return {
31
- packageVersion: version,
32
32
  platform: osLabel,
33
- downloadUrl: `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${osLabel}-${version}.zip`
33
+ downloadUrl: `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${osLabel}-${version}.zip`,
34
+ name,
35
+ version
34
36
  };
35
37
  };
36
38
 
37
39
  const main = () => {
38
40
  const {
39
- packageVersion,
40
41
  platform,
41
- downloadUrl
42
+ downloadUrl,
43
+ name,
44
+ version
42
45
  } = buildDownloadInfo();
43
46
 
44
- const outputDir = './temp';
47
+ const outputDir = path.join(__dirname, '../temp');
45
48
  const buildDir = path.join(__dirname, '../build');
46
49
 
50
+ rimraf.sync(outputDir);
47
51
  rimraf(buildDir, err => {
48
52
  if (err) {
49
53
  signale.fatal(err);
@@ -54,33 +58,79 @@ const main = () => {
54
58
  signale.info('removeDir =', buildDir);
55
59
  signale.info('outputDir =', outputDir);
56
60
 
57
- signale.info('Package Version =', packageVersion);
61
+ signale.info('Package Version =', version);
58
62
  signale.info('Platform =', platform);
59
63
  signale.info('Download Url =', downloadUrl, '\n');
60
64
 
61
- // start
62
65
  signale.pending('Downloading C++ addon Electron SDK...\n');
63
66
  download(downloadUrl, outputDir, {
64
67
  strip: 0,
65
68
  extract: true
66
69
  }).then(() => {
67
- signale.success('Success', 'Download finished');
70
+ signale.success(`Download finished - ${platform}`);
68
71
 
69
- fs.copy(path.join(outputDir, './build'), buildDir)
70
- .then(() => {
71
- console.log('copy success!');
72
- rimraf.sync(outputDir);
72
+ fs.copySync(
73
+ path.join(outputDir, './build/Release'),
74
+ path.join(buildDir, 'Release')
75
+ );
76
+ signale.success(`copy success! - ${platform}`);
77
+
78
+ if (platform === Platform.WINDOWS32 || platform === Platform.WINDOWS64) {
79
+ rimraf.sync(outputDir); // windows 下
80
+ } else {
81
+ // mac 下
82
+ const arch = process.arch;
83
+ fs.copySync(
84
+ path.join(outputDir, './build/Release/trtc_electron_sdk.node'),
85
+ path.join(buildDir, 'Release', arch, 'trtc_electron_sdk.node')
86
+ );
87
+ fs.copySync(
88
+ path.join(outputDir, './build/mac-framework'),
89
+ path.join(buildDir, 'mac-framework')
90
+ );
91
+ signale.success(`copy success! - mac ${arch}`, '\n');
92
+
93
+ let anotherPlatform, anotherArch;
94
+ if (arch === 'x64') {
95
+ // download arm64
96
+ anotherPlatform = Platform.MACOS_ARM;
97
+ anotherArch = 'arm64';
98
+ } else {
99
+ // arch = arm64, download x64
100
+ anotherPlatform = Platform.MACOS;
101
+ anotherArch = 'x64';
102
+ }
103
+ const anotherDownloadUrl = `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${anotherPlatform}-${version}.zip`;
104
+ signale.info('Download Url =', anotherDownloadUrl, '\n');
105
+ signale.pending(`Downloading C++ addon Electron SDK... ${anotherArch}\n`);
106
+ download(anotherDownloadUrl, path.join(outputDir, anotherPlatform), {
107
+ strip: 0,
108
+ extract: true
109
+ })
110
+ .then(() => {
111
+ signale.success(`Download finished - mac ${anotherArch}`);
112
+
113
+ fs.copySync(
114
+ path.join(outputDir, anotherPlatform, '/build/Release/trtc_electron_sdk.node'),
115
+ path.join(buildDir, 'Release', anotherArch, 'trtc_electron_sdk.node')
116
+ );
117
+ signale.success(`copy success! - mac ${anotherArch}`);
73
118
 
74
- if (process.platform === 'darwin') {
75
119
  // Mac 下完成文件下载后,执行该命令,同步文件到 Electron 目录下
120
+ // exec('npm run postinstall-mac');
121
+ // exec(`rsync -a ../../node_modules/trtc-electron-sdk/build/mac-framework/${process.arch}/ ../../node_modules/electron/dist/Electron.app/Contents/Frameworks`);
76
122
  exec(`rsync -a ../../node_modules/trtc-electron-sdk/build/mac-framework/ ../../node_modules/electron/dist/Electron.app/Contents/Frameworks`);
77
- }
78
- })
79
- .catch(err => console.error(err));
123
+
124
+ rimraf.sync(outputDir);
125
+ })
126
+ .catch(err => {
127
+ signale.fatal(`download error! - mac ${anotherPlatform}`, err);
128
+ });
129
+ }
80
130
  }).catch(err => {
81
- signale.fatal('Failed', err);
131
+ signale.fatal(`Failed! Download error - ${platform}`, err);
82
132
  });
83
133
  });
84
134
  };
85
135
 
86
- main();
136
+ main();
package/scripts/utils.js CHANGED
@@ -43,7 +43,11 @@ module.exports.detectOS = (archType = '') => {
43
43
  const platform = process.platform;
44
44
  const arch = archType !== '' ? archType : process.arch;
45
45
  if (platform === 'darwin') {
46
- return Platform.MACOS;
46
+ if (arch === 'x64') {
47
+ return Platform.MACOS;
48
+ } else {
49
+ return Platform.MACOS_ARM;
50
+ }
47
51
  }
48
52
  if (platform === 'win32') {
49
53
  if (arch === 'x64') {
@@ -66,4 +70,3 @@ module.exports.detectOwnName = () => {
66
70
  const name = pkg.name;
67
71
  return name;
68
72
  };
69
-