@yume-chan/adb 0.0.18 → 0.0.20

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 (241) hide show
  1. package/CHANGELOG.json +54 -0
  2. package/CHANGELOG.md +25 -1
  3. package/README.md +220 -103
  4. package/esm/adb.d.ts +43 -60
  5. package/esm/adb.d.ts.map +1 -1
  6. package/esm/adb.js +68 -249
  7. package/esm/adb.js.map +1 -1
  8. package/esm/banner.d.ts +17 -0
  9. package/esm/banner.d.ts.map +1 -0
  10. package/esm/banner.js +67 -0
  11. package/esm/banner.js.map +1 -0
  12. package/esm/commands/base.d.ts +6 -6
  13. package/esm/commands/base.d.ts.map +1 -1
  14. package/esm/commands/base.js +8 -8
  15. package/esm/commands/framebuffer.d.ts +53 -53
  16. package/esm/commands/framebuffer.d.ts.map +1 -1
  17. package/esm/commands/framebuffer.js +46 -46
  18. package/esm/commands/framebuffer.js.map +1 -1
  19. package/esm/commands/index.d.ts +7 -8
  20. package/esm/commands/index.d.ts.map +1 -1
  21. package/esm/commands/index.js +7 -8
  22. package/esm/commands/index.js.map +1 -1
  23. package/esm/commands/power.d.ts +22 -22
  24. package/esm/commands/power.js +48 -48
  25. package/esm/commands/reverse.d.ts +40 -28
  26. package/esm/commands/reverse.d.ts.map +1 -1
  27. package/esm/commands/reverse.js +130 -100
  28. package/esm/commands/reverse.js.map +1 -1
  29. package/esm/commands/subprocess/command.d.ts +57 -51
  30. package/esm/commands/subprocess/command.d.ts.map +1 -1
  31. package/esm/commands/subprocess/command.js +86 -80
  32. package/esm/commands/subprocess/command.js.map +1 -1
  33. package/esm/commands/subprocess/index.d.ts +3 -3
  34. package/esm/commands/subprocess/index.js +3 -3
  35. package/esm/commands/subprocess/protocols/index.d.ts +3 -3
  36. package/esm/commands/subprocess/protocols/index.js +3 -3
  37. package/esm/commands/subprocess/protocols/none.d.ts +30 -35
  38. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
  39. package/esm/commands/subprocess/protocols/none.js +65 -55
  40. package/esm/commands/subprocess/protocols/none.js.map +1 -1
  41. package/esm/commands/subprocess/protocols/shell.d.ts +33 -38
  42. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
  43. package/esm/commands/subprocess/protocols/shell.js +172 -162
  44. package/esm/commands/subprocess/protocols/shell.js.map +1 -1
  45. package/esm/commands/subprocess/protocols/types.d.ts +48 -49
  46. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
  47. package/esm/commands/subprocess/protocols/types.js +1 -1
  48. package/esm/commands/subprocess/utils.d.ts +1 -1
  49. package/esm/commands/subprocess/utils.js +18 -18
  50. package/esm/commands/sync/index.d.ts +8 -7
  51. package/esm/commands/sync/index.d.ts.map +1 -1
  52. package/esm/commands/sync/index.js +8 -7
  53. package/esm/commands/sync/index.js.map +1 -1
  54. package/esm/commands/sync/list.d.ts +42 -40
  55. package/esm/commands/sync/list.d.ts.map +1 -1
  56. package/esm/commands/sync/list.js +67 -47
  57. package/esm/commands/sync/list.js.map +1 -1
  58. package/esm/commands/sync/pull.d.ts +13 -11
  59. package/esm/commands/sync/pull.d.ts.map +1 -1
  60. package/esm/commands/sync/pull.js +35 -37
  61. package/esm/commands/sync/pull.js.map +1 -1
  62. package/esm/commands/sync/push.d.ts +57 -7
  63. package/esm/commands/sync/push.d.ts.map +1 -1
  64. package/esm/commands/sync/push.js +89 -22
  65. package/esm/commands/sync/push.js.map +1 -1
  66. package/esm/commands/sync/request.d.ts +26 -23
  67. package/esm/commands/sync/request.d.ts.map +1 -1
  68. package/esm/commands/sync/request.js +40 -42
  69. package/esm/commands/sync/request.js.map +1 -1
  70. package/esm/commands/sync/response.d.ts +19 -19
  71. package/esm/commands/sync/response.d.ts.map +1 -1
  72. package/esm/commands/sync/response.js +54 -54
  73. package/esm/commands/sync/response.js.map +1 -1
  74. package/esm/commands/sync/socket.d.ts +22 -0
  75. package/esm/commands/sync/socket.d.ts.map +1 -0
  76. package/esm/commands/sync/socket.js +69 -0
  77. package/esm/commands/sync/socket.js.map +1 -0
  78. package/esm/commands/sync/stat.d.ts +72 -72
  79. package/esm/commands/sync/stat.d.ts.map +1 -1
  80. package/esm/commands/sync/stat.js +116 -104
  81. package/esm/commands/sync/stat.js.map +1 -1
  82. package/esm/commands/sync/sync.d.ts +65 -60
  83. package/esm/commands/sync/sync.d.ts.map +1 -1
  84. package/esm/commands/sync/sync.js +123 -149
  85. package/esm/commands/sync/sync.js.map +1 -1
  86. package/esm/commands/tcpip.d.ts +5 -5
  87. package/esm/commands/tcpip.d.ts.map +1 -1
  88. package/esm/commands/tcpip.js +20 -18
  89. package/esm/commands/tcpip.js.map +1 -1
  90. package/esm/{auth.d.ts → daemon/auth.d.ts} +50 -51
  91. package/esm/daemon/auth.d.ts.map +1 -0
  92. package/esm/{auth.js → daemon/auth.js} +95 -96
  93. package/esm/daemon/auth.js.map +1 -0
  94. package/esm/daemon/connection.d.ts +11 -0
  95. package/esm/daemon/connection.d.ts.map +1 -0
  96. package/esm/daemon/connection.js +2 -0
  97. package/esm/daemon/connection.js.map +1 -0
  98. package/esm/{crypto.d.ts → daemon/crypto.d.ts} +36 -36
  99. package/esm/daemon/crypto.d.ts.map +1 -0
  100. package/esm/{crypto.js → daemon/crypto.js} +244 -248
  101. package/esm/daemon/crypto.js.map +1 -0
  102. package/esm/daemon/device.d.ts +9 -0
  103. package/esm/daemon/device.d.ts.map +1 -0
  104. package/esm/daemon/device.js +2 -0
  105. package/esm/daemon/device.js.map +1 -0
  106. package/esm/daemon/dispatcher.d.ts +42 -0
  107. package/esm/daemon/dispatcher.d.ts.map +1 -0
  108. package/esm/{socket → daemon}/dispatcher.js +225 -234
  109. package/esm/daemon/dispatcher.js.map +1 -0
  110. package/esm/daemon/index.d.ts +8 -0
  111. package/esm/daemon/index.d.ts.map +1 -0
  112. package/esm/daemon/index.js +8 -0
  113. package/esm/daemon/index.js.map +1 -0
  114. package/esm/{packet.d.ts → daemon/packet.d.ts} +45 -46
  115. package/esm/daemon/packet.d.ts.map +1 -0
  116. package/esm/{packet.js → daemon/packet.js} +43 -48
  117. package/esm/daemon/packet.js.map +1 -0
  118. package/esm/daemon/socket.d.ts +58 -0
  119. package/esm/daemon/socket.d.ts.map +1 -0
  120. package/esm/{socket → daemon}/socket.js +121 -118
  121. package/esm/daemon/socket.js.map +1 -0
  122. package/esm/daemon/transport.d.ts +45 -0
  123. package/esm/daemon/transport.d.ts.map +1 -0
  124. package/esm/daemon/transport.js +184 -0
  125. package/esm/daemon/transport.js.map +1 -0
  126. package/esm/features.d.ts +10 -7
  127. package/esm/features.d.ts.map +1 -1
  128. package/esm/features.js +13 -10
  129. package/esm/features.js.map +1 -1
  130. package/esm/index.d.ts +7 -9
  131. package/esm/index.d.ts.map +1 -1
  132. package/esm/index.js +7 -9
  133. package/esm/index.js.map +1 -1
  134. package/esm/server/client.d.ts +78 -0
  135. package/esm/server/client.d.ts.map +1 -0
  136. package/esm/server/client.js +329 -0
  137. package/esm/server/client.js.map +1 -0
  138. package/esm/server/index.d.ts +3 -0
  139. package/esm/server/index.d.ts.map +1 -0
  140. package/esm/server/index.js +3 -0
  141. package/esm/server/index.js.map +1 -0
  142. package/esm/server/transport.d.ts +19 -0
  143. package/esm/server/transport.d.ts.map +1 -0
  144. package/esm/server/transport.js +44 -0
  145. package/esm/server/transport.js.map +1 -0
  146. package/esm/utils/auto-reset-event.d.ts +8 -9
  147. package/esm/utils/auto-reset-event.d.ts.map +1 -1
  148. package/esm/utils/auto-reset-event.js +33 -33
  149. package/esm/utils/auto-reset-event.js.map +1 -1
  150. package/esm/utils/base64.d.ts +27 -27
  151. package/esm/utils/base64.js +246 -246
  152. package/esm/utils/base64.js.map +1 -1
  153. package/esm/utils/conditional-variable.d.ts +8 -0
  154. package/esm/utils/conditional-variable.d.ts.map +1 -0
  155. package/esm/utils/conditional-variable.js +34 -0
  156. package/esm/utils/conditional-variable.js.map +1 -0
  157. package/esm/utils/hex.d.ts +3 -0
  158. package/esm/utils/hex.d.ts.map +1 -0
  159. package/esm/utils/hex.js +55 -0
  160. package/esm/utils/hex.js.map +1 -0
  161. package/esm/utils/index.d.ts +6 -3
  162. package/esm/utils/index.d.ts.map +1 -1
  163. package/esm/utils/index.js +6 -3
  164. package/esm/utils/index.js.map +1 -1
  165. package/esm/utils/no-op.d.ts +7 -0
  166. package/esm/utils/no-op.d.ts.map +1 -0
  167. package/esm/utils/no-op.js +12 -0
  168. package/esm/utils/no-op.js.map +1 -0
  169. package/package.json +14 -12
  170. package/src/adb.ts +47 -248
  171. package/src/banner.ts +82 -0
  172. package/src/commands/base.ts +1 -1
  173. package/src/commands/framebuffer.ts +4 -4
  174. package/src/commands/index.ts +7 -8
  175. package/src/commands/power.ts +2 -2
  176. package/src/commands/reverse.ts +90 -70
  177. package/src/commands/subprocess/command.ts +12 -4
  178. package/src/commands/subprocess/index.ts +3 -3
  179. package/src/commands/subprocess/protocols/index.ts +3 -3
  180. package/src/commands/subprocess/protocols/none.ts +36 -23
  181. package/src/commands/subprocess/protocols/shell.ts +94 -74
  182. package/src/commands/subprocess/protocols/types.ts +7 -7
  183. package/src/commands/subprocess/utils.ts +1 -1
  184. package/src/commands/sync/index.ts +8 -7
  185. package/src/commands/sync/list.ts +44 -25
  186. package/src/commands/sync/pull.ts +40 -45
  187. package/src/commands/sync/push.ts +158 -39
  188. package/src/commands/sync/request.ts +21 -16
  189. package/src/commands/sync/response.ts +10 -9
  190. package/src/commands/sync/socket.ts +99 -0
  191. package/src/commands/sync/stat.ts +47 -42
  192. package/src/commands/sync/sync.ts +73 -116
  193. package/src/commands/tcpip.ts +9 -7
  194. package/src/{auth.ts → daemon/auth.ts} +24 -23
  195. package/src/{crypto.ts → daemon/crypto.ts} +25 -33
  196. package/src/daemon/device.ts +14 -0
  197. package/src/{socket → daemon}/dispatcher.ts +95 -117
  198. package/src/daemon/index.ts +7 -0
  199. package/src/daemon/packet.ts +75 -0
  200. package/src/{socket → daemon}/socket.ts +71 -56
  201. package/src/daemon/transport.ts +269 -0
  202. package/src/features.ts +9 -6
  203. package/src/index.ts +3 -5
  204. package/src/server/client.ts +476 -0
  205. package/src/server/index.ts +2 -0
  206. package/src/server/transport.ts +77 -0
  207. package/src/utils/auto-reset-event.ts +14 -15
  208. package/src/utils/conditional-variable.ts +45 -0
  209. package/src/utils/hex.ts +58 -0
  210. package/src/utils/index.ts +6 -3
  211. package/src/utils/no-op.ts +12 -0
  212. package/tsconfig.build.json +12 -1
  213. package/tsconfig.build.tsbuildinfo +1 -1
  214. package/esm/auth.d.ts.map +0 -1
  215. package/esm/auth.js.map +0 -1
  216. package/esm/backend.d.ts +0 -9
  217. package/esm/backend.d.ts.map +0 -1
  218. package/esm/backend.js +0 -2
  219. package/esm/backend.js.map +0 -1
  220. package/esm/commands/install.d.ts +0 -4
  221. package/esm/commands/install.d.ts.map +0 -1
  222. package/esm/commands/install.js +0 -29
  223. package/esm/commands/install.js.map +0 -1
  224. package/esm/crypto.d.ts.map +0 -1
  225. package/esm/crypto.js.map +0 -1
  226. package/esm/packet.d.ts.map +0 -1
  227. package/esm/packet.js.map +0 -1
  228. package/esm/socket/dispatcher.d.ts +0 -60
  229. package/esm/socket/dispatcher.d.ts.map +0 -1
  230. package/esm/socket/dispatcher.js.map +0 -1
  231. package/esm/socket/index.d.ts +0 -3
  232. package/esm/socket/index.d.ts.map +0 -1
  233. package/esm/socket/index.js +0 -3
  234. package/esm/socket/index.js.map +0 -1
  235. package/esm/socket/socket.d.ts +0 -60
  236. package/esm/socket/socket.d.ts.map +0 -1
  237. package/esm/socket/socket.js.map +0 -1
  238. package/src/backend.ts +0 -14
  239. package/src/commands/install.ts +0 -40
  240. package/src/packet.ts +0 -90
  241. package/src/socket/index.ts +0 -2
@@ -1,39 +1,34 @@
1
- import { WritableStream, type ReadableStream } from "@yume-chan/stream-extra";
2
- import { type Adb } from "../../../adb.js";
3
- import { type AdbSocket } from "../../../socket/index.js";
4
- import { type AdbSubprocessProtocol } from "./types.js";
5
- export declare enum AdbShellProtocolId {
6
- Stdin = 0,
7
- Stdout = 1,
8
- Stderr = 2,
9
- Exit = 3,
10
- CloseStdin = 4,
11
- WindowSizeChange = 5
12
- }
13
- /**
14
- * Shell v2 a.k.a Shell Protocol
15
- *
16
- * Features:
17
- * * `stderr`: Yes
18
- * * `exit` exit code: Yes
19
- * * `resize`: Yes
20
- */
21
- export declare class AdbSubprocessShellProtocol implements AdbSubprocessProtocol {
22
- static isSupported(adb: Adb): boolean;
23
- static pty(adb: Adb, command: string): Promise<AdbSubprocessShellProtocol>;
24
- static raw(adb: Adb, command: string): Promise<AdbSubprocessShellProtocol>;
25
- private readonly _socket;
26
- private _socketWriter;
27
- private _stdin;
28
- get stdin(): WritableStream<Uint8Array>;
29
- private _stdout;
30
- get stdout(): ReadableStream<Uint8Array>;
31
- private _stderr;
32
- get stderr(): ReadableStream<Uint8Array>;
33
- private readonly _exit;
34
- get exit(): Promise<number>;
35
- constructor(socket: AdbSocket);
36
- resize(rows: number, cols: number): Promise<void>;
37
- kill(): Promise<void>;
38
- }
1
+ import type { Consumable, ReadableStream } from "@yume-chan/stream-extra";
2
+ import { WritableStream } from "@yume-chan/stream-extra";
3
+ import type { Adb, AdbSocket } from "../../../adb.js";
4
+ import type { AdbSubprocessProtocol } from "./types.js";
5
+ export declare enum AdbShellProtocolId {
6
+ Stdin = 0,
7
+ Stdout = 1,
8
+ Stderr = 2,
9
+ Exit = 3,
10
+ CloseStdin = 4,
11
+ WindowSizeChange = 5
12
+ }
13
+ /**
14
+ * Shell v2 a.k.a Shell Protocol
15
+ *
16
+ * Features:
17
+ * * `stderr`: Yes
18
+ * * `exit` exit code: Yes
19
+ * * `resize`: Yes
20
+ */
21
+ export declare class AdbSubprocessShellProtocol implements AdbSubprocessProtocol {
22
+ #private;
23
+ static isSupported(adb: Adb): boolean;
24
+ static pty(adb: Adb, command: string): Promise<AdbSubprocessShellProtocol>;
25
+ static raw(adb: Adb, command: string): Promise<AdbSubprocessShellProtocol>;
26
+ get stdin(): WritableStream<Consumable<Uint8Array>>;
27
+ get stdout(): ReadableStream<Uint8Array>;
28
+ get stderr(): ReadableStream<Uint8Array>;
29
+ get exit(): Promise<number>;
30
+ constructor(socket: AdbSocket);
31
+ resize(rows: number, cols: number): Promise<void>;
32
+ kill(): import("@yume-chan/struct").ValueOrPromise<void>;
33
+ }
39
34
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/shell.ts"],"names":[],"mappings":"AACA,OAAO,EAKH,cAAc,EAGd,KAAK,cAAc,EAEtB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,oBAAY,kBAAkB;IAC1B,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,UAAU,IAAA;IACV,gBAAgB,IAAA;CACnB;AAgFD;;;;;;;GAOG;AACH,qBAAa,0BAA2B,YAAW,qBAAqB;WACtD,WAAW,CAAC,GAAG,EAAE,GAAG;WAId,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;WAO7B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;IAMjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;IACpC,OAAO,CAAC,aAAa,CAA0D;IAE/E,OAAO,CAAC,MAAM,CAA6B;IAC3C,IAAW,KAAK,+BAEf;IAED,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,+BAEhB;IAED,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,+BAEhB;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,IAAW,IAAI,oBAEd;gBAEkB,MAAM,EAAE,SAAS;IAkDvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAYvC,IAAI;CAGd"}
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/shell.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,UAAU,EAEV,cAAc,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAKH,cAAc,EAEjB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAItD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,oBAAY,kBAAkB;IAC1B,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,UAAU,IAAA;IACV,gBAAgB,IAAA;CACnB;AAsED;;;;;;;GAOG;AACH,qBAAa,0BAA2B,YAAW,qBAAqB;;WACtD,WAAW,CAAC,GAAG,EAAE,GAAG;WAId,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;WAO7B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;IAYjD,IAAW,KAAK,2CAEf;IAGD,IAAW,MAAM,+BAEhB;IAGD,IAAW,MAAM,+BAEhB;IAGD,IAAW,IAAI,oBAEd;gBAEkB,MAAM,EAAE,SAAS;IA2EvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAYvC,IAAI;CAGd"}
@@ -1,163 +1,173 @@
1
- import { PromiseResolver } from '@yume-chan/async';
2
- import { PushReadableStream, StructDeserializeStream, StructSerializeStream, TransformStream, WritableStream, pipeFrom, } from "@yume-chan/stream-extra";
3
- import Struct, { placeholder } from '@yume-chan/struct';
4
- import { AdbFeatures } from '../../../features.js';
5
- import { encodeUtf8 } from '../../../utils/index.js';
6
- export var AdbShellProtocolId;
7
- (function (AdbShellProtocolId) {
8
- AdbShellProtocolId[AdbShellProtocolId["Stdin"] = 0] = "Stdin";
9
- AdbShellProtocolId[AdbShellProtocolId["Stdout"] = 1] = "Stdout";
10
- AdbShellProtocolId[AdbShellProtocolId["Stderr"] = 2] = "Stderr";
11
- AdbShellProtocolId[AdbShellProtocolId["Exit"] = 3] = "Exit";
12
- AdbShellProtocolId[AdbShellProtocolId["CloseStdin"] = 4] = "CloseStdin";
13
- AdbShellProtocolId[AdbShellProtocolId["WindowSizeChange"] = 5] = "WindowSizeChange";
14
- })(AdbShellProtocolId = AdbShellProtocolId || (AdbShellProtocolId = {}));
15
- // This packet format is used in both direction.
16
- const AdbShellProtocolPacket = new Struct({ littleEndian: true })
17
- .uint8('id', placeholder())
18
- .uint32('length')
19
- .uint8Array('data', { lengthField: 'length' });
20
- class StdinSerializeStream extends TransformStream {
21
- constructor() {
22
- super({
23
- transform(chunk, controller) {
24
- controller.enqueue({
25
- id: AdbShellProtocolId.Stdin,
26
- data: chunk,
27
- });
28
- },
29
- flush() {
30
- // TODO: AdbShellSubprocessProtocol: support closing stdin
31
- }
32
- });
33
- }
34
- }
35
- class StdoutDeserializeStream extends TransformStream {
36
- constructor(type) {
37
- super({
38
- transform(chunk, controller) {
39
- if (chunk.id === type) {
40
- controller.enqueue(chunk.data);
41
- }
42
- },
43
- });
44
- }
45
- }
46
- class MultiplexStream {
47
- _readable;
48
- _readableController;
49
- get readable() {
50
- return this._readable;
51
- }
52
- _activeCount = 0;
53
- constructor() {
54
- this._readable = new PushReadableStream((controller) => {
55
- this._readableController = controller;
56
- });
57
- }
58
- createWriteable() {
59
- return new WritableStream({
60
- start: () => {
61
- this._activeCount += 1;
62
- },
63
- write: async (chunk) => {
64
- await this._readableController.enqueue(chunk);
65
- },
66
- abort: () => {
67
- this._activeCount -= 1;
68
- if (this._activeCount === 0) {
69
- this._readableController.close();
70
- }
71
- },
72
- close: () => {
73
- this._activeCount -= 1;
74
- if (this._activeCount === 0) {
75
- this._readableController.close();
76
- }
77
- },
78
- });
79
- }
80
- }
81
- /**
82
- * Shell v2 a.k.a Shell Protocol
83
- *
84
- * Features:
85
- * * `stderr`: Yes
86
- * * `exit` exit code: Yes
87
- * * `resize`: Yes
88
- */
89
- export class AdbSubprocessShellProtocol {
90
- static isSupported(adb) {
91
- return adb.features.includes(AdbFeatures.ShellV2);
92
- }
93
- static async pty(adb, command) {
94
- // TODO: AdbShellSubprocessProtocol: Support setting `XTERM` environment variable
95
- return new AdbSubprocessShellProtocol(await adb.createSocket(`shell,v2,pty:${command}`));
96
- }
97
- static async raw(adb, command) {
98
- return new AdbSubprocessShellProtocol(await adb.createSocket(`shell,v2,raw:${command}`));
99
- }
100
- _socket;
101
- _socketWriter;
102
- _stdin;
103
- get stdin() {
104
- return this._stdin;
105
- }
106
- _stdout;
107
- get stdout() {
108
- return this._stdout;
109
- }
110
- _stderr;
111
- get stderr() {
112
- return this._stderr;
113
- }
114
- _exit = new PromiseResolver();
115
- get exit() {
116
- return this._exit.promise;
117
- }
118
- constructor(socket) {
119
- this._socket = socket;
120
- // Check this image to help you understand the stream graph
121
- // cspell: disable-next-line
122
- // https://www.plantuml.com/plantuml/png/bL91QiCm4Bpx5SAdv90lb1JISmiw5XzaQKf5PIkiLZIqzEyLSg8ks13gYtOykpFhiOw93N6UGjVDqK7rZsxKqNw0U_NTgVAy4empOy2mm4_olC0VEVEE47GUpnGjKdgXoD76q4GIEpyFhOwP_m28hW0NNzxNUig1_JdW0bA7muFIJDco1daJ_1SAX9bgvoPJPyIkSekhNYctvIGXrCH6tIsPL5fs-s6J5yc9BpWXhKtNdF2LgVYPGM_6GlMwfhWUsIt4lbScANrwlgVVUifPSVi__t44qStnwPvZwobdSmHHlL57p2vFuHS0
123
- // TODO: AdbShellSubprocessProtocol: Optimize stream graph
124
- const [stdout, stderr] = socket.readable
125
- .pipeThrough(new StructDeserializeStream(AdbShellProtocolPacket))
126
- .pipeThrough(new TransformStream({
127
- transform: (chunk, controller) => {
128
- if (chunk.id === AdbShellProtocolId.Exit) {
129
- this._exit.resolve(new Uint8Array(chunk.data)[0]);
130
- // We can let `StdoutDeserializeStream` to process `AdbShellProtocolId.Exit`,
131
- // but since we need this `TransformStream` to capture the exit code anyway,
132
- // terminating child streams here is killing two birds with one stone.
133
- controller.terminate();
134
- return;
135
- }
136
- controller.enqueue(chunk);
137
- },
138
- }))
139
- .tee();
140
- this._stdout = stdout.pipeThrough(new StdoutDeserializeStream(AdbShellProtocolId.Stdout));
141
- this._stderr = stderr.pipeThrough(new StdoutDeserializeStream(AdbShellProtocolId.Stderr));
142
- const multiplexer = new MultiplexStream();
143
- void multiplexer.readable
144
- .pipeThrough(new StructSerializeStream(AdbShellProtocolPacket))
145
- .pipeTo(socket.writable);
146
- this._stdin = pipeFrom(multiplexer.createWriteable(), new StdinSerializeStream());
147
- this._socketWriter = multiplexer.createWriteable().getWriter();
148
- }
149
- async resize(rows, cols) {
150
- await this._socketWriter.write({
151
- id: AdbShellProtocolId.WindowSizeChange,
152
- data: encodeUtf8(
153
- // The "correct" format is `${rows}x${cols},${x_pixels}x${y_pixels}`
154
- // However, according to https://linux.die.net/man/4/tty_ioctl
155
- // `x_pixels` and `y_pixels` are unused, so always sending `0` should be fine.
156
- `${rows}x${cols},0x0\0`),
157
- });
158
- }
159
- kill() {
160
- return this._socket.close();
161
- }
162
- }
1
+ import { PromiseResolver } from "@yume-chan/async";
2
+ import { ConsumableTransformStream, ConsumableWritableStream, PushReadableStream, StructDeserializeStream, WritableStream, pipeFrom, } from "@yume-chan/stream-extra";
3
+ import Struct, { placeholder } from "@yume-chan/struct";
4
+ import { AdbFeature } from "../../../features.js";
5
+ import { encodeUtf8 } from "../../../utils/index.js";
6
+ export var AdbShellProtocolId;
7
+ (function (AdbShellProtocolId) {
8
+ AdbShellProtocolId[AdbShellProtocolId["Stdin"] = 0] = "Stdin";
9
+ AdbShellProtocolId[AdbShellProtocolId["Stdout"] = 1] = "Stdout";
10
+ AdbShellProtocolId[AdbShellProtocolId["Stderr"] = 2] = "Stderr";
11
+ AdbShellProtocolId[AdbShellProtocolId["Exit"] = 3] = "Exit";
12
+ AdbShellProtocolId[AdbShellProtocolId["CloseStdin"] = 4] = "CloseStdin";
13
+ AdbShellProtocolId[AdbShellProtocolId["WindowSizeChange"] = 5] = "WindowSizeChange";
14
+ })(AdbShellProtocolId = AdbShellProtocolId || (AdbShellProtocolId = {}));
15
+ // This packet format is used in both direction.
16
+ const AdbShellProtocolPacket = new Struct({ littleEndian: true })
17
+ .uint8("id", placeholder())
18
+ .uint32("length")
19
+ .uint8Array("data", { lengthField: "length" });
20
+ class StdinSerializeStream extends ConsumableTransformStream {
21
+ constructor() {
22
+ super({
23
+ async transform(chunk, controller) {
24
+ await controller.enqueue({
25
+ id: AdbShellProtocolId.Stdin,
26
+ data: chunk,
27
+ });
28
+ },
29
+ flush() {
30
+ // TODO: AdbShellSubprocessProtocol: support closing stdin
31
+ },
32
+ });
33
+ }
34
+ }
35
+ class MultiplexStream {
36
+ _readable;
37
+ _readableController;
38
+ get readable() {
39
+ return this._readable;
40
+ }
41
+ _activeCount = 0;
42
+ constructor() {
43
+ this._readable = new PushReadableStream((controller) => {
44
+ this._readableController = controller;
45
+ });
46
+ }
47
+ createWriteable() {
48
+ return new WritableStream({
49
+ start: () => {
50
+ this._activeCount += 1;
51
+ },
52
+ write: async (chunk) => {
53
+ await this._readableController.enqueue(chunk);
54
+ },
55
+ abort: () => {
56
+ this._activeCount -= 1;
57
+ if (this._activeCount === 0) {
58
+ this._readableController.close();
59
+ }
60
+ },
61
+ close: () => {
62
+ this._activeCount -= 1;
63
+ if (this._activeCount === 0) {
64
+ this._readableController.close();
65
+ }
66
+ },
67
+ });
68
+ }
69
+ }
70
+ /**
71
+ * Shell v2 a.k.a Shell Protocol
72
+ *
73
+ * Features:
74
+ * * `stderr`: Yes
75
+ * * `exit` exit code: Yes
76
+ * * `resize`: Yes
77
+ */
78
+ export class AdbSubprocessShellProtocol {
79
+ static isSupported(adb) {
80
+ return adb.supportsFeature(AdbFeature.ShellV2);
81
+ }
82
+ static async pty(adb, command) {
83
+ // TODO: AdbShellSubprocessProtocol: Support setting `XTERM` environment variable
84
+ return new AdbSubprocessShellProtocol(await adb.createSocket(`shell,v2,pty:${command}`));
85
+ }
86
+ static async raw(adb, command) {
87
+ return new AdbSubprocessShellProtocol(await adb.createSocket(`shell,v2,raw:${command}`));
88
+ }
89
+ #socket;
90
+ #socketWriter;
91
+ #stdin;
92
+ get stdin() {
93
+ return this.#stdin;
94
+ }
95
+ #stdout;
96
+ get stdout() {
97
+ return this.#stdout;
98
+ }
99
+ #stderr;
100
+ get stderr() {
101
+ return this.#stderr;
102
+ }
103
+ #exit = new PromiseResolver();
104
+ get exit() {
105
+ return this.#exit.promise;
106
+ }
107
+ constructor(socket) {
108
+ this.#socket = socket;
109
+ // Check this image to help you understand the stream graph
110
+ // cspell: disable-next-line
111
+ // https://www.plantuml.com/plantuml/png/bL91QiCm4Bpx5SAdv90lb1JISmiw5XzaQKf5PIkiLZIqzEyLSg8ks13gYtOykpFhiOw93N6UGjVDqK7rZsxKqNw0U_NTgVAy4empOy2mm4_olC0VEVEE47GUpnGjKdgXoD76q4GIEpyFhOwP_m28hW0NNzxNUig1_JdW0bA7muFIJDco1daJ_1SAX9bgvoPJPyIkSekhNYctvIGXrCH6tIsPL5fs-s6J5yc9BpWXhKtNdF2LgVYPGM_6GlMwfhWUsIt4lbScANrwlgVVUifPSVi__t44qStnwPvZwobdSmHHlL57p2vFuHS0
112
+ let stdoutController;
113
+ let stderrController;
114
+ this.#stdout = new PushReadableStream((controller) => {
115
+ stdoutController = controller;
116
+ });
117
+ this.#stderr = new PushReadableStream((controller) => {
118
+ stderrController = controller;
119
+ });
120
+ socket.readable
121
+ .pipeThrough(new StructDeserializeStream(AdbShellProtocolPacket))
122
+ .pipeTo(new WritableStream({
123
+ write: async (chunk) => {
124
+ switch (chunk.id) {
125
+ case AdbShellProtocolId.Exit:
126
+ this.#exit.resolve(chunk.data[0]);
127
+ break;
128
+ case AdbShellProtocolId.Stdout:
129
+ await stdoutController.enqueue(chunk.data);
130
+ break;
131
+ case AdbShellProtocolId.Stderr:
132
+ await stderrController.enqueue(chunk.data);
133
+ break;
134
+ }
135
+ },
136
+ }))
137
+ .then(() => {
138
+ stdoutController.close();
139
+ stderrController.close();
140
+ // If `#exit` has already resolved, this will be a no-op
141
+ this.#exit.reject(new Error("Socket ended without exit message"));
142
+ }, (e) => {
143
+ stdoutController.error(e);
144
+ stderrController.error(e);
145
+ // If `#exit` has already resolved, this will be a no-op
146
+ this.#exit.reject(e);
147
+ });
148
+ const multiplexer = new MultiplexStream();
149
+ void multiplexer.readable
150
+ .pipeThrough(new ConsumableTransformStream({
151
+ async transform(chunk, controller) {
152
+ await controller.enqueue(AdbShellProtocolPacket.serialize(chunk));
153
+ },
154
+ }))
155
+ .pipeTo(socket.writable);
156
+ this.#stdin = pipeFrom(multiplexer.createWriteable(), new StdinSerializeStream());
157
+ this.#socketWriter = multiplexer.createWriteable().getWriter();
158
+ }
159
+ async resize(rows, cols) {
160
+ await ConsumableWritableStream.write(this.#socketWriter, {
161
+ id: AdbShellProtocolId.WindowSizeChange,
162
+ data: encodeUtf8(
163
+ // The "correct" format is `${rows}x${cols},${x_pixels}x${y_pixels}`
164
+ // However, according to https://linux.die.net/man/4/tty_ioctl
165
+ // `x_pixels` and `y_pixels` are unused, so always sending `0` should be fine.
166
+ `${rows}x${cols},0x0\0`),
167
+ });
168
+ }
169
+ kill() {
170
+ return this.#socket.close();
171
+ }
172
+ }
163
173
  //# sourceMappingURL=shell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACH,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe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AQ,CAAC,CAAC;QAE7B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAClB,WAAW,CAAC,eAAe,EAAE,EAC7B,IAAI,oBAAoB,EAAE,CAC7B,CAAC;QAEF,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,eAAe,EAAE,CAAC,SAAS,EAAE,CAAC;IACnE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,IAAY;QAC1C,MAAM,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE;YACrD,EAAE,EAAE,kBAAkB,CAAC,gBAAgB;YACvC,IAAI,EAAE,UAAU;YACZ,oEAAoE;YACpE,8DAA8D;YAC9D,8EAA8E;YAC9E,GAAG,IAAI,IAAI,IAAI,QAAQ,CAC1B;SACJ,CAAC,CAAC;IACP,CAAC;IAEM,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACJ"}
@@ -1,50 +1,49 @@
1
- import { type ReadableStream, type WritableStream } from "@yume-chan/stream-extra";
2
- import { type ValueOrPromise } from "@yume-chan/struct";
3
- import { type Adb } from "../../../adb.js";
4
- import { type AdbSocket } from "../../../socket/index.js";
5
- export interface AdbSubprocessProtocol {
6
- /**
7
- * A WritableStream that writes to the `stdin` stream.
8
- */
9
- readonly stdin: WritableStream<Uint8Array>;
10
- /**
11
- * The `stdout` stream of the process.
12
- */
13
- readonly stdout: ReadableStream<Uint8Array>;
14
- /**
15
- * The `stderr` stream of the process.
16
- *
17
- * Note: Some `AdbSubprocessProtocol` doesn't separate `stdout` and `stderr`,
18
- * All output will be sent to `stdout`.
19
- */
20
- readonly stderr: ReadableStream<Uint8Array>;
21
- /**
22
- * A `Promise` that resolves to the exit code of the process.
23
- *
24
- * Note: Some `AdbSubprocessProtocol` doesn't support exit code,
25
- * They will always resolve it with `0`.
26
- */
27
- readonly exit: Promise<number>;
28
- /**
29
- * Resizes the current shell.
30
- *
31
- * Some `AdbSubprocessProtocol`s may not support resizing
32
- * and will ignore calls to this method.
33
- */
34
- resize(rows: number, cols: number): ValueOrPromise<void>;
35
- /**
36
- * Kills the current process.
37
- */
38
- kill(): ValueOrPromise<void>;
39
- }
40
- export interface AdbSubprocessProtocolConstructor {
41
- /** Returns `true` if the `adb` instance supports this shell */
42
- isSupported(adb: Adb): ValueOrPromise<boolean>;
43
- /** Spawns an executable in PTY (interactive) mode. */
44
- pty(adb: Adb, command: string): ValueOrPromise<AdbSubprocessProtocol>;
45
- /** Spawns an executable and pipe the output. */
46
- raw(adb: Adb, command: string): ValueOrPromise<AdbSubprocessProtocol>;
47
- /** Creates a new `AdbShell` by attaching to an exist `AdbSocket` */
48
- new (socket: AdbSocket): AdbSubprocessProtocol;
49
- }
1
+ import type { Consumable, ReadableStream, WritableStream } from "@yume-chan/stream-extra";
2
+ import type { ValueOrPromise } from "@yume-chan/struct";
3
+ import type { Adb, AdbSocket } from "../../../adb.js";
4
+ export interface AdbSubprocessProtocol {
5
+ /**
6
+ * A WritableStream that writes to the `stdin` stream.
7
+ */
8
+ readonly stdin: WritableStream<Consumable<Uint8Array>>;
9
+ /**
10
+ * The `stdout` stream of the process.
11
+ */
12
+ readonly stdout: ReadableStream<Uint8Array>;
13
+ /**
14
+ * The `stderr` stream of the process.
15
+ *
16
+ * Note: Some `AdbSubprocessProtocol` doesn't separate `stdout` and `stderr`,
17
+ * All output will be sent to `stdout`.
18
+ */
19
+ readonly stderr: ReadableStream<Uint8Array>;
20
+ /**
21
+ * A `Promise` that resolves to the exit code of the process.
22
+ *
23
+ * Note: Some `AdbSubprocessProtocol` doesn't support exit code,
24
+ * They will always resolve it with `0`.
25
+ */
26
+ readonly exit: Promise<number>;
27
+ /**
28
+ * Resizes the current shell.
29
+ *
30
+ * Some `AdbSubprocessProtocol`s may not support resizing
31
+ * and will ignore calls to this method.
32
+ */
33
+ resize(rows: number, cols: number): ValueOrPromise<void>;
34
+ /**
35
+ * Kills the current process.
36
+ */
37
+ kill(): ValueOrPromise<void>;
38
+ }
39
+ export interface AdbSubprocessProtocolConstructor {
40
+ /** Returns `true` if the `adb` instance supports this shell */
41
+ isSupported(adb: Adb): ValueOrPromise<boolean>;
42
+ /** Spawns an executable in PTY (interactive) mode. */
43
+ pty(adb: Adb, command: string): ValueOrPromise<AdbSubprocessProtocol>;
44
+ /** Spawns an executable and pipe the output. */
45
+ raw(adb: Adb, command: string): ValueOrPromise<AdbSubprocessProtocol>;
46
+ /** Creates a new `AdbShell` by attaching to an exist `AdbSocket` */
47
+ new (socket: AdbSocket): AdbSubprocessProtocol;
48
+ }
50
49
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,cAAc,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAE5C;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAE5C;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD;;OAEG;IACH,IAAI,IAAI,cAAc,CAAC,IAAI,C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CAAC,CAAC;CAChC;AAED,MAAM,WAAW,gCAAgC;IAC7C,+DAA+D;IAC/D,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAE/C,sDAAsD;IACtD,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC;IAEtE,gDAAgD;IAChD,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC;IAEtE,oEAAoE;IACpE,KAAK,MAAM,EAAE,SAAS,GAAG,qBAAqB,CAAC;CAClD"}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=types.js.map
@@ -1,2 +1,2 @@
1
- export declare function escapeArg(s: string): string;
1
+ export declare function escapeArg(s: string): string;
2
2
  //# sourceMappingURL=utils.d.ts.map
@@ -1,19 +1,19 @@
1
- export function escapeArg(s) {
2
- let result = '';
3
- result += `'`;
4
- let base = 0;
5
- while (true) {
6
- const found = s.indexOf(`'`, base);
7
- if (found === -1) {
8
- result += s.substring(base);
9
- break;
10
- }
11
- result += s.substring(base, found);
12
- // a'b becomes a'\'b
13
- result += String.raw `'\''`;
14
- base = found + 1;
15
- }
16
- result += `'`;
17
- return result;
18
- }
1
+ export function escapeArg(s) {
2
+ let result = "";
3
+ result += `'`;
4
+ let base = 0;
5
+ while (true) {
6
+ const found = s.indexOf(`'`, base);
7
+ if (found === -1) {
8
+ result += s.substring(base);
9
+ break;
10
+ }
11
+ result += s.substring(base, found);
12
+ // a'b becomes a'\'b
13
+ result += String.raw `'\''`;
14
+ base = found + 1;
15
+ }
16
+ result += `'`;
17
+ return result;
18
+ }
19
19
  //# sourceMappingURL=utils.js.map
@@ -1,8 +1,9 @@
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 './stat.js';
7
- export * from './sync.js';
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";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}