@yume-chan/adb 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +21 -0
- package/CHANGELOG.md +11 -1
- package/LICENSE +21 -21
- package/README.md +247 -247
- package/esm/adb.d.ts +7 -0
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +7 -0
- package/esm/adb.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +1 -0
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +6 -5
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +4 -1
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +11 -8
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/socket.d.ts +6 -1
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +17 -7
- package/esm/socket/socket.js.map +1 -1
- package/esm/stream/buffered.d.ts +6 -2
- package/esm/stream/buffered.d.ts.map +1 -1
- package/esm/stream/buffered.js +67 -47
- package/esm/stream/buffered.js.map +1 -1
- package/esm/stream/detect.js +1 -0
- package/esm/stream/detect.js.map +1 -1
- package/esm/stream/detect.polyfill.d.ts.map +1 -1
- package/esm/stream/detect.polyfill.js +0 -5
- package/esm/stream/detect.polyfill.js.map +1 -1
- package/esm/stream/transform.d.ts +20 -0
- package/esm/stream/transform.d.ts.map +1 -1
- package/esm/stream/transform.js +7 -1
- package/esm/stream/transform.js.map +1 -1
- package/package.json +10 -10
- package/src/adb.ts +280 -273
- package/src/auth.ts +173 -173
- package/src/backend.ts +11 -11
- package/src/commands/base.ts +11 -11
- package/src/commands/framebuffer.ts +73 -73
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +30 -30
- package/src/commands/power.ts +54 -54
- package/src/commands/reverse.ts +140 -140
- package/src/commands/subprocess/index.ts +139 -139
- package/src/commands/subprocess/protocols/none.ts +70 -68
- package/src/commands/subprocess/protocols/shell.ts +190 -190
- package/src/commands/subprocess/protocols/types.ts +59 -59
- package/src/commands/subprocess/utils.ts +20 -20
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +86 -86
- package/src/commands/sync/pull.ts +46 -46
- package/src/commands/sync/push.ts +41 -41
- package/src/commands/sync/request.ts +50 -50
- package/src/commands/sync/response.ts +64 -64
- package/src/commands/sync/stat.ts +151 -150
- package/src/commands/sync/sync.ts +181 -181
- package/src/commands/tcpip.ts +21 -21
- package/src/crypto.ts +296 -296
- package/src/features.ts +9 -9
- package/src/index.ts +11 -11
- package/src/packet.ts +80 -80
- package/src/socket/dispatcher.ts +305 -304
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +155 -144
- package/src/stream/buffered.ts +168 -147
- package/src/stream/detect.native.ts +362 -362
- package/src/stream/detect.polyfill.ts +22 -28
- package/src/stream/detect.ts +7 -5
- package/src/stream/index.ts +3 -3
- package/src/stream/transform.ts +474 -447
- package/src/utils/auto-reset-event.ts +41 -41
- package/src/utils/base64.ts +306 -306
- package/src/utils/index.ts +3 -3
- package/tsconfig.build.json +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.test.json +9 -10
- package/web-streams-polyfill-4.0.0-beta.2.tgz +0 -0
- package/esm/commands/subprocess/legacy.d.ts +0 -35
- package/esm/commands/subprocess/legacy.d.ts.map +0 -1
- package/esm/commands/subprocess/legacy.js +0 -53
- package/esm/commands/subprocess/legacy.js.map +0 -1
- package/esm/commands/subprocess/protocol.d.ts +0 -39
- package/esm/commands/subprocess/protocol.d.ts.map +0 -1
- package/esm/commands/subprocess/protocol.js +0 -157
- package/esm/commands/subprocess/protocol.js.map +0 -1
- package/esm/commands/subprocess/types.d.ts +0 -50
- package/esm/commands/subprocess/types.d.ts.map +0 -1
- package/esm/commands/subprocess/types.js +0 -2
- package/esm/commands/subprocess/types.js.map +0 -1
- package/esm/socket/controller.d.ts +0 -37
- package/esm/socket/controller.d.ts.map +0 -1
- package/esm/socket/controller.js +0 -66
- package/esm/socket/controller.js.map +0 -1
- package/esm/stream/detect.bak.d.ts +0 -240
- package/esm/stream/detect.bak.d.ts.map +0 -1
- package/esm/stream/detect.bak.js +0 -60
- package/esm/stream/detect.bak.js.map +0 -1
- package/esm/utils/encoding.d.ts +0 -3
- package/esm/utils/encoding.d.ts.map +0 -1
- package/esm/utils/encoding.js +0 -11
- package/esm/utils/encoding.js.map +0 -1
package/esm/stream/transform.js
CHANGED
|
@@ -63,6 +63,7 @@ export class DuplexStreamFactory {
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
this._writableClosed = true;
|
|
66
|
+
// Call `close` first, so it can still write data to `WritableStream`s.
|
|
66
67
|
if (await this.options.close?.() !== false) {
|
|
67
68
|
// `close` can return `false` to disable automatic `dispose`.
|
|
68
69
|
await this.dispose();
|
|
@@ -340,6 +341,11 @@ export class PushReadableStream extends ReadableStream {
|
|
|
340
341
|
source({
|
|
341
342
|
abortSignal: canceled.signal,
|
|
342
343
|
async enqueue(chunk) {
|
|
344
|
+
if (canceled.signal.aborted) {
|
|
345
|
+
// If the stream is already cancelled,
|
|
346
|
+
// throw immediately.
|
|
347
|
+
throw canceled.signal.reason ?? new Error('Aborted');
|
|
348
|
+
}
|
|
343
349
|
// Only when the stream is errored, `desiredSize` will be `null`.
|
|
344
350
|
// But since `null <= 0` is `true`
|
|
345
351
|
// (`null <= 0` is evaluated as `!(null > 0)` => `!false` => `true`),
|
|
@@ -364,7 +370,7 @@ export class PushReadableStream extends ReadableStream {
|
|
|
364
370
|
waterMarkLow?.resolve();
|
|
365
371
|
},
|
|
366
372
|
cancel: async (reason) => {
|
|
367
|
-
canceled.abort();
|
|
373
|
+
canceled.abort(reason);
|
|
368
374
|
waterMarkLow?.reject(reason);
|
|
369
375
|
},
|
|
370
376
|
}, strategy);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAe,cAAc,EAA+B,eAAe,EAAE,cAAc,EAAsH,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAe,cAAc,EAA+B,eAAe,EAAE,cAAc,EAAsH,MAAM,aAAa,CAAC;AA4B7P;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IACpB,mBAAmB,GAAyC,EAAE,CAAC;IAC/D,OAAO,GAAqC,EAAE,CAAC;IAE/C,eAAe,GAAG,KAAK,CAAC;IAChC,IAAW,cAAc,KAAK,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAEpD,OAAO,GAAG,IAAI,eAAe,EAAQ,CAAC;IAC9C,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5C,OAAO,CAA6B;IAE5C,YAAmB,OAAoC;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IACjC,CAAC;IAEM,YAAY,CAAC,QAA2B;QAC3C,OAAO,IAAI,kBAAkB,CAAI;YAC7B,KAAK,EAAE,CAAC,UAAU,EAA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,CAAC,MAAM;oBAC5B,KAAK,CAAC,OAAO,CAAC,KAAK;wBACf,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE;4BACzB,sCAAsC;4BACtC,qBAAqB;4BACrB,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;yBACxD;wBAED,iEAAiE;wBACjE,kCAAkC;wBAClC,qEAAqE;wBACrE,yCAAyC;wBACzC,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE;4BACpC,YAAY,GAAG,IAAI,eAAe,EAAQ,CAAC;4BAC3C,MAAM,YAAY,CAAC,OAAO,CAAC;yBAC9B;wBAED,+CAA+C;wBAC/C,oCAAoC;wBACpC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBAC9B,CAAC;oBACD,KAAK;wBACD,UAAU,CAAC,KAAK,EAAE,CAAC;oBACvB,CAAC;oBACD,KAAK,CAAC,CAAC;wBACH,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBACxB,CAAC;iBACJ,CAAC,CAAC;YACP,CAAC;YACD,IAAI,EAAE,GAAG,EAAE;gBACP,YAAY,EAAE,OAAO,EAAE,CAAC;YAC5B,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBACrB,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACvB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;SACJ,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"types": "esm/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@yume-chan/async": "^2.1.4",
|
|
29
|
-
"@yume-chan/dataview-bigint-polyfill": "^0.0.
|
|
30
|
-
"@yume-chan/event": "^0.0.
|
|
31
|
-
"@yume-chan/struct": "^0.0.
|
|
29
|
+
"@yume-chan/dataview-bigint-polyfill": "^0.0.16",
|
|
30
|
+
"@yume-chan/event": "^0.0.16",
|
|
31
|
+
"@yume-chan/struct": "^0.0.16",
|
|
32
32
|
"tslib": "^2.3.1",
|
|
33
|
-
"web-streams-polyfill": "^4.0.0-beta.
|
|
33
|
+
"web-streams-polyfill": "^4.0.0-beta.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@jest/globals": "^28.1.0",
|
|
36
37
|
"@types/node": "^17.0.17",
|
|
37
|
-
"@types/jest": "^27.4.1",
|
|
38
38
|
"@yume-chan/ts-package-builder": "^1.0.0",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"jest": "^
|
|
41
|
-
"ts-jest": "^
|
|
42
|
-
"typescript": "4.7.
|
|
40
|
+
"jest": "^28.1.0",
|
|
41
|
+
"ts-jest": "^28.0.2",
|
|
42
|
+
"typescript": "4.7.2"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc -b tsconfig.build.json",
|
|
46
46
|
"build:watch": "tsc -b tsconfig.build.json",
|
|
47
47
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
48
48
|
},
|
|
49
|
-
"readme": "# @yume-chan/adb\
|
|
49
|
+
"readme": "# @yume-chan/adb\n\nTypeScript implementation of Android Debug Bridge (ADB) protocol.\n\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\n\n- [Compatibility](#compatibility)\n - [Basic usage](#basic-usage)\n - [Use without bundlers](#use-without-bundlers)\n- [Connection](#connection)\n - [Backend](#backend)\n - [`connect`](#connect)\n- [Authentication](#authentication)\n - [AdbCredentialStore](#adbcredentialstore)\n - [`generateKey`](#generatekey)\n - [`iterateKeys`](#iteratekeys)\n - [Implementations](#implementations)\n - [AdbAuthenticator](#adbauthenticator)\n - [`authenticate`](#authenticate)\n- [Stream multiplex](#stream-multiplex)\n- [Commands](#commands)\n - [subprocess](#subprocess)\n - [raw mode](#raw-mode)\n - [pty mode](#pty-mode)\n - [usb](#usb)\n - [tcpip](#tcpip)\n - [sync](#sync)\n - [LIST](#list)\n - [LIS2](#lis2)\n - [STAT](#stat)\n - [LST2](#lst2)\n - [STA2](#sta2)\n - [RECV](#recv)\n - [RCV2](#rcv2)\n - [SEND](#send)\n - [SND2](#snd2)\n- [Useful links](#useful-links)\n\n## Compatibility\n\nHere is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.\n\nSome features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.\n\nEach backend may have different requirements.\n\n### Basic usage\n\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\n| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |\n| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |\n| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |\n\n<sup>1</sup> `uint64` and `string` are used.\n\n<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.\n\n### Use without bundlers\n\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\n| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |\n| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |\n\n## Connection\n\nThis library doesn't tie to a specific transportation method.\n\nInstead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).\n\n### Backend\n\n#### `connect`\n\n```ts\nconnect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>\n```\n\nConnect to a device and create a pair of `AdbPacket` streams.\n\nThe backend, instead of the core library, is responsible for serializing and deserializing the packets. Because it's extreme slow for WebUSB backend (`@yume-chan/adb-backend-webusb`) to read packets with unknown size.\n\n## Authentication\n\nFor how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/webadb-part2-connection/#auth.\n\nIn this library, authentication comes in two parts:\n\n#### AdbCredentialStore\n\nAn interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)\n\n##### `generateKey`\n\n```ts\ngenerateKey(): ValueOrPromise<Uint8Array>\n```\n\nGenerate and store a RSA private key with modulus length `2048` and public exponent `65537`.\n\nThe returned `Uint8Array` is the private key in PKCS #8 format.\n\n##### `iterateKeys`\n\n```ts\niterateKeys(): Iterator<ArrayBuffer> | AsyncIterator<ArrayBuffer>\n```\n\nSynchronously or asynchronously iterate through all stored RSA private keys.\n\nEach call to `iterateKeys` must return a different iterator that iterate through all stored keys.\n\n##### Implementations\n\nThe `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.\n\n#### AdbAuthenticator\n\nAn `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from server.\n\nThis package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.\n\n#### `authenticate`\n\n```ts\nstatic async authenticate(\n connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,\n credentialStore: AdbCredentialStore,\n authenticators = AdbDefaultAuthenticators,\n): Promise<Adb>\n```\n\nCall this method to authenticate the connection and create an `Adb` instance.\n\nIf an authentication process failed, it's possible to call `authenticate` again on the same connection (`AdbPacket` stream pair). Every time the device receives a `CNXN` packet, it resets all internal state, and starts a new authentication process.\n\n## Stream multiplex\n\nADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.\n\n1. Client sends an `OPEN` packet to create a stream.\n2. Server responds with `OKAY` or `FAIL`.\n3. Client and server read/write on the stream.\n4. Client/server sends a `CLSE` to close the stream.\n\n## Commands\n\n### subprocess\n\nADB has two subprocess invocation modes and two data protocols (4 combinations).\n\n#### raw mode\n\nIn raw mode, Shell protocol transfers `stdout` and `stderr` separately. It also supports returning exit code.\n\n| | Legacy protocol | Shell Protocol |\n| --------------------------- | --------------------------- | ---------------------------- |\n| Feature flag | - | `shell_v2` |\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\n| Splitting stdout and stderr | No | Yes |\n| Returning exit code | No | Yes |\n\nUse `spawn` method to create a subprocess in raw mode.\n\n#### pty mode\n\nIn PTY mode, the subprocess has a pseudo-terminal, so it can send special control sequences like clear screen and set cursor position. The two protocols both send data in `stdout`, but Shell Protocol also supports resizing the terminal from client.\n\n| | Legacy protocol | Shell Protocol |\n| --------------------------- | --------------------------- | ---------------------------- |\n| Feature flag | - | `shell_v2` |\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\n| Resizing window | No | Yes |\n\nUse `shell` method to create a subprocess in PTY mode.\n\n### usb\n\nDisable ADB over WiFi.\n\n### tcpip\n\nEnable ADB over WiFi.\n\n### sync\n\nClient and server will communicate with another protocol on the opened stream.\n\n#### LIST\n\nRequest server to list the content of a folder.\n\n#### LIS2\n\nVersion 2 of the LIST command, contains more information.\n\nSupported on devices with `ls_v2` feature.\n\n#### STAT\n\nRequest server to return the information of a file.\n\nIf path is a symbolic link, the returned information is about the link itself.\n\nSo it's actually the [`lstat`](https://linux.die.net/man/2/lstat) system call.\n\n#### LST2\n\nVersion 2 of the STAT command, contains more information.\n\nSupported on devices with `stat_v2` feature.\n\n#### STA2\n\nBasically identical to LST2, but if path is a symbolic link, the information is about the file it refers to.\n\nSupported on devices with `stat_v2` feature.\n\n#### RECV\n\nRequest server to send the content of a file.\n\n#### RCV2\n\n*(Not Implemented)*\n\nVersion 2 of the RECV command.\n\nSupported on devices with `sendrecv_v2` feature.\n\n#### SEND\n\n*(Not Implemented)*\n\nSend a file onto server's file system.\n\n#### SND2\n\n*(Not Implemented)*\n\nVersion 2 of the SEND command.\n\nSupported on devices with `sendrecv_v2` feature.\n\n## Useful links\n\n* [ADB protocol overview](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/OVERVIEW.TXT)\n* [ADB commands](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/SERVICES.TXT#145)\n"
|
|
50
50
|
}
|