diff --git a/src/index.ts b/src/index.ts index 061b936..272ea6c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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"; @@ -11,8 +18,49 @@ const FakeAgoraRTC = createFakeAgoraRTC({ setAppType(): void { // }, + setArea(): void { + // + }, + checkSystemRequirements(): boolean { + return true; + }, + setLogLevel(): void { + // + }, + getCameras(): Promise { + //todo + return Promise.resolve([]); + }, + getDevices(): Promise { + //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(), }); @@ -24,4 +72,4 @@ export const FakeAgoraRTCWrapper = { getFakeAgoraRTC: getFakeAgoraRTC, }; -export default FakeAgoraRTC; +export default FakeAgoraRTCWrapper; diff --git a/tsup.config.ts b/tsup.config.ts index acc2e76..0617040 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -36,7 +36,7 @@ export default defineConfig([ define: { "process.env.NODE_ENV": JSON.stringify("production"), }, - globalName: "AgoraRTCFake", + globalName: "FakeAgoraRTCWrapper", platform: "browser", }, ]);