chore: small cleanups

This commit is contained in:
Simon Chan 2024-11-29 22:40:08 +08:00
parent 6ae5f38af1
commit ea5002bc87
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
33 changed files with 55 additions and 46 deletions

View file

@ -0,0 +1,5 @@
---
"@yume-chan/stream-extra": patch
---
Polyfill `ReadableStream.from` and `ReadableStream.prototype.values`

View file

@ -0,0 +1,5 @@
---
"@yume-chan/fetch-scrcpy-server": patch
---
Mark `BIN` field as pure

View file

@ -0,0 +1,5 @@
---
"@yume-chan/scrcpy": patch
---
Add support up to Scrcpy version 3.0

View file

@ -66,8 +66,6 @@ async function getAllKeys() {
/** /**
* An `AdbCredentialStore` implementation that creates RSA private keys using Web Crypto API * An `AdbCredentialStore` implementation that creates RSA private keys using Web Crypto API
* and stores them in IndexedDB. * and stores them in IndexedDB.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/credential-store/)
*/ */
export default class AdbWebCredentialStore implements AdbCredentialStore { export default class AdbWebCredentialStore implements AdbCredentialStore {
#appName: string; #appName: string;

View file

@ -30,7 +30,7 @@ This package is part of [Tango ADB](https://github.com/yume-chan/ya-webadb). Gen
## Documentation ## Documentation
Check the latest documentation at https://docs.tangoapp.dev/tango/daemon/usb/device-manager/ Check the latest documentation at https://docs.tangoapp.dev/tango/daemon/usb/
## Sponsors ## Sponsors

View file

@ -344,8 +344,6 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice {
/** /**
* Open the device and create a new connection to the ADB Daemon. * Open the device and create a new connection to the ADB Daemon.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/create-connection/)
*/ */
async connect(): Promise<AdbDaemonWebUsbConnection> { async connect(): Promise<AdbDaemonWebUsbConnection> {
const [inEndpoint, outEndpoint] = await this.#claimInterface(); const [inEndpoint, outEndpoint] = await this.#claimInterface();

View file

@ -9,9 +9,6 @@ export namespace AdbDaemonWebUsbDeviceManager {
} }
} }
/**
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/device-manager/)
*/
export class AdbDaemonWebUsbDeviceManager { export class AdbDaemonWebUsbDeviceManager {
/** /**
* Gets the instance of {@link AdbDaemonWebUsbDeviceManager} using browser WebUSB implementation. * Gets the instance of {@link AdbDaemonWebUsbDeviceManager} using browser WebUSB implementation.
@ -36,8 +33,6 @@ export class AdbDaemonWebUsbDeviceManager {
/** /**
* Call `USB#requestDevice()` to prompt the user to select a device. * Call `USB#requestDevice()` to prompt the user to select a device.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/request-device/)
*/ */
async requestDevice( async requestDevice(
options: AdbDaemonWebUsbDeviceManager.RequestDeviceOptions = {}, options: AdbDaemonWebUsbDeviceManager.RequestDeviceOptions = {},
@ -62,8 +57,6 @@ export class AdbDaemonWebUsbDeviceManager {
/** /**
* Get all connected and requested devices that match the specified filters. * Get all connected and requested devices that match the specified filters.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/get-devices/)
*/ */
getDevices(filters?: USBDeviceFilter[]): Promise<AdbDaemonWebUsbDevice[]>; getDevices(filters?: USBDeviceFilter[]): Promise<AdbDaemonWebUsbDevice[]>;
async getDevices( async getDevices(

View file

@ -8,8 +8,6 @@ import { matchesFilters } from "./utils.js";
/** /**
* A watcher that listens for new WebUSB devices and notifies the callback when * A watcher that listens for new WebUSB devices and notifies the callback when
* a new device is connected or disconnected. * a new device is connected or disconnected.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/watch-devices/)
*/ */
export class AdbDaemonWebUsbDeviceObserver export class AdbDaemonWebUsbDeviceObserver
implements DeviceObserver<AdbDaemonWebUsbDevice> implements DeviceObserver<AdbDaemonWebUsbDevice>

View file

@ -30,7 +30,7 @@ This package is part of [Tango ADB](https://github.com/yume-chan/ya-webadb). Gen
## Documentation ## Documentation
Check the latest documentation at https://docs.tangoapp.dev/tango/server/client/ Check the latest documentation at https://docs.tangoapp.dev/tango/server/
## Sponsors ## Sponsors

View file

@ -58,8 +58,6 @@ function nodeSocketToConnection(
/** /**
* An `AdbServerClient.ServerConnector` implementation for Node.js. * An `AdbServerClient.ServerConnector` implementation for Node.js.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/client/)
*/ */
export class AdbServerNodeTcpConnector export class AdbServerNodeTcpConnector
implements AdbServerClient.ServerConnector implements AdbServerClient.ServerConnector

View file

@ -24,8 +24,6 @@ export interface Closeable {
/** /**
* Represents an ADB socket. * Represents an ADB socket.
*
* [Online Documentation](https://docs.tangoapp.dev/api/socket/)
*/ */
export interface AdbSocket export interface AdbSocket
extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>, extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>,
@ -112,8 +110,6 @@ export class Adb implements Closeable {
/** /**
* Creates a new ADB Socket to the specified service or socket address. * Creates a new ADB Socket to the specified service or socket address.
*
* [Online Documentation](https://docs.tangoapp.dev/api/socket/#forward-tunnel)
*/ */
async createSocket(service: string): Promise<AdbSocket> { async createSocket(service: string): Promise<AdbSocket> {
return this.transport.connect(service); return this.transport.connect(service);

View file

@ -25,7 +25,7 @@ const AdbReverseStringResponse = struct(
content: string({ content: string({
field: "length", field: "length",
convert(value: string) { convert(value: string) {
return Number.parseInt(value); return Number.parseInt(value, 16);
}, },
back(value) { back(value) {
return value.toString(16).padStart(4, "0"); return value.toString(16).padStart(4, "0");
@ -108,8 +108,6 @@ export class AdbReverseCommand {
/** /**
* Get a list of all reverse port forwarding on the device. * Get a list of all reverse port forwarding on the device.
*
* [Online Documentation](https://docs.tangoapp.dev/api/reverse/list/)
*/ */
async list(): Promise<AdbForwardListener[]> { async list(): Promise<AdbForwardListener[]> {
const stream = await this.createBufferedStream("reverse:list-forward"); const stream = await this.createBufferedStream("reverse:list-forward");
@ -130,8 +128,6 @@ export class AdbReverseCommand {
/** /**
* Add a reverse port forwarding for a program that already listens on a port. * Add a reverse port forwarding for a program that already listens on a port.
*
* [Online Documentation](https://docs.tangoapp.dev/api/reverse/add/#addexternal)
*/ */
async addExternal(deviceAddress: string, localAddress: string) { async addExternal(deviceAddress: string, localAddress: string) {
const stream = await this.sendRequest( const stream = await this.sendRequest(
@ -165,8 +161,6 @@ export class AdbReverseCommand {
/** /**
* Add a reverse port forwarding. * Add a reverse port forwarding.
*
* [Online Documentation](https://docs.tangoapp.dev/api/reverse/add/)
*/ */
async add( async add(
deviceAddress: string, deviceAddress: string,
@ -190,8 +184,6 @@ export class AdbReverseCommand {
/** /**
* Remove a reverse port forwarding. * Remove a reverse port forwarding.
*
* [Online Documentation](https://docs.tangoapp.dev/api/reverse/remove/#remove-one-port-forwarding)
*/ */
async remove(deviceAddress: string): Promise<void> { async remove(deviceAddress: string): Promise<void> {
const localAddress = const localAddress =
@ -207,8 +199,6 @@ export class AdbReverseCommand {
/** /**
* Remove all reverse port forwarding, including the ones added by other programs. * Remove all reverse port forwarding, including the ones added by other programs.
*
* [Online Documentation](https://docs.tangoapp.dev/api/reverse/remove/#remove-all-port-forwardings)
*/ */
async removeAll(): Promise<void> { async removeAll(): Promise<void> {
await this.adb.transport.clearReverseTunnels(); await this.adb.transport.clearReverseTunnels();

View file

@ -151,14 +151,10 @@ interface AdbDaemonSocketConnectorConstructionOptions {
/** /**
* An ADB Transport that connects to ADB Daemons directly. * An ADB Transport that connects to ADB Daemons directly.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/)
*/ */
export class AdbDaemonTransport implements AdbTransport { export class AdbDaemonTransport implements AdbTransport {
/** /**
* Authenticate with the ADB Daemon and create a new transport. * Authenticate with the ADB Daemon and create a new transport.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/connect-device/)
*/ */
static async authenticate({ static async authenticate({
serial, serial,

View file

@ -115,8 +115,6 @@ class AdbServerStream {
/** /**
* Client for the ADB Server. * Client for the ADB Server.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/client/)
*/ */
export class AdbServerClient { export class AdbServerClient {
static readonly VERSION = 41; static readonly VERSION = 41;
@ -275,8 +273,6 @@ export class AdbServerClient {
* Get a list of connected devices from ADB Server. * Get a list of connected devices from ADB Server.
* *
* Equivalent ADB Command: `adb devices -l` * Equivalent ADB Command: `adb devices -l`
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/devices/)
*/ */
async getDevices(): Promise<AdbServerClient.Device[]> { async getDevices(): Promise<AdbServerClient.Device[]> {
const connection = await this.createConnection("host:devices-l"); const connection = await this.createConnection("host:devices-l");
@ -290,8 +286,6 @@ export class AdbServerClient {
/** /**
* Monitors device list changes. * Monitors device list changes.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/watch/)
*/ */
async trackDevices(): Promise<DeviceObserver<AdbServerClient.Device>> { async trackDevices(): Promise<DeviceObserver<AdbServerClient.Device>> {
const connection = await this.createConnection("host:track-devices-l"); const connection = await this.createConnection("host:track-devices-l");
@ -520,8 +514,6 @@ export class AdbServerClient {
/** /**
* Creates an ADB Transport for the specified device. * Creates an ADB Transport for the specified device.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/transport/)
*/ */
async createTransport( async createTransport(
device: AdbServerClient.DeviceSelector, device: AdbServerClient.DeviceSelector,
@ -613,8 +605,6 @@ export namespace AdbServerClient {
/** /**
* A union type for selecting a device. * A union type for selecting a device.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/selector/)
*/ */
export type DeviceSelector = export type DeviceSelector =
| { transportId: bigint } | { transportId: bigint }

View file

@ -41,6 +41,7 @@ export class H265Decoder extends H26xDecoder {
].join("."); ].join(".");
this.#decoder.configure({ this.#decoder.configure({
codec, codec,
// Microsoft Edge requires explicit size to work
codedWidth: croppedWidth, codedWidth: croppedWidth,
codedHeight: croppedHeight, codedHeight: croppedHeight,
optimizeForLatency: true, optimizeForLatency: true,

View file

@ -34,6 +34,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_15 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_15 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -38,6 +38,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_17 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_17 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -38,6 +38,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_18 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_18 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -37,6 +37,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_21 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_21 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -37,6 +37,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_22 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_22 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -37,6 +37,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_23 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_23 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -37,6 +37,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_24 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_24 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -37,6 +37,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions1_25 implements ScrcpyOptions<Init> { export class ScrcpyOptions1_25 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -38,6 +38,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions2_0 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_0 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -38,6 +38,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions2_1 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_1 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -38,6 +38,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions2_2 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_2 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -38,6 +38,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions2_3 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_3 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -42,6 +42,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions2_4 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_4 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -42,6 +42,8 @@ import {
import type { Init } from "./impl/index.js"; import type { Init } from "./impl/index.js";
export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -42,6 +42,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> { export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -42,6 +42,8 @@ import {
} from "./impl/index.js"; } from "./impl/index.js";
export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> { export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
static readonly Defaults = Defaults;
readonly value: Required<Init>; readonly value: Required<Init>;
get controlMessageTypes(): readonly ScrcpyControlMessageType[] { get controlMessageTypes(): readonly ScrcpyControlMessageType[] {

View file

@ -84,6 +84,9 @@ const ReadableStream = /* #__PURE__ */ (() => {
yield value; yield value;
} }
} finally { } finally {
// Calling `iterator.return` will enter this `finally` block.
// We don't need to care about the parameter to `iterator.return`,
// it will be returned as the final `result.value` automatically.
if (!options?.preventCancel) { if (!options?.preventCancel) {
await reader.cancel(); await reader.cancel();
} }

View file

@ -1,6 +1,7 @@
{ {
"name": "side-effect-test", "name": "side-effect-test",
"version": "1.0.0", "version": "1.0.0",
"private": true,
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {