@yume-chan/adb 0.0.0-20240714132542
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.md +178 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/esm/adb.d.ts +51 -0
- package/esm/adb.d.ts.map +1 -0
- package/esm/adb.js +86 -0
- package/esm/adb.js.map +1 -0
- package/esm/banner.d.ts +17 -0
- package/esm/banner.d.ts.map +1 -0
- package/esm/banner.js +68 -0
- package/esm/banner.js.map +1 -0
- package/esm/commands/base.d.ts +7 -0
- package/esm/commands/base.d.ts.map +1 -0
- package/esm/commands/base.js +9 -0
- package/esm/commands/base.js.map +1 -0
- package/esm/commands/framebuffer.d.ts +63 -0
- package/esm/commands/framebuffer.d.ts.map +1 -0
- package/esm/commands/framebuffer.js +71 -0
- package/esm/commands/framebuffer.js.map +1 -0
- package/esm/commands/index.d.ts +8 -0
- package/esm/commands/index.d.ts.map +1 -0
- package/esm/commands/index.js +8 -0
- package/esm/commands/index.js.map +1 -0
- package/esm/commands/power.d.ts +23 -0
- package/esm/commands/power.d.ts.map +1 -0
- package/esm/commands/power.js +50 -0
- package/esm/commands/power.js.map +1 -0
- package/esm/commands/reverse.d.ts +41 -0
- package/esm/commands/reverse.d.ts.map +1 -0
- package/esm/commands/reverse.js +143 -0
- package/esm/commands/reverse.js.map +1 -0
- package/esm/commands/subprocess/command.d.ts +58 -0
- package/esm/commands/subprocess/command.d.ts.map +1 -0
- package/esm/commands/subprocess/command.js +89 -0
- package/esm/commands/subprocess/command.js.map +1 -0
- package/esm/commands/subprocess/index.d.ts +4 -0
- package/esm/commands/subprocess/index.d.ts.map +1 -0
- package/esm/commands/subprocess/index.js +4 -0
- package/esm/commands/subprocess/index.js.map +1 -0
- package/esm/commands/subprocess/protocols/index.d.ts +4 -0
- package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/index.js +4 -0
- package/esm/commands/subprocess/protocols/index.js.map +1 -0
- package/esm/commands/subprocess/protocols/none.d.ts +32 -0
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/none.js +63 -0
- package/esm/commands/subprocess/protocols/none.js.map +1 -0
- package/esm/commands/subprocess/protocols/shell.d.ts +40 -0
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/shell.js +118 -0
- package/esm/commands/subprocess/protocols/shell.js.map +1 -0
- package/esm/commands/subprocess/protocols/types.d.ts +49 -0
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/types.js +2 -0
- package/esm/commands/subprocess/protocols/types.js.map +1 -0
- package/esm/commands/subprocess/utils.d.ts +2 -0
- package/esm/commands/subprocess/utils.d.ts.map +1 -0
- package/esm/commands/subprocess/utils.js +19 -0
- package/esm/commands/subprocess/utils.js.map +1 -0
- package/esm/commands/sync/index.d.ts +9 -0
- package/esm/commands/sync/index.d.ts.map +1 -0
- package/esm/commands/sync/index.js +9 -0
- package/esm/commands/sync/index.js.map +1 -0
- package/esm/commands/sync/list.d.ts +41 -0
- package/esm/commands/sync/list.d.ts.map +1 -0
- package/esm/commands/sync/list.js +66 -0
- package/esm/commands/sync/list.js.map +1 -0
- package/esm/commands/sync/pull.d.ts +11 -0
- package/esm/commands/sync/pull.d.ts.map +1 -0
- package/esm/commands/sync/pull.js +40 -0
- package/esm/commands/sync/pull.js.map +1 -0
- package/esm/commands/sync/push.d.ts +55 -0
- package/esm/commands/sync/push.d.ts.map +1 -0
- package/esm/commands/sync/push.js +87 -0
- package/esm/commands/sync/push.js.map +1 -0
- package/esm/commands/sync/request.d.ts +22 -0
- package/esm/commands/sync/request.d.ts.map +1 -0
- package/esm/commands/sync/request.js +36 -0
- package/esm/commands/sync/request.js.map +1 -0
- package/esm/commands/sync/response.d.ts +28 -0
- package/esm/commands/sync/response.d.ts.map +1 -0
- package/esm/commands/sync/response.js +79 -0
- package/esm/commands/sync/response.js.map +1 -0
- package/esm/commands/sync/socket.d.ts +22 -0
- package/esm/commands/sync/socket.d.ts.map +1 -0
- package/esm/commands/sync/socket.js +78 -0
- package/esm/commands/sync/socket.js.map +1 -0
- package/esm/commands/sync/stat.d.ts +70 -0
- package/esm/commands/sync/stat.d.ts.map +1 -0
- package/esm/commands/sync/stat.js +115 -0
- package/esm/commands/sync/stat.js.map +1 -0
- package/esm/commands/sync/sync.d.ts +82 -0
- package/esm/commands/sync/sync.d.ts.map +1 -0
- package/esm/commands/sync/sync.js +141 -0
- package/esm/commands/sync/sync.js.map +1 -0
- package/esm/commands/tcpip.d.ts +26 -0
- package/esm/commands/tcpip.d.ts.map +1 -0
- package/esm/commands/tcpip.js +39 -0
- package/esm/commands/tcpip.js.map +1 -0
- package/esm/daemon/auth.d.ts +53 -0
- package/esm/daemon/auth.d.ts.map +1 -0
- package/esm/daemon/auth.js +105 -0
- package/esm/daemon/auth.js.map +1 -0
- package/esm/daemon/crypto.d.ts +38 -0
- package/esm/daemon/crypto.d.ts.map +1 -0
- package/esm/daemon/crypto.js +253 -0
- package/esm/daemon/crypto.js.map +1 -0
- package/esm/daemon/device.d.ts +9 -0
- 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/daemon/dispatcher.d.ts +75 -0
- package/esm/daemon/dispatcher.d.ts.map +1 -0
- package/esm/daemon/dispatcher.js +295 -0
- 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/daemon/packet.d.ts +46 -0
- package/esm/daemon/packet.d.ts.map +1 -0
- package/esm/daemon/packet.js +45 -0
- package/esm/daemon/packet.js.map +1 -0
- package/esm/daemon/socket.d.ts +51 -0
- package/esm/daemon/socket.d.ts.map +1 -0
- package/esm/daemon/socket.js +141 -0
- package/esm/daemon/socket.js.map +1 -0
- package/esm/daemon/transport.d.ts +121 -0
- package/esm/daemon/transport.d.ts.map +1 -0
- package/esm/daemon/transport.js +215 -0
- package/esm/daemon/transport.js.map +1 -0
- package/esm/features.d.ts +12 -0
- package/esm/features.d.ts.map +1 -0
- package/esm/features.js +15 -0
- package/esm/features.js.map +1 -0
- package/esm/index.d.ts +8 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +8 -0
- package/esm/index.js.map +1 -0
- package/esm/server/client.d.ts +162 -0
- package/esm/server/client.d.ts.map +1 -0
- package/esm/server/client.js +576 -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 +22 -0
- package/esm/server/transport.d.ts.map +1 -0
- package/esm/server/transport.js +70 -0
- package/esm/server/transport.js.map +1 -0
- package/esm/utils/auto-reset-event.d.ts +9 -0
- package/esm/utils/auto-reset-event.d.ts.map +1 -0
- package/esm/utils/auto-reset-event.js +34 -0
- package/esm/utils/auto-reset-event.js.map +1 -0
- package/esm/utils/base64.d.ts +28 -0
- package/esm/utils/base64.d.ts.map +1 -0
- package/esm/utils/base64.js +258 -0
- package/esm/utils/base64.js.map +1 -0
- package/esm/utils/hex.d.ts +3 -0
- package/esm/utils/hex.d.ts.map +1 -0
- package/esm/utils/hex.js +53 -0
- package/esm/utils/hex.js.map +1 -0
- package/esm/utils/index.d.ts +7 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +7 -0
- package/esm/utils/index.js.map +1 -0
- 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/esm/utils/sequence-equal.d.ts +2 -0
- package/esm/utils/sequence-equal.d.ts.map +1 -0
- package/esm/utils/sequence-equal.js +12 -0
- package/esm/utils/sequence-equal.js.map +1 -0
- package/package.json +52 -0
- package/src/adb.ts +163 -0
- package/src/banner.ts +83 -0
- package/src/commands/base.ts +12 -0
- package/src/commands/framebuffer.ts +102 -0
- package/src/commands/index.ts +7 -0
- package/src/commands/power.ts +60 -0
- package/src/commands/reverse.ts +193 -0
- package/src/commands/subprocess/command.ts +141 -0
- package/src/commands/subprocess/index.ts +3 -0
- package/src/commands/subprocess/protocols/index.ts +3 -0
- package/src/commands/subprocess/protocols/none.ts +83 -0
- package/src/commands/subprocess/protocols/shell.ts +165 -0
- package/src/commands/subprocess/protocols/types.ts +63 -0
- package/src/commands/subprocess/utils.ts +20 -0
- package/src/commands/sync/index.ts +8 -0
- package/src/commands/sync/list.ts +102 -0
- package/src/commands/sync/pull.ts +60 -0
- package/src/commands/sync/push.ts +168 -0
- package/src/commands/sync/request.ts +54 -0
- package/src/commands/sync/response.ts +104 -0
- package/src/commands/sync/socket.ts +109 -0
- package/src/commands/sync/stat.ts +155 -0
- package/src/commands/sync/sync.ts +179 -0
- package/src/commands/tcpip.ts +67 -0
- package/src/daemon/auth.ts +202 -0
- package/src/daemon/crypto.ts +327 -0
- package/src/daemon/device.ts +14 -0
- package/src/daemon/dispatcher.ts +479 -0
- package/src/daemon/index.ts +7 -0
- package/src/daemon/packet.ts +82 -0
- package/src/daemon/socket.ts +214 -0
- package/src/daemon/transport.ts +394 -0
- package/src/features.ts +13 -0
- package/src/index.ts +7 -0
- package/src/server/client.ts +731 -0
- package/src/server/index.ts +2 -0
- package/src/server/transport.ts +105 -0
- package/src/utils/auto-reset-event.ts +40 -0
- package/src/utils/base64.ts +350 -0
- package/src/utils/hex.ts +60 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/no-op.ts +12 -0
- package/src/utils/sequence-equal.ts +13 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.build.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Change Log - @yume-chan/adb
|
|
2
|
+
|
|
3
|
+
## 0.0.0-20240714132542
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Switch to PNPM workspace and changesets
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @yume-chan/no-data-view@0.0.0-20240714132542
|
|
10
|
+
- @yume-chan/stream-extra@0.0.0-20240714132542
|
|
11
|
+
- @yume-chan/struct@0.0.0-20240714132542
|
|
12
|
+
- @yume-chan/event@0.0.0-20240714132542
|
|
13
|
+
|
|
14
|
+
This log was last generated on Tue, 18 Jun 2024 02:49:43 GMT and should not be manually modified.
|
|
15
|
+
|
|
16
|
+
## 0.0.24
|
|
17
|
+
|
|
18
|
+
Tue, 18 Jun 2024 02:49:43 GMT
|
|
19
|
+
|
|
20
|
+
### Updates
|
|
21
|
+
|
|
22
|
+
- Allow streams to accept both `Uint8Array` and `Consumable<Uint8Array>` as inputs
|
|
23
|
+
- Rename `AdbDaemonTransport`'s `debugSlowRead` option to `readTimeLimit`. Allow users to specify a custom timeout for read operations. It's still disabled by default.
|
|
24
|
+
- Include unauthorized devices in `AdbServerClient#getDevices()` and `AdbServerClient#trackDevices()`. You need to filter them out if you don't need them.
|
|
25
|
+
- Add more methods to `AdbServerClient`
|
|
26
|
+
- Group `AdbServerClient`-relating types into namespace. In future, more types will be moved to namespaces.
|
|
27
|
+
- Fix `Adb#reverse#list()` returning an extra empty object.
|
|
28
|
+
- Fix reverse tunnel handler not invoked.
|
|
29
|
+
- Fix too many event listener warning in Node.js.
|
|
30
|
+
|
|
31
|
+
## 0.0.23
|
|
32
|
+
|
|
33
|
+
Thu, 21 Mar 2024 03:15:10 GMT
|
|
34
|
+
|
|
35
|
+
### Updates
|
|
36
|
+
|
|
37
|
+
- Refactor `AdbSubprocessShellProtocol` (this shouldn't affect usage)
|
|
38
|
+
- Add `AdbServerClient.trackDevices`, which runs a callback function whenever device list changes
|
|
39
|
+
- Add support for delayed ack on Android 14
|
|
40
|
+
|
|
41
|
+
## 0.0.22
|
|
42
|
+
|
|
43
|
+
Wed, 13 Dec 2023 05:57:27 GMT
|
|
44
|
+
|
|
45
|
+
### Updates
|
|
46
|
+
|
|
47
|
+
- Add `getListenAddresses` method to `AdbTcpIpCommand` class for retrieving current ADB over WiFi state
|
|
48
|
+
- Add `debugSlowRead` option to `AdbDaemonTransport` that throws an error when an ADB socket is stalled for 5 seconds
|
|
49
|
+
- Fix `AdbSync#read` stuck when there is an error
|
|
50
|
+
- Fix TypeScript build when using `AdbSubprocessNoneProtocol` without installing `web-streams-polyfill` package
|
|
51
|
+
|
|
52
|
+
## 0.0.21
|
|
53
|
+
|
|
54
|
+
Fri, 25 Aug 2023 14:05:18 GMT
|
|
55
|
+
|
|
56
|
+
### Updates
|
|
57
|
+
|
|
58
|
+
- Change `AdbSync` to throws `AdbSyncError` for errors returned by ADB Daemon
|
|
59
|
+
- Add name for public keys
|
|
60
|
+
- Add typed errors for `framebuffer` command when current app disables screen capture
|
|
61
|
+
- Change `AdbDaemonTransport` class to automatically close the connection, unless the new `preserveConnection` option is `true`
|
|
62
|
+
- Add `recursive` and `force` options to `rm` method, allow deleting folders
|
|
63
|
+
|
|
64
|
+
## 0.0.20
|
|
65
|
+
|
|
66
|
+
Mon, 05 Jun 2023 02:51:41 GMT
|
|
67
|
+
|
|
68
|
+
### Updates
|
|
69
|
+
|
|
70
|
+
- Use ECMAScript private class fields syntax (supported by Chrome 74, Firefox 90, Safari 14.1 and Node.js 12.0.0).
|
|
71
|
+
- Refactor `AdbSubprocessShellProtocol` class, this should improve some performance.
|
|
72
|
+
- Split `mode` parameter in `AdbSync#write()` into `type` and `permission` for ease of use.
|
|
73
|
+
- 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.
|
|
74
|
+
- 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.
|
|
75
|
+
- 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))
|
|
76
|
+
- Add `serial` field to `Adb` class.
|
|
77
|
+
- Group `product`, `model`, `device` and `features` fields on `Adb` class to the `banner` field with type of `AdbBanner`.
|
|
78
|
+
|
|
79
|
+
## 0.0.19
|
|
80
|
+
|
|
81
|
+
Sun, 09 Apr 2023 05:55:33 GMT
|
|
82
|
+
|
|
83
|
+
### Updates
|
|
84
|
+
|
|
85
|
+
- Remove `Adb#install` in favor of `PackageManager#install` from `@yume-chan/android-bin` package
|
|
86
|
+
- Change `AdbSync#write` to take a `ReadableStream<Uint8Array>` instead of returning a `WritableStream<Uint8Array>`
|
|
87
|
+
- Add buffering in sync module to improve transfer speed
|
|
88
|
+
- Add `AdbReverseError` and `AdbReverseNotSupportedError` for better error handling in reverse tunnel command.
|
|
89
|
+
|
|
90
|
+
## 0.0.18
|
|
91
|
+
|
|
92
|
+
Wed, 25 Jan 2023 21:33:49 GMT
|
|
93
|
+
|
|
94
|
+
_Version update only_
|
|
95
|
+
|
|
96
|
+
## 0.0.17
|
|
97
|
+
|
|
98
|
+
Tue, 18 Oct 2022 09:32:30 GMT
|
|
99
|
+
|
|
100
|
+
### Updates
|
|
101
|
+
|
|
102
|
+
- Move stream utils to separate package
|
|
103
|
+
|
|
104
|
+
## 0.0.16
|
|
105
|
+
|
|
106
|
+
Sat, 28 May 2022 03:56:37 GMT
|
|
107
|
+
|
|
108
|
+
### Updates
|
|
109
|
+
|
|
110
|
+
- Upgrade TypeScript to 4.7.2 to enable Node.js ESM
|
|
111
|
+
- Upgrade web-streams-polyfill to 4.0.0-beta.3, fix an issue where `Adb#close()` doesn't release the connection.
|
|
112
|
+
- Fix an issue where `AdbSocket#readable#cancel()` stalls the connection.
|
|
113
|
+
- Improve performance of `BufferedStream` by up to 100%.
|
|
114
|
+
|
|
115
|
+
## 0.0.15
|
|
116
|
+
|
|
117
|
+
Mon, 02 May 2022 04:18:01 GMT
|
|
118
|
+
|
|
119
|
+
### Updates
|
|
120
|
+
|
|
121
|
+
- Add support for old protocol of `reverse:forward` command before Android 8
|
|
122
|
+
- Improve connection lifecycle handling
|
|
123
|
+
- Update `reverse.add` to accept any string local address
|
|
124
|
+
- Fix an issue where `reverse` commands doesn't parse error message correctly
|
|
125
|
+
|
|
126
|
+
## 0.0.14
|
|
127
|
+
|
|
128
|
+
Sat, 30 Apr 2022 14:05:48 GMT
|
|
129
|
+
|
|
130
|
+
### Updates
|
|
131
|
+
|
|
132
|
+
- Fix an issue where `subprocess.spawn` doesn't work on Android 6
|
|
133
|
+
- Add an `Adb#close()` method to gracefully shutdown a connection
|
|
134
|
+
|
|
135
|
+
## 0.0.13
|
|
136
|
+
|
|
137
|
+
Thu, 28 Apr 2022 01:23:53 GMT
|
|
138
|
+
|
|
139
|
+
### Updates
|
|
140
|
+
|
|
141
|
+
- Add support for raw shell mode
|
|
142
|
+
- Add support for LIS2 command in Sync protocol
|
|
143
|
+
- Add workaround for the push_mkdir issue in Android 9
|
|
144
|
+
|
|
145
|
+
## 0.0.12
|
|
146
|
+
|
|
147
|
+
Sun, 03 Apr 2022 11:18:47 GMT
|
|
148
|
+
|
|
149
|
+
_Version update only_
|
|
150
|
+
|
|
151
|
+
## 0.0.11
|
|
152
|
+
|
|
153
|
+
Sun, 03 Apr 2022 10:54:15 GMT
|
|
154
|
+
|
|
155
|
+
### Patches
|
|
156
|
+
|
|
157
|
+
- Update to use Web Streams API
|
|
158
|
+
- Improve compatibility with Node.js 12 ESM format
|
|
159
|
+
|
|
160
|
+
### Updates
|
|
161
|
+
|
|
162
|
+
- Add power related API
|
|
163
|
+
- Update compatibility matrix
|
|
164
|
+
- Update license year
|
|
165
|
+
|
|
166
|
+
## 0.0.10
|
|
167
|
+
|
|
168
|
+
Sun, 09 Jan 2022 15:52:20 GMT
|
|
169
|
+
|
|
170
|
+
### Updates
|
|
171
|
+
|
|
172
|
+
- Remove `encodeUtf8()` and `decodeUtf8()` from `AdbBackend`
|
|
173
|
+
|
|
174
|
+
## 0.0.9
|
|
175
|
+
|
|
176
|
+
Sun, 09 Jan 2022 15:50:20 GMT
|
|
177
|
+
|
|
178
|
+
_Initial release_
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2024 Simon Chan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img alt="Tango" src="https://raw.githubusercontent.com/yume-chan/ya-webadb/main/.github/logo.svg" width="200">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@yume-chan/adb</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
TypeScript implementation of Android Debug Bridge (ADB) protocol.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/yume-chan/ya-webadb/blob/main/LICENSE">
|
|
13
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/yume-chan/ya-webadb">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/yume-chan/ya-webadb/releases">
|
|
16
|
+
<img alt="GitHub release" src="https://img.shields.io/github/v/release/yume-chan/ya-webadb?logo=github">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://bundlephobia.com/package/@yume-chan/adb">
|
|
19
|
+
<img alt="Package Size" src="https://img.shields.io/bundlephobia/minzip/%40yume-chan%2Fadb">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://www.npmjs.com/package/@yume-chan/adb">
|
|
22
|
+
<img alt="npm" src="https://img.shields.io/npm/dm/%40yume-chan/adb?logo=npm">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://discord.gg/26k3ttC2PN">
|
|
25
|
+
<img alt="Discord" src="https://img.shields.io/discord/1120215514732564502?logo=discord&logoColor=%23ffffff&label=Discord">
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
This package is part of [Tango ADB](https://github.com/yume-chan/ya-webadb). Generally you need multiple packages to build a complete ADB client that can run on Web browsers and Node.js. Read the documentation for more information.
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
Check the latest documentation at https://docs.tangoapp.dev/
|
|
34
|
+
|
|
35
|
+
## Sponsors
|
|
36
|
+
|
|
37
|
+
[Become a backer](https://opencollective.com/ya-webadb) and get your image on our README on Github with a link to your site.
|
|
38
|
+
|
|
39
|
+
<a href="https://opencollective.com/ya-webadb/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/0/avatar.svg?requireActive=false"></a>
|
|
40
|
+
<a href="https://opencollective.com/ya-webadb/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/1/avatar.svg?requireActive=false"></a>
|
|
41
|
+
<a href="https://opencollective.com/ya-webadb/backer/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/2/avatar.svg?requireActive=false"></a>
|
|
42
|
+
<a href="https://opencollective.com/ya-webadb/backer/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/3/avatar.svg?requireActive=false"></a>
|
|
43
|
+
<a href="https://opencollective.com/ya-webadb/backer/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/4/avatar.svg?requireActive=false"></a>
|
|
44
|
+
<a href="https://opencollective.com/ya-webadb/backer/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/5/avatar.svg?requireActive=false"></a>
|
|
45
|
+
<a href="https://opencollective.com/ya-webadb/backer/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/6/avatar.svg?requireActive=false"></a>
|
|
46
|
+
<a href="https://opencollective.com/ya-webadb/backer/7/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/7/avatar.svg?requireActive=false"></a>
|
|
47
|
+
<a href="https://opencollective.com/ya-webadb/backer/8/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/8/avatar.svg?requireActive=false"></a>
|
|
48
|
+
<a href="https://opencollective.com/ya-webadb/backer/9/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/9/avatar.svg?requireActive=false"></a>
|
|
49
|
+
<a href="https://opencollective.com/ya-webadb/backer/10/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/10/avatar.svg?requireActive=false"></a>
|
package/esm/adb.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { MaybeConsumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
2
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
+
import type { AdbBanner } from "./banner.js";
|
|
4
|
+
import type { AdbFrameBuffer } from "./commands/index.js";
|
|
5
|
+
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand } from "./commands/index.js";
|
|
6
|
+
import type { AdbFeature } from "./features.js";
|
|
7
|
+
export interface Closeable {
|
|
8
|
+
close(): ValueOrPromise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface AdbSocket extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>, Closeable {
|
|
11
|
+
get service(): string;
|
|
12
|
+
get closed(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export type AdbIncomingSocketHandler = (socket: AdbSocket) => ValueOrPromise<void>;
|
|
15
|
+
export interface AdbTransport extends Closeable {
|
|
16
|
+
readonly serial: string;
|
|
17
|
+
readonly maxPayloadSize: number;
|
|
18
|
+
readonly banner: AdbBanner;
|
|
19
|
+
readonly disconnected: Promise<void>;
|
|
20
|
+
readonly clientFeatures: readonly AdbFeature[];
|
|
21
|
+
connect(service: string): ValueOrPromise<AdbSocket>;
|
|
22
|
+
addReverseTunnel(handler: AdbIncomingSocketHandler, address?: string): ValueOrPromise<string>;
|
|
23
|
+
removeReverseTunnel(address: string): ValueOrPromise<void>;
|
|
24
|
+
clearReverseTunnels(): ValueOrPromise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare class Adb implements Closeable {
|
|
27
|
+
readonly transport: AdbTransport;
|
|
28
|
+
get serial(): string;
|
|
29
|
+
get maxPayloadSize(): number;
|
|
30
|
+
get banner(): AdbBanner;
|
|
31
|
+
get disconnected(): Promise<void>;
|
|
32
|
+
get clientFeatures(): readonly AdbFeature[];
|
|
33
|
+
get deviceFeatures(): AdbFeature[];
|
|
34
|
+
readonly subprocess: AdbSubprocess;
|
|
35
|
+
readonly power: AdbPower;
|
|
36
|
+
readonly reverse: AdbReverseCommand;
|
|
37
|
+
readonly tcpip: AdbTcpIpCommand;
|
|
38
|
+
constructor(transport: AdbTransport);
|
|
39
|
+
canUseFeature(feature: AdbFeature): boolean;
|
|
40
|
+
createSocket(service: string): Promise<AdbSocket>;
|
|
41
|
+
createSocketAndWait(service: string): Promise<string>;
|
|
42
|
+
getProp(key: string): Promise<string>;
|
|
43
|
+
rm(filenames: string | string[], options?: {
|
|
44
|
+
recursive?: boolean;
|
|
45
|
+
force?: boolean;
|
|
46
|
+
}): Promise<string>;
|
|
47
|
+
sync(): Promise<AdbSync>;
|
|
48
|
+
framebuffer(): Promise<AdbFrameBuffer>;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=adb.d.ts.map
|
package/esm/adb.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,oBAAoB,EACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACH,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,eAAe,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAA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AAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;gBAEpB,SAAS,EAAE,YAAY;IASnC,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO;IAOrC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIjD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQrC,EAAE,CACJ,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GACnD,OAAO,CAAC,MAAM,CAAC;IAqBZ,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;IAItC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
package/esm/adb.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ConcatStringStream, TextDecoderStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, } from "./commands/index.js";
|
|
3
|
+
export class Adb {
|
|
4
|
+
transport;
|
|
5
|
+
get serial() {
|
|
6
|
+
return this.transport.serial;
|
|
7
|
+
}
|
|
8
|
+
get maxPayloadSize() {
|
|
9
|
+
return this.transport.maxPayloadSize;
|
|
10
|
+
}
|
|
11
|
+
get banner() {
|
|
12
|
+
return this.transport.banner;
|
|
13
|
+
}
|
|
14
|
+
get disconnected() {
|
|
15
|
+
return this.transport.disconnected;
|
|
16
|
+
}
|
|
17
|
+
get clientFeatures() {
|
|
18
|
+
return this.transport.clientFeatures;
|
|
19
|
+
}
|
|
20
|
+
get deviceFeatures() {
|
|
21
|
+
return this.banner.features;
|
|
22
|
+
}
|
|
23
|
+
subprocess;
|
|
24
|
+
power;
|
|
25
|
+
reverse;
|
|
26
|
+
tcpip;
|
|
27
|
+
constructor(transport) {
|
|
28
|
+
this.transport = transport;
|
|
29
|
+
this.subprocess = new AdbSubprocess(this);
|
|
30
|
+
this.power = new AdbPower(this);
|
|
31
|
+
this.reverse = new AdbReverseCommand(this);
|
|
32
|
+
this.tcpip = new AdbTcpIpCommand(this);
|
|
33
|
+
}
|
|
34
|
+
canUseFeature(feature) {
|
|
35
|
+
return (this.clientFeatures.includes(feature) &&
|
|
36
|
+
this.deviceFeatures.includes(feature));
|
|
37
|
+
}
|
|
38
|
+
async createSocket(service) {
|
|
39
|
+
return this.transport.connect(service);
|
|
40
|
+
}
|
|
41
|
+
async createSocketAndWait(service) {
|
|
42
|
+
const socket = await this.createSocket(service);
|
|
43
|
+
return await socket.readable
|
|
44
|
+
.pipeThrough(new TextDecoderStream())
|
|
45
|
+
.pipeThrough(new ConcatStringStream());
|
|
46
|
+
}
|
|
47
|
+
async getProp(key) {
|
|
48
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy([
|
|
49
|
+
"getprop",
|
|
50
|
+
key,
|
|
51
|
+
]);
|
|
52
|
+
return stdout.trim();
|
|
53
|
+
}
|
|
54
|
+
async rm(filenames, options) {
|
|
55
|
+
const args = ["rm"];
|
|
56
|
+
if (options?.recursive) {
|
|
57
|
+
args.push("-r");
|
|
58
|
+
}
|
|
59
|
+
if (options?.force) {
|
|
60
|
+
args.push("-f");
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(filenames)) {
|
|
63
|
+
for (const filename of filenames) {
|
|
64
|
+
args.push(escapeArg(filename));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
args.push(escapeArg(filenames));
|
|
69
|
+
}
|
|
70
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984
|
|
71
|
+
args.push("</dev/null");
|
|
72
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy(args);
|
|
73
|
+
return stdout;
|
|
74
|
+
}
|
|
75
|
+
async sync() {
|
|
76
|
+
const socket = await this.createSocket("sync:");
|
|
77
|
+
return new AdbSync(this, socket);
|
|
78
|
+
}
|
|
79
|
+
async framebuffer() {
|
|
80
|
+
return framebuffer(this);
|
|
81
|
+
}
|
|
82
|
+
async close() {
|
|
83
|
+
await this.transport.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=adb.js.map
|
package/esm/adb.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAKhF,OAAO,EACH,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,eAAe,EACf,SAAS,EACT,WAAW,GACd,MAAM,qBAAqB,CAAC;AA0C7B,MAAM,OAAO,GAAG;IACH,SAAS,CAAe;IAEjC,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;IACzC,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;IACvC,CAAC;IAED,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;IACzC,CAAC;IAED,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,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,OAAkD;QAElD,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnC,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,uIAAuI;QACvI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,WAAW;QACb,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACJ"}
|
package/esm/banner.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AdbFeature } from "./features.js";
|
|
2
|
+
export declare enum AdbBannerKey {
|
|
3
|
+
Product = "ro.product.name",
|
|
4
|
+
Model = "ro.product.model",
|
|
5
|
+
Device = "ro.product.device",
|
|
6
|
+
Features = "features"
|
|
7
|
+
}
|
|
8
|
+
export declare class AdbBanner {
|
|
9
|
+
#private;
|
|
10
|
+
static parse(banner: string): AdbBanner;
|
|
11
|
+
get product(): string | undefined;
|
|
12
|
+
get model(): string | undefined;
|
|
13
|
+
get device(): string | undefined;
|
|
14
|
+
get features(): AdbFeature[];
|
|
15
|
+
constructor(product: string | undefined, model: string | undefined, device: string | undefined, features: AdbFeature[]);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,oBAAY,YAAY;IACpB,OAAO,oBAAoB;IAC3B,KAAK,qBAAqB;IAC1B,MAAM,sBAAsB;IAC5B,QAAQ,aAAa;CACxB;AAED,qBAAa,SAAS;;IAClB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;IA0C3B,IAAI,OAAO,uBAEV;IAGD,IAAI,KAAK,uBAER;IAGD,IAAI,MAAM,uBAET;IAGD,IAAI,QAAQ,iBAEX;gBAGG,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,UAAU,EAAE;CAO7B"}
|
package/esm/banner.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export var AdbBannerKey;
|
|
2
|
+
(function (AdbBannerKey) {
|
|
3
|
+
AdbBannerKey["Product"] = "ro.product.name";
|
|
4
|
+
AdbBannerKey["Model"] = "ro.product.model";
|
|
5
|
+
AdbBannerKey["Device"] = "ro.product.device";
|
|
6
|
+
AdbBannerKey["Features"] = "features";
|
|
7
|
+
})(AdbBannerKey || (AdbBannerKey = {}));
|
|
8
|
+
export class AdbBanner {
|
|
9
|
+
static parse(banner) {
|
|
10
|
+
let product;
|
|
11
|
+
let model;
|
|
12
|
+
let device;
|
|
13
|
+
let features = [];
|
|
14
|
+
const pieces = banner.split("::");
|
|
15
|
+
if (pieces.length > 1) {
|
|
16
|
+
const props = pieces[1];
|
|
17
|
+
for (const prop of props.split(";")) {
|
|
18
|
+
// istanbul ignore if
|
|
19
|
+
if (!prop) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const keyValue = prop.split("=");
|
|
23
|
+
if (keyValue.length !== 2) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const [key, value] = keyValue;
|
|
27
|
+
switch (key) {
|
|
28
|
+
case AdbBannerKey.Product:
|
|
29
|
+
product = value;
|
|
30
|
+
break;
|
|
31
|
+
case AdbBannerKey.Model:
|
|
32
|
+
model = value;
|
|
33
|
+
break;
|
|
34
|
+
case AdbBannerKey.Device:
|
|
35
|
+
device = value;
|
|
36
|
+
break;
|
|
37
|
+
case AdbBannerKey.Features:
|
|
38
|
+
features = value.split(",");
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return new AdbBanner(product, model, device, features);
|
|
44
|
+
}
|
|
45
|
+
#product;
|
|
46
|
+
get product() {
|
|
47
|
+
return this.#product;
|
|
48
|
+
}
|
|
49
|
+
#model;
|
|
50
|
+
get model() {
|
|
51
|
+
return this.#model;
|
|
52
|
+
}
|
|
53
|
+
#device;
|
|
54
|
+
get device() {
|
|
55
|
+
return this.#device;
|
|
56
|
+
}
|
|
57
|
+
#features = [];
|
|
58
|
+
get features() {
|
|
59
|
+
return this.#features;
|
|
60
|
+
}
|
|
61
|
+
constructor(product, model, device, features) {
|
|
62
|
+
this.#product = product;
|
|
63
|
+
this.#model = model;
|
|
64
|
+
this.#device = device;
|
|
65
|
+
this.#features = features;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
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|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,OAAO,cAAe,SAAQ,cAAc;IACpC,GAAG,CAAM;IAEnB,YAAY,GAAQ;QAChB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Struct from "@yume-chan/struct";
|
|
2
|
+
import type { Adb } from "../adb.js";
|
|
3
|
+
export declare const AdbFrameBufferV1: Struct<{
|
|
4
|
+
bpp: number;
|
|
5
|
+
size: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
red_offset: number;
|
|
9
|
+
red_length: number;
|
|
10
|
+
blue_offset: number;
|
|
11
|
+
blue_length: number;
|
|
12
|
+
green_offset: number;
|
|
13
|
+
green_length: number;
|
|
14
|
+
alpha_offset: number;
|
|
15
|
+
alpha_length: number;
|
|
16
|
+
data: Uint8Array;
|
|
17
|
+
}, "size", Record<never, never>, undefined>;
|
|
18
|
+
export type AdbFrameBufferV1 = (typeof AdbFrameBufferV1)["TDeserializeResult"];
|
|
19
|
+
export declare const AdbFrameBufferV2: Struct<{
|
|
20
|
+
bpp: number;
|
|
21
|
+
colorSpace: number;
|
|
22
|
+
size: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
red_offset: number;
|
|
26
|
+
red_length: number;
|
|
27
|
+
blue_offset: number;
|
|
28
|
+
blue_length: number;
|
|
29
|
+
green_offset: number;
|
|
30
|
+
green_length: number;
|
|
31
|
+
alpha_offset: number;
|
|
32
|
+
alpha_length: number;
|
|
33
|
+
data: Uint8Array;
|
|
34
|
+
}, "size", Record<never, never>, undefined>;
|
|
35
|
+
export type AdbFrameBufferV2 = (typeof AdbFrameBufferV2)["TDeserializeResult"];
|
|
36
|
+
/**
|
|
37
|
+
* ADB uses 8 int32 fields to describe bit depths
|
|
38
|
+
*
|
|
39
|
+
* The only combination I have seen is RGBA8888, which is
|
|
40
|
+
*
|
|
41
|
+
* red_offset: 0
|
|
42
|
+
* red_length: 8
|
|
43
|
+
* blue_offset: 16
|
|
44
|
+
* blue_length: 8
|
|
45
|
+
* green_offset: 8
|
|
46
|
+
* green_length: 8
|
|
47
|
+
* alpha_offset: 24
|
|
48
|
+
* alpha_length: 8
|
|
49
|
+
*
|
|
50
|
+
* But it doesn't mean that other combinations are not possible.
|
|
51
|
+
*/
|
|
52
|
+
export type AdbFrameBuffer = AdbFrameBufferV1 | AdbFrameBufferV2;
|
|
53
|
+
export declare abstract class AdbFrameBufferError extends Error {
|
|
54
|
+
constructor(message: string, options?: ErrorOptions);
|
|
55
|
+
}
|
|
56
|
+
export declare class AdbFrameBufferUnsupportedVersionError extends AdbFrameBufferError {
|
|
57
|
+
constructor(version: number);
|
|
58
|
+
}
|
|
59
|
+
export declare class AdbFrameBufferForbiddenError extends AdbFrameBufferError {
|
|
60
|
+
constructor();
|
|
61
|
+
}
|
|
62
|
+
export declare function framebuffer(adb: Adb): Promise<AdbFrameBuffer>;
|
|
63
|
+
//# sourceMappingURL=framebuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AACA,OAAO,MAA4B,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAIrC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;2CAamB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAE/E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;2CAcmB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEjE,8BAAsB,mBAAoB,SAAQ,KAAK;gBACvC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGtD;AAED,qBAAa,qCAAsC,SAAQ,mBAAmB;gBAC9D,OAAO,EAAE,MAAM;CAG9B;AAED,qBAAa,4BAA6B,SAAQ,mBAAmB;;CAIpE;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAuBnE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BufferedReadableStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import Struct, { StructEmptyError } from "@yume-chan/struct";
|
|
3
|
+
const Version = new Struct({ littleEndian: true }).uint32("version");
|
|
4
|
+
export const AdbFrameBufferV1 = new Struct({ littleEndian: true })
|
|
5
|
+
.uint32("bpp")
|
|
6
|
+
.uint32("size")
|
|
7
|
+
.uint32("width")
|
|
8
|
+
.uint32("height")
|
|
9
|
+
.uint32("red_offset")
|
|
10
|
+
.uint32("red_length")
|
|
11
|
+
.uint32("blue_offset")
|
|
12
|
+
.uint32("blue_length")
|
|
13
|
+
.uint32("green_offset")
|
|
14
|
+
.uint32("green_length")
|
|
15
|
+
.uint32("alpha_offset")
|
|
16
|
+
.uint32("alpha_length")
|
|
17
|
+
.uint8Array("data", { lengthField: "size" });
|
|
18
|
+
export const AdbFrameBufferV2 = new Struct({ littleEndian: true })
|
|
19
|
+
.uint32("bpp")
|
|
20
|
+
.uint32("colorSpace")
|
|
21
|
+
.uint32("size")
|
|
22
|
+
.uint32("width")
|
|
23
|
+
.uint32("height")
|
|
24
|
+
.uint32("red_offset")
|
|
25
|
+
.uint32("red_length")
|
|
26
|
+
.uint32("blue_offset")
|
|
27
|
+
.uint32("blue_length")
|
|
28
|
+
.uint32("green_offset")
|
|
29
|
+
.uint32("green_length")
|
|
30
|
+
.uint32("alpha_offset")
|
|
31
|
+
.uint32("alpha_length")
|
|
32
|
+
.uint8Array("data", { lengthField: "size" });
|
|
33
|
+
export class AdbFrameBufferError extends Error {
|
|
34
|
+
constructor(message, options) {
|
|
35
|
+
super(message, options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class AdbFrameBufferUnsupportedVersionError extends AdbFrameBufferError {
|
|
39
|
+
constructor(version) {
|
|
40
|
+
super(`Unsupported FrameBuffer version ${version}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class AdbFrameBufferForbiddenError extends AdbFrameBufferError {
|
|
44
|
+
constructor() {
|
|
45
|
+
super("FrameBuffer is disabled by current app");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function framebuffer(adb) {
|
|
49
|
+
const socket = await adb.createSocket("framebuffer:");
|
|
50
|
+
const stream = new BufferedReadableStream(socket.readable);
|
|
51
|
+
let version;
|
|
52
|
+
try {
|
|
53
|
+
({ version } = await Version.deserialize(stream));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
if (e instanceof StructEmptyError) {
|
|
57
|
+
throw new AdbFrameBufferForbiddenError();
|
|
58
|
+
}
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
61
|
+
switch (version) {
|
|
62
|
+
case 1:
|
|
63
|
+
// TODO: AdbFrameBuffer: does all v1 responses uses the same color space? Add it so the command returns same format for all versions.
|
|
64
|
+
return AdbFrameBufferV1.deserialize(stream);
|
|
65
|
+
case 2:
|
|
66
|
+
return AdbFrameBufferV2.deserialize(stream);
|
|
67
|
+
default:
|
|
68
|
+
throw new AdbFrameBufferUnsupportedVersionError(version);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=framebuffer.js.map
|