@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,170 @@
1
+ import { AdbFeature } from "../../features.js";
2
+ import { escapeArg } from "../subprocess/index.js";
3
+ import { Compression } from "./compression/index.js";
4
+ import { OpenDir, Receive, Send, Stat } from "./request/index.js";
5
+ import { SocketPool } from "./socket-pool.js";
6
+ import { Error as AdbSyncError } from "./socket.js";
7
+ /**
8
+ * A simplified `dirname` function that only handles absolute unix paths.
9
+ * @param path an absolute unix path
10
+ * @returns the directory name of the input path
11
+ */
12
+ export function dirname(path) {
13
+ const end = path.lastIndexOf("/");
14
+ if (end === -1) {
15
+ throw new Error(`Invalid absolute unix path: ${path}`);
16
+ }
17
+ if (end === 0) {
18
+ return "/";
19
+ }
20
+ return path.substring(0, end);
21
+ }
22
+ export class Service {
23
+ _adb;
24
+ #socketPool;
25
+ #supportsStat2;
26
+ #supportsLs2;
27
+ #fixedPushMkdir;
28
+ #supportsSendReceive2;
29
+ #needPushMkdirWorkaround;
30
+ get supportsStat2() {
31
+ return this.#supportsStat2;
32
+ }
33
+ get supportsLs2() {
34
+ return this.#supportsLs2;
35
+ }
36
+ get fixedPushMkdir() {
37
+ return this.#fixedPushMkdir;
38
+ }
39
+ get supportsSendReceive2() {
40
+ return this.#supportsSendReceive2;
41
+ }
42
+ get needPushMkdirWorkaround() {
43
+ return this.#needPushMkdirWorkaround;
44
+ }
45
+ constructor(adb, options) {
46
+ this._adb = adb;
47
+ this.#socketPool = new SocketPool(adb, options?.maxPoolSize, options?.idleTimeout);
48
+ // Dispose the socket pool when the abort signal is triggered
49
+ options?.signal?.addEventListener("abort", () => {
50
+ void this.#socketPool.dispose();
51
+ });
52
+ this.#supportsStat2 = adb.canUseFeature(AdbFeature.Stat2);
53
+ this.#supportsLs2 = adb.canUseFeature(AdbFeature.Ls2);
54
+ this.#fixedPushMkdir = adb.canUseFeature(AdbFeature.FixedPushMkdir);
55
+ this.#supportsSendReceive2 = adb.canUseFeature(AdbFeature.SendReceive2);
56
+ // https://android.googlesource.com/platform/packages/modules/adb/+/91768a57b7138166e0a3d11f79cd55909dda7014/client/file_sync_client.cpp#1361
57
+ this.#needPushMkdirWorkaround =
58
+ this._adb.canUseFeature(AdbFeature.Shell2) && !this.fixedPushMkdir;
59
+ }
60
+ /**
61
+ * Acquires a socket from the pool for direct use.
62
+ *
63
+ * The socket must be returned to the pool using {@link releaseSocket} after use.
64
+ *
65
+ * @returns A socket from the pool
66
+ */
67
+ async acquireSocket() {
68
+ return await this.#socketPool.acquire();
69
+ }
70
+ /**
71
+ * Returns a socket to the pool after use.
72
+ *
73
+ * @param socket The socket to return to the pool
74
+ * @param discard Whether to discard the socket instead of returning it to the pool
75
+ */
76
+ async releaseSocket(socket, discard = false) {
77
+ await this.#socketPool.release(socket, discard);
78
+ }
79
+ /**
80
+ * Gets information of a file or folder.
81
+ *
82
+ * If `path` points to a symbolic link, the returned information is about the link itself (with `type` being `LinuxFileType.Link`).
83
+ */
84
+ lstat(path) {
85
+ return Stat.lstat(this.#socketPool, path, {
86
+ version: this.#supportsStat2 ? 2 : 1,
87
+ });
88
+ }
89
+ /**
90
+ * Gets the information of a file or folder.
91
+ *
92
+ * If `path` points to a symbolic link, it will be resolved and the returned information is about the target (with `type` being `LinuxFileType.File` or `LinuxFileType.Directory`).
93
+ */
94
+ stat(path) {
95
+ if (!this.#supportsStat2) {
96
+ throw new Error("Not supported");
97
+ }
98
+ return Stat.stat(this.#socketPool, path);
99
+ }
100
+ /**
101
+ * Checks if `path` is a directory, or a symbolic link to a directory.
102
+ *
103
+ * This uses `lstat` internally, thus works on all Android versions.
104
+ */
105
+ async isDirectory(path) {
106
+ try {
107
+ await this.lstat(path + "/");
108
+ return true;
109
+ }
110
+ catch (e) {
111
+ if (e instanceof AdbSyncError) {
112
+ return false;
113
+ }
114
+ else {
115
+ throw e;
116
+ }
117
+ }
118
+ }
119
+ opendir(path) {
120
+ return OpenDir.opendir(this.#socketPool, path, {
121
+ version: this.supportsLs2 ? 2 : 1,
122
+ });
123
+ }
124
+ async readdir(path) {
125
+ // TODO: Convert to `Array.fromAsync`
126
+ const results = [];
127
+ for await (const entry of this.opendir(path)) {
128
+ results.push(entry);
129
+ }
130
+ return results;
131
+ }
132
+ /**
133
+ * Reads the content of a file on device.
134
+ *
135
+ * @param filename The full path of the file on device to read.
136
+ * @returns A `ReadableStream` that contains the file content.
137
+ */
138
+ read(filename) {
139
+ return Receive.stream(this.#socketPool, filename);
140
+ }
141
+ /**
142
+ * Writes a file on device. If the file name already exists, it will be overwritten.
143
+ *
144
+ * @param options The content and options of the file to write.
145
+ */
146
+ async write(options) {
147
+ if (this.needPushMkdirWorkaround) {
148
+ // It may fail if `filename` already exists.
149
+ // Ignore the result.
150
+ // TODO: sync: test push mkdir workaround (need an Android 8 device)
151
+ await this._adb.subprocess.noneProtocol
152
+ .spawn(["mkdir", "-p", escapeArg(dirname(options.filename))])
153
+ .wait();
154
+ }
155
+ if (this.supportsSendReceive2) {
156
+ if (options.compression === undefined) {
157
+ options.compression = Compression.chooseFormat(this._adb, Compression.Mode.Compress);
158
+ }
159
+ else if (!Compression.canUseFormat(this._adb, options.compression, Compression.Mode.Compress)) {
160
+ throw new Error(`Compression type ${options.compression} is not supported`);
161
+ }
162
+ }
163
+ await Send.send({
164
+ version: this.supportsSendReceive2 ? 2 : 1,
165
+ pool: this.#socketPool,
166
+ ...options,
167
+ });
168
+ }
169
+ }
170
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/service/sync/service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAuBpD;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,I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AAI,CAAC,IAAI,EACT,WAAW,CAAC,IAAI,CAAC,QAAQ,CAC5B,CAAC;YACN,CAAC;iBAAM,IACH,CAAC,WAAW,CAAC,YAAY,CACrB,IAAI,CAAC,IAAI,EACT,OAAO,CAAC,WAAW,EACnB,WAAW,CAAC,IAAI,CAAC,QAAQ,CAC5B,EACH,CAAC;gBACC,MAAM,IAAI,KAAK,CACX,oBAAoB,OAAO,CAAC,WAAW,mBAAmB,CAC7D,CAAC;YACN,CAAC;QACL,CAAC;QAED,MAAM,IAAI,CAAC,IAAI,CAAC;YACZ,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,GAAG,OAAO;SACb,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,11 @@
1
+ import type { Adb } from "../../adb.js";
2
+ import { Socket } from "./socket.js";
3
+ export declare class SocketPool {
4
+ #private;
5
+ constructor(adb: Adb, maxSize?: number, idleTimeout?: number);
6
+ acquire(): Promise<Socket>;
7
+ withSocket<T>(fn: (socket: Socket) => Promise<T>): Promise<T>;
8
+ release(socket: Socket, discard?: boolean): Promise<void>;
9
+ dispose(): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=socket-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-pool.d.ts","sourceRoot":"","sources":["../../../src/service/sync/socket-pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAyB,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,UAAU;;gBAQP,GAAG,EAAE,GAAG,EAAE,OAAO,SAAI,EAAE,WAAW,SAAQ;IAMhD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAwB1B,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAY7D,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBvD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAiBjC"}
@@ -0,0 +1,80 @@
1
+ import { Error as AdbSyncError, Socket } from "./socket.js";
2
+ export class SocketPool {
3
+ #adb;
4
+ #maxSize;
5
+ #idleTimeout;
6
+ #availableSockets = [];
7
+ #inUseSockets = new Set();
8
+ #closed = false;
9
+ constructor(adb, maxSize = 4, idleTimeout = 60000) {
10
+ this.#adb = adb;
11
+ this.#maxSize = maxSize;
12
+ this.#idleTimeout = idleTimeout;
13
+ }
14
+ async acquire() {
15
+ if (this.#closed) {
16
+ throw new Error("SocketPool is closed");
17
+ }
18
+ // Try to reuse an available socket
19
+ if (this.#availableSockets.length > 0) {
20
+ const socket = this.#availableSockets.pop();
21
+ // Clear the idle timeout
22
+ socket.clearIdleTimer();
23
+ this.#inUseSockets.add(socket);
24
+ return socket;
25
+ }
26
+ // Create a new socket
27
+ const adbSocket = await this.#adb.createSocket("sync:");
28
+ if (this.#closed) {
29
+ await adbSocket.close();
30
+ throw new Error("SocketPool is closed");
31
+ }
32
+ const socket = new Socket(adbSocket, this.#adb.maxPayloadSize);
33
+ this.#inUseSockets.add(socket);
34
+ return socket;
35
+ }
36
+ async withSocket(fn) {
37
+ const socket = await this.acquire();
38
+ try {
39
+ const result = await fn(socket);
40
+ await this.release(socket);
41
+ return result;
42
+ }
43
+ catch (e) {
44
+ await this.release(socket, !(e instanceof AdbSyncError));
45
+ throw e;
46
+ }
47
+ }
48
+ async release(socket, discard = false) {
49
+ this.#inUseSockets.delete(socket);
50
+ // If discarding or we already have enough sockets in the pool, close this socket
51
+ if (discard || this.#availableSockets.length >= this.#maxSize) {
52
+ await socket.close();
53
+ return;
54
+ }
55
+ // Otherwise, return it to the pool and start idle timeout
56
+ socket.startIdleTimer(this.#idleTimeout, () => {
57
+ this.#closeIdleSocket(socket);
58
+ });
59
+ this.#availableSockets.push(socket);
60
+ }
61
+ #closeIdleSocket(socket) {
62
+ // Remove from available sockets
63
+ const index = this.#availableSockets.indexOf(socket);
64
+ if (index !== -1) {
65
+ this.#availableSockets.splice(index, 1);
66
+ void socket.close();
67
+ }
68
+ }
69
+ async dispose() {
70
+ this.#closed = true;
71
+ // Close all available sockets
72
+ const closePromises = this.#availableSockets.map((socket) => socket.close());
73
+ this.#availableSockets.length = 0;
74
+ // Force close all in-use sockets immediately
75
+ const inUseClosePromises = Array.from(this.#inUseSockets).map((socket) => socket.close());
76
+ this.#inUseSockets.clear();
77
+ await Promise.all([...closePromises, ...inUseClosePromises]);
78
+ }
79
+ }
80
+ //# sourceMappingURL=socket-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-pool.js","sourceRoot":"","sources":["../../../src/service/sync/socket-pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,OAAO,UAAU;IACV,IAAI,CAAM;IACV,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,iBAAiB,GAAa,EAAE,CAAC;IACjC,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3C,OAAO,GAAG,KAAK,CAAC;IAEhB,YAAY,GAAQ,EAAE,OAAO,GAAG,CAAC,EAAE,WAAW,GAAG,KAAK;QAClD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC5C,CAAC;QACD,mCAAmC;QACnC,IAAI,IAAI,CAAC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MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,kBAAkB,CAAC,CAAC,CAAC;IACjE,CAAC;CACJ"}
@@ -0,0 +1,40 @@
1
+ import type { AsyncExactReadable, StructDeserializer } from "@yume-chan/struct";
2
+ import type { Adb } from "../../adb.js";
3
+ declare class AdbSyncError extends Error {
4
+ }
5
+ export { AdbSyncError as Error };
6
+ export declare class Socket implements AsyncExactReadable {
7
+ #private;
8
+ static readonly NumberRequest: import("@yume-chan/struct").Struct<{
9
+ id: import("@yume-chan/struct").NumberField<number>;
10
+ arg: import("@yume-chan/struct").NumberField<number>;
11
+ }, undefined, import("@yume-chan/struct").FieldsValue<{
12
+ id: import("@yume-chan/struct").NumberField<number>;
13
+ arg: import("@yume-chan/struct").NumberField<number>;
14
+ }>>;
15
+ static readonly FailResponse: import("@yume-chan/struct").Struct<{
16
+ message: import("@yume-chan/struct").Field<string, string, never, string>;
17
+ }, undefined, never>;
18
+ get position(): number;
19
+ get closed(): Promise<undefined>;
20
+ constructor(socket: Adb.Socket, bufferSize: number);
21
+ /**
22
+ * Start an idle timer that will close the socket after the specified duration.
23
+ * The timer is automatically cancelled when the socket is used.
24
+ * @param timeout The timeout in milliseconds
25
+ * @param callback The callback to invoke when the timeout expires
26
+ */
27
+ startIdleTimer(timeout: number, callback: () => void): void;
28
+ /**
29
+ * Clear the idle timer.
30
+ */
31
+ clearIdleTimer(): void;
32
+ flush(): Promise<void>;
33
+ write(data: Uint8Array): Promise<void>;
34
+ writeRequest(id: number, value: number | string | Uint8Array): Promise<void>;
35
+ readExactly(length: number): Promise<Uint8Array<ArrayBufferLike>>;
36
+ readResponse<T>(id: number, type: StructDeserializer<T>): Promise<T>;
37
+ readResponses<T>(expectedId: number, type: StructDeserializer<T>): AsyncGenerator<T, void, void>;
38
+ close(): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../../src/service/sync/socket.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOxC,cAAM,YAAa,SAAQ,KAAK;CAAG;AACnC,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,CAAC;AAgBjC,qBAAa,MAAO,YAAW,kBAAkB;;IAC7C,MAAM,CAAC,QAAQ,CAAC,aAAa;;;;;;QAAiB;IAC9C,MAAM,CAAC,QAAQ,CAAC,YAAY;;yBAAgB;IAS5C,IAAI,QAAQ,WAEX;IAED,IAAI,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAE/B;gBAEW,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM;IAOlD;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;IAKpD;;OAEG;IACH,cAAc;IAyBR,KAAK;IAaX,KAAK,CAAC,IAAI,EAAE,UAAU;IAIhB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU;IAkB5D,WAAW,CAAC,MAAM,EAAE,MAAM;IAO1B,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAgBtD,aAAa,CAAC,CAAC,EAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC5B,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;IA6B1B,KAAK;CAKd"}
@@ -0,0 +1,153 @@
1
+ import { getUint32LittleEndian } from "@yume-chan/no-data-view";
2
+ import { BufferCombiner, BufferedReadableStream, clearTimeout, Consumable, setTimeout, tryCancel, } from "@yume-chan/stream-extra";
3
+ import { decodeUtf8, string, struct, u32 } from "@yume-chan/struct";
4
+ import { AutoResetEvent, encodeUtf8, unreachable } from "../../utils/index.js";
5
+ import { ResponseId } from "./id/index.js";
6
+ const NumberRequest = struct({ id: u32, arg: u32 }, { littleEndian: true });
7
+ class AdbSyncError extends Error {
8
+ }
9
+ export { AdbSyncError as Error };
10
+ const FailResponse = struct({ message: string(u32) }, {
11
+ littleEndian: true,
12
+ postDeserialize(value) {
13
+ throw new AdbSyncError(value.message);
14
+ },
15
+ });
16
+ function i32ToHex(i) {
17
+ return "0x" + i.toString(16).padStart(8, "0");
18
+ }
19
+ export class Socket {
20
+ static NumberRequest = NumberRequest;
21
+ static FailResponse = FailResponse;
22
+ #socket;
23
+ #writer;
24
+ #readable;
25
+ #writeLock = new AutoResetEvent();
26
+ #combiner;
27
+ #idleTimeoutId = null;
28
+ get position() {
29
+ return this.#readable.position;
30
+ }
31
+ get closed() {
32
+ return this.#socket.closed;
33
+ }
34
+ constructor(socket, bufferSize) {
35
+ this.#socket = socket;
36
+ this.#writer = socket.writable.getWriter();
37
+ this.#readable = new BufferedReadableStream(socket.readable);
38
+ this.#combiner = new BufferCombiner(bufferSize);
39
+ }
40
+ /**
41
+ * Start an idle timer that will close the socket after the specified duration.
42
+ * The timer is automatically cancelled when the socket is used.
43
+ * @param timeout The timeout in milliseconds
44
+ * @param callback The callback to invoke when the timeout expires
45
+ */
46
+ startIdleTimer(timeout, callback) {
47
+ this.clearIdleTimer();
48
+ this.#idleTimeoutId = setTimeout(callback, timeout);
49
+ }
50
+ /**
51
+ * Clear the idle timer.
52
+ */
53
+ clearIdleTimer() {
54
+ if (this.#idleTimeoutId !== null) {
55
+ clearTimeout(this.#idleTimeoutId);
56
+ this.#idleTimeoutId = null;
57
+ }
58
+ }
59
+ /**
60
+ * Write a packet to the socket.
61
+ * @param packet The packet to write. Must be smaller than the buffer size.
62
+ */
63
+ #writeOne(packet) {
64
+ // `#combiner` will reuse the buffer, so we need to use the Consumable pattern
65
+ return Consumable.WritableStream.write(this.#writer, packet);
66
+ }
67
+ async #withWriteLock(callback) {
68
+ try {
69
+ await this.#writeLock.wait();
70
+ await callback();
71
+ }
72
+ finally {
73
+ this.#writeLock.notifyOne();
74
+ }
75
+ }
76
+ async flush() {
77
+ const buffer = this.#combiner.flush();
78
+ if (buffer) {
79
+ await this.#withWriteLock(() => this.#writeOne(buffer));
80
+ }
81
+ }
82
+ async #write(data) {
83
+ for (const buffer of this.#combiner.push(data)) {
84
+ await this.#writeOne(buffer);
85
+ }
86
+ }
87
+ write(data) {
88
+ return this.#withWriteLock(() => this.#write(data));
89
+ }
90
+ async writeRequest(id, value) {
91
+ return this.#withWriteLock(async () => {
92
+ if (typeof value === "number") {
93
+ await this.#write(NumberRequest.serialize({ id, arg: value }));
94
+ return;
95
+ }
96
+ if (typeof value === "string") {
97
+ value = encodeUtf8(value);
98
+ }
99
+ await this.#write(NumberRequest.serialize({ id, arg: value.length }));
100
+ await this.#write(value);
101
+ });
102
+ }
103
+ async readExactly(length) {
104
+ // The request may still be in the internal buffer.
105
+ // Call `flush` to send it before starting reading
106
+ await this.flush();
107
+ return await this.#readable.readExactly(length);
108
+ }
109
+ async readResponse(id, type) {
110
+ const buffer = await this.readExactly(4);
111
+ switch (getUint32LittleEndian(buffer, 0)) {
112
+ case ResponseId.Fail:
113
+ await FailResponse.deserialize(this.#readable);
114
+ unreachable();
115
+ case id:
116
+ return await type.deserialize(this.#readable);
117
+ default:
118
+ // non-recoverable
119
+ throw new Error(`Expected '${id}', but got '${decodeUtf8(buffer)}'`);
120
+ }
121
+ }
122
+ async *readResponses(expectedId, type) {
123
+ await this.flush();
124
+ while (true) {
125
+ const buffer = await this.#readable.readExactly(4);
126
+ const actualId = getUint32LittleEndian(buffer, 0);
127
+ switch (actualId) {
128
+ case ResponseId.Fail:
129
+ await FailResponse.deserialize(this.#readable);
130
+ unreachable();
131
+ case ResponseId.Done:
132
+ // `DONE` responses' size are always same as the request's normal response.
133
+ //
134
+ // For example, `DONE` responses for `LIST` requests are 16 bytes (same as `DENT` responses),
135
+ // but `DONE` responses for `STAT` requests are 12 bytes (same as `STAT` responses).
136
+ await this.#readable.readExactly(type.size);
137
+ return;
138
+ case expectedId:
139
+ yield await type.deserialize(this.#readable);
140
+ break;
141
+ default:
142
+ // non-recoverable
143
+ throw new Error(`Expected ${i32ToHex(expectedId)} or ${i32ToHex(ResponseId.Done)}, but got ${i32ToHex(actualId)}`);
144
+ }
145
+ }
146
+ }
147
+ async close() {
148
+ this.clearIdleTimer();
149
+ await tryCancel(this.#readable);
150
+ await this.#socket.close();
151
+ }
152
+ }
153
+ //# sourceMappingURL=socket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/service/sync/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,OAAO,EACH,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,GACZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;AAE5E,MAAM,YAAa,SAAQ,KAAK;CAAG;AACnC,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,CAAC;AAEjC,MAAM,YAAY,GAAG,MAAM,CACvB,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,EACxB;IACI,YAAY,EAAE,IAAI;IAClB,eAAe,CAAC,KAAK;Q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ChB,UAAkB,EAClB,IAA2B;QAE3B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QAEnB,OAAO,IAAI,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACnD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAClD,QAAQ,QAAQ,EAAE,CAAC;gBACf,KAAK,UAAU,CAAC,IAAI;oBAChB,MAAM,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC/C,WAAW,EAAE,CAAC;gBAClB,KAAK,UAAU,CAAC,IAAI;oBAChB,2EAA2E;oBAC3E,EAAE;oBACF,6FAA6F;oBAC7F,oFAAoF;oBACpF,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAC5C,OAAO;gBACX,KAAK,UAAU;oBACX,MAAM,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC7C,MAAM;gBACV;oBACI,kBAAkB;oBAClB,MAAM,IAAI,KAAK,CACX,YAAY,QAAQ,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,QAAQ,CAAC,QAAQ,CAAC,EAAE,CACpG,CAAC;YACV,CAAC;QACL,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { AdbServiceBase } from "./base.js";
1
+ import type { Adb } from "../adb.js";
2
2
  /**
3
3
  * ADB daemon checks for the following properties in the order of
4
4
  *
@@ -18,7 +18,9 @@ export interface AdbTcpIpListenAddresses {
18
18
  servicePort: number | undefined;
19
19
  persistPort: number | undefined;
20
20
  }
21
- export declare class AdbTcpIpService extends AdbServiceBase {
21
+ export declare class AdbTcpIpService {
22
+ #private;
23
+ constructor(adb: Adb);
22
24
  getListenAddresses(): Promise<AdbTcpIpListenAddresses>;
23
25
  setPort(port: number): Promise<string>;
24
26
  disable(): Promise<string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcpip.d.ts","sourceRoot":"","sources":["../../src/service/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,uBAAuB;IACpC,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AASD,qBAAa,eAAe;;gBAGZ,GAAG,EAAE,GAAG;IAId,kBAAkB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAiBtD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYtC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAOnC"}
@@ -1,15 +1,18 @@
1
- import { AdbServiceBase } from "./base.js";
2
1
  function parsePort(value) {
3
2
  if (!value || value === "0") {
4
3
  return undefined;
5
4
  }
6
5
  return Number.parseInt(value, 10);
7
6
  }
8
- export class AdbTcpIpService extends AdbServiceBase {
7
+ export class AdbTcpIpService {
8
+ #adb;
9
+ constructor(adb) {
10
+ this.#adb = adb;
11
+ }
9
12
  async getListenAddresses() {
10
- const serviceListenAddresses = await this.adb.getProp("service.adb.listen_addrs");
11
- const servicePort = await this.adb.getProp("service.adb.tcp.port");
12
- const persistPort = await this.adb.getProp("persist.adb.tcp.port");
13
+ const serviceListenAddresses = await this.#adb.getProp("service.adb.listen_addrs");
14
+ const servicePort = await this.#adb.getProp("service.adb.tcp.port");
15
+ const persistPort = await this.#adb.getProp("persist.adb.tcp.port");
13
16
  return {
14
17
  serviceListenAddresses: serviceListenAddresses != ""
15
18
  ? serviceListenAddresses.split(",")
@@ -22,14 +25,14 @@ export class AdbTcpIpService extends AdbServiceBase {
22
25
  if (port <= 0) {
23
26
  throw new TypeError(`Invalid port ${port}`);
24
27
  }
25
- const output = await this.adb.createSocketAndWait(`tcpip:${port}`);
28
+ const output = await this.#adb.createSocketAndWait(`tcpip:${port}`);
26
29
  if (output !== `restarting in TCP mode port: ${port}\n`) {
27
30
  throw new Error(output);
28
31
  }
29
32
  return output;
30
33
  }
31
34
  async disable() {
32
- const output = await this.adb.createSocketAndWait("usb:");
35
+ const output = await this.#adb.createSocketAndWait("usb:");
33
36
  if (output !== "restarting in USB mode\n") {
34
37
  throw new Error(output);
35
38
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcpip.js","sourceRoot":"","sources":["../../src/service/tcpip.ts"],"names":[],"mappings":"AAsBA,SAAS,SAAS,CAAC,KAAa;IAC5B,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,OAAO,eAAe;IACf,IAAI,CAAM;IAEnB,YAAY,GAAQ;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACpB,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAClD,0BAA0B,CAC7B,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACpE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAEpE,OAAO;YACH,sBAAsB,EAClB,sBAAsB,IAAI,EAAE;gBACxB,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC;gBACnC,CAAC,CAAC,EAAE;YACZ,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC;YACnC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC;SACtC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY;QACtB,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,SAAS,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACpE,IAAI,MAAM,KAAK,gCAAgC,IAAI,IAAI,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAI,MAAM,KAAK,0BAA0B,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"array-buffer.d.ts","sourceRoot":"","sources":["../../src/utils/array-buffer.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAQ5E"}
1
+ {"version":3,"file":"array-buffer.d.ts","sourceRoot":"","sources":["../../src/utils/array-buffer.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAO5E"}
@@ -2,8 +2,7 @@ export function toLocalUint8Array(value) {
2
2
  if (value.buffer instanceof ArrayBuffer) {
3
3
  return value;
4
4
  }
5
- const copy = new Uint8Array(value.length);
6
- copy.set(value);
7
- return copy;
5
+ // This invokes the `constructor(Iterable<number>)` overload and copies the data
6
+ return new Uint8Array(value);
8
7
  }
9
8
  //# sourceMappingURL=array-buffer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"array-buffer.js","sourceRoot":"","sources":["../../src/utils/array-buffer.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IAC/C,IAAI,KAAK,CAAC,MAAM,YAAY,WAAW,EAAE,CAAC;QACtC,OAAO,KAAgC,CAAC;IAC5C,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,IAAI,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"array-buffer.js","sourceRoot":"","sources":["../../src/utils/array-buffer.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IAC/C,IAAI,KAAK,CAAC,MAAM,YAAY,WAAW,EAAE,CAAC;QACtC,OAAO,KAAgC,CAAC;IAC5C,CAAC;IAED,gFAAgF;IAChF,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,MAAM,GACpB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAI/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AACzE;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;AA4O5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CA4DnE"}
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,MAAM,GACpB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAI/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AACzE;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;AAmP5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAiEnE"}