Loading .changeset/light-pears-bake.md 0 → 100644 +6 −0 Original line number Diff line number Diff line --- "@yume-chan/adb-scrcpy": minor "@yume-chan/scrcpy": minor --- Add alias for all AdbScrcpyOptions versions libraries/adb-scrcpy/src/1_15/impl/create-connection.ts 0 → 100644 +29 −0 Original line number Diff line number Diff line import type { Adb } from "@yume-chan/adb"; import type { ScrcpyOptions1_15 } from "@yume-chan/scrcpy"; import type { AdbScrcpyConnection, AdbScrcpyConnectionOptions, } from "../../connection.js"; import { AdbScrcpyForwardConnection, AdbScrcpyReverseConnection, } from "../../connection.js"; export function createConnection( adb: Adb, options: Pick<ScrcpyOptions1_15.Init, "tunnelForward">, ): AdbScrcpyConnection { const connectionOptions: AdbScrcpyConnectionOptions = { scid: undefined, // Not Supported video: true, // Always enabled audio: false, // Not Supported control: true, // Always enabled even when `--no-control` is specified sendDummyByte: true, // Always enabled }; if (options.tunnelForward) { return new AdbScrcpyForwardConnection(adb, connectionOptions); } else { return new AdbScrcpyReverseConnection(adb, connectionOptions); } } libraries/adb-scrcpy/src/1_15/impl/get-displays.ts 0 → 100644 +38 −0 Original line number Diff line number Diff line import type { Adb } from "@yume-chan/adb"; import type { ScrcpyDisplay, ScrcpyOptions1_15 } from "@yume-chan/scrcpy"; import { AdbScrcpyClient, AdbScrcpyExitedError } from "../../client.js"; import type { AdbScrcpyOptions } from "../../types.js"; export async function getDisplays( adb: Adb, path: string, options: AdbScrcpyOptions<Pick<ScrcpyOptions1_15.Init, "tunnelForward">>, ): Promise<ScrcpyDisplay[]> { try { // Server will exit before opening connections when an invalid display id was given // so `start` will throw an `AdbScrcpyExitedError` const client = await AdbScrcpyClient.start(adb, path, options); // If the server didn't exit, manually stop it and throw an error await client.close(); throw new Error("Unexpected server output"); } catch (e) { if (e instanceof AdbScrcpyExitedError) { if (e.output[0]?.startsWith("[server] ERROR:")) { throw e; } const displays: ScrcpyDisplay[] = []; for (const line of e.output) { const display = options.parseDisplay(line); if (display) { displays.push(display); } } return displays; } throw e; } } libraries/adb-scrcpy/src/1_15/impl/get-encoders.ts 0 → 100644 +24 −0 Original line number Diff line number Diff line import type { Adb } from "@yume-chan/adb"; import type { ScrcpyEncoder, ScrcpyOptions1_15 } from "@yume-chan/scrcpy"; import { AdbScrcpyClient } from "../../client.js"; import type { AdbScrcpyOptions } from "../../types.js"; export async function getEncoders( adb: Adb, path: string, options: AdbScrcpyOptions<Pick<ScrcpyOptions1_15.Init, "tunnelForward">>, ): Promise<ScrcpyEncoder[]> { const client = await AdbScrcpyClient.start(adb, path, options); const encoders: ScrcpyEncoder[] = []; for await (const line of client.stdout) { const encoder = options.parseEncoder(line); if (encoder) { encoders.push(encoder); } } return encoders; } libraries/adb-scrcpy/src/1_15/impl/index.ts 0 → 100644 +3 −0 Original line number Diff line number Diff line export * from "./create-connection.js"; export * from "./get-displays.js"; export * from "./get-encoders.js"; Loading
.changeset/light-pears-bake.md 0 → 100644 +6 −0 Original line number Diff line number Diff line --- "@yume-chan/adb-scrcpy": minor "@yume-chan/scrcpy": minor --- Add alias for all AdbScrcpyOptions versions
libraries/adb-scrcpy/src/1_15/impl/create-connection.ts 0 → 100644 +29 −0 Original line number Diff line number Diff line import type { Adb } from "@yume-chan/adb"; import type { ScrcpyOptions1_15 } from "@yume-chan/scrcpy"; import type { AdbScrcpyConnection, AdbScrcpyConnectionOptions, } from "../../connection.js"; import { AdbScrcpyForwardConnection, AdbScrcpyReverseConnection, } from "../../connection.js"; export function createConnection( adb: Adb, options: Pick<ScrcpyOptions1_15.Init, "tunnelForward">, ): AdbScrcpyConnection { const connectionOptions: AdbScrcpyConnectionOptions = { scid: undefined, // Not Supported video: true, // Always enabled audio: false, // Not Supported control: true, // Always enabled even when `--no-control` is specified sendDummyByte: true, // Always enabled }; if (options.tunnelForward) { return new AdbScrcpyForwardConnection(adb, connectionOptions); } else { return new AdbScrcpyReverseConnection(adb, connectionOptions); } }
libraries/adb-scrcpy/src/1_15/impl/get-displays.ts 0 → 100644 +38 −0 Original line number Diff line number Diff line import type { Adb } from "@yume-chan/adb"; import type { ScrcpyDisplay, ScrcpyOptions1_15 } from "@yume-chan/scrcpy"; import { AdbScrcpyClient, AdbScrcpyExitedError } from "../../client.js"; import type { AdbScrcpyOptions } from "../../types.js"; export async function getDisplays( adb: Adb, path: string, options: AdbScrcpyOptions<Pick<ScrcpyOptions1_15.Init, "tunnelForward">>, ): Promise<ScrcpyDisplay[]> { try { // Server will exit before opening connections when an invalid display id was given // so `start` will throw an `AdbScrcpyExitedError` const client = await AdbScrcpyClient.start(adb, path, options); // If the server didn't exit, manually stop it and throw an error await client.close(); throw new Error("Unexpected server output"); } catch (e) { if (e instanceof AdbScrcpyExitedError) { if (e.output[0]?.startsWith("[server] ERROR:")) { throw e; } const displays: ScrcpyDisplay[] = []; for (const line of e.output) { const display = options.parseDisplay(line); if (display) { displays.push(display); } } return displays; } throw e; } }
libraries/adb-scrcpy/src/1_15/impl/get-encoders.ts 0 → 100644 +24 −0 Original line number Diff line number Diff line import type { Adb } from "@yume-chan/adb"; import type { ScrcpyEncoder, ScrcpyOptions1_15 } from "@yume-chan/scrcpy"; import { AdbScrcpyClient } from "../../client.js"; import type { AdbScrcpyOptions } from "../../types.js"; export async function getEncoders( adb: Adb, path: string, options: AdbScrcpyOptions<Pick<ScrcpyOptions1_15.Init, "tunnelForward">>, ): Promise<ScrcpyEncoder[]> { const client = await AdbScrcpyClient.start(adb, path, options); const encoders: ScrcpyEncoder[] = []; for await (const line of client.stdout) { const encoder = options.parseEncoder(line); if (encoder) { encoders.push(encoder); } } return encoders; }
libraries/adb-scrcpy/src/1_15/impl/index.ts 0 → 100644 +3 −0 Original line number Diff line number Diff line export * from "./create-connection.js"; export * from "./get-displays.js"; export * from "./get-encoders.js";