@yume-chan/adb 2.6.2 → 3.0.0-beta.1

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 (450) 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 +11 -10
  63. package/esm/server/client.d.ts.map +1 -1
  64. package/esm/server/client.js +82 -98
  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 +36 -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 +11 -15
  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 +50 -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 +7 -7
  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 +112 -104
  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 +85 -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 +13 -17
  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 +113 -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/CHANGELOG.md +0 -257
  331. package/esm/commands/base.d.ts +0 -8
  332. package/esm/commands/base.d.ts.map +0 -1
  333. package/esm/commands/base.js +0 -12
  334. package/esm/commands/base.js.map +0 -1
  335. package/esm/commands/framebuffer.d.ts.map +0 -1
  336. package/esm/commands/framebuffer.js.map +0 -1
  337. package/esm/commands/index.d.ts.map +0 -1
  338. package/esm/commands/index.js.map +0 -1
  339. package/esm/commands/power.d.ts.map +0 -1
  340. package/esm/commands/power.js.map +0 -1
  341. package/esm/commands/reverse.d.ts +0 -48
  342. package/esm/commands/reverse.d.ts.map +0 -1
  343. package/esm/commands/reverse.js.map +0 -1
  344. package/esm/commands/subprocess/index.d.ts.map +0 -1
  345. package/esm/commands/subprocess/index.js.map +0 -1
  346. package/esm/commands/subprocess/none/process.d.ts.map +0 -1
  347. package/esm/commands/subprocess/none/process.js.map +0 -1
  348. package/esm/commands/subprocess/none/pty.d.ts.map +0 -1
  349. package/esm/commands/subprocess/none/pty.js.map +0 -1
  350. package/esm/commands/subprocess/none/service.d.ts +0 -10
  351. package/esm/commands/subprocess/none/service.d.ts.map +0 -1
  352. package/esm/commands/subprocess/none/service.js +0 -34
  353. package/esm/commands/subprocess/none/service.js.map +0 -1
  354. package/esm/commands/subprocess/none/spawner.d.ts +0 -19
  355. package/esm/commands/subprocess/none/spawner.d.ts.map +0 -1
  356. package/esm/commands/subprocess/none/spawner.js +0 -26
  357. package/esm/commands/subprocess/none/spawner.js.map +0 -1
  358. package/esm/commands/subprocess/pty.d.ts.map +0 -1
  359. package/esm/commands/subprocess/service.d.ts.map +0 -1
  360. package/esm/commands/subprocess/service.js.map +0 -1
  361. package/esm/commands/subprocess/shell/index.d.ts +0 -6
  362. package/esm/commands/subprocess/shell/index.d.ts.map +0 -1
  363. package/esm/commands/subprocess/shell/index.js +0 -6
  364. package/esm/commands/subprocess/shell/index.js.map +0 -1
  365. package/esm/commands/subprocess/shell/process.d.ts.map +0 -1
  366. package/esm/commands/subprocess/shell/process.js.map +0 -1
  367. package/esm/commands/subprocess/shell/pty.d.ts.map +0 -1
  368. package/esm/commands/subprocess/shell/pty.js.map +0 -1
  369. package/esm/commands/subprocess/shell/service.d.ts +0 -14
  370. package/esm/commands/subprocess/shell/service.d.ts.map +0 -1
  371. package/esm/commands/subprocess/shell/service.js +0 -41
  372. package/esm/commands/subprocess/shell/service.js.map +0 -1
  373. package/esm/commands/subprocess/shell/shared.d.ts +0 -19
  374. package/esm/commands/subprocess/shell/shared.d.ts.map +0 -1
  375. package/esm/commands/subprocess/shell/shared.js.map +0 -1
  376. package/esm/commands/subprocess/shell/spawner.d.ts.map +0 -1
  377. package/esm/commands/subprocess/shell/spawner.js +0 -38
  378. package/esm/commands/subprocess/shell/spawner.js.map +0 -1
  379. package/esm/commands/subprocess/utils.d.ts +0 -3
  380. package/esm/commands/subprocess/utils.d.ts.map +0 -1
  381. package/esm/commands/subprocess/utils.js +0 -56
  382. package/esm/commands/subprocess/utils.js.map +0 -1
  383. package/esm/commands/sync/index.d.ts +0 -9
  384. package/esm/commands/sync/index.d.ts.map +0 -1
  385. package/esm/commands/sync/index.js +0 -9
  386. package/esm/commands/sync/index.js.map +0 -1
  387. package/esm/commands/sync/list.d.ts.map +0 -1
  388. package/esm/commands/sync/list.js +0 -64
  389. package/esm/commands/sync/list.js.map +0 -1
  390. package/esm/commands/sync/pull.d.ts +0 -12
  391. package/esm/commands/sync/pull.d.ts.map +0 -1
  392. package/esm/commands/sync/pull.js +0 -33
  393. package/esm/commands/sync/pull.js.map +0 -1
  394. package/esm/commands/sync/push.d.ts +0 -61
  395. package/esm/commands/sync/push.d.ts.map +0 -1
  396. package/esm/commands/sync/push.js +0 -83
  397. package/esm/commands/sync/push.js.map +0 -1
  398. package/esm/commands/sync/request.d.ts +0 -24
  399. package/esm/commands/sync/request.d.ts.map +0 -1
  400. package/esm/commands/sync/request.js +0 -32
  401. package/esm/commands/sync/request.js.map +0 -1
  402. package/esm/commands/sync/response.d.ts +0 -28
  403. package/esm/commands/sync/response.d.ts.map +0 -1
  404. package/esm/commands/sync/response.js +0 -81
  405. package/esm/commands/sync/response.js.map +0 -1
  406. package/esm/commands/sync/socket.d.ts +0 -22
  407. package/esm/commands/sync/socket.d.ts.map +0 -1
  408. package/esm/commands/sync/socket.js +0 -78
  409. package/esm/commands/sync/socket.js.map +0 -1
  410. package/esm/commands/sync/stat.d.ts.map +0 -1
  411. package/esm/commands/sync/stat.js +0 -121
  412. package/esm/commands/sync/stat.js.map +0 -1
  413. package/esm/commands/sync/sync.d.ts +0 -82
  414. package/esm/commands/sync/sync.d.ts.map +0 -1
  415. package/esm/commands/sync/sync.js +0 -138
  416. package/esm/commands/sync/sync.js.map +0 -1
  417. package/esm/commands/tcpip.d.ts.map +0 -1
  418. package/esm/commands/tcpip.js.map +0 -1
  419. package/esm/daemon/auth.d.ts +0 -54
  420. package/esm/daemon/auth.d.ts.map +0 -1
  421. package/esm/daemon/auth.js +0 -104
  422. package/esm/daemon/auth.js.map +0 -1
  423. package/esm/server/stream.d.ts.map +0 -1
  424. package/esm/server/stream.js.map +0 -1
  425. package/src/commands/base.ts +0 -15
  426. package/src/commands/subprocess/none/service.ts +0 -45
  427. package/src/commands/subprocess/none/spawner.ts +0 -68
  428. package/src/commands/subprocess/shell/service.ts +0 -58
  429. package/src/commands/subprocess/shell/spawner.ts +0 -90
  430. package/src/commands/subprocess/utils.ts +0 -61
  431. package/src/commands/sync/index.ts +0 -8
  432. package/src/commands/sync/list.ts +0 -99
  433. package/src/commands/sync/pull.ts +0 -55
  434. package/src/commands/sync/push.ts +0 -172
  435. package/src/commands/sync/request.ts +0 -53
  436. package/src/commands/sync/response.ts +0 -105
  437. package/src/commands/sync/socket.ts +0 -109
  438. package/src/commands/sync/stat.ts +0 -177
  439. package/src/commands/sync/sync.ts +0 -175
  440. package/src/daemon/auth.ts +0 -203
  441. package/tsconfig.build.tsbuildinfo +0 -1
  442. /package/esm/{commands → service}/framebuffer.d.ts +0 -0
  443. /package/esm/{commands → service}/framebuffer.js +0 -0
  444. /package/esm/{commands → service}/subprocess/none/index.d.ts +0 -0
  445. /package/esm/{commands → service}/subprocess/none/index.js +0 -0
  446. /package/esm/{commands → service}/subprocess/none/process.js +0 -0
  447. /package/esm/{commands → service}/subprocess/pty.js +0 -0
  448. /package/esm/{commands → service}/subprocess/service.d.ts +0 -0
  449. /package/src/{commands → service}/framebuffer.ts +0 -0
  450. /package/src/{commands → service}/subprocess/none/index.ts +0 -0
@@ -0,0 +1,15 @@
1
+ import type { MaybePromiseLike } from "@yume-chan/async";
2
+ import type { AbortSignal, MaybeConsumable, ReadableStream, WritableStream } from "@yume-chan/stream-extra";
3
+ import type { AdbSubprocessSpawner } from "../types.js";
4
+ export interface AdbNoneProtocolProcess {
5
+ get stdin(): WritableStream<MaybeConsumable<Uint8Array>>;
6
+ /**
7
+ * Mix of stdout and stderr
8
+ */
9
+ get output(): ReadableStream<Uint8Array>;
10
+ get exited(): Promise<void>;
11
+ kill(): MaybePromiseLike<void>;
12
+ }
13
+ export type AdbNoneProtocolSpawner = (command: string | readonly string[], signal?: AbortSignal) => Promise<AdbNoneProtocolProcess> & AdbSubprocessSpawner.Wait<Uint8Array, string>;
14
+ export declare function adbNoneProtocolSpawner(spawn: (command: readonly string[], signal: AbortSignal | undefined) => Promise<AdbNoneProtocolProcess>): AdbNoneProtocolSpawner;
15
+ //# sourceMappingURL=spawner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawner.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/none/spawner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACR,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQxD,MAAM,WAAW,sBAAsB;IACnC,IAAI,KAAK,IAAI,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzD;;OAEG;IACH,IAAI,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IAEzC,IAAI,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,sBAAsB,GAAG,CACjC,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACnC,MAAM,CAAC,EAAE,WAAW,KACnB,OAAO,CAAC,sBAAsB,CAAC,GAChC,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAElD,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,CACH,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,MAAM,EAAE,WAAW,GAAG,SAAS,KAC9B,OAAO,CAAC,sBAAsB,CAAC,GACrC,sBAAsB,CA2CxB"}
@@ -0,0 +1,36 @@
1
+ import { concatUint8Arrays } from "@yume-chan/stream-extra";
2
+ import { createLazyPromise, decodeUtf8Chunked, splitCommand, ToArrayStream, } from "../utils.js";
3
+ export function adbNoneProtocolSpawner(spawn) {
4
+ return (command, signal) => {
5
+ signal?.throwIfAborted();
6
+ if (typeof command === "string") {
7
+ command = splitCommand(command);
8
+ }
9
+ const processPromise = spawn(command, signal);
10
+ processPromise.wait = (options) => {
11
+ const waitPromise = processPromise.then(async (process) => {
12
+ try {
13
+ const [, output] = await Promise.all([
14
+ options?.stdin?.pipeTo(process.stdin),
15
+ process.output.pipeThrough(new ToArrayStream()),
16
+ ]);
17
+ return output;
18
+ }
19
+ finally {
20
+ await process.kill();
21
+ }
22
+ });
23
+ return createLazyPromise(async () => {
24
+ const chunks = await waitPromise;
25
+ return concatUint8Arrays(chunks);
26
+ }, {
27
+ async toString() {
28
+ const chunks = await waitPromise;
29
+ return decodeUtf8Chunked(chunks);
30
+ },
31
+ });
32
+ };
33
+ return processPromise;
34
+ };
35
+ }
36
+ //# sourceMappingURL=spawner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawner.js","sourceRoot":"","sources":["../../../../src/service/subprocess/none/spawner.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,aAAa,GAChB,MAAM,aAAa,CAAC;AAqBrB,MAAM,UAAU,sBAAsB,CAClC,KAGoC;IAEpC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACvB,MAAM,EAAE,cAAc,EAAE,CAAC;QAEzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,cAAc,GAAG,KAAK,CACxB,OAAO,EACP,MAAM,CAEuC,CAAC;QAElD,cAAc,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;gBACtD,IAAI,CAAC;oBACD,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;wBACjC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;wBACrC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,aAAa,EAAE,CAAC;qBAClD,CAAC,CAAC;oBACH,OAAO,MAAM,CAAC;gBAClB,CAAC;wBAAS,CAAC;oBACP,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;gBACzB,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,iBAAiB,CACpB,KAAK,IAAI,EAAE;gBACP,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;gBACjC,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;YACrC,CAAC,EACD;gBACI,KAAK,CAAC,QAAQ;oBACV,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;oBACjC,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;aACJ,CACJ,CAAC;QACN,CAAC,CAAC;QAEF,OAAO,cAAc,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { MaybeConsumable, ReadableStream, WritableStream } from "@yume-chan/stream-extra";
3
- export interface AdbPtyProcess<TExitCode> {
3
+ export interface AdbPty<TExitCode> {
4
4
  get input(): WritableStream<MaybeConsumable<Uint8Array>>;
5
5
  get output(): ReadableStream<Uint8Array>;
6
6
  get exited(): Promise<TExitCode>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pty.d.ts","sourceRoot":"","sources":["../../../src/service/subprocess/pty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACR,eAAe,EACf,cAAc,EACd,cAAc,EACjB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,MAAM,CAAC,SAAS;IAC7B,IAAI,KAAK,IAAI,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IACzD,IAAI,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IACzC,IAAI,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pty.js","sourceRoot":"","sources":["../../../src/commands/subprocess/pty.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"pty.js","sourceRoot":"","sources":["../../../src/service/subprocess/pty.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/service/subprocess/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAErE,qBAAa,oBAAoB;;IAE7B,IAAI,GAAG,QAEN;IAGD,IAAI,YAAY,IAAI,gCAAgC,CAEnD;IAGD,IAAI,aAAa,IAAI,iCAAiC,GAAG,SAAS,CAEjE;gBAEW,GAAG,EAAE,GAAG;CASvB"}
@@ -17,7 +17,7 @@ export class AdbSubprocessService {
17
17
  constructor(adb) {
18
18
  this.#adb = adb;
19
19
  this.#noneProtocol = new AdbNoneProtocolSubprocessService(adb);
20
- if (adb.canUseFeature(AdbFeature.ShellV2)) {
20
+ if (adb.canUseFeature(AdbFeature.Shell2)) {
21
21
  this.#shellProtocol = new AdbShellProtocolSubprocessService(adb);
22
22
  }
23
23
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/service/subprocess/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,OAAO,oBAAoB;IACpB,IAAI,CAAM;IACnB,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEQ,aAAa,CAAmC;IACzD,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAEQ,cAAc,CAAqC;IAC5D,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,YAAY,GAAQ;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAEhB,IAAI,CAAC,aAAa,GAAG,IAAI,gCAAgC,CAAC,GAAG,CAAC,CAAC;QAE/D,IAAI,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,cAAc,GAAG,IAAI,iCAAiC,CAAC,GAAG,CAAC,CAAC;QACrE,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,5 @@
1
+ export * from "./process.js";
2
+ export * from "./pty.js";
3
+ export * from "./service.js";
4
+ export * from "./spawner.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/none/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./process.js";
2
+ export * from "./pty.js";
3
+ export * from "./service.js";
4
+ export * from "./spawner.js";
5
+ // `shared.ts` is internal
6
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/subprocess/none/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,0BAA0B"}
@@ -1,7 +1,7 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { AbortSignal, ReadableStream } from "@yume-chan/stream-extra";
3
3
  import { MaybeConsumable, WritableStream } from "@yume-chan/stream-extra";
4
- import type { AdbSocket } from "../../../adb.js";
4
+ import type { Adb } from "../../../adb.js";
5
5
  import type { AdbShellProtocolProcess } from "./spawner.js";
6
6
  export declare class AdbShellProtocolProcessImpl implements AdbShellProtocolProcess {
7
7
  #private;
@@ -9,7 +9,7 @@ export declare class AdbShellProtocolProcessImpl implements AdbShellProtocolProc
9
9
  get stdout(): ReadableStream<Uint8Array<ArrayBufferLike>>;
10
10
  get stderr(): ReadableStream<Uint8Array<ArrayBufferLike>>;
11
11
  get exited(): Promise<number>;
12
- constructor(socket: AdbSocket, signal?: AbortSignal);
12
+ constructor(socket: Adb.Socket, signal?: AbortSignal);
13
13
  kill(): MaybePromiseLike<void>;
14
14
  }
15
15
  //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EACR,WAAW,EAEX,cAAc,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,eAAe,EAGf,cAAc,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D,qBAAa,2BAA4B,YAAW,uBAAuB;;IAKvE,IAAI,KAAK,iEAER;IAGD,IAAI,MAAM,gDAET;IAGD,IAAI,MAAM,gDAET;IAGD,IAAI,MAAM,oBAET;gBAEW,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW;IAmFpD,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC;CAGjC"}
@@ -65,23 +65,19 @@ export class AdbShellProtocolProcessImpl {
65
65
  // If `exited` has already settled, this will be a no-op
66
66
  exited.reject(e);
67
67
  });
68
- if (signal) {
69
- // `signal` won't affect `this.stdout` and `this.stderr`
70
- // So remaining data can still be read
71
- // (call `controller.error` will discard all pending data)
72
- signal.addEventListener("abort", () => {
73
- exited.reject(signal.reason);
74
- this.#socket.close();
75
- });
76
- }
68
+ // `signal` won't affect `this.stdout` and `this.stderr`
69
+ // So remaining data can still be read
70
+ // (call `controller.error` will discard all pending data)
71
+ signal?.addEventListener("abort", () => {
72
+ exited.reject(signal.reason);
73
+ this.#socket.close();
74
+ });
77
75
  this.#writer = this.#socket.writable.getWriter();
78
76
  this.#stdin = new MaybeConsumable.WritableStream({
79
- write: async (chunk) => {
80
- await this.#writer.write(AdbShellProtocolPacket.serialize({
81
- id: AdbShellProtocolId.Stdin,
82
- data: chunk,
83
- }));
84
- },
77
+ write: (chunk) => this.#writer.write(AdbShellProtocolPacket.serialize({
78
+ id: AdbShellProtocolId.Stdin,
79
+ data: chunk,
80
+ })),
85
81
  close: () =>
86
82
  // Only shell protocol + raw mode supports closing stdin
87
83
  this.#writer.write(AdbShellProtocolPacket.serialize({
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/process.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOnD,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGzE,MAAM,OAAO,2BAA2B;IAC3B,OAAO,CAAa;IACpB,OAAO,CAA2D;IAElE,MAAM,CAA8C;IAC7D,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEQ,OAAO,CAA6B;IAC7C,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEQ,OAAO,CAA6B;IAC7C,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEQ,OAAO,CAAkB;IAClC,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,YAAY,MAAkB,EAAE,MAAoB;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,gBAA2D,CAAC;QAChE,IAAI,gBAA2D,CAAC;QAChE,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAkB,CAAa,CAAC,UAAU,EAAE,EAAE;YAC7D,gBAAgB,GAAG,UAAU,CAAC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,CAAC,CAAC,CAAC,CAAC;YAC1B,wDAAwD;YACxD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CACJ,CAAC;QAEN,wDAAwD;QACxD,sCAAsC;QACtC,0DAA0D;QAC1D,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,cAAc,CAAa;YACzD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,IAAI,CAAC,OAAO,CAAC,KAAK,CACd,sBAAsB,CAAC,SAAS,CAAC;gBAC7B,EAAE,EAAE,kBAAkB,CAAC,KAAK;gBAC5B,IAAI,EAAE,KAAK;aACd,CAAC,CACL;YACL,KAAK,EAAE,GAAG,EAAE;YACR,wDAAwD;YACxD,IAAI,CAAC,OAAO,CAAC,KAAK,CACd,sBAAsB,CAAC,SAAS,CAAC;gBAC7B,EAAE,EAAE,kBAAkB,CAAC,UAAU;gBACjC,IAAI,EAAE,eAAe;aACxB,CAAC,CACL;SACR,CAAC,CAAC;IACP,CAAC;IAED,IAAI;QACA,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACJ"}
@@ -1,13 +1,13 @@
1
1
  import type { ReadableStream } from "@yume-chan/stream-extra";
2
2
  import { MaybeConsumable, WritableStream } from "@yume-chan/stream-extra";
3
- import type { AdbSocket } from "../../../adb.js";
4
- import type { AdbPtyProcess } from "../pty.js";
5
- export declare class AdbShellProtocolPtyProcess implements AdbPtyProcess<number> {
3
+ import type { Adb } from "../../../adb.js";
4
+ import type { AdbPty } from "../pty.js";
5
+ export declare class AdbShellProtocolPty implements AdbPty<number> {
6
6
  #private;
7
7
  get input(): WritableStream<MaybeConsumable<Uint8Array<ArrayBufferLike>>>;
8
8
  get output(): ReadableStream<Uint8Array<ArrayBufferLike>>;
9
9
  get exited(): Promise<number>;
10
- constructor(socket: AdbSocket);
10
+ constructor(socket: Adb.Socket);
11
11
  resize(rows: number, cols: number): Promise<void>;
12
12
  sigint(): Promise<void>;
13
13
  kill(): import("@yume-chan/async").MaybePromiseLike<void>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pty.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/pty.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAER,cAAc,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,eAAe,EAGf,cAAc,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIxC,qBAAa,mBAAoB,YAAW,MAAM,CAAC,MAAM,CAAC;;IAKtD,IAAI,KAAK,iEAER;IAGD,IAAI,MAAM,gDAET;IAGD,IAAI,MAAM,oBAET;gBAEW,MAAM,EAAE,GAAG,CAAC,MAAM;IAuDxB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAYvC,MAAM;IAKN,IAAI;CAGP"}
@@ -2,16 +2,16 @@ import { PromiseResolver } from "@yume-chan/async";
2
2
  import { MaybeConsumable, PushReadableStream, StructDeserializeStream, WritableStream, } from "@yume-chan/stream-extra";
3
3
  import { encodeUtf8 } from "@yume-chan/struct";
4
4
  import { AdbShellProtocolId, AdbShellProtocolPacket } from "./shared.js";
5
- export class AdbShellProtocolPtyProcess {
5
+ export class AdbShellProtocolPty {
6
6
  #socket;
7
7
  #writer;
8
8
  #input;
9
9
  get input() {
10
10
  return this.#input;
11
11
  }
12
- #stdout;
12
+ #output;
13
13
  get output() {
14
- return this.#stdout;
14
+ return this.#output;
15
15
  }
16
16
  #exited = new PromiseResolver();
17
17
  get exited() {
@@ -19,9 +19,9 @@ export class AdbShellProtocolPtyProcess {
19
19
  }
20
20
  constructor(socket) {
21
21
  this.#socket = socket;
22
- let stdoutController;
23
- this.#stdout = new PushReadableStream((controller) => {
24
- stdoutController = controller;
22
+ let outputController;
23
+ this.#output = new PushReadableStream((controller) => {
24
+ outputController = controller;
25
25
  });
26
26
  socket.readable
27
27
  .pipeThrough(new StructDeserializeStream(AdbShellProtocolPacket))
@@ -32,17 +32,18 @@ export class AdbShellProtocolPtyProcess {
32
32
  this.#exited.resolve(chunk.data[0]);
33
33
  break;
34
34
  case AdbShellProtocolId.Stdout:
35
- await stdoutController.enqueue(chunk.data);
35
+ await outputController.enqueue(chunk.data);
36
36
  break;
37
+ // PTY mode doesn't have stderr
37
38
  }
38
39
  },
39
40
  }))
40
41
  .then(() => {
41
- stdoutController.close();
42
+ outputController.close();
42
43
  // If `#exit` has already resolved, this will be a no-op
43
44
  this.#exited.reject(new Error("Socket ended without exit message"));
44
45
  }, (e) => {
45
- stdoutController.error(e);
46
+ outputController.error(e);
46
47
  // If `#exit` has already resolved, this will be a no-op
47
48
  this.#exited.reject(e);
48
49
  });
@@ -67,6 +68,7 @@ export class AdbShellProtocolPtyProcess {
67
68
  }));
68
69
  }
69
70
  sigint() {
71
+ // Write `^C`
70
72
  return this.#writeStdin(new Uint8Array([0x03]));
71
73
  }
72
74
  kill() {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pty.js","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/pty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMnD,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB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,KAAK,EAAE,CAAC;IAChC,CAAC;CACJ"}
@@ -0,0 +1,34 @@
1
+ import type { Adb } from "../../../adb.js";
2
+ import { AdbShellProtocolPty } from "./pty.js";
3
+ import { AdbShellProtocolId, AdbShellProtocolPacket } from "./shared.js";
4
+ export declare class AdbShellProtocolSubprocessService {
5
+ #private;
6
+ static readonly PacketId: {
7
+ readonly Stdin: 0;
8
+ readonly Stdout: 1;
9
+ readonly Stderr: 2;
10
+ readonly Exit: 3;
11
+ readonly CloseStdin: 4;
12
+ readonly WindowSizeChange: 5;
13
+ };
14
+ static readonly Packet: import("@yume-chan/struct").Struct<{
15
+ id: import("@yume-chan/struct").Field<AdbShellProtocolId, never, never, number>;
16
+ data: import("@yume-chan/struct").Field<Uint8Array<ArrayBufferLike>, string, never, Uint8Array<ArrayBufferLike>>;
17
+ }, undefined, import("@yume-chan/struct").FieldsValue<{
18
+ id: import("@yume-chan/struct").Field<AdbShellProtocolId, never, never, number>;
19
+ data: import("@yume-chan/struct").Field<Uint8Array<ArrayBufferLike>, string, never, Uint8Array<ArrayBufferLike>>;
20
+ }>>;
21
+ get adb(): Adb;
22
+ get isSupported(): boolean;
23
+ constructor(adb: Adb);
24
+ spawn: import("./spawner.js").AdbShellProtocolSpawner;
25
+ pty(options?: {
26
+ command?: string | readonly string[] | undefined;
27
+ terminalType?: string;
28
+ }): Promise<AdbShellProtocolPty>;
29
+ }
30
+ export declare namespace AdbShellProtocolSubprocessService {
31
+ type PacketId = AdbShellProtocolId;
32
+ type Packet = AdbShellProtocolPacket;
33
+ }
34
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGzE,qBAAa,iCAAiC;;IAC1C,MAAM,CAAC,QAAQ,CAAC,QAAQ;;;;;;;MAAsB;IAE9C,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;;QAA0B;IAGhD,IAAI,GAAG,QAEN;IAED,IAAI,WAAW,YAEd;gBAEW,GAAG,EAAE,GAAG;IAIpB,KAAK,iDAeF;IAEG,GAAG,CAAC,OAAO,CAAC,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;QACjD,YAAY,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAsBnC;AAED,yBAAiB,iCAAiC,CAAC;IAC/C,KAAY,QAAQ,GAAG,kBAAkB,CAAC;IAE1C,KAAY,MAAM,GAAG,sBAAsB,CAAC;CAC/C"}
@@ -0,0 +1,52 @@
1
+ import { AdbFeature } from "../../../features.js";
2
+ import { AdbShellProtocolProcessImpl } from "./process.js";
3
+ import { AdbShellProtocolPty } from "./pty.js";
4
+ import { AdbShellProtocolId, AdbShellProtocolPacket } from "./shared.js";
5
+ import { adbShellProtocolSpawner } from "./spawner.js";
6
+ export class AdbShellProtocolSubprocessService {
7
+ static PacketId = AdbShellProtocolId;
8
+ static Packet = AdbShellProtocolPacket;
9
+ #adb;
10
+ get adb() {
11
+ return this.#adb;
12
+ }
13
+ get isSupported() {
14
+ return this.#adb.canUseFeature(AdbFeature.Shell2);
15
+ }
16
+ constructor(adb) {
17
+ this.#adb = adb;
18
+ }
19
+ spawn = adbShellProtocolSpawner(async (command, signal) => {
20
+ if (!command.length) {
21
+ throw new Error("Command cannot be empty");
22
+ }
23
+ // Don't escape `command`. See `AdbNoneProtocolSubprocessService.prototype.spawn` for details.
24
+ const service = "shell,v2,raw:" + command.join(" ");
25
+ const socket = await this.#adb.createSocket(service);
26
+ if (signal?.aborted) {
27
+ await socket.close();
28
+ throw signal.reason;
29
+ }
30
+ return new AdbShellProtocolProcessImpl(socket, signal);
31
+ });
32
+ async pty(options) {
33
+ const { command, terminalType } = options ?? {};
34
+ let service = "shell,v2,pty";
35
+ if (terminalType) {
36
+ if (terminalType.includes(",") || terminalType.includes(":")) {
37
+ throw new Error("terminalType must not contain ',' or ':'");
38
+ }
39
+ service += `,TERM=` + terminalType;
40
+ }
41
+ service += ":";
42
+ if (typeof command === "string") {
43
+ service += command;
44
+ }
45
+ else if (Array.isArray(command)) {
46
+ // Don't escape `command`. See `AdbNoneProtocolSubprocessService.prototype.spawn` for details.
47
+ service += command.join(" ");
48
+ }
49
+ return new AdbShellProtocolPty(await this.#adb.createSocket(service));
50
+ }
51
+ }
52
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,OAAO,iCAAiC;IAC1C,MAAM,CAAU,QAAQ,GAAG,kBAAkB,CAAC;IAE9C,MAAM,CAAU,MAAM,GAAG,sBAAsB,CAAC;IAEvC,IAAI,CAAM;IACnB,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,YAAY,GAAQ;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,KAAK,GAAG,uBAAu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AAO,IAAI,mBAAmB,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/shared.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  import { buffer, struct, u32, u8 } from "@yume-chan/struct";
2
+ /** @internal */
2
3
  export const AdbShellProtocolId = {
3
4
  Stdin: 0,
4
5
  Stdout: 1,
@@ -8,6 +9,7 @@ export const AdbShellProtocolId = {
8
9
  WindowSizeChange: 5,
9
10
  };
10
11
  // This packet format is used in both directions.
12
+ /** @internal */
11
13
  export const AdbShellProtocolPacket = struct({
12
14
  id: u8(),
13
15
  data: buffer(u32),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAE5D,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,CAAC;IACb,gBAAgB,EAAE,CAAC;CACb,CAAC;AAMX,iDAAiD;AACjD,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CACxC;IACI,EAAE,EAAE,EAAE,EAAsB;IAC5B,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC;CACpB,EACD,EAAE,YAAY,EAAE,IAAI,EAAE,CACzB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { AbortSignal, MaybeConsumable, ReadableStream, WritableStream } from "@yume-chan/stream-extra";
3
+ import type { AdbSubprocessSpawner } from "../types.js";
3
4
  export interface AdbShellProtocolProcess {
4
5
  get stdin(): WritableStream<MaybeConsumable<Uint8Array>>;
5
6
  get stdout(): ReadableStream<Uint8Array>;
@@ -7,13 +8,7 @@ export interface AdbShellProtocolProcess {
7
8
  get exited(): Promise<number>;
8
9
  kill(): MaybePromiseLike<void>;
9
10
  }
10
- export declare class AdbShellProtocolSpawner {
11
- #private;
12
- constructor(spawn: (command: readonly string[], signal: AbortSignal | undefined) => Promise<AdbShellProtocolProcess>);
13
- spawn(command: string | readonly string[], signal?: AbortSignal): Promise<AdbShellProtocolProcess>;
14
- spawnWait(command: string | readonly string[]): Promise<AdbShellProtocolSpawner.WaitResult<Uint8Array>>;
15
- spawnWaitText(command: string | readonly string[]): Promise<AdbShellProtocolSpawner.WaitResult<string>>;
16
- }
11
+ export type AdbShellProtocolSpawner = (command: string | readonly string[], signal?: AbortSignal) => Promise<AdbShellProtocolProcess> & AdbSubprocessSpawner.Wait<AdbShellProtocolSpawner.WaitResult<Uint8Array>, AdbShellProtocolSpawner.WaitResult<string>>;
17
12
  export declare namespace AdbShellProtocolSpawner {
18
13
  interface WaitResult<T> {
19
14
  stdout: T;
@@ -21,4 +16,5 @@ export declare namespace AdbShellProtocolSpawner {
21
16
  exitCode: number;
22
17
  }
23
18
  }
19
+ export declare function adbShellProtocolSpawner(spawn: (command: readonly string[], signal: AbortSignal | undefined) => Promise<AdbShellProtocolProcess>): AdbShellProtocolSpawner;
24
20
  //# sourceMappingURL=spawner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawner.d.ts","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/spawner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACR,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQxD,MAAM,WAAW,uBAAuB;IACpC,IAAI,KAAK,IAAI,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzD,IAAI,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IACzC,IAAI,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IAEzC,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,uBAAuB,GAAG,CAClC,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACnC,MAAM,CAAC,EAAE,WAAW,KACnB,OAAO,CAAC,uBAAuB,CAAC,GACjC,oBAAoB,CAAC,IAAI,CACrB,uBAAuB,CAAC,UAAU,CAAC,UAAU,CAAC,EAC9C,uBAAuB,CAAC,UAAU,CAAC,MAAM,CAAC,CAC7C,CAAC;AAEN,yBAAiB,uBAAuB,CAAC;IACrC,UAAiB,UAAU,CAAC,CAAC;QACzB,MAAM,EAAE,CAAC,CAAC;QACV,MAAM,EAAE,CAAC,CAAC;QACV,QAAQ,EAAE,MAAM,CAAC;KACpB;CACJ;AAED,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,CACH,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,MAAM,EAAE,WAAW,GAAG,SAAS,KAC9B,OAAO,CAAC,uBAAuB,CAAC,GACtC,uBAAuB,CA8DzB"}
@@ -0,0 +1,50 @@
1
+ import { concatUint8Arrays } from "@yume-chan/stream-extra";
2
+ import { createLazyPromise, decodeUtf8Chunked, splitCommand, ToArrayStream, } from "../utils.js";
3
+ export function adbShellProtocolSpawner(spawn) {
4
+ return (command, signal) => {
5
+ signal?.throwIfAborted();
6
+ if (typeof command === "string") {
7
+ command = splitCommand(command);
8
+ }
9
+ const processPromise = spawn(command, signal);
10
+ processPromise.wait = (options) => {
11
+ const waitPromise = processPromise.then(async (process) => {
12
+ try {
13
+ const [, stdout, stderr, exitCode] = await Promise.all([
14
+ options?.stdin?.pipeTo(process.stdin),
15
+ process.stdout.pipeThrough(new ToArrayStream()),
16
+ process.stderr.pipeThrough(new ToArrayStream()),
17
+ process.exited,
18
+ ]);
19
+ return {
20
+ stdout,
21
+ stderr,
22
+ exitCode,
23
+ };
24
+ }
25
+ finally {
26
+ await process.kill();
27
+ }
28
+ });
29
+ return createLazyPromise(async () => {
30
+ const { stdout, stderr, exitCode } = await waitPromise;
31
+ return {
32
+ stdout: concatUint8Arrays(stdout),
33
+ stderr: concatUint8Arrays(stderr),
34
+ exitCode,
35
+ };
36
+ }, {
37
+ async toString() {
38
+ const { stdout, stderr, exitCode } = await waitPromise;
39
+ return {
40
+ stdout: decodeUtf8Chunked(stdout),
41
+ stderr: decodeUtf8Chunked(stderr),
42
+ exitCode,
43
+ };
44
+ },
45
+ });
46
+ };
47
+ return processPromise;
48
+ };
49
+ }
50
+ //# sourceMappingURL=spawner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawner.js","sourceRoot":"","sources":["../../../../src/service/subprocess/shell/spawner.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,aAAa,GAChB,MAAM,aAAa,CAAC;AA8BrB,MAAM,UAAU,uBAAuB,CACnC,KAGqC;IAErC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACvB,MAAM,EAAE,cAAc,EAAE,CAAC;QAEzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,cAAc,GAAG,KAAK,CACxB,OAAO,EACP,MAAM,CAKL,CAAC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,cAAc,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { MaybeConsumable, ReadableStream } from "@yume-chan/stream-extra";
2
+ import type { LazyPromise } from "./utils.js";
3
+ export declare namespace AdbSubprocessSpawner {
4
+ interface WaitToString<T> {
5
+ toString(): Promise<T>;
6
+ }
7
+ interface WaitOptions {
8
+ stdin?: ReadableStream<MaybeConsumable<Uint8Array>> | undefined;
9
+ }
10
+ interface Wait<TBuffer, TString> {
11
+ wait(options?: WaitOptions): LazyPromise<TBuffer, WaitToString<TString>>;
12
+ }
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/service/subprocess/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,yBAAiB,oBAAoB,CAAC;IAClC,UAAiB,YAAY,CAAC,CAAC;QAC3B,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,UAAiB,WAAW;QACxB,KAAK,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;KACnE;IAED,UAAiB,IAAI,CAAC,OAAO,EAAE,OAAO;QAClC,IAAI,CACA,OAAO,CAAC,EAAE,WAAW,GACtB,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;KAClD;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/service/subprocess/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { AccumulateStream } from "@yume-chan/stream-extra";
2
+ export declare function escapeArg(s: string): string;
3
+ /**
4
+ * Split the command.
5
+ *
6
+ * Quotes and escaped characters are supported, and will be returned as-is.
7
+ * @param input The input command
8
+ * @returns An array of string containing the arguments
9
+ */
10
+ export declare function splitCommand(input: string): string[];
11
+ export type LazyPromise<T, U> = Omit<Promise<T>, typeof Symbol.toStringTag> & U;
12
+ /**
13
+ * Creates a `Promise`-like object that lazily computes the result
14
+ * only when it's being used as a `Promise`.
15
+ *
16
+ * For example, if an API returns a value `p` of type `Promise<T> & { asU(): Promise<U> }`,
17
+ * and the user calls `p.asU()` instead of using it as a `Promise` (`p.then()`, `await p`, etc.),
18
+ * is unnecessary to compute the result `T` (unless `asU` also depends on it).
19
+ *
20
+ * By using `createLazyPromise(computeT, { asU: computeU })`,
21
+ * `computeT` will only run when `p` is used as a `Promise`.
22
+ *
23
+ * Note that the result object can't be returned from an async function,
24
+ * as async functions always creates a new `Promise` with the return value,
25
+ * which runs `initializer` immediately, and discards any extra `methods` attached.
26
+ * @param initializer
27
+ * The initializer function when the result object is being used as a `Promise`.
28
+ *
29
+ * The result value will be cached.
30
+ * @param methods Any extra methods to add to the result object
31
+ * @returns
32
+ * A `Promise`-like object that runs `initializer` when used as a `Promise`, and contains `methods`.
33
+ */
34
+ export declare function createLazyPromise<T, U extends Record<PropertyKey, () => unknown>>(initializer: () => Promise<T>, methods: U): LazyPromise<T, U>;
35
+ export declare class ToArrayStream<T> extends AccumulateStream<T, T[]> {
36
+ constructor();
37
+ }
38
+ export declare function decodeUtf8Chunked(chunks: Uint8Array[]): string;
39
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/service/subprocess/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,UAoBlC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAyCpD;AAID,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAC7B,CAAC,EACD,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,EAC9C,WAAW,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAoC9D;AAED,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;;CAW7D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAU9D"}