Skip to main content
Version: next

Upgrade from 2.0.0

This page lists changes from version 2.0.0 in core packages.

For changes in Scrcpy-related packages, see this page.

@yume-chan/adb

Server client can filter devices by state

AdbServerClient.prototype.getDevices and AdbServerClient.prototype.trackDevices now accept an optional includeStates parameter.

It can be an array of AdbServerClient.ConnectionState, i.e., "unauthorized" | "offline" | "device"

The default value is ["unauthorized", "device"] for backward compatibility. In a future major version, the default value will be changed to ["unauthorized", "offline", "device"].

import type { AdbServerClient } from "@yume-chan/adb";

declare const client: AdbServerClient;

const devices: AdbServerClient.Device[] = await client.getDevices([
"unauthorized",
"offline",
"device",
]);

const observer = await client.trackDevices({
includeStates: ["unauthorized", "offline", "device"],
});

Add device state to AdbServerClient.Device

To comply with the new API, AdbServerClient.Device now has a state property.

The old authenticating property is deprecated, and will be removed in a future major version. It now only returns true when state is "unauthorized".

import type { AdbServerClient } from "@yume-chan/adb";

declare const device: AdbServerClient.Device;

console.log(device.state); // "unauthorized" | "offline" | "device"
console.log(device.authenticating); // `true` when `device.state === "unauthorized"`

Subprocess spawnWait and spawnWaitText methods has been moved to method chaining

import type { Adb } from "@yume-chan/adb";

declare const adb: Adb;

// Before
const output = await adb.subprocess.noneProtocol.spawnWait("ls -al /");
// After
const output = await adb.subprocess.noneProtocol.spawn("ls -al /").wait();

// Before
const output = await adb.subprocess.noneProtocol.spawnWaitText("ls -al /");
// After
const output = await adb.subprocess.noneProtocol.spawn("ls -al /").wait().toString();

The wait method now accepts a ReadableStream for stdin:

import type { Adb } from "@yume-chan/adb";
import { ReadableStream } from "@yume-chan/stream-extra";

declare const adb: Adb;

const output = await adb.subprocess.shellProtocol!.spawn("cat").wait({
stdin: new ReadableStream<Uint8Array>({
start(controller) {
controller.enqueue(encodeUtf8("Hello World!"));
controller.close();
},
}),
});

Shell protocol raw mode now supports closing stdin

Shell protocol in raw mode is the only combination that supports closing stdin. Some programs (like cat) might rely on this behavior to properly function.

When using spawn, stdin can be closed by closing the WritableStream:

import type { Adb } from "@yume-chan/adb";
import { encodeUtf8 } from "@yume-chan/adb";

declare const adb: Adb;

const process = await adb.subprocess.shellProtocol!.spawn("cat");

const writer = process.stdin.getWriter();
await writer.write(encodeUtf8("Hello World!"));
await writer.close();

When using spawn.wait, stdin can be closed by closing the ReadableStream:

import type { Adb } from "@yume-chan/adb";
import { encodeUtf8 } from "@yume-chan/adb";
import { ReadableStream } from "@yume-chan/stream-extra";

declare const adb: Adb;

const output = await adb.subprocess.shellProtocol!.spawn("cat").wait({
stdin: new ReadableStream<Uint8Array>({
start(controller) {
controller.enqueue(encodeUtf8("Hello World!"));
controller.close();
},
}),
});