Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change default export #5

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
},
]);