mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 19:42:15 +02:00
feat(scrcpy): support v2.2
This commit is contained in:
parent
d6d03061da
commit
336e0ffd5d
4 changed files with 80 additions and 8 deletions
|
@ -7,7 +7,10 @@ import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
const __dirname = fileURLToPath(dirname(import.meta.url));
|
const __dirname = fileURLToPath(dirname(import.meta.url));
|
||||||
|
|
||||||
const serverVersion = process.argv[2];
|
let serverVersion = process.argv[2];
|
||||||
|
if (!serverVersion.startsWith("v")) {
|
||||||
|
serverVersion = "v" + serverVersion;
|
||||||
|
}
|
||||||
if (!serverVersion) {
|
if (!serverVersion) {
|
||||||
console.log("Usage: fetch-scrcpy-server <version>");
|
console.log("Usage: fetch-scrcpy-server <version>");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -18,15 +21,15 @@ const binFolder = resolve(__dirname, "..");
|
||||||
|
|
||||||
await fetchVersion({
|
await fetchVersion({
|
||||||
repository: "Genymobile/scrcpy",
|
repository: "Genymobile/scrcpy",
|
||||||
version: `v${serverVersion}`,
|
version: serverVersion,
|
||||||
package: `scrcpy-server-v${serverVersion}`,
|
package: `scrcpy-server-${serverVersion}`,
|
||||||
destination: binFolder,
|
destination: binFolder,
|
||||||
extract: false,
|
extract: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fs.rename(
|
fs.rename(
|
||||||
resolve(binFolder, `scrcpy-server-v${serverVersion}`),
|
resolve(binFolder, `scrcpy-server-${serverVersion}`),
|
||||||
resolve(binFolder, "server.bin"),
|
resolve(binFolder, "server.bin"),
|
||||||
),
|
),
|
||||||
fs.writeFile(
|
fs.writeFile(
|
||||||
|
|
68
libraries/scrcpy/src/options/2_2.ts
Normal file
68
libraries/scrcpy/src/options/2_2.ts
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
import { ScrcpyOptions1_21 } from "./1_21.js";
|
||||||
|
import type { ScrcpyOptionsInit2_1 } from "./2_1.js";
|
||||||
|
import { ScrcpyOptions2_1 } from "./2_1.js";
|
||||||
|
import type { ScrcpyDisplay } from "./types.js";
|
||||||
|
import { ScrcpyOptionsBase } from "./types.js";
|
||||||
|
|
||||||
|
export interface ScrcpyOptionsInit2_2
|
||||||
|
extends Omit<ScrcpyOptionsInit2_1, "display"> {
|
||||||
|
videoSource?: "display" | "camera";
|
||||||
|
displayId?: number;
|
||||||
|
cameraId?: string | undefined;
|
||||||
|
cameraSize?: string | undefined;
|
||||||
|
cameraFacing?: "front" | "back" | "external" | undefined;
|
||||||
|
cameraAr?: string | undefined;
|
||||||
|
cameraFps?: number | undefined;
|
||||||
|
cameraHighSpeed?: boolean;
|
||||||
|
|
||||||
|
listCameras?: boolean;
|
||||||
|
listCameraSizes?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ScrcpyOptions2_2 extends ScrcpyOptionsBase<
|
||||||
|
ScrcpyOptionsInit2_2,
|
||||||
|
ScrcpyOptions2_1
|
||||||
|
> {
|
||||||
|
static readonly DEFAULTS = {
|
||||||
|
...ScrcpyOptions2_1.DEFAULTS,
|
||||||
|
videoSource: "display",
|
||||||
|
displayId: 0,
|
||||||
|
cameraId: undefined,
|
||||||
|
cameraSize: undefined,
|
||||||
|
cameraFacing: undefined,
|
||||||
|
cameraAr: undefined,
|
||||||
|
cameraFps: undefined,
|
||||||
|
cameraHighSpeed: false,
|
||||||
|
listCameras: false,
|
||||||
|
listCameraSizes: false,
|
||||||
|
} as const satisfies Required<ScrcpyOptionsInit2_2>;
|
||||||
|
|
||||||
|
override get defaults(): Required<ScrcpyOptionsInit2_2> {
|
||||||
|
return ScrcpyOptions2_2.DEFAULTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(init: ScrcpyOptionsInit2_2) {
|
||||||
|
super(new ScrcpyOptions2_1(init), {
|
||||||
|
...ScrcpyOptions2_2.DEFAULTS,
|
||||||
|
...init,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
override parseDisplay(line: string): ScrcpyDisplay | undefined {
|
||||||
|
const match = line.match(/\s+--display-id=(\d+)\s+\((.*?)\)/);
|
||||||
|
if (match) {
|
||||||
|
const display: ScrcpyDisplay = {
|
||||||
|
id: Number.parseInt(match[1]!, 10),
|
||||||
|
};
|
||||||
|
if (match[2] !== "size unknown") {
|
||||||
|
display.resolution = match[2]!;
|
||||||
|
}
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
override serialize(): string[] {
|
||||||
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ export * from "./1_24.js";
|
||||||
export * from "./1_25/index.js";
|
export * from "./1_25/index.js";
|
||||||
export * from "./2_0.js";
|
export * from "./2_0.js";
|
||||||
export * from "./2_1.js";
|
export * from "./2_1.js";
|
||||||
|
export * from "./2_2.js";
|
||||||
export * from "./codec.js";
|
export * from "./codec.js";
|
||||||
export * from "./latest.js";
|
export * from "./latest.js";
|
||||||
export * from "./types.js";
|
export * from "./types.js";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ScrcpyLogLevel1_18, ScrcpyVideoOrientation1_18 } from "./1_18.js";
|
import { ScrcpyLogLevel1_18, ScrcpyVideoOrientation1_18 } from "./1_18.js";
|
||||||
import type { ScrcpyOptionsInit2_1 } from "./2_1.js";
|
import type { ScrcpyOptionsInit2_2 } from "./2_2.js";
|
||||||
import { ScrcpyOptions2_1 } from "./2_1.js";
|
import { ScrcpyOptions2_2 } from "./2_2.js";
|
||||||
|
|
||||||
export const ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
export const ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
||||||
export type ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
export type ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
||||||
|
@ -8,5 +8,5 @@ export type ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
||||||
export const ScrcpyVideoOrientation = ScrcpyVideoOrientation1_18;
|
export const ScrcpyVideoOrientation = ScrcpyVideoOrientation1_18;
|
||||||
export type ScrcpyVideoOrientation = ScrcpyVideoOrientation1_18;
|
export type ScrcpyVideoOrientation = ScrcpyVideoOrientation1_18;
|
||||||
|
|
||||||
export type ScrcpyOptionsInitLatest = ScrcpyOptionsInit2_1;
|
export type ScrcpyOptionsInitLatest = ScrcpyOptionsInit2_2;
|
||||||
export class ScrcpyOptionsLatest extends ScrcpyOptions2_1 {}
|
export class ScrcpyOptionsLatest extends ScrcpyOptions2_2 {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue