UNPKG

@yume-chan/adb-scrcpy

Version:

Use `@yume-chan/adb` to bootstrap `@yume-chan/scrcpy`.

28 lines 1.04 kB
import { AdbScrcpyClient, AdbScrcpyExitedError } from "../../client.js"; export async function getDisplays(adb, path, options) { 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 = []; for (const line of e.output) { const display = options.parseDisplay(line); if (display) { displays.push(display); } } return displays; } throw e; } } //# sourceMappingURL=get-displays.js.map