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.

Here are all the changes, grouped by package:

@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/adb-scrcpy

Fix automatically switching to forward tunnel

Fixed a bug that AdbScrcpyOptionsX_XX doesn't automatically switch to forward tunnel mode when reverse tunnel is not supported.

Properly handle device message stream

Now it handles errors and stream closures when parsing the device message stream. The errors and closures will be propagated to ScrcpyOptionsX_XX.prototype.clipboard and ScrcpyOptionsX_XX.prototype.uHidOutput (docs to be added).

@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/aoa

All options to HidMouse.serializeInputReport are now optional.

0.0.241.0.0
const report = HidMouse.serializeInputReport({
movementX: 10,
movementY: -5,
buttons: 0,
scrollX: 0,
scrollY: 0,
});
const report = HidMouse.serializeInputReport({
movementX: 10,
movementY: -5,
});

@yume-chan/scrcpy

Rewrite options classes

Options classes now share code using ES modules, instead of inheritance, so if you only import one options class, unused code can be tree-shaken.

Removed ScrcpyOptionsX_XX.prototype.defaults. Now there is only ScrcpyOptionsX_XX.Defaults.

Added ScrcpyOptionsX_XX.Init type aliases for the options types.

Rename AndroidKeyEventMeta values

Addition to the enum-to-object conversion, the AndroidKeyEventMeta enum also have its value names changed:

0.0.241.0.0
const message: Uint8Array = serializer.injectKeyCode({
action: AndroidKeyEventAction.Down,
keyCode: AndroidKeyCode.KeyA,
repeat: 0,
metaState: AndroidKeyEventMeta.ShiftOn,
});
const message: Uint8Array = serializer.injectKeyCode({
action: AndroidKeyEventAction.Down,
keyCode: AndroidKeyCode.KeyA,
repeat: 0,
metaState: AndroidKeyEventMeta.Shift,
});

Improve clipboard stream

Set ScrcpyOptionsX_XX.prototype.clipboard to undefined when it's disabled by options.

const options = new ScrcpyOptions3_0({
control: false,
});
options.clipboard; // undefined
const options = new ScrcpyOptions3_0({
clipboardAutosync: false,
});
options.clipboard; // undefined

ScrcpyOptionsX_XX.prototype.clipboard.cancel now correctly ignores future messages.

const options = new ScrcpyOptions3_0();
await options.clipboard.cancel();

Add basic UHID support

Support Scrcpy UHID messages via ScrcpyOptionsX_XX.prototype.uHidOutput (from v2.4), ScrcpyControlMessageSerializer.prototype.uHidCreate (from v2.4), ScrcpyControlMessageSerializer.prototype.uHidInput (from v2.4) and ScrcpyControlMessageSerializer.prototype.uHidDestroy (from v2.7).

A better integration is coming soon.

Add support for Scrcpy 3.0

Support all new options up to Scrcpy 3.0.

@yume-chan/scrcpy-decoder-tinyh264

Support rendering to OffscreenCanvas. Thanks @oott123 for submitting #643!

@yume-chan/scrcpy-decoder-webcodecs

Add multiple renderers

There are multiple ways to render WebCodecs video frames. Now the package ships with several renderers, and you need to create a renderer before creating a decoder.

For canvas-based renderers, rendering to OffscreenCanvas is now also supported.

Fix rendering H.265 in Microsoft Edge

Fixed rendering H.265 videos having incorrect size in Microsoft Edge on Windows.

@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.