@yume-chan/adb 0.0.18 → 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.
- package/CHANGELOG.json +21 -0
- package/CHANGELOG.md +11 -1
- package/esm/adb.d.ts +63 -60
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +257 -249
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +51 -51
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +95 -96
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +8 -8
- package/esm/backend.d.ts.map +1 -1
- package/esm/backend.js +1 -1
- package/esm/commands/base.d.ts +6 -6
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js +8 -8
- package/esm/commands/framebuffer.d.ts +53 -53
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +46 -46
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +7 -8
- package/esm/commands/index.d.ts.map +1 -1
- package/esm/commands/index.js +7 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/install.d.ts +9 -3
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +26 -26
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +22 -22
- package/esm/commands/power.js +48 -48
- package/esm/commands/reverse.d.ts +41 -28
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +125 -100
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +57 -51
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +86 -80
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +3 -3
- package/esm/commands/subprocess/index.js +3 -3
- package/esm/commands/subprocess/protocols/index.d.ts +3 -3
- package/esm/commands/subprocess/protocols/index.js +3 -3
- package/esm/commands/subprocess/protocols/none.d.ts +35 -35
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +65 -55
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +166 -162
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +49 -49
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/types.js +1 -1
- package/esm/commands/subprocess/utils.d.ts +1 -1
- package/esm/commands/subprocess/utils.js +18 -18
- package/esm/commands/sync/index.d.ts +8 -7
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +8 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +42 -40
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +67 -47
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +13 -11
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +35 -37
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +46 -7
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +89 -22
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +26 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +40 -42
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +19 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +54 -54
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +27 -0
- package/esm/commands/sync/socket.d.ts.map +1 -0
- package/esm/commands/sync/socket.js +66 -0
- package/esm/commands/sync/socket.js.map +1 -0
- package/esm/commands/sync/stat.d.ts +72 -72
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +116 -104
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +72 -60
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +127 -149
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +5 -5
- package/esm/commands/tcpip.js +18 -18
- package/esm/crypto.d.ts +36 -36
- package/esm/crypto.js +248 -248
- package/esm/features.d.ts +10 -7
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +13 -10
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +9 -9
- package/esm/index.js +9 -9
- package/esm/packet.d.ts +45 -46
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +43 -48
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +59 -59
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +223 -234
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +2 -2
- package/esm/socket/index.js +2 -2
- package/esm/socket/socket.d.ts +59 -59
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +118 -118
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/auto-reset-event.d.ts +9 -9
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +33 -33
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +27 -27
- package/esm/utils/base64.js +246 -246
- package/esm/utils/conditional-variable.d.ts +9 -0
- package/esm/utils/conditional-variable.d.ts.map +1 -0
- package/esm/utils/conditional-variable.js +34 -0
- package/esm/utils/conditional-variable.js.map +1 -0
- package/esm/utils/index.d.ts +4 -3
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +4 -3
- package/esm/utils/index.js.map +1 -1
- package/package.json +11 -10
- package/src/adb.ts +47 -37
- package/src/auth.ts +7 -6
- package/src/backend.ts +4 -4
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +4 -4
- package/src/commands/index.ts +7 -8
- package/src/commands/reverse.ts +35 -10
- package/src/commands/subprocess/command.ts +12 -4
- package/src/commands/subprocess/index.ts +3 -3
- package/src/commands/subprocess/protocols/index.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +25 -11
- package/src/commands/subprocess/protocols/shell.ts +50 -28
- package/src/commands/subprocess/protocols/types.ts +8 -7
- package/src/commands/subprocess/utils.ts +1 -1
- package/src/commands/sync/index.ts +8 -7
- package/src/commands/sync/list.ts +42 -23
- package/src/commands/sync/pull.ts +40 -45
- package/src/commands/sync/push.ts +146 -39
- package/src/commands/sync/request.ts +20 -15
- package/src/commands/sync/response.ts +7 -6
- package/src/commands/sync/socket.ts +97 -0
- package/src/commands/sync/stat.ts +47 -42
- package/src/commands/sync/sync.ts +68 -108
- package/src/commands/tcpip.ts +5 -5
- package/src/features.ts +9 -6
- package/src/packet.ts +19 -34
- package/src/socket/dispatcher.ts +32 -47
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +26 -17
- package/src/utils/auto-reset-event.ts +14 -15
- package/src/utils/conditional-variable.ts +45 -0
- package/src/utils/index.ts +4 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/commands/install.ts +0 -40
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* * `
|
|
19
|
-
* * `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static
|
|
24
|
-
static
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import type { Consumable, ReadableStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import { WritableStream } from "@yume-chan/stream-extra";
|
|
3
|
+
import type { Adb } from "../../../adb.js";
|
|
4
|
+
import type { AdbSocket } from "../../../socket/index.js";
|
|
5
|
+
import type { AdbSubprocessProtocol } from "./types.js";
|
|
6
|
+
export declare enum AdbShellProtocolId {
|
|
7
|
+
Stdin = 0,
|
|
8
|
+
Stdout = 1,
|
|
9
|
+
Stderr = 2,
|
|
10
|
+
Exit = 3,
|
|
11
|
+
CloseStdin = 4,
|
|
12
|
+
WindowSizeChange = 5
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Shell v2 a.k.a Shell Protocol
|
|
16
|
+
*
|
|
17
|
+
* Features:
|
|
18
|
+
* * `stderr`: Yes
|
|
19
|
+
* * `exit` exit code: Yes
|
|
20
|
+
* * `resize`: Yes
|
|
21
|
+
*/
|
|
22
|
+
export declare class AdbSubprocessShellProtocol implements AdbSubprocessProtocol {
|
|
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
|
+
private readonly _socket;
|
|
27
|
+
private _socketWriter;
|
|
28
|
+
private _stdin;
|
|
29
|
+
get stdin(): WritableStream<Consumable<Uint8Array>>;
|
|
30
|
+
private _stdout;
|
|
31
|
+
get stdout(): ReadableStream<Uint8Array>;
|
|
32
|
+
private _stderr;
|
|
33
|
+
get stderr(): ReadableStream<Uint8Array>;
|
|
34
|
+
private readonly _exit;
|
|
35
|
+
get exit(): Promise<number>;
|
|
36
|
+
constructor(socket: AdbSocket);
|
|
37
|
+
resize(rows: number, cols: number): Promise<void>;
|
|
38
|
+
kill(): Promise<void>;
|
|
39
|
+
}
|
|
39
40
|
//# 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,
|
|
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,EAMH,cAAc,EAEjB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D,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;AAqFD;;;;;;;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,CAEnB;IAEF,OAAO,CAAC,MAAM,CAAyC;IACvD,IAAW,KAAK,2CAEf;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;IA4DvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAYvC,IAAI;CAGd"}
|
|
@@ -1,163 +1,167 @@
|
|
|
1
|
-
import { PromiseResolver } from
|
|
2
|
-
import { PushReadableStream, StructDeserializeStream,
|
|
3
|
-
import Struct, { placeholder } from
|
|
4
|
-
import {
|
|
5
|
-
import { encodeUtf8 } from
|
|
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(
|
|
18
|
-
.uint32(
|
|
19
|
-
.uint8Array(
|
|
20
|
-
class StdinSerializeStream extends
|
|
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.
|
|
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
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
import { ConsumableTransformStream, ConsumableWritableStream, PushReadableStream, StructDeserializeStream, TransformStream, 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 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.supportsFeature(AdbFeature.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 ConsumableTransformStream({
|
|
145
|
+
async transform(chunk, controller) {
|
|
146
|
+
await controller.enqueue(AdbShellProtocolPacket.serialize(chunk));
|
|
147
|
+
},
|
|
148
|
+
}))
|
|
149
|
+
.pipeTo(socket.writable);
|
|
150
|
+
this._stdin = pipeFrom(multiplexer.createWriteable(), new StdinSerializeStream());
|
|
151
|
+
this._socketWriter = multiplexer.createWriteable().getWriter();
|
|
152
|
+
}
|
|
153
|
+
async resize(rows, cols) {
|
|
154
|
+
await ConsumableWritableStream.write(this._socketWriter, {
|
|
155
|
+
id: AdbShellProtocolId.WindowSizeChange,
|
|
156
|
+
data: encodeUtf8(
|
|
157
|
+
// The "correct" format is `${rows}x${cols},${x_pixels}x${y_pixels}`
|
|
158
|
+
// However, according to https://linux.die.net/man/4/tty_ioctl
|
|
159
|
+
// `x_pixels` and `y_pixels` are unused, so always sending `0` should be fine.
|
|
160
|
+
`${rows}x${cols},0x0\0`),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
kill() {
|
|
164
|
+
return this._socket.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
163
167
|
//# 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;
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../../src/commands/subprocess/protoc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AK,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,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 } 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<Consumable<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
|
+
}
|
|
50
50
|
//# 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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,cAAc,EACd,cAAc,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;IAEvD;;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,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
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
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"}
|