@yume-chan/adb 0.0.12 → 0.0.15

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 (145) hide show
  1. package/CHANGELOG.json +54 -0
  2. package/CHANGELOG.md +28 -1
  3. package/README.md +24 -17
  4. package/esm/adb.d.ts +10 -9
  5. package/esm/adb.d.ts.map +1 -1
  6. package/esm/adb.js +88 -67
  7. package/esm/adb.js.map +1 -1
  8. package/esm/auth.d.ts +6 -6
  9. package/esm/auth.d.ts.map +1 -1
  10. package/esm/auth.js +8 -6
  11. package/esm/auth.js.map +1 -1
  12. package/esm/backend.d.ts +2 -2
  13. package/esm/commands/install.d.ts.map +1 -1
  14. package/esm/commands/install.js +5 -7
  15. package/esm/commands/install.js.map +1 -1
  16. package/esm/commands/reverse.d.ts +9 -12
  17. package/esm/commands/reverse.d.ts.map +1 -1
  18. package/esm/commands/reverse.js +44 -36
  19. package/esm/commands/reverse.js.map +1 -1
  20. package/esm/commands/subprocess/index.d.ts +19 -20
  21. package/esm/commands/subprocess/index.d.ts.map +1 -1
  22. package/esm/commands/subprocess/index.js +36 -31
  23. package/esm/commands/subprocess/index.js.map +1 -1
  24. package/esm/commands/subprocess/legacy.d.ts +14 -7
  25. package/esm/commands/subprocess/legacy.d.ts.map +1 -1
  26. package/esm/commands/subprocess/legacy.js +14 -5
  27. package/esm/commands/subprocess/legacy.js.map +1 -1
  28. package/esm/commands/subprocess/protocol.d.ts +3 -2
  29. package/esm/commands/subprocess/protocol.d.ts.map +1 -1
  30. package/esm/commands/subprocess/protocol.js +6 -4
  31. package/esm/commands/subprocess/protocol.js.map +1 -1
  32. package/esm/commands/subprocess/protocols/index.d.ts +4 -0
  33. package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
  34. package/esm/commands/subprocess/protocols/index.js +4 -0
  35. package/esm/commands/subprocess/protocols/index.js.map +1 -0
  36. package/esm/commands/subprocess/protocols/none.d.ts +35 -0
  37. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
  38. package/esm/commands/subprocess/protocols/none.js +53 -0
  39. package/esm/commands/subprocess/protocols/none.js.map +1 -0
  40. package/esm/commands/subprocess/protocols/shell.d.ts +39 -0
  41. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
  42. package/esm/commands/subprocess/protocols/shell.js +155 -0
  43. package/esm/commands/subprocess/protocols/shell.js.map +1 -0
  44. package/esm/commands/subprocess/protocols/types.d.ts +50 -0
  45. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
  46. package/esm/commands/subprocess/protocols/types.js +2 -0
  47. package/esm/commands/subprocess/protocols/types.js.map +1 -0
  48. package/esm/commands/subprocess/types.d.ts +9 -6
  49. package/esm/commands/subprocess/types.d.ts.map +1 -1
  50. package/esm/commands/sync/list.d.ts +25 -1
  51. package/esm/commands/sync/list.d.ts.map +1 -1
  52. package/esm/commands/sync/list.js +40 -5
  53. package/esm/commands/sync/list.js.map +1 -1
  54. package/esm/commands/sync/pull.d.ts.map +1 -1
  55. package/esm/commands/sync/pull.js +6 -3
  56. package/esm/commands/sync/pull.js.map +1 -1
  57. package/esm/commands/sync/request.d.ts +1 -0
  58. package/esm/commands/sync/request.d.ts.map +1 -1
  59. package/esm/commands/sync/request.js +1 -0
  60. package/esm/commands/sync/request.js.map +1 -1
  61. package/esm/commands/sync/response.d.ts +2 -1
  62. package/esm/commands/sync/response.d.ts.map +1 -1
  63. package/esm/commands/sync/response.js +2 -1
  64. package/esm/commands/sync/response.js.map +1 -1
  65. package/esm/commands/sync/stat.d.ts +13 -1
  66. package/esm/commands/sync/stat.d.ts.map +1 -1
  67. package/esm/commands/sync/stat.js +22 -9
  68. package/esm/commands/sync/stat.js.map +1 -1
  69. package/esm/commands/sync/sync.d.ts +13 -35
  70. package/esm/commands/sync/sync.d.ts.map +1 -1
  71. package/esm/commands/sync/sync.js +40 -10
  72. package/esm/commands/sync/sync.js.map +1 -1
  73. package/esm/crypto.d.ts +23 -10
  74. package/esm/crypto.d.ts.map +1 -1
  75. package/esm/crypto.js +64 -46
  76. package/esm/crypto.js.map +1 -1
  77. package/esm/features.d.ts +4 -2
  78. package/esm/features.d.ts.map +1 -1
  79. package/esm/features.js +6 -2
  80. package/esm/features.js.map +1 -1
  81. package/esm/packet.d.ts +21 -2
  82. package/esm/packet.d.ts.map +1 -1
  83. package/esm/packet.js +2 -2
  84. package/esm/packet.js.map +1 -1
  85. package/esm/socket/dispatcher.d.ts +35 -23
  86. package/esm/socket/dispatcher.d.ts.map +1 -1
  87. package/esm/socket/dispatcher.js +97 -72
  88. package/esm/socket/dispatcher.js.map +1 -1
  89. package/esm/socket/socket.d.ts +29 -8
  90. package/esm/socket/socket.d.ts.map +1 -1
  91. package/esm/socket/socket.js +43 -29
  92. package/esm/socket/socket.js.map +1 -1
  93. package/esm/stream/buffered.d.ts +1 -1
  94. package/esm/stream/buffered.d.ts.map +1 -1
  95. package/esm/stream/buffered.js +2 -2
  96. package/esm/stream/buffered.js.map +1 -1
  97. package/esm/stream/detect.d.ts +1 -17
  98. package/esm/stream/detect.d.ts.map +1 -1
  99. package/esm/stream/detect.js +4 -5
  100. package/esm/stream/detect.js.map +1 -1
  101. package/esm/stream/detect.polyfill.d.ts +1 -1
  102. package/esm/stream/detect.polyfill.d.ts.map +1 -1
  103. package/esm/stream/detect.polyfill.js +4 -1
  104. package/esm/stream/detect.polyfill.js.map +1 -1
  105. package/esm/stream/transform.d.ts +39 -33
  106. package/esm/stream/transform.d.ts.map +1 -1
  107. package/esm/stream/transform.js +121 -100
  108. package/esm/stream/transform.js.map +1 -1
  109. package/esm/utils/base64.js +5 -5
  110. package/esm/utils/base64.js.map +1 -1
  111. package/esm/utils/encoding.d.ts.map +1 -1
  112. package/esm/utils/encoding.js.map +1 -1
  113. package/esm/utils/index.d.ts +1 -1
  114. package/esm/utils/index.d.ts.map +1 -1
  115. package/esm/utils/index.js +1 -1
  116. package/esm/utils/index.js.map +1 -1
  117. package/package.json +7 -7
  118. package/src/adb.ts +112 -86
  119. package/src/auth.ts +21 -18
  120. package/src/backend.ts +2 -2
  121. package/src/commands/install.ts +7 -9
  122. package/src/commands/reverse.ts +48 -44
  123. package/src/commands/subprocess/index.ts +57 -42
  124. package/src/commands/subprocess/protocols/index.ts +3 -0
  125. package/src/commands/subprocess/{legacy.ts → protocols/none.ts} +20 -10
  126. package/src/commands/subprocess/{protocol.ts → protocols/shell.ts} +22 -17
  127. package/src/commands/subprocess/{types.ts → protocols/types.ts} +13 -9
  128. package/src/commands/sync/list.ts +51 -5
  129. package/src/commands/sync/pull.ts +6 -3
  130. package/src/commands/sync/request.ts +1 -0
  131. package/src/commands/sync/response.ts +8 -2
  132. package/src/commands/sync/stat.ts +36 -9
  133. package/src/commands/sync/sync.ts +56 -20
  134. package/src/crypto.ts +72 -56
  135. package/src/features.ts +6 -2
  136. package/src/packet.ts +17 -6
  137. package/src/socket/dispatcher.ts +139 -91
  138. package/src/socket/socket.ts +76 -61
  139. package/src/stream/buffered.ts +2 -2
  140. package/src/stream/detect.polyfill.ts +5 -2
  141. package/src/stream/detect.ts +4 -24
  142. package/src/stream/transform.ts +144 -124
  143. package/src/utils/index.ts +1 -1
  144. package/tsconfig.build.tsbuildinfo +1 -1
  145. package/src/utils/encoding.ts +0 -13
@@ -0,0 +1,35 @@
1
+ import type { Adb } from "../../../adb.js";
2
+ import type { AdbSocket } from "../../../socket/index.js";
3
+ import { ReadableStream } from "../../../stream/index.js";
4
+ import type { AdbSubprocessProtocol } from "./types.js";
5
+ /**
6
+ * The legacy shell
7
+ *
8
+ * Features:
9
+ * * `stderr`: No
10
+ * * `exit` exit code: No
11
+ * * `resize`: No
12
+ */
13
+ export declare class AdbSubprocessNoneProtocol implements AdbSubprocessProtocol {
14
+ static isSupported(): boolean;
15
+ static pty(adb: Adb, command: string): Promise<AdbSubprocessNoneProtocol>;
16
+ static raw(adb: Adb, command: string): Promise<AdbSubprocessNoneProtocol>;
17
+ private readonly socket;
18
+ get stdin(): import("web-streams-polyfill").WritableStream<Uint8Array>;
19
+ private _stdout;
20
+ /**
21
+ * Legacy shell mixes stdout and stderr.
22
+ */
23
+ get stdout(): ReadableStream<Uint8Array>;
24
+ private _stderr;
25
+ /**
26
+ * `stderr` will always be empty.
27
+ */
28
+ get stderr(): ReadableStream<Uint8Array>;
29
+ private _exit;
30
+ get exit(): Promise<number>;
31
+ constructor(socket: AdbSocket);
32
+ resize(): void;
33
+ kill(): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=none.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/none.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAuB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;GAOG;AACH,qBAAa,yBAA0B,YAAW,qBAAqB;WACrD,WAAW;WAEL,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;WAI7B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;IAMjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IAGnC,IAAW,KAAK,8DAAmC;IAEnD,OAAO,CAAC,OAAO,CAA6B;IAC5C;;OAEG;IACH,IAAW,MAAM,+BAA2B;IAE5C,OAAO,CAAC,OAAO,CAA6B;IAC5C;;OAEG;IACH,IAAW,MAAM,+BAA2B;IAE5C,OAAO,CAAC,KAAK,CAAkB;IAC/B,IAAW,IAAI,oBAAyB;gBAErB,MAAM,EAAE,SAAS;IAc7B,MAAM;IAIN,IAAI;CAGd"}
@@ -0,0 +1,53 @@
1
+ import { DuplexStreamFactory, ReadableStream } from "../../../stream/index.js";
2
+ /**
3
+ * The legacy shell
4
+ *
5
+ * Features:
6
+ * * `stderr`: No
7
+ * * `exit` exit code: No
8
+ * * `resize`: No
9
+ */
10
+ export class AdbSubprocessNoneProtocol {
11
+ static isSupported() { return true; }
12
+ static async pty(adb, command) {
13
+ return new AdbSubprocessNoneProtocol(await adb.createSocket(`shell:${command}`));
14
+ }
15
+ static async raw(adb, command) {
16
+ // `shell,raw:${command}` also triggers raw mode,
17
+ // But is not supported before Android 7.
18
+ return new AdbSubprocessNoneProtocol(await adb.createSocket(`exec:${command}`));
19
+ }
20
+ socket;
21
+ // Legacy shell forwards all data to stdin.
22
+ get stdin() { return this.socket.writable; }
23
+ _stdout;
24
+ /**
25
+ * Legacy shell mixes stdout and stderr.
26
+ */
27
+ get stdout() { return this._stdout; }
28
+ _stderr;
29
+ /**
30
+ * `stderr` will always be empty.
31
+ */
32
+ get stderr() { return this._stderr; }
33
+ _exit;
34
+ get exit() { return this._exit; }
35
+ constructor(socket) {
36
+ this.socket = socket;
37
+ const factory = new DuplexStreamFactory({
38
+ close: async () => {
39
+ await this.socket.close();
40
+ },
41
+ });
42
+ this._stdout = factory.wrapReadable(this.socket.readable);
43
+ this._stderr = factory.wrapReadable(new ReadableStream());
44
+ this._exit = factory.closed.then(() => 0);
45
+ }
46
+ resize() {
47
+ // Not supported
48
+ }
49
+ kill() {
50
+ return this.socket.close();
51
+ }
52
+ }
53
+ //# sourceMappingURL=none.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"none.js","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/none.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/E;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IAC3B,MAAM,CAAC,WAAW,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAErC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAQ,EAAE,OAAe;QAC7C,OAAO,IAAI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AEM,MAAM;QACT,gBAAgB;IACpB,CAAC;IAEM,IAAI;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACJ"}
@@ -0,0 +1,39 @@
1
+ import type { Adb } from "../../../adb.js";
2
+ import type { AdbSocket } from "../../../socket/index.js";
3
+ import { ReadableStream, WritableStream } from "../../../stream/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
+ }
39
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/shell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAgC,cAAc,EAAmE,cAAc,EAAkE,MAAM,0BAA0B,CAAC;AAEzO,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;AA8ED;;;;;;;GAOG;AACH,qBAAa,0BAA2B,YAAW,qBAAqB;WACtD,WAAW,CAAC,GAAG,EAAE,GAAG;WAId,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;WAK7B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;IAIjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;IACpC,OAAO,CAAC,aAAa,CAA0D;IAE/E,OAAO,CAAC,MAAM,CAA6B;IAC3C,IAAW,KAAK,+BAA0B;IAE1C,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,+BAA2B;IAE5C,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,+BAA2B;IAE5C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,IAAW,IAAI,oBAAiC;gBAE7B,MAAM,EAAE,SAAS;IA2CvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAYvC,IAAI;CAGd"}
@@ -0,0 +1,155 @@
1
+ import { PromiseResolver } from "@yume-chan/async";
2
+ import Struct, { placeholder } from "@yume-chan/struct";
3
+ import { AdbFeatures } from "../../../features.js";
4
+ import { pipeFrom, PushReadableStream, StructDeserializeStream, StructSerializeStream, TransformStream, WritableStream } from "../../../stream/index.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() { return this._readable; }
50
+ _activeCount = 0;
51
+ constructor() {
52
+ this._readable = new PushReadableStream(controller => {
53
+ this._readableController = controller;
54
+ });
55
+ }
56
+ createWriteable() {
57
+ return new WritableStream({
58
+ start: () => {
59
+ this._activeCount += 1;
60
+ },
61
+ write: async (chunk) => {
62
+ await this._readableController.enqueue(chunk);
63
+ },
64
+ abort: async (e) => {
65
+ this._activeCount -= 1;
66
+ if (this._activeCount === 0) {
67
+ this._readableController.close();
68
+ }
69
+ },
70
+ close: async () => {
71
+ this._activeCount -= 1;
72
+ if (this._activeCount === 0) {
73
+ this._readableController.close();
74
+ }
75
+ },
76
+ });
77
+ }
78
+ }
79
+ /**
80
+ * Shell v2 a.k.a Shell Protocol
81
+ *
82
+ * Features:
83
+ * * `stderr`: Yes
84
+ * * `exit` exit code: Yes
85
+ * * `resize`: Yes
86
+ */
87
+ export class AdbSubprocessShellProtocol {
88
+ static isSupported(adb) {
89
+ return adb.features.includes(AdbFeatures.ShellV2);
90
+ }
91
+ static async pty(adb, command) {
92
+ // TODO: AdbShellSubprocessProtocol: Support setting `XTERM` environment variable
93
+ return new AdbSubprocessShellProtocol(await adb.createSocket(`shell,v2,pty:${command}`));
94
+ }
95
+ static async raw(adb, command) {
96
+ return new AdbSubprocessShellProtocol(await adb.createSocket(`shell,v2,raw:${command}`));
97
+ }
98
+ _socket;
99
+ _socketWriter;
100
+ _stdin;
101
+ get stdin() { return this._stdin; }
102
+ _stdout;
103
+ get stdout() { return this._stdout; }
104
+ _stderr;
105
+ get stderr() { return this._stderr; }
106
+ _exit = new PromiseResolver();
107
+ get exit() { return this._exit.promise; }
108
+ constructor(socket) {
109
+ this._socket = socket;
110
+ // Check this image to help you understand the stream graph
111
+ // cspell: disable-next-line
112
+ // https://www.plantuml.com/plantuml/png/bL91QiCm4Bpx5SAdv90lb1JISmiw5XzaQKf5PIkiLZIqzEyLSg8ks13gYtOykpFhiOw93N6UGjVDqK7rZsxKqNw0U_NTgVAy4empOy2mm4_olC0VEVEE47GUpnGjKdgXoD76q4GIEpyFhOwP_m28hW0NNzxNUig1_JdW0bA7muFIJDco1daJ_1SAX9bgvoPJPyIkSekhNYctvIGXrCH6tIsPL5fs-s6J5yc9BpWXhKtNdF2LgVYPGM_6GlMwfhWUsIt4lbScANrwlgVVUifPSVi__t44qStnwPvZwobdSmHHlL57p2vFuHS0
113
+ // TODO: AdbShellSubprocessProtocol: Optimize stream graph
114
+ const [stdout, stderr] = socket.readable
115
+ .pipeThrough(new StructDeserializeStream(AdbShellProtocolPacket))
116
+ .pipeThrough(new TransformStream({
117
+ transform: (chunk, controller) => {
118
+ if (chunk.id === AdbShellProtocolId.Exit) {
119
+ this._exit.resolve(new Uint8Array(chunk.data)[0]);
120
+ // We can let `StdoutDeserializeStream` to process `AdbShellProtocolId.Exit`,
121
+ // but since we need this `TransformStream` to capture the exit code anyway,
122
+ // terminating child streams here is killing two birds with one stone.
123
+ controller.terminate();
124
+ return;
125
+ }
126
+ controller.enqueue(chunk);
127
+ }
128
+ }))
129
+ .tee();
130
+ this._stdout = stdout
131
+ .pipeThrough(new StdoutDeserializeStream(AdbShellProtocolId.Stdout));
132
+ this._stderr = stderr
133
+ .pipeThrough(new StdoutDeserializeStream(AdbShellProtocolId.Stderr));
134
+ const multiplexer = new MultiplexStream();
135
+ multiplexer.readable
136
+ .pipeThrough(new StructSerializeStream(AdbShellProtocolPacket))
137
+ .pipeTo(socket.writable);
138
+ this._stdin = pipeFrom(multiplexer.createWriteable(), new StdinSerializeStream());
139
+ this._socketWriter = multiplexer.createWriteable().getWriter();
140
+ }
141
+ async resize(rows, cols) {
142
+ await this._socketWriter.write({
143
+ id: AdbShellProtocolId.WindowSizeChange,
144
+ data: encodeUtf8(
145
+ // The "correct" format is `${rows}x${cols},${x_pixels}x${y_pixels}`
146
+ // However, according to https://linux.die.net/man/4/tty_ioctl
147
+ // `x_pixels` and `y_pixels` are not used, so always passing `0` is fine.
148
+ `${rows}x${cols},0x0\0`),
149
+ });
150
+ }
151
+ kill() {
152
+ return this._socket.close();
153
+ }
154
+ }
155
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +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,MAAM,EAAE,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,kBAAkB,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../../../adb.js";
3
+ import type { AdbSocket } from "../../../socket/index.js";
4
+ import type { ReadableStream, WritableStream } from "../../../stream/index.js";
5
+ export interface AdbSubprocessProtocol {
6
+ /**
7
+ * A WritableStream that writes to the `stdin` pipe.
8
+ */
9
+ readonly stdin: WritableStream<Uint8Array>;
10
+ /**
11
+ * The `stdout` pipe of the process.
12
+ */
13
+ readonly stdout: ReadableStream<Uint8Array>;
14
+ /**
15
+ * The `stderr` pipe 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
+ }
50
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/types.ts"],"names":[],"mappings":"AAAA,OAAO,K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 {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/types.ts"],"names":[],"mappings":""}
@@ -14,21 +14,22 @@ export interface AdbSubprocessProtocol {
14
14
  /**
15
15
  * The `stderr` pipe of the process.
16
16
  *
17
- * Note: Some `AdbShell` doesn't separate `stdout` and `stderr`,
17
+ * Note: Some `AdbSubprocessProtocol` doesn't separate `stdout` and `stderr`,
18
18
  * All output will be sent to `stdout`.
19
19
  */
20
20
  readonly stderr: ReadableStream<Uint8Array>;
21
21
  /**
22
22
  * A `Promise` that resolves to the exit code of the process.
23
23
  *
24
- * Note: Some `AdbShell` doesn't support exit code,
25
- * They will always resolve with `0`.
24
+ * Note: Some `AdbSubprocessProtocol` doesn't support exit code,
25
+ * They will always resolve it with `0`.
26
26
  */
27
27
  readonly exit: Promise<number>;
28
28
  /**
29
29
  * Resizes the current shell.
30
30
  *
31
- * Some `AdbShell`s may not support resizing and will always ignore calls to this method.
31
+ * Some `AdbSubprocessProtocol`s may not support resizing
32
+ * and will ignore calls to this method.
32
33
  */
33
34
  resize(rows: number, cols: number): ValueOrPromise<void>;
34
35
  /**
@@ -39,8 +40,10 @@ export interface AdbSubprocessProtocol {
39
40
  export interface AdbSubprocessProtocolConstructor {
40
41
  /** Returns `true` if the `adb` instance supports this shell */
41
42
  isSupported(adb: Adb): ValueOrPromise<boolean>;
42
- /** Creates a new `AdbShell` using the specified `Adb` and `command` */
43
- spawn(adb: Adb, command: string): ValueOrPromise<AdbSubprocessProtocol>;
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>;
44
47
  /** Creates a new `AdbShell` by attaching to an exist `AdbSocket` */
45
48
  new (socket: AdbSocket): AdbSubprocessProtocol;
46
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5E,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;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD;;OAEG;IACH,IAAI,IAAI,cAAc,CAAC,IAAI,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,uEAAuE;IACvE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC;IAExE,oEAAoE;IACpE,KAAI,MAAM,EAAE,SAAS,GAAG,qBAAqB,CAAC;CACjD"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5E,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,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,KAAI,MAAM,EAAE,SAAS,GAAG,qBAAqB,CAAC;CACjD"}
@@ -1,6 +1,10 @@
1
1
  import Struct from '@yume-chan/struct';
2
2
  import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream/index.js';
3
3
  import { AdbSyncResponseId } from './response.js';
4
+ import { type AdbSyncStat } from './stat.js';
5
+ export interface AdbSyncEntry extends AdbSyncStat {
6
+ name: string;
7
+ }
4
8
  export declare const AdbSyncEntryResponse: Struct<{
5
9
  mode: number;
6
10
  size: number;
@@ -13,5 +17,25 @@ export declare const AdbSyncEntryResponse: Struct<{
13
17
  id: AdbSyncResponseId.Entry;
14
18
  }, undefined>;
15
19
  export declare type AdbSyncEntryResponse = typeof AdbSyncEntryResponse['TDeserializeResult'];
16
- export declare function adbSyncOpenDir(stream: AdbBufferedStream, writer: WritableStreamDefaultWriter<Uint8Array>, path: string): AsyncGenerator<AdbSyncEntryResponse, void, void>;
20
+ export declare const AdbSyncEntry2Response: Struct<{
21
+ error: import("./stat.js").AdbSyncStatErrorCode;
22
+ dev: bigint;
23
+ ino: bigint;
24
+ mode: number;
25
+ nlink: number;
26
+ uid: number;
27
+ gid: number;
28
+ size: bigint;
29
+ atime: bigint;
30
+ mtime: bigint;
31
+ ctime: bigint;
32
+ nameLength: number;
33
+ name: string;
34
+ }, "nameLength", {
35
+ readonly type: import("./stat.js").LinuxFileType;
36
+ readonly permission: number;
37
+ id: AdbSyncResponseId.Entry2;
38
+ }, undefined>;
39
+ export declare type AdbSyncEntry2Response = typeof AdbSyncEntry2Response['TDeserializeResult'];
40
+ export declare function adbSyncOpenDir(stream: AdbBufferedStream, writer: WritableStreamDefaultWriter<Uint8Array>, path: string, v2: boolean): AsyncGenerator<AdbSyncEntry, void, void>;
17
41
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/list.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAA4C,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAG5F,eAAO,MAAM,oBAAoB;;;;;;;;;;aAKuB,CAAC;AAEzD,oBAAY,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;AAOrF,wBAAuB,cAAc,CACjC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,IAAI,EAAE,MAAM,GACb,cAAc,CAAC,oBAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,CAelD"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/list.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAA4C,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAA6C,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAExF,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC7C,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;aAKuB,CAAC;AAEzD,oBAAY,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;AAErF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;aAKuB,CAAC;AAE1D,oBAAY,qBAAqB,GAAG,OAAO,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;AAYvF,wBAAuB,cAAc,CACjC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,OAAO,GACZ,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CA0C1C"}
@@ -1,22 +1,57 @@
1
1
  import Struct from '@yume-chan/struct';
2
2
  import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
3
3
  import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js';
4
- import { AdbSyncLstatResponse } from './stat.js';
4
+ import { AdbSyncLstatResponse, AdbSyncStatResponse } from './stat.js';
5
5
  export const AdbSyncEntryResponse = new Struct({ littleEndian: true })
6
6
  .fields(AdbSyncLstatResponse)
7
7
  .uint32('nameLength')
8
8
  .string('name', { lengthField: 'nameLength' })
9
9
  .extra({ id: AdbSyncResponseId.Entry });
10
- const ResponseTypes = {
10
+ export const AdbSyncEntry2Response = new Struct({ littleEndian: true })
11
+ .fields(AdbSyncStatResponse)
12
+ .uint32('nameLength')
13
+ .string('name', { lengthField: 'nameLength' })
14
+ .extra({ id: AdbSyncResponseId.Entry2 });
15
+ const LIST_V1_RESPONSE_TYPES = {
11
16
  [AdbSyncResponseId.Entry]: AdbSyncEntryResponse,
12
17
  [AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncEntryResponse.size),
13
18
  };
14
- export async function* adbSyncOpenDir(stream, writer, path) {
15
- await adbSyncWriteRequest(writer, AdbSyncRequestId.List, path);
19
+ const LIST_V2_RESPONSE_TYPES = {
20
+ [AdbSyncResponseId.Entry2]: AdbSyncEntry2Response,
21
+ [AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncEntry2Response.size),
22
+ };
23
+ export async function* adbSyncOpenDir(stream, writer, path, v2) {
24
+ let requestId;
25
+ let responseType;
26
+ if (v2) {
27
+ requestId = AdbSyncRequestId.List2;
28
+ responseType = LIST_V2_RESPONSE_TYPES;
29
+ }
30
+ else {
31
+ requestId = AdbSyncRequestId.List;
32
+ responseType = LIST_V1_RESPONSE_TYPES;
33
+ }
34
+ await adbSyncWriteRequest(writer, requestId, path);
16
35
  while (true) {
17
- const response = await adbSyncReadResponse(stream, ResponseTypes);
36
+ const response = await adbSyncReadResponse(stream, responseType);
18
37
  switch (response.id) {
19
38
  case AdbSyncResponseId.Entry:
39
+ yield {
40
+ mode: response.mode,
41
+ size: BigInt(response.size),
42
+ mtime: BigInt(response.mtime),
43
+ get type() { return response.type; },
44
+ get permission() { return response.permission; },
45
+ name: response.name,
46
+ };
47
+ break;
48
+ case AdbSyncResponseId.Entry2:
49
+ // `LST2` can return error codes for failed `lstat` calls.
50
+ // `LIST` just ignores them.
51
+ // But they only contain `name` so still pretty useless.
52
+ if (response.error !== 0) {
53
+ continue;
54
+ }
20
55
  yield response;
21
56
  break;
22
57
  case AdbSyncResponseId.Done:
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/sync/list.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAC7B,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAC7B,MAAM,CAAC,oBAAoB,CAAC;KAC5B,MAAM,CAAC,YAAY,CAAC;KACpB,MAAM,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;KAC7C,KAAK,CAAC,EAAE,EAAE,EAAE,iBAAiB,CAAC,KAAc,EAAE,CAAC,CAAC;AAIzD,MAAM,aAAa,GAAG;IAClB,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,oBAAoB;IAC/C,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,mBAAmB,CAAC,oBAAoB,CAAC,IAAI,CAAC;CAC/E,CAAC;AAEF,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,cAAc,CACjC,MAAyB,EACzB,MAA+C,EAC/C,IAAY;IAEZ,MAAM,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE/D,OAAO,IAAI,EAAE;QACT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AAC,UAAU,CAAC,CAAC,CAAC;oBAChD,IAAI,EAAE,QAAQ,CAAC,IAAI;iBACtB,CAAC;gBACF,MAAM;YACV,KAAK,iBAAiB,CAAC,MAAM;gBACzB,0DAA0D;gBAC1D,4BAA4B;gBAC5B,wDAAwD;gBACxD,IAAI,QAAQ,CAAC,KAAK,KAAK,CAAC,EAAE;oBACtB,SAAS;iBACZ;gBACD,MAAM,QAAQ,CAAC;gBACf,MAAM;YACV,KAAK,iBAAiB,CAAC,IAAI;gBACvB,OAAO;YACX;gBACI,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SACjD;KACJ;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/pull.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEvG,OAAO,EAA4C,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5F,eAAO,MAAM,mBAAmB;;;;;aAIuB,CAAC;AAOxD,wBAAgB,WAAW,CACvB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,IAAI,EAAE,MAAM,GACb,cAAc,CAAC,UAAU,CAAC,CAsB5B"}
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/pull.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEvG,OAAO,EAA4C,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5F,eAAO,MAAM,mBAAmB;;;;;aAIuB,CAAC;AAOxD,wBAAgB,WAAW,CACvB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,IAAI,EAAE,MAAM,GACb,cAAc,CAAC,UAAU,CAAC,CAyB5B"}
@@ -6,7 +6,7 @@ export const AdbSyncDataResponse = new Struct({ littleEndian: true })
6
6
  .uint32('dataLength')
7
7
  .uint8Array('data', { lengthField: 'dataLength' })
8
8
  .extra({ id: AdbSyncResponseId.Data });
9
- const ResponseTypes = {
9
+ const RESPONSE_TYPES = {
10
10
  [AdbSyncResponseId.Data]: AdbSyncDataResponse,
11
11
  [AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncDataResponse.size),
12
12
  };
@@ -16,7 +16,7 @@ export function adbSyncPull(stream, writer, path) {
16
16
  await adbSyncWriteRequest(writer, AdbSyncRequestId.Receive, path);
17
17
  },
18
18
  async pull(controller) {
19
- const response = await adbSyncReadResponse(stream, ResponseTypes);
19
+ const response = await adbSyncReadResponse(stream, RESPONSE_TYPES);
20
20
  switch (response.id) {
21
21
  case AdbSyncResponseId.Data:
22
22
  controller.enqueue(response.data);
@@ -27,7 +27,10 @@ export function adbSyncPull(stream, writer, path) {
27
27
  default:
28
28
  throw new Error('Unexpected response id');
29
29
  }
30
- }
30
+ },
31
+ cancel() {
32
+ throw new Error(`Sync commands don't support cancel.`);
33
+ },
31
34
  }, {
32
35
  highWaterMark: 16 * 1024,
33
36
  size(chunk) { return chunk.byteLength; }
@@ -1 +1 @@
1
- {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../src/commands/sync/pull.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAqB,cAAc,EAA+B,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5F,MAAM,CAAC,MAAM,mBAAmB,GAC5B,IAAI,MAAM,CAAC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E,CAAC;oBACnB,MAAM;gBACV;oBACI,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;aACjD;QACL,CAAC;QACD,MAAM;YACF,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3D,CAAC;KACJ,EAAE;QACC,aAAa,EAAE,EAAE,GAAG,IAAI;QACxB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;KAC3C,CAAC,CAAC;AACP,CAAC"}
@@ -2,6 +2,7 @@ import Struct from '@yume-chan/struct';
2
2
  import type { WritableStreamDefaultWriter } from "../../stream/index.js";
3
3
  export declare enum AdbSyncRequestId {
4
4
  List = "LIST",
5
+ List2 = "LIS2",
5
6
  Send = "SEND",
6
7
  Lstat = "STAT",
7
8
  Stat = "STA2",
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/request.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAGzE,oBAAY,gBAAgB;IACxB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,SAAS;IACd,IAAI,SAAS;IACb,MAAM,SAAS;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,SAAS;CACnB;AAED,eAAO,MAAM,oBAAoB;;;wBAGX,CAAC;AAEvB,eAAO,MAAM,kBAAkB;;;;wBAGoB,CAAC;AAEpD,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,EAAE,EAAE,gBAAgB,GAAG,MAAM,EAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GACpC,OAAO,CAAC,IAAI,CAAC,CAmBf"}
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/request.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAGzE,oBAAY,gBAAgB;IACxB,IAAI,SAAS;IACb,KAAK,SAAS;IACd,IAAI,SAAS;IACb,KAAK,SAAS;IACd,IAAI,SAAS;IACb,MAAM,SAAS;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,SAAS;CACnB;AAED,eAAO,MAAM,oBAAoB;;;wBAGX,CAAC;AAEvB,eAAO,MAAM,kBAAkB;;;;wBAGoB,CAAC;AAEpD,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,EAAE,EAAE,gBAAgB,GAAG,MAAM,EAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GACpC,OAAO,CAAC,IAAI,CAAC,CAmBf"}
@@ -3,6 +3,7 @@ import { encodeUtf8 } from "../../utils/index.js";
3
3
  export var AdbSyncRequestId;
4
4
  (function (AdbSyncRequestId) {
5
5
  AdbSyncRequestId["List"] = "LIST";
6
+ AdbSyncRequestId["List2"] = "LIS2";
6
7
  AdbSyncRequestId["Send"] = "SEND";
7
8
  AdbSyncRequestId["Lstat"] = "STAT";
8
9
  AdbSyncRequestId["Stat"] = "STA2";
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/commands/sync/request.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,kCAAc,CAAA;IACd,iCAAa,CAAA;IACb,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,oCAAgB,CAAA;AACpB,CAAC,EATW,gBAAgB,GAAhB,gBAAgB,KAAhB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import Struct, { type StructAsyncDeserializeStream, type StructLike, type Struct
2
2
  import type { AdbBufferedStream } from '../../stream/index.js';
3
3
  export declare enum AdbSyncResponseId {
4
4
  Entry = "DENT",
5
+ Entry2 = "DNT2",
5
6
  Lstat = "STAT",
6
7
  Stat = "STA2",
7
8
  Lstat2 = "LST2",
@@ -20,5 +21,5 @@ export declare const AdbSyncFailResponse: Struct<{
20
21
  messageLength: number;
21
22
  message: string;
22
23
  }, "messageLength", {}, never>;
23
- export declare function adbSyncReadResponse<T extends Record<string, StructLike<any>>>(stream: AdbBufferedStream, types: T): Promise<StructValueType<T[keyof T]>>;
24
+ export declare function adbSyncReadResponse<T extends Record<string, StructLike<any>>>(stream: AdbBufferedStream, types: T): Promise<StructValueType<T extends unknown ? T[keyof T] : never>>;
24
25
  //# sourceMappingURL=response.d.ts.map