Upgrade from 1.1.0
This page lists changes from version 1.1.0 in core packages.
For changes in Scrcpy-related packages, see this page.
@yume-chan/adb
Subprocess API redesign
The subprocess has been completed redesigned.
none protocol and shell protocol are now completely separated, so you can choose none protocol for speed and compatibility, or shell protocol for features.
raw mode and pty mode now also have separated types.
| Type | Protocol | Mode | stdin | input | stdout | stderr | output | resize | sigint |
|---|---|---|---|---|---|---|---|---|---|
AdbNoneProtocolProcess | None | Raw | ✅ | ⛔ | ⛔ | ⛔ | ✅ | ⛔ | ⛔ |
AdbShellProtocolProcess | Shell | Raw | ✅ | ⛔ | ✅ | ✅ | ⛔ | ⛔ | ⛔ |
AdbNoneProtocolPtyProcess | None | PTY | ⛔ | ✅ | ⛔ | ⛔ | ✅ | ⛔ | ✅ |
AdbShellProtocolPtyProcess | Shell | PTY | ⛔ | ✅ | ⛔ | ⛔ | ✅ | ✅ | ✅ |
Choose protocol explicitly
// Will try shell protocol first and fallback to none protocol
const process = await adb.subprocess.spawn("ls");
// Use none protocol if you don't need separated `stdout` and `stderr`
const process = await adb.subprocess.noneProtocol.spawn("ls");
// Or test if shell protocol is supported by device
if (adb.subprocess.shellProtocol) {
const process = await adb.subprocess.shellProtocol.spawn("ls");
} else {
// Unsupported, not possible to get separated `stdout` and `stderr`
}
None protocol output stream contains both stdout and stderr
const process = await adb.subprocess.spawn("ls", {
protocols: [AdbSubprocessNoneProtocol],
});
// `stdout` field actually contains both `stdout` and `stderr`
for (const chunk of process.stdout) {
console.log(chunk);
}
const process = await adb.subprocess.noneProtocol.spawn("ls");
// It has been renamed to `output`
for (const chunk of process.output) {
console.log(chunk);
}
shell renamed to pty
const process = await adb.subprocess.shell();
// PTY mode only has one output stream
for (const chunk of process.stdout) {
console.log(chunk);
}
const process = await adb.subprocess.noneProtocol.pty();
// It has been renamed to `output`
for (const chunk of process.output) {
console.log(chunk);
}
spawnAndWait enhancements
const { exitCode, stdout, stderr } = await adb.subprocess.spawnAndWait("ls");
| Field | None protocol | Shell protocol |
|---|---|---|
exitCode | Always 0 | Actual exit code |
stdout | Mix of stdout and stderr | stdout |
stderr | Always an empty string | stderr |
const binaryOutput: Uint8Array =
await adb.subprocess.noneProtocol.spawnWait("ls");
const textOutput: string =
await adb.subprocess.noneProtocol.spawnWaitText("ls");
const {
exitCode /* : number */,
stdout /* : Uint8Array */,
stderr /* : Uint8Array */,
} = await adb.subprocess.shellProtocol.spawnWait("ls");
const {
exitCode /* : number */,
stdout /* : string */,
stderr /* : string */,
} = await adb.subprocess.shellProtocol.spawnWaitText("ls");
Creating AdbDaemonWebUsbDeviceObserver is now asynchronous
AdbDaemonWebUsbDeviceObserver needs to retrieve initial device list and set the current field, so the creating process needs to be asynchronous.
-
AdbDaemonWebUsbDeviceManager#trackDeviceshas became asynchronous.1.1.0const observer = manager.trackDevices();
console.log(observer.current); // []nextconst observer = await manager.trackDevices();
console.log(observer.current); // [device1, ...] -
AdbDaemonWebUsbDeviceObserver's constructor now require aninitialparameter. Generally, it should not be used directly. -
AdbDaemonWebUsbDeviceObserver.createstatic method has been added to asynchronously create anAdbDaemonWebUsbDeviceObserver1.1.0const observer = new AdbDaemonWebUsbDeviceObserver(navigator.usb);
console.log(observer.current); // []nextconst observer = await AdbDaemonWebUsbDeviceObserver.create(navigator.usb);
console.log(observer.current); // [device1, ...]
DeviceObserver behavior normalization
DeviceObserver is the common interface behind daemon transport WebUSB connection device observer AdbDaemonWebUsbDeviceObserver and server transport device observer AdbServerDeviceObserver.
- The
currentfield is now an immutable array. It will be guaranteed to contain current device list when the observer is created. Every time the list changes, a new array will be created and returned. onListChangeevent is now sticky, meaning newly attached event listeners will be invoked immediately with the latest value.