feat(adb-scrcpy): add aliases for all AdbScrcpyOptions versions

This commit is contained in:
Simon Chan 2025-01-27 12:44:57 +08:00
parent 7ad568d1b5
commit 02f5bd5929
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
80 changed files with 1181 additions and 331 deletions

View file

@ -0,0 +1,40 @@
import type { Adb } from "@yume-chan/adb";
import type { ScrcpyOptions2_1 } from "@yume-chan/scrcpy";
import { toScrcpyOptionValue } from "@yume-chan/scrcpy";
import type {
AdbScrcpyConnection,
AdbScrcpyConnectionOptions,
} from "../../connection.js";
import {
AdbScrcpyForwardConnection,
AdbScrcpyReverseConnection,
} from "../../connection.js";
export function createConnection(
adb: Adb,
options: Required<
Pick<
ScrcpyOptions2_1.Init,
| "tunnelForward"
| "control"
| "sendDummyByte"
| "scid"
| "audio"
| "video"
>
>,
): AdbScrcpyConnection {
const connectionOptions: AdbScrcpyConnectionOptions = {
scid: toScrcpyOptionValue(options.scid, undefined),
video: options.video,
audio: options.audio,
control: options.control,
sendDummyByte: options.sendDummyByte,
};
if (options.tunnelForward) {
return new AdbScrcpyForwardConnection(adb, connectionOptions);
} else {
return new AdbScrcpyReverseConnection(adb, connectionOptions);
}
}