@yume-chan/adb 0.0.17 → 0.0.19

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 (177) hide show
  1. package/CHANGELOG.json +27 -0
  2. package/CHANGELOG.md +16 -1
  3. package/LICENSE +1 -1
  4. package/esm/adb.d.ts +63 -60
  5. package/esm/adb.d.ts.map +1 -1
  6. package/esm/adb.js +257 -229
  7. package/esm/adb.js.map +1 -1
  8. package/esm/auth.d.ts +51 -51
  9. package/esm/auth.d.ts.map +1 -1
  10. package/esm/auth.js +95 -96
  11. package/esm/auth.js.map +1 -1
  12. package/esm/backend.d.ts +8 -8
  13. package/esm/backend.d.ts.map +1 -1
  14. package/esm/backend.js +1 -1
  15. package/esm/commands/base.d.ts +6 -6
  16. package/esm/commands/base.js +8 -8
  17. package/esm/commands/framebuffer.d.ts +53 -53
  18. package/esm/commands/framebuffer.d.ts.map +1 -1
  19. package/esm/commands/framebuffer.js +46 -47
  20. package/esm/commands/framebuffer.js.map +1 -1
  21. package/esm/commands/index.d.ts +7 -8
  22. package/esm/commands/index.d.ts.map +1 -1
  23. package/esm/commands/index.js +7 -8
  24. package/esm/commands/index.js.map +1 -1
  25. package/esm/commands/install.d.ts +9 -3
  26. package/esm/commands/install.d.ts.map +1 -1
  27. package/esm/commands/install.js +27 -21
  28. package/esm/commands/install.js.map +1 -1
  29. package/esm/commands/power.d.ts +22 -22
  30. package/esm/commands/power.d.ts.map +1 -1
  31. package/esm/commands/power.js +48 -44
  32. package/esm/commands/power.js.map +1 -1
  33. package/esm/commands/reverse.d.ts +41 -28
  34. package/esm/commands/reverse.d.ts.map +1 -1
  35. package/esm/commands/reverse.js +125 -98
  36. package/esm/commands/reverse.js.map +1 -1
  37. package/esm/commands/subprocess/command.d.ts +57 -51
  38. package/esm/commands/subprocess/command.d.ts.map +1 -1
  39. package/esm/commands/subprocess/command.js +86 -82
  40. package/esm/commands/subprocess/command.js.map +1 -1
  41. package/esm/commands/subprocess/index.d.ts +3 -3
  42. package/esm/commands/subprocess/index.js +3 -3
  43. package/esm/commands/subprocess/protocols/index.d.ts +3 -3
  44. package/esm/commands/subprocess/protocols/index.js +3 -3
  45. package/esm/commands/subprocess/protocols/none.d.ts +35 -35
  46. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
  47. package/esm/commands/subprocess/protocols/none.js +65 -55
  48. package/esm/commands/subprocess/protocols/none.js.map +1 -1
  49. package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
  50. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
  51. package/esm/commands/subprocess/protocols/shell.js +166 -154
  52. package/esm/commands/subprocess/protocols/shell.js.map +1 -1
  53. package/esm/commands/subprocess/protocols/types.d.ts +49 -49
  54. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
  55. package/esm/commands/subprocess/protocols/types.js +1 -1
  56. package/esm/commands/subprocess/utils.d.ts +1 -1
  57. package/esm/commands/subprocess/utils.js +18 -18
  58. package/esm/commands/sync/index.d.ts +8 -7
  59. package/esm/commands/sync/index.d.ts.map +1 -1
  60. package/esm/commands/sync/index.js +8 -7
  61. package/esm/commands/sync/index.js.map +1 -1
  62. package/esm/commands/sync/list.d.ts +42 -40
  63. package/esm/commands/sync/list.d.ts.map +1 -1
  64. package/esm/commands/sync/list.js +67 -35
  65. package/esm/commands/sync/list.js.map +1 -1
  66. package/esm/commands/sync/pull.d.ts +13 -11
  67. package/esm/commands/sync/pull.d.ts.map +1 -1
  68. package/esm/commands/sync/pull.js +35 -36
  69. package/esm/commands/sync/pull.js.map +1 -1
  70. package/esm/commands/sync/push.d.ts +46 -7
  71. package/esm/commands/sync/push.d.ts.map +1 -1
  72. package/esm/commands/sync/push.js +89 -23
  73. package/esm/commands/sync/push.js.map +1 -1
  74. package/esm/commands/sync/request.d.ts +26 -23
  75. package/esm/commands/sync/request.d.ts.map +1 -1
  76. package/esm/commands/sync/request.js +40 -42
  77. package/esm/commands/sync/request.js.map +1 -1
  78. package/esm/commands/sync/response.d.ts +19 -19
  79. package/esm/commands/sync/response.d.ts.map +1 -1
  80. package/esm/commands/sync/response.js +54 -54
  81. package/esm/commands/sync/response.js.map +1 -1
  82. package/esm/commands/sync/socket.d.ts +27 -0
  83. package/esm/commands/sync/socket.d.ts.map +1 -0
  84. package/esm/commands/sync/socket.js +66 -0
  85. package/esm/commands/sync/socket.js.map +1 -0
  86. package/esm/commands/sync/stat.d.ts +72 -72
  87. package/esm/commands/sync/stat.d.ts.map +1 -1
  88. package/esm/commands/sync/stat.js +116 -94
  89. package/esm/commands/sync/stat.js.map +1 -1
  90. package/esm/commands/sync/sync.d.ts +72 -60
  91. package/esm/commands/sync/sync.d.ts.map +1 -1
  92. package/esm/commands/sync/sync.js +127 -148
  93. package/esm/commands/sync/sync.js.map +1 -1
  94. package/esm/commands/tcpip.d.ts +5 -5
  95. package/esm/commands/tcpip.js +18 -18
  96. package/esm/crypto.d.ts +36 -36
  97. package/esm/crypto.d.ts.map +1 -1
  98. package/esm/crypto.js +248 -238
  99. package/esm/crypto.js.map +1 -1
  100. package/esm/features.d.ts +10 -7
  101. package/esm/features.d.ts.map +1 -1
  102. package/esm/features.js +13 -10
  103. package/esm/features.js.map +1 -1
  104. package/esm/index.d.ts +9 -9
  105. package/esm/index.d.ts.map +1 -1
  106. package/esm/index.js +9 -9
  107. package/esm/index.js.map +1 -1
  108. package/esm/packet.d.ts +45 -46
  109. package/esm/packet.d.ts.map +1 -1
  110. package/esm/packet.js +43 -46
  111. package/esm/packet.js.map +1 -1
  112. package/esm/socket/dispatcher.d.ts +59 -59
  113. package/esm/socket/dispatcher.d.ts.map +1 -1
  114. package/esm/socket/dispatcher.js +223 -231
  115. package/esm/socket/dispatcher.js.map +1 -1
  116. package/esm/socket/index.d.ts +2 -2
  117. package/esm/socket/index.js +2 -2
  118. package/esm/socket/socket.d.ts +59 -59
  119. package/esm/socket/socket.d.ts.map +1 -1
  120. package/esm/socket/socket.js +118 -98
  121. package/esm/socket/socket.js.map +1 -1
  122. package/esm/utils/auto-reset-event.d.ts +9 -9
  123. package/esm/utils/auto-reset-event.d.ts.map +1 -1
  124. package/esm/utils/auto-reset-event.js +33 -33
  125. package/esm/utils/auto-reset-event.js.map +1 -1
  126. package/esm/utils/base64.d.ts +27 -27
  127. package/esm/utils/base64.d.ts.map +1 -1
  128. package/esm/utils/base64.js +246 -245
  129. package/esm/utils/base64.js.map +1 -1
  130. package/esm/utils/conditional-variable.d.ts +9 -0
  131. package/esm/utils/conditional-variable.d.ts.map +1 -0
  132. package/esm/utils/conditional-variable.js +34 -0
  133. package/esm/utils/conditional-variable.js.map +1 -0
  134. package/esm/utils/index.d.ts +4 -3
  135. package/esm/utils/index.d.ts.map +1 -1
  136. package/esm/utils/index.js +4 -3
  137. package/esm/utils/index.js.map +1 -1
  138. package/package.json +17 -13
  139. package/src/adb.ts +160 -101
  140. package/src/auth.ts +31 -22
  141. package/src/backend.ts +6 -4
  142. package/src/commands/base.ts +2 -2
  143. package/src/commands/framebuffer.ts +37 -41
  144. package/src/commands/index.ts +7 -8
  145. package/src/commands/power.ts +15 -11
  146. package/src/commands/reverse.ts +74 -30
  147. package/src/commands/subprocess/command.ts +34 -23
  148. package/src/commands/subprocess/index.ts +3 -3
  149. package/src/commands/subprocess/protocols/index.ts +3 -3
  150. package/src/commands/subprocess/protocols/none.ts +26 -11
  151. package/src/commands/subprocess/protocols/shell.ts +110 -56
  152. package/src/commands/subprocess/protocols/types.ts +10 -6
  153. package/src/commands/subprocess/utils.ts +1 -1
  154. package/src/commands/sync/index.ts +8 -7
  155. package/src/commands/sync/list.ts +74 -28
  156. package/src/commands/sync/pull.ts +49 -37
  157. package/src/commands/sync/push.ts +153 -32
  158. package/src/commands/sync/request.ts +37 -34
  159. package/src/commands/sync/response.ts +34 -27
  160. package/src/commands/sync/socket.ts +97 -0
  161. package/src/commands/sync/stat.ts +98 -70
  162. package/src/commands/sync/sync.ts +78 -97
  163. package/src/commands/tcpip.ts +5 -5
  164. package/src/crypto.ts +60 -32
  165. package/src/features.ts +9 -6
  166. package/src/index.ts +9 -10
  167. package/src/packet.ts +41 -46
  168. package/src/socket/dispatcher.ts +130 -108
  169. package/src/socket/index.ts +2 -2
  170. package/src/socket/socket.ts +84 -34
  171. package/src/utils/auto-reset-event.ts +16 -17
  172. package/src/utils/base64.ts +51 -41
  173. package/src/utils/conditional-variable.ts +45 -0
  174. package/src/utils/index.ts +4 -3
  175. package/tsconfig.build.json +1 -1
  176. package/tsconfig.build.tsbuildinfo +1 -1
  177. package/src/commands/install.ts +0 -32
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,yBAAyB,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,UAAU,OAAO,CACnB,GAAQ;IAER,MAAM,QAAQ,GAAG,mBAAmB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAEhF,IAAI,IAAc,CAAC;IACnB,OAAO,IAAI,kBAAkB,CAAa;QACtC,KAAK,CAAC,KAAK;YACP,qEAAqE;YACrE,oEAAoE;YAEpE,gCAAgC;YAChC,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACtD,CAAC;QACD,KAAK,CAAC,KAAK;YACP,IAAI,CAAC,OAAO,EAAE,CAAC;YAEf,oCAAoC;YACpC,MAAM,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEhF,uBAAuB;YACvB,MAAM,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAQ,EAAE,IAAgC;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,mBAAmB,QAAQ,MAAM,CAAC;IAEnD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI;QACA,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;KAC1D;YAAS;QACN,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;KACxB;IAED,IAAI;QACA,MAAM,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC;YACpC,IAAI;YACJ,SAAS;YACT,SAAS,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAC;KACN;YAAS;QACN,MAAM,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC1B;AACL,CAAC"}
@@ -1,23 +1,23 @@
1
- import { AdbCommandBase } from './base.js';
2
- export declare class AdbPower extends AdbCommandBase {
3
- reboot(name?: string): Promise<string>;
4
- bootloader(): Promise<string>;
5
- fastboot(): Promise<string>;
6
- recovery(): Promise<string>;
7
- sideload(): Promise<string>;
8
- /**
9
- * Reboot to Qualcomm Emergency Download (EDL) Mode.
10
- *
11
- * Only works on some Qualcomm devices.
12
- */
13
- qualcommEdlMode(): Promise<string>;
14
- powerOff(): Promise<string>;
15
- powerButton(longPress?: boolean): Promise<string>;
16
- /**
17
- * Reboot to Samsung Odin download mode.
18
- *
19
- * Only works on Samsung devices.
20
- */
21
- samsungOdin(): Promise<string>;
22
- }
1
+ import { AdbCommandBase } from "./base.js";
2
+ export declare class AdbPower extends AdbCommandBase {
3
+ reboot(name?: string): Promise<string>;
4
+ bootloader(): Promise<string>;
5
+ fastboot(): Promise<string>;
6
+ recovery(): Promise<string>;
7
+ sideload(): Promise<string>;
8
+ /**
9
+ * Reboot to Qualcomm Emergency Download (EDL) Mode.
10
+ *
11
+ * Only works on some Qualcomm devices.
12
+ */
13
+ qualcommEdlMode(): Promise<string>;
14
+ powerOff(): Promise<string>;
15
+ powerButton(longPress?: boolean): Promise<string>;
16
+ /**
17
+ * Reboot to Samsung Odin download mode.
18
+ *
19
+ * Only works on Samsung devices.
20
+ */
21
+ samsungOdin(): Promise<string>;
22
+ }
23
23
  //# sourceMappingURL=power.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,QAAS,SAAQ,cAAc;IACjC,MAAM,CAAC,IAAI,GAAE,MAAW;IAIxB,UAAU;IAIV,QAAQ;IAIR,QAAQ;IAIR,QAAQ;IAIf;;;;OAIG;IACI,eAAe;IAIf,QAAQ;IAIR,WAAW,CAAC,SAAS,GAAE,OAAe;IAI7C;;;;OAIG;IACI,WAAW;CAGrB"}
1
+ {"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,QAAS,SAAQ,cAAc;IACjC,MAAM,CAAC,IAAI,SAAK;IAIhB,UAAU;IAIV,QAAQ;IAIR,QAAQ;IAIR,QAAQ;IAIf;;;;OAIG;IACI,eAAe;IAIf,QAAQ;IAIR,WAAW,CAAC,SAAS,UAAQ;IAQpC;;;;OAIG;IACI,WAAW;CAGrB"}
@@ -1,45 +1,49 @@
1
- // cspell: ignore bootloader
2
- // cspell: ignore fastboot
3
- // cspell: ignore keyevent
4
- // cspell: ignore longpress
5
- import { AdbCommandBase } from './base.js';
6
- export class AdbPower extends AdbCommandBase {
7
- reboot(name = '') {
8
- return this.adb.createSocketAndWait(`reboot:${name}`);
9
- }
10
- bootloader() {
11
- return this.reboot('bootloader');
12
- }
13
- fastboot() {
14
- return this.reboot('fastboot');
15
- }
16
- recovery() {
17
- return this.reboot('recovery');
18
- }
19
- sideload() {
20
- return this.reboot('sideload');
21
- }
22
- /**
23
- * Reboot to Qualcomm Emergency Download (EDL) Mode.
24
- *
25
- * Only works on some Qualcomm devices.
26
- */
27
- qualcommEdlMode() {
28
- return this.reboot('edl');
29
- }
30
- powerOff() {
31
- return this.adb.subprocess.spawnAndWaitLegacy(['reboot', '-p']);
32
- }
33
- powerButton(longPress = false) {
34
- return this.adb.subprocess.spawnAndWaitLegacy(['input', 'keyevent', longPress ? '--longpress POWER' : 'POWER']);
35
- }
36
- /**
37
- * Reboot to Samsung Odin download mode.
38
- *
39
- * Only works on Samsung devices.
40
- */
41
- samsungOdin() {
42
- return this.reboot('download');
43
- }
44
- }
1
+ // cspell: ignore bootloader
2
+ // cspell: ignore fastboot
3
+ // cspell: ignore keyevent
4
+ // cspell: ignore longpress
5
+ import { AdbCommandBase } from "./base.js";
6
+ export class AdbPower extends AdbCommandBase {
7
+ reboot(name = "") {
8
+ return this.adb.createSocketAndWait(`reboot:${name}`);
9
+ }
10
+ bootloader() {
11
+ return this.reboot("bootloader");
12
+ }
13
+ fastboot() {
14
+ return this.reboot("fastboot");
15
+ }
16
+ recovery() {
17
+ return this.reboot("recovery");
18
+ }
19
+ sideload() {
20
+ return this.reboot("sideload");
21
+ }
22
+ /**
23
+ * Reboot to Qualcomm Emergency Download (EDL) Mode.
24
+ *
25
+ * Only works on some Qualcomm devices.
26
+ */
27
+ qualcommEdlMode() {
28
+ return this.reboot("edl");
29
+ }
30
+ powerOff() {
31
+ return this.adb.subprocess.spawnAndWaitLegacy(["reboot", "-p"]);
32
+ }
33
+ powerButton(longPress = false) {
34
+ return this.adb.subprocess.spawnAndWaitLegacy([
35
+ "input",
36
+ "keyevent",
37
+ longPress ? "--longpress POWER" : "POWER",
38
+ ]);
39
+ }
40
+ /**
41
+ * Reboot to Samsung Odin download mode.
42
+ *
43
+ * Only works on Samsung devices.
44
+ */
45
+ samsungOdin() {
46
+ return this.reboot("download");
47
+ }
48
+ }
45
49
  //# sourceMappingURL=power.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"power.js","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,0BAA0B;AAC1B,0BAA0B;AAC1B,2BAA2B;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,QAAS,SAAQ,cAAc;IACjC,MAAM,CAAC,OAAe,EAAE;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,eAAe;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;IAEM,WAAW,CAAC,YAAqB,KAAK;QACzC,OAAO,IA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kB,CAAC;YAC1C,OAAO;YACP,UAAU;YACV,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO;SAC5C,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACJ"}
@@ -1,29 +1,42 @@
1
- import { AutoDisposable } from '@yume-chan/event';
2
- import type { Adb } from '../adb.js';
3
- import type { AdbIncomingSocketHandler, AdbSocket } from '../socket/index.js';
4
- export interface AdbForwardListener {
5
- deviceSerial: string;
6
- localName: string;
7
- remoteName: string;
8
- }
9
- export declare class AdbReverseCommand extends AutoDisposable {
10
- protected localAddressToHandler: Map<string, AdbIncomingSocketHandler>;
11
- protected deviceAddressToLocalAddress: Map<string, string>;
12
- protected adb: Adb;
13
- protected listening: boolean;
14
- constructor(adb: Adb);
15
- protected handleIncomingSocket: (socket: AdbSocket) => Promise<boolean>;
16
- private createBufferedStream;
17
- private sendRequest;
18
- list(): Promise<AdbForwardListener[]>;
19
- /**
20
- * @param deviceAddress The address adbd on device is listening on. Can be `tcp:0` to let adbd choose an available TCP port by itself.
21
- * @param localAddress Native ADB client will open a connection to this address when reverse connection received. In WebADB, it's only used to uniquely identify a reverse tunnel registry, `handler` will be called to handle the connection.
22
- * @param handler A callback to handle incoming connections. It must return `true` if it accepts the connection.
23
- * @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
24
- */
25
- add(deviceAddress: string, localAddress: string, handler: AdbIncomingSocketHandler): Promise<string>;
26
- remove(deviceAddress: string): Promise<void>;
27
- removeAll(): Promise<void>;
28
- }
1
+ import { AutoDisposable } from "@yume-chan/event";
2
+ import type { Adb } from "../adb.js";
3
+ import type { AdbIncomingSocketHandler, AdbSocket } from "../socket/index.js";
4
+ export interface AdbForwardListener {
5
+ deviceSerial: string;
6
+ localName: string;
7
+ remoteName: string;
8
+ }
9
+ export declare class AdbReverseError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ export declare class AdbReverseNotSupportedError extends Error {
13
+ constructor();
14
+ }
15
+ export declare class AdbReverseCommand extends AutoDisposable {
16
+ protected localAddressToHandler: Map<string, AdbIncomingSocketHandler>;
17
+ protected deviceAddressToLocalAddress: Map<string, string>;
18
+ protected adb: Adb;
19
+ protected listening: boolean;
20
+ constructor(adb: Adb);
21
+ protected handleIncomingSocket: (socket: AdbSocket) => Promise<boolean>;
22
+ private createBufferedStream;
23
+ private sendRequest;
24
+ list(): Promise<AdbForwardListener[]>;
25
+ /**
26
+ * @param deviceAddress
27
+ * The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
28
+ * @param localAddress
29
+ * An identifier for the reverse tunnel.
30
+ *
31
+ * When a socket wants to connect to {@link deviceAddress}, native ADB client will forward that connection to {@link localAddress}.
32
+ * However in this library, the {@link handler} is invoked instead. So this parameter is only used to identify the reverse tunnel.
33
+ * @param handler A callback to handle incoming connections. It must return `true` if it accepts the connection.
34
+ * @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
35
+ * @throws {AdbReverseNotSupportedError} If ADB reverse tunnel is not supported on this device when connected wirelessly.
36
+ * @throws {AdbReverseError} If ADB daemon returns an error.
37
+ */
38
+ add(deviceAddress: string, localAddress: string, handler: AdbIncomingSocketHandler): Promise<string>;
39
+ remove(deviceAddress: string): Promise<void>;
40
+ removeAll(): Promise<void>;
41
+ }
29
42
  //# sourceMappingURL=reverse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,o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AAQ,cAAc;IACjD,SAAS,CAAC,qBAAqB,wCAG3B;IAEJ,SAAS,CAAC,2BAA2B,sBAA6B;IAElE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEnB,SAAS,CAAC,SAAS,UAAS;gBAET,GAAG,EAAE,GAAG;IAS3B,SAAS,CAAC,oBAAoB,WAAkB,SAAS,sBAKvD;YAEY,oBAAoB;YAKpB,WAAW;IASZ,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAgBlD;;;;;;;;;;;;OAYG;IACU,GAAG,CACZ,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,MAAM,CAAC;IAkCL,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa5C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ1C"}
@@ -1,99 +1,126 @@
1
- // cspell: ignore killforward
2
- import { AutoDisposable } from '@yume-chan/event';
3
- import { BufferedReadableStream, BufferedReadableStreamEndedError } from '@yume-chan/stream-extra';
4
- import Struct from '@yume-chan/struct';
5
- import { decodeUtf8 } from '../utils/index.js';
6
- const AdbReverseStringResponse = new Struct()
7
- .string('length', { length: 4 })
8
- .string('content', { lengthField: 'length', lengthFieldRadix: 16 });
9
- const AdbReverseErrorResponse = new Struct()
10
- .fields(AdbReverseStringResponse)
11
- .postDeserialize((value) => {
12
- throw new Error(value.content);
13
- });
14
- export class AdbReverseCommand extends AutoDisposable {
15
- localAddressToHandler = new Map();
16
- deviceAddressToLocalAddress = new Map();
17
- adb;
18
- listening = false;
19
- constructor(adb) {
20
- super();
21
- this.adb = adb;
22
- this.addDisposable(this.adb.onIncomingSocket(this.handleIncomingSocket));
23
- }
24
- handleIncomingSocket = async (socket) => {
25
- let address = socket.serviceString;
26
- // ADB daemon appends `\0` to the service string
27
- address = address.replace(/\0/g, '');
28
- return !!(await this.localAddressToHandler.get(address)?.(socket));
29
- };
30
- async createBufferedStream(service) {
31
- const socket = await this.adb.createSocket(service);
32
- return new BufferedReadableStream(socket.readable);
33
- }
34
- async sendRequest(service) {
35
- const stream = await this.createBufferedStream(service);
36
- const success = decodeUtf8(await stream.read(4)) === 'OKAY';
37
- if (!success) {
38
- await AdbReverseErrorResponse.deserialize(stream);
39
- }
40
- return stream;
41
- }
42
- async list() {
43
- const stream = await this.createBufferedStream('reverse:list-forward');
44
- const response = await AdbReverseStringResponse.deserialize(stream);
45
- return response.content.split('\n').map(line => {
46
- const [deviceSerial, localName, remoteName] = line.split(' ');
47
- return { deviceSerial, localName, remoteName };
48
- });
49
- // No need to close the stream, device will close it
50
- }
51
- /**
52
- * @param deviceAddress The address adbd on device is listening on. Can be `tcp:0` to let adbd choose an available TCP port by itself.
53
- * @param localAddress Native ADB client will open a connection to this address when reverse connection received. In WebADB, it's only used to uniquely identify a reverse tunnel registry, `handler` will be called to handle the connection.
54
- * @param handler A callback to handle incoming connections. It must return `true` if it accepts the connection.
55
- * @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
56
- */
57
- async add(deviceAddress, localAddress, handler) {
58
- const stream = await this.sendRequest(`reverse:forward:${deviceAddress};${localAddress}`);
59
- // `tcp:0` tells the device to pick an available port.
60
- // On Android >=8, device will respond with the selected port for all `tcp:` requests.
61
- if (deviceAddress.startsWith('tcp:')) {
62
- let length;
63
- try {
64
- length = Number.parseInt(decodeUtf8(await stream.read(4)), 16);
65
- }
66
- catch (e) {
67
- if (!(e instanceof BufferedReadableStreamEndedError)) {
68
- throw e;
69
- }
70
- // Android <8 doesn't have this response.
71
- // (the stream is closed now)
72
- // Can be safely ignored.
73
- }
74
- if (length !== undefined) {
75
- const port = decodeUtf8(await stream.read(length));
76
- deviceAddress = `tcp:${Number.parseInt(port, 10)}`;
77
- }
78
- }
79
- this.localAddressToHandler.set(localAddress, handler);
80
- this.deviceAddressToLocalAddress.set(deviceAddress, localAddress);
81
- return deviceAddress;
82
- // No need to close the stream, device will close it
83
- }
84
- async remove(deviceAddress) {
85
- await this.sendRequest(`reverse:killforward:${deviceAddress}`);
86
- if (this.deviceAddressToLocalAddress.has(deviceAddress)) {
87
- this.localAddressToHandler.delete(this.deviceAddressToLocalAddress.get(deviceAddress));
88
- this.deviceAddressToLocalAddress.delete(deviceAddress);
89
- }
90
- // No need to close the stream, device will close it
91
- }
92
- async removeAll() {
93
- await this.sendRequest(`reverse:killforward-all`);
94
- this.deviceAddressToLocalAddress.clear();
95
- this.localAddressToHandler.clear();
96
- // No need to close the stream, device will close it
97
- }
98
- }
1
+ // cspell: ignore killforward
2
+ import { AutoDisposable } from "@yume-chan/event";
3
+ import { BufferedReadableStream, BufferedReadableStreamEndedError, } from "@yume-chan/stream-extra";
4
+ import Struct from "@yume-chan/struct";
5
+ import { decodeUtf8 } from "../utils/index.js";
6
+ const AdbReverseStringResponse = new Struct()
7
+ .string("length", { length: 4 })
8
+ .string("content", { lengthField: "length", lengthFieldRadix: 16 });
9
+ export class AdbReverseError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ Object.setPrototypeOf(this, AdbReverseError.prototype);
13
+ }
14
+ }
15
+ export class AdbReverseNotSupportedError extends Error {
16
+ constructor() {
17
+ super("ADB reverse tunnel is not supported on this device when connected wirelessly.");
18
+ Object.setPrototypeOf(this, AdbReverseNotSupportedError.prototype);
19
+ }
20
+ }
21
+ const AdbReverseErrorResponse = new Struct()
22
+ .fields(AdbReverseStringResponse)
23
+ .postDeserialize((value) => {
24
+ // https://issuetracker.google.com/issues/37066218
25
+ // ADB on Android <9 can't create reverse tunnels when connected wirelessly (ADB over WiFi),
26
+ // and returns this confusing "more than one device/emulator" error.
27
+ if (value.content === "more than one device/emulator") {
28
+ throw new AdbReverseNotSupportedError();
29
+ }
30
+ else {
31
+ throw new AdbReverseError(value.content);
32
+ }
33
+ });
34
+ export class AdbReverseCommand extends AutoDisposable {
35
+ localAddressToHandler = new Map();
36
+ deviceAddressToLocalAddress = new Map();
37
+ adb;
38
+ listening = false;
39
+ constructor(adb) {
40
+ super();
41
+ this.adb = adb;
42
+ this.addDisposable(this.adb.onIncomingSocket(this.handleIncomingSocket));
43
+ }
44
+ handleIncomingSocket = async (socket) => {
45
+ let address = socket.serviceString;
46
+ // ADB daemon appends `\0` to the service string
47
+ address = address.replace(/\0/g, "");
48
+ return !!(await this.localAddressToHandler.get(address)?.(socket));
49
+ };
50
+ async createBufferedStream(service) {
51
+ const socket = await this.adb.createSocket(service);
52
+ return new BufferedReadableStream(socket.readable);
53
+ }
54
+ async sendRequest(service) {
55
+ const stream = await this.createBufferedStream(service);
56
+ const success = decodeUtf8(await stream.read(4)) === "OKAY";
57
+ if (!success) {
58
+ await AdbReverseErrorResponse.deserialize(stream);
59
+ }
60
+ return stream;
61
+ }
62
+ async list() {
63
+ const stream = await this.createBufferedStream("reverse:list-forward");
64
+ const response = await AdbReverseStringResponse.deserialize(stream);
65
+ return response.content.split("\n").map((line) => {
66
+ const [deviceSerial, localName, remoteName] = line.split(" ");
67
+ return { deviceSerial, localName, remoteName };
68
+ });
69
+ // No need to close the stream, device will close it
70
+ }
71
+ /**
72
+ * @param deviceAddress
73
+ * The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
74
+ * @param localAddress
75
+ * An identifier for the reverse tunnel.
76
+ *
77
+ * When a socket wants to connect to {@link deviceAddress}, native ADB client will forward that connection to {@link localAddress}.
78
+ * However in this library, the {@link handler} is invoked instead. So this parameter is only used to identify the reverse tunnel.
79
+ * @param handler A callback to handle incoming connections. It must return `true` if it accepts the connection.
80
+ * @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
81
+ * @throws {AdbReverseNotSupportedError} If ADB reverse tunnel is not supported on this device when connected wirelessly.
82
+ * @throws {AdbReverseError} If ADB daemon returns an error.
83
+ */
84
+ async add(deviceAddress, localAddress, handler) {
85
+ const stream = await this.sendRequest(`reverse:forward:${deviceAddress};${localAddress}`);
86
+ // `tcp:0` tells the device to pick an available port.
87
+ // On Android >=8, device will respond with the selected port for all `tcp:` requests.
88
+ if (deviceAddress.startsWith("tcp:")) {
89
+ let length;
90
+ try {
91
+ length = Number.parseInt(decodeUtf8(await stream.read(4)), 16);
92
+ }
93
+ catch (e) {
94
+ if (!(e instanceof BufferedReadableStreamEndedError)) {
95
+ throw e;
96
+ }
97
+ // Android <8 doesn't have this response.
98
+ // (the stream is closed now)
99
+ // Can be safely ignored.
100
+ }
101
+ if (length !== undefined) {
102
+ const port = decodeUtf8(await stream.read(length));
103
+ deviceAddress = `tcp:${Number.parseInt(port, 10)}`;
104
+ }
105
+ }
106
+ this.localAddressToHandler.set(localAddress, handler);
107
+ this.deviceAddressToLocalAddress.set(deviceAddress, localAddress);
108
+ return deviceAddress;
109
+ // No need to close the stream, device will close it
110
+ }
111
+ async remove(deviceAddress) {
112
+ await this.sendRequest(`reverse:killforward:${deviceAddress}`);
113
+ if (this.deviceAddressToLocalAddress.has(deviceAddress)) {
114
+ this.localAddressToHandler.delete(this.deviceAddressToLocalAddress.get(deviceAddress));
115
+ this.deviceAddressToLocalAddress.delete(deviceAddress);
116
+ }
117
+ // No need to close the stream, device will close it
118
+ }
119
+ async removeAll() {
120
+ await this.sendRequest(`reverse:killforward-all`);
121
+ this.deviceAddressToLocalAddress.clear();
122
+ this.localAddressToHandler.clear();
123
+ // No need to close the stream, device will close it
124
+ }
125
+ }
99
126
  //# sourceMappingURL=reverse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AACnG,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAIvC,OAAO,EAAE,UAAU,E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AAK,SAAS,EAAE;gBACtB,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;gBACnD,aAAa,GAAG,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;aACtD;SACJ;QAED,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAClE,OAAO,aAAa,CAAC;QAErB,oDAAoD;IACxD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,aAAqB;QACrC,MAAM,IAAI,CAAC,WAAW,CAAC,uBAAuB,aAAa,EAAE,CAAC,CAAC;QAE/D,IAAI,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACrD,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAC7B,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,CAAE,CACvD,CAAC;YACF,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;SAC1D;QAED,oDAAoD;IACxD,CAAC;IAEM,KAAK,CAAC,SAAS;QAClB,MAAM,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;QAElD,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QAEnC,oDAAoD;IACxD,CAAC;CACJ"}
@@ -1,52 +1,58 @@
1
- import { AdbCommandBase } from '../base.js';
2
- import { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from './protocols/index.js';
3
- export interface AdbSubprocessOptions {
4
- /**
5
- * A list of `AdbSubprocessProtocolConstructor`s to be used.
6
- *
7
- * Different `AdbSubprocessProtocol` has different capabilities, thus requires specific adaptations.
8
- * Check their documentations for details.
9
- *
10
- * The first protocol whose `isSupported` returns `true` will be used.
11
- * If no `AdbSubprocessProtocol` is supported, an error will be thrown.
12
- *
13
- * @default [AdbSubprocessShellProtocol, AdbSubprocessNoneProtocol]
14
- */
15
- protocols: AdbSubprocessProtocolConstructor[];
16
- }
17
- export interface AdbSubprocessWaitResult {
18
- stdout: string;
19
- stderr: string;
20
- exitCode: number;
21
- }
22
- export declare class AdbSubprocess extends AdbCommandBase {
23
- private createProtocol;
24
- /**
25
- * Spawns an executable in PTY (interactive) mode.
26
- * @param command The command to run. If omitted, the default shell will be spawned.
27
- * @param options The options for creating the `AdbSubprocessProtocol`
28
- * @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
29
- */
30
- shell(command?: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessProtocol>;
31
- /**
32
- * Spawns an executable and pipe the output.
33
- * @param command The command to run, or an array of strings containing both command and args.
34
- * @param options The options for creating the `AdbSubprocessProtocol`
35
- * @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
36
- */
37
- spawn(command: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessProtocol>;
38
- /**
39
- * Spawns a new process, waits until it exits, and returns the entire output.
40
- * @param command The command to run
41
- * @param options The options for creating the `AdbSubprocessProtocol`
42
- * @returns The entire output of the command
43
- */
44
- spawnAndWait(command: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessWaitResult>;
45
- /**
46
- * Spawns a new process, waits until it exits, and returns the entire output.
47
- * @param command The command to run
48
- * @returns The entire output of the command
49
- */
50
- spawnAndWaitLegacy(command: string | string[]): Promise<string>;
51
- }
1
+ import { AdbCommandBase } from "../base.js";
2
+ import type { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from "./protocols/index.js";
3
+ export interface AdbSubprocessOptions {
4
+ /**
5
+ * A list of `AdbSubprocessProtocolConstructor`s to be used.
6
+ *
7
+ * Different `AdbSubprocessProtocol` has different capabilities, thus requires specific adaptations.
8
+ * Check their documentations for details.
9
+ *
10
+ * The first protocol whose `isSupported` returns `true` will be used.
11
+ * If no `AdbSubprocessProtocol` is supported, an error will be thrown.
12
+ *
13
+ * @default [AdbSubprocessShellProtocol, AdbSubprocessNoneProtocol]
14
+ */
15
+ protocols: AdbSubprocessProtocolConstructor[];
16
+ }
17
+ export interface AdbSubprocessWaitResult {
18
+ stdout: string;
19
+ stderr: string;
20
+ exitCode: number;
21
+ }
22
+ export declare class AdbSubprocess extends AdbCommandBase {
23
+ private createProtocol;
24
+ /**
25
+ * Spawns an executable in PTY mode.
26
+ *
27
+ * Redirection mode is enough for most simple commands, but PTY mode is required for
28
+ * commands that manipulate the terminal, such as `vi` and `less`.
29
+ * @param command The command to run. If omitted, the default shell will be spawned.
30
+ * @param options The options for creating the `AdbSubprocessProtocol`
31
+ * @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
32
+ */
33
+ shell(command?: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessProtocol>;
34
+ /**
35
+ * Spawns an executable and redirect the standard input/output stream.
36
+ *
37
+ * Redirection mode is enough for most simple commands, but PTY mode is required for
38
+ * commands that manipulate the terminal, such as `vi` and `less`.
39
+ * @param command The command to run, or an array of strings containing both command and args.
40
+ * @param options The options for creating the `AdbSubprocessProtocol`
41
+ * @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
42
+ */
43
+ spawn(command: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessProtocol>;
44
+ /**
45
+ * Spawns a new process, waits until it exits, and returns the entire output.
46
+ * @param command The command to run
47
+ * @param options The options for creating the `AdbSubprocessProtocol`
48
+ * @returns The entire output of the command
49
+ */
50
+ spawnAndWait(command: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessWaitResult>;
51
+ /**
52
+ * Spawns a new process, waits until it exits, and returns the entire output.
53
+ * @param command The command to run
54
+ * @returns The entire output of the command
55
+ */
56
+ spawnAndWaitLegacy(command: string | string[]): Promise<string>;
57
+ }
52
58
  //# sourceMappingURL=command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAA6B,qBAAqB,EAAE,gCAAgC,EAA8B,MAAM,sBAAsB,CAAC;AAEtJ,MAAM,WAAW,oBAAoB;IACjC;;;;;;;;;;OAUG;IACH,SAAS,EAAE,gCAAgC,EAAE,CAAC;CACjD;AAMD,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,aAAc,SAAQ,cAAc;YAC/B,cAAc;IA6B5B;;;;;OAKG;IACI,KAAK,CACR,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;OAKG;IACI,KAAK,CACR,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;OAKG;IACU,YAAY,CACrB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,uBAAuB,CAAC;IAuBnC;;;;OAIG;IACU,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAO/E"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CA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