Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit cc5d5291 authored by Simon Chan's avatar Simon Chan
Browse files

refactor(scrcpy): rewrite option classes to improve tree-shaking

parent 92472007
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ export class AdbScrcpyOptions1_16 extends AdbScrcpyOptions<
        const client = await AdbScrcpyClient.start(adb, path, version, options);

        const encoders: ScrcpyEncoder[] = [];

        // `client.stdout` is supplied by user and may not support async iteration
        await client.stdout.pipeTo(
            new WritableStream({
                write: (line) => {
+3 −5
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@ import type { MaybeConsumable, WritableStream } from "@yume-chan/stream-extra";
import { ReadableStream } from "@yume-chan/stream-extra";

import type { Adb, AdbSocket } from "../../../adb.js";
import { unreachable } from "../../../utils/index.js";

import type { AdbSubprocessProtocol } from "./types.js";

@@ -64,10 +63,9 @@ export class AdbSubprocessNoneProtocol implements AdbSubprocessProtocol {
        this.#socket = socket;

        this.#stderr = new ReadableStream({
            start: (controller) => {
                this.#socket.closed
                    .then(() => controller.close())
                    .catch(unreachable);
            start: async (controller) => {
                await this.#socket.closed;
                controller.close();
            },
        });
        this.#exit = socket.closed.then(() => 0);
+16 −14
Original line number Diff line number Diff line
@@ -15,23 +15,25 @@ export interface AdbSyncEntry extends AdbSyncStat {
    name: string;
}

export const AdbSyncEntryResponse = struct(
    /* #__PURE__ */ (() => ({
export const AdbSyncEntryResponse = /* #__PURE__ */ (() =>
    struct(
        {
            ...AdbSyncLstatResponse.fields,
            name: string(u32),
    }))(),
        },
        { littleEndian: true, extra: AdbSyncLstatResponse.extra },
);
    ))();

export type AdbSyncEntryResponse = StructValue<typeof AdbSyncEntryResponse>;

export const AdbSyncEntry2Response = struct(
    /* #__PURE__ */ (() => ({
export const AdbSyncEntry2Response = /* #__PURE__ */ (() =>
    struct(
        {
            ...AdbSyncStatResponse.fields,
            name: string(u32),
    }))(),
        },
        { littleEndian: true, extra: AdbSyncStatResponse.extra },
);
    ))();

export type AdbSyncEntry2Response = StructValue<typeof AdbSyncEntry2Response>;

+7 −5
Original line number Diff line number Diff line
@@ -43,11 +43,13 @@ export interface AdbCredentialStore {
    iterateKeys(): AdbKeyIterable;
}

export enum AdbAuthType {
    Token = 1,
    Signature = 2,
    PublicKey = 3,
}
export const AdbAuthType = {
    Token: 1,
    Signature: 2,
    PublicKey: 3,
} as const;

export type AdbAuthType = (typeof AdbAuthType)[keyof typeof AdbAuthType];

export interface AdbAuthenticator {
    /**
+22 −21
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ import { AdbCommand, calculateChecksum } from "./packet.js";
export const ADB_DAEMON_VERSION_OMIT_CHECKSUM = 0x01000001;
// https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
// There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
export const ADB_DAEMON_DEFAULT_FEATURES = [
export const ADB_DAEMON_DEFAULT_FEATURES = /* #__PURE__ */ (() =>
    [
        AdbFeature.ShellV2,
        AdbFeature.Cmd,
        AdbFeature.StatV2,
@@ -48,7 +49,7 @@ export const ADB_DAEMON_DEFAULT_FEATURES = [
        "sendrecv_v2_zstd",
        "sendrecv_v2_dry_run_send",
        AdbFeature.DelayedAck,
] as AdbFeature[];
    ] as AdbFeature[])();
export const ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE = 32 * 1024 * 1024;

export type AdbDaemonConnection = ReadableWritablePair<
Loading