mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 09:49:24 +02:00
feat(adb-scrcpy): add aliases for all AdbScrcpyOptions versions
This commit is contained in:
parent
7ad568d1b5
commit
02f5bd5929
80 changed files with 1181 additions and 331 deletions
6
.changeset/light-pears-bake.md
Normal file
6
.changeset/light-pears-bake.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
"@yume-chan/adb-scrcpy": minor
|
||||||
|
"@yume-chan/scrcpy": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add alias for all AdbScrcpyOptions versions
|
29
libraries/adb-scrcpy/src/1_15/impl/create-connection.ts
Normal file
29
libraries/adb-scrcpy/src/1_15/impl/create-connection.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
38
libraries/adb-scrcpy/src/1_15/impl/get-displays.ts
Normal file
38
libraries/adb-scrcpy/src/1_15/impl/get-displays.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
24
libraries/adb-scrcpy/src/1_15/impl/get-encoders.ts
Normal file
24
libraries/adb-scrcpy/src/1_15/impl/get-encoders.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
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;
|
||||||
|
}
|
3
libraries/adb-scrcpy/src/1_15/impl/index.ts
Normal file
3
libraries/adb-scrcpy/src/1_15/impl/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export * from "./create-connection.js";
|
||||||
|
export * from "./get-displays.js";
|
||||||
|
export * from "./get-encoders.js";
|
1
libraries/adb-scrcpy/src/1_15/index.ts
Normal file
1
libraries/adb-scrcpy/src/1_15/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from "./options.js";
|
30
libraries/adb-scrcpy/src/1_15/options.ts
Normal file
30
libraries/adb-scrcpy/src/1_15/options.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_15 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import type { AdbScrcpyConnection } from "../connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "../types.js";
|
||||||
|
|
||||||
|
import { createConnection, getDisplays, getEncoders } from "./impl/index.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_15 extends AdbScrcpyOptions<ScrcpyOptions1_15.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_15.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_15(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_15 {
|
||||||
|
export type Init = ScrcpyOptions1_15.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_15_1.ts
Normal file
33
libraries/adb-scrcpy/src/1_15_1.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_15_1 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_15_1 extends AdbScrcpyOptions<ScrcpyOptions1_15_1.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_15_1.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_15_1(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_15_1 {
|
||||||
|
export type Init = ScrcpyOptions1_15_1.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_16.ts
Normal file
33
libraries/adb-scrcpy/src/1_16.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_16 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<ScrcpyOptions1_16.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_16.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_16(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_16 {
|
||||||
|
export type Init = ScrcpyOptions1_16.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_17.ts
Normal file
33
libraries/adb-scrcpy/src/1_17.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_17 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_17 extends AdbScrcpyOptions<ScrcpyOptions1_17.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_17.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_17(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_17 {
|
||||||
|
export type Init = ScrcpyOptions1_17.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_18.ts
Normal file
33
libraries/adb-scrcpy/src/1_18.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_18 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_18 extends AdbScrcpyOptions<ScrcpyOptions1_18.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_18.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_18(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_18 {
|
||||||
|
export type Init = ScrcpyOptions1_18.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_19.ts
Normal file
33
libraries/adb-scrcpy/src/1_19.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_19 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_19 extends AdbScrcpyOptions<ScrcpyOptions1_19.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_19.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_19(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_19 {
|
||||||
|
export type Init = ScrcpyOptions1_19.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_20.ts
Normal file
33
libraries/adb-scrcpy/src/1_20.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_20 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_20 extends AdbScrcpyOptions<ScrcpyOptions1_20.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_20.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_20(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_20 {
|
||||||
|
export type Init = ScrcpyOptions1_20.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_21.ts
Normal file
33
libraries/adb-scrcpy/src/1_21.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_21 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_21 extends AdbScrcpyOptions<ScrcpyOptions1_21.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_21.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_21(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_21 {
|
||||||
|
export type Init = ScrcpyOptions1_21.Init;
|
||||||
|
}
|
34
libraries/adb-scrcpy/src/1_22/impl/create-connection.ts
Normal file
34
libraries/adb-scrcpy/src/1_22/impl/create-connection.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyOptions1_22 } 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<
|
||||||
|
ScrcpyOptions1_22.Init,
|
||||||
|
"tunnelForward" | "control" | "sendDummyByte"
|
||||||
|
>
|
||||||
|
>,
|
||||||
|
): AdbScrcpyConnection {
|
||||||
|
const connectionOptions: AdbScrcpyConnectionOptions = {
|
||||||
|
scid: undefined, // Not Supported
|
||||||
|
video: true, // Always enabled
|
||||||
|
audio: false, // Not Supported
|
||||||
|
control: options.control,
|
||||||
|
sendDummyByte: options.sendDummyByte,
|
||||||
|
};
|
||||||
|
if (options.tunnelForward) {
|
||||||
|
return new AdbScrcpyForwardConnection(adb, connectionOptions);
|
||||||
|
} else {
|
||||||
|
return new AdbScrcpyReverseConnection(adb, connectionOptions);
|
||||||
|
}
|
||||||
|
}
|
2
libraries/adb-scrcpy/src/1_22/impl/index.ts
Normal file
2
libraries/adb-scrcpy/src/1_22/impl/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from "../../1_15/impl/index.js";
|
||||||
|
export { createConnection } from "./create-connection.js";
|
1
libraries/adb-scrcpy/src/1_22/index.ts
Normal file
1
libraries/adb-scrcpy/src/1_22/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from "./options.js";
|
33
libraries/adb-scrcpy/src/1_22/options.ts
Normal file
33
libraries/adb-scrcpy/src/1_22/options.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_22 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "../1_15/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "../connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "../types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_22 extends AdbScrcpyOptions<ScrcpyOptions1_22.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_22.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_22(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_22 {
|
||||||
|
export type Init = ScrcpyOptions1_22.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_23.ts
Normal file
33
libraries/adb-scrcpy/src/1_23.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_23 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_22/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_23 extends AdbScrcpyOptions<ScrcpyOptions1_23.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_23.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_23(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_23 {
|
||||||
|
export type Init = ScrcpyOptions1_23.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_24.ts
Normal file
33
libraries/adb-scrcpy/src/1_24.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_24 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_22/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_24 extends AdbScrcpyOptions<ScrcpyOptions1_24.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_24.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_24(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_24 {
|
||||||
|
export type Init = ScrcpyOptions1_24.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/1_25.ts
Normal file
33
libraries/adb-scrcpy/src/1_25.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions1_25 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./1_22/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions1_25 extends AdbScrcpyOptions<ScrcpyOptions1_25.Init> {
|
||||||
|
constructor(init: ScrcpyOptions1_25.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions1_25(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions1_25 {
|
||||||
|
export type Init = ScrcpyOptions1_25.Init;
|
||||||
|
}
|
35
libraries/adb-scrcpy/src/2_0/impl/create-connection.ts
Normal file
35
libraries/adb-scrcpy/src/2_0/impl/create-connection.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyOptions2_0 } 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_0.Init,
|
||||||
|
"tunnelForward" | "control" | "sendDummyByte" | "scid" | "audio"
|
||||||
|
>
|
||||||
|
>,
|
||||||
|
): AdbScrcpyConnection {
|
||||||
|
const connectionOptions: AdbScrcpyConnectionOptions = {
|
||||||
|
scid: toScrcpyOptionValue(options.scid, undefined),
|
||||||
|
video: true, // Always enabled
|
||||||
|
audio: options.audio,
|
||||||
|
control: options.control,
|
||||||
|
sendDummyByte: options.sendDummyByte,
|
||||||
|
};
|
||||||
|
if (options.tunnelForward) {
|
||||||
|
return new AdbScrcpyForwardConnection(adb, connectionOptions);
|
||||||
|
} else {
|
||||||
|
return new AdbScrcpyReverseConnection(adb, connectionOptions);
|
||||||
|
}
|
||||||
|
}
|
38
libraries/adb-scrcpy/src/2_0/impl/get-encoders.ts
Normal file
38
libraries/adb-scrcpy/src/2_0/impl/get-encoders.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyEncoder, ScrcpyOptions1_15 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import { AdbScrcpyClient, AdbScrcpyExitedError } 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[]> {
|
||||||
|
try {
|
||||||
|
// Similar to `getDisplays`, now the server won't create video sockets,
|
||||||
|
// so `start` will throw an `AdbScrcpyExitedError` instead
|
||||||
|
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 encoders: ScrcpyEncoder[] = [];
|
||||||
|
for (const line of e.output) {
|
||||||
|
const encoder = options.parseEncoder(line);
|
||||||
|
if (encoder) {
|
||||||
|
encoders.push(encoder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return encoders;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
3
libraries/adb-scrcpy/src/2_0/impl/index.ts
Normal file
3
libraries/adb-scrcpy/src/2_0/impl/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export * from "../../1_22/impl/index.js";
|
||||||
|
export { createConnection } from "./create-connection.js";
|
||||||
|
export { getEncoders } from "./get-encoders.js";
|
1
libraries/adb-scrcpy/src/2_0/index.ts
Normal file
1
libraries/adb-scrcpy/src/2_0/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from "./options.js";
|
30
libraries/adb-scrcpy/src/2_0/options.ts
Normal file
30
libraries/adb-scrcpy/src/2_0/options.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_0 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import type { AdbScrcpyConnection } from "../connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "../types.js";
|
||||||
|
|
||||||
|
import { createConnection, getDisplays, getEncoders } from "./impl/index.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<ScrcpyOptions2_0.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_0.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_0(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_0 {
|
||||||
|
export type Init = ScrcpyOptions2_0.Init;
|
||||||
|
}
|
40
libraries/adb-scrcpy/src/2_1/impl/create-connection.ts
Normal file
40
libraries/adb-scrcpy/src/2_1/impl/create-connection.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
2
libraries/adb-scrcpy/src/2_1/impl/index.ts
Normal file
2
libraries/adb-scrcpy/src/2_1/impl/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from "../../2_0/impl/index.js";
|
||||||
|
export { createConnection } from "./create-connection.js";
|
1
libraries/adb-scrcpy/src/2_1/index.ts
Normal file
1
libraries/adb-scrcpy/src/2_1/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from "./options.js";
|
33
libraries/adb-scrcpy/src/2_1/options.ts
Normal file
33
libraries/adb-scrcpy/src/2_1/options.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_1 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "../2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "../connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "../types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_1 extends AdbScrcpyOptions<ScrcpyOptions2_1.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_1.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_1(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_1 {
|
||||||
|
export type Init = ScrcpyOptions2_1.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_1_1.ts
Normal file
33
libraries/adb-scrcpy/src/2_1_1.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_1_1 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_1_1 extends AdbScrcpyOptions<ScrcpyOptions2_1_1.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_1_1.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_1_1(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_1_1 {
|
||||||
|
export type Init = ScrcpyOptions2_1_1.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_2.ts
Normal file
33
libraries/adb-scrcpy/src/2_2.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_2 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_2 extends AdbScrcpyOptions<ScrcpyOptions2_2.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_2.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_2(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_2 {
|
||||||
|
export type Init = ScrcpyOptions2_2.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_3.ts
Normal file
33
libraries/adb-scrcpy/src/2_3.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_3 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_3 extends AdbScrcpyOptions<ScrcpyOptions2_3.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_3.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_3(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_3 {
|
||||||
|
export type Init = ScrcpyOptions2_3.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_3_1.ts
Normal file
33
libraries/adb-scrcpy/src/2_3_1.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_3_1 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_3_1 extends AdbScrcpyOptions<ScrcpyOptions2_3_1.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_3_1.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_3_1(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_3_1 {
|
||||||
|
export type Init = ScrcpyOptions2_3_1.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_4.ts
Normal file
33
libraries/adb-scrcpy/src/2_4.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_4 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_4 extends AdbScrcpyOptions<ScrcpyOptions2_4.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_4.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_4(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_4 {
|
||||||
|
export type Init = ScrcpyOptions2_4.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_5.ts
Normal file
33
libraries/adb-scrcpy/src/2_5.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_5 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_5 extends AdbScrcpyOptions<ScrcpyOptions2_5.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_5.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_5(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_5 {
|
||||||
|
export type Init = ScrcpyOptions2_5.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_6.ts
Normal file
33
libraries/adb-scrcpy/src/2_6.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_6 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_6 extends AdbScrcpyOptions<ScrcpyOptions2_6.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_6.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_6(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_6 {
|
||||||
|
export type Init = ScrcpyOptions2_6.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/2_7.ts
Normal file
33
libraries/adb-scrcpy/src/2_7.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions2_7 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions2_7 extends AdbScrcpyOptions<ScrcpyOptions2_7.Init> {
|
||||||
|
constructor(init: ScrcpyOptions2_7.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions2_7(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions2_7 {
|
||||||
|
export type Init = ScrcpyOptions2_7.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/3_0.ts
Normal file
33
libraries/adb-scrcpy/src/3_0.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions3_0 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions3_0 extends AdbScrcpyOptions<ScrcpyOptions3_0.Init> {
|
||||||
|
constructor(init: ScrcpyOptions3_0.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions3_0(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions3_0 {
|
||||||
|
export type Init = ScrcpyOptions3_0.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/3_0_1.ts
Normal file
33
libraries/adb-scrcpy/src/3_0_1.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions3_0_1 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions3_0_1 extends AdbScrcpyOptions<ScrcpyOptions3_0_1.Init> {
|
||||||
|
constructor(init: ScrcpyOptions3_0_1.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions3_0_1(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions3_0_1 {
|
||||||
|
export type Init = ScrcpyOptions3_0_1.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/3_0_2.ts
Normal file
33
libraries/adb-scrcpy/src/3_0_2.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions3_0_2 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions3_0_2 extends AdbScrcpyOptions<ScrcpyOptions3_0_2.Init> {
|
||||||
|
constructor(init: ScrcpyOptions3_0_2.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions3_0_2(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions3_0_2 {
|
||||||
|
export type Init = ScrcpyOptions3_0_2.Init;
|
||||||
|
}
|
33
libraries/adb-scrcpy/src/3_1.ts
Normal file
33
libraries/adb-scrcpy/src/3_1.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { Adb } from "@yume-chan/adb";
|
||||||
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
|
import { ScrcpyOptions3_1 } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createConnection,
|
||||||
|
getDisplays,
|
||||||
|
getEncoders,
|
||||||
|
} from "./2_1/impl/index.js";
|
||||||
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
import { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptions3_1 extends AdbScrcpyOptions<ScrcpyOptions3_1.Init> {
|
||||||
|
constructor(init: ScrcpyOptions3_1.Init, version?: string) {
|
||||||
|
super(new ScrcpyOptions3_1(init, version));
|
||||||
|
}
|
||||||
|
|
||||||
|
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||||
|
return getEncoders(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||||
|
return getDisplays(adb, path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||||
|
return createConnection(adb, this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptions3_1 {
|
||||||
|
export type Init = ScrcpyOptions3_1.Init;
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ import {
|
||||||
import { ExactReadableEndedError } from "@yume-chan/struct";
|
import { ExactReadableEndedError } from "@yume-chan/struct";
|
||||||
|
|
||||||
import type { AdbScrcpyConnection } from "./connection.js";
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
import type { AdbScrcpyOptions } from "./options/index.js";
|
import type { AdbScrcpyOptions } from "./types.js";
|
||||||
|
|
||||||
function arrayToStream<T>(array: T[]): ReadableStream<T> {
|
function arrayToStream<T>(array: T[]): ReadableStream<T> {
|
||||||
return new PushReadableStream(async (controller) => {
|
return new PushReadableStream(async (controller) => {
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
export * from "./1_15/index.js";
|
||||||
|
export * from "./1_15_1.js";
|
||||||
|
export * from "./1_16.js";
|
||||||
|
export * from "./1_17.js";
|
||||||
|
export * from "./1_18.js";
|
||||||
|
export * from "./1_19.js";
|
||||||
|
export * from "./1_20.js";
|
||||||
|
export * from "./1_21.js";
|
||||||
|
export * from "./1_22/index.js";
|
||||||
|
export * from "./1_23.js";
|
||||||
|
export * from "./1_24.js";
|
||||||
|
export * from "./1_25.js";
|
||||||
|
export * from "./2_0/index.js";
|
||||||
|
export * from "./2_1/index.js";
|
||||||
|
export * from "./2_2.js";
|
||||||
|
export * from "./2_3.js";
|
||||||
|
export * from "./2_4.js";
|
||||||
|
export * from "./2_5.js";
|
||||||
|
export * from "./2_6.js";
|
||||||
|
export * from "./2_7.js";
|
||||||
|
export * from "./3_0.js";
|
||||||
|
export * from "./3_0_1.js";
|
||||||
|
export * from "./3_0_2.js";
|
||||||
|
export * from "./3_1.js";
|
||||||
export * from "./client.js";
|
export * from "./client.js";
|
||||||
export * from "./connection.js";
|
export * from "./connection.js";
|
||||||
export * from "./options/index.js";
|
export * from "./latest.js";
|
||||||
|
|
11
libraries/adb-scrcpy/src/latest.ts
Normal file
11
libraries/adb-scrcpy/src/latest.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { AdbScrcpyOptions3_1 } from "./3_1.js";
|
||||||
|
|
||||||
|
export class AdbScrcpyOptionsLatest extends AdbScrcpyOptions3_1 {
|
||||||
|
constructor(init: AdbScrcpyOptions3_1.Init, version: string) {
|
||||||
|
super(init, version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace AdbScrcpyOptionsLatest {
|
||||||
|
export type Init = AdbScrcpyOptions3_1.Init;
|
||||||
|
}
|
|
@ -1,120 +0,0 @@
|
||||||
import type { Adb } from "@yume-chan/adb";
|
|
||||||
import type {
|
|
||||||
ScrcpyDisplay,
|
|
||||||
ScrcpyEncoder,
|
|
||||||
ScrcpyOptions1_16Impl,
|
|
||||||
} from "@yume-chan/scrcpy";
|
|
||||||
import { WritableStream } from "@yume-chan/stream-extra";
|
|
||||||
|
|
||||||
import { AdbScrcpyClient, AdbScrcpyExitedError } from "../client.js";
|
|
||||||
import type {
|
|
||||||
AdbScrcpyConnection,
|
|
||||||
AdbScrcpyConnectionOptions,
|
|
||||||
} from "../connection.js";
|
|
||||||
import {
|
|
||||||
AdbScrcpyForwardConnection,
|
|
||||||
AdbScrcpyReverseConnection,
|
|
||||||
} from "../connection.js";
|
|
||||||
|
|
||||||
import { AdbScrcpyOptions } from "./types.js";
|
|
||||||
|
|
||||||
export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
|
|
||||||
// Only pick options that are used in this class,
|
|
||||||
// so changes in `ScrcpyOptionsInitX_XX` won't affect type assignability with this class
|
|
||||||
Pick<ScrcpyOptions1_16Impl.Init, "tunnelForward">
|
|
||||||
> {
|
|
||||||
static createConnection(
|
|
||||||
adb: Adb,
|
|
||||||
connectionOptions: AdbScrcpyConnectionOptions,
|
|
||||||
tunnelForward: boolean,
|
|
||||||
): AdbScrcpyConnection {
|
|
||||||
if (tunnelForward) {
|
|
||||||
return new AdbScrcpyForwardConnection(adb, connectionOptions);
|
|
||||||
} else {
|
|
||||||
return new AdbScrcpyReverseConnection(adb, connectionOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async getEncoders(
|
|
||||||
adb: Adb,
|
|
||||||
path: string,
|
|
||||||
options: AdbScrcpyOptions<
|
|
||||||
Pick<ScrcpyOptions1_16Impl.Init, "tunnelForward">
|
|
||||||
>,
|
|
||||||
): Promise<ScrcpyEncoder[]> {
|
|
||||||
const client = await AdbScrcpyClient.start(adb, path, options);
|
|
||||||
|
|
||||||
const encoders: ScrcpyEncoder[] = [];
|
|
||||||
|
|
||||||
// `client.stdout` is supplied by user and may not support async iteration
|
|
||||||
await client.stdout.pipeTo(
|
|
||||||
new WritableStream({
|
|
||||||
write: (line) => {
|
|
||||||
const encoder = options.parseEncoder(line);
|
|
||||||
if (encoder) {
|
|
||||||
encoders.push(encoder);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return encoders;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async getDisplays(
|
|
||||||
adb: Adb,
|
|
||||||
path: string,
|
|
||||||
options: AdbScrcpyOptions<
|
|
||||||
Pick<ScrcpyOptions1_16Impl.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
|
||||||
return AdbScrcpyOptions1_16.getEncoders(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
|
||||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
|
||||||
return AdbScrcpyOptions1_16.createConnection(
|
|
||||||
adb,
|
|
||||||
{
|
|
||||||
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
|
|
||||||
},
|
|
||||||
this.value.tunnelForward,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
import type { Adb } from "@yume-chan/adb";
|
|
||||||
import type {
|
|
||||||
ScrcpyDisplay,
|
|
||||||
ScrcpyEncoder,
|
|
||||||
ScrcpyOptions1_22Impl,
|
|
||||||
} from "@yume-chan/scrcpy";
|
|
||||||
|
|
||||||
import type { AdbScrcpyConnection } from "../connection.js";
|
|
||||||
|
|
||||||
import { AdbScrcpyOptions1_16 } from "./1_16.js";
|
|
||||||
import { AdbScrcpyOptions } from "./types.js";
|
|
||||||
|
|
||||||
export class AdbScrcpyOptions1_22 extends AdbScrcpyOptions<
|
|
||||||
// Only pick options that are used in this class,
|
|
||||||
// so changes in `ScrcpyOptionsInitX_XX` won't affect type assignability with this class
|
|
||||||
Pick<
|
|
||||||
ScrcpyOptions1_22Impl.Init,
|
|
||||||
"tunnelForward" | "control" | "sendDummyByte"
|
|
||||||
>
|
|
||||||
> {
|
|
||||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
|
||||||
return AdbScrcpyOptions1_16.getEncoders(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
|
||||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
|
||||||
return AdbScrcpyOptions1_16.createConnection(
|
|
||||||
adb,
|
|
||||||
{
|
|
||||||
scid: undefined, // Not Supported
|
|
||||||
video: true, // Always enabled
|
|
||||||
audio: false, // Not Supported
|
|
||||||
control: this.value.control,
|
|
||||||
sendDummyByte: this.value.sendDummyByte,
|
|
||||||
},
|
|
||||||
this.value.tunnelForward,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
import type { Adb } from "@yume-chan/adb";
|
|
||||||
import type {
|
|
||||||
ScrcpyDisplay,
|
|
||||||
ScrcpyEncoder,
|
|
||||||
ScrcpyOptions1_16Impl,
|
|
||||||
ScrcpyOptions2_0Impl,
|
|
||||||
} from "@yume-chan/scrcpy";
|
|
||||||
import { toScrcpyOptionValue } from "@yume-chan/scrcpy";
|
|
||||||
|
|
||||||
import { AdbScrcpyClient, AdbScrcpyExitedError } from "../client.js";
|
|
||||||
import type { AdbScrcpyConnection } from "../connection.js";
|
|
||||||
|
|
||||||
import { AdbScrcpyOptions1_16 } from "./1_16.js";
|
|
||||||
import { AdbScrcpyOptions } from "./types.js";
|
|
||||||
|
|
||||||
export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<
|
|
||||||
// Only pick options that are used in this class,
|
|
||||||
// so changes in `ScrcpyOptionsInitX_XX` won't affect type assignability with this class
|
|
||||||
Pick<
|
|
||||||
ScrcpyOptions2_0Impl.Init,
|
|
||||||
"tunnelForward" | "control" | "sendDummyByte" | "scid" | "audio"
|
|
||||||
>
|
|
||||||
> {
|
|
||||||
static async getEncoders(
|
|
||||||
adb: Adb,
|
|
||||||
path: string,
|
|
||||||
options: AdbScrcpyOptions<
|
|
||||||
Pick<ScrcpyOptions1_16Impl.Init, "tunnelForward">
|
|
||||||
>,
|
|
||||||
): Promise<ScrcpyEncoder[]> {
|
|
||||||
try {
|
|
||||||
// Similar to `AdbScrcpyOptions1_16.getDisplays`,
|
|
||||||
// server start procedure won't complete and `start `will throw
|
|
||||||
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) {
|
|
||||||
const encoders: ScrcpyEncoder[] = [];
|
|
||||||
for (const line of e.output) {
|
|
||||||
const encoder = options.parseEncoder(line);
|
|
||||||
if (encoder) {
|
|
||||||
encoders.push(encoder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return encoders;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override async getEncoders(
|
|
||||||
adb: Adb,
|
|
||||||
path: string,
|
|
||||||
): Promise<ScrcpyEncoder[]> {
|
|
||||||
return AdbScrcpyOptions2_0.getEncoders(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
|
||||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
|
||||||
return AdbScrcpyOptions1_16.createConnection(
|
|
||||||
adb,
|
|
||||||
{
|
|
||||||
scid: toScrcpyOptionValue(this.value.scid, undefined),
|
|
||||||
video: true, // Always enabled
|
|
||||||
audio: this.value.audio,
|
|
||||||
control: this.value.control,
|
|
||||||
sendDummyByte: this.value.sendDummyByte,
|
|
||||||
},
|
|
||||||
this.value.tunnelForward,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
import type { Adb } from "@yume-chan/adb";
|
|
||||||
import type {
|
|
||||||
ScrcpyDisplay,
|
|
||||||
ScrcpyEncoder,
|
|
||||||
ScrcpyOptions2_1Impl,
|
|
||||||
} from "@yume-chan/scrcpy";
|
|
||||||
import { toScrcpyOptionValue } from "@yume-chan/scrcpy";
|
|
||||||
|
|
||||||
import type { AdbScrcpyConnection } from "../connection.js";
|
|
||||||
|
|
||||||
import { AdbScrcpyOptions1_16 } from "./1_16.js";
|
|
||||||
import { AdbScrcpyOptions2_0 } from "./2_0.js";
|
|
||||||
import { AdbScrcpyOptions } from "./types.js";
|
|
||||||
|
|
||||||
export class AdbScrcpyOptions2_1 extends AdbScrcpyOptions<
|
|
||||||
// Only pick options that are used in this class,
|
|
||||||
// so changes in `ScrcpyOptionsInitX_XX` won't affect type assignability with this class
|
|
||||||
Pick<
|
|
||||||
ScrcpyOptions2_1Impl.Init,
|
|
||||||
| "tunnelForward"
|
|
||||||
| "control"
|
|
||||||
| "sendDummyByte"
|
|
||||||
| "scid"
|
|
||||||
| "audio"
|
|
||||||
| "video"
|
|
||||||
>
|
|
||||||
> {
|
|
||||||
override async getEncoders(
|
|
||||||
adb: Adb,
|
|
||||||
path: string,
|
|
||||||
): Promise<ScrcpyEncoder[]> {
|
|
||||||
return AdbScrcpyOptions2_0.getEncoders(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
|
||||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
|
||||||
return AdbScrcpyOptions1_16.createConnection(
|
|
||||||
adb,
|
|
||||||
{
|
|
||||||
scid: toScrcpyOptionValue(this.value.scid, undefined),
|
|
||||||
video: this.value.video,
|
|
||||||
audio: this.value.audio,
|
|
||||||
control: this.value.control,
|
|
||||||
sendDummyByte: this.value.sendDummyByte,
|
|
||||||
},
|
|
||||||
this.value.tunnelForward,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
export * from "./1_16.js";
|
|
||||||
export * from "./1_22.js";
|
|
||||||
export * from "./2_0.js";
|
|
||||||
export * from "./2_1.js";
|
|
||||||
export * from "./latest.js";
|
|
||||||
export * from "./types.js";
|
|
|
@ -1 +0,0 @@
|
||||||
export { AdbScrcpyOptions2_1 as AdbScrcpyOptionsLatest } from "./2_1.js";
|
|
|
@ -2,7 +2,7 @@ import type { Adb } from "@yume-chan/adb";
|
||||||
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||||
import { ScrcpyOptionsWrapper } from "@yume-chan/scrcpy";
|
import { ScrcpyOptionsWrapper } from "@yume-chan/scrcpy";
|
||||||
|
|
||||||
import type { AdbScrcpyConnection } from "../connection.js";
|
import type { AdbScrcpyConnection } from "./connection.js";
|
||||||
|
|
||||||
export abstract class AdbScrcpyOptions<
|
export abstract class AdbScrcpyOptions<
|
||||||
T extends object,
|
T extends object,
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_15Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions1_15_1 extends ScrcpyOptions1_15 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions1_15Impl as ScrcpyOptions1_15_1Impl } from "./1_15/index.js";
|
export namespace ScrcpyOptions1_15_1 {
|
||||||
|
export type Init = ScrcpyOptions1_15.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions1_16 extends ScrcpyOptions1_15 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions1_15Impl as ScrcpyOptions1_16Impl } from "./1_15/index.js";
|
export namespace ScrcpyOptions1_16 {
|
||||||
|
export type Init = ScrcpyOptions1_15.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_17Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_18Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions1_19 extends ScrcpyOptions1_18 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions1_18Impl as ScrcpyOptions1_19Impl } from "./1_18/index.js";
|
export namespace ScrcpyOptions1_19 {
|
||||||
|
export type Init = ScrcpyOptions1_18.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions1_20 extends ScrcpyOptions1_18 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions1_18Impl as ScrcpyOptions1_20Impl } from "./1_18/index.js";
|
export namespace ScrcpyOptions1_20 {
|
||||||
|
export type Init = ScrcpyOptions1_18.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_21Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_22Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_23Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_24Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions1_25Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_0Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_1Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions2_1_1 extends ScrcpyOptions2_1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions2_1Impl as ScrcpyOptions2_1_1Impl } from "./2_1/index.js";
|
export namespace ScrcpyOptions2_1_1 {
|
||||||
|
export type Init = ScrcpyOptions2_1.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_2Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_3Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions2_3_1 extends ScrcpyOptions2_3 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions2_3Impl as ScrcpyOptions2_3_1Impl } from "./2_3/index.js";
|
export namespace ScrcpyOptions2_3_1 {
|
||||||
|
export type Init = ScrcpyOptions2_3.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_4Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions2_5 extends ScrcpyOptions2_4 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions2_4Impl as ScrcpyOptions2_5Impl } from "./2_4/index.js";
|
export namespace ScrcpyOptions2_5 {
|
||||||
|
export type Init = ScrcpyOptions2_4.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_6Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions2_6_1 extends ScrcpyOptions2_6 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions2_6Impl as ScrcpyOptions2_6_1Impl } from "./2_6/index.js";
|
export namespace ScrcpyOptions2_6_1 {
|
||||||
|
export type Init = ScrcpyOptions2_6.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions2_7Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions3_0Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions3_0_1 extends ScrcpyOptions3_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_1Impl } from "./3_0/index.js";
|
export namespace ScrcpyOptions3_0_1 {
|
||||||
|
export type Init = ScrcpyOptions3_0.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ export class ScrcpyOptions3_0_2 extends ScrcpyOptions3_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_2Impl } from "./3_0/index.js";
|
export namespace ScrcpyOptions3_0_2 {
|
||||||
|
export type Init = ScrcpyOptions3_0.Init;
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * as ScrcpyOptions3_1Impl from "./impl/index.js";
|
|
||||||
export * from "./options.js";
|
export * from "./options.js";
|
||||||
|
|
|
@ -6,7 +6,9 @@ export class ScrcpyOptionsLatest extends ScrcpyOptions3_1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ScrcpyOptions3_1Impl as ScrcpyOptionsLatestImpl } from "./3_1/index.js";
|
export namespace ScrcpyOptionsLatest {
|
||||||
|
export type Init = ScrcpyOptions3_1.Init;
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
BackOrScreenOnControlMessage as ScrcpyBackOrScreenOnControlMessage,
|
BackOrScreenOnControlMessage as ScrcpyBackOrScreenOnControlMessage,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue