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

Unverified Commit 1d719712 authored by Simon Chan's avatar Simon Chan
Browse files

refactor: add `readonly` to many read only fields

parent 05c01adb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ async function getAllKeys() {
 * and stores them in IndexedDB.
 */
export default class AdbWebCredentialStore implements AdbCredentialStore {
    #appName: string;
    readonly #appName: string;

    constructor(appName = "Tango") {
        this.#appName = appName;
+9 −9
Original line number Diff line number Diff line
@@ -54,27 +54,27 @@ export function mergeDefaultAdbInterfaceFilter(
export class AdbDaemonWebUsbConnection
    implements ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>
{
    #device: AdbDaemonWebUsbDevice;
    readonly #device: AdbDaemonWebUsbDevice;
    get device() {
        return this.#device;
    }

    #inEndpoint: USBEndpoint;
    readonly #inEndpoint: USBEndpoint;
    get inEndpoint() {
        return this.#inEndpoint;
    }

    #outEndpoint: USBEndpoint;
    readonly #outEndpoint: USBEndpoint;
    get outEndpoint() {
        return this.#outEndpoint;
    }

    #readable: ReadableStream<AdbPacketData>;
    readonly #readable: ReadableStream<AdbPacketData>;
    get readable() {
        return this.#readable;
    }

    #writable: WritableStream<Consumable<AdbPacketInit>>;
    readonly #writable: WritableStream<Consumable<AdbPacketInit>>;
    get writable() {
        return this.#writable;
    }
@@ -233,15 +233,15 @@ export class AdbDaemonWebUsbConnection
export class AdbDaemonWebUsbDevice implements AdbDaemonDevice {
    static DeviceBusyError = _DeviceBusyError;

    #interface: UsbInterfaceIdentifier;
    #usbManager: USB;
    readonly #interface: UsbInterfaceIdentifier;
    readonly #usbManager: USB;

    #raw: USBDevice;
    readonly #raw: USBDevice;
    get raw() {
        return this.#raw;
    }

    #serial: string;
    readonly #serial: string;
    get serial(): string {
        return this.#serial;
    }
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ export class AdbDaemonWebUsbDeviceManager {
            ? new AdbDaemonWebUsbDeviceManager(globalThis.navigator.usb)
            : undefined)();

    #usbManager: USB;
    readonly #usbManager: USB;

    /**
     * Create a new instance of {@link AdbDaemonWebUsbDeviceManager} using the specified WebUSB implementation.
+18 −15
Original line number Diff line number Diff line
@@ -9,10 +9,10 @@ import type { AdbBanner } from "./banner.js";
import type { AdbFrameBuffer } from "./commands/index.js";
import {
    AdbPower,
    AdbReverseCommand,
    AdbReverseService,
    AdbSubprocessService,
    AdbSync,
    AdbTcpIpCommand,
    AdbTcpIpService,
    escapeArg,
    framebuffer,
} from "./commands/index.js";
@@ -61,26 +61,29 @@ export interface AdbTransport extends Closeable {
}

export class Adb implements Closeable {
    readonly transport: AdbTransport;
    readonly #transport: AdbTransport;
    get transport(): AdbTransport {
        return this.#transport;
    }

    get serial() {
        return this.transport.serial;
        return this.#transport.serial;
    }

    get maxPayloadSize() {
        return this.transport.maxPayloadSize;
        return this.#transport.maxPayloadSize;
    }

    get banner() {
        return this.transport.banner;
        return this.#transport.banner;
    }

    get disconnected() {
        return this.transport.disconnected;
        return this.#transport.disconnected;
    }

    public get clientFeatures() {
        return this.transport.clientFeatures;
        return this.#transport.clientFeatures;
    }

    public get deviceFeatures() {
@@ -89,16 +92,16 @@ export class Adb implements Closeable {

    readonly subprocess: AdbSubprocessService;
    readonly power: AdbPower;
    readonly reverse: AdbReverseCommand;
    readonly tcpip: AdbTcpIpCommand;
    readonly reverse: AdbReverseService;
    readonly tcpip: AdbTcpIpService;

    constructor(transport: AdbTransport) {
        this.transport = transport;
        this.#transport = transport;

        this.subprocess = new AdbSubprocessService(this);
        this.power = new AdbPower(this);
        this.reverse = new AdbReverseCommand(this);
        this.tcpip = new AdbTcpIpCommand(this);
        this.reverse = new AdbReverseService(this);
        this.tcpip = new AdbTcpIpService(this);
    }

    canUseFeature(feature: AdbFeature): boolean {
@@ -112,7 +115,7 @@ export class Adb implements Closeable {
     * Creates a new ADB Socket to the specified service or socket address.
     */
    async createSocket(service: string): Promise<AdbSocket> {
        return this.transport.connect(service);
        return this.#transport.connect(service);
    }

    async createSocketAndWait(service: string): Promise<string> {
@@ -162,6 +165,6 @@ export class Adb implements Closeable {
    }

    async close(): Promise<void> {
        await this.transport.close();
        await this.#transport.close();
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -51,22 +51,22 @@ export class AdbBanner {
        return new AdbBanner(product, model, device, features);
    }

    #product: string | undefined;
    readonly #product: string | undefined;
    get product() {
        return this.#product;
    }

    #model: string | undefined;
    readonly #model: string | undefined;
    get model() {
        return this.#model;
    }

    #device: string | undefined;
    readonly #device: string | undefined;
    get device() {
        return this.#device;
    }

    #features: AdbFeature[] = [];
    readonly #features: AdbFeature[] = [];
    get features() {
        return this.#features;
    }
Loading