@yume-chan/adb 0.0.10 → 0.0.13

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 (342) hide show
  1. package/CHANGELOG.json +50 -0
  2. package/CHANGELOG.md +29 -1
  3. package/LICENSE +1 -1
  4. package/README.md +71 -51
  5. package/esm/adb.d.ts +48 -0
  6. package/esm/adb.d.ts.map +1 -0
  7. package/esm/adb.js +149 -136
  8. package/esm/adb.js.map +1 -1
  9. package/{dts → esm}/auth.d.ts +11 -11
  10. package/esm/auth.d.ts.map +1 -0
  11. package/esm/auth.js +72 -110
  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 +19 -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 +56 -0
  40. package/esm/commands/subprocess/index.d.ts.map +1 -0
  41. package/esm/commands/subprocess/index.js +88 -0
  42. package/esm/commands/subprocess/index.js.map +1 -0
  43. package/esm/commands/subprocess/legacy.d.ts +35 -0
  44. package/esm/commands/subprocess/legacy.d.ts.map +1 -0
  45. package/esm/commands/subprocess/legacy.js +53 -0
  46. package/esm/commands/subprocess/legacy.js.map +1 -0
  47. package/esm/commands/subprocess/protocol.d.ts +39 -0
  48. package/esm/commands/subprocess/protocol.d.ts.map +1 -0
  49. package/esm/commands/subprocess/protocol.js +157 -0
  50. package/esm/commands/subprocess/protocol.js.map +1 -0
  51. package/esm/commands/subprocess/protocols/index.d.ts +4 -0
  52. package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
  53. package/esm/commands/subprocess/protocols/index.js +4 -0
  54. package/esm/commands/subprocess/protocols/index.js.map +1 -0
  55. package/esm/commands/subprocess/protocols/none.d.ts +35 -0
  56. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
  57. package/esm/commands/subprocess/protocols/none.js +53 -0
  58. package/esm/commands/subprocess/protocols/none.js.map +1 -0
  59. package/esm/commands/subprocess/protocols/shell.d.ts +39 -0
  60. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
  61. package/esm/commands/subprocess/protocols/shell.js +155 -0
  62. package/esm/commands/subprocess/protocols/shell.js.map +1 -0
  63. package/esm/commands/subprocess/protocols/types.d.ts +50 -0
  64. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
  65. package/esm/commands/{shell → subprocess/protocols}/types.js +0 -0
  66. package/esm/commands/subprocess/protocols/types.js.map +1 -0
  67. package/esm/commands/subprocess/types.d.ts +50 -0
  68. package/esm/commands/subprocess/types.d.ts.map +1 -0
  69. package/esm/commands/subprocess/types.js +2 -0
  70. package/esm/commands/{shell → subprocess}/types.js.map +1 -1
  71. package/{dts/commands/shell → esm/commands/subprocess}/utils.d.ts +0 -0
  72. package/esm/commands/subprocess/utils.d.ts.map +1 -0
  73. package/esm/commands/{shell → subprocess}/utils.js +0 -0
  74. package/esm/commands/subprocess/utils.js.map +1 -0
  75. package/esm/commands/sync/index.d.ts +8 -0
  76. package/esm/commands/sync/index.d.ts.map +1 -0
  77. package/esm/commands/sync/index.js +7 -7
  78. package/esm/commands/sync/index.js.map +1 -1
  79. package/esm/commands/sync/list.d.ts +41 -0
  80. package/esm/commands/sync/list.d.ts.map +1 -0
  81. package/esm/commands/sync/list.js +52 -20
  82. package/esm/commands/sync/list.js.map +1 -1
  83. package/esm/commands/sync/pull.d.ts +11 -0
  84. package/esm/commands/sync/pull.d.ts.map +1 -0
  85. package/esm/commands/sync/pull.js +17 -11
  86. package/esm/commands/sync/pull.js.map +1 -1
  87. package/esm/commands/sync/push.d.ts +8 -0
  88. package/esm/commands/sync/push.d.ts.map +1 -0
  89. package/esm/commands/sync/push.js +19 -37
  90. package/esm/commands/sync/push.js.map +1 -1
  91. package/{dts → esm}/commands/sync/request.d.ts +4 -3
  92. package/esm/commands/sync/request.d.ts.map +1 -0
  93. package/esm/commands/sync/request.js +25 -27
  94. package/esm/commands/sync/request.js.map +1 -1
  95. package/{dts → esm}/commands/sync/response.d.ts +4 -3
  96. package/esm/commands/sync/response.d.ts.map +1 -0
  97. package/esm/commands/sync/response.js +17 -20
  98. package/esm/commands/sync/response.js.map +1 -1
  99. package/{dts → esm}/commands/sync/stat.d.ts +16 -4
  100. package/esm/commands/sync/stat.d.ts.map +1 -0
  101. package/esm/commands/sync/stat.js +38 -30
  102. package/esm/commands/sync/stat.js.map +1 -1
  103. package/esm/commands/sync/sync.d.ts +61 -0
  104. package/esm/commands/sync/sync.d.ts.map +1 -0
  105. package/esm/commands/sync/sync.js +122 -89
  106. package/esm/commands/sync/sync.js.map +1 -1
  107. package/{dts → esm}/commands/tcpip.d.ts +1 -1
  108. package/{dts → esm}/commands/tcpip.d.ts.map +1 -1
  109. package/esm/commands/tcpip.js +14 -19
  110. package/esm/commands/tcpip.js.map +1 -1
  111. package/esm/crypto.d.ts +37 -0
  112. package/esm/crypto.d.ts.map +1 -0
  113. package/esm/crypto.js +77 -62
  114. package/esm/crypto.js.map +1 -1
  115. package/esm/features.d.ts +8 -0
  116. package/esm/features.d.ts.map +1 -0
  117. package/esm/features.js +7 -3
  118. package/esm/features.js.map +1 -1
  119. package/esm/index.d.ts +11 -0
  120. package/esm/index.d.ts.map +1 -0
  121. package/esm/index.js +10 -10
  122. package/esm/index.js.map +1 -1
  123. package/esm/packet.d.ts +47 -0
  124. package/esm/packet.d.ts.map +1 -0
  125. package/esm/packet.js +27 -52
  126. package/esm/packet.js.map +1 -1
  127. package/esm/socket/controller.d.ts +37 -0
  128. package/esm/socket/controller.d.ts.map +1 -0
  129. package/esm/socket/controller.js +52 -66
  130. package/esm/socket/controller.js.map +1 -1
  131. package/esm/socket/dispatcher.d.ts +44 -0
  132. package/esm/socket/dispatcher.d.ts.map +1 -0
  133. package/esm/socket/dispatcher.js +146 -165
  134. package/esm/socket/dispatcher.js.map +1 -1
  135. package/esm/socket/index.d.ts +3 -0
  136. package/esm/socket/index.d.ts.map +1 -0
  137. package/esm/socket/index.js +2 -6
  138. package/esm/socket/index.js.map +1 -1
  139. package/esm/socket/socket.d.ts +46 -0
  140. package/esm/socket/socket.d.ts.map +1 -0
  141. package/esm/socket/socket.js +77 -13
  142. package/esm/socket/socket.js.map +1 -1
  143. package/esm/stream/buffered.d.ts +35 -0
  144. package/esm/stream/buffered.d.ts.map +1 -0
  145. package/esm/stream/buffered.js +123 -0
  146. package/esm/stream/buffered.js.map +1 -0
  147. package/esm/stream/detect.bak.d.ts +240 -0
  148. package/esm/stream/detect.bak.d.ts.map +1 -0
  149. package/esm/stream/detect.bak.js +60 -0
  150. package/esm/stream/detect.bak.js.map +1 -0
  151. package/esm/stream/detect.d.ts +2 -0
  152. package/esm/stream/detect.d.ts.map +1 -0
  153. package/esm/stream/detect.js +5 -0
  154. package/esm/stream/detect.js.map +1 -0
  155. package/esm/stream/detect.native.d.ts +240 -0
  156. package/esm/stream/detect.native.d.ts.map +1 -0
  157. package/esm/stream/detect.native.js +60 -0
  158. package/esm/stream/detect.native.js.map +1 -0
  159. package/esm/stream/detect.polyfill.d.ts +18 -0
  160. package/esm/stream/detect.polyfill.d.ts.map +1 -0
  161. package/esm/stream/detect.polyfill.js +9 -0
  162. package/esm/stream/detect.polyfill.js.map +1 -0
  163. package/esm/stream/index.d.ts +4 -0
  164. package/esm/stream/index.d.ts.map +1 -0
  165. package/esm/stream/index.js +3 -2
  166. package/esm/stream/index.js.map +1 -1
  167. package/esm/stream/transform.d.ts +98 -0
  168. package/esm/stream/transform.d.ts.map +1 -0
  169. package/esm/stream/transform.js +402 -0
  170. package/esm/stream/transform.js.map +1 -0
  171. package/{dts → esm}/utils/auto-reset-event.d.ts +1 -1
  172. package/esm/utils/auto-reset-event.d.ts.map +1 -0
  173. package/esm/utils/auto-reset-event.js +2 -1
  174. package/esm/utils/auto-reset-event.js.map +1 -1
  175. package/esm/utils/base64.d.ts +5 -0
  176. package/esm/utils/base64.d.ts.map +1 -0
  177. package/esm/utils/base64.js +116 -80
  178. package/esm/utils/base64.js.map +1 -1
  179. package/esm/utils/encoding.d.ts +3 -0
  180. package/esm/utils/encoding.d.ts.map +1 -0
  181. package/esm/utils/encoding.js +1 -1
  182. package/esm/utils/encoding.js.map +1 -1
  183. package/esm/utils/index.d.ts +4 -0
  184. package/esm/utils/index.d.ts.map +1 -0
  185. package/esm/utils/index.js +3 -5
  186. package/esm/utils/index.js.map +1 -1
  187. package/package.json +50 -44
  188. package/src/adb.ts +177 -150
  189. package/src/auth.ts +37 -30
  190. package/src/backend.ts +3 -12
  191. package/src/commands/base.ts +1 -1
  192. package/src/commands/framebuffer.ts +4 -4
  193. package/src/commands/index.ts +8 -8
  194. package/src/commands/install.ts +24 -15
  195. package/src/commands/power.ts +54 -0
  196. package/src/commands/reverse.ts +10 -8
  197. package/src/commands/subprocess/index.ts +139 -0
  198. package/src/commands/subprocess/protocols/index.ts +3 -0
  199. package/src/commands/subprocess/protocols/none.ts +68 -0
  200. package/src/commands/subprocess/protocols/shell.ts +190 -0
  201. package/src/commands/subprocess/protocols/types.ts +59 -0
  202. package/src/commands/{shell → subprocess}/utils.ts +0 -0
  203. package/src/commands/sync/index.ts +7 -7
  204. package/src/commands/sync/list.ts +56 -9
  205. package/src/commands/sync/pull.ts +27 -18
  206. package/src/commands/sync/push.ts +25 -30
  207. package/src/commands/sync/request.ts +8 -7
  208. package/src/commands/sync/response.ts +12 -6
  209. package/src/commands/sync/stat.ts +43 -14
  210. package/src/commands/sync/sync.ts +102 -34
  211. package/src/commands/tcpip.ts +3 -3
  212. package/src/crypto.ts +95 -84
  213. package/src/features.ts +6 -2
  214. package/src/index.ts +11 -10
  215. package/src/packet.ts +49 -53
  216. package/src/socket/dispatcher.ts +110 -109
  217. package/src/socket/index.ts +2 -6
  218. package/src/socket/socket.ts +125 -17
  219. package/src/stream/buffered.ts +147 -0
  220. package/src/stream/detect.native.ts +362 -0
  221. package/src/stream/detect.polyfill.ts +28 -0
  222. package/src/stream/detect.ts +5 -0
  223. package/src/stream/index.ts +3 -2
  224. package/src/stream/transform.ts +483 -0
  225. package/src/utils/auto-reset-event.ts +1 -1
  226. package/src/utils/base64.ts +161 -129
  227. package/src/utils/index.ts +3 -5
  228. package/tsconfig.build.json +3 -0
  229. package/tsconfig.build.tsbuildinfo +1 -0
  230. package/tsconfig.test.json +10 -0
  231. package/dts/adb.d.ts +0 -46
  232. package/dts/adb.d.ts.map +0 -1
  233. package/dts/auth.d.ts.map +0 -1
  234. package/dts/backend.d.ts +0 -13
  235. package/dts/backend.d.ts.map +0 -1
  236. package/dts/commands/base.d.ts.map +0 -1
  237. package/dts/commands/demo-mode.d.ts +0 -41
  238. package/dts/commands/demo-mode.d.ts.map +0 -1
  239. package/dts/commands/framebuffer.d.ts.map +0 -1
  240. package/dts/commands/index.d.ts +0 -9
  241. package/dts/commands/index.d.ts.map +0 -1
  242. package/dts/commands/install.d.ts +0 -3
  243. package/dts/commands/install.d.ts.map +0 -1
  244. package/dts/commands/reverse.d.ts.map +0 -1
  245. package/dts/commands/shell/index.d.ts +0 -46
  246. package/dts/commands/shell/index.d.ts.map +0 -1
  247. package/dts/commands/shell/legacy.d.ts +0 -38
  248. package/dts/commands/shell/legacy.d.ts.map +0 -1
  249. package/dts/commands/shell/protocol.d.ts +0 -45
  250. package/dts/commands/shell/protocol.d.ts.map +0 -1
  251. package/dts/commands/shell/types.d.ts +0 -47
  252. package/dts/commands/shell/types.d.ts.map +0 -1
  253. package/dts/commands/shell/utils.d.ts.map +0 -1
  254. package/dts/commands/sync/index.d.ts +0 -8
  255. package/dts/commands/sync/index.d.ts.map +0 -1
  256. package/dts/commands/sync/list.d.ts +0 -17
  257. package/dts/commands/sync/list.d.ts.map +0 -1
  258. package/dts/commands/sync/pull.d.ts +0 -11
  259. package/dts/commands/sync/pull.d.ts.map +0 -1
  260. package/dts/commands/sync/push.d.ts +0 -8
  261. package/dts/commands/sync/push.d.ts.map +0 -1
  262. package/dts/commands/sync/request.d.ts.map +0 -1
  263. package/dts/commands/sync/response.d.ts.map +0 -1
  264. package/dts/commands/sync/stat.d.ts.map +0 -1
  265. package/dts/commands/sync/sync.d.ts +0 -68
  266. package/dts/commands/sync/sync.d.ts.map +0 -1
  267. package/dts/crypto.d.ts +0 -24
  268. package/dts/crypto.d.ts.map +0 -1
  269. package/dts/features.d.ts +0 -6
  270. package/dts/features.d.ts.map +0 -1
  271. package/dts/index.d.ts +0 -11
  272. package/dts/index.d.ts.map +0 -1
  273. package/dts/packet.d.ts +0 -27
  274. package/dts/packet.d.ts.map +0 -1
  275. package/dts/socket/close-event-emitter.d.ts +0 -8
  276. package/dts/socket/close-event-emitter.d.ts.map +0 -1
  277. package/dts/socket/controller.d.ts +0 -43
  278. package/dts/socket/controller.d.ts.map +0 -1
  279. package/dts/socket/data-event-emitter.d.ts +0 -10
  280. package/dts/socket/data-event-emitter.d.ts.map +0 -1
  281. package/dts/socket/dispatcher.d.ts +0 -53
  282. package/dts/socket/dispatcher.d.ts.map +0 -1
  283. package/dts/socket/index.d.ts +0 -7
  284. package/dts/socket/index.d.ts.map +0 -1
  285. package/dts/socket/logger.d.ts +0 -9
  286. package/dts/socket/logger.d.ts.map +0 -1
  287. package/dts/socket/socket.d.ts +0 -22
  288. package/dts/socket/socket.d.ts.map +0 -1
  289. package/dts/stream/buffered-stream.d.ts +0 -28
  290. package/dts/stream/buffered-stream.d.ts.map +0 -1
  291. package/dts/stream/index.d.ts +0 -3
  292. package/dts/stream/index.d.ts.map +0 -1
  293. package/dts/stream/stream.d.ts +0 -15
  294. package/dts/stream/stream.d.ts.map +0 -1
  295. package/dts/utils/auto-reset-event.d.ts.map +0 -1
  296. package/dts/utils/base64.d.ts +0 -7
  297. package/dts/utils/base64.d.ts.map +0 -1
  298. package/dts/utils/chunk.d.ts +0 -3
  299. package/dts/utils/chunk.d.ts.map +0 -1
  300. package/dts/utils/encoding.d.ts +0 -3
  301. package/dts/utils/encoding.d.ts.map +0 -1
  302. package/dts/utils/event-queue.d.ts +0 -35
  303. package/dts/utils/event-queue.d.ts.map +0 -1
  304. package/dts/utils/index.d.ts +0 -6
  305. package/dts/utils/index.d.ts.map +0 -1
  306. package/esm/commands/demo-mode.js +0 -170
  307. package/esm/commands/demo-mode.js.map +0 -1
  308. package/esm/commands/shell/index.js +0 -62
  309. package/esm/commands/shell/index.js.map +0 -1
  310. package/esm/commands/shell/legacy.js +0 -49
  311. package/esm/commands/shell/legacy.js.map +0 -1
  312. package/esm/commands/shell/protocol.js +0 -106
  313. package/esm/commands/shell/protocol.js.map +0 -1
  314. package/esm/commands/shell/utils.js.map +0 -1
  315. package/esm/socket/close-event-emitter.js +0 -28
  316. package/esm/socket/close-event-emitter.js.map +0 -1
  317. package/esm/socket/data-event-emitter.js +0 -25
  318. package/esm/socket/data-event-emitter.js.map +0 -1
  319. package/esm/socket/logger.js +0 -2
  320. package/esm/socket/logger.js.map +0 -1
  321. package/esm/stream/buffered-stream.js +0 -67
  322. package/esm/stream/buffered-stream.js.map +0 -1
  323. package/esm/stream/stream.js +0 -41
  324. package/esm/stream/stream.js.map +0 -1
  325. package/esm/utils/chunk.js +0 -70
  326. package/esm/utils/chunk.js.map +0 -1
  327. package/esm/utils/event-queue.js +0 -104
  328. package/esm/utils/event-queue.js.map +0 -1
  329. package/src/commands/demo-mode.ts +0 -160
  330. package/src/commands/shell/index.ts +0 -87
  331. package/src/commands/shell/legacy.ts +0 -59
  332. package/src/commands/shell/protocol.ts +0 -121
  333. package/src/commands/shell/types.ts +0 -55
  334. package/src/socket/close-event-emitter.ts +0 -28
  335. package/src/socket/controller.ts +0 -105
  336. package/src/socket/data-event-emitter.ts +0 -27
  337. package/src/socket/logger.ts +0 -12
  338. package/src/stream/buffered-stream.ts +0 -92
  339. package/src/stream/stream.ts +0 -50
  340. package/src/utils/chunk.ts +0 -70
  341. package/src/utils/encoding.ts +0 -13
  342. package/src/utils/event-queue.ts +0 -145
package/CHANGELOG.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@yume-chan/adb",
3
3
  "entries": [
4
+ {
5
+ "version": "0.0.13",
6
+ "tag": "@yume-chan/adb_v0.0.13",
7
+ "date": "Thu, 28 Apr 2022 01:23:53 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Add support for raw shell mode"
12
+ },
13
+ {
14
+ "comment": "Add support for LIS2 command in Sync protocol"
15
+ },
16
+ {
17
+ "comment": "Add workaround for the push_mkdir issue in Android 9"
18
+ }
19
+ ]
20
+ }
21
+ },
22
+ {
23
+ "version": "0.0.12",
24
+ "tag": "@yume-chan/adb_v0.0.12",
25
+ "date": "Sun, 03 Apr 2022 11:18:47 GMT",
26
+ "comments": {}
27
+ },
28
+ {
29
+ "version": "0.0.11",
30
+ "tag": "@yume-chan/adb_v0.0.11",
31
+ "date": "Sun, 03 Apr 2022 10:54:15 GMT",
32
+ "comments": {
33
+ "none": [
34
+ {
35
+ "comment": "Add power related API"
36
+ },
37
+ {
38
+ "comment": "Update compatibility matrix"
39
+ },
40
+ {
41
+ "comment": "Update license year"
42
+ }
43
+ ],
44
+ "patch": [
45
+ {
46
+ "comment": "Update to use Web Streams API"
47
+ },
48
+ {
49
+ "comment": "Improve compatibility with Node.js 12 ESM format"
50
+ }
51
+ ]
52
+ }
53
+ },
4
54
  {
5
55
  "version": "0.0.10",
6
56
  "tag": "@yume-chan/adb_v0.0.10",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,34 @@
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 Thu, 28 Apr 2022 01:23:53 GMT and should not be manually modified.
4
+
5
+ ## 0.0.13
6
+ Thu, 28 Apr 2022 01:23:53 GMT
7
+
8
+ ### Updates
9
+
10
+ - Add support for raw shell mode
11
+ - Add support for LIS2 command in Sync protocol
12
+ - Add workaround for the push_mkdir issue in Android 9
13
+
14
+ ## 0.0.12
15
+ Sun, 03 Apr 2022 11:18:47 GMT
16
+
17
+ _Version update only_
18
+
19
+ ## 0.0.11
20
+ Sun, 03 Apr 2022 10:54:15 GMT
21
+
22
+ ### Patches
23
+
24
+ - Update to use Web Streams API
25
+ - Improve compatibility with Node.js 12 ESM format
26
+
27
+ ### Updates
28
+
29
+ - Add power related API
30
+ - Update compatibility matrix
31
+ - Update license year
4
32
 
5
33
  ## 0.0.10
6
34
  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,21 +5,23 @@ 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
- - [Backend](#backend-1)
21
21
  - [Commands](#commands)
22
- - [childProcess](#childprocess)
22
+ - [subprocess](#subprocess)
23
+ - [raw mode](#raw-mode)
24
+ - [pty mode](#pty-mode)
23
25
  - [usb](#usb)
24
26
  - [tcpip](#tcpip)
25
27
  - [sync](#sync)
@@ -36,50 +38,46 @@ TypeScript implementation of Android Debug Bridge (ADB) protocol.
36
38
 
37
39
  ## Compatibility
38
40
 
39
- The main limiting factor of compatibility is [@yume-chan/struct](https://www.npmjs.com/package/@yume-chan/struct).
41
+ 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
42
 
41
- This library doesn't use any DOM or Node.js API.
43
+ Some features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.
42
44
 
43
- | | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
44
- | --------------- | ------ | ---- | ------- | ----------------- | -------------- | ------- |
45
- | **Basic usage** | 68 | 79 | 68 | No | 14<sup>1</sup> | 10.4 |
45
+ Each backend may have different requirements.
46
46
 
47
- <sup>1</sup> Requires a polyfill for [`DataView#getBigUint64`][MDN_DataView_getBigUint64] and [`DataView#setBigUint64`][MDN_DataView_setBigUint64]
47
+ ### Basic usage
48
48
 
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
49
+ | | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
50
+ | ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |
51
+ | `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |
52
+ | *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |
53
+
54
+ <sup>1</sup> `uint64` and `string` are used.
55
+
56
+ <sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.
57
+
58
+ ### Use without bundlers
59
+
60
+ | | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
61
+ | --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |
62
+ | Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |
51
63
 
52
64
  ## Connection
53
65
 
54
66
  This library doesn't tie to a specific transportation method.
55
67
 
56
- Instead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, etc).
68
+ Instead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).
57
69
 
58
70
  ### Backend
59
71
 
60
72
  #### `connect`
61
73
 
62
- Establishes a connection with the device.
63
-
64
- If a backend doesn't have extra steps to establish the connection, it can omit the `connect` method implementation.
65
-
66
- #### `read`
67
-
68
74
  ```ts
69
- read(length: number): ArrayBuffer | Promise<ArrayBuffer>
75
+ connect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>
70
76
  ```
71
77
 
72
- Reads the specified amount of data from the underlying connection.
78
+ Connect to a device and create a pair of `AdbPacket` streams.
73
79
 
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`.
75
-
76
- #### `write`
77
-
78
- ```ts
79
- write(buffer: ArrayBuffer): void | Promise<void>
80
- ```
81
-
82
- Writes data to the underlying connection.
80
+ The backend, instead of the core library, is responsible for serializing and deserializing the packets. Because it's extreme slow for WebUSB backend (`@yume-chan/adb-backend-webusb`) to read packets with unknown size.
83
81
 
84
82
  ## Authentication
85
83
 
@@ -87,22 +85,19 @@ For how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/web
87
85
 
88
86
  In this library, authentication comes in two parts:
89
87
 
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
88
  #### AdbCredentialStore
96
89
 
90
+ An interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)
91
+
97
92
  ##### `generateKey`
98
93
 
99
94
  ```ts
100
- generateKey(): ArrayBuffer | Promise<ArrayBuffer>
95
+ generateKey(): ValueOrPromise<Uint8Array>
101
96
  ```
102
97
 
103
98
  Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
104
99
 
105
- The returned `ArrayBuffer` is the private key in PKCS #8 format.
100
+ The returned `Uint8Array` is the private key in PKCS #8 format.
106
101
 
107
102
  ##### `iterateKeys`
108
103
 
@@ -116,7 +111,7 @@ Each call to `iterateKeys` must return a different iterator that iterate through
116
111
 
117
112
  ##### Implementations
118
113
 
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.
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.
120
115
 
121
116
  #### AdbAuthenticator
122
117
 
@@ -124,6 +119,20 @@ An `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from se
124
119
 
125
120
  This package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.
126
121
 
122
+ #### `authenticate`
123
+
124
+ ```ts
125
+ static async authenticate(
126
+ connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,
127
+ credentialStore: AdbCredentialStore,
128
+ authenticators = AdbDefaultAuthenticators,
129
+ ): Promise<Adb>
130
+ ```
131
+
132
+ Call this method to authenticate the connection and create an `Adb` instance.
133
+
134
+ If an authentication process failed, it's possible to call `authenticate` again on the same connection (`AdbPacket` stream pair). Every time the device receives a `CNXN` packet, it resets all internal state, and starts a new authentication process.
135
+
127
136
  ## Stream multiplex
128
137
 
129
138
  ADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.
@@ -133,25 +142,36 @@ ADB commands are all based on streams. Multiple streams can send and receive at
133
142
  3. Client and server read/write on the stream.
134
143
  4. Client/server sends a `CLSE` to close the stream.
135
144
 
136
- The `Backend` is responsible for reading and writing data from underlying source.
145
+ ## Commands
137
146
 
138
- ### Backend
147
+ ### subprocess
139
148
 
140
- ## Commands
149
+ ADB has two subprocess invocation modes and two data protocols (4 combinations).
150
+
151
+ #### raw mode
152
+
153
+ In raw mode, Shell protocol transfers `stdout` and `stderr` separately. It also supports returning exit code.
154
+
155
+ | | Legacy protocol | Shell Protocol |
156
+ | --------------------------- | --------------------------- | ---------------------------- |
157
+ | Feature flag | - | `shell_v2` |
158
+ | Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
159
+ | Splitting stdout and stderr | No | Yes |
160
+ | Returning exit code | No | Yes |
161
+
162
+ Use `spawn` method to create a subprocess in raw mode.
141
163
 
142
- ### childProcess
164
+ #### pty mode
143
165
 
144
- Spawns child process on server. ADB has two shell modes:
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.
145
167
 
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 |
168
+ | | Legacy protocol | Shell Protocol |
169
+ | --------------------------- | --------------------------- | ---------------------------- |
170
+ | Feature flag | - | `shell_v2` |
171
+ | Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
172
+ | Resizing window | No | Yes |
153
173
 
154
- The `Adb#childProcess#shell` and `Adb#childProcess#spawn` methods accepts a list of implementations, and will use the first supported one.
174
+ Use `shell` method to create a subprocess in PTY mode.
155
175
 
156
176
  ### usb
157
177
 
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 AdbPacketData, type AdbPacketInit } from './packet.js';
5
+ import { type 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<AdbPacketData, AdbPacketInit>, 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<AdbPacketData, AdbPacketInit>, version: number, maxPayloadSize: number, banner: string);
38
+ private parseBanner;
39
+ createSocket(service: string): Promise<AdbSocket>;
40
+ createSocketAndWait(service: string): Promise<string>;
41
+ getProp(key: string): Promise<string>;
42
+ rm(...filenames: string[]): Promise<string>;
43
+ install(): WritableStream<Uint8Array>;
44
+ sync(): Promise<AdbSync>;
45
+ framebuffer(): Promise<AdbFrameBuffer>;
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":"AAGA,OAAO,EAA0D,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC5G,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,EAAiC,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxE,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,yCAA6B,GAC5C,OAAO,CAAC,GAAG,CAAC;IAsGf,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;IA+BlB,OAAO,CAAC,WAAW;IAmCN,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIjD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASrD,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,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}