Skip to content

Commit fee78ef

Browse files
xiayangqun夏羊群sda-rob
authored
Jira/csd 70752/main (#1275)
* feat: update dependencies * Fix: 修复 package.json 中的命令行参数,使其与 Gulp 5.0.0 兼容 * Fix: 修复代码格式问题和未使用的函数 * feat: downlaod.js * feat: roll back example * feat: remove pwd * chore: roll back package.json * chore: delete un used code * chore: make-dir update to 5.0.0 * chore: update node version * chore: release 0.0.0-dev.1 * chore(example): update example to install agora-electron-sdk@0.0.0-dev.1 * chore: release 4.5.2-dev.1 * chore(example): update example to install agora-electron-sdk@4.5.2-dev.1 * chore: yarn.lock * chore: roll back node version to 16.18.1 * chore: yarn.lock * chore: release 4.5.2-dev.2 * chore(example): update example to install agora-electron-sdk@4.5.2-dev.2 * chore: roll back version and CHANGELOGA.md * chore: roll back CHANNGLOG.md --------- Co-authored-by: 夏羊群 <xiayangqun@agora.io> Co-authored-by: sda_rob <sda_rob@agora.io>
1 parent dac7a1f commit fee78ef

File tree

7 files changed

+734
-1680
lines changed

7 files changed

+734
-1680
lines changed

package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,32 @@
131131
"dependencies": {
132132
"buffer": "^6.0.3",
133133
"cross-env": "^7.0.3",
134-
"download": "^8.0.0",
134+
"node-fetch": "^2.7.0",
135+
"extract-zip": "^2.0.1",
135136
"eventemitter3": "^5.0.1",
136137
"fs-extra": "^11.1.1",
137-
"gulp": "^4.0.2",
138+
"gulp": "^5.0.0",
138139
"json-bigint": "^1.0.0",
139140
"jsonfile": "^6.1.0",
140141
"lodash.isequal": "^4.5.0",
141-
"minimist": "^1.2.5",
142+
"minimist": "^1.2.8",
143+
"shelljs": "^0.8.5",
142144
"semver": "^7.6.0",
143-
"shelljs": "^0.8.4",
144145
"ts-interface-checker": "^1.0.2",
145-
"winston": "^3.3.3",
146+
"winston": "^3.11.0",
146147
"yuv-buffer": "1.0.0",
147-
"yuv-canvas": "1.2.6"
148+
"yuv-canvas": "1.2.6",
149+
"archive-type": "^4.0.0",
150+
"content-disposition": "^0.5.2",
151+
"decompress": "^4.2.1",
152+
"ext-name": "^5.0.0",
153+
"file-type": "^11.1.0",
154+
"filenamify": "^3.0.0",
155+
"get-stream": "^4.1.0",
156+
"got": "^11.8.5",
157+
"make-dir": "^4.0.0",
158+
"p-event": "^2.1.0",
159+
"pify": "^4.0.1"
148160
},
149161
"agora_electron": {
150162
"iris_sdk_win": "https://download.agora.io/sdk/release/iris_4.5.1-build.1_DCG_Windows_Video_Standalone_20250305_1103_622.zip",

scripts/checkElectron.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const path = require('path');
22

3-
const download = require('download');
4-
53
const { cleanDir } = require('./clean');
4+
const download = require('./download');
5+
66
const getConfig = require('./getConfig');
77
const logger = require('./logger');
88

@@ -30,9 +30,11 @@ const checkElectron = async (cb) => {
3030
let downloadUrl = `https://download.agora.io/sdk/release/electron-v${electron_version}-${platform}-${arch}.zip`;
3131
logger.info(`Downloading:${downloadUrl}`);
3232
await cleanDir(tp);
33+
3334
await download(downloadUrl, tp, {
3435
extract: true,
3536
});
37+
3638
logger.info(`Finish download:${downloadUrl}`);
3739
logger.info(`sync electron success`);
3840
cb();

scripts/download.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
'use strict';
2+
const fs = require('fs');
3+
const path = require('path');
4+
const { URL } = require('url');
5+
6+
const archiveType = require('archive-type');
7+
const contentDisposition = require('content-disposition');
8+
const decompress = require('decompress');
9+
const extName = require('ext-name');
10+
const fileType = require('file-type');
11+
const filenamify = require('filenamify');
12+
const getStream = require('get-stream');
13+
const got = require('got');
14+
const makeDir = require('make-dir');
15+
const pEvent = require('p-event');
16+
const pify = require('pify');
17+
18+
const fsP = pify(fs);
19+
const filenameFromPath = (res) =>
20+
path.basename(new URL(res.requestUrl).pathname);
21+
22+
const getExtFromMime = (res) => {
23+
const header = res.headers['content-type'];
24+
25+
if (!header) {
26+
return null;
27+
}
28+
29+
const exts = extName.mime(header);
30+
31+
if (exts.length !== 1) {
32+
return null;
33+
}
34+
35+
return exts[0].ext;
36+
};
37+
38+
const getFilename = (res, data) => {
39+
const header = res.headers['content-disposition'];
40+
41+
if (header) {
42+
const parsed = contentDisposition.parse(header);
43+
44+
if (parsed.parameters && parsed.parameters.filename) {
45+
return parsed.parameters.filename;
46+
}
47+
}
48+
49+
let filename = filenameFromPath(res);
50+
51+
if (!path.extname(filename)) {
52+
const ext = (fileType(data) || {}).ext || getExtFromMime(res);
53+
54+
if (ext) {
55+
filename = `${filename}.${ext}`;
56+
}
57+
}
58+
59+
return filename;
60+
};
61+
62+
module.exports = (uri, output, opts) => {
63+
opts = {
64+
...opts,
65+
encoding: null,
66+
responseType: 'buffer',
67+
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false',
68+
};
69+
70+
const stream = got.stream(uri);
71+
72+
const promise = pEvent(stream, 'response')
73+
.then((res) => {
74+
const encoding = opts.encoding === null ? 'buffer' : opts.encoding;
75+
return Promise.all([getStream(stream, { encoding }), res]);
76+
})
77+
.then((result) => {
78+
const [data, res] = result;
79+
80+
if (!output) {
81+
return opts.extract && archiveType(data)
82+
? decompress(data, opts)
83+
: data;
84+
}
85+
86+
const filename = opts.filename || filenamify(getFilename(res, data));
87+
const outputFilepath = path.join(output, filename);
88+
89+
if (opts.extract && archiveType(data)) {
90+
return decompress(data, path.dirname(outputFilepath), opts);
91+
}
92+
93+
return makeDir(path.dirname(outputFilepath))
94+
.then(() => fsP.writeFile(outputFilepath, data))
95+
.then(() => data);
96+
});
97+
98+
stream.then = promise.then.bind(promise);
99+
stream.catch = promise.catch.bind(promise);
100+
101+
return stream;
102+
};

scripts/downloadPrebuild.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const path = require('path');
22

3-
const download = require('download');
43
const fs = require('fs-extra');
54

65
const { cleanDir, buildDir } = require('./clean');
6+
const download = require('./download');
7+
78
const getConfig = require('./getConfig');
89
const logger = require('./logger');
910
const { getOS } = require('./util');

scripts/synclib.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const path = require('path');
22

3-
const download = require('download');
4-
53
const { destIrisSDKDir, cleanDir, destNativeSDKDir } = require('./clean');
4+
const download = require('./download');
5+
66
const getConfig = require('./getConfig');
77
const logger = require('./logger');
88
const { getOS, moveFile, getIrisStandAlone } = require('./util');

ts/Utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ export function classMix(...mixins: any[]): any {
100100
class MixClass {
101101
constructor() {
102102
for (let mixin of mixins) {
103-
copyProperties(this, new mixin()); // 拷贝实例属性
103+
copyProperties(this, new mixin()); // Copy instance properties
104104
}
105105
}
106106
}
107107

108108
for (let mixin of mixins) {
109-
copyProperties(MixClass, mixin); // 拷贝静态属性
110-
copyProperties(MixClass.prototype, mixin.prototype); // 拷贝原型属性
109+
copyProperties(MixClass, mixin); // Copy static properties
110+
copyProperties(MixClass.prototype, mixin.prototype); // Copy prototype properties
111111
}
112112

113113
return MixClass;

0 commit comments

Comments
 (0)