MCPcopy
hub / github.com/yume-chan/ya-webadb / getDisplays

Function getDisplays

libraries/adb-scrcpy/src/1_15/impl/get-displays.ts:7–38  ·  view source on GitHub ↗
(
    adb: Adb,
    path: string,
    options: AdbScrcpyOptions<Pick<ScrcpyOptions1_15.Init, "tunnelForward">>,
)

Source from the content-addressed store, hash-verified

5import type { AdbScrcpyOptions } from "../../types.js";
6
7export async function getDisplays(
8 adb: Adb,
9 path: string,
10 options: AdbScrcpyOptions<Pick<ScrcpyOptions1_15.Init, "tunnelForward">>,
11): Promise<ScrcpyDisplay[]> {
12 try {
13 // Server will exit before opening connections when an invalid display id was given
14 // so `start` will throw an `AdbScrcpyExitedError`
15 const client = await AdbScrcpyClient.start(adb, path, options);
16
17 // If the server didn't exit, manually stop it and throw an error
18 await client.close();
19 throw new Error("Unexpected server output");
20 } catch (e) {
21 if (e instanceof AdbScrcpyExitedError) {
22 if (e.output[0]?.startsWith("[server] ERROR:")) {
23 throw e;
24 }
25
26 const displays: ScrcpyDisplay[] = [];
27 for (const line of e.output) {
28 const display = options.parseDisplay(line);
29 if (display) {
30 displays.push(display);
31 }
32 }
33 return displays;
34 }
35
36 throw e;
37 }
38}

Callers 15

getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85
getDisplaysMethod · 0.85

Calls 4

pushMethod · 0.80
startMethod · 0.65
closeMethod · 0.65
parseDisplayMethod · 0.65

Tested by

no test coverage detected