Skip to content

Commit bc068bb

Browse files
committed
add headers to changelog
1 parent 53208fd commit bc068bb

File tree

2 files changed

+146
-44
lines changed

2 files changed

+146
-44
lines changed

docs/scrcpy/control/keyboard.mdx

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,35 @@ Inject a keyboard event into the device.
99
## Options
1010

1111
```ts
12-
enum AndroidKeyEventAction {
13-
Down = 0,
14-
Up = 1,
15-
}
12+
export const AndroidKeyEventAction = {
13+
Down: 0,
14+
Up: 1,
15+
} as const;
1616

17-
export enum AndroidKeyEventMeta {
18-
AltOn = 0x02,
19-
AltLeftOn = 0x10,
20-
AltRightOn = 0x20,
21-
ShiftOn = 0x01,
22-
ShiftLeftOn = 0x40,
23-
ShiftRightOn = 0x80,
24-
CtrlOn = 0x1000,
25-
CtrlLeftOn = 0x2000,
26-
CtrlRightOn = 0x4000,
27-
MetaOn = 0x10000,
28-
MetaLeftOn = 0x20000,
29-
MetaRightOn = 0x40000,
30-
CapsLockOn = 0x100000,
31-
NumLockOn = 0x200000,
32-
ScrollLockOn = 0x400000,
33-
}
17+
export type AndroidKeyEventAction =
18+
(typeof AndroidKeyEventAction)[keyof typeof AndroidKeyEventAction];
19+
20+
export const AndroidKeyEventMeta = {
21+
None: 0,
22+
Alt: 0x02,
23+
AltLeft: 0x10,
24+
AltRight: 0x20,
25+
Shift: 0x01,
26+
ShiftLeft: 0x40,
27+
ShiftRight: 0x80,
28+
Ctrl: 0x1000,
29+
CtrlLeft: 0x2000,
30+
CtrlRight: 0x4000,
31+
Meta: 0x10000,
32+
MetaLeft: 0x20000,
33+
MetaRight: 0x40000,
34+
CapsLock: 0x100000,
35+
NumLock: 0x200000,
36+
ScrollLock: 0x400000,
37+
} as const;
38+
39+
export type AndroidKeyEventMeta =
40+
(typeof AndroidKeyEventMeta)[keyof typeof AndroidKeyEventMeta];
3441

3542
interface ScrcpyInjectKeyCodeControlMessage {
3643
action: AndroidKeyEventAction;
@@ -59,22 +66,22 @@ const message: Uint8Array = serializer.injectKeyCode({
5966
action: AndroidKeyEventAction.Down,
6067
keyCode: AndroidKeyCode.KeyA,
6168
repeat: 0,
62-
metaState: AndroidKeyEventMeta.ShiftOn,
69+
metaState: AndroidKeyEventMeta.Shift,
6370
});
6471

6572
// Using `ScrcpyControlMessageWriter`
6673
await writer.injectKeyCode({
6774
action: AndroidKeyEventAction.Down,
6875
keyCode: AndroidKeyCode.KeyA,
6976
repeat: 0,
70-
metaState: AndroidKeyEventMeta.ShiftOn,
77+
metaState: AndroidKeyEventMeta.Shift,
7178
});
7279

7380
// Using `AdbScrcpyClient`
7481
await client.controller!.injectKeyCode({
7582
action: AndroidKeyEventAction.Down,
7683
keyCode: AndroidKeyCode.KeyA,
7784
repeat: 0,
78-
metaState: AndroidKeyEventMeta.ShiftOn,
85+
metaState: AndroidKeyEventMeta.Shift,
7986
});
8087
```

docs/tango/upgrade.mdx

Lines changed: 115 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ Here are all the changes, grouped by package:
66

77
## `@yume-chan/adb`
88

9-
The following TypeScript enums have been converted to plain objects to improve tree-shaking in Rollup. Type aliases that represents the union of their values has been added to keep source-compatibility. But you can't directly convert the value back to its name any more:
9+
### Remove TypeScript enums and namespaces
10+
11+
TypeScript enums and namespaces transpiles to IIFEs with side effects, which can't be tree-shaken.
12+
13+
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:
1014

1115
- `AdbShellProtocolId`
1216
- `AdbSyncSendV2Flags`
@@ -46,7 +50,9 @@ const name = AdbCommand[AdbCommand.Connect]; // Error
4650
</tbody>
4751
</table>
4852

49-
[`AdbServerClient#trackDevices`](./server/watch.mdx) now returns an `AdbServerClient.DeviceObserver` instead of an async generator.
53+
### Device watcher API change
54+
55+
[`AdbServerClient.prototype.trackDevices`](./server/watch.mdx) now returns an `AdbServerClient.DeviceObserver` instead of an async generator.
5056

5157
<table style={{display:'table',width:'100%', tableLayout:'fixed'}}>
5258
<thead>
@@ -84,13 +90,15 @@ observer.stop();
8490
</tbody>
8591
</table>
8692

87-
`AdbServerClient.ServerConnector#connect` now needs to return a `WritableStream<MaybeConsumable<Uint8Array>>` instead of a [`WritableStream<Uint8Array>`](./web-stream/index.mdx#writeablestream). It's unsafe to automatically unwrap [`MaybeConsumable`](./consumable.mdx#writablestream)s, the old version was causing corruptions when [pushing files](../api/adb/sync/write.mdx).
93+
### Fix pushing files with custom server connector
94+
95+
The `connect` method of `AdbServerClient.ServerConnector` instances now needs to return a `WritableStream<MaybeConsumable<Uint8Array>>` instead of a [`WritableStream<Uint8Array>`](./web-stream/index.mdx#writeablestream). It's unsafe to automatically unwrap [`MaybeConsumable`](./consumable.mdx#writablestream)s, the old version was causing corruptions when [pushing files](../api/adb/sync/write.mdx).
8896

8997
## `@yume-chan/adb-daemon-webusb`
9098

91-
Removed `AdbDeviceFilter` and `ADB_DEFAULT_DEVICE_FILTER`.
99+
### Simplified device filter
92100

93-
[`AdbDaemonWebUsbDeviceManager#requestDevice`](./daemon/usb/request-device.mdx) now accepts normal `USBDeviceFilter` objects (means all fields are optional), and automatically merges default ADB interface filters (`classCode`, `subclassCode` and `protocolCode`) into each of them if not exist.
101+
[`AdbDaemonWebUsbDeviceManager.prototype.requestDevice`](./daemon/usb/request-device.mdx) 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.
94102

95103
<table style={{display:'table',width:'100%', tableLayout:'fixed'}}>
96104
<thead>
@@ -123,7 +131,11 @@ const device = await manager.requestDevice({
123131
</tbody>
124132
</table>
125133

126-
Changed [`AdbDaemonWebUsbDeviceManager#getDevices`](./daemon/usb/get-devices.mdx) method to also accept `exclusionFilters`.
134+
As a result, `AdbDeviceFilter` type and `ADB_DEFAULT_DEVICE_FILTER` constant are removed.
135+
136+
### Exclusive filter in `getDevices`
137+
138+
Changed [`AdbDaemonWebUsbDeviceManager.prototype.getDevices`](./daemon/usb/get-devices.mdx) method to also accept `exclusionFilters`.
127139

128140
<table style={{display:'table',width:'100%', tableLayout:'fixed'}}>
129141
<thead>
@@ -155,7 +167,9 @@ const devices = await manager.getDevices({
155167
</tbody>
156168
</table>
157169

158-
The exported type `AdbDaemonWebUsbDeviceWatcher` has been replaced by [`AdbDaemonWebUsbDeviceObserver`](./daemon/usb/watch-devices.mdx). It shares the same interface as `AdbServerClient.DeviceObserver` to improve consistency and ease of use.
170+
### Device watcher API change
171+
172+
The exported type `AdbDaemonWebUsbDeviceWatcher` has been replaced by [`AdbDaemonWebUsbDeviceObserver`](./daemon/usb/watch-devices.mdx). It shares the same interface as [`AdbServerClient.DeviceObserver`](#device-watcher-api-change) to improve consistency and ease of use.
159173

160174
<table style={{display:'table',width:'100%', tableLayout:'fixed'}}>
161175
<thead>
@@ -193,7 +207,7 @@ observer.stop();
193207
</tbody>
194208
</table>
195209

196-
Added `AdbDaemonWebUsbDeviceManager#trackDevices` method that creates an `AdbDaemonWebUsbDeviceObserver` instance. It mirrors `AdbServerClient#trackDevices`.
210+
Added `AdbDaemonWebUsbDeviceManager.prototype.trackDevices` method that creates an `AdbDaemonWebUsbDeviceObserver` instance. It mirrors `AdbServerClient.prototype.trackDevices`.
197211

198212
```ts showLineNumbers
199213
const observer1 = new AdbDaemonWebUsbDeviceObserver(navigator.usb, {
@@ -204,21 +218,29 @@ const observer2 = manager.trackDevices();
204218

205219
## `@yume-chan/adb-scrcpy`
206220

221+
### Fix automatically switching to forward tunnel
222+
207223
Fixed a bug that `AdbScrcpyOptionsX_XX` doesn't [automatically switch to forward tunnel mode](../scrcpy/connect-server.mdx#with-yume-chanadb-scrcpy) when reverse tunnel is not supported.
208224

209-
Now it handles errors and stream closures when parsing the device message stream. The errors and closures will be propagated to [`ScrcpyOptionsX_XX#clipboard`](../scrcpy/options/index.mdx#watch-device-clipboard-changes) and `ScrcpyOptionsX_XX#uHidOutput` (docs to be added).
225+
### Properly handle device message stream
226+
227+
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`](../scrcpy/options/index.mdx#watch-device-clipboard-changes) and `ScrcpyOptionsX_XX.prototype.uHidOutput` (docs to be added).
210228

211229
## `@yume-chan/android-bin`
212230

213-
Similar to `@yume-chan/adb`, the following TypeScript enums are converted to plain objects:
231+
### Remove TypeScript enums
232+
233+
For the reason stated [above](#remove-typescript-enums-and-namespaces), the following TypeScript enums are converted to plain objects:
214234

215235
- `DumpSys.Battery.Status`
216236
- `DumpSys.Battery.Health`
217237
- `LogId` (use `LogIdName` to convert values back to names)
218238
- `AndroidLogPriority`
219239
- `LogcatFormat`
220240

221-
Added `Intent#addStringExtra` method. Thanks [@cedricdevriendt](https://github.com/cedricdevriendt) for submitting [#644](https://github.com/yume-chan/ya-webadb/pull/644)!
241+
### Add `Intent.prototype.addStringExtra` method
242+
243+
Thanks [@cedricdevriendt](https://github.com/cedricdevriendt) for submitting [#644](https://github.com/yume-chan/ya-webadb/pull/644)!
222244

223245
## `@yume-chan/aoa`
224246

@@ -262,13 +284,58 @@ const report = HidMouse.serializeInputReport({
262284

263285
## `@yume-chan/scrcpy`
264286

265-
The whole package has been completely rewritten. Options classes now shares code using ES modules, instead of inheritance, so if you only import one options class, only the related code will be included in the output bundle.
287+
### Rewrite options classes
266288

267-
Removed `ScrcpyOptionsX_XX#defaults`. Now there is only `ScrcpyOptionsX_XX.Defaults`.
289+
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.
290+
291+
Removed `ScrcpyOptionsX_XX.prototype.defaults`. Now there is only `ScrcpyOptionsX_XX.Defaults`.
268292

269293
Added `ScrcpyOptionsX_XX.Init` type aliases for the options types.
270294

271-
Set `ScrcpyOptionsX_XX#clipboard` to `undefined` if it's disabled by options, and allows `ScrcpyOptionsX_XX#clipboard#cancel` to ignore future messages.
295+
### Rename `AndroidKeyEventMeta` values
296+
297+
Addition to the [enum-to-object conversion](#remove-typescript-enums-and-namespaces), the `AndroidKeyEventMeta` enum also have its value names changed:
298+
299+
<table style={{display:'table',width:'100%', tableLayout:'fixed'}}>
300+
<thead>
301+
<tr>
302+
<td>0.0.24</td>
303+
<td>1.0.0</td>
304+
</tr>
305+
</thead>
306+
<tbody>
307+
<tr>
308+
<td>
309+
310+
```ts
311+
const message: Uint8Array = serializer.injectKeyCode({
312+
action: AndroidKeyEventAction.Down,
313+
keyCode: AndroidKeyCode.KeyA,
314+
repeat: 0,
315+
metaState: AndroidKeyEventMeta.ShiftOn,
316+
});
317+
```
318+
319+
</td>
320+
<td>
321+
322+
```ts
323+
const message: Uint8Array = serializer.injectKeyCode({
324+
action: AndroidKeyEventAction.Down,
325+
keyCode: AndroidKeyCode.KeyA,
326+
repeat: 0,
327+
metaState: AndroidKeyEventMeta.Shift,
328+
});
329+
```
330+
331+
</td>
332+
</tr>
333+
</tbody>
334+
</table>
335+
336+
### Improve clipboard stream
337+
338+
Set `ScrcpyOptionsX_XX.prototype.clipboard` to `undefined` when it's disabled by options.
272339

273340
```ts showLineNumbers
274341
const options = new ScrcpyOptions3_0({
@@ -284,12 +351,20 @@ const options = new ScrcpyOptions3_0({
284351
options.clipboard; // undefined
285352
```
286353

354+
`ScrcpyOptionsX_XX.prototype.clipboard.cancel` now correctly ignores future messages.
355+
287356
```ts showLineNumbers
288357
const options = new ScrcpyOptions3_0();
289358
await options.clipboard.cancel();
290359
```
291360

292-
Support Scrcpy UHID messages via `ScrcpyOptionsX_XX#uHidOutput` (from v2.4), `ScrcpyControlMessageSerializer#uHidCreate` (from v2.4), `ScrcpyControlMessageSerializer#uHidInput` (from v2.4) and `ScrcpyControlMessageSerializer#uHidDestroy` (from v2.7).
361+
### Add basic UHID support
362+
363+
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).
364+
365+
A better integration is coming soon.
366+
367+
### Add support for Scrcpy 3.0
293368

294369
Support all new [options](../scrcpy/versions.mdx) up to Scrcpy 3.0.
295370

@@ -299,30 +374,50 @@ Support [rendering to `OffscreenCanvas`](../scrcpy/video/tiny-h264.mdx#create-a-
299374

300375
## `@yume-chan/scrcpy-decoder-webcodecs`
301376

302-
Added multiple [rendering modes](../scrcpy/video/web-codecs.mdx#renderer) and [rendering to `OffscreenCanvas`](../scrcpy/video/web-codecs.mdx#create-a-decoder).
377+
### Add multiple renderers
378+
379+
There are multiple ways to render WebCodecs video frames. Now the package ships with [several renderers](../scrcpy/video/web-codecs.mdx#renderer), and you need to create a renderer before creating a decoder.
380+
381+
For canvas-based renderers, [rendering to `OffscreenCanvas`](../scrcpy/video/web-codecs.mdx#create-a-decoder) is now also supported.
382+
383+
### Fix rendering H.265 in Microsoft Edge
303384

304-
Fixed rendering H.265 videos having incorrect size on Microsoft Edge on Windows.
385+
Fixed rendering H.265 videos having incorrect size in Microsoft Edge on Windows.
305386

306387
## `@yume-chan/stream-extra`
307388

308-
Added `BufferedReadableStream#iterateExactly` which returns raw chunks until the requested size is reached (while `BufferedReadableStream#readExactly` combines the chunks into one `Uint8Array`). This allows incremental processing and more granular control.
389+
### Add `BufferedReadableStream.prototype.iterateExactly`
390+
391+
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.
392+
393+
### Workaround a ESBuild bug
309394

310395
Changed the coding style to workaround [evanw/esbuild#3923](https://github.com/evanw/esbuild/issues/3923). This should allow using in Vite without `optimizeDeps.exclude` option.
311396

397+
### Simplify `PushReadableStream` usage
398+
312399
`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.
313400

314-
Automatically polyfill [`ReadableStream.from`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static), [`ReadableStream.prototype[Symbol.asyncIterator]` and `ReadableStream#values`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#async_iteration) when necessary.
401+
### Polyfill `ReadableStream.from` and `ReadableStream.prototype[Symbol.asyncIterator]`
402+
403+
Automatically polyfill [`ReadableStream.from`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static), [`ReadableStream.prototype[Symbol.asyncIterator]` and `ReadableStream.prototype.values`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#async_iteration) when necessary.
315404

316405
## `@yume-chan/struct`
317406

407+
### Whole package rewrite
408+
318409
The whole package has been mostly rewritten:
319410

320-
- `SyncPromise` has been replaced with `bipedal` to support running async functions synchronously if possible.
411+
- `SyncPromise` has been replaced with `bipedal` to support running async functions synchronously when possible.
321412
- `new Struct` has been replaced with `struct` method.
322413
- Fluent style API has been replaced by individual field type methods for easier extension and better tree-shaking.
323414

324415
The new API is inspired by [TypeGPU](https://docs.swmansion.com/TypeGPU/) and [gensync](https://github.com/loganfsmyth/gensync). Check [README](https://www.npmjs.com/package/@yume-chan/struct/v/1.0.0) for documentation.
325416

417+
### Remove `ValueOrPromise`
418+
326419
The exported type `ValueOrPromise` has been moved to `@yume-chan/async` and renamed to `MaybePromiseLike`.
327420

421+
### Rename `EMPTY_UINT8_ARRAY`
422+
328423
The exported value `EMPTY_UINT8_ARRAY` has been renamed to `EmptyUint8Array`. We will use `PascalCase` for constants in the future.

0 commit comments

Comments
 (0)