mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 01:39:21 +02:00
feat(scrcpy): move version
info to option classes
This commit is contained in:
parent
a7a84979a5
commit
cb44b6384c
36 changed files with 189 additions and 116 deletions
6
.changeset/warm-badgers-burn.md
Normal file
6
.changeset/warm-badgers-burn.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"@yume-chan/adb-scrcpy": minor
|
||||
"@yume-chan/scrcpy": minor
|
||||
---
|
||||
|
||||
Move `version` info to option classes and provide default values
|
|
@ -120,7 +120,6 @@ export class AdbScrcpyClient {
|
|||
static async start(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
options: AdbScrcpyOptions<
|
||||
Pick<ScrcpyOptions1_15.Init, "tunnelForward">
|
||||
>,
|
||||
|
@ -151,7 +150,7 @@ export class AdbScrcpyClient {
|
|||
"app_process",
|
||||
/* unused */ "/",
|
||||
"com.genymobile.scrcpy.Server",
|
||||
version,
|
||||
options.version,
|
||||
...options.serialize(),
|
||||
],
|
||||
{
|
||||
|
|
|
@ -38,12 +38,11 @@ export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
|
|||
static async getEncoders(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
options: AdbScrcpyOptions<
|
||||
Pick<ScrcpyOptions1_16Impl.Init, "tunnelForward">
|
||||
>,
|
||||
): Promise<ScrcpyEncoder[]> {
|
||||
const client = await AdbScrcpyClient.start(adb, path, version, options);
|
||||
const client = await AdbScrcpyClient.start(adb, path, options);
|
||||
|
||||
const encoders: ScrcpyEncoder[] = [];
|
||||
|
||||
|
@ -65,7 +64,6 @@ export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
|
|||
static async getDisplays(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
options: AdbScrcpyOptions<
|
||||
Pick<ScrcpyOptions1_16Impl.Init, "tunnelForward">
|
||||
>,
|
||||
|
@ -73,12 +71,7 @@ export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
|
|||
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,
|
||||
version,
|
||||
options,
|
||||
);
|
||||
const client = await AdbScrcpyClient.start(adb, path, options);
|
||||
|
||||
// If the server didn't exit, manually stop it and throw an error
|
||||
await client.close();
|
||||
|
@ -103,20 +96,12 @@ export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
|
|||
}
|
||||
}
|
||||
|
||||
override getEncoders(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyEncoder[]> {
|
||||
return AdbScrcpyOptions1_16.getEncoders(adb, path, version, this);
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
return AdbScrcpyOptions1_16.getEncoders(adb, path, this);
|
||||
}
|
||||
|
||||
override getDisplays(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, version, this);
|
||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
||||
}
|
||||
|
||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||
|
|
|
@ -18,20 +18,12 @@ export class AdbScrcpyOptions1_22 extends AdbScrcpyOptions<
|
|||
"tunnelForward" | "control" | "sendDummyByte"
|
||||
>
|
||||
> {
|
||||
override getEncoders(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyEncoder[]> {
|
||||
return AdbScrcpyOptions1_16.getEncoders(adb, path, version, this);
|
||||
override getEncoders(adb: Adb, path: string): Promise<ScrcpyEncoder[]> {
|
||||
return AdbScrcpyOptions1_16.getEncoders(adb, path, this);
|
||||
}
|
||||
|
||||
override getDisplays(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, version, this);
|
||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
||||
}
|
||||
|
||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||
|
|
|
@ -24,7 +24,6 @@ export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<
|
|||
static async getEncoders(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
options: AdbScrcpyOptions<
|
||||
Pick<ScrcpyOptions1_16Impl.Init, "tunnelForward">
|
||||
>,
|
||||
|
@ -32,12 +31,7 @@ export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<
|
|||
try {
|
||||
// Similar to `AdbScrcpyOptions1_16.getDisplays`,
|
||||
// server start procedure won't complete and `start `will throw
|
||||
const client = await AdbScrcpyClient.start(
|
||||
adb,
|
||||
path,
|
||||
version,
|
||||
options,
|
||||
);
|
||||
const client = await AdbScrcpyClient.start(adb, path, options);
|
||||
|
||||
// If the server didn't exit, manually stop it and throw an error
|
||||
await client.close();
|
||||
|
@ -61,17 +55,12 @@ export class AdbScrcpyOptions2_0 extends AdbScrcpyOptions<
|
|||
override async getEncoders(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyEncoder[]> {
|
||||
return AdbScrcpyOptions2_0.getEncoders(adb, path, version, this);
|
||||
return AdbScrcpyOptions2_0.getEncoders(adb, path, this);
|
||||
}
|
||||
|
||||
override getDisplays(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, version, this);
|
||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
||||
}
|
||||
|
||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||
|
|
|
@ -28,17 +28,12 @@ export class AdbScrcpyOptions2_1 extends AdbScrcpyOptions<
|
|||
override async getEncoders(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyEncoder[]> {
|
||||
return AdbScrcpyOptions2_0.getEncoders(adb, path, version, this);
|
||||
return AdbScrcpyOptions2_0.getEncoders(adb, path, this);
|
||||
}
|
||||
|
||||
override getDisplays(
|
||||
adb: Adb,
|
||||
path: string,
|
||||
version: string,
|
||||
): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, version, this);
|
||||
override getDisplays(adb: Adb, path: string): Promise<ScrcpyDisplay[]> {
|
||||
return AdbScrcpyOptions1_16.getDisplays(adb, path, this);
|
||||
}
|
||||
|
||||
override createConnection(adb: Adb): AdbScrcpyConnection {
|
||||
|
|
|
@ -36,6 +36,8 @@ import {
|
|||
export class ScrcpyOptions1_15 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -47,8 +49,9 @@ export class ScrcpyOptions1_15 implements ScrcpyOptions<Init> {
|
|||
return this.#clipboard;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.15") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions1_15 as ScrcpyOptions1_15_1,
|
||||
ScrcpyOptions1_15Impl as ScrcpyOptions1_15_1Impl,
|
||||
} from "./1_15/index.js";
|
||||
import { ScrcpyOptions1_15 } from "./1_15/index.js";
|
||||
|
||||
export class ScrcpyOptions1_15_1 extends ScrcpyOptions1_15 {
|
||||
constructor(init: ScrcpyOptions1_15.Init, version = "1.15.1") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions1_15Impl as ScrcpyOptions1_15_1Impl } from "./1_15/index.js";
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions1_15 as ScrcpyOptions1_16,
|
||||
ScrcpyOptions1_15Impl as ScrcpyOptions1_16Impl,
|
||||
} from "./1_15/index.js";
|
||||
import { ScrcpyOptions1_15 } from "./1_15/index.js";
|
||||
|
||||
export class ScrcpyOptions1_16 extends ScrcpyOptions1_15 {
|
||||
constructor(init: ScrcpyOptions1_15.Init, version = "1.16") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions1_15Impl as ScrcpyOptions1_16Impl } from "./1_15/index.js";
|
||||
|
|
|
@ -40,6 +40,8 @@ import {
|
|||
export class ScrcpyOptions1_17 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -51,8 +53,9 @@ export class ScrcpyOptions1_17 implements ScrcpyOptions<Init> {
|
|||
return this.#clipboard;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.17") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -40,6 +40,8 @@ import {
|
|||
export class ScrcpyOptions1_18 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -51,8 +53,9 @@ export class ScrcpyOptions1_18 implements ScrcpyOptions<Init> {
|
|||
return this.#clipboard;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.18") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions1_18 as ScrcpyOptions1_19,
|
||||
ScrcpyOptions1_18Impl as ScrcpyOptions1_19Impl,
|
||||
} from "./1_18/index.js";
|
||||
import { ScrcpyOptions1_18 } from "./1_18/index.js";
|
||||
|
||||
export class ScrcpyOptions1_19 extends ScrcpyOptions1_18 {
|
||||
constructor(init: ScrcpyOptions1_18.Init, version = "1.19") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions1_18Impl as ScrcpyOptions1_19Impl } from "./1_18/index.js";
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions1_18 as ScrcpyOptions1_20,
|
||||
ScrcpyOptions1_18Impl as ScrcpyOptions1_20Impl,
|
||||
} from "./1_18/index.js";
|
||||
import { ScrcpyOptions1_18 } from "./1_18/index.js";
|
||||
|
||||
export class ScrcpyOptions1_20 extends ScrcpyOptions1_18 {
|
||||
constructor(init: ScrcpyOptions1_18.Init, version = "1.20") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions1_18Impl as ScrcpyOptions1_20Impl } from "./1_18/index.js";
|
||||
|
|
|
@ -39,6 +39,8 @@ import {
|
|||
export class ScrcpyOptions1_21 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -52,8 +54,9 @@ export class ScrcpyOptions1_21 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.21") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { StructInit } from "@yume-chan/struct";
|
||||
import { s32, struct } from "@yume-chan/struct";
|
||||
|
||||
import type { ScrcpyScrollController } from "../../base/index.js";
|
||||
import type { ScrcpyInjectScrollControlMessage } from "../../latest.js";
|
||||
|
||||
import type { ScrcpyScrollController } from "../../base/index.js";
|
||||
import { PrevImpl } from "./prev.js";
|
||||
|
||||
export const InjectScrollControlMessage = /* #__PURE__ */ (() =>
|
||||
|
|
|
@ -39,6 +39,8 @@ import {
|
|||
export class ScrcpyOptions1_22 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -52,8 +54,9 @@ export class ScrcpyOptions1_22 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.22") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -39,6 +39,8 @@ import {
|
|||
export class ScrcpyOptions1_23 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -52,8 +54,9 @@ export class ScrcpyOptions1_23 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.23") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -39,6 +39,8 @@ import {
|
|||
export class ScrcpyOptions1_24 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -52,8 +54,9 @@ export class ScrcpyOptions1_24 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.24") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -39,6 +39,8 @@ import {
|
|||
export class ScrcpyOptions1_25 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -52,8 +54,9 @@ export class ScrcpyOptions1_25 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "1.25") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -40,6 +40,8 @@ import {
|
|||
export class ScrcpyOptions2_0 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -53,8 +55,9 @@ export class ScrcpyOptions2_0 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "2.0") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -40,6 +40,8 @@ import {
|
|||
export class ScrcpyOptions2_1 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -53,8 +55,9 @@ export class ScrcpyOptions2_1 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "2.1") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.control && this.value.clipboardAutosync) {
|
||||
this.#clipboard = new ClipboardStream();
|
||||
|
|
|
@ -40,6 +40,8 @@ import {
|
|||
export class ScrcpyOptions2_2 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -53,8 +55,9 @@ export class ScrcpyOptions2_2 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "v2.2") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.videoSource === "camera") {
|
||||
this.value.control = false;
|
||||
|
|
|
@ -40,6 +40,8 @@ import {
|
|||
export class ScrcpyOptions2_3 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -53,8 +55,9 @@ export class ScrcpyOptions2_3 implements ScrcpyOptions<Init> {
|
|||
|
||||
#ackClipboardHandler: AckClipboardHandler | undefined;
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "2.3") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.videoSource === "camera") {
|
||||
this.value.control = false;
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions2_3 as ScrcpyOptions2_3_1,
|
||||
ScrcpyOptions2_3Impl as ScrcpyOptions2_3_1Impl,
|
||||
} from "./2_3/index.js";
|
||||
import { ScrcpyOptions2_3 } from "./2_3/index.js";
|
||||
|
||||
export class ScrcpyOptions2_3_1 extends ScrcpyOptions2_3 {
|
||||
constructor(init: ScrcpyOptions2_3.Init, version = "2.3.1") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions2_3Impl as ScrcpyOptions2_3_1Impl } from "./2_3/index.js";
|
||||
|
|
|
@ -44,6 +44,8 @@ import {
|
|||
export class ScrcpyOptions2_4 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -64,8 +66,9 @@ export class ScrcpyOptions2_4 implements ScrcpyOptions<Init> {
|
|||
return this.#uHidOutput;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "2.4") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.videoSource === "camera") {
|
||||
this.value.control = false;
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions2_4 as ScrcpyOptions2_5,
|
||||
ScrcpyOptions2_4Impl as ScrcpyOptions2_5Impl,
|
||||
} from "./2_4/index.js";
|
||||
import { ScrcpyOptions2_4 } from "./2_4/index.js";
|
||||
|
||||
export class ScrcpyOptions2_5 extends ScrcpyOptions2_4 {
|
||||
constructor(init: ScrcpyOptions2_4.Init, version = "2.5") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions2_4Impl as ScrcpyOptions2_5Impl } from "./2_4/index.js";
|
||||
|
|
|
@ -20,6 +20,7 @@ import type {
|
|||
ScrcpyUHidOutputDeviceMessage,
|
||||
} from "../latest.js";
|
||||
|
||||
import type { Init } from "./impl/index.js";
|
||||
import {
|
||||
AckClipboardHandler,
|
||||
ClipboardStream,
|
||||
|
@ -39,11 +40,12 @@ import {
|
|||
setListEncoders,
|
||||
UHidOutputStream,
|
||||
} from "./impl/index.js";
|
||||
import type { Init } from "./impl/index.js";
|
||||
|
||||
export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -64,8 +66,9 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
|
|||
return this.#uHidOutput;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "2.6") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.videoSource === "camera") {
|
||||
this.value.control = false;
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions2_6 as ScrcpyOptions2_6_1,
|
||||
ScrcpyOptions2_6Impl as ScrcpyOptions2_6_1Impl,
|
||||
} from "./2_6/index.js";
|
||||
import { ScrcpyOptions2_6 } from "./2_6/index.js";
|
||||
|
||||
export class ScrcpyOptions2_6_1 extends ScrcpyOptions2_6 {
|
||||
constructor(init: ScrcpyOptions2_6.Init, version = "2.6.1") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions2_6Impl as ScrcpyOptions2_6_1Impl } from "./2_6/index.js";
|
||||
|
|
|
@ -44,6 +44,8 @@ import {
|
|||
export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -64,8 +66,9 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
|
|||
return this.#uHidOutput;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "2.7") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.videoSource === "camera") {
|
||||
this.value.control = false;
|
||||
|
|
|
@ -44,6 +44,8 @@ import {
|
|||
export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
|
||||
static readonly Defaults = Defaults;
|
||||
|
||||
readonly version: string;
|
||||
|
||||
readonly value: Required<Init>;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
||||
|
@ -64,8 +66,9 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
|
|||
return this.#uHidOutput;
|
||||
}
|
||||
|
||||
constructor(init: Init) {
|
||||
constructor(init: Init, version = "3.0") {
|
||||
this.value = { ...Defaults, ...init };
|
||||
this.version = version;
|
||||
|
||||
if (this.value.videoSource === "camera") {
|
||||
this.value.control = false;
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions3_0 as ScrcpyOptions3_0_1,
|
||||
ScrcpyOptions3_0Impl as ScrcpyOptions3_0_1Impl,
|
||||
} from "./3_0/index.js";
|
||||
import { ScrcpyOptions3_0 } from "./3_0/index.js";
|
||||
|
||||
export class ScrcpyOptions3_0_1 extends ScrcpyOptions3_0 {
|
||||
constructor(init: ScrcpyOptions3_0.Init, version = "3.0.1") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_1Impl } from "./3_0/index.js";
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export {
|
||||
ScrcpyOptions3_0 as ScrcpyOptions3_0_2,
|
||||
ScrcpyOptions3_0Impl as ScrcpyOptions3_0_2Impl,
|
||||
} from "./3_0/index.js";
|
||||
import { ScrcpyOptions3_0 } from "./3_0/index.js";
|
||||
|
||||
export class ScrcpyOptions3_0_2 extends ScrcpyOptions3_0 {
|
||||
constructor(init: ScrcpyOptions3_0.Init, version = "3.0.2") {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_2Impl } from "./3_0/index.js";
|
||||
|
|
|
@ -28,8 +28,8 @@ export function toScrcpyOptionValue<T>(value: unknown, empty: T): string | T {
|
|||
typeof value !== "number" &&
|
||||
typeof value !== "boolean"
|
||||
) {
|
||||
throw new TypeError(`Invalid option value: ${String(value)}`);
|
||||
throw new TypeError(`Invalid option value: ${JSON.stringify(value)}`);
|
||||
}
|
||||
|
||||
return String(value);
|
||||
return value.toString();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import type { ScrcpyScrollController } from "./scroll-controller.js";
|
|||
import type { ScrcpyVideoStream } from "./video.js";
|
||||
|
||||
export interface ScrcpyOptions<T extends object> {
|
||||
get version(): string;
|
||||
|
||||
get controlMessageTypes(): readonly ScrcpyControlMessageType[];
|
||||
|
||||
value: Required<T>;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
import { ScrcpyOptions3_0 } from "./3_0/options.js";
|
||||
|
||||
export class ScrcpyOptionsLatest extends ScrcpyOptions3_0 {
|
||||
constructor(init: ScrcpyOptions3_0.Init, version: string) {
|
||||
super(init, version);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScrcpyOptions3_0Impl as ScrcpyOptionsLatestImpl } from "./3_0/index.js";
|
||||
|
||||
export {
|
||||
BackOrScreenOnControlMessage as ScrcpyBackOrScreenOnControlMessage,
|
||||
CaptureOrientation as ScrcpyCaptureOrientation,
|
||||
|
@ -14,5 +24,3 @@ export {
|
|||
UHidCreateControlMessage as ScrcpyUHidCreateControlMessage,
|
||||
UHidOutputDeviceMessage as ScrcpyUHidOutputDeviceMessage,
|
||||
} from "./3_0/impl/index.js";
|
||||
|
||||
export { ScrcpyOptions3_0 as ScrcpyOptionsLatest } from "./3_0/index.js";
|
||||
|
|
|
@ -20,6 +20,10 @@ export class ScrcpyOptionsWrapper<T extends object>
|
|||
{
|
||||
#base: ScrcpyOptions<T>;
|
||||
|
||||
get version() {
|
||||
return this.#base.version;
|
||||
}
|
||||
|
||||
get controlMessageTypes() {
|
||||
return this.#base.controlMessageTypes;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue