diff --git a/libraries/adb-daemon-webusb/src/manager.spec.ts b/libraries/adb-daemon-webusb/src/manager.spec.ts index f260f15f0..14ab8aa41 100644 --- a/libraries/adb-daemon-webusb/src/manager.spec.ts +++ b/libraries/adb-daemon-webusb/src/manager.spec.ts @@ -12,7 +12,45 @@ class MockUsb implements USB { getDevices = mock.fn(async () => []); requestDevice = mock.fn( - async () => ({ serialNumber: "abcdefgh" }) as never, + async (options?: USBDeviceRequestOptions) => + ({ + serialNumber: options?.filters?.[0]?.serialNumber ?? "abcdefgh", + vendorId: options?.filters?.[0]?.vendorId ?? 0x18d1, + productId: options?.filters?.[0]?.productId ?? 0x4e49, + configurations: [ + { + configurationValue: 1, + interfaces: [ + { + interfaceNumber: 0, + claimed: false, + alternate: { + alternateSetting: 0, + interfaceClass: + AdbDefaultInterfaceFilter.classCode, + interfaceSubclass: + AdbDefaultInterfaceFilter.subclassCode, + interfaceProtocol: + AdbDefaultInterfaceFilter.protocolCode, + endpoints: [], + }, + alternates: [ + { + alternateSetting: 0, + interfaceClass: + AdbDefaultInterfaceFilter.classCode, + interfaceSubclass: + AdbDefaultInterfaceFilter.subclassCode, + interfaceProtocol: + AdbDefaultInterfaceFilter.protocolCode, + endpoints: [], + }, + ], + }, + ], + }, + ], + }) satisfies Partial as never, ); addEventListener( diff --git a/libraries/scrcpy/src/2_3/impl/init.ts b/libraries/scrcpy/src/2_3/impl/init.ts index e85e4eb26..3b1dadcd0 100644 --- a/libraries/scrcpy/src/2_3/impl/init.ts +++ b/libraries/scrcpy/src/2_3/impl/init.ts @@ -1,5 +1,5 @@ import type { PrevImpl } from "./prev.js"; export interface Init extends Omit { - audioCodec?: "raw" | "opus" | "aac" | "flac"; + audioCodec?: PrevImpl.Init["audioCodec"] | "flac"; } diff --git a/libraries/scrcpy/src/2_6/impl/init.ts b/libraries/scrcpy/src/2_6/impl/init.ts index 0e91d26ab..31fdc6949 100644 --- a/libraries/scrcpy/src/2_6/impl/init.ts +++ b/libraries/scrcpy/src/2_6/impl/init.ts @@ -1,5 +1,6 @@ import type { PrevImpl } from "./prev.js"; -export interface Init extends PrevImpl.Init { +export interface Init extends Omit { + audioSource?: PrevImpl.Init["audioSource"] | "playback"; audioDup?: boolean; } diff --git a/libraries/scrcpy/src/2_6/options.ts b/libraries/scrcpy/src/2_6/options.ts index 11df0f97f..8c895b12e 100644 --- a/libraries/scrcpy/src/2_6/options.ts +++ b/libraries/scrcpy/src/2_6/options.ts @@ -71,6 +71,10 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions { this.value.control = false; } + if (this.value.audioDup) { + this.value.audioSource = "playback"; + } + if (this.value.control) { if (this.value.clipboardAutosync) { this.#clipboard = new ClipboardStream(); diff --git a/libraries/scrcpy/src/2_7/options.ts b/libraries/scrcpy/src/2_7/options.ts index 4d8595c31..e46f56904 100644 --- a/libraries/scrcpy/src/2_7/options.ts +++ b/libraries/scrcpy/src/2_7/options.ts @@ -71,6 +71,10 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions { this.value.control = false; } + if (this.value.audioDup) { + this.value.audioSource = "playback"; + } + if (this.value.control) { if (this.value.clipboardAutosync) { this.#clipboard = new ClipboardStream(); diff --git a/libraries/scrcpy/src/3_0/options.ts b/libraries/scrcpy/src/3_0/options.ts index 047ee1e1d..450228525 100644 --- a/libraries/scrcpy/src/3_0/options.ts +++ b/libraries/scrcpy/src/3_0/options.ts @@ -71,6 +71,10 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions { this.value.control = false; } + if (this.value.audioDup) { + this.value.audioSource = "playback"; + } + if (this.value.control) { if (this.value.clipboardAutosync) { this.#clipboard = new ClipboardStream(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9fe883ec..01f48aeaa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -534,6 +534,9 @@ importers: '@yume-chan/adb': specifier: workspace:^ version: link:../../libraries/adb + '@yume-chan/scrcpy': + specifier: workspace:^ + version: link:../../libraries/scrcpy '@yume-chan/struct': specifier: workspace:^ version: link:../../libraries/struct diff --git a/toolchain/side-effect-test/package.json b/toolchain/side-effect-test/package.json index 02ead8eb0..f87caf4bb 100644 --- a/toolchain/side-effect-test/package.json +++ b/toolchain/side-effect-test/package.json @@ -19,6 +19,7 @@ }, "dependencies": { "@yume-chan/adb": "workspace:^", - "@yume-chan/struct": "workspace:^" + "@yume-chan/struct": "workspace:^", + "@yume-chan/scrcpy": "workspace:^" } } diff --git a/toolchain/side-effect-test/src/index.js b/toolchain/side-effect-test/src/index.js index 052319191..d34ef8b88 100644 --- a/toolchain/side-effect-test/src/index.js +++ b/toolchain/side-effect-test/src/index.js @@ -30,4 +30,5 @@ u64(1); u8(1); struct({}, {}); +export * from "@yume-chan/scrcpy"; export * from "@yume-chan/struct";