Skip to content

Commit 17b9f71

Browse files
author
chengjiao
committed
feat: refactor code style and update package configurations
1 parent f3de8ca commit 17b9f71

File tree

140 files changed

+17343
-5712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+17343
-5712
lines changed

ExtensionDemo/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# Agora-RTE-Extension Demo
2+
23
A simple demo for how to create video and audio extension for Agora Web SDK NG.
34

45
Detailed documentation [here](https://docs.agora.io/en/extension_vendor/plugin_web_ng?platform=Web).
56

67
## Install Dependencies
8+
79
```shell
810
npm install
911
```
1012

1113
## Build
14+
1215
```shell
1316
npm run build
1417
```
1518

1619
## Run the demo
20+
1721
```shell
1822
npm run demo
1923
```
20-

ExtensionDemo/babel.config.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"presets": [
3-
"@babel/preset-typescript",
4-
"@babel/preset-env"
5-
]
6-
}
2+
"presets": ["@babel/preset-typescript", "@babel/preset-env"]
3+
}

ExtensionDemo/index.html

+44-45
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport"
6-
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
7-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8-
<title>Document</title>
9-
<style>
10-
.video-container{
11-
width:640px;
12-
height:480px;
13-
}
14-
</style>
15-
<script src="./dist/index.js"></script>
16-
<script src="https://download.agora.io/sdk/release/AgoraRTC_N-4.11.0.js"></script>
17-
</head>
18-
<body>
19-
<div class="video-container">
20-
</div>
21-
22-
<script>
23-
async function main(){
24-
//create extension
25-
const videoExtension = new SimpleExtension.SimpleVideoExtension();
26-
27-
//register extension
28-
AgoraRTC.registerExtensions([videoExtension]);
29-
30-
//create processor
31-
const processor = videoExtension.createProcessor();
32-
33-
//create CameraVideoTrack
34-
const videoTrack = await AgoraRTC.createCameraVideoTrack();
35-
36-
//piping processor
37-
videoTrack.pipe(processor).pipe(videoTrack.processorDestination);
38-
39-
videoTrack.play(document.querySelector('.video-container'));
40-
}
41-
42-
main();
43-
44-
</script>
45-
46-
</body>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
8+
/>
9+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
10+
<title>Document</title>
11+
<style>
12+
.video-container {
13+
width: 640px;
14+
height: 480px;
15+
}
16+
</style>
17+
<script src="./dist/index.js"></script>
18+
<script src="https://download.agora.io/sdk/release/AgoraRTC_N-4.11.0.js"></script>
19+
</head>
20+
<body>
21+
<div class="video-container"></div>
22+
23+
<script>
24+
async function main() {
25+
//create extension
26+
const videoExtension = new SimpleExtension.SimpleVideoExtension();
27+
28+
//register extension
29+
AgoraRTC.registerExtensions([videoExtension]);
30+
31+
//create processor
32+
const processor = videoExtension.createProcessor();
33+
34+
//create CameraVideoTrack
35+
const videoTrack = await AgoraRTC.createCameraVideoTrack();
36+
37+
//piping processor
38+
videoTrack.pipe(processor).pipe(videoTrack.processorDestination);
39+
40+
videoTrack.play(document.querySelector(".video-container"));
41+
}
42+
43+
main();
44+
</script>
45+
</body>
4746
</html>

ExtensionDemo/src/audio-extension.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { AudioExtension, AudioProcessor, IAudioProcessorContext } from 'agora-rte-extension'
1+
import { AudioExtension, AudioProcessor, IAudioProcessorContext } from "agora-rte-extension";
22

33
class SimpleAudioExtension extends AudioExtension<SimpleAudioProcessor> {
44
protected _createProcessor(): SimpleAudioProcessor {
55
return new SimpleAudioProcessor();
66
}
7-
87
}
98

109
class SimpleAudioProcessor extends AudioProcessor {
@@ -28,7 +27,6 @@ class SimpleAudioProcessor extends AudioProcessor {
2827
this.gainNode = undefined;
2928
this.oscillatorNode?.stop();
3029
this.oscillatorNode = undefined;
31-
3230
}
3331

3432
protected onEnableChange(enabled: boolean): void | Promise<void> {
@@ -50,4 +48,4 @@ class SimpleAudioProcessor extends AudioProcessor {
5048
}
5149
}
5250

53-
export { SimpleAudioExtension }
51+
export { SimpleAudioExtension };

ExtensionDemo/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { SimpleAudioExtension } from "./audio-extension";
22
import { SimpleVideoExtension } from "./video-extension";
33

4-
export { SimpleAudioExtension, SimpleVideoExtension }
4+
export { SimpleAudioExtension, SimpleVideoExtension };

ExtensionDemo/src/video-extension.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Extension, VideoProcessor, Ticker, IProcessorContext } from 'agora-rte-extension'
1+
import { Extension, VideoProcessor, Ticker, IProcessorContext } from "agora-rte-extension";
22

33
class SimpleVideoExtension extends Extension<SimpleVideoProcessor> {
44
protected _createProcessor(): SimpleVideoProcessor {
55
return new SimpleVideoProcessor();
66
}
7-
87
}
98

109
class SimpleVideoProcessor extends VideoProcessor {
@@ -18,11 +17,11 @@ class SimpleVideoProcessor extends VideoProcessor {
1817
public constructor() {
1918
super();
2019

21-
this.canvas = document.createElement('canvas');
20+
this.canvas = document.createElement("canvas");
2221
this.canvas.width = 640;
2322
this.canvas.height = 480;
24-
this.ctx = this.canvas.getContext('2d')!;
25-
this.videoElement = document.createElement('video');
23+
this.ctx = this.canvas.getContext("2d")!;
24+
this.videoElement = document.createElement("video");
2625
this.videoElement.muted = true;
2726
const outputStream = this.canvas.captureStream(30);
2827
this.canvasTrack = outputStream.getVideoTracks()[0];
@@ -37,7 +36,7 @@ class SimpleVideoProcessor extends VideoProcessor {
3736
this.ctx.fillStyle = "red";
3837
this.ctx.fillRect(0, 0, 100, 100);
3938
}
40-
}
39+
};
4140

4241
protected onEnableChange(enabled: boolean): void | Promise<void> {
4342
if (!this.context) {
@@ -61,7 +60,7 @@ class SimpleVideoProcessor extends VideoProcessor {
6160
this.videoElement.onplaying = () => {
6261
this.canvas.width = this.videoElement.videoWidth;
6362
this.canvas.height = this.videoElement.videoHeight;
64-
}
63+
};
6564

6665
if (this.enabled) {
6766
this.ticker.start();
@@ -77,4 +76,4 @@ class SimpleVideoProcessor extends VideoProcessor {
7776
}
7877
}
7978

80-
export { SimpleVideoExtension }
79+
export { SimpleVideoExtension };

ExtensionDemo/tsconfig.json

+4-13
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
"moduleResolution": "node",
55
"target": "es5",
66
"module": "umd",
7-
"lib": [
8-
"es2015",
9-
"es2016",
10-
"es2017",
11-
"dom"
12-
],
7+
"lib": ["es2015", "es2016", "es2017", "dom"],
138
"strict": true,
149
"strictNullChecks": true,
1510
"strictPropertyInitialization": true,
@@ -25,11 +20,7 @@
2520
"stripInternal": true,
2621
"isolatedModules": true,
2722
"outDir": "./dist",
28-
"typeRoots": [
29-
"node_modules/@types"
30-
]
23+
"typeRoots": ["node_modules/@types"]
3124
},
32-
"include": [
33-
"src/**/*"
34-
]
35-
}
25+
"include": ["src/**/*"]
26+
}

ExtensionDemo/webpack.config.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ module.exports = {
99
filename: "index.js",
1010
library: {
1111
type: "umd",
12-
name: "SimpleExtension"
13-
}
12+
name: "SimpleExtension",
13+
},
1414
},
1515
module: {
1616
rules: [
1717
{
1818
test: /.ts$/,
19-
include: path.resolve(ROOT, 'src'),
19+
include: path.resolve(ROOT, "src"),
2020
exclude: /node_modules/,
21-
loader: 'babel-loader'
22-
}
23-
]
21+
loader: "babel-loader",
22+
},
23+
],
2424
},
2525
resolve: {
26-
extensions: ['.ts', '.js']
27-
}
28-
}
26+
extensions: [".ts", ".js"],
27+
},
28+
};

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
"main": "index.js",
66
"scripts": {
77
"dev": "node ./scripts/server.js",
8-
"pure": "node ./scripts/pure.js"
8+
"pure": "node ./scripts/pure.js",
9+
"lint": "prettier . --write --ignore-unknown"
910
},
1011
"devDependencies": {
11-
"express":"^4.18.2"
12+
"express": "^4.18.2",
13+
"prettier": "^3.3.3"
1214
},
1315
"author": "qz",
14-
"license": "ISC"
16+
"license": "ISC",
17+
"packageManager": "[email protected]"
1518
}

0 commit comments

Comments
 (0)