Skip to content

Commit

Permalink
change default export (#5)
Browse files Browse the repository at this point in the history
* chore: change default export to FakeAgoraRTCWrapper

* chore:  override AgoraRTC
  • Loading branch information
guoxianzhe authored Oct 17, 2023
1 parent 56e116b commit 0291286
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
50 changes: 49 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import type {
IBufferSourceAudioTrack,
ILocalAudioTrack,
ILocalVideoTrack,
ScreenVideoTrackInitConfig,
} from "agora-rtc-sdk-ng";

import { FakeRTCClient } from "./client";
import { createFakeAgoraRTC } from "./top";
import { FakeCameraVideoTrack, FakeMicrophoneAudioTrack } from "./tracks";
Expand All @@ -11,8 +18,49 @@ const FakeAgoraRTC = createFakeAgoraRTC({
setAppType(): void {
//
},
setArea(): void {
//
},
checkSystemRequirements(): boolean {
return true;
},
setLogLevel(): void {
//
},
getCameras(): Promise<MediaDeviceInfo[]> {
//todo
return Promise.resolve([]);
},
getDevices(): Promise<MediaDeviceInfo[]> {
//todo
return Promise.resolve([]);
},
createMicrophoneAudioTrack: async () => FakeMicrophoneAudioTrack.create(),
createCameraVideoTrack: async () => FakeCameraVideoTrack.create(),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
createScreenVideoTrack(
config: ScreenVideoTrackInitConfig,
withAudio?: "enable" | "disable" | "auto",
): Promise<[ILocalVideoTrack, ILocalAudioTrack] | ILocalVideoTrack> {
// 根据参数返回视频轨 或 [视频轨,音频轨]
if (withAudio === "enable") {
return Promise.resolve([
FakeCameraVideoTrack.create() as ILocalVideoTrack,
FakeMicrophoneAudioTrack.create() as ILocalAudioTrack,
]);
} else if (withAudio === "disable") {
return Promise.resolve(FakeCameraVideoTrack.create() as ILocalVideoTrack);
} else {
return Promise.resolve([
FakeCameraVideoTrack.create() as ILocalVideoTrack,
FakeMicrophoneAudioTrack.create() as ILocalAudioTrack,
]);
}
},
createBufferSourceAudioTrack: async () =>
FakeMicrophoneAudioTrack.create() as unknown as IBufferSourceAudioTrack,
createCustomVideoTrack: () => FakeCameraVideoTrack.create(),
createClient: () => FakeRTCClient.create(),
});

Expand All @@ -24,4 +72,4 @@ export const FakeAgoraRTCWrapper = {
getFakeAgoraRTC: getFakeAgoraRTC,
};

export default FakeAgoraRTC;
export default FakeAgoraRTCWrapper;
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineConfig([
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
globalName: "AgoraRTCFake",
globalName: "FakeAgoraRTCWrapper",
platform: "browser",
},
]);

0 comments on commit 0291286

Please sign in to comment.