@yume-chan/adb 0.0.10 → 0.0.11

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.
Files changed (318) hide show
  1. package/CHANGELOG.json +26 -0
  2. package/CHANGELOG.md +15 -1
  3. package/LICENSE +1 -1
  4. package/README.md +56 -43
  5. package/esm/adb.d.ts +48 -0
  6. package/esm/adb.d.ts.map +1 -0
  7. package/esm/adb.js +141 -146
  8. package/esm/adb.js.map +1 -1
  9. package/{dts → esm}/auth.d.ts +8 -8
  10. package/esm/auth.d.ts.map +1 -0
  11. package/esm/auth.js +68 -108
  12. package/esm/auth.js.map +1 -1
  13. package/esm/backend.d.ts +9 -0
  14. package/esm/backend.d.ts.map +1 -0
  15. package/{dts → esm}/commands/base.d.ts +1 -1
  16. package/esm/commands/base.d.ts.map +1 -0
  17. package/esm/commands/base.js +1 -0
  18. package/esm/commands/base.js.map +1 -1
  19. package/{dts → esm}/commands/framebuffer.d.ts +3 -3
  20. package/esm/commands/framebuffer.d.ts.map +1 -0
  21. package/esm/commands/framebuffer.js +15 -18
  22. package/esm/commands/framebuffer.js.map +1 -1
  23. package/esm/commands/index.d.ts +9 -0
  24. package/esm/commands/index.d.ts.map +1 -0
  25. package/esm/commands/index.js +8 -8
  26. package/esm/commands/index.js.map +1 -1
  27. package/esm/commands/install.d.ts +4 -0
  28. package/esm/commands/install.d.ts.map +1 -0
  29. package/esm/commands/install.js +21 -13
  30. package/esm/commands/install.js.map +1 -1
  31. package/esm/commands/power.d.ts +23 -0
  32. package/esm/commands/power.d.ts.map +1 -0
  33. package/esm/commands/power.js +45 -0
  34. package/esm/commands/power.js.map +1 -0
  35. package/{dts → esm}/commands/reverse.d.ts +3 -3
  36. package/esm/commands/reverse.d.ts.map +1 -0
  37. package/esm/commands/reverse.js +49 -60
  38. package/esm/commands/reverse.js.map +1 -1
  39. package/esm/commands/subprocess/index.d.ts +57 -0
  40. package/esm/commands/subprocess/index.d.ts.map +1 -0
  41. package/esm/commands/subprocess/index.js +83 -0
  42. package/esm/commands/subprocess/index.js.map +1 -0
  43. package/esm/commands/subprocess/legacy.d.ts +28 -0
  44. package/esm/commands/subprocess/legacy.d.ts.map +1 -0
  45. package/esm/commands/subprocess/legacy.js +44 -0
  46. package/esm/commands/subprocess/legacy.js.map +1 -0
  47. package/esm/commands/subprocess/protocol.d.ts +38 -0
  48. package/esm/commands/subprocess/protocol.d.ts.map +1 -0
  49. package/esm/commands/subprocess/protocol.js +155 -0
  50. package/esm/commands/subprocess/protocol.js.map +1 -0
  51. package/esm/commands/subprocess/types.d.ts +47 -0
  52. package/esm/commands/subprocess/types.d.ts.map +1 -0
  53. package/esm/commands/{shell → subprocess}/types.js +0 -0
  54. package/esm/commands/{shell → subprocess}/types.js.map +1 -1
  55. package/{dts/commands/shell → esm/commands/subprocess}/utils.d.ts +0 -0
  56. package/esm/commands/subprocess/utils.d.ts.map +1 -0
  57. package/esm/commands/{shell → subprocess}/utils.js +0 -0
  58. package/esm/commands/subprocess/utils.js.map +1 -0
  59. package/esm/commands/sync/index.d.ts +8 -0
  60. package/esm/commands/sync/index.d.ts.map +1 -0
  61. package/esm/commands/sync/index.js +7 -7
  62. package/esm/commands/sync/index.js.map +1 -1
  63. package/{dts → esm}/commands/sync/list.d.ts +4 -4
  64. package/esm/commands/sync/list.d.ts.map +1 -0
  65. package/esm/commands/sync/list.js +16 -19
  66. package/esm/commands/sync/list.js.map +1 -1
  67. package/esm/commands/sync/pull.d.ts +11 -0
  68. package/esm/commands/sync/pull.d.ts.map +1 -0
  69. package/esm/commands/sync/pull.js +17 -11
  70. package/esm/commands/sync/pull.js.map +1 -1
  71. package/esm/commands/sync/push.d.ts +8 -0
  72. package/esm/commands/sync/push.d.ts.map +1 -0
  73. package/esm/commands/sync/push.js +19 -37
  74. package/esm/commands/sync/push.js.map +1 -1
  75. package/{dts → esm}/commands/sync/request.d.ts +3 -3
  76. package/esm/commands/sync/request.d.ts.map +1 -0
  77. package/esm/commands/sync/request.js +24 -27
  78. package/esm/commands/sync/request.js.map +1 -1
  79. package/{dts → esm}/commands/sync/response.d.ts +2 -2
  80. package/esm/commands/sync/response.d.ts.map +1 -0
  81. package/esm/commands/sync/response.js +16 -20
  82. package/esm/commands/sync/response.js.map +1 -1
  83. package/{dts → esm}/commands/sync/stat.d.ts +4 -4
  84. package/esm/commands/sync/stat.d.ts.map +1 -0
  85. package/esm/commands/sync/stat.js +22 -27
  86. package/esm/commands/sync/stat.js.map +1 -1
  87. package/esm/commands/sync/sync.d.ts +83 -0
  88. package/esm/commands/sync/sync.d.ts.map +1 -0
  89. package/esm/commands/sync/sync.js +92 -89
  90. package/esm/commands/sync/sync.js.map +1 -1
  91. package/{dts → esm}/commands/tcpip.d.ts +1 -1
  92. package/{dts → esm}/commands/tcpip.d.ts.map +1 -1
  93. package/esm/commands/tcpip.js +14 -19
  94. package/esm/commands/tcpip.js.map +1 -1
  95. package/{dts → esm}/crypto.d.ts +7 -7
  96. package/esm/crypto.d.ts.map +1 -0
  97. package/esm/crypto.js +26 -29
  98. package/esm/crypto.js.map +1 -1
  99. package/{dts → esm}/features.d.ts +0 -0
  100. package/{dts → esm}/features.d.ts.map +0 -0
  101. package/esm/features.js +1 -1
  102. package/esm/features.js.map +1 -1
  103. package/esm/index.d.ts +11 -0
  104. package/esm/index.d.ts.map +1 -0
  105. package/esm/index.js +10 -10
  106. package/esm/index.js.map +1 -1
  107. package/esm/packet.d.ts +28 -0
  108. package/esm/packet.d.ts.map +1 -0
  109. package/esm/packet.js +26 -51
  110. package/esm/packet.js.map +1 -1
  111. package/esm/socket/controller.d.ts +37 -0
  112. package/esm/socket/controller.d.ts.map +1 -0
  113. package/esm/socket/controller.js +52 -66
  114. package/esm/socket/controller.js.map +1 -1
  115. package/{dts → esm}/socket/dispatcher.d.ts +10 -23
  116. package/esm/socket/dispatcher.d.ts.map +1 -0
  117. package/esm/socket/dispatcher.js +148 -164
  118. package/esm/socket/dispatcher.js.map +1 -1
  119. package/esm/socket/index.d.ts +3 -0
  120. package/esm/socket/index.d.ts.map +1 -0
  121. package/esm/socket/index.js +2 -6
  122. package/esm/socket/index.js.map +1 -1
  123. package/esm/socket/socket.d.ts +34 -0
  124. package/esm/socket/socket.d.ts.map +1 -0
  125. package/esm/socket/socket.js +69 -14
  126. package/esm/socket/socket.js.map +1 -1
  127. package/esm/stream/buffered.d.ts +35 -0
  128. package/esm/stream/buffered.d.ts.map +1 -0
  129. package/esm/stream/buffered.js +123 -0
  130. package/esm/stream/buffered.js.map +1 -0
  131. package/esm/stream/detect.bak.d.ts +240 -0
  132. package/esm/stream/detect.bak.d.ts.map +1 -0
  133. package/esm/stream/detect.bak.js +60 -0
  134. package/esm/stream/detect.bak.js.map +1 -0
  135. package/esm/stream/detect.d.ts +18 -0
  136. package/esm/stream/detect.d.ts.map +1 -0
  137. package/esm/stream/detect.js +6 -0
  138. package/esm/stream/detect.js.map +1 -0
  139. package/esm/stream/detect.native.d.ts +240 -0
  140. package/esm/stream/detect.native.d.ts.map +1 -0
  141. package/esm/stream/detect.native.js +60 -0
  142. package/esm/stream/detect.native.js.map +1 -0
  143. package/esm/stream/detect.polyfill.d.ts +18 -0
  144. package/esm/stream/detect.polyfill.d.ts.map +1 -0
  145. package/esm/stream/detect.polyfill.js +6 -0
  146. package/esm/stream/detect.polyfill.js.map +1 -0
  147. package/esm/stream/index.d.ts +4 -0
  148. package/esm/stream/index.d.ts.map +1 -0
  149. package/esm/stream/index.js +3 -2
  150. package/esm/stream/index.js.map +1 -1
  151. package/esm/stream/transform.d.ts +98 -0
  152. package/esm/stream/transform.d.ts.map +1 -0
  153. package/esm/stream/transform.js +352 -0
  154. package/esm/stream/transform.js.map +1 -0
  155. package/{dts → esm}/utils/auto-reset-event.d.ts +1 -1
  156. package/esm/utils/auto-reset-event.d.ts.map +1 -0
  157. package/esm/utils/auto-reset-event.js +2 -1
  158. package/esm/utils/auto-reset-event.js.map +1 -1
  159. package/esm/utils/base64.d.ts +5 -0
  160. package/esm/utils/base64.d.ts.map +1 -0
  161. package/esm/utils/base64.js +116 -80
  162. package/esm/utils/base64.js.map +1 -1
  163. package/esm/utils/encoding.d.ts +3 -0
  164. package/{dts → esm}/utils/encoding.d.ts.map +1 -1
  165. package/esm/utils/encoding.js +1 -1
  166. package/esm/utils/encoding.js.map +1 -1
  167. package/esm/utils/index.d.ts +4 -0
  168. package/esm/utils/index.d.ts.map +1 -0
  169. package/esm/utils/index.js +3 -5
  170. package/esm/utils/index.js.map +1 -1
  171. package/package.json +50 -44
  172. package/src/adb.ts +147 -143
  173. package/src/auth.ts +23 -19
  174. package/src/backend.ts +3 -12
  175. package/src/commands/base.ts +1 -1
  176. package/src/commands/framebuffer.ts +4 -4
  177. package/src/commands/index.ts +8 -8
  178. package/src/commands/install.ts +26 -15
  179. package/src/commands/power.ts +54 -0
  180. package/src/commands/reverse.ts +10 -8
  181. package/src/commands/subprocess/index.ts +124 -0
  182. package/src/commands/subprocess/legacy.ts +58 -0
  183. package/src/commands/subprocess/protocol.ts +185 -0
  184. package/src/commands/subprocess/types.ts +55 -0
  185. package/src/commands/{shell → subprocess}/utils.ts +0 -0
  186. package/src/commands/sync/index.ts +7 -7
  187. package/src/commands/sync/list.ts +7 -6
  188. package/src/commands/sync/pull.ts +27 -18
  189. package/src/commands/sync/push.ts +25 -30
  190. package/src/commands/sync/request.ts +7 -7
  191. package/src/commands/sync/response.ts +4 -4
  192. package/src/commands/sync/stat.ts +8 -6
  193. package/src/commands/sync/sync.ts +64 -32
  194. package/src/commands/tcpip.ts +3 -3
  195. package/src/crypto.ts +38 -43
  196. package/src/index.ts +11 -10
  197. package/src/packet.ts +37 -52
  198. package/src/socket/dispatcher.ts +90 -103
  199. package/src/socket/index.ts +2 -6
  200. package/src/socket/socket.ts +117 -16
  201. package/src/stream/buffered.ts +147 -0
  202. package/src/stream/detect.native.ts +362 -0
  203. package/src/stream/detect.polyfill.ts +25 -0
  204. package/src/stream/detect.ts +25 -0
  205. package/src/stream/index.ts +3 -2
  206. package/src/stream/transform.ts +427 -0
  207. package/src/utils/auto-reset-event.ts +1 -1
  208. package/src/utils/base64.ts +161 -129
  209. package/src/utils/encoding.ts +3 -3
  210. package/src/utils/index.ts +3 -5
  211. package/tsconfig.build.json +3 -0
  212. package/tsconfig.build.tsbuildinfo +1 -0
  213. package/tsconfig.test.json +10 -0
  214. package/dts/adb.d.ts +0 -46
  215. package/dts/adb.d.ts.map +0 -1
  216. package/dts/auth.d.ts.map +0 -1
  217. package/dts/backend.d.ts +0 -13
  218. package/dts/backend.d.ts.map +0 -1
  219. package/dts/commands/base.d.ts.map +0 -1
  220. package/dts/commands/demo-mode.d.ts +0 -41
  221. package/dts/commands/demo-mode.d.ts.map +0 -1
  222. package/dts/commands/framebuffer.d.ts.map +0 -1
  223. package/dts/commands/index.d.ts +0 -9
  224. package/dts/commands/index.d.ts.map +0 -1
  225. package/dts/commands/install.d.ts +0 -3
  226. package/dts/commands/install.d.ts.map +0 -1
  227. package/dts/commands/reverse.d.ts.map +0 -1
  228. package/dts/commands/shell/index.d.ts +0 -46
  229. package/dts/commands/shell/index.d.ts.map +0 -1
  230. package/dts/commands/shell/legacy.d.ts +0 -38
  231. package/dts/commands/shell/legacy.d.ts.map +0 -1
  232. package/dts/commands/shell/protocol.d.ts +0 -45
  233. package/dts/commands/shell/protocol.d.ts.map +0 -1
  234. package/dts/commands/shell/types.d.ts +0 -47
  235. package/dts/commands/shell/types.d.ts.map +0 -1
  236. package/dts/commands/shell/utils.d.ts.map +0 -1
  237. package/dts/commands/sync/index.d.ts +0 -8
  238. package/dts/commands/sync/index.d.ts.map +0 -1
  239. package/dts/commands/sync/list.d.ts.map +0 -1
  240. package/dts/commands/sync/pull.d.ts +0 -11
  241. package/dts/commands/sync/pull.d.ts.map +0 -1
  242. package/dts/commands/sync/push.d.ts +0 -8
  243. package/dts/commands/sync/push.d.ts.map +0 -1
  244. package/dts/commands/sync/request.d.ts.map +0 -1
  245. package/dts/commands/sync/response.d.ts.map +0 -1
  246. package/dts/commands/sync/stat.d.ts.map +0 -1
  247. package/dts/commands/sync/sync.d.ts +0 -68
  248. package/dts/commands/sync/sync.d.ts.map +0 -1
  249. package/dts/crypto.d.ts.map +0 -1
  250. package/dts/index.d.ts +0 -11
  251. package/dts/index.d.ts.map +0 -1
  252. package/dts/packet.d.ts +0 -27
  253. package/dts/packet.d.ts.map +0 -1
  254. package/dts/socket/close-event-emitter.d.ts +0 -8
  255. package/dts/socket/close-event-emitter.d.ts.map +0 -1
  256. package/dts/socket/controller.d.ts +0 -43
  257. package/dts/socket/controller.d.ts.map +0 -1
  258. package/dts/socket/data-event-emitter.d.ts +0 -10
  259. package/dts/socket/data-event-emitter.d.ts.map +0 -1
  260. package/dts/socket/dispatcher.d.ts.map +0 -1
  261. package/dts/socket/index.d.ts +0 -7
  262. package/dts/socket/index.d.ts.map +0 -1
  263. package/dts/socket/logger.d.ts +0 -9
  264. package/dts/socket/logger.d.ts.map +0 -1
  265. package/dts/socket/socket.d.ts +0 -22
  266. package/dts/socket/socket.d.ts.map +0 -1
  267. package/dts/stream/buffered-stream.d.ts +0 -28
  268. package/dts/stream/buffered-stream.d.ts.map +0 -1
  269. package/dts/stream/index.d.ts +0 -3
  270. package/dts/stream/index.d.ts.map +0 -1
  271. package/dts/stream/stream.d.ts +0 -15
  272. package/dts/stream/stream.d.ts.map +0 -1
  273. package/dts/utils/auto-reset-event.d.ts.map +0 -1
  274. package/dts/utils/base64.d.ts +0 -7
  275. package/dts/utils/base64.d.ts.map +0 -1
  276. package/dts/utils/chunk.d.ts +0 -3
  277. package/dts/utils/chunk.d.ts.map +0 -1
  278. package/dts/utils/encoding.d.ts +0 -3
  279. package/dts/utils/event-queue.d.ts +0 -35
  280. package/dts/utils/event-queue.d.ts.map +0 -1
  281. package/dts/utils/index.d.ts +0 -6
  282. package/dts/utils/index.d.ts.map +0 -1
  283. package/esm/commands/demo-mode.js +0 -170
  284. package/esm/commands/demo-mode.js.map +0 -1
  285. package/esm/commands/shell/index.js +0 -62
  286. package/esm/commands/shell/index.js.map +0 -1
  287. package/esm/commands/shell/legacy.js +0 -49
  288. package/esm/commands/shell/legacy.js.map +0 -1
  289. package/esm/commands/shell/protocol.js +0 -106
  290. package/esm/commands/shell/protocol.js.map +0 -1
  291. package/esm/commands/shell/utils.js.map +0 -1
  292. package/esm/socket/close-event-emitter.js +0 -28
  293. package/esm/socket/close-event-emitter.js.map +0 -1
  294. package/esm/socket/data-event-emitter.js +0 -25
  295. package/esm/socket/data-event-emitter.js.map +0 -1
  296. package/esm/socket/logger.js +0 -2
  297. package/esm/socket/logger.js.map +0 -1
  298. package/esm/stream/buffered-stream.js +0 -67
  299. package/esm/stream/buffered-stream.js.map +0 -1
  300. package/esm/stream/stream.js +0 -41
  301. package/esm/stream/stream.js.map +0 -1
  302. package/esm/utils/chunk.js +0 -70
  303. package/esm/utils/chunk.js.map +0 -1
  304. package/esm/utils/event-queue.js +0 -104
  305. package/esm/utils/event-queue.js.map +0 -1
  306. package/src/commands/demo-mode.ts +0 -160
  307. package/src/commands/shell/index.ts +0 -87
  308. package/src/commands/shell/legacy.ts +0 -59
  309. package/src/commands/shell/protocol.ts +0 -121
  310. package/src/commands/shell/types.ts +0 -55
  311. package/src/socket/close-event-emitter.ts +0 -28
  312. package/src/socket/controller.ts +0 -105
  313. package/src/socket/data-event-emitter.ts +0 -27
  314. package/src/socket/logger.ts +0 -12
  315. package/src/stream/buffered-stream.ts +0 -92
  316. package/src/stream/stream.ts +0 -50
  317. package/src/utils/chunk.ts +0 -70
  318. package/src/utils/event-queue.ts +0 -145
package/CHANGELOG.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@yume-chan/adb",
3
3
  "entries": [
4
+ {
5
+ "version": "0.0.11",
6
+ "tag": "@yume-chan/adb_v0.0.11",
7
+ "date": "Sun, 03 Apr 2022 10:54:15 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Add power related API"
12
+ },
13
+ {
14
+ "comment": "Update compatibility matrix"
15
+ },
16
+ {
17
+ "comment": "Update license year"
18
+ }
19
+ ],
20
+ "patch": [
21
+ {
22
+ "comment": "Update to use Web Streams API"
23
+ },
24
+ {
25
+ "comment": "Improve compatibility with Node.js 12 ESM format"
26
+ }
27
+ ]
28
+ }
29
+ },
4
30
  {
5
31
  "version": "0.0.10",
6
32
  "tag": "@yume-chan/adb_v0.0.10",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log - @yume-chan/adb
2
2
 
3
- This log was last generated on Sun, 09 Jan 2022 15:52:20 GMT and should not be manually modified.
3
+ This log was last generated on Sun, 03 Apr 2022 10:54:15 GMT and should not be manually modified.
4
+
5
+ ## 0.0.11
6
+ Sun, 03 Apr 2022 10:54:15 GMT
7
+
8
+ ### Patches
9
+
10
+ - Update to use Web Streams API
11
+ - Improve compatibility with Node.js 12 ESM format
12
+
13
+ ### Updates
14
+
15
+ - Add power related API
16
+ - Update compatibility matrix
17
+ - Update license year
4
18
 
5
19
  ## 0.0.10
6
20
  Sun, 09 Jan 2022 15:52:20 GMT
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Simon Chan
3
+ Copyright (c) 2020-2022 Simon Chan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -5,17 +5,18 @@ TypeScript implementation of Android Debug Bridge (ADB) protocol.
5
5
  **WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.
6
6
 
7
7
  - [Compatibility](#compatibility)
8
+ - [Basic usage](#basic-usage)
9
+ - [Use without bundlers](#use-without-bundlers)
8
10
  - [Connection](#connection)
9
11
  - [Backend](#backend)
10
12
  - [`connect`](#connect)
11
- - [`read`](#read)
12
- - [`write`](#write)
13
13
  - [Authentication](#authentication)
14
14
  - [AdbCredentialStore](#adbcredentialstore)
15
15
  - [`generateKey`](#generatekey)
16
16
  - [`iterateKeys`](#iteratekeys)
17
17
  - [Implementations](#implementations)
18
18
  - [AdbAuthenticator](#adbauthenticator)
19
+ - [`authenticate`](#authenticate)
19
20
  - [Stream multiplex](#stream-multiplex)
20
21
  - [Backend](#backend-1)
21
22
  - [Commands](#commands)
@@ -36,50 +37,49 @@ TypeScript implementation of Android Debug Bridge (ADB) protocol.
36
37
 
37
38
  ## Compatibility
38
39
 
39
- The main limiting factor of compatibility is [@yume-chan/struct](https://www.npmjs.com/package/@yume-chan/struct).
40
+ Here is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.
40
41
 
41
- This library doesn't use any DOM or Node.js API.
42
+ Some features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.
42
43
 
43
- | | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
44
- | --------------- | ------ | ---- | ------- | ----------------- | -------------- | ------- |
45
- | **Basic usage** | 68 | 79 | 68 | No | 14<sup>1</sup> | 10.4 |
44
+ Each backend may have different requirements.
46
45
 
47
- <sup>1</sup> Requires a polyfill for [`DataView#getBigUint64`][MDN_DataView_getBigUint64] and [`DataView#setBigUint64`][MDN_DataView_setBigUint64]
46
+ ### Basic usage
48
47
 
49
- [MDN_DataView_getBigUint64]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getBigUint64
50
- [MDN_DataView_setBigUint64]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setBigUint64
48
+ | | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
49
+ | ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |
50
+ | `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |
51
+ | [Streams][MDN_Streams] | 67 | 79 | No | No | 14.1 | 16.5 |
52
+ | *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |
51
53
 
52
- ## Connection
53
-
54
- This library doesn't tie to a specific transportation method.
54
+ <sup>1</sup> `uint64` and `string` used.
55
55
 
56
- Instead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, etc).
56
+ <sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.
57
57
 
58
- ### Backend
59
-
60
- #### `connect`
58
+ ### Use without bundlers
61
59
 
62
- Establishes a connection with the device.
60
+ | | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
61
+ | --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |
62
+ | Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |
63
63
 
64
- If a backend doesn't have extra steps to establish the connection, it can omit the `connect` method implementation.
64
+ [MDN_Streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
65
65
 
66
- #### `read`
66
+ ## Connection
67
67
 
68
- ```ts
69
- read(length: number): ArrayBuffer | Promise<ArrayBuffer>
70
- ```
68
+ This library doesn't tie to a specific transportation method.
71
69
 
72
- Reads the specified amount of data from the underlying connection.
70
+ Instead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).
73
71
 
74
- The returned `ArrayBuffer` may have more or less data than the `length` parameter specified, if there is some residual data in the connection buffer. The client will automatically call `read` again with the same `length`.
72
+ ### Backend
75
73
 
76
- #### `write`
74
+ #### `connect`
77
75
 
78
76
  ```ts
79
- write(buffer: ArrayBuffer): void | Promise<void>
77
+ connect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>
80
78
  ```
81
79
 
82
- Writes data to the underlying connection.
80
+ Connect to a device and create a pair of `AdbPacket` streams.
81
+
82
+ The backend 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.
83
83
 
84
84
  ## Authentication
85
85
 
@@ -87,22 +87,19 @@ For how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/web
87
87
 
88
88
  In this library, authentication comes in two parts:
89
89
 
90
- * `AdbCredentialStore`: because JavaScript has no unified method to generate, store and iterate crypto keys, an implementation of `AdbCredentialStore` is required for the two built-in authenticators.
91
- * `AdbAuthenticator`: can be used to implement custom authentication modes.
92
-
93
- Custom `AdbCredentialStore`s and `AdbAuthenticator`s can be specified in the `Adb#connect` method.
94
-
95
90
  #### AdbCredentialStore
96
91
 
92
+ An interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)
93
+
97
94
  ##### `generateKey`
98
95
 
99
96
  ```ts
100
- generateKey(): ArrayBuffer | Promise<ArrayBuffer>
97
+ generateKey(): ValueOrPromise<Uint8Array>
101
98
  ```
102
99
 
103
100
  Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
104
101
 
105
- The returned `ArrayBuffer` is the private key in PKCS #8 format.
102
+ The returned `Uint8Array` is the private key in PKCS #8 format.
106
103
 
107
104
  ##### `iterateKeys`
108
105
 
@@ -116,7 +113,7 @@ Each call to `iterateKeys` must return a different iterator that iterate through
116
113
 
117
114
  ##### Implementations
118
115
 
119
- The `@yume-chan/adb-backend-webusb` package contains a `AdbWebCredentialStore` implementation using Web Crypto API to generating keys and Web Storage API to storing keys.
116
+ 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.
120
117
 
121
118
  #### AdbAuthenticator
122
119
 
@@ -124,6 +121,20 @@ An `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from se
124
121
 
125
122
  This package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.
126
123
 
124
+ #### `authenticate`
125
+
126
+ ```ts
127
+ static async authenticate(
128
+ connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,
129
+ credentialStore: AdbCredentialStore,
130
+ authenticators = AdbDefaultAuthenticators,
131
+ ): Promise<Adb>
132
+ ```
133
+
134
+ Call this method to authenticate the connection and create an `Adb` instance.
135
+
136
+ It's possible to call `authenticate` multiple times on a single connection, every time the device receives a `CNXN` packet, it resets its internal state, and starts a new authentication process.
137
+
127
138
  ## Stream multiplex
128
139
 
129
140
  ADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.
@@ -143,16 +154,18 @@ The `Backend` is responsible for reading and writing data from underlying source
143
154
 
144
155
  Spawns child process on server. ADB has two shell modes:
145
156
 
146
- | | Legacy mode | Shell Protocol |
147
- | --------------------------- | ---------------- | ------------------ |
148
- | Feature flag | - | `shell_v2` |
149
- | Implementation | `AdbLegacyShell` | `AdbShellProtocol` |
150
- | Splitting stdout and stderr | No | Yes |
151
- | Returning exit code | No | Yes |
152
- | Resizing window | No | Yes |
157
+ | | Legacy mode | Shell Protocol |
158
+ | --------------------------- | --------------------------- | ---------------------------- |
159
+ | Feature flag | - | `shell_v2` |
160
+ | Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
161
+ | Splitting stdout and stderr | No | Yes |
162
+ | Returning exit code | No | Yes |
163
+ | Resizing window | No | Yes |
153
164
 
154
165
  The `Adb#childProcess#shell` and `Adb#childProcess#spawn` methods accepts a list of implementations, and will use the first supported one.
155
166
 
167
+ For simple command invocation, usually the `AdbNoneSubprocessProtocol` is enough.
168
+
156
169
  ### usb
157
170
 
158
171
  Disable ADB over WiFi.
package/esm/adb.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { type AdbCredentialStore } from './auth.js';
2
+ import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, type AdbFrameBuffer } from './commands/index.js';
3
+ import { AdbFeatures } from './features.js';
4
+ import { type AdbPacketCore, type AdbPacketInit } from './packet.js';
5
+ import { AdbSocket } from './socket/index.js';
6
+ import { WritableStream, type ReadableWritablePair } from "./stream/index.js";
7
+ export declare enum AdbPropKey {
8
+ Product = "ro.product.name",
9
+ Model = "ro.product.model",
10
+ Device = "ro.product.device",
11
+ Features = "features"
12
+ }
13
+ export declare const VERSION_OMIT_CHECKSUM = 16777217;
14
+ export declare class Adb {
15
+ /**
16
+ * It's possible to call `authenticate` multiple times on a single connection,
17
+ * every time the device receives a `CNXN` packet, it resets its internal state,
18
+ * and starts a new authentication process.
19
+ */
20
+ static authenticate(connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>, credentialStore: AdbCredentialStore, authenticators?: import("./auth.js").AdbAuthenticator[]): Promise<Adb>;
21
+ private readonly packetDispatcher;
22
+ get disconnected(): Promise<void>;
23
+ private _protocolVersion;
24
+ get protocolVersion(): number | undefined;
25
+ private _product;
26
+ get product(): string | undefined;
27
+ private _model;
28
+ get model(): string | undefined;
29
+ private _device;
30
+ get device(): string | undefined;
31
+ private _features;
32
+ get features(): AdbFeatures[] | undefined;
33
+ readonly subprocess: AdbSubprocess;
34
+ readonly power: AdbPower;
35
+ readonly reverse: AdbReverseCommand;
36
+ readonly tcpip: AdbTcpIpCommand;
37
+ constructor(connection: ReadableWritablePair<AdbPacketCore, AdbPacketInit>, version: number, maxPayloadSize: number, banner: string);
38
+ private parseBanner;
39
+ getProp(key: string): Promise<string>;
40
+ rm(...filenames: string[]): Promise<string>;
41
+ install(): WritableStream<Uint8Array>;
42
+ sync(): Promise<AdbSync>;
43
+ framebuffer(): Promise<AdbFrameBuffer>;
44
+ createSocket(service: string): Promise<AdbSocket>;
45
+ createSocketAndWait(service: string): Promise<string>;
46
+ dispose(): Promise<void>;
47
+ }
48
+ //# sourceMappingURL=adb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AACA,OAAO,EAAsD,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAmC,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjK,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAA4C,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,EAAuB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAyD,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGrI,oBAAY,UAAU;IAClB,OAAO,oBAAoB;IAC3B,KAAK,qBAAqB;IAC1B,MAAM,sBAAsB;IAC5B,QAAQ,aAAa;CACxB;AAED,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAEhD,qBAAa,GAAG;IACZ;;;;OAIG;WACiB,YAAY,CAC5B,UAAU,EAAE,oBAAoB,CAAC,aAAa,EAAE,aAAa,CAAC,EAC9D,eAAe,EAAE,kBAAkB,EACnC,cAAc,yCAA2B,GAC1C,OAAO,CAAC,GAAG,CAAC;IA4Ff,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsB;IAEvD,IAAW,YAAY,kBAAiD;IAExE,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,IAAW,eAAe,uBAAoC;IAE9D,OAAO,CAAC,QAAQ,CAAqB;IACrC,IAAW,OAAO,uBAA4B;IAE9C,OAAO,CAAC,MAAM,CAAqB;IACnC,IAAW,KAAK,uBAA0B;IAE1C,OAAO,CAAC,OAAO,CAAqB;IACpC,IAAW,MAAM,uBAA2B;IAE5C,OAAO,CAAC,SAAS,CAA4B;IAC7C,IAAW,QAAQ,8BAA6B;IAEhD,SAAgB,UAAU,EAAE,aAAa,CAAC;IAC1C,SAAgB,KAAK,EAAE,QAAQ,CAAC;IAChC,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,SAAgB,KAAK,EAAE,eAAe,CAAC;gBAGnC,UAAU,EAAE,oBAAoB,CAAC,aAAa,EAAE,aAAa,CAAC,EAC9D,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM;IAoBlB,OAAO,CAAC,WAAW;IAmCN,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrC,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAOjD,OAAO;IAID,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;IAItC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIjD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASrD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}
package/esm/adb.js CHANGED
@@ -1,121 +1,134 @@
1
- import { __awaiter } from "tslib";
2
1
  import { PromiseResolver } from '@yume-chan/async';
3
- import { DisposableList } from '@yume-chan/event';
4
- import { AdbAuthenticationHandler, AdbDefaultAuthenticators } from './auth';
5
- import { AdbChildProcess, AdbDemoMode, AdbReverseCommand, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install } from './commands';
6
- import { AdbFeatures } from './features';
7
- import { AdbCommand } from './packet';
8
- import { AdbPacketDispatcher } from './socket';
9
- import { decodeUtf8 } from "./utils";
2
+ import { AdbAuthenticationHandler, AdbDefaultAuthenticators } from './auth.js';
3
+ import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install } from './commands/index.js';
4
+ import { AdbFeatures } from './features.js';
5
+ import { AdbCommand, calculateChecksum } from './packet.js';
6
+ import { AdbPacketDispatcher } from './socket/index.js';
7
+ import { AbortController, DecodeUtf8Stream, GatherStringStream, WritableStream } from "./stream/index.js";
8
+ import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
10
9
  export var AdbPropKey;
11
10
  (function (AdbPropKey) {
12
11
  AdbPropKey["Product"] = "ro.product.name";
13
12
  AdbPropKey["Model"] = "ro.product.model";
14
13
  AdbPropKey["Device"] = "ro.product.device";
15
14
  AdbPropKey["Features"] = "features";
16
- })(AdbPropKey || (AdbPropKey = {}));
15
+ })(AdbPropKey = AdbPropKey || (AdbPropKey = {}));
16
+ export const VERSION_OMIT_CHECKSUM = 0x01000001;
17
17
  export class Adb {
18
- constructor(backend, logger) {
19
- this._connected = false;
20
- this._backend = backend;
21
- this.packetDispatcher = new AdbPacketDispatcher(backend, logger);
22
- this.tcpip = new AdbTcpIpCommand(this);
23
- this.reverse = new AdbReverseCommand(this.packetDispatcher);
24
- this.demoMode = new AdbDemoMode(this);
25
- this.childProcess = new AdbChildProcess(this);
26
- backend.onDisconnected(this.dispose, this);
18
+ /**
19
+ * It's possible to call `authenticate` multiple times on a single connection,
20
+ * every time the device receives a `CNXN` packet, it resets its internal state,
21
+ * and starts a new authentication process.
22
+ */
23
+ static async authenticate(connection, credentialStore, authenticators = AdbDefaultAuthenticators) {
24
+ let version = 0x01000001;
25
+ let maxPayloadSize = 0x100000;
26
+ const features = [
27
+ 'shell_v2',
28
+ 'cmd',
29
+ AdbFeatures.StatV2,
30
+ 'ls_v2',
31
+ 'fixed_push_mkdir',
32
+ 'apex',
33
+ 'abb',
34
+ 'fixed_push_symlink_timestamp',
35
+ 'abb_exec',
36
+ 'remount_shell',
37
+ 'track_app',
38
+ 'sendrecv_v2',
39
+ 'sendrecv_v2_brotli',
40
+ 'sendrecv_v2_lz4',
41
+ 'sendrecv_v2_zstd',
42
+ 'sendrecv_v2_dry_run_send',
43
+ ].join(',');
44
+ const resolver = new PromiseResolver();
45
+ const authHandler = new AdbAuthenticationHandler(authenticators, credentialStore);
46
+ const abortController = new AbortController();
47
+ const pipe = connection.readable
48
+ .pipeTo(new WritableStream({
49
+ async write(packet) {
50
+ switch (packet.command) {
51
+ case AdbCommand.Connect:
52
+ version = Math.min(version, packet.arg0);
53
+ maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
54
+ resolver.resolve(decodeUtf8(packet.payload));
55
+ break;
56
+ case AdbCommand.Auth:
57
+ const response = await authHandler.handle(packet);
58
+ await sendPacket(response);
59
+ break;
60
+ case AdbCommand.Close:
61
+ // Last connection was interrupted
62
+ // Ignore this packet, device will recover
63
+ break;
64
+ default:
65
+ throw new Error('Device not in correct state. Reconnect your device and try again');
66
+ }
67
+ }
68
+ }), {
69
+ preventCancel: true,
70
+ signal: abortController.signal,
71
+ })
72
+ .catch((e) => { resolver.reject(e); });
73
+ const writer = connection.writable.getWriter();
74
+ async function sendPacket(init) {
75
+ // Always send checksum in auth steps
76
+ // Because we don't know if the device will ignore it yet.
77
+ await writer.write(calculateChecksum(init));
78
+ }
79
+ await sendPacket({
80
+ command: AdbCommand.Connect,
81
+ arg0: version,
82
+ arg1: maxPayloadSize,
83
+ // The terminating `;` is required in formal definition
84
+ // But ADB daemon (all versions) can still work without it
85
+ payload: encodeUtf8(`host::features=${features};`),
86
+ });
87
+ try {
88
+ const banner = await resolver.promise;
89
+ // Stop piping before creating Adb object
90
+ // Because AdbPacketDispatcher will try to lock the streams when initializing
91
+ abortController.abort();
92
+ await pipe;
93
+ writer.releaseLock();
94
+ return new Adb(connection, version, maxPayloadSize, banner);
95
+ }
96
+ finally {
97
+ abortController.abort();
98
+ writer.releaseLock();
99
+ }
27
100
  }
28
- get backend() { return this._backend; }
29
- get onDisconnected() { return this.backend.onDisconnected; }
30
- get connected() { return this._connected; }
31
- get name() { return this.backend.name; }
101
+ packetDispatcher;
102
+ get disconnected() { return this.packetDispatcher.disconnected; }
103
+ _protocolVersion;
32
104
  get protocolVersion() { return this._protocolVersion; }
105
+ _product;
33
106
  get product() { return this._product; }
107
+ _model;
34
108
  get model() { return this._model; }
109
+ _device;
35
110
  get device() { return this._device; }
111
+ _features;
36
112
  get features() { return this._features; }
37
- connect(credentialStore, authenticators = AdbDefaultAuthenticators) {
38
- var _a, _b;
39
- return __awaiter(this, void 0, void 0, function* () {
40
- yield ((_b = (_a = this.backend).connect) === null || _b === void 0 ? void 0 : _b.call(_a));
41
- this.packetDispatcher.maxPayloadSize = 0x1000;
42
- this.packetDispatcher.calculateChecksum = true;
43
- this.packetDispatcher.appendNullToServiceString = true;
44
- this.packetDispatcher.start();
45
- const version = 0x01000001;
46
- const versionNoChecksum = 0x01000001;
47
- const maxPayloadSize = 0x100000;
48
- const features = [
49
- 'shell_v2',
50
- 'cmd',
51
- AdbFeatures.StatV2,
52
- 'ls_v2',
53
- 'fixed_push_mkdir',
54
- 'apex',
55
- 'abb',
56
- 'fixed_push_symlink_timestamp',
57
- 'abb_exec',
58
- 'remount_shell',
59
- 'track_app',
60
- 'sendrecv_v2',
61
- 'sendrecv_v2_brotli',
62
- 'sendrecv_v2_lz4',
63
- 'sendrecv_v2_zstd',
64
- 'sendrecv_v2_dry_run_send',
65
- ].join(',');
66
- const resolver = new PromiseResolver();
67
- const authHandler = new AdbAuthenticationHandler(authenticators, credentialStore);
68
- const disposableList = new DisposableList();
69
- disposableList.add(this.packetDispatcher.onPacket((e) => __awaiter(this, void 0, void 0, function* () {
70
- e.handled = true;
71
- const { packet } = e;
72
- try {
73
- switch (packet.command) {
74
- case AdbCommand.Connect:
75
- this.packetDispatcher.maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
76
- const finalVersion = Math.min(version, packet.arg0);
77
- this._protocolVersion = finalVersion;
78
- if (finalVersion >= versionNoChecksum) {
79
- this.packetDispatcher.calculateChecksum = false;
80
- // Android prior to 9.0.0 uses char* to parse service string
81
- // thus requires an extra null character
82
- this.packetDispatcher.appendNullToServiceString = false;
83
- }
84
- this.parseBanner(decodeUtf8(packet.payload));
85
- resolver.resolve();
86
- break;
87
- case AdbCommand.Auth:
88
- const authPacket = yield authHandler.handle(e.packet);
89
- yield this.packetDispatcher.sendPacket(authPacket);
90
- break;
91
- case AdbCommand.Close:
92
- // Last connection was interrupted
93
- // Ignore this packet, device will recover
94
- break;
95
- default:
96
- throw new Error('Device not in correct state. Reconnect your device and try again');
97
- }
98
- }
99
- catch (e) {
100
- resolver.reject(e);
101
- }
102
- })));
103
- disposableList.add(this.packetDispatcher.onError(e => {
104
- resolver.reject(e);
105
- }));
106
- // Android prior 9.0.0 requires the null character
107
- // Newer versions can also handle the null character
108
- // The terminating `;` is required in formal definition
109
- // But ADB daemon can also work without it
110
- yield this.packetDispatcher.sendPacket(AdbCommand.Connect, version, maxPayloadSize, `host::features=${features};\0`);
111
- try {
112
- yield resolver.promise;
113
- this._connected = true;
114
- }
115
- finally {
116
- disposableList.dispose();
117
- }
118
- });
113
+ subprocess;
114
+ power;
115
+ reverse;
116
+ tcpip;
117
+ constructor(connection, version, maxPayloadSize, banner) {
118
+ this.parseBanner(banner);
119
+ this.packetDispatcher = new AdbPacketDispatcher(connection);
120
+ this._protocolVersion = version;
121
+ if (version >= VERSION_OMIT_CHECKSUM) {
122
+ this.packetDispatcher.calculateChecksum = false;
123
+ // Android prior to 9.0.0 uses char* to parse service string
124
+ // thus requires an extra null character
125
+ this.packetDispatcher.appendNullToServiceString = false;
126
+ }
127
+ this.packetDispatcher.maxPayloadSize = maxPayloadSize;
128
+ this.subprocess = new AdbSubprocess(this);
129
+ this.power = new AdbPower(this);
130
+ this.reverse = new AdbReverseCommand(this.packetDispatcher);
131
+ this.tcpip = new AdbTcpIpCommand(this);
119
132
  }
120
133
  parseBanner(banner) {
121
134
  this._features = [];
@@ -148,55 +161,37 @@ export class Adb {
148
161
  }
149
162
  }
150
163
  }
151
- getProp(key) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- const output = yield this.childProcess.exec('getprop', key);
154
- return output.trim();
155
- });
164
+ async getProp(key) {
165
+ const stdout = await this.subprocess.spawnAndWaitLegacy(['getprop', key]);
166
+ return stdout.trim();
156
167
  }
157
- rm(...filenames) {
158
- return __awaiter(this, void 0, void 0, function* () {
159
- return yield this.childProcess.exec('rm', '-rf', ...filenames.map(arg => escapeArg(arg)));
160
- });
168
+ async rm(...filenames) {
169
+ const stdout = await this.subprocess.spawnAndWaitLegacy(['rm', '-rf', ...filenames.map(arg => escapeArg(arg))]);
170
+ return stdout;
161
171
  }
162
- install(apk, onProgress) {
163
- return __awaiter(this, void 0, void 0, function* () {
164
- return yield install(this, apk, onProgress);
165
- });
172
+ install() {
173
+ return install(this);
166
174
  }
167
- sync() {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- const socket = yield this.createSocket('sync:');
170
- return new AdbSync(this, socket);
171
- });
175
+ async sync() {
176
+ const socket = await this.createSocket('sync:');
177
+ return new AdbSync(this, socket);
172
178
  }
173
- framebuffer() {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- return framebuffer(this);
176
- });
179
+ async framebuffer() {
180
+ return framebuffer(this);
177
181
  }
178
- createSocket(service) {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- return this.packetDispatcher.createSocket(service);
181
- });
182
+ async createSocket(service) {
183
+ return this.packetDispatcher.createSocket(service);
182
184
  }
183
- createSocketAndReadAll(service) {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- const socket = yield this.createSocket(service);
186
- const resolver = new PromiseResolver();
187
- let result = '';
188
- socket.onData(buffer => {
189
- result += decodeUtf8(buffer);
190
- });
191
- socket.onClose(() => resolver.resolve(result));
192
- return resolver.promise;
193
- });
185
+ async createSocketAndWait(service) {
186
+ const socket = await this.createSocket(service);
187
+ const gatherStream = new GatherStringStream();
188
+ await socket.readable
189
+ .pipeThrough(new DecodeUtf8Stream())
190
+ .pipeTo(gatherStream.writable);
191
+ return gatherStream.result;
194
192
  }
195
- dispose() {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- this.packetDispatcher.dispose();
198
- yield this.backend.dispose();
199
- });
193
+ async dispose() {
194
+ this.packetDispatcher.dispose();
200
195
  }
201
196
  }
202
197
  //# sourceMappingURL=adb.js.map