Skip to main content
Version: 1.0.0

Upgrade from 0.0.24

The version 1.0.0 contains many breaking changes, mainly to improve developer experience and reduce bundling size by improve tree-shaking.

This page lists changes from version 0.0.24 in core packages.

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

@yume-chan/adb

Remove TypeScript enums and namespaces

TypeScript enums and namespaces transpiles to IIFEs with side effects, which can't be tree-shaken.

To reduce the bundling size, the following TypeScript enums have been converted to plain objects. Type aliases that represents the union of their values has been added to keep source-compatibility. However, you can't directly convert the value back to its name any more:

  • AdbShellProtocolId
  • AdbSyncSendV2Flags
  • LinuxFileType
  • AdbSyncStatErrorCode (use AdbSyncStatErrorName to convert values back to names)
  • AdbAuthType
  • AdbCommand
  • AdbBannerKey
  • AdbFeature
0.0.241.0.0
const value = AdbCommand.Connect; // 0
const name = AdbCommand[AdbCommand.Connect]; // "Connect"
const value = AdbCommand.Connect; // 0
const name = AdbCommand[AdbCommand.Connect]; // Error

Device watcher API change

AdbServerClient.prototype.trackDevices now returns an AdbServerClient.DeviceObserver instead of an async generator.

0.0.241.0.0
for await (const devices of client.trackDevices(signal)) {
console.log(devices);
}
const observer = client.trackDevices();
observer.onDeviceAdd((devices) => {
console.log(devices);
});
observer.onDeviceRemove((devices) => {
console.log(devices);
});
observer.stop();

Fix pushing files with custom server connector

The connect method of AdbServerClient.ServerConnector instances now needs to return a WritableStream<MaybeConsumable<Uint8Array>> instead of a WritableStream<Uint8Array>. It's unsafe to automatically unwrap MaybeConsumables, the old version was causing corruptions when pushing files.

@yume-chan/adb-daemon-webusb

Simplified device filter

AdbDaemonWebUsbDeviceManager.prototype.requestDevice now accepts normal USBDeviceFilter objects (which means all fields are optional), and automatically merges default ADB interface filters (classCode, subclassCode and protocolCode) into each of them if not exist.

0.0.241.0.0
const device = await manager.requestDevice({
filters: [{ ...ADB_DEFAULT_DEVICE_FILTER, vendorId: 0x1234 }],
});
const device = await manager.requestDevice({
filters: [{ vendorId: 0x1234 }],
});

As a result, AdbDeviceFilter type and ADB_DEFAULT_DEVICE_FILTER constant are removed.

Exclusive filter in getDevices

Changed AdbDaemonWebUsbDeviceManager.prototype.getDevices method to also accept exclusionFilters.

0.0.241.0.0
const devices = await manager.getDevices([{ vendorId: 0x1234 }]);
const devices = await manager.getDevices({
filters: [{ vendorId: 0x1234 }],
exclusionFilters: [{ vendorId: 0x5678 }],
});

Device watcher API change

The exported type AdbDaemonWebUsbDeviceWatcher has been replaced by AdbDaemonWebUsbDeviceObserver. It shares the same interface as AdbServerClient.DeviceObserver to improve consistency and ease of use.

0.0.241.0.0
const watcher = new AdbDaemonWebUsbDeviceWatcher((serial) => {
console.log(serial); // string for added device, undefined for removed device
}, navigator.usb);
const observer = manager.trackDevices();
observer.onDeviceAdd((devices) => {
console.log(devices);
});
observer.onDeviceRemove((devices) => {
console.log(devices);
});
observer.stop();

Added AdbDaemonWebUsbDeviceManager.prototype.trackDevices method that creates an AdbDaemonWebUsbDeviceObserver instance. It mirrors AdbServerClient.prototype.trackDevices.

const observer1 = new AdbDaemonWebUsbDeviceObserver(navigator.usb, {
filters: [{ vendorId: 0x1234 }],
});
const observer2 = manager.trackDevices();

@yume-chan/android-bin

Remove TypeScript enums

For the reason stated above, the following TypeScript enums are converted to plain objects:

  • DumpSys.Battery.Status
  • DumpSys.Battery.Health
  • LogId (use LogIdName to convert values back to names)
  • AndroidLogPriority
  • LogcatFormat

Add Intent.prototype.addStringExtra method

Thanks @cedricdevriendt for submitting #644!

@yume-chan/stream-extra

Add BufferedReadableStream.prototype.iterateExactly

Which returns chunks of data until the requested size is reached (while BufferedReadableStream.prototype.readExactly combines the chunks into one Uint8Array). This allows incremental processing and more granular control.

Workaround a ESBuild bug

Changed the coding style to workaround evanw/esbuild#3923. This should allow using in Vite without optimizeDeps.exclude option.

Simplify PushReadableStream usage

PushReadableStream now ignores (instead of throwing an error) calling controller.enqueue, controller.close and controller.error when the stream is already in an errored or closed state. This simplifies the usage.

Polyfill ReadableStream.from and ReadableStream.prototype[Symbol.asyncIterator]

Automatically polyfill ReadableStream.from, ReadableStream.prototype[Symbol.asyncIterator] and ReadableStream.prototype.values when necessary.

@yume-chan/struct

Whole package rewrite

The whole package has been mostly rewritten:

  • SyncPromise has been replaced with bipedal to support running async functions synchronously when possible.
  • new Struct has been replaced with struct method.
  • Fluent style API has been replaced by individual field type methods for easier extension and better tree-shaking.

The new API is inspired by TypeGPU and gensync. Check README for documentation.

Remove ValueOrPromise

The exported type ValueOrPromise has been moved to @yume-chan/async and renamed to MaybePromiseLike.

Rename EMPTY_UINT8_ARRAY

The exported value EMPTY_UINT8_ARRAY has been renamed to EmptyUint8Array. We will use PascalCase for constants in the future.