@yume-chan/adb 0.0.19 → 0.0.21
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 +57 -0
- package/CHANGELOG.md +26 -1
- package/README.md +222 -103
- package/esm/adb.d.ts +28 -45
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +34 -213
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +17 -0
- package/esm/banner.d.ts.map +1 -0
- package/esm/banner.js +67 -0
- package/esm/banner.js.map +1 -0
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +9 -0
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +27 -3
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/power.d.ts +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +2 -2
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +17 -18
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +53 -48
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +1 -1
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +15 -13
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +3 -8
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +16 -16
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +3 -9
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +63 -57
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +1 -2
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.js +2 -2
- package/esm/commands/sync/push.d.ts +14 -3
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +9 -9
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.js +2 -2
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +5 -3
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +7 -5
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +8 -14
- package/esm/commands/sync/socket.d.ts.map +1 -1
- package/esm/commands/sync/socket.js +35 -32
- package/esm/commands/sync/socket.js.map +1 -1
- package/esm/commands/sync/stat.js +4 -4
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +26 -18
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +36 -25
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +2 -2
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +4 -2
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/{auth.d.ts → daemon/auth.d.ts} +12 -11
- package/esm/daemon/auth.d.ts.map +1 -0
- package/esm/{auth.js → daemon/auth.js} +31 -22
- package/esm/daemon/auth.js.map +1 -0
- package/esm/{crypto.d.ts → daemon/crypto.d.ts} +5 -5
- package/esm/daemon/crypto.d.ts.map +1 -0
- package/esm/{crypto.js → daemon/crypto.js} +24 -28
- package/esm/daemon/crypto.js.map +1 -0
- package/esm/{backend.d.ts → daemon/device.d.ts} +2 -2
- package/esm/daemon/device.d.ts.map +1 -0
- package/esm/daemon/device.js +2 -0
- package/esm/daemon/device.js.map +1 -0
- package/esm/{socket → daemon}/dispatcher.d.ts +12 -30
- package/esm/daemon/dispatcher.d.ts.map +1 -0
- package/esm/{socket → daemon}/dispatcher.js +80 -78
- package/esm/daemon/dispatcher.js.map +1 -0
- package/esm/daemon/index.d.ts +8 -0
- package/esm/daemon/index.d.ts.map +1 -0
- package/esm/daemon/index.js +8 -0
- package/esm/daemon/index.js.map +1 -0
- package/esm/{packet.d.ts → daemon/packet.d.ts} +4 -4
- package/esm/daemon/packet.d.ts.map +1 -0
- package/esm/{packet.js → daemon/packet.js} +2 -2
- package/esm/{packet.js.map → daemon/packet.js.map} +1 -1
- package/esm/{socket → daemon}/socket.d.ts +15 -19
- package/esm/daemon/socket.d.ts.map +1 -0
- package/esm/{socket → daemon}/socket.js +49 -42
- package/esm/daemon/socket.js.map +1 -0
- package/esm/daemon/transport.d.ts +53 -0
- package/esm/daemon/transport.d.ts.map +1 -0
- package/esm/daemon/transport.js +186 -0
- package/esm/daemon/transport.js.map +1 -0
- package/esm/features.js +1 -1
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +3 -5
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -5
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +78 -0
- package/esm/server/client.d.ts.map +1 -0
- package/esm/server/client.js +328 -0
- package/esm/server/client.js.map +1 -0
- package/esm/server/index.d.ts +3 -0
- package/esm/server/index.d.ts.map +1 -0
- package/esm/server/index.js +3 -0
- package/esm/server/index.js.map +1 -0
- package/esm/server/transport.d.ts +19 -0
- package/esm/server/transport.d.ts.map +1 -0
- package/esm/server/transport.js +44 -0
- package/esm/server/transport.js.map +1 -0
- package/esm/utils/auto-reset-event.d.ts +1 -2
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +12 -12
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.js +5 -5
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +1 -2
- package/esm/utils/conditional-variable.d.ts.map +1 -1
- package/esm/utils/conditional-variable.js +10 -10
- package/esm/utils/conditional-variable.js.map +1 -1
- package/esm/utils/hex.d.ts +3 -0
- package/esm/utils/hex.d.ts.map +1 -0
- package/esm/utils/hex.js +55 -0
- package/esm/utils/hex.js.map +1 -0
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +2 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/no-op.d.ts +7 -0
- package/esm/utils/no-op.d.ts.map +1 -0
- package/esm/utils/no-op.js +12 -0
- package/esm/utils/no-op.js.map +1 -0
- package/package.json +12 -12
- package/src/adb.ts +75 -274
- package/src/banner.ts +82 -0
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +31 -3
- package/src/commands/power.ts +10 -10
- package/src/commands/reverse.ts +77 -82
- package/src/commands/subprocess/command.ts +24 -25
- package/src/commands/subprocess/protocols/none.ts +29 -30
- package/src/commands/subprocess/protocols/shell.ts +87 -89
- package/src/commands/subprocess/protocols/types.ts +1 -2
- package/src/commands/sync/list.ts +7 -7
- package/src/commands/sync/pull.ts +4 -4
- package/src/commands/sync/push.ts +28 -16
- package/src/commands/sync/request.ts +4 -4
- package/src/commands/sync/response.ts +13 -11
- package/src/commands/sync/socket.ts +48 -46
- package/src/commands/sync/stat.ts +5 -5
- package/src/commands/sync/sync.ts +55 -43
- package/src/commands/tcpip.ts +6 -4
- package/src/{auth.ts → daemon/auth.ts} +62 -43
- package/src/{crypto.ts → daemon/crypto.ts} +33 -41
- package/src/{backend.ts → daemon/device.ts} +1 -1
- package/src/{socket → daemon}/dispatcher.ts +103 -109
- package/src/daemon/index.ts +7 -0
- package/src/{packet.ts → daemon/packet.ts} +6 -6
- package/src/{socket → daemon}/socket.ts +77 -67
- package/src/daemon/transport.ts +281 -0
- package/src/index.ts +3 -5
- package/src/server/client.ts +473 -0
- package/src/server/index.ts +2 -0
- package/src/server/transport.ts +77 -0
- package/src/utils/auto-reset-event.ts +16 -16
- package/src/utils/base64.ts +5 -5
- package/src/utils/conditional-variable.ts +14 -14
- package/src/utils/hex.ts +58 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/no-op.ts +12 -0
- package/tsconfig.build.json +12 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/auth.d.ts.map +0 -1
- package/esm/auth.js.map +0 -1
- package/esm/backend.d.ts.map +0 -1
- package/esm/backend.js +0 -2
- package/esm/backend.js.map +0 -1
- package/esm/commands/install.d.ts +0 -10
- package/esm/commands/install.d.ts.map +0 -1
- package/esm/commands/install.js +0 -29
- package/esm/commands/install.js.map +0 -1
- package/esm/crypto.d.ts.map +0 -1
- package/esm/crypto.js.map +0 -1
- package/esm/packet.d.ts.map +0 -1
- package/esm/socket/dispatcher.d.ts.map +0 -1
- package/esm/socket/dispatcher.js.map +0 -1
- package/esm/socket/index.d.ts +0 -3
- package/esm/socket/index.d.ts.map +0 -1
- package/esm/socket/index.js +0 -3
- package/esm/socket/index.js.map +0 -1
- package/esm/socket/socket.d.ts.map +0 -1
- package/esm/socket/socket.js.map +0 -1
- package/src/socket/index.ts +0 -2
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.0.21",
|
|
6
|
+
"tag": "@yume-chan/adb_v0.0.21",
|
|
7
|
+
"date": "Fri, 25 Aug 2023 14:05:18 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Change `AdbSync` to throws `AdbSyncError` for errors returned by ADB Daemon"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "Add name for public keys"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"comment": "Add typed errors for `framebuffer` command when current app disables screen capture"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"comment": "Change `AdbDaemonTransport` class to automatically close the connection, unless the new `preserveConnection` option is `true`"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"comment": "Add `recursive` and `force` options to `rm` method, allow deleting folders"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"version": "0.0.20",
|
|
30
|
+
"tag": "@yume-chan/adb_v0.0.20",
|
|
31
|
+
"date": "Mon, 05 Jun 2023 02:51:41 GMT",
|
|
32
|
+
"comments": {
|
|
33
|
+
"none": [
|
|
34
|
+
{
|
|
35
|
+
"comment": "Use ECMAScript private class fields syntax (supported by Chrome 74, Firefox 90, Safari 14.1 and Node.js 12.0.0)."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"comment": "Refactor `AdbSubprocessShellProtocol` class, this should improve some performance."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"comment": "Split `mode` parameter in `AdbSync#write()` into `type` and `permission` for ease of use."
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"comment": "Add `AdbReverseCommand#addExternal()`. This only register the reverse tunnel to the device, the handler should already exists (for example you are adding a reverse tunnel for an external program that's already listening on the port). In ADB direct connection, this should do nothing, because the reverse tunnel is handled by this library and there is no mean of \"external\" handler."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"comment": "Change `AdbTcpIpCommand#setPort` and `AdbTcpIpCommand#disable` to return or throw the response text. This can be displayed to the user to know what's wrong."
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"comment": "Add support for connecting to ADB servers. Because a USB device can only be used by one process at a time, the ADB server is the process that manages all connected devices. The server proxies and multiplexes connections from ADB clients so multiple adb commands can be executed on one device at the same time. The `Adb` class is no longer responsible for connecting and authenticating with ADB daemons. The `AdbTransport` interface and its two implementations `AdbDaemonTransport` and `AdbServerTransport` was added to connect to either ADB daemons or servers in compatible environments. Read the PR for details, migration paths, and examples. ([#549](https://github.com/yume-chan/ya-webadb/pull/549))"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"comment": "Add `serial` field to `Adb` class."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"comment": "Group `product`, `model`, `device` and `features` fields on `Adb` class to the `banner` field with type of `AdbBanner`."
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
4
61
|
{
|
|
5
62
|
"version": "0.0.19",
|
|
6
63
|
"tag": "@yume-chan/adb_v0.0.19",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
# Change Log - @yume-chan/adb
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 25 Aug 2023 14:05:18 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.0.21
|
|
6
|
+
Fri, 25 Aug 2023 14:05:18 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Change `AdbSync` to throws `AdbSyncError` for errors returned by ADB Daemon
|
|
11
|
+
- Add name for public keys
|
|
12
|
+
- Add typed errors for `framebuffer` command when current app disables screen capture
|
|
13
|
+
- Change `AdbDaemonTransport` class to automatically close the connection, unless the new `preserveConnection` option is `true`
|
|
14
|
+
- Add `recursive` and `force` options to `rm` method, allow deleting folders
|
|
15
|
+
|
|
16
|
+
## 0.0.20
|
|
17
|
+
Mon, 05 Jun 2023 02:51:41 GMT
|
|
18
|
+
|
|
19
|
+
### Updates
|
|
20
|
+
|
|
21
|
+
- Use ECMAScript private class fields syntax (supported by Chrome 74, Firefox 90, Safari 14.1 and Node.js 12.0.0).
|
|
22
|
+
- Refactor `AdbSubprocessShellProtocol` class, this should improve some performance.
|
|
23
|
+
- Split `mode` parameter in `AdbSync#write()` into `type` and `permission` for ease of use.
|
|
24
|
+
- Add `AdbReverseCommand#addExternal()`. This only register the reverse tunnel to the device, the handler should already exists (for example you are adding a reverse tunnel for an external program that's already listening on the port). In ADB direct connection, this should do nothing, because the reverse tunnel is handled by this library and there is no mean of "external" handler.
|
|
25
|
+
- Change `AdbTcpIpCommand#setPort` and `AdbTcpIpCommand#disable` to return or throw the response text. This can be displayed to the user to know what's wrong.
|
|
26
|
+
- Add support for connecting to ADB servers. Because a USB device can only be used by one process at a time, the ADB server is the process that manages all connected devices. The server proxies and multiplexes connections from ADB clients so multiple adb commands can be executed on one device at the same time. The `Adb` class is no longer responsible for connecting and authenticating with ADB daemons. The `AdbTransport` interface and its two implementations `AdbDaemonTransport` and `AdbServerTransport` was added to connect to either ADB daemons or servers in compatible environments. Read the PR for details, migration paths, and examples. ([#549](https://github.com/yume-chan/ya-webadb/pull/549))
|
|
27
|
+
- Add `serial` field to `Adb` class.
|
|
28
|
+
- Group `product`, `model`, `device` and `features` fields on `Adb` class to the `banner` field with type of `AdbBanner`.
|
|
4
29
|
|
|
5
30
|
## 0.0.19
|
|
6
31
|
Sun, 09 Apr 2023 05:55:33 GMT
|
package/README.md
CHANGED
|
@@ -2,39 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript implementation of Android Debug Bridge (ADB) protocol.
|
|
4
4
|
|
|
5
|
-
**WARNING:** The public API is UNSTABLE.
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
5
|
+
**WARNING:** The public API is UNSTABLE. Open a GitHub discussion if you have any questions.
|
|
6
|
+
|
|
7
|
+
- [Compatibility](#compatibility)
|
|
8
|
+
- [Basic usage](#basic-usage)
|
|
9
|
+
- [Use without bundlers](#use-without-bundlers)
|
|
10
|
+
- [Transport](#transport)
|
|
11
|
+
- [`AdbDaemonTransport`](#adbdaemontransport)
|
|
12
|
+
- [`AdbCredentialStore`](#adbcredentialstore)
|
|
13
|
+
- [`generateKey`](#generatekey)
|
|
14
|
+
- [`iterateKeys`](#iteratekeys)
|
|
15
|
+
- [`AdbAuthenticator`](#adbauthenticator)
|
|
16
|
+
- [`authenticate`](#authenticate)
|
|
17
|
+
- [`addReverseTunnel`](#addreversetunnel)
|
|
18
|
+
- [`AdbServerTransport`](#adbservertransport)
|
|
19
|
+
- [`AdbServerClient`](#adbserverclient)
|
|
20
|
+
- [`getVersion`](#getversion)
|
|
21
|
+
- [`kill`](#kill)
|
|
22
|
+
- [`getServerFeatures`](#getserverfeatures)
|
|
23
|
+
- [`getDevices`](#getdevices)
|
|
24
|
+
- [`AdbServerDeviceSelector`](#adbserverdeviceselector)
|
|
25
|
+
- [`getDeviceFeatures`](#getdevicefeatures)
|
|
26
|
+
- [`waitFor`](#waitfor)
|
|
27
|
+
- [Commands](#commands)
|
|
28
|
+
- [subprocess](#subprocess)
|
|
29
|
+
- [raw mode](#raw-mode)
|
|
30
|
+
- [pty mode](#pty-mode)
|
|
31
|
+
- [usb](#usb)
|
|
32
|
+
- [tcpip](#tcpip)
|
|
33
|
+
- [sync](#sync)
|
|
34
|
+
- [`lstat`](#lstat)
|
|
35
|
+
- [`stat`](#stat)
|
|
36
|
+
- [`isDirectory`](#isdirectory)
|
|
37
|
+
- [`opendir`](#opendir)
|
|
38
|
+
- [`readdir`](#readdir)
|
|
39
|
+
- [Useful links](#useful-links)
|
|
38
40
|
|
|
39
41
|
## Compatibility
|
|
40
42
|
|
|
@@ -42,52 +44,56 @@ Here is a list of features, their used APIs, and their compatibilities. If an op
|
|
|
42
44
|
|
|
43
45
|
Some features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.
|
|
44
46
|
|
|
45
|
-
Each
|
|
47
|
+
Each transport and connection may have different requirements.
|
|
46
48
|
|
|
47
49
|
### Basic usage
|
|
48
50
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
| `@yume-chan/struct`<sup>1</sup>
|
|
52
|
-
|
|
|
51
|
+
| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
|
|
52
|
+
| -------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |
|
|
53
|
+
| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |
|
|
54
|
+
| Private class fields<sup>3</sup> | 74 | 79 | 90 | No | 14.1 | 12.0.0 |
|
|
55
|
+
| _Overall_ | 74 | 79 | 90 | No | 14.1 | 16.5 |
|
|
53
56
|
|
|
54
57
|
<sup>1</sup> `uint64` and `string` are used.
|
|
55
58
|
|
|
56
59
|
<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.
|
|
57
60
|
|
|
61
|
+
<sup>3</sup> Can be down-level compiled using Babel.
|
|
62
|
+
|
|
58
63
|
### Use without bundlers
|
|
59
64
|
|
|
60
65
|
| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
|
|
61
66
|
| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |
|
|
62
67
|
| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |
|
|
63
68
|
|
|
64
|
-
##
|
|
69
|
+
## Transport
|
|
65
70
|
|
|
66
71
|
This library doesn't tie to a specific transportation method.
|
|
67
72
|
|
|
68
|
-
Instead,
|
|
73
|
+
Instead, an implementation of the `AdbTransport` interface is responsible for creating ADB sockets when requested. Each implementation might have different methods to discover, connect and authenticate devices.
|
|
69
74
|
|
|
70
|
-
###
|
|
75
|
+
### `AdbDaemonTransport`
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
`AdbDaemonTransport` connects to an ADB daemon directly.
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
connect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>
|
|
76
|
-
```
|
|
79
|
+
It requires a `ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>` to send and receive ADB packets to the daemon.
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
Usually an implementation of `AdbDaemonConnection` will provide that along with other useful information about the device. Possible implementations includes:
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
- WebUSB API
|
|
84
|
+
- `usb` package for Node.js
|
|
85
|
+
- Node.js' `net` module (for ADB over WiFi)
|
|
86
|
+
- Though a WebSockify wrapper (also for ADB over WiFi).
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
ADB daemon requires authentication unless built in debug mode. For how ADB authentication work, see https://chensi.moe/blog/2020/09/30/webadb-part2-connection/#auth.
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
Authentication requires two extra components:
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
#### `AdbCredentialStore`
|
|
87
93
|
|
|
88
|
-
|
|
94
|
+
An interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do that)
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
The `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and IndexedDB for storing keys.
|
|
91
97
|
|
|
92
98
|
##### `generateKey`
|
|
93
99
|
|
|
@@ -109,48 +115,128 @@ Synchronously or asynchronously iterate through all stored RSA private keys.
|
|
|
109
115
|
|
|
110
116
|
Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
|
|
111
117
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
The `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.
|
|
115
|
-
|
|
116
|
-
#### AdbAuthenticator
|
|
118
|
+
#### `AdbAuthenticator`
|
|
117
119
|
|
|
118
120
|
An `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from server.
|
|
119
121
|
|
|
120
|
-
This package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator
|
|
122
|
+
This package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator` classes for the two basic modes, they all uses the `AdbCredentialStore` to get the private key.
|
|
121
123
|
|
|
122
124
|
#### `authenticate`
|
|
123
125
|
|
|
124
126
|
```ts
|
|
125
|
-
static async authenticate(
|
|
127
|
+
static async authenticate(options: {
|
|
126
128
|
connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,
|
|
127
129
|
credentialStore: AdbCredentialStore,
|
|
128
|
-
authenticators
|
|
129
|
-
): Promise<
|
|
130
|
+
authenticators?: AdbAuthenticator[],
|
|
131
|
+
}): Promise<AdbDaemonTransport>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Authenticates the connection and creates an `AdbDaemonTransport` instance that can be used by `Adb` class.
|
|
135
|
+
|
|
136
|
+
If an authentication process failed, it's possible to call `authenticate` again on the same connection. Because every time the device receives a `CNXN` packet, it resets all internal state, and starts a new authentication process.
|
|
137
|
+
|
|
138
|
+
#### `addReverseTunnel`
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
public addReverseTunnel(
|
|
142
|
+
handler: AdbIncomingSocketHandler,
|
|
143
|
+
address?: string
|
|
144
|
+
): string
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Adds a reverse tunnel handler to the transport. It doesn't register the reverse tunnel to the device, for that use `AdbReverseCommand#add` instead. Because the process for ADB to create a tunnel is same as calling a command, `address` can be any string that the ADB daemon might call as a command.
|
|
148
|
+
|
|
149
|
+
### `AdbServerTransport`
|
|
150
|
+
|
|
151
|
+
`AdbServerTransport` connects to an ADB server. Because a USB device can only be used by one process at a time, the ADB server is the process that manages all connected devices. The server proxies and multiplexes connections from ADB clients so multiple adb commands can be executed on one device at the same time. `AdbServerTransport` instances can be retrieved from `AdbServerClient` class.
|
|
152
|
+
|
|
153
|
+
#### `AdbServerClient`
|
|
154
|
+
|
|
155
|
+
The `AdbServerClient` class implements the client-server protocol to interact with the ADB server. It can query the list of connected devices, detect device connections and disconnections, and invoke other server commands.
|
|
156
|
+
|
|
157
|
+
It needs an implementation of `AdbServerConnection` interface to actually connects to the ADB server using each runtime's API.
|
|
158
|
+
|
|
159
|
+
##### `getVersion`
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
public async getVersion(): Promise<string>;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Get the version number of the ADB server. This version is not related to the ADB server-daemon protocol version nor device Android version, it increases when a breaking change is introduced into the client-server protocol.
|
|
166
|
+
|
|
167
|
+
##### `kill`
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
public async kill(): Promise<void>;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Kill the ADB server, for example if you want to connect to the ADB daemon directly over USB.
|
|
174
|
+
|
|
175
|
+
##### `getServerFeatures`
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
public async getServerFeatures(): Promise<AdbFeature[]>;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Get the list of ADB features supported by the server.
|
|
182
|
+
|
|
183
|
+
Generally it's not that useful because most ADB commands only cares about what features the device supports.
|
|
184
|
+
|
|
185
|
+
##### `getDevices`
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
public async getDevices(): Promise<AdbServerTransport[]>;
|
|
130
189
|
```
|
|
131
190
|
|
|
132
|
-
|
|
191
|
+
Get the list of connected devices.
|
|
192
|
+
|
|
193
|
+
The returned `AdbServerTransport` instance can be supplied to `new Adb` to operate on that device.
|
|
194
|
+
|
|
195
|
+
##### `AdbServerDeviceSelector`
|
|
196
|
+
|
|
197
|
+
Some commands target a specific device. `AdbServerDeviceSelector` chooses a device from the list of connected devices.
|
|
198
|
+
|
|
199
|
+
It can be one of:
|
|
200
|
+
|
|
201
|
+
- `undefined`: any one device, will throw an error if there are multiple devices connected. Same as no argument are given to `adb` command.
|
|
202
|
+
- `{ serial: string }`: a device with the given serial number. Note that multiple devices can have the same serial number (if the manufacturer is lazy), usually it's enough to identify a device. Same as the `-s` argument for the `adb` command.
|
|
203
|
+
- `{ transportId: number }`: a device with the given transport ID. The transport ID is from the order devices connect. It can be obtained from `getDevices` method. Same as the `-t` argument for the `adb` command.
|
|
204
|
+
- `{ usb: true }`: any one USB device, will throw an error if there are multiple devices connected via USB. Same as the `-d` argument for the `adb` command.
|
|
205
|
+
- `{ emulator: true }`: any one TCP device (including emulators and devices connected via ADB over WiFi), will throw an error if there are multiple TCP devices. Same as the `-e` argument for the `adb` command. Same as the `-e` argument for the `adb` command.
|
|
206
|
+
|
|
207
|
+
The selector will be sent to ADB server and resolved there.
|
|
208
|
+
|
|
209
|
+
##### `getDeviceFeatures`
|
|
133
210
|
|
|
134
|
-
|
|
211
|
+
```ts
|
|
212
|
+
public async getDeviceFeatures(
|
|
213
|
+
device: AdbServerDeviceSelector
|
|
214
|
+
): Promise<AdbFeature[]>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Gets the list of ADB features supported by the device. `Adb` class requires this information to choose the correct commands to use.
|
|
135
218
|
|
|
136
|
-
|
|
219
|
+
##### `waitFor`
|
|
137
220
|
|
|
138
|
-
|
|
221
|
+
```ts
|
|
222
|
+
public async waitFor(
|
|
223
|
+
device: AdbServerDeviceSelector,
|
|
224
|
+
state: "device" | "disconnect",
|
|
225
|
+
signal?: AbortSignal
|
|
226
|
+
): Promise<void>
|
|
227
|
+
```
|
|
139
228
|
|
|
140
|
-
|
|
141
|
-
2. Server responds with `OKAY` or `FAIL`.
|
|
142
|
-
3. Client and server read/write on the stream.
|
|
143
|
-
4. Client/server sends a `CLSE` to close the stream.
|
|
229
|
+
Wait for a specific device to be connected or disconnected. The `AdbServerTransport` instance uses this method to detect device disconnects.
|
|
144
230
|
|
|
145
231
|
## Commands
|
|
146
232
|
|
|
147
233
|
### subprocess
|
|
148
234
|
|
|
149
|
-
ADB has two subprocess invocation modes and two data protocols (4 combinations).
|
|
235
|
+
ADB has two subprocess invocation modes and two data protocols (4 combinations). The Shell protocol was added in Android 8 and can be identified by the `shell_v2` feature flag.
|
|
150
236
|
|
|
151
237
|
#### raw mode
|
|
152
238
|
|
|
153
|
-
In raw mode, Shell protocol transfers `stdout` and `stderr` separately
|
|
239
|
+
In raw mode, Shell protocol transfers `stdout` and `stderr` separately, and supports returning exit code.
|
|
154
240
|
|
|
155
241
|
| | Legacy protocol | Shell Protocol |
|
|
156
242
|
| --------------------------- | --------------------------- | ---------------------------- |
|
|
@@ -163,13 +249,15 @@ Use `spawn` method to create a subprocess in raw mode.
|
|
|
163
249
|
|
|
164
250
|
#### pty mode
|
|
165
251
|
|
|
166
|
-
In 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.
|
|
252
|
+
In 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 and returning the exit code.
|
|
167
253
|
|
|
168
254
|
| | Legacy protocol | Shell Protocol |
|
|
169
255
|
| --------------------------- | --------------------------- | ---------------------------- |
|
|
170
256
|
| Feature flag | - | `shell_v2` |
|
|
171
257
|
| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
|
|
172
258
|
| Resizing window | No | Yes |
|
|
259
|
+
| Splitting stdout and stderr | No | No |
|
|
260
|
+
| Returning exit code | No | Yes |
|
|
173
261
|
|
|
174
262
|
Use `shell` method to create a subprocess in PTY mode.
|
|
175
263
|
|
|
@@ -183,65 +271,96 @@ Enable ADB over WiFi.
|
|
|
183
271
|
|
|
184
272
|
### sync
|
|
185
273
|
|
|
186
|
-
|
|
274
|
+
Sync protocol is a sub-protocol of the server-daemon protocol, it allows interacting with the device's filesystem.
|
|
187
275
|
|
|
188
|
-
|
|
276
|
+
```ts
|
|
277
|
+
public async sync(): Promise<AdbSync>;
|
|
278
|
+
```
|
|
189
279
|
|
|
190
|
-
|
|
280
|
+
Creates an `AdbSync` client. The client can send multiple command in sequence, and multiple clients can be created to send commands in parallel.
|
|
191
281
|
|
|
192
|
-
####
|
|
282
|
+
#### `lstat`
|
|
193
283
|
|
|
194
|
-
|
|
284
|
+
```ts
|
|
285
|
+
public async lstat(path: string): Promise<AdbSyncStat>;
|
|
286
|
+
```
|
|
195
287
|
|
|
196
|
-
|
|
288
|
+
Gets the information of a file or folder. If `path` points to a symbolic link, the returned information is about the link itself.
|
|
197
289
|
|
|
198
|
-
|
|
290
|
+
This uses the `STAT` or `LST2` (when supported) sync commands, notice that despite the name of `STAT`, it doesn't resolve symbolic links.
|
|
199
291
|
|
|
200
|
-
|
|
292
|
+
Same as the [`lstat`](https://linux.die.net/man/2/lstat) system call in Linux.
|
|
201
293
|
|
|
202
|
-
|
|
294
|
+
#### `stat`
|
|
203
295
|
|
|
204
|
-
|
|
296
|
+
```ts
|
|
297
|
+
public async stat(path: string): Promise<AdbSyncStat>;
|
|
298
|
+
```
|
|
205
299
|
|
|
206
|
-
|
|
300
|
+
Gets the information of a file or folder. If `path` points to a symbolic link, it will be resolved and the returned information is about the target.
|
|
207
301
|
|
|
208
|
-
|
|
302
|
+
Uses the `STA2` sync command, which requires the `stat_v2` feature flag. Will throw an error if device doesn't support that.
|
|
209
303
|
|
|
210
|
-
|
|
304
|
+
Same as the `stat` system call in Linux.
|
|
211
305
|
|
|
212
|
-
####
|
|
306
|
+
#### `isDirectory`
|
|
213
307
|
|
|
214
|
-
|
|
308
|
+
```ts
|
|
309
|
+
public async isDirectory(path: string): Promise<boolean>
|
|
310
|
+
```
|
|
215
311
|
|
|
216
|
-
|
|
312
|
+
Checks if `path` is a directory, or a symbolic link to a directory.
|
|
217
313
|
|
|
218
|
-
|
|
314
|
+
This uses `lstat` internally, thus works on all Android versions.
|
|
219
315
|
|
|
220
|
-
|
|
316
|
+
#### `opendir`
|
|
221
317
|
|
|
222
|
-
|
|
318
|
+
```ts
|
|
319
|
+
public opendir(path: string): AsyncGenerator<AdbSyncEntry, void, void>;
|
|
320
|
+
```
|
|
223
321
|
|
|
224
|
-
|
|
322
|
+
Returns an async generator that yields the content of a folder.
|
|
225
323
|
|
|
226
|
-
|
|
324
|
+
Example:
|
|
227
325
|
|
|
228
|
-
|
|
326
|
+
```ts
|
|
327
|
+
for await (const entry of this.opendir(path)) {
|
|
328
|
+
console.log(entry.name, entry.size);
|
|
329
|
+
}
|
|
330
|
+
```
|
|
229
331
|
|
|
230
|
-
####
|
|
332
|
+
#### `readdir`
|
|
231
333
|
|
|
232
|
-
|
|
334
|
+
```ts
|
|
335
|
+
public async readdir(path: string): Promise<AdbSyncEntry>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Collects the result of `opendir` into an array. Useful if you want to send other commands using the same `AdbSync` instance while iterating the folder.
|
|
339
|
+
|
|
340
|
+
#### `read`
|
|
233
341
|
|
|
234
|
-
|
|
342
|
+
```ts
|
|
343
|
+
public read(filename: string): ReadableStream<Uint8Array>
|
|
344
|
+
```
|
|
235
345
|
|
|
236
|
-
|
|
346
|
+
Reads the content of a file on device.
|
|
237
347
|
|
|
238
|
-
|
|
348
|
+
#### `write`
|
|
239
349
|
|
|
240
|
-
|
|
350
|
+
```ts
|
|
351
|
+
public async write(options: {
|
|
352
|
+
filename: string;
|
|
353
|
+
file: ReadableStream<Consumable<Uint8Array>>;
|
|
354
|
+
type?: LinuxFileType;
|
|
355
|
+
permission?: number;
|
|
356
|
+
mtime?: number;
|
|
357
|
+
dryRun?: boolean;
|
|
358
|
+
})
|
|
359
|
+
```
|
|
241
360
|
|
|
242
|
-
|
|
361
|
+
Writes a file on device. If the file name already exists, it will be overwritten.
|
|
243
362
|
|
|
244
363
|
## Useful links
|
|
245
364
|
|
|
246
|
-
|
|
247
|
-
|
|
365
|
+
- [ADB protocol overview](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/OVERVIEW.TXT)
|
|
366
|
+
- [ADB commands](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/SERVICES.TXT#145)
|
package/esm/adb.d.ts
CHANGED
|
@@ -1,64 +1,47 @@
|
|
|
1
1
|
import type { Consumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
+
import type { AdbBanner } from "./banner.js";
|
|
3
4
|
import type { AdbFrameBuffer } from "./commands/index.js";
|
|
4
5
|
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand } from "./commands/index.js";
|
|
5
|
-
import { AdbFeature } from "./features.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import type { AdbFeature } from "./features.js";
|
|
7
|
+
export interface AdbSocket extends ReadableWritablePair<Uint8Array, Consumable<Uint8Array>>, Closeable {
|
|
8
|
+
readonly service: string;
|
|
9
|
+
}
|
|
10
|
+
export type AdbIncomingSocketHandler = (socket: AdbSocket) => ValueOrPromise<void>;
|
|
11
|
+
export interface Closeable {
|
|
12
|
+
close(): ValueOrPromise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface AdbTransport extends Closeable {
|
|
15
|
+
readonly serial: string;
|
|
16
|
+
readonly maxPayloadSize: number;
|
|
17
|
+
readonly banner: AdbBanner;
|
|
18
|
+
readonly disconnected: Promise<void>;
|
|
19
|
+
connect(service: string): ValueOrPromise<AdbSocket>;
|
|
20
|
+
addReverseTunnel(handler: AdbIncomingSocketHandler, address?: string): ValueOrPromise<string>;
|
|
21
|
+
removeReverseTunnel(address: string): ValueOrPromise<void>;
|
|
22
|
+
clearReverseTunnels(): ValueOrPromise<void>;
|
|
13
23
|
}
|
|
14
|
-
export declare const VERSION_OMIT_CHECKSUM = 16777217;
|
|
15
24
|
export declare class Adb implements Closeable {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* every time the device receives a `CNXN` packet, it resets its internal state,
|
|
19
|
-
* and starts a new authentication process.
|
|
20
|
-
*/
|
|
21
|
-
static authenticate(connection: ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>, credentialStore: AdbCredentialStore, authenticators?: import("./auth.js").AdbAuthenticator[]): Promise<Adb>;
|
|
22
|
-
private readonly dispatcher;
|
|
23
|
-
get disconnected(): Promise<void>;
|
|
24
|
-
private _protocolVersion;
|
|
25
|
-
get protocolVersion(): number;
|
|
26
|
-
private _maxPayloadSize;
|
|
25
|
+
readonly transport: AdbTransport;
|
|
26
|
+
get serial(): string;
|
|
27
27
|
get maxPayloadSize(): number;
|
|
28
|
-
|
|
29
|
-
get
|
|
30
|
-
private _model;
|
|
31
|
-
get model(): string | undefined;
|
|
32
|
-
private _device;
|
|
33
|
-
get device(): string | undefined;
|
|
34
|
-
private _features;
|
|
35
|
-
get features(): AdbFeature[];
|
|
28
|
+
get banner(): AdbBanner;
|
|
29
|
+
get disconnected(): Promise<void>;
|
|
36
30
|
readonly subprocess: AdbSubprocess;
|
|
37
31
|
readonly power: AdbPower;
|
|
38
32
|
readonly reverse: AdbReverseCommand;
|
|
39
33
|
readonly tcpip: AdbTcpIpCommand;
|
|
40
|
-
constructor(
|
|
41
|
-
private parseBanner;
|
|
34
|
+
constructor(transport: AdbTransport);
|
|
42
35
|
supportsFeature(feature: AdbFeature): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Add a handler for incoming socket.
|
|
45
|
-
* @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
|
|
46
|
-
* @returns A function to remove the handler.
|
|
47
|
-
*/
|
|
48
|
-
onIncomingSocket(handler: AdbIncomingSocketHandler): import("@yume-chan/event").RemoveEventListener;
|
|
49
36
|
createSocket(service: string): Promise<AdbSocket>;
|
|
50
37
|
createSocketAndWait(service: string): Promise<string>;
|
|
51
38
|
getProp(key: string): Promise<string>;
|
|
52
|
-
rm(
|
|
39
|
+
rm(filenames: string | string[], options?: {
|
|
40
|
+
recursive?: boolean;
|
|
41
|
+
force?: boolean;
|
|
42
|
+
}): Promise<string>;
|
|
53
43
|
sync(): Promise<AdbSync>;
|
|
54
44
|
framebuffer(): Promise<AdbFrameBuffer>;
|
|
55
|
-
/**
|
|
56
|
-
* Close the ADB connection.
|
|
57
|
-
*
|
|
58
|
-
* Note that it won't close the streams from backends.
|
|
59
|
-
* The streams are both physically and logically intact,
|
|
60
|
-
* and can be reused.
|
|
61
|
-
*/
|
|
62
45
|
close(): Promise<void>;
|
|
63
46
|
}
|
|
64
47
|
//# sourceMappingURL=adb.d.ts.map
|