@yume-chan/adb 2.6.0 → 3.0.0-beta.0

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 (449) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/esm/adb.d.ts +18 -15
  4. package/esm/adb.d.ts.map +1 -1
  5. package/esm/adb.js +18 -11
  6. package/esm/adb.js.map +1 -1
  7. package/esm/banner.d.ts +1 -1
  8. package/esm/banner.d.ts.map +1 -1
  9. package/esm/daemon/auth/authenticator.d.ts +28 -0
  10. package/esm/daemon/auth/authenticator.d.ts.map +1 -0
  11. package/esm/daemon/auth/authenticator.js +108 -0
  12. package/esm/daemon/auth/authenticator.js.map +1 -0
  13. package/esm/daemon/auth/index.d.ts +5 -0
  14. package/esm/daemon/auth/index.d.ts.map +1 -0
  15. package/esm/daemon/auth/index.js +5 -0
  16. package/esm/daemon/auth/index.js.map +1 -0
  17. package/esm/daemon/auth/packet-processor.d.ts +42 -0
  18. package/esm/daemon/auth/packet-processor.d.ts.map +1 -0
  19. package/esm/daemon/auth/packet-processor.js +129 -0
  20. package/esm/daemon/auth/packet-processor.js.map +1 -0
  21. package/esm/daemon/auth/public-key.d.ts +8 -0
  22. package/esm/daemon/auth/public-key.d.ts.map +1 -0
  23. package/esm/daemon/auth/public-key.js +74 -0
  24. package/esm/daemon/auth/public-key.js.map +1 -0
  25. package/esm/daemon/auth/type.d.ts +5 -0
  26. package/esm/daemon/auth/type.d.ts.map +1 -0
  27. package/esm/daemon/auth/type.js +2 -0
  28. package/esm/daemon/auth/type.js.map +1 -0
  29. package/esm/daemon/crypto.d.ts +6 -5
  30. package/esm/daemon/crypto.d.ts.map +1 -1
  31. package/esm/daemon/crypto.js +23 -73
  32. package/esm/daemon/crypto.js.map +1 -1
  33. package/esm/daemon/dispatcher.d.ts +3 -3
  34. package/esm/daemon/dispatcher.d.ts.map +1 -1
  35. package/esm/daemon/dispatcher.js +11 -4
  36. package/esm/daemon/dispatcher.js.map +1 -1
  37. package/esm/daemon/index.d.ts +1 -1
  38. package/esm/daemon/index.d.ts.map +1 -1
  39. package/esm/daemon/index.js +1 -1
  40. package/esm/daemon/index.js.map +1 -1
  41. package/esm/daemon/socket.d.ts +3 -3
  42. package/esm/daemon/socket.d.ts.map +1 -1
  43. package/esm/daemon/transport.d.ts +13 -65
  44. package/esm/daemon/transport.d.ts.map +1 -1
  45. package/esm/daemon/transport.js +18 -140
  46. package/esm/daemon/transport.js.map +1 -1
  47. package/esm/device-observer.d.ts +2 -3
  48. package/esm/device-observer.d.ts.map +1 -1
  49. package/esm/features-value.d.ts +40 -0
  50. package/esm/features-value.d.ts.map +1 -0
  51. package/esm/features-value.js +46 -0
  52. package/esm/features-value.js.map +1 -0
  53. package/esm/features.d.ts +4 -12
  54. package/esm/features.d.ts.map +1 -1
  55. package/esm/features.js +27 -13
  56. package/esm/features.js.map +1 -1
  57. package/esm/index.d.ts +1 -1
  58. package/esm/index.d.ts.map +1 -1
  59. package/esm/index.js +1 -1
  60. package/esm/index.js.map +1 -1
  61. package/esm/server/client.d.ts +7 -7
  62. package/esm/server/client.d.ts.map +1 -1
  63. package/esm/server/client.js +69 -86
  64. package/esm/server/client.js.map +1 -1
  65. package/esm/server/commands/wireless.js +1 -1
  66. package/esm/server/commands/wireless.js.map +1 -1
  67. package/esm/server/{stream.d.ts → data-connection.d.ts} +5 -5
  68. package/esm/server/data-connection.d.ts.map +1 -0
  69. package/esm/server/{stream.js → data-connection.js} +4 -4
  70. package/esm/server/data-connection.js.map +1 -0
  71. package/esm/server/index.d.ts +1 -1
  72. package/esm/server/index.d.ts.map +1 -1
  73. package/esm/server/index.js +1 -1
  74. package/esm/server/index.js.map +1 -1
  75. package/esm/server/observer.d.ts.map +1 -1
  76. package/esm/server/observer.js +14 -13
  77. package/esm/server/observer.js.map +1 -1
  78. package/esm/server/transport.d.ts +4 -6
  79. package/esm/server/transport.d.ts.map +1 -1
  80. package/esm/server/transport.js +9 -24
  81. package/esm/server/transport.js.map +1 -1
  82. package/esm/service/framebuffer.d.ts.map +1 -0
  83. package/esm/service/framebuffer.js.map +1 -0
  84. package/esm/{commands → service}/index.d.ts +1 -2
  85. package/esm/service/index.d.ts.map +1 -0
  86. package/esm/{commands → service}/index.js +1 -2
  87. package/esm/service/index.js.map +1 -0
  88. package/esm/{commands → service}/power.d.ts +4 -2
  89. package/esm/service/power.d.ts.map +1 -0
  90. package/esm/{commands → service}/power.js +11 -5
  91. package/esm/service/power.js.map +1 -0
  92. package/esm/service/reverse/error.d.ts +14 -0
  93. package/esm/service/reverse/error.d.ts.map +1 -0
  94. package/esm/service/reverse/error.js +21 -0
  95. package/esm/service/reverse/error.js.map +1 -0
  96. package/esm/service/reverse/index.d.ts +3 -0
  97. package/esm/service/reverse/index.d.ts.map +1 -0
  98. package/esm/service/reverse/index.js +4 -0
  99. package/esm/service/reverse/index.js.map +1 -0
  100. package/esm/service/reverse/response.d.ts +2 -0
  101. package/esm/service/reverse/response.d.ts.map +1 -0
  102. package/esm/service/reverse/response.js +30 -0
  103. package/esm/service/reverse/response.js.map +1 -0
  104. package/esm/service/reverse/service.d.ts +59 -0
  105. package/esm/service/reverse/service.d.ts.map +1 -0
  106. package/esm/{commands/reverse.js → service/reverse/service.js} +16 -45
  107. package/esm/service/reverse/service.js.map +1 -0
  108. package/esm/{commands → service}/subprocess/index.d.ts +1 -0
  109. package/esm/service/subprocess/index.d.ts.map +1 -0
  110. package/esm/{commands → service}/subprocess/index.js +1 -0
  111. package/esm/service/subprocess/index.js.map +1 -0
  112. package/esm/service/subprocess/none/index.d.ts.map +1 -0
  113. package/esm/service/subprocess/none/index.js.map +1 -0
  114. package/esm/{commands → service}/subprocess/none/process.d.ts +2 -2
  115. package/esm/service/subprocess/none/process.d.ts.map +1 -0
  116. package/esm/service/subprocess/none/process.js.map +1 -0
  117. package/esm/{commands → service}/subprocess/none/pty.d.ts +4 -4
  118. package/esm/service/subprocess/none/pty.d.ts.map +1 -0
  119. package/esm/{commands → service}/subprocess/none/pty.js +1 -1
  120. package/esm/service/subprocess/none/pty.js.map +1 -0
  121. package/esm/service/subprocess/none/service.d.ts +10 -0
  122. package/esm/service/subprocess/none/service.d.ts.map +1 -0
  123. package/esm/service/subprocess/none/service.js +44 -0
  124. package/esm/service/subprocess/none/service.js.map +1 -0
  125. package/esm/service/subprocess/none/spawner.d.ts +15 -0
  126. package/esm/service/subprocess/none/spawner.d.ts.map +1 -0
  127. package/esm/service/subprocess/none/spawner.js +31 -0
  128. package/esm/service/subprocess/none/spawner.js.map +1 -0
  129. package/esm/{commands → service}/subprocess/pty.d.ts +1 -1
  130. package/esm/service/subprocess/pty.d.ts.map +1 -0
  131. package/esm/{commands → service}/subprocess/pty.js.map +1 -1
  132. package/esm/service/subprocess/service.d.ts.map +1 -0
  133. package/esm/{commands → service}/subprocess/service.js +1 -1
  134. package/esm/service/subprocess/service.js.map +1 -0
  135. package/esm/service/subprocess/shell/index.d.ts +5 -0
  136. package/esm/{commands/subprocess/none → service/subprocess/shell}/index.d.ts.map +1 -1
  137. package/esm/service/subprocess/shell/index.js +6 -0
  138. package/esm/{commands/subprocess/none → service/subprocess/shell}/index.js.map +1 -1
  139. package/esm/{commands → service}/subprocess/shell/process.d.ts +2 -2
  140. package/esm/service/subprocess/shell/process.d.ts.map +1 -0
  141. package/esm/{commands → service}/subprocess/shell/process.js +4 -6
  142. package/esm/service/subprocess/shell/process.js.map +1 -0
  143. package/esm/{commands → service}/subprocess/shell/pty.d.ts +4 -4
  144. package/esm/service/subprocess/shell/pty.d.ts.map +1 -0
  145. package/esm/{commands → service}/subprocess/shell/pty.js +11 -9
  146. package/esm/service/subprocess/shell/pty.js.map +1 -0
  147. package/esm/service/subprocess/shell/service.d.ts +34 -0
  148. package/esm/service/subprocess/shell/service.d.ts.map +1 -0
  149. package/esm/service/subprocess/shell/service.js +52 -0
  150. package/esm/service/subprocess/shell/service.js.map +1 -0
  151. package/esm/service/subprocess/shell/shared.d.ts +2 -0
  152. package/esm/service/subprocess/shell/shared.d.ts.map +1 -0
  153. package/esm/{commands → service}/subprocess/shell/shared.js +2 -0
  154. package/esm/service/subprocess/shell/shared.js.map +1 -0
  155. package/esm/{commands → service}/subprocess/shell/spawner.d.ts +3 -7
  156. package/esm/service/subprocess/shell/spawner.d.ts.map +1 -0
  157. package/esm/service/subprocess/shell/spawner.js +45 -0
  158. package/esm/service/subprocess/shell/spawner.js.map +1 -0
  159. package/esm/service/subprocess/types.d.ts +14 -0
  160. package/esm/service/subprocess/types.d.ts.map +1 -0
  161. package/esm/service/subprocess/types.js +2 -0
  162. package/esm/service/subprocess/types.js.map +1 -0
  163. package/esm/service/subprocess/utils.d.ts +39 -0
  164. package/esm/service/subprocess/utils.d.ts.map +1 -0
  165. package/esm/service/subprocess/utils.js +142 -0
  166. package/esm/service/subprocess/utils.js.map +1 -0
  167. package/esm/service/sync/android.d.ts +34 -0
  168. package/esm/service/sync/android.d.ts.map +1 -0
  169. package/esm/service/sync/android.js +34 -0
  170. package/esm/service/sync/android.js.map +1 -0
  171. package/esm/service/sync/compression/compression.d.ts +17 -0
  172. package/esm/service/sync/compression/compression.d.ts.map +1 -0
  173. package/esm/service/sync/compression/compression.js +92 -0
  174. package/esm/service/sync/compression/compression.js.map +1 -0
  175. package/esm/service/sync/compression/format-ns.d.ts +5 -0
  176. package/esm/service/sync/compression/format-ns.d.ts.map +1 -0
  177. package/esm/service/sync/compression/format-ns.js +5 -0
  178. package/esm/service/sync/compression/format-ns.js.map +1 -0
  179. package/esm/service/sync/compression/format.d.ts +4 -0
  180. package/esm/service/sync/compression/format.d.ts.map +1 -0
  181. package/esm/service/sync/compression/format.js +3 -0
  182. package/esm/service/sync/compression/format.js.map +1 -0
  183. package/esm/service/sync/compression/index.d.ts +2 -0
  184. package/esm/service/sync/compression/index.d.ts.map +1 -0
  185. package/esm/service/sync/compression/index.js +2 -0
  186. package/esm/service/sync/compression/index.js.map +1 -0
  187. package/esm/service/sync/id/common.d.ts +17 -0
  188. package/esm/service/sync/id/common.d.ts.map +1 -0
  189. package/esm/service/sync/id/common.js +29 -0
  190. package/esm/service/sync/id/common.js.map +1 -0
  191. package/esm/service/sync/id/index.d.ts +4 -0
  192. package/esm/service/sync/id/index.d.ts.map +1 -0
  193. package/esm/service/sync/id/index.js +6 -0
  194. package/esm/service/sync/id/index.js.map +1 -0
  195. package/esm/service/sync/id/request.d.ts +7 -0
  196. package/esm/service/sync/id/request.d.ts.map +1 -0
  197. package/esm/service/sync/id/request.js +9 -0
  198. package/esm/service/sync/id/request.js.map +1 -0
  199. package/esm/service/sync/id/response.d.ts +6 -0
  200. package/esm/service/sync/id/response.d.ts.map +1 -0
  201. package/esm/service/sync/id/response.js +8 -0
  202. package/esm/service/sync/id/response.js.map +1 -0
  203. package/esm/service/sync/index-ns.d.ts +7 -0
  204. package/esm/service/sync/index-ns.d.ts.map +1 -0
  205. package/esm/service/sync/index-ns.js +7 -0
  206. package/esm/service/sync/index-ns.js.map +1 -0
  207. package/esm/service/sync/index.d.ts +3 -0
  208. package/esm/service/sync/index.d.ts.map +1 -0
  209. package/esm/service/sync/index.js +3 -0
  210. package/esm/service/sync/index.js.map +1 -0
  211. package/esm/service/sync/request/index.d.ts +5 -0
  212. package/esm/service/sync/request/index.d.ts.map +1 -0
  213. package/esm/service/sync/request/index.js +5 -0
  214. package/esm/service/sync/request/index.js.map +1 -0
  215. package/esm/{commands/sync → service/sync/request}/list.d.ts +21 -19
  216. package/esm/service/sync/request/list.d.ts.map +1 -0
  217. package/esm/service/sync/request/list.js +77 -0
  218. package/esm/service/sync/request/list.js.map +1 -0
  219. package/esm/service/sync/request/pull.d.ts +12 -0
  220. package/esm/service/sync/request/pull.d.ts.map +1 -0
  221. package/esm/service/sync/request/pull.js +28 -0
  222. package/esm/service/sync/request/pull.js.map +1 -0
  223. package/esm/service/sync/request/push.d.ts +54 -0
  224. package/esm/service/sync/request/push.d.ts.map +1 -0
  225. package/esm/service/sync/request/push.js +95 -0
  226. package/esm/service/sync/request/push.js.map +1 -0
  227. package/esm/{commands/sync → service/sync/request}/stat.d.ts +40 -50
  228. package/esm/service/sync/request/stat.d.ts.map +1 -0
  229. package/esm/service/sync/request/stat.js +89 -0
  230. package/esm/service/sync/request/stat.js.map +1 -0
  231. package/esm/service/sync/service.d.ts +123 -0
  232. package/esm/service/sync/service.d.ts.map +1 -0
  233. package/esm/service/sync/service.js +170 -0
  234. package/esm/service/sync/service.js.map +1 -0
  235. package/esm/service/sync/socket-pool.d.ts +11 -0
  236. package/esm/service/sync/socket-pool.d.ts.map +1 -0
  237. package/esm/service/sync/socket-pool.js +80 -0
  238. package/esm/service/sync/socket-pool.js.map +1 -0
  239. package/esm/service/sync/socket.d.ts +40 -0
  240. package/esm/service/sync/socket.d.ts.map +1 -0
  241. package/esm/service/sync/socket.js +153 -0
  242. package/esm/service/sync/socket.js.map +1 -0
  243. package/esm/{commands → service}/tcpip.d.ts +4 -2
  244. package/esm/service/tcpip.d.ts.map +1 -0
  245. package/esm/{commands → service}/tcpip.js +10 -7
  246. package/esm/service/tcpip.js.map +1 -0
  247. package/esm/utils/array-buffer.d.ts.map +1 -1
  248. package/esm/utils/array-buffer.js +2 -3
  249. package/esm/utils/array-buffer.js.map +1 -1
  250. package/esm/utils/base64.d.ts.map +1 -1
  251. package/esm/utils/base64.js +22 -12
  252. package/esm/utils/base64.js.map +1 -1
  253. package/esm/utils/index.d.ts +1 -0
  254. package/esm/utils/index.d.ts.map +1 -1
  255. package/esm/utils/index.js +1 -0
  256. package/esm/utils/index.js.map +1 -1
  257. package/esm/utils/md5.d.ts +8 -0
  258. package/esm/utils/md5.d.ts.map +1 -0
  259. package/esm/utils/md5.js +149 -0
  260. package/esm/utils/md5.js.map +1 -0
  261. package/package.json +10 -10
  262. package/src/adb.ts +44 -34
  263. package/src/daemon/auth/authenticator.ts +186 -0
  264. package/src/daemon/auth/index.ts +4 -0
  265. package/src/daemon/auth/packet-processor.ts +212 -0
  266. package/src/daemon/auth/public-key.ts +112 -0
  267. package/src/daemon/auth/type.ts +5 -0
  268. package/src/daemon/crypto.ts +36 -102
  269. package/src/daemon/dispatcher.ts +15 -8
  270. package/src/daemon/index.ts +1 -1
  271. package/src/daemon/socket.ts +3 -3
  272. package/src/daemon/transport.ts +35 -253
  273. package/src/device-observer.ts +3 -3
  274. package/src/features-value.ts +47 -0
  275. package/src/features.ts +31 -14
  276. package/src/index.ts +1 -1
  277. package/src/server/client.ts +96 -94
  278. package/src/server/commands/wireless.ts +1 -1
  279. package/src/server/{stream.ts → data-connection.ts} +4 -4
  280. package/src/server/index.ts +1 -1
  281. package/src/server/observer.ts +21 -19
  282. package/src/server/transport.ts +13 -34
  283. package/src/{commands → service}/index.ts +1 -2
  284. package/src/{commands → service}/power.ts +14 -5
  285. package/src/service/reverse/error.ts +35 -0
  286. package/src/service/reverse/index.ts +3 -0
  287. package/src/service/reverse/response.ts +38 -0
  288. package/src/{commands/reverse.ts → service/reverse/service.ts} +32 -72
  289. package/src/{commands → service}/subprocess/index.ts +1 -0
  290. package/src/{commands → service}/subprocess/none/process.ts +3 -3
  291. package/src/{commands → service}/subprocess/none/pty.ts +5 -5
  292. package/src/service/subprocess/none/service.ts +57 -0
  293. package/src/service/subprocess/none/spawner.ts +81 -0
  294. package/src/{commands → service}/subprocess/pty.ts +1 -1
  295. package/src/{commands → service}/subprocess/service.ts +1 -1
  296. package/src/{commands → service}/subprocess/shell/index.ts +1 -1
  297. package/src/{commands → service}/subprocess/shell/process.ts +6 -7
  298. package/src/{commands → service}/subprocess/shell/pty.ts +15 -13
  299. package/src/service/subprocess/shell/service.ts +75 -0
  300. package/src/{commands → service}/subprocess/shell/shared.ts +5 -0
  301. package/src/service/subprocess/shell/spawner.ts +109 -0
  302. package/src/service/subprocess/types.ts +19 -0
  303. package/src/service/subprocess/utils.ts +166 -0
  304. package/src/service/sync/android.ts +43 -0
  305. package/src/service/sync/compression/compression.ts +126 -0
  306. package/src/service/sync/compression/format-ns.ts +4 -0
  307. package/src/service/sync/compression/format.ts +5 -0
  308. package/src/service/sync/compression/index.ts +1 -0
  309. package/src/service/sync/id/common.ts +33 -0
  310. package/src/service/sync/id/index.ts +7 -0
  311. package/src/service/sync/id/request.ts +12 -0
  312. package/src/service/sync/id/response.ts +11 -0
  313. package/src/service/sync/index-ns.ts +6 -0
  314. package/src/service/sync/index.ts +2 -0
  315. package/src/service/sync/request/index.ts +4 -0
  316. package/src/service/sync/request/list.ts +110 -0
  317. package/src/service/sync/request/pull.ts +49 -0
  318. package/src/service/sync/request/push.ts +184 -0
  319. package/src/service/sync/request/stat.ts +127 -0
  320. package/src/service/sync/service.ts +255 -0
  321. package/src/service/sync/socket-pool.ts +97 -0
  322. package/src/service/sync/socket.ts +201 -0
  323. package/src/{commands → service}/tcpip.ts +13 -7
  324. package/src/utils/array-buffer.ts +2 -3
  325. package/src/utils/base64.ts +24 -12
  326. package/src/utils/index.ts +1 -0
  327. package/src/utils/md5.ts +185 -0
  328. package/yume-chan-adb-3.0.0-beta.0.tgz +0 -0
  329. package/CHANGELOG.md +0 -251
  330. package/esm/commands/base.d.ts +0 -8
  331. package/esm/commands/base.d.ts.map +0 -1
  332. package/esm/commands/base.js +0 -12
  333. package/esm/commands/base.js.map +0 -1
  334. package/esm/commands/framebuffer.d.ts.map +0 -1
  335. package/esm/commands/framebuffer.js.map +0 -1
  336. package/esm/commands/index.d.ts.map +0 -1
  337. package/esm/commands/index.js.map +0 -1
  338. package/esm/commands/power.d.ts.map +0 -1
  339. package/esm/commands/power.js.map +0 -1
  340. package/esm/commands/reverse.d.ts +0 -48
  341. package/esm/commands/reverse.d.ts.map +0 -1
  342. package/esm/commands/reverse.js.map +0 -1
  343. package/esm/commands/subprocess/index.d.ts.map +0 -1
  344. package/esm/commands/subprocess/index.js.map +0 -1
  345. package/esm/commands/subprocess/none/process.d.ts.map +0 -1
  346. package/esm/commands/subprocess/none/process.js.map +0 -1
  347. package/esm/commands/subprocess/none/pty.d.ts.map +0 -1
  348. package/esm/commands/subprocess/none/pty.js.map +0 -1
  349. package/esm/commands/subprocess/none/service.d.ts +0 -10
  350. package/esm/commands/subprocess/none/service.d.ts.map +0 -1
  351. package/esm/commands/subprocess/none/service.js +0 -34
  352. package/esm/commands/subprocess/none/service.js.map +0 -1
  353. package/esm/commands/subprocess/none/spawner.d.ts +0 -19
  354. package/esm/commands/subprocess/none/spawner.d.ts.map +0 -1
  355. package/esm/commands/subprocess/none/spawner.js +0 -26
  356. package/esm/commands/subprocess/none/spawner.js.map +0 -1
  357. package/esm/commands/subprocess/pty.d.ts.map +0 -1
  358. package/esm/commands/subprocess/service.d.ts.map +0 -1
  359. package/esm/commands/subprocess/service.js.map +0 -1
  360. package/esm/commands/subprocess/shell/index.d.ts +0 -6
  361. package/esm/commands/subprocess/shell/index.d.ts.map +0 -1
  362. package/esm/commands/subprocess/shell/index.js +0 -6
  363. package/esm/commands/subprocess/shell/index.js.map +0 -1
  364. package/esm/commands/subprocess/shell/process.d.ts.map +0 -1
  365. package/esm/commands/subprocess/shell/process.js.map +0 -1
  366. package/esm/commands/subprocess/shell/pty.d.ts.map +0 -1
  367. package/esm/commands/subprocess/shell/pty.js.map +0 -1
  368. package/esm/commands/subprocess/shell/service.d.ts +0 -14
  369. package/esm/commands/subprocess/shell/service.d.ts.map +0 -1
  370. package/esm/commands/subprocess/shell/service.js +0 -41
  371. package/esm/commands/subprocess/shell/service.js.map +0 -1
  372. package/esm/commands/subprocess/shell/shared.d.ts +0 -19
  373. package/esm/commands/subprocess/shell/shared.d.ts.map +0 -1
  374. package/esm/commands/subprocess/shell/shared.js.map +0 -1
  375. package/esm/commands/subprocess/shell/spawner.d.ts.map +0 -1
  376. package/esm/commands/subprocess/shell/spawner.js +0 -38
  377. package/esm/commands/subprocess/shell/spawner.js.map +0 -1
  378. package/esm/commands/subprocess/utils.d.ts +0 -3
  379. package/esm/commands/subprocess/utils.d.ts.map +0 -1
  380. package/esm/commands/subprocess/utils.js +0 -56
  381. package/esm/commands/subprocess/utils.js.map +0 -1
  382. package/esm/commands/sync/index.d.ts +0 -9
  383. package/esm/commands/sync/index.d.ts.map +0 -1
  384. package/esm/commands/sync/index.js +0 -9
  385. package/esm/commands/sync/index.js.map +0 -1
  386. package/esm/commands/sync/list.d.ts.map +0 -1
  387. package/esm/commands/sync/list.js +0 -64
  388. package/esm/commands/sync/list.js.map +0 -1
  389. package/esm/commands/sync/pull.d.ts +0 -12
  390. package/esm/commands/sync/pull.d.ts.map +0 -1
  391. package/esm/commands/sync/pull.js +0 -33
  392. package/esm/commands/sync/pull.js.map +0 -1
  393. package/esm/commands/sync/push.d.ts +0 -61
  394. package/esm/commands/sync/push.d.ts.map +0 -1
  395. package/esm/commands/sync/push.js +0 -83
  396. package/esm/commands/sync/push.js.map +0 -1
  397. package/esm/commands/sync/request.d.ts +0 -24
  398. package/esm/commands/sync/request.d.ts.map +0 -1
  399. package/esm/commands/sync/request.js +0 -32
  400. package/esm/commands/sync/request.js.map +0 -1
  401. package/esm/commands/sync/response.d.ts +0 -28
  402. package/esm/commands/sync/response.d.ts.map +0 -1
  403. package/esm/commands/sync/response.js +0 -81
  404. package/esm/commands/sync/response.js.map +0 -1
  405. package/esm/commands/sync/socket.d.ts +0 -22
  406. package/esm/commands/sync/socket.d.ts.map +0 -1
  407. package/esm/commands/sync/socket.js +0 -78
  408. package/esm/commands/sync/socket.js.map +0 -1
  409. package/esm/commands/sync/stat.d.ts.map +0 -1
  410. package/esm/commands/sync/stat.js +0 -121
  411. package/esm/commands/sync/stat.js.map +0 -1
  412. package/esm/commands/sync/sync.d.ts +0 -82
  413. package/esm/commands/sync/sync.d.ts.map +0 -1
  414. package/esm/commands/sync/sync.js +0 -138
  415. package/esm/commands/sync/sync.js.map +0 -1
  416. package/esm/commands/tcpip.d.ts.map +0 -1
  417. package/esm/commands/tcpip.js.map +0 -1
  418. package/esm/daemon/auth.d.ts +0 -54
  419. package/esm/daemon/auth.d.ts.map +0 -1
  420. package/esm/daemon/auth.js +0 -104
  421. package/esm/daemon/auth.js.map +0 -1
  422. package/esm/server/stream.d.ts.map +0 -1
  423. package/esm/server/stream.js.map +0 -1
  424. package/src/commands/base.ts +0 -15
  425. package/src/commands/subprocess/none/service.ts +0 -45
  426. package/src/commands/subprocess/none/spawner.ts +0 -68
  427. package/src/commands/subprocess/shell/service.ts +0 -58
  428. package/src/commands/subprocess/shell/spawner.ts +0 -90
  429. package/src/commands/subprocess/utils.ts +0 -61
  430. package/src/commands/sync/index.ts +0 -8
  431. package/src/commands/sync/list.ts +0 -99
  432. package/src/commands/sync/pull.ts +0 -55
  433. package/src/commands/sync/push.ts +0 -172
  434. package/src/commands/sync/request.ts +0 -53
  435. package/src/commands/sync/response.ts +0 -105
  436. package/src/commands/sync/socket.ts +0 -109
  437. package/src/commands/sync/stat.ts +0 -177
  438. package/src/commands/sync/sync.ts +0 -175
  439. package/src/daemon/auth.ts +0 -204
  440. package/tsconfig.build.tsbuildinfo +0 -1
  441. /package/esm/{commands → service}/framebuffer.d.ts +0 -0
  442. /package/esm/{commands → service}/framebuffer.js +0 -0
  443. /package/esm/{commands → service}/subprocess/none/index.d.ts +0 -0
  444. /package/esm/{commands → service}/subprocess/none/index.js +0 -0
  445. /package/esm/{commands → service}/subprocess/none/process.js +0 -0
  446. /package/esm/{commands → service}/subprocess/pty.js +0 -0
  447. /package/esm/{commands → service}/subprocess/service.d.ts +0 -0
  448. /package/src/{commands → service}/framebuffer.ts +0 -0
  449. /package/src/{commands → service}/subprocess/none/index.ts +0 -0
@@ -0,0 +1,47 @@
1
+ // cspell: ignore Libusb
2
+ // cspell: ignore devraw
3
+ // cspell: ignore Openscreen
4
+ // cspell: ignore devicetracker
5
+
6
+ // The order follows
7
+ // https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/adb/transport.cpp;l=81;drc=2d3e62c2af54a3e8f8803ea10492e63b8dfe709f
8
+
9
+ export const Shell2 = "shell_v2";
10
+ export const Cmd = "cmd";
11
+ export const Stat2 = "stat_v2";
12
+ export const Ls2 = "ls_v2";
13
+ /**
14
+ * server only
15
+ */
16
+ export const Libusb = "libusb";
17
+ /**
18
+ * server only
19
+ */
20
+ export const PushSync = "push_sync";
21
+ export const Apex = "apex";
22
+ export const FixedPushMkdir = "fixed_push_mkdir";
23
+ export const Abb = "abb";
24
+ export const FixedPushSymlinkTimestamp = "fixed_push_symlink_timestamp";
25
+ export const AbbExec = "abb_exec";
26
+ export const RemountShell = "remount_shell";
27
+ export const TrackApp = "track_app";
28
+ export const SendReceive2 = "sendrecv_v2";
29
+ export const SendReceive2Brotli = "sendrecv_v2_brotli";
30
+ export const SendReceive2Lz4 = "sendrecv_v2_lz4";
31
+ export const SendReceive2Zstd = "sendrecv_v2_zstd";
32
+ export const SendReceive2DryRunSend = "sendrecv_v2_dry_run_send";
33
+ export const DelayedAck = "delayed_ack";
34
+ /**
35
+ * server only
36
+ */
37
+ export const OpenscreenMdns = "openscreen_mdns";
38
+ /**
39
+ * server only
40
+ */
41
+ export const DeviceTrackerProtoFormat = "devicetracker_proto_format";
42
+ export const DevRaw = "devraw";
43
+ export const AppInfo = "app_info";
44
+ /**
45
+ * server only
46
+ */
47
+ export const ServerStatus = "server_status";
package/src/features.ts CHANGED
@@ -1,15 +1,32 @@
1
- // The order follows
2
- // https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/transport.cpp;l=77;drc=6d14d35d0241f6fee145f8e54ffd77252e8d29fd
3
- export const AdbFeature = {
4
- ShellV2: "shell_v2",
5
- Cmd: "cmd",
6
- StatV2: "stat_v2",
7
- ListV2: "ls_v2",
8
- FixedPushMkdir: "fixed_push_mkdir",
9
- Abb: "abb",
10
- AbbExec: "abb_exec",
11
- SendReceiveV2: "sendrecv_v2",
12
- DelayedAck: "delayed_ack",
13
- } as const;
1
+ import * as AdbFeature from "./features-value.js";
14
2
 
15
- export type AdbFeature = (typeof AdbFeature)[keyof typeof AdbFeature];
3
+ // biome-ignore lint/suspicious/noRedeclare: TypeScript declaration merging for enum-like object
4
+ type AdbFeature = (typeof AdbFeature)[keyof typeof AdbFeature];
5
+
6
+ export { AdbFeature };
7
+
8
+ // https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
9
+ // There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
10
+ export const AdbDeviceFeatures = [
11
+ AdbFeature.Shell2,
12
+ AdbFeature.Cmd,
13
+ AdbFeature.Stat2,
14
+ AdbFeature.Ls2,
15
+ AdbFeature.FixedPushMkdir,
16
+ AdbFeature.Apex,
17
+ AdbFeature.Abb,
18
+ // only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
19
+ // No special handling required.
20
+ AdbFeature.FixedPushSymlinkTimestamp,
21
+ AdbFeature.AbbExec,
22
+ AdbFeature.RemountShell,
23
+ AdbFeature.TrackApp,
24
+ AdbFeature.SendReceive2,
25
+ AdbFeature.SendReceive2Brotli,
26
+ AdbFeature.SendReceive2Lz4,
27
+ AdbFeature.SendReceive2Zstd,
28
+ AdbFeature.SendReceive2DryRunSend,
29
+ AdbFeature.DevRaw,
30
+ AdbFeature.AppInfo,
31
+ AdbFeature.DelayedAck,
32
+ ] as readonly AdbFeature[];
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from "./adb.js";
2
2
  export * from "./banner.js";
3
- export * from "./commands/index.js";
4
3
  export * from "./daemon/index.js";
5
4
  export * from "./device-observer.js";
6
5
  export * from "./features.js";
7
6
  export * from "./server/index.js";
7
+ export * from "./service/index.js";
8
8
  export * from "./utils/index.js";
@@ -1,7 +1,6 @@
1
1
  // cspell:ignore tport
2
2
 
3
3
  import type { MaybePromiseLike } from "@yume-chan/async";
4
- import { PromiseResolver } from "@yume-chan/async";
5
4
  import type { Event } from "@yume-chan/event";
6
5
  import { getUint64LittleEndian } from "@yume-chan/no-data-view";
7
6
  import type {
@@ -11,7 +10,7 @@ import type {
11
10
  } from "@yume-chan/stream-extra";
12
11
  import { AbortController } from "@yume-chan/stream-extra";
13
12
 
14
- import type { AdbIncomingSocketHandler, AdbSocket, Closeable } from "../adb.js";
13
+ import type { Closeable } from "../adb.js";
15
14
  import { Adb } from "../adb.js";
16
15
  import { AdbBanner } from "../banner.js";
17
16
  import type { DeviceObserver as DeviceObserverBase } from "../device-observer.js";
@@ -25,14 +24,53 @@ import {
25
24
  NetworkError as _NetworkError,
26
25
  UnauthorizedError as _UnauthorizedError,
27
26
  } from "./commands/index.js";
27
+ import { AdbServerDataConnection } from "./data-connection.js";
28
28
  import { AdbServerDeviceObserverOwner } from "./observer.js";
29
- import { AdbServerStream } from "./stream.js";
30
29
  import { AdbServerTransport } from "./transport.js";
31
30
 
31
+ const KeyTransportId = " transport_id:";
32
+ const KeyDevice = " device:";
33
+ const KeyModel = " model:";
34
+ const KeyProduct = " product:";
35
+
36
+ function parseDeviceLineItem<
37
+ T extends string = string,
38
+ Optional extends boolean = false,
39
+ >(
40
+ line: string,
41
+ end: number,
42
+ key: string,
43
+ optional?: Optional,
44
+ ): readonly [start: number, value: Optional extends false ? T : T | undefined] {
45
+ const start = line.lastIndexOf(key, end - 1);
46
+ if (start === -1) {
47
+ if (optional) {
48
+ return [end, undefined as never] as const;
49
+ } else {
50
+ throw new Error(`Invalid device line: ${line}`);
51
+ }
52
+ }
53
+ return [start, line.substring(start + key.length, end) as T] as const;
54
+ }
55
+
32
56
  /**
33
57
  * Client for the ADB Server.
34
58
  */
35
59
  export class AdbServerClient {
60
+ // https://android.googlesource.com/platform/packages/modules/adb/+/9f298fb1f3317371b49439efb20a598b3a881bf3/adb.cpp#144
61
+ static ConnectionState = [
62
+ "offline",
63
+ "bootloader",
64
+ "device",
65
+ "host",
66
+ "recovery",
67
+ "rescue",
68
+ "sideload",
69
+ "unauthorized",
70
+ "authorizing",
71
+ "detached",
72
+ ] as const;
73
+
36
74
  static NetworkError = _NetworkError;
37
75
  static UnauthorizedError = _UnauthorizedError;
38
76
  static AlreadyConnectedError = _AlreadyConnectedError;
@@ -50,37 +88,46 @@ export class AdbServerClient {
50
88
  continue;
51
89
  }
52
90
 
53
- const parts = line.split(" ").filter(Boolean);
54
- const serial = parts[0]!;
55
- const state = parts[1]! as AdbServerClient.ConnectionState;
91
+ // Parse backwards because `serial` might contain spaces.
92
+
93
+ let end = line.length;
94
+ let value: string;
95
+
96
+ // transport_id:123
97
+ // eslint-disable-next-line prefer-const
98
+ [end, value] = parseDeviceLineItem(line, end, KeyTransportId);
99
+ const transportId = BigInt(value);
100
+
101
+ // device:abc (optional)
102
+ let device: string | undefined;
103
+ // eslint-disable-next-line prefer-const
104
+ [end, device] = parseDeviceLineItem(line, end, KeyDevice, true);
105
+
106
+ // model:abc (optional)
107
+ let model: string | undefined;
108
+ // eslint-disable-next-line prefer-const
109
+ [end, model] = parseDeviceLineItem(line, end, KeyModel, true);
110
+
111
+ // product:abc (optional)
112
+ let product: string | undefined;
113
+ // eslint-disable-next-line prefer-const
114
+ [end, product] = parseDeviceLineItem(line, end, KeyProduct, true);
115
+
116
+ let state: AdbServerClient.ConnectionState;
117
+ do {
118
+ // devpath or state
119
+ // devpath doesn't have a fixed pattern
120
+ // (for example, libusb driver gives plain strings like `5-1.4`)
121
+ // so keep parsing until we get a valid state
122
+ [end, state] = parseDeviceLineItem(line, end, " ");
123
+ } while (!AdbServerClient.ConnectionState.includes(state));
124
+
56
125
  if (!includeStates.includes(state)) {
57
126
  continue;
58
127
  }
59
128
 
60
- let product: string | undefined;
61
- let model: string | undefined;
62
- let device: string | undefined;
63
- let transportId: bigint | undefined;
64
- for (let i = 2; i < parts.length; i += 1) {
65
- const [key, value] = parts[i]!.split(":");
66
- switch (key) {
67
- case "product":
68
- product = value;
69
- break;
70
- case "model":
71
- model = value;
72
- break;
73
- case "device":
74
- device = value;
75
- break;
76
- case "transport_id":
77
- transportId = BigInt(value!);
78
- break;
79
- }
80
- }
81
- if (!transportId) {
82
- throw new Error(`No transport id for device ${serial}`);
83
- }
129
+ const serial = line.substring(0, end).trim();
130
+
84
131
  devices.push({
85
132
  serial,
86
133
  state,
@@ -129,24 +176,16 @@ export class AdbServerClient {
129
176
  async createConnection(
130
177
  request: string,
131
178
  options?: AdbServerClient.ServerConnectionOptions,
132
- ): Promise<AdbServerStream> {
179
+ ): Promise<AdbServerDataConnection> {
133
180
  const connection = await this.connector.connect(options);
134
- const stream = new AdbServerStream(connection);
135
-
136
- try {
137
- await stream.writeString(request);
138
- } catch (e) {
139
- await stream.dispose();
140
- throw e;
141
- }
181
+ const dataConnection = new AdbServerDataConnection(connection);
142
182
 
143
183
  try {
144
- // `raceSignal` throws when the signal is aborted,
145
- // so the `catch` block can close the connection.
146
- await raceSignal(() => stream.readOkay(), options?.signal);
147
- return stream;
184
+ await dataConnection.writeString(request);
185
+ await dataConnection.readOkay();
186
+ return dataConnection;
148
187
  } catch (e) {
149
- await stream.dispose();
188
+ await dataConnection.dispose();
150
189
  throw e;
151
190
  }
152
191
  }
@@ -271,13 +310,13 @@ export class AdbServerClient {
271
310
  "host:features",
272
311
  );
273
312
  // Luckily `AdbServerClient.Socket` is compatible with `AdbServerClient.ServerConnection`
274
- const stream = new AdbServerStream(connection);
313
+ const dataConnection = new AdbServerDataConnection(connection);
275
314
  try {
276
- const featuresString = await stream.readString();
315
+ const featuresString = await dataConnection.readString();
277
316
  const features = featuresString.split(",") as AdbFeature[];
278
317
  return { transportId: connection.transportId, features };
279
318
  } finally {
280
- await stream.dispose();
319
+ await dataConnection.dispose();
281
320
  }
282
321
  }
283
322
 
@@ -316,12 +355,7 @@ export class AdbServerClient {
316
355
 
317
356
  try {
318
357
  await connection.writeString(service);
319
- } catch (e) {
320
- await connection.dispose();
321
- throw e;
322
- }
323
358
 
324
- try {
325
359
  if (transportId === undefined) {
326
360
  const array = await connection.readExactly(8);
327
361
  transportId = getUint64LittleEndian(array, 0);
@@ -348,17 +382,14 @@ export class AdbServerClient {
348
382
  throw e;
349
383
  }
350
384
  }
385
+
351
386
  async #waitForUnchecked(
352
387
  device: AdbServerClient.DeviceSelector,
353
388
  state: "device" | "disconnect",
354
389
  options?: AdbServerClient.ServerConnectionOptions,
355
390
  ): Promise<void> {
356
391
  let type: string;
357
- if (!device) {
358
- type = "any";
359
- } else if ("transportId" in device) {
360
- type = "any";
361
- } else if ("serial" in device) {
392
+ if (!device || "transportId" in device || "serial" in device) {
362
393
  type = "any";
363
394
  } else if ("usb" in device) {
364
395
  type = "usb";
@@ -425,12 +456,12 @@ export class AdbServerClient {
425
456
  (device) => device.transportId === transportId,
426
457
  )
427
458
  ) {
428
- observer.stop();
459
+ observer.close();
429
460
  resolve();
430
461
  }
431
462
  });
432
463
  observer.onError((e) => {
433
- observer.stop();
464
+ observer.close();
434
465
  reject(e);
435
466
  });
436
467
  });
@@ -483,37 +514,6 @@ export class AdbServerClient {
483
514
  }
484
515
  }
485
516
 
486
- export async function raceSignal<T>(
487
- callback: () => PromiseLike<T>,
488
- ...signals: (AbortSignal | undefined)[]
489
- ): Promise<T> {
490
- const abortPromise = new PromiseResolver<never>();
491
- function abort(this: AbortSignal) {
492
- abortPromise.reject(this.reason);
493
- }
494
-
495
- try {
496
- for (const signal of signals) {
497
- if (!signal) {
498
- continue;
499
- }
500
- if (signal.aborted) {
501
- throw signal.reason;
502
- }
503
- signal.addEventListener("abort", abort);
504
- }
505
-
506
- return await Promise.race([callback(), abortPromise.promise]);
507
- } finally {
508
- for (const signal of signals) {
509
- if (!signal) {
510
- continue;
511
- }
512
- signal.removeEventListener("abort", abort);
513
- }
514
- }
515
- }
516
-
517
517
  export namespace AdbServerClient {
518
518
  export interface ServerConnectionOptions {
519
519
  unref?: boolean | undefined;
@@ -521,7 +521,8 @@ export namespace AdbServerClient {
521
521
  }
522
522
 
523
523
  export interface ServerConnection
524
- extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>,
524
+ extends
525
+ ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>,
525
526
  Closeable {
526
527
  get closed(): Promise<undefined>;
527
528
  }
@@ -532,7 +533,7 @@ export namespace AdbServerClient {
532
533
  ): MaybePromiseLike<ServerConnection>;
533
534
 
534
535
  addReverseTunnel(
535
- handler: AdbIncomingSocketHandler,
536
+ handler: Adb.IncomingSocketHandler,
536
537
  address?: string,
537
538
  ): MaybePromiseLike<string>;
538
539
 
@@ -541,7 +542,7 @@ export namespace AdbServerClient {
541
542
  clearReverseTunnels(): MaybePromiseLike<void>;
542
543
  }
543
544
 
544
- export interface Socket extends AdbSocket {
545
+ export interface Socket extends Adb.Socket {
545
546
  transportId: bigint;
546
547
  }
547
548
 
@@ -555,7 +556,8 @@ export namespace AdbServerClient {
555
556
  | { tcp: true }
556
557
  | undefined;
557
558
 
558
- export type ConnectionState = "unauthorized" | "offline" | "device";
559
+ export type ConnectionState =
560
+ (typeof AdbServerClient.ConnectionState)[number];
559
561
 
560
562
  export interface Device {
561
563
  serial: string;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { hexToNumber, sequenceEqual } from "../../utils/index.js";
4
4
  import type { AdbServerClient } from "../client.js";
5
- import { FAIL } from "../stream.js";
5
+ import { FAIL } from "../data-connection.js";
6
6
 
7
7
  export class NetworkError extends Error {
8
8
  constructor(message: string) {
@@ -19,7 +19,7 @@ import type { AdbServerClient } from "./client.js";
19
19
  const OKAY = encodeUtf8("OKAY");
20
20
  export const FAIL = encodeUtf8("FAIL");
21
21
 
22
- export class AdbServerStream {
22
+ export class AdbServerDataConnection {
23
23
  #connection: AdbServerClient.ServerConnection;
24
24
  #buffered: BufferedReadableStream;
25
25
  #writer: WritableStreamDefaultWriter<Uint8Array>;
@@ -34,7 +34,7 @@ export class AdbServerStream {
34
34
  return this.#buffered.readExactly(length);
35
35
  }
36
36
 
37
- readString = bipedal(function* (this: AdbServerStream, then) {
37
+ readString = bipedal(function* (this: AdbServerDataConnection, then) {
38
38
  const data = yield* then(this.readExactly(4));
39
39
  const length = hexToNumber(data);
40
40
  if (length === 0) {
@@ -93,8 +93,8 @@ export class AdbServerStream {
93
93
  }
94
94
 
95
95
  async dispose() {
96
- void tryCancel(this.#buffered);
97
- void tryClose(this.#writer);
96
+ await tryCancel(this.#buffered);
97
+ await tryClose(this.#writer);
98
98
  await this.#connection.close();
99
99
  }
100
100
  }
@@ -1,4 +1,4 @@
1
1
  export * from "./client.js";
2
+ export * from "./data-connection.js";
2
3
  export * from "./observer.js";
3
- export * from "./stream.js";
4
4
  export * from "./transport.js";
@@ -3,7 +3,7 @@ import { EventEmitter, StickyEventEmitter } from "@yume-chan/event";
3
3
  import { Ref } from "../utils/index.js";
4
4
 
5
5
  import { AdbServerClient } from "./client.js";
6
- import type { AdbServerStream } from "./stream.js";
6
+ import type { AdbServerDataConnection } from "./data-connection.js";
7
7
 
8
8
  export function unorderedRemove<T>(array: T[], index: number) {
9
9
  if (index < 0 || index >= array.length) {
@@ -33,14 +33,14 @@ export class AdbServerDeviceObserverOwner {
33
33
 
34
34
  readonly #client: AdbServerClient;
35
35
 
36
- #stream: Promise<AdbServerStream> | undefined;
36
+ #stream: Promise<AdbServerDataConnection> | undefined;
37
37
  #observers: Observer[] = [];
38
38
 
39
39
  constructor(client: AdbServerClient) {
40
40
  this.#client = client;
41
41
  }
42
42
 
43
- async #receive(stream: AdbServerStream) {
43
+ async #receive(stream: AdbServerDataConnection) {
44
44
  const response = await stream.readString();
45
45
  const next = AdbServerClient.parseDeviceList(response);
46
46
 
@@ -93,7 +93,7 @@ export class AdbServerDeviceObserverOwner {
93
93
  }
94
94
  }
95
95
 
96
- async #receiveLoop(stream: AdbServerStream) {
96
+ async #receiveLoop(stream: AdbServerDataConnection) {
97
97
  try {
98
98
  while (true) {
99
99
  await this.#receive(stream);
@@ -123,10 +123,10 @@ export class AdbServerDeviceObserverOwner {
123
123
  return stream;
124
124
  }
125
125
 
126
- async #handleObserverStop(stream: AdbServerStream) {
126
+ async #handleObserverClose(connection: AdbServerDataConnection) {
127
127
  if (this.#observers.length === 0) {
128
128
  this.#stream = undefined;
129
- await stream.dispose();
129
+ await connection.dispose();
130
130
  }
131
131
  }
132
132
 
@@ -135,7 +135,6 @@ export class AdbServerDeviceObserverOwner {
135
135
  ): Promise<AdbServerClient.DeviceObserver> {
136
136
  options?.signal?.throwIfAborted();
137
137
 
138
- let current: readonly AdbServerClient.Device[] = [];
139
138
  const onDeviceAdd = new EventEmitter<
140
139
  readonly AdbServerClient.Device[]
141
140
  >();
@@ -162,12 +161,9 @@ export class AdbServerDeviceObserverOwner {
162
161
  // So `#handleObserverStop` knows if there is any observer.
163
162
  this.#observers.push(observer);
164
163
 
165
- // Read the filtered `current` value from `onListChange` event
166
- onListChange.event((value) => (current = value));
167
-
168
- let stream: AdbServerStream;
164
+ let stream: AdbServerDataConnection;
169
165
  if (!this.#stream) {
170
- // `#connect` will initialize `onListChange` and `current`
166
+ // `#connect` will initialize `onListChange`
171
167
  this.#stream = this.#connect();
172
168
 
173
169
  try {
@@ -178,25 +174,31 @@ export class AdbServerDeviceObserverOwner {
178
174
  }
179
175
  } else {
180
176
  stream = await this.#stream;
181
- // Initialize `onListChange` and `current` ourselves
177
+ // Initialize `onListChange` ourselves
182
178
  onListChange.fire(filterDeviceStates(this.current, includeStates));
183
179
  }
184
180
 
185
181
  const ref = new Ref(options);
186
182
 
187
- const stop = async () => {
183
+ const close = async () => {
184
+ onDeviceAdd.dispose();
185
+ onDeviceRemove.dispose();
186
+ onListChange.dispose();
187
+ onError.dispose();
188
+
188
189
  unorderedRemove(this.#observers, this.#observers.indexOf(observer));
189
- await this.#handleObserverStop(stream);
190
+ await this.#handleObserverClose(stream);
191
+
190
192
  ref.unref();
191
193
  };
192
194
 
193
195
  if (options?.signal) {
194
196
  if (options.signal.aborted) {
195
- await stop();
197
+ await close();
196
198
  throw options.signal.reason;
197
199
  }
198
200
 
199
- options.signal.addEventListener("abort", () => void stop());
201
+ options.signal.addEventListener("abort", () => void close());
200
202
  }
201
203
 
202
204
  return {
@@ -205,9 +207,9 @@ export class AdbServerDeviceObserverOwner {
205
207
  onListChange: onListChange.event,
206
208
  onError: onError.event,
207
209
  get current() {
208
- return current;
210
+ return onListChange.value;
209
211
  },
210
- stop,
212
+ close,
211
213
  };
212
214
  }
213
215
  }
@@ -1,37 +1,11 @@
1
1
  import { PromiseResolver } from "@yume-chan/async";
2
2
 
3
- import type {
4
- AdbIncomingSocketHandler,
5
- AdbSocket,
6
- AdbTransport,
7
- } from "../adb.js";
3
+ import type { Adb, AdbTransport } from "../adb.js";
8
4
  import type { AdbBanner } from "../banner.js";
9
- import { AdbFeature } from "../features.js";
5
+ import { AdbDeviceFeatures } from "../features.js";
10
6
 
11
7
  import type { AdbServerClient } from "./client.js";
12
8
 
13
- export const ADB_SERVER_DEFAULT_FEATURES = /* #__PURE__ */ (() =>
14
- [
15
- AdbFeature.ShellV2,
16
- AdbFeature.Cmd,
17
- AdbFeature.StatV2,
18
- AdbFeature.ListV2,
19
- AdbFeature.FixedPushMkdir,
20
- "apex",
21
- AdbFeature.Abb,
22
- // only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
23
- // No special handling required.
24
- "fixed_push_symlink_timestamp",
25
- AdbFeature.AbbExec,
26
- "remount_shell",
27
- "track_app",
28
- AdbFeature.SendReceiveV2,
29
- "sendrecv_v2_brotli",
30
- "sendrecv_v2_lz4",
31
- "sendrecv_v2_zstd",
32
- "sendrecv_v2_dry_run_send",
33
- ] as readonly AdbFeature[])();
34
-
35
9
  export class AdbServerTransport implements AdbTransport {
36
10
  #client: AdbServerClient;
37
11
 
@@ -43,7 +17,7 @@ export class AdbServerTransport implements AdbTransport {
43
17
 
44
18
  readonly banner: AdbBanner;
45
19
 
46
- #sockets: AdbSocket[] = [];
20
+ #sockets: Adb.Socket[] = [];
47
21
 
48
22
  #closed = new PromiseResolver<void>();
49
23
  #disconnected: Promise<void>;
@@ -52,9 +26,14 @@ export class AdbServerTransport implements AdbTransport {
52
26
  }
53
27
 
54
28
  get clientFeatures() {
55
- // No need to get host features (features supported by ADB server)
56
- // Because we create all ADB packets ourselves
57
- return ADB_SERVER_DEFAULT_FEATURES;
29
+ // This list tells the `Adb` instance how to invoke some commands.
30
+ //
31
+ // Because all device commands are created by the `Adb` instance, not ADB server,
32
+ // we don't need to fetch current server's feature list using `host-features` command.
33
+ //
34
+ // And because all server commands are created by the `AdbServerClient` instance, not `Adb`,
35
+ // we don't need to pass server-only features to `Adb` in this list.
36
+ return AdbDeviceFeatures;
58
37
  }
59
38
 
60
39
  // eslint-disable-next-line @typescript-eslint/max-params
@@ -73,7 +52,7 @@ export class AdbServerTransport implements AdbTransport {
73
52
  this.#disconnected = Promise.race([this.#closed.promise, disconnected]);
74
53
  }
75
54
 
76
- async connect(service: string): Promise<AdbSocket> {
55
+ async connect(service: string): Promise<Adb.Socket> {
77
56
  const socket = await this.#client.createDeviceConnection(
78
57
  { transportId: this.transportId },
79
58
  service,
@@ -83,7 +62,7 @@ export class AdbServerTransport implements AdbTransport {
83
62
  }
84
63
 
85
64
  async addReverseTunnel(
86
- handler: AdbIncomingSocketHandler,
65
+ handler: Adb.IncomingSocketHandler,
87
66
  address?: string,
88
67
  ): Promise<string> {
89
68
  return await this.#client.connector.addReverseTunnel(handler, address);
@@ -1,7 +1,6 @@
1
- export * from "./base.js";
2
1
  export * from "./framebuffer.js";
3
2
  export * from "./power.js";
4
- export * from "./reverse.js";
3
+ export * from "./reverse/index.js";
5
4
  export * from "./subprocess/index.js";
6
5
  export * from "./sync/index.js";
7
6
  export * from "./tcpip.js";