@yume-chan/adb 2.6.2 → 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 (451) 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/banner.js.map +1 -1
  10. package/esm/daemon/auth/authenticator.d.ts +28 -0
  11. package/esm/daemon/auth/authenticator.d.ts.map +1 -0
  12. package/esm/daemon/auth/authenticator.js +108 -0
  13. package/esm/daemon/auth/authenticator.js.map +1 -0
  14. package/esm/daemon/auth/index.d.ts +5 -0
  15. package/esm/daemon/auth/index.d.ts.map +1 -0
  16. package/esm/daemon/auth/index.js +5 -0
  17. package/esm/daemon/auth/index.js.map +1 -0
  18. package/esm/daemon/auth/packet-processor.d.ts +42 -0
  19. package/esm/daemon/auth/packet-processor.d.ts.map +1 -0
  20. package/esm/daemon/auth/packet-processor.js +129 -0
  21. package/esm/daemon/auth/packet-processor.js.map +1 -0
  22. package/esm/daemon/auth/public-key.d.ts +8 -0
  23. package/esm/daemon/auth/public-key.d.ts.map +1 -0
  24. package/esm/daemon/auth/public-key.js +74 -0
  25. package/esm/daemon/auth/public-key.js.map +1 -0
  26. package/esm/daemon/auth/type.d.ts +5 -0
  27. package/esm/daemon/auth/type.d.ts.map +1 -0
  28. package/esm/daemon/auth/type.js +2 -0
  29. package/esm/daemon/auth/type.js.map +1 -0
  30. package/esm/daemon/crypto.d.ts +6 -5
  31. package/esm/daemon/crypto.d.ts.map +1 -1
  32. package/esm/daemon/crypto.js +23 -72
  33. package/esm/daemon/crypto.js.map +1 -1
  34. package/esm/daemon/dispatcher.d.ts +3 -3
  35. package/esm/daemon/dispatcher.d.ts.map +1 -1
  36. package/esm/daemon/dispatcher.js +11 -4
  37. package/esm/daemon/dispatcher.js.map +1 -1
  38. package/esm/daemon/index.d.ts +1 -1
  39. package/esm/daemon/index.d.ts.map +1 -1
  40. package/esm/daemon/index.js +1 -1
  41. package/esm/daemon/index.js.map +1 -1
  42. package/esm/daemon/socket.d.ts +3 -3
  43. package/esm/daemon/socket.d.ts.map +1 -1
  44. package/esm/daemon/transport.d.ts +13 -65
  45. package/esm/daemon/transport.d.ts.map +1 -1
  46. package/esm/daemon/transport.js +18 -140
  47. package/esm/daemon/transport.js.map +1 -1
  48. package/esm/device-observer.d.ts +2 -3
  49. package/esm/device-observer.d.ts.map +1 -1
  50. package/esm/features-value.d.ts +40 -0
  51. package/esm/features-value.d.ts.map +1 -0
  52. package/esm/features-value.js +46 -0
  53. package/esm/features-value.js.map +1 -0
  54. package/esm/features.d.ts +4 -12
  55. package/esm/features.d.ts.map +1 -1
  56. package/esm/features.js +27 -13
  57. package/esm/features.js.map +1 -1
  58. package/esm/index.d.ts +1 -1
  59. package/esm/index.d.ts.map +1 -1
  60. package/esm/index.js +1 -1
  61. package/esm/index.js.map +1 -1
  62. package/esm/server/client.d.ts +7 -7
  63. package/esm/server/client.d.ts.map +1 -1
  64. package/esm/server/client.js +69 -86
  65. package/esm/server/client.js.map +1 -1
  66. package/esm/server/commands/wireless.js +1 -1
  67. package/esm/server/commands/wireless.js.map +1 -1
  68. package/esm/server/{stream.d.ts → data-connection.d.ts} +5 -5
  69. package/esm/server/data-connection.d.ts.map +1 -0
  70. package/esm/server/{stream.js → data-connection.js} +4 -4
  71. package/esm/server/data-connection.js.map +1 -0
  72. package/esm/server/index.d.ts +1 -1
  73. package/esm/server/index.d.ts.map +1 -1
  74. package/esm/server/index.js +1 -1
  75. package/esm/server/index.js.map +1 -1
  76. package/esm/server/observer.d.ts.map +1 -1
  77. package/esm/server/observer.js +14 -13
  78. package/esm/server/observer.js.map +1 -1
  79. package/esm/server/transport.d.ts +4 -6
  80. package/esm/server/transport.d.ts.map +1 -1
  81. package/esm/server/transport.js +9 -24
  82. package/esm/server/transport.js.map +1 -1
  83. package/esm/service/framebuffer.d.ts.map +1 -0
  84. package/esm/service/framebuffer.js.map +1 -0
  85. package/esm/{commands → service}/index.d.ts +1 -2
  86. package/esm/service/index.d.ts.map +1 -0
  87. package/esm/{commands → service}/index.js +1 -2
  88. package/esm/service/index.js.map +1 -0
  89. package/esm/{commands → service}/power.d.ts +4 -2
  90. package/esm/service/power.d.ts.map +1 -0
  91. package/esm/{commands → service}/power.js +11 -5
  92. package/esm/service/power.js.map +1 -0
  93. package/esm/service/reverse/error.d.ts +14 -0
  94. package/esm/service/reverse/error.d.ts.map +1 -0
  95. package/esm/service/reverse/error.js +21 -0
  96. package/esm/service/reverse/error.js.map +1 -0
  97. package/esm/service/reverse/index.d.ts +3 -0
  98. package/esm/service/reverse/index.d.ts.map +1 -0
  99. package/esm/service/reverse/index.js +4 -0
  100. package/esm/service/reverse/index.js.map +1 -0
  101. package/esm/service/reverse/response.d.ts +2 -0
  102. package/esm/service/reverse/response.d.ts.map +1 -0
  103. package/esm/service/reverse/response.js +30 -0
  104. package/esm/service/reverse/response.js.map +1 -0
  105. package/esm/service/reverse/service.d.ts +59 -0
  106. package/esm/service/reverse/service.d.ts.map +1 -0
  107. package/esm/{commands/reverse.js → service/reverse/service.js} +16 -45
  108. package/esm/service/reverse/service.js.map +1 -0
  109. package/esm/{commands → service}/subprocess/index.d.ts +1 -0
  110. package/esm/service/subprocess/index.d.ts.map +1 -0
  111. package/esm/{commands → service}/subprocess/index.js +1 -0
  112. package/esm/service/subprocess/index.js.map +1 -0
  113. package/esm/service/subprocess/none/index.d.ts.map +1 -0
  114. package/esm/service/subprocess/none/index.js.map +1 -0
  115. package/esm/{commands → service}/subprocess/none/process.d.ts +2 -2
  116. package/esm/service/subprocess/none/process.d.ts.map +1 -0
  117. package/esm/service/subprocess/none/process.js.map +1 -0
  118. package/esm/{commands → service}/subprocess/none/pty.d.ts +4 -4
  119. package/esm/service/subprocess/none/pty.d.ts.map +1 -0
  120. package/esm/{commands → service}/subprocess/none/pty.js +1 -1
  121. package/esm/service/subprocess/none/pty.js.map +1 -0
  122. package/esm/service/subprocess/none/service.d.ts +10 -0
  123. package/esm/service/subprocess/none/service.d.ts.map +1 -0
  124. package/esm/service/subprocess/none/service.js +44 -0
  125. package/esm/service/subprocess/none/service.js.map +1 -0
  126. package/esm/service/subprocess/none/spawner.d.ts +15 -0
  127. package/esm/service/subprocess/none/spawner.d.ts.map +1 -0
  128. package/esm/service/subprocess/none/spawner.js +31 -0
  129. package/esm/service/subprocess/none/spawner.js.map +1 -0
  130. package/esm/{commands → service}/subprocess/pty.d.ts +1 -1
  131. package/esm/service/subprocess/pty.d.ts.map +1 -0
  132. package/esm/{commands → service}/subprocess/pty.js.map +1 -1
  133. package/esm/service/subprocess/service.d.ts.map +1 -0
  134. package/esm/{commands → service}/subprocess/service.js +1 -1
  135. package/esm/service/subprocess/service.js.map +1 -0
  136. package/esm/service/subprocess/shell/index.d.ts +5 -0
  137. package/esm/{commands/subprocess/none → service/subprocess/shell}/index.d.ts.map +1 -1
  138. package/esm/service/subprocess/shell/index.js +6 -0
  139. package/esm/{commands/subprocess/none → service/subprocess/shell}/index.js.map +1 -1
  140. package/esm/{commands → service}/subprocess/shell/process.d.ts +2 -2
  141. package/esm/service/subprocess/shell/process.d.ts.map +1 -0
  142. package/esm/{commands → service}/subprocess/shell/process.js +4 -6
  143. package/esm/service/subprocess/shell/process.js.map +1 -0
  144. package/esm/{commands → service}/subprocess/shell/pty.d.ts +4 -4
  145. package/esm/service/subprocess/shell/pty.d.ts.map +1 -0
  146. package/esm/{commands → service}/subprocess/shell/pty.js +11 -9
  147. package/esm/service/subprocess/shell/pty.js.map +1 -0
  148. package/esm/service/subprocess/shell/service.d.ts +34 -0
  149. package/esm/service/subprocess/shell/service.d.ts.map +1 -0
  150. package/esm/service/subprocess/shell/service.js +52 -0
  151. package/esm/service/subprocess/shell/service.js.map +1 -0
  152. package/esm/service/subprocess/shell/shared.d.ts +2 -0
  153. package/esm/service/subprocess/shell/shared.d.ts.map +1 -0
  154. package/esm/{commands → service}/subprocess/shell/shared.js +2 -0
  155. package/esm/service/subprocess/shell/shared.js.map +1 -0
  156. package/esm/{commands → service}/subprocess/shell/spawner.d.ts +3 -7
  157. package/esm/service/subprocess/shell/spawner.d.ts.map +1 -0
  158. package/esm/service/subprocess/shell/spawner.js +45 -0
  159. package/esm/service/subprocess/shell/spawner.js.map +1 -0
  160. package/esm/service/subprocess/types.d.ts +14 -0
  161. package/esm/service/subprocess/types.d.ts.map +1 -0
  162. package/esm/service/subprocess/types.js +2 -0
  163. package/esm/service/subprocess/types.js.map +1 -0
  164. package/esm/service/subprocess/utils.d.ts +39 -0
  165. package/esm/service/subprocess/utils.d.ts.map +1 -0
  166. package/esm/service/subprocess/utils.js +142 -0
  167. package/esm/service/subprocess/utils.js.map +1 -0
  168. package/esm/service/sync/android.d.ts +34 -0
  169. package/esm/service/sync/android.d.ts.map +1 -0
  170. package/esm/service/sync/android.js +34 -0
  171. package/esm/service/sync/android.js.map +1 -0
  172. package/esm/service/sync/compression/compression.d.ts +17 -0
  173. package/esm/service/sync/compression/compression.d.ts.map +1 -0
  174. package/esm/service/sync/compression/compression.js +92 -0
  175. package/esm/service/sync/compression/compression.js.map +1 -0
  176. package/esm/service/sync/compression/format-ns.d.ts +5 -0
  177. package/esm/service/sync/compression/format-ns.d.ts.map +1 -0
  178. package/esm/service/sync/compression/format-ns.js +5 -0
  179. package/esm/service/sync/compression/format-ns.js.map +1 -0
  180. package/esm/service/sync/compression/format.d.ts +4 -0
  181. package/esm/service/sync/compression/format.d.ts.map +1 -0
  182. package/esm/service/sync/compression/format.js +3 -0
  183. package/esm/service/sync/compression/format.js.map +1 -0
  184. package/esm/service/sync/compression/index.d.ts +2 -0
  185. package/esm/service/sync/compression/index.d.ts.map +1 -0
  186. package/esm/service/sync/compression/index.js +2 -0
  187. package/esm/service/sync/compression/index.js.map +1 -0
  188. package/esm/service/sync/id/common.d.ts +17 -0
  189. package/esm/service/sync/id/common.d.ts.map +1 -0
  190. package/esm/service/sync/id/common.js +29 -0
  191. package/esm/service/sync/id/common.js.map +1 -0
  192. package/esm/service/sync/id/index.d.ts +4 -0
  193. package/esm/service/sync/id/index.d.ts.map +1 -0
  194. package/esm/service/sync/id/index.js +6 -0
  195. package/esm/service/sync/id/index.js.map +1 -0
  196. package/esm/service/sync/id/request.d.ts +7 -0
  197. package/esm/service/sync/id/request.d.ts.map +1 -0
  198. package/esm/service/sync/id/request.js +9 -0
  199. package/esm/service/sync/id/request.js.map +1 -0
  200. package/esm/service/sync/id/response.d.ts +6 -0
  201. package/esm/service/sync/id/response.d.ts.map +1 -0
  202. package/esm/service/sync/id/response.js +8 -0
  203. package/esm/service/sync/id/response.js.map +1 -0
  204. package/esm/service/sync/index-ns.d.ts +7 -0
  205. package/esm/service/sync/index-ns.d.ts.map +1 -0
  206. package/esm/service/sync/index-ns.js +7 -0
  207. package/esm/service/sync/index-ns.js.map +1 -0
  208. package/esm/service/sync/index.d.ts +3 -0
  209. package/esm/service/sync/index.d.ts.map +1 -0
  210. package/esm/service/sync/index.js +3 -0
  211. package/esm/service/sync/index.js.map +1 -0
  212. package/esm/service/sync/request/index.d.ts +5 -0
  213. package/esm/service/sync/request/index.d.ts.map +1 -0
  214. package/esm/service/sync/request/index.js +5 -0
  215. package/esm/service/sync/request/index.js.map +1 -0
  216. package/esm/{commands/sync → service/sync/request}/list.d.ts +21 -19
  217. package/esm/service/sync/request/list.d.ts.map +1 -0
  218. package/esm/service/sync/request/list.js +77 -0
  219. package/esm/service/sync/request/list.js.map +1 -0
  220. package/esm/service/sync/request/pull.d.ts +12 -0
  221. package/esm/service/sync/request/pull.d.ts.map +1 -0
  222. package/esm/service/sync/request/pull.js +28 -0
  223. package/esm/service/sync/request/pull.js.map +1 -0
  224. package/esm/service/sync/request/push.d.ts +54 -0
  225. package/esm/service/sync/request/push.d.ts.map +1 -0
  226. package/esm/service/sync/request/push.js +95 -0
  227. package/esm/service/sync/request/push.js.map +1 -0
  228. package/esm/{commands/sync → service/sync/request}/stat.d.ts +40 -50
  229. package/esm/service/sync/request/stat.d.ts.map +1 -0
  230. package/esm/service/sync/request/stat.js +89 -0
  231. package/esm/service/sync/request/stat.js.map +1 -0
  232. package/esm/service/sync/service.d.ts +123 -0
  233. package/esm/service/sync/service.d.ts.map +1 -0
  234. package/esm/service/sync/service.js +170 -0
  235. package/esm/service/sync/service.js.map +1 -0
  236. package/esm/service/sync/socket-pool.d.ts +11 -0
  237. package/esm/service/sync/socket-pool.d.ts.map +1 -0
  238. package/esm/service/sync/socket-pool.js +80 -0
  239. package/esm/service/sync/socket-pool.js.map +1 -0
  240. package/esm/service/sync/socket.d.ts +40 -0
  241. package/esm/service/sync/socket.d.ts.map +1 -0
  242. package/esm/service/sync/socket.js +153 -0
  243. package/esm/service/sync/socket.js.map +1 -0
  244. package/esm/{commands → service}/tcpip.d.ts +4 -2
  245. package/esm/service/tcpip.d.ts.map +1 -0
  246. package/esm/{commands → service}/tcpip.js +10 -7
  247. package/esm/service/tcpip.js.map +1 -0
  248. package/esm/utils/array-buffer.d.ts.map +1 -1
  249. package/esm/utils/array-buffer.js +2 -3
  250. package/esm/utils/array-buffer.js.map +1 -1
  251. package/esm/utils/base64.d.ts.map +1 -1
  252. package/esm/utils/base64.js +22 -10
  253. package/esm/utils/base64.js.map +1 -1
  254. package/esm/utils/index.d.ts +1 -0
  255. package/esm/utils/index.d.ts.map +1 -1
  256. package/esm/utils/index.js +1 -0
  257. package/esm/utils/index.js.map +1 -1
  258. package/esm/utils/md5.d.ts +8 -0
  259. package/esm/utils/md5.d.ts.map +1 -0
  260. package/esm/utils/md5.js +149 -0
  261. package/esm/utils/md5.js.map +1 -0
  262. package/package.json +9 -9
  263. package/src/adb.ts +44 -35
  264. package/src/banner.ts +2 -1
  265. package/src/daemon/auth/authenticator.ts +186 -0
  266. package/src/daemon/auth/index.ts +4 -0
  267. package/src/daemon/auth/packet-processor.ts +212 -0
  268. package/src/daemon/auth/public-key.ts +112 -0
  269. package/src/daemon/auth/type.ts +5 -0
  270. package/src/daemon/crypto.ts +36 -101
  271. package/src/daemon/dispatcher.ts +15 -8
  272. package/src/daemon/index.ts +1 -1
  273. package/src/daemon/socket.ts +3 -3
  274. package/src/daemon/transport.ts +35 -253
  275. package/src/device-observer.ts +3 -3
  276. package/src/features-value.ts +47 -0
  277. package/src/features.ts +31 -14
  278. package/src/index.ts +1 -1
  279. package/src/server/client.ts +94 -93
  280. package/src/server/commands/wireless.ts +1 -1
  281. package/src/server/{stream.ts → data-connection.ts} +4 -4
  282. package/src/server/index.ts +1 -1
  283. package/src/server/observer.ts +21 -19
  284. package/src/server/transport.ts +13 -34
  285. package/src/{commands → service}/index.ts +1 -2
  286. package/src/{commands → service}/power.ts +14 -5
  287. package/src/service/reverse/error.ts +35 -0
  288. package/src/service/reverse/index.ts +3 -0
  289. package/src/service/reverse/response.ts +38 -0
  290. package/src/{commands/reverse.ts → service/reverse/service.ts} +32 -72
  291. package/src/{commands → service}/subprocess/index.ts +1 -0
  292. package/src/{commands → service}/subprocess/none/process.ts +3 -3
  293. package/src/{commands → service}/subprocess/none/pty.ts +5 -5
  294. package/src/service/subprocess/none/service.ts +57 -0
  295. package/src/service/subprocess/none/spawner.ts +81 -0
  296. package/src/{commands → service}/subprocess/pty.ts +1 -1
  297. package/src/{commands → service}/subprocess/service.ts +1 -1
  298. package/src/{commands → service}/subprocess/shell/index.ts +1 -1
  299. package/src/{commands → service}/subprocess/shell/process.ts +6 -7
  300. package/src/{commands → service}/subprocess/shell/pty.ts +15 -13
  301. package/src/service/subprocess/shell/service.ts +75 -0
  302. package/src/{commands → service}/subprocess/shell/shared.ts +5 -0
  303. package/src/service/subprocess/shell/spawner.ts +109 -0
  304. package/src/service/subprocess/types.ts +19 -0
  305. package/src/service/subprocess/utils.ts +166 -0
  306. package/src/service/sync/android.ts +43 -0
  307. package/src/service/sync/compression/compression.ts +126 -0
  308. package/src/service/sync/compression/format-ns.ts +4 -0
  309. package/src/service/sync/compression/format.ts +5 -0
  310. package/src/service/sync/compression/index.ts +1 -0
  311. package/src/service/sync/id/common.ts +33 -0
  312. package/src/service/sync/id/index.ts +7 -0
  313. package/src/service/sync/id/request.ts +12 -0
  314. package/src/service/sync/id/response.ts +11 -0
  315. package/src/service/sync/index-ns.ts +6 -0
  316. package/src/service/sync/index.ts +2 -0
  317. package/src/service/sync/request/index.ts +4 -0
  318. package/src/service/sync/request/list.ts +110 -0
  319. package/src/service/sync/request/pull.ts +49 -0
  320. package/src/service/sync/request/push.ts +184 -0
  321. package/src/service/sync/request/stat.ts +127 -0
  322. package/src/service/sync/service.ts +255 -0
  323. package/src/service/sync/socket-pool.ts +97 -0
  324. package/src/service/sync/socket.ts +201 -0
  325. package/src/{commands → service}/tcpip.ts +13 -7
  326. package/src/utils/array-buffer.ts +2 -3
  327. package/src/utils/base64.ts +24 -10
  328. package/src/utils/index.ts +1 -0
  329. package/src/utils/md5.ts +185 -0
  330. package/yume-chan-adb-3.0.0-beta.0.tgz +0 -0
  331. package/CHANGELOG.md +0 -257
  332. package/esm/commands/base.d.ts +0 -8
  333. package/esm/commands/base.d.ts.map +0 -1
  334. package/esm/commands/base.js +0 -12
  335. package/esm/commands/base.js.map +0 -1
  336. package/esm/commands/framebuffer.d.ts.map +0 -1
  337. package/esm/commands/framebuffer.js.map +0 -1
  338. package/esm/commands/index.d.ts.map +0 -1
  339. package/esm/commands/index.js.map +0 -1
  340. package/esm/commands/power.d.ts.map +0 -1
  341. package/esm/commands/power.js.map +0 -1
  342. package/esm/commands/reverse.d.ts +0 -48
  343. package/esm/commands/reverse.d.ts.map +0 -1
  344. package/esm/commands/reverse.js.map +0 -1
  345. package/esm/commands/subprocess/index.d.ts.map +0 -1
  346. package/esm/commands/subprocess/index.js.map +0 -1
  347. package/esm/commands/subprocess/none/process.d.ts.map +0 -1
  348. package/esm/commands/subprocess/none/process.js.map +0 -1
  349. package/esm/commands/subprocess/none/pty.d.ts.map +0 -1
  350. package/esm/commands/subprocess/none/pty.js.map +0 -1
  351. package/esm/commands/subprocess/none/service.d.ts +0 -10
  352. package/esm/commands/subprocess/none/service.d.ts.map +0 -1
  353. package/esm/commands/subprocess/none/service.js +0 -34
  354. package/esm/commands/subprocess/none/service.js.map +0 -1
  355. package/esm/commands/subprocess/none/spawner.d.ts +0 -19
  356. package/esm/commands/subprocess/none/spawner.d.ts.map +0 -1
  357. package/esm/commands/subprocess/none/spawner.js +0 -26
  358. package/esm/commands/subprocess/none/spawner.js.map +0 -1
  359. package/esm/commands/subprocess/pty.d.ts.map +0 -1
  360. package/esm/commands/subprocess/service.d.ts.map +0 -1
  361. package/esm/commands/subprocess/service.js.map +0 -1
  362. package/esm/commands/subprocess/shell/index.d.ts +0 -6
  363. package/esm/commands/subprocess/shell/index.d.ts.map +0 -1
  364. package/esm/commands/subprocess/shell/index.js +0 -6
  365. package/esm/commands/subprocess/shell/index.js.map +0 -1
  366. package/esm/commands/subprocess/shell/process.d.ts.map +0 -1
  367. package/esm/commands/subprocess/shell/process.js.map +0 -1
  368. package/esm/commands/subprocess/shell/pty.d.ts.map +0 -1
  369. package/esm/commands/subprocess/shell/pty.js.map +0 -1
  370. package/esm/commands/subprocess/shell/service.d.ts +0 -14
  371. package/esm/commands/subprocess/shell/service.d.ts.map +0 -1
  372. package/esm/commands/subprocess/shell/service.js +0 -41
  373. package/esm/commands/subprocess/shell/service.js.map +0 -1
  374. package/esm/commands/subprocess/shell/shared.d.ts +0 -19
  375. package/esm/commands/subprocess/shell/shared.d.ts.map +0 -1
  376. package/esm/commands/subprocess/shell/shared.js.map +0 -1
  377. package/esm/commands/subprocess/shell/spawner.d.ts.map +0 -1
  378. package/esm/commands/subprocess/shell/spawner.js +0 -38
  379. package/esm/commands/subprocess/shell/spawner.js.map +0 -1
  380. package/esm/commands/subprocess/utils.d.ts +0 -3
  381. package/esm/commands/subprocess/utils.d.ts.map +0 -1
  382. package/esm/commands/subprocess/utils.js +0 -56
  383. package/esm/commands/subprocess/utils.js.map +0 -1
  384. package/esm/commands/sync/index.d.ts +0 -9
  385. package/esm/commands/sync/index.d.ts.map +0 -1
  386. package/esm/commands/sync/index.js +0 -9
  387. package/esm/commands/sync/index.js.map +0 -1
  388. package/esm/commands/sync/list.d.ts.map +0 -1
  389. package/esm/commands/sync/list.js +0 -64
  390. package/esm/commands/sync/list.js.map +0 -1
  391. package/esm/commands/sync/pull.d.ts +0 -12
  392. package/esm/commands/sync/pull.d.ts.map +0 -1
  393. package/esm/commands/sync/pull.js +0 -33
  394. package/esm/commands/sync/pull.js.map +0 -1
  395. package/esm/commands/sync/push.d.ts +0 -61
  396. package/esm/commands/sync/push.d.ts.map +0 -1
  397. package/esm/commands/sync/push.js +0 -83
  398. package/esm/commands/sync/push.js.map +0 -1
  399. package/esm/commands/sync/request.d.ts +0 -24
  400. package/esm/commands/sync/request.d.ts.map +0 -1
  401. package/esm/commands/sync/request.js +0 -32
  402. package/esm/commands/sync/request.js.map +0 -1
  403. package/esm/commands/sync/response.d.ts +0 -28
  404. package/esm/commands/sync/response.d.ts.map +0 -1
  405. package/esm/commands/sync/response.js +0 -81
  406. package/esm/commands/sync/response.js.map +0 -1
  407. package/esm/commands/sync/socket.d.ts +0 -22
  408. package/esm/commands/sync/socket.d.ts.map +0 -1
  409. package/esm/commands/sync/socket.js +0 -78
  410. package/esm/commands/sync/socket.js.map +0 -1
  411. package/esm/commands/sync/stat.d.ts.map +0 -1
  412. package/esm/commands/sync/stat.js +0 -121
  413. package/esm/commands/sync/stat.js.map +0 -1
  414. package/esm/commands/sync/sync.d.ts +0 -82
  415. package/esm/commands/sync/sync.d.ts.map +0 -1
  416. package/esm/commands/sync/sync.js +0 -138
  417. package/esm/commands/sync/sync.js.map +0 -1
  418. package/esm/commands/tcpip.d.ts.map +0 -1
  419. package/esm/commands/tcpip.js.map +0 -1
  420. package/esm/daemon/auth.d.ts +0 -54
  421. package/esm/daemon/auth.d.ts.map +0 -1
  422. package/esm/daemon/auth.js +0 -104
  423. package/esm/daemon/auth.js.map +0 -1
  424. package/esm/server/stream.d.ts.map +0 -1
  425. package/esm/server/stream.js.map +0 -1
  426. package/src/commands/base.ts +0 -15
  427. package/src/commands/subprocess/none/service.ts +0 -45
  428. package/src/commands/subprocess/none/spawner.ts +0 -68
  429. package/src/commands/subprocess/shell/service.ts +0 -58
  430. package/src/commands/subprocess/shell/spawner.ts +0 -90
  431. package/src/commands/subprocess/utils.ts +0 -61
  432. package/src/commands/sync/index.ts +0 -8
  433. package/src/commands/sync/list.ts +0 -99
  434. package/src/commands/sync/pull.ts +0 -55
  435. package/src/commands/sync/push.ts +0 -172
  436. package/src/commands/sync/request.ts +0 -53
  437. package/src/commands/sync/response.ts +0 -105
  438. package/src/commands/sync/socket.ts +0 -109
  439. package/src/commands/sync/stat.ts +0 -177
  440. package/src/commands/sync/sync.ts +0 -175
  441. package/src/daemon/auth.ts +0 -203
  442. package/tsconfig.build.tsbuildinfo +0 -1
  443. /package/esm/{commands → service}/framebuffer.d.ts +0 -0
  444. /package/esm/{commands → service}/framebuffer.js +0 -0
  445. /package/esm/{commands → service}/subprocess/none/index.d.ts +0 -0
  446. /package/esm/{commands → service}/subprocess/none/index.js +0 -0
  447. /package/esm/{commands → service}/subprocess/none/process.js +0 -0
  448. /package/esm/{commands → service}/subprocess/pty.js +0 -0
  449. /package/esm/{commands → service}/subprocess/service.d.ts +0 -0
  450. /package/src/{commands → service}/framebuffer.ts +0 -0
  451. /package/src/{commands → service}/subprocess/none/index.ts +0 -0
@@ -1,104 +0,0 @@
1
- import { PromiseResolver } from "@yume-chan/async";
2
- import { EmptyUint8Array } from "@yume-chan/struct";
3
- import { calculateBase64EncodedLength, encodeBase64, encodeUtf8, } from "../utils/index.js";
4
- import { adbGeneratePublicKey, adbGetPublicKeySize, rsaSign, } from "./crypto.js";
5
- import { AdbCommand } from "./packet.js";
6
- export const AdbAuthType = {
7
- Token: 1,
8
- Signature: 2,
9
- PublicKey: 3,
10
- };
11
- export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
12
- for await (const key of credentialStore.iterateKeys()) {
13
- const packet = await getNextRequest();
14
- if (packet.arg0 !== AdbAuthType.Token) {
15
- return;
16
- }
17
- const signature = rsaSign(key.buffer, packet.payload);
18
- yield {
19
- command: AdbCommand.Auth,
20
- arg0: AdbAuthType.Signature,
21
- arg1: 0,
22
- payload: signature,
23
- };
24
- }
25
- };
26
- export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNextRequest) {
27
- const packet = await getNextRequest();
28
- if (packet.arg0 !== AdbAuthType.Token) {
29
- return;
30
- }
31
- let privateKey;
32
- for await (const key of credentialStore.iterateKeys()) {
33
- privateKey = key;
34
- break;
35
- }
36
- if (!privateKey) {
37
- privateKey = await credentialStore.generateKey();
38
- }
39
- const publicKeyLength = adbGetPublicKeySize();
40
- const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
41
- const nameBuffer = privateKey.name?.length
42
- ? encodeUtf8(privateKey.name)
43
- : EmptyUint8Array;
44
- const publicKeyBuffer = new Uint8Array(publicKeyBase64Length +
45
- (nameBuffer.length ? nameBuffer.length + 1 : 0) + // Space character + name
46
- 1);
47
- adbGeneratePublicKey(privateKey.buffer, publicKeyBuffer);
48
- encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);
49
- if (nameBuffer.length) {
50
- publicKeyBuffer[publicKeyBase64Length] = 0x20;
51
- publicKeyBuffer.set(nameBuffer, publicKeyBase64Length + 1);
52
- }
53
- yield {
54
- command: AdbCommand.Auth,
55
- arg0: AdbAuthType.PublicKey,
56
- arg1: 0,
57
- payload: publicKeyBuffer,
58
- };
59
- };
60
- export const ADB_DEFAULT_AUTHENTICATORS = [
61
- AdbSignatureAuthenticator,
62
- AdbPublicKeyAuthenticator,
63
- ];
64
- export class AdbAuthenticationProcessor {
65
- authenticators;
66
- #credentialStore;
67
- #pendingRequest = new PromiseResolver();
68
- #iterator;
69
- constructor(authenticators, credentialStore) {
70
- this.authenticators = authenticators;
71
- this.#credentialStore = credentialStore;
72
- }
73
- #getNextRequest = () => {
74
- return this.#pendingRequest.promise;
75
- };
76
- async *#invokeAuthenticator() {
77
- for (const authenticator of this.authenticators) {
78
- for await (const packet of authenticator(this.#credentialStore, this.#getNextRequest)) {
79
- // If the authenticator yielded a response
80
- // Prepare `nextRequest` for next authentication request
81
- this.#pendingRequest = new PromiseResolver();
82
- // Yield the response to outer layer
83
- yield packet;
84
- }
85
- // If the authenticator returned,
86
- // Next authenticator will be given the same `pendingRequest`
87
- }
88
- }
89
- async process(packet) {
90
- if (!this.#iterator) {
91
- this.#iterator = this.#invokeAuthenticator();
92
- }
93
- this.#pendingRequest.resolve(packet);
94
- const result = await this.#iterator.next();
95
- if (result.done) {
96
- throw new Error("No authenticator can handle the request");
97
- }
98
- return result.value;
99
- }
100
- dispose() {
101
- void this.#iterator?.return?.();
102
- }
103
- }
104
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACZ,UAAU,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2BzC,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;CACN,CAAC;AAsBX,MAAM,CAAC,MAAM,yBAAyB,GAAqB,KAAK,SAAS,CAAC,EACtE,eAAmC,EACnC,cAA4C;IAE5C,IAAI,KAAK,EAAE,M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AC,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAClD,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACvB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACH,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;YAClC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ;YACnC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM;YAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;SACxC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAO;QACT,KAAK,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,KAAK,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ"}
@@ -1,15 +0,0 @@
1
- import { AutoDisposable } from "@yume-chan/event";
2
-
3
- import type { Adb } from "../adb.js";
4
-
5
- export class AdbServiceBase extends AutoDisposable {
6
- readonly #adb: Adb;
7
- get adb() {
8
- return this.#adb;
9
- }
10
-
11
- constructor(adb: Adb) {
12
- super();
13
- this.#adb = adb;
14
- }
15
- }
@@ -1,45 +0,0 @@
1
- import type { Adb } from "../../../adb.js";
2
-
3
- import { AdbNoneProtocolProcessImpl } from "./process.js";
4
- import { AdbNoneProtocolPtyProcess } from "./pty.js";
5
- import { AdbNoneProtocolSpawner } from "./spawner.js";
6
-
7
- export class AdbNoneProtocolSubprocessService extends AdbNoneProtocolSpawner {
8
- readonly #adb: Adb;
9
- get adb(): Adb {
10
- return this.#adb;
11
- }
12
-
13
- constructor(adb: Adb) {
14
- super(async (command, signal) => {
15
- // `shell,raw:${command}` also triggers raw mode,
16
- // But is not supported on Android version <7.
17
- const socket = await this.#adb.createSocket(
18
- `exec:${command.join(" ")}`,
19
- );
20
-
21
- if (signal?.aborted) {
22
- await socket.close();
23
- throw signal.reason;
24
- }
25
-
26
- return new AdbNoneProtocolProcessImpl(socket, signal);
27
- });
28
- this.#adb = adb;
29
- }
30
-
31
- async pty(
32
- command?: string | readonly string[],
33
- ): Promise<AdbNoneProtocolPtyProcess> {
34
- if (command === undefined) {
35
- command = "";
36
- } else if (Array.isArray(command)) {
37
- command = command.join(" ");
38
- }
39
-
40
- return new AdbNoneProtocolPtyProcess(
41
- // https://github.com/microsoft/typescript/issues/17002
42
- await this.#adb.createSocket(`shell:${command as string}`),
43
- );
44
- }
45
- }
@@ -1,68 +0,0 @@
1
- import type { MaybePromiseLike } from "@yume-chan/async";
2
- import type {
3
- AbortSignal,
4
- MaybeConsumable,
5
- ReadableStream,
6
- WritableStream,
7
- } from "@yume-chan/stream-extra";
8
- import {
9
- ConcatBufferStream,
10
- ConcatStringStream,
11
- TextDecoderStream,
12
- } from "@yume-chan/stream-extra";
13
-
14
- import { splitCommand } from "../utils.js";
15
-
16
- export interface AdbNoneProtocolProcess {
17
- get stdin(): WritableStream<MaybeConsumable<Uint8Array>>;
18
-
19
- /**
20
- * Mix of stdout and stderr
21
- */
22
- get output(): ReadableStream<Uint8Array>;
23
-
24
- get exited(): Promise<void>;
25
-
26
- kill(): MaybePromiseLike<void>;
27
- }
28
-
29
- export class AdbNoneProtocolSpawner {
30
- readonly #spawn: (
31
- command: readonly string[],
32
- signal: AbortSignal | undefined,
33
- ) => Promise<AdbNoneProtocolProcess>;
34
-
35
- constructor(
36
- spawn: (
37
- command: readonly string[],
38
- signal: AbortSignal | undefined,
39
- ) => Promise<AdbNoneProtocolProcess>,
40
- ) {
41
- this.#spawn = spawn;
42
- }
43
-
44
- spawn(
45
- command: string | readonly string[],
46
- signal?: AbortSignal,
47
- ): Promise<AdbNoneProtocolProcess> {
48
- signal?.throwIfAborted();
49
-
50
- if (typeof command === "string") {
51
- command = splitCommand(command);
52
- }
53
-
54
- return this.#spawn(command, signal);
55
- }
56
-
57
- async spawnWait(command: string | readonly string[]): Promise<Uint8Array> {
58
- const process = await this.spawn(command);
59
- return await process.output.pipeThrough(new ConcatBufferStream());
60
- }
61
-
62
- async spawnWaitText(command: string | readonly string[]): Promise<string> {
63
- const process = await this.spawn(command);
64
- return await process.output
65
- .pipeThrough(new TextDecoderStream())
66
- .pipeThrough(new ConcatStringStream());
67
- }
68
- }
@@ -1,58 +0,0 @@
1
- import type { Adb } from "../../../adb.js";
2
- import { AdbFeature } from "../../../features.js";
3
-
4
- import { AdbShellProtocolProcessImpl } from "./process.js";
5
- import { AdbShellProtocolPtyProcess } from "./pty.js";
6
- import { AdbShellProtocolSpawner } from "./spawner.js";
7
-
8
- export class AdbShellProtocolSubprocessService extends AdbShellProtocolSpawner {
9
- readonly #adb: Adb;
10
- get adb() {
11
- return this.#adb;
12
- }
13
-
14
- get isSupported() {
15
- return this.#adb.canUseFeature(AdbFeature.ShellV2);
16
- }
17
-
18
- constructor(adb: Adb) {
19
- super(async (command, signal) => {
20
- const socket = await this.#adb.createSocket(
21
- `shell,v2,raw:${command.join(" ")}`,
22
- );
23
-
24
- if (signal?.aborted) {
25
- await socket.close();
26
- throw signal.reason;
27
- }
28
-
29
- return new AdbShellProtocolProcessImpl(socket, signal);
30
- });
31
- this.#adb = adb;
32
- }
33
-
34
- async pty(options?: {
35
- command?: string | readonly string[] | undefined;
36
- terminalType?: string;
37
- }): Promise<AdbShellProtocolPtyProcess> {
38
- let service = "shell,v2,pty";
39
-
40
- if (options?.terminalType) {
41
- service += `,TERM=` + options.terminalType;
42
- }
43
-
44
- service += ":";
45
-
46
- if (options) {
47
- if (typeof options.command === "string") {
48
- service += options.command;
49
- } else if (Array.isArray(options.command)) {
50
- service += options.command.join(" ");
51
- }
52
- }
53
-
54
- return new AdbShellProtocolPtyProcess(
55
- await this.#adb.createSocket(service),
56
- );
57
- }
58
- }
@@ -1,90 +0,0 @@
1
- import type { MaybePromiseLike } from "@yume-chan/async";
2
- import type {
3
- AbortSignal,
4
- MaybeConsumable,
5
- ReadableStream,
6
- WritableStream,
7
- } from "@yume-chan/stream-extra";
8
- import {
9
- ConcatBufferStream,
10
- ConcatStringStream,
11
- TextDecoderStream,
12
- } from "@yume-chan/stream-extra";
13
-
14
- import { splitCommand } from "../utils.js";
15
-
16
- export interface AdbShellProtocolProcess {
17
- get stdin(): WritableStream<MaybeConsumable<Uint8Array>>;
18
-
19
- get stdout(): ReadableStream<Uint8Array>;
20
- get stderr(): ReadableStream<Uint8Array>;
21
-
22
- get exited(): Promise<number>;
23
-
24
- kill(): MaybePromiseLike<void>;
25
- }
26
-
27
- export class AdbShellProtocolSpawner {
28
- readonly #spawn: (
29
- command: readonly string[],
30
- signal: AbortSignal | undefined,
31
- ) => Promise<AdbShellProtocolProcess>;
32
-
33
- constructor(
34
- spawn: (
35
- command: readonly string[],
36
- signal: AbortSignal | undefined,
37
- ) => Promise<AdbShellProtocolProcess>,
38
- ) {
39
- this.#spawn = spawn;
40
- }
41
-
42
- spawn(
43
- command: string | readonly string[],
44
- signal?: AbortSignal,
45
- ): Promise<AdbShellProtocolProcess> {
46
- signal?.throwIfAborted();
47
-
48
- if (typeof command === "string") {
49
- command = splitCommand(command);
50
- }
51
-
52
- return this.#spawn(command, signal);
53
- }
54
-
55
- async spawnWait(
56
- command: string | readonly string[],
57
- ): Promise<AdbShellProtocolSpawner.WaitResult<Uint8Array>> {
58
- const process = await this.spawn(command);
59
- const [stdout, stderr, exitCode] = await Promise.all([
60
- process.stdout.pipeThrough(new ConcatBufferStream()),
61
- process.stderr.pipeThrough(new ConcatBufferStream()),
62
- process.exited,
63
- ]);
64
- return { stdout, stderr, exitCode };
65
- }
66
-
67
- async spawnWaitText(
68
- command: string | readonly string[],
69
- ): Promise<AdbShellProtocolSpawner.WaitResult<string>> {
70
- const process = await this.spawn(command);
71
- const [stdout, stderr, exitCode] = await Promise.all([
72
- process.stdout
73
- .pipeThrough(new TextDecoderStream())
74
- .pipeThrough(new ConcatStringStream()),
75
- process.stderr
76
- .pipeThrough(new TextDecoderStream())
77
- .pipeThrough(new ConcatStringStream()),
78
- process.exited,
79
- ]);
80
- return { stdout, stderr, exitCode };
81
- }
82
- }
83
-
84
- export namespace AdbShellProtocolSpawner {
85
- export interface WaitResult<T> {
86
- stdout: T;
87
- stderr: T;
88
- exitCode: number;
89
- }
90
- }
@@ -1,61 +0,0 @@
1
- export function escapeArg(s: string) {
2
- let result = "";
3
- result += `'`;
4
-
5
- let base = 0;
6
- while (true) {
7
- const found = s.indexOf(`'`, base);
8
- if (found === -1) {
9
- result += s.substring(base);
10
- break;
11
- }
12
- result += s.substring(base, found);
13
- // a'b becomes a'\'b (the backslash is not a escape character)
14
- result += String.raw`'\''`;
15
- base = found + 1;
16
- }
17
-
18
- result += `'`;
19
- return result;
20
- }
21
-
22
- export function splitCommand(command: string): string[] {
23
- const result: string[] = [];
24
- let quote: string | undefined;
25
- let isEscaped = false;
26
- let start = 0;
27
-
28
- for (let i = 0, len = command.length; i < len; i += 1) {
29
- if (isEscaped) {
30
- isEscaped = false;
31
- continue;
32
- }
33
-
34
- const char = command.charAt(i);
35
- switch (char) {
36
- case " ":
37
- if (!quote && i !== start) {
38
- result.push(command.substring(start, i));
39
- start = i + 1;
40
- }
41
- break;
42
- case "'":
43
- case '"':
44
- if (!quote) {
45
- quote = char;
46
- } else if (char === quote) {
47
- quote = undefined;
48
- }
49
- break;
50
- case "\\":
51
- isEscaped = true;
52
- break;
53
- }
54
- }
55
-
56
- if (start < command.length) {
57
- result.push(command.substring(start));
58
- }
59
-
60
- return result;
61
- }
@@ -1,8 +0,0 @@
1
- export * from "./list.js";
2
- export * from "./pull.js";
3
- export * from "./push.js";
4
- export * from "./request.js";
5
- export * from "./response.js";
6
- export * from "./socket.js";
7
- export * from "./stat.js";
8
- export * from "./sync.js";
@@ -1,99 +0,0 @@
1
- import type { StructValue } from "@yume-chan/struct";
2
- import { extend, string, u32 } from "@yume-chan/struct";
3
-
4
- import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js";
5
- import { AdbSyncResponseId, adbSyncReadResponses } from "./response.js";
6
- import type { AdbSyncSocket } from "./socket.js";
7
- import type { AdbSyncStat } from "./stat.js";
8
- import {
9
- AdbSyncLstatResponse,
10
- AdbSyncStatErrorCode,
11
- AdbSyncStatResponse,
12
- } from "./stat.js";
13
-
14
- export interface AdbSyncEntry extends AdbSyncStat {
15
- name: string;
16
- }
17
-
18
- export const AdbSyncEntryResponse = extend(AdbSyncLstatResponse, {
19
- name: string(u32),
20
- });
21
-
22
- export type AdbSyncEntryResponse = StructValue<typeof AdbSyncEntryResponse>;
23
-
24
- export const AdbSyncEntry2Response = extend(AdbSyncStatResponse, {
25
- name: string(u32),
26
- });
27
-
28
- export type AdbSyncEntry2Response = StructValue<typeof AdbSyncEntry2Response>;
29
-
30
- export async function* adbSyncOpenDirV2(
31
- socket: AdbSyncSocket,
32
- path: string,
33
- ): AsyncGenerator<AdbSyncEntry2Response, void, void> {
34
- const locked = await socket.lock();
35
- try {
36
- await adbSyncWriteRequest(locked, AdbSyncRequestId.ListV2, path);
37
- for await (const item of adbSyncReadResponses(
38
- locked,
39
- AdbSyncResponseId.Entry2,
40
- AdbSyncEntry2Response,
41
- )) {
42
- // `LST2` can return error codes for failed `lstat` calls.
43
- // `LIST` just ignores them.
44
- // But they only contain `name` so still pretty useless.
45
- if (item.error !== AdbSyncStatErrorCode.SUCCESS) {
46
- continue;
47
- }
48
- yield item;
49
- }
50
- } finally {
51
- locked.release();
52
- }
53
- }
54
-
55
- export async function* adbSyncOpenDirV1(
56
- socket: AdbSyncSocket,
57
- path: string,
58
- ): AsyncGenerator<AdbSyncEntryResponse, void, void> {
59
- const locked = await socket.lock();
60
- try {
61
- await adbSyncWriteRequest(locked, AdbSyncRequestId.List, path);
62
- for await (const item of adbSyncReadResponses(
63
- locked,
64
- AdbSyncResponseId.Entry,
65
- AdbSyncEntryResponse,
66
- )) {
67
- yield item;
68
- }
69
- } finally {
70
- locked.release();
71
- }
72
- }
73
-
74
- export async function* adbSyncOpenDir(
75
- socket: AdbSyncSocket,
76
- path: string,
77
- v2: boolean,
78
- ): AsyncGenerator<AdbSyncEntry, void, void> {
79
- if (v2) {
80
- yield* adbSyncOpenDirV2(socket, path);
81
- } else {
82
- for await (const item of adbSyncOpenDirV1(socket, path)) {
83
- // Convert to same format as `AdbSyncEntry2Response` for easier consumption.
84
- // However it will add some overhead.
85
- yield {
86
- mode: item.mode,
87
- size: BigInt(item.size),
88
- mtime: BigInt(item.mtime),
89
- get type() {
90
- return item.type;
91
- },
92
- get permission() {
93
- return item.permission;
94
- },
95
- name: item.name,
96
- };
97
- }
98
- }
99
- }
@@ -1,55 +0,0 @@
1
- import { ReadableStream } from "@yume-chan/stream-extra";
2
- import type { StructValue } from "@yume-chan/struct";
3
- import { buffer, struct, u32 } from "@yume-chan/struct";
4
-
5
- import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js";
6
- import { adbSyncReadResponses, AdbSyncResponseId } from "./response.js";
7
- import type { AdbSyncSocket } from "./socket.js";
8
-
9
- export const AdbSyncDataResponse = struct(
10
- { data: buffer(u32) },
11
- { littleEndian: true },
12
- );
13
-
14
- export type AdbSyncDataResponse = StructValue<typeof AdbSyncDataResponse>;
15
-
16
- export async function* adbSyncPullGenerator(
17
- socket: AdbSyncSocket,
18
- path: string,
19
- ): AsyncGenerator<Uint8Array, void, void> {
20
- const locked = await socket.lock();
21
- let done = false;
22
- try {
23
- await adbSyncWriteRequest(locked, AdbSyncRequestId.Receive, path);
24
- for await (const packet of adbSyncReadResponses(
25
- locked,
26
- AdbSyncResponseId.Data,
27
- AdbSyncDataResponse,
28
- )) {
29
- yield packet.data;
30
- }
31
- done = true;
32
- } catch (e) {
33
- done = true;
34
- throw e;
35
- } finally {
36
- if (!done) {
37
- // sync pull can't be cancelled, so we have to read all data
38
- for await (const packet of adbSyncReadResponses(
39
- locked,
40
- AdbSyncResponseId.Data,
41
- AdbSyncDataResponse,
42
- )) {
43
- void packet;
44
- }
45
- }
46
- locked.release();
47
- }
48
- }
49
-
50
- export function adbSyncPull(
51
- socket: AdbSyncSocket,
52
- path: string,
53
- ): ReadableStream<Uint8Array> {
54
- return ReadableStream.from(adbSyncPullGenerator(socket, path));
55
- }