mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 02:09:18 +02:00
feat(adb): rewrite process spawner API (#739)
This commit is contained in:
parent
46e78401a4
commit
d3019ce738
75 changed files with 1422 additions and 1022 deletions
|
@ -2,14 +2,21 @@ import type { Adb } from "@yume-chan/adb";
|
|||
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||
import { ScrcpyOptions1_15 } from "@yume-chan/scrcpy";
|
||||
|
||||
import type { AdbScrcpyClientOptions } from "../client-options.js";
|
||||
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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_15.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_15(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_15_1.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_15_1(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_16.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_16(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_17.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_17(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_18.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_18(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_19.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_19(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_20.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_20(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_21.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_21(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "../1_15/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "../client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_22.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_22(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_22/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_23.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_23(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_22/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_24.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_24(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,12 +7,19 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./1_22/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.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));
|
||||
constructor(
|
||||
init: ScrcpyOptions1_25.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions1_25(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -2,14 +2,21 @@ import type { Adb } from "@yume-chan/adb";
|
|||
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||
import { ScrcpyOptions2_0 } from "@yume-chan/scrcpy";
|
||||
|
||||
import type { AdbScrcpyClientOptions } from "../client-options.js";
|
||||
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));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_0.Init,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_0(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "../2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "../client-options.js";
|
||||
import type { AdbScrcpyConnection } from "../connection.js";
|
||||
import { AdbScrcpyOptions } from "../types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_1<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_1.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_1.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_1(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_1.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_1(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_1_1<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_1_1.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_1_1.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_1_1(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_1_1.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_1_1(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_2<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_2.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_2.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_2(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_2.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_2(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_3<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_3.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_3.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_3(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_3.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_3(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_3_1<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_3_1.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_3_1.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_3_1(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_3_1.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_3_1(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_4<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_4.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_4.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_4(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_4.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_4(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_5<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_5.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_5.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_5(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_5.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_5(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_6<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_6.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_6.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_6(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_6.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_6(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions2_7<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions2_7.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions2_7.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions2_7(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions2_7.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions2_7(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions3_0<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions3_0.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions3_0.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions3_0(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions3_0.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions3_0(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions3_0_1<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions3_0_1.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions3_0_1.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions3_0_1(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions3_0_1.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions3_0_1(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions3_0_2<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions3_0_2.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions3_0_2.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions3_0_2(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions3_0_2.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions3_0_2(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
|
@ -7,14 +7,21 @@ import {
|
|||
getDisplays,
|
||||
getEncoders,
|
||||
} from "./2_1/impl/index.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
import { AdbScrcpyOptions } from "./types.js";
|
||||
|
||||
export class AdbScrcpyOptions3_1<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions<ScrcpyOptions3_1.Init<TVideo>> {
|
||||
constructor(init: ScrcpyOptions3_1.Init<TVideo>, version?: string) {
|
||||
super(new ScrcpyOptions3_1(init, version));
|
||||
constructor(
|
||||
init: ScrcpyOptions3_1.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(
|
||||
new ScrcpyOptions3_1(init, clientOptions?.version),
|
||||
clientOptions?.spawner,
|
||||
);
|
||||
}
|
||||
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
|
|
6
libraries/adb-scrcpy/src/client-options.ts
Normal file
6
libraries/adb-scrcpy/src/client-options.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import type { AdbNoneProtocolSpawner } from "@yume-chan/adb";
|
||||
|
||||
export interface AdbScrcpyClientOptions {
|
||||
version?: string;
|
||||
spawner?: AdbNoneProtocolSpawner | undefined;
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
import type { Adb, AdbSubprocessProtocol } from "@yume-chan/adb";
|
||||
import {
|
||||
AdbReverseNotSupportedError,
|
||||
AdbSubprocessNoneProtocol,
|
||||
} from "@yume-chan/adb";
|
||||
import type { Adb, AdbNoneProtocolProcess } from "@yume-chan/adb";
|
||||
import { AdbReverseNotSupportedError } from "@yume-chan/adb";
|
||||
import type {
|
||||
ScrcpyAudioStreamDisabledMetadata,
|
||||
ScrcpyAudioStreamErroredMetadata,
|
||||
|
@ -70,7 +67,7 @@ export class AdbScrcpyExitedError extends Error {
|
|||
|
||||
interface AdbScrcpyClientInit<TOptions extends AdbScrcpyOptions<object>> {
|
||||
options: TOptions;
|
||||
process: AdbSubprocessProtocol;
|
||||
process: AdbNoneProtocolProcess;
|
||||
stdout: ReadableStream<string>;
|
||||
|
||||
videoStream: ReadableStream<Uint8Array> | undefined;
|
||||
|
@ -117,7 +114,7 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> {
|
|||
options: TOptions,
|
||||
): Promise<AdbScrcpyClient<TOptions>> {
|
||||
let connection: AdbScrcpyConnection | undefined;
|
||||
let process: AdbSubprocessProtocol | undefined;
|
||||
let process: AdbNoneProtocolProcess | undefined;
|
||||
|
||||
try {
|
||||
try {
|
||||
|
@ -135,35 +132,34 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> {
|
|||
}
|
||||
}
|
||||
|
||||
process = await adb.subprocess.spawn(
|
||||
[
|
||||
// cspell: disable-next-line
|
||||
`CLASSPATH=${path}`,
|
||||
"app_process",
|
||||
/* unused */ "/",
|
||||
"com.genymobile.scrcpy.Server",
|
||||
options.version,
|
||||
...options.serialize(),
|
||||
],
|
||||
{
|
||||
// Scrcpy server doesn't use stderr,
|
||||
// so disable Shell Protocol to simplify processing
|
||||
protocols: [AdbSubprocessNoneProtocol],
|
||||
},
|
||||
);
|
||||
const args = [
|
||||
"app_process",
|
||||
"-cp",
|
||||
path,
|
||||
/* unused */ "/",
|
||||
"com.genymobile.scrcpy.Server",
|
||||
options.version,
|
||||
...options.serialize(),
|
||||
];
|
||||
|
||||
const stdout = process.stdout
|
||||
if (options.spawner) {
|
||||
process = await options.spawner.spawn(args);
|
||||
} else {
|
||||
process = await adb.subprocess.noneProtocol.spawn(args);
|
||||
}
|
||||
|
||||
const output = process.output
|
||||
.pipeThrough(new TextDecoderStream())
|
||||
.pipeThrough(new SplitStringStream("\n"));
|
||||
|
||||
// Must read all streams, otherwise the whole connection will be blocked.
|
||||
const output: string[] = [];
|
||||
const lines: string[] = [];
|
||||
const abortController = new AbortController();
|
||||
const pipe = stdout
|
||||
const pipe = output
|
||||
.pipeTo(
|
||||
new WritableStream({
|
||||
write(chunk) {
|
||||
output.push(chunk);
|
||||
lines.push(chunk);
|
||||
},
|
||||
}),
|
||||
{
|
||||
|
@ -180,8 +176,8 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> {
|
|||
});
|
||||
|
||||
const streams = await Promise.race([
|
||||
process.exit.then(() => {
|
||||
throw new AdbScrcpyExitedError(output);
|
||||
process.exited.then(() => {
|
||||
throw new AdbScrcpyExitedError(lines);
|
||||
}),
|
||||
connection.getStreams(),
|
||||
]);
|
||||
|
@ -192,7 +188,7 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> {
|
|||
return new AdbScrcpyClient({
|
||||
options,
|
||||
process,
|
||||
stdout: concatStreams(arrayToStream(output), stdout),
|
||||
stdout: concatStreams(arrayToStream(lines), output),
|
||||
videoStream: streams.video,
|
||||
audioStream: streams.audio,
|
||||
controlStream: streams.control,
|
||||
|
@ -232,15 +228,15 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> {
|
|||
}
|
||||
|
||||
#options: TOptions;
|
||||
#process: AdbSubprocessProtocol;
|
||||
#process: AdbNoneProtocolProcess;
|
||||
|
||||
#stdout: ReadableStream<string>;
|
||||
get stdout() {
|
||||
return this.#stdout;
|
||||
}
|
||||
|
||||
get exit() {
|
||||
return this.#process.exit;
|
||||
get exited() {
|
||||
return this.#process.exited;
|
||||
}
|
||||
|
||||
#videoStream: Promise<AdbScrcpyVideoStream> | undefined;
|
||||
|
|
|
@ -22,6 +22,8 @@ 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-options.js";
|
||||
export * from "./client.js";
|
||||
export * from "./connection.js";
|
||||
export * from "./latest.js";
|
||||
export * from "./types.js";
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { AdbScrcpyOptions3_1 } from "./3_1.js";
|
||||
import type { AdbScrcpyClientOptions } from "./client-options.js";
|
||||
|
||||
export class AdbScrcpyOptionsLatest<
|
||||
TVideo extends boolean,
|
||||
> extends AdbScrcpyOptions3_1<TVideo> {
|
||||
constructor(init: AdbScrcpyOptions3_1.Init<TVideo>, version: string) {
|
||||
super(init, version);
|
||||
constructor(
|
||||
init: AdbScrcpyOptions3_1.Init<TVideo>,
|
||||
clientOptions?: AdbScrcpyClientOptions,
|
||||
) {
|
||||
super(init, clientOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import type { Adb } from "@yume-chan/adb";
|
||||
import type { ScrcpyDisplay, ScrcpyEncoder } from "@yume-chan/scrcpy";
|
||||
import type { Adb, AdbNoneProtocolSpawner } from "@yume-chan/adb";
|
||||
import type {
|
||||
ScrcpyDisplay,
|
||||
ScrcpyEncoder,
|
||||
ScrcpyOptions,
|
||||
} from "@yume-chan/scrcpy";
|
||||
import { ScrcpyOptionsWrapper } from "@yume-chan/scrcpy";
|
||||
|
||||
import type { AdbScrcpyConnection } from "./connection.js";
|
||||
|
@ -7,6 +11,16 @@ import type { AdbScrcpyConnection } from "./connection.js";
|
|||
export abstract class AdbScrcpyOptions<
|
||||
T extends object,
|
||||
> extends ScrcpyOptionsWrapper<T> {
|
||||
#spawner: AdbNoneProtocolSpawner | undefined;
|
||||
get spawner() {
|
||||
return this.#spawner;
|
||||
}
|
||||
|
||||
constructor(base: ScrcpyOptions<T>, spawner?: AdbNoneProtocolSpawner) {
|
||||
super(base);
|
||||
this.#spawner = spawner;
|
||||
}
|
||||
|
||||
abstract getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]>;
|
||||
|
||||
abstract getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue