@yume-chan/adb 0.0.10 → 0.0.13
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 +50 -0
- package/CHANGELOG.md +29 -1
- package/LICENSE +1 -1
- package/README.md +71 -51
- package/esm/adb.d.ts +48 -0
- package/esm/adb.d.ts.map +1 -0
- package/esm/adb.js +149 -136
- package/esm/adb.js.map +1 -1
- package/{dts → esm}/auth.d.ts +11 -11
- package/esm/auth.d.ts.map +1 -0
- package/esm/auth.js +72 -110
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +9 -0
- package/esm/backend.d.ts.map +1 -0
- package/{dts → esm}/commands/base.d.ts +1 -1
- package/esm/commands/base.d.ts.map +1 -0
- package/esm/commands/base.js +1 -0
- package/esm/commands/base.js.map +1 -1
- package/{dts → esm}/commands/framebuffer.d.ts +3 -3
- package/esm/commands/framebuffer.d.ts.map +1 -0
- package/esm/commands/framebuffer.js +15 -18
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +9 -0
- package/esm/commands/index.d.ts.map +1 -0
- package/esm/commands/index.js +8 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/install.d.ts +4 -0
- package/esm/commands/install.d.ts.map +1 -0
- package/esm/commands/install.js +19 -13
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +23 -0
- package/esm/commands/power.d.ts.map +1 -0
- package/esm/commands/power.js +45 -0
- package/esm/commands/power.js.map +1 -0
- package/{dts → esm}/commands/reverse.d.ts +3 -3
- package/esm/commands/reverse.d.ts.map +1 -0
- package/esm/commands/reverse.js +49 -60
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +56 -0
- package/esm/commands/subprocess/index.d.ts.map +1 -0
- package/esm/commands/subprocess/index.js +88 -0
- package/esm/commands/subprocess/index.js.map +1 -0
- package/esm/commands/subprocess/legacy.d.ts +35 -0
- package/esm/commands/subprocess/legacy.d.ts.map +1 -0
- package/esm/commands/subprocess/legacy.js +53 -0
- package/esm/commands/subprocess/legacy.js.map +1 -0
- package/esm/commands/subprocess/protocol.d.ts +39 -0
- package/esm/commands/subprocess/protocol.d.ts.map +1 -0
- package/esm/commands/subprocess/protocol.js +157 -0
- package/esm/commands/subprocess/protocol.js.map +1 -0
- package/esm/commands/subprocess/protocols/index.d.ts +4 -0
- package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/index.js +4 -0
- package/esm/commands/subprocess/protocols/index.js.map +1 -0
- package/esm/commands/subprocess/protocols/none.d.ts +35 -0
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/none.js +53 -0
- package/esm/commands/subprocess/protocols/none.js.map +1 -0
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -0
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/shell.js +155 -0
- package/esm/commands/subprocess/protocols/shell.js.map +1 -0
- package/esm/commands/subprocess/protocols/types.d.ts +50 -0
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
- package/esm/commands/{shell → subprocess/protocols}/types.js +0 -0
- package/esm/commands/subprocess/protocols/types.js.map +1 -0
- package/esm/commands/subprocess/types.d.ts +50 -0
- package/esm/commands/subprocess/types.d.ts.map +1 -0
- package/esm/commands/subprocess/types.js +2 -0
- package/esm/commands/{shell → subprocess}/types.js.map +1 -1
- package/{dts/commands/shell → esm/commands/subprocess}/utils.d.ts +0 -0
- package/esm/commands/subprocess/utils.d.ts.map +1 -0
- package/esm/commands/{shell → subprocess}/utils.js +0 -0
- package/esm/commands/subprocess/utils.js.map +1 -0
- package/esm/commands/sync/index.d.ts +8 -0
- package/esm/commands/sync/index.d.ts.map +1 -0
- package/esm/commands/sync/index.js +7 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +41 -0
- package/esm/commands/sync/list.d.ts.map +1 -0
- package/esm/commands/sync/list.js +52 -20
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +11 -0
- package/esm/commands/sync/pull.d.ts.map +1 -0
- package/esm/commands/sync/pull.js +17 -11
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +8 -0
- package/esm/commands/sync/push.d.ts.map +1 -0
- package/esm/commands/sync/push.js +19 -37
- package/esm/commands/sync/push.js.map +1 -1
- package/{dts → esm}/commands/sync/request.d.ts +4 -3
- package/esm/commands/sync/request.d.ts.map +1 -0
- package/esm/commands/sync/request.js +25 -27
- package/esm/commands/sync/request.js.map +1 -1
- package/{dts → esm}/commands/sync/response.d.ts +4 -3
- package/esm/commands/sync/response.d.ts.map +1 -0
- package/esm/commands/sync/response.js +17 -20
- package/esm/commands/sync/response.js.map +1 -1
- package/{dts → esm}/commands/sync/stat.d.ts +16 -4
- package/esm/commands/sync/stat.d.ts.map +1 -0
- package/esm/commands/sync/stat.js +38 -30
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +61 -0
- package/esm/commands/sync/sync.d.ts.map +1 -0
- package/esm/commands/sync/sync.js +122 -89
- package/esm/commands/sync/sync.js.map +1 -1
- package/{dts → esm}/commands/tcpip.d.ts +1 -1
- package/{dts → esm}/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +14 -19
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/crypto.d.ts +37 -0
- package/esm/crypto.d.ts.map +1 -0
- package/esm/crypto.js +77 -62
- package/esm/crypto.js.map +1 -1
- package/esm/features.d.ts +8 -0
- package/esm/features.d.ts.map +1 -0
- package/esm/features.js +7 -3
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +11 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +10 -10
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +47 -0
- package/esm/packet.d.ts.map +1 -0
- package/esm/packet.js +27 -52
- package/esm/packet.js.map +1 -1
- package/esm/socket/controller.d.ts +37 -0
- package/esm/socket/controller.d.ts.map +1 -0
- package/esm/socket/controller.js +52 -66
- package/esm/socket/controller.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +44 -0
- package/esm/socket/dispatcher.d.ts.map +1 -0
- package/esm/socket/dispatcher.js +146 -165
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +3 -0
- package/esm/socket/index.d.ts.map +1 -0
- package/esm/socket/index.js +2 -6
- package/esm/socket/index.js.map +1 -1
- package/esm/socket/socket.d.ts +46 -0
- package/esm/socket/socket.d.ts.map +1 -0
- package/esm/socket/socket.js +77 -13
- package/esm/socket/socket.js.map +1 -1
- package/esm/stream/buffered.d.ts +35 -0
- package/esm/stream/buffered.d.ts.map +1 -0
- package/esm/stream/buffered.js +123 -0
- package/esm/stream/buffered.js.map +1 -0
- package/esm/stream/detect.bak.d.ts +240 -0
- package/esm/stream/detect.bak.d.ts.map +1 -0
- package/esm/stream/detect.bak.js +60 -0
- package/esm/stream/detect.bak.js.map +1 -0
- package/esm/stream/detect.d.ts +2 -0
- package/esm/stream/detect.d.ts.map +1 -0
- package/esm/stream/detect.js +5 -0
- package/esm/stream/detect.js.map +1 -0
- package/esm/stream/detect.native.d.ts +240 -0
- package/esm/stream/detect.native.d.ts.map +1 -0
- package/esm/stream/detect.native.js +60 -0
- package/esm/stream/detect.native.js.map +1 -0
- package/esm/stream/detect.polyfill.d.ts +18 -0
- package/esm/stream/detect.polyfill.d.ts.map +1 -0
- package/esm/stream/detect.polyfill.js +9 -0
- package/esm/stream/detect.polyfill.js.map +1 -0
- package/esm/stream/index.d.ts +4 -0
- package/esm/stream/index.d.ts.map +1 -0
- package/esm/stream/index.js +3 -2
- package/esm/stream/index.js.map +1 -1
- package/esm/stream/transform.d.ts +98 -0
- package/esm/stream/transform.d.ts.map +1 -0
- package/esm/stream/transform.js +402 -0
- package/esm/stream/transform.js.map +1 -0
- package/{dts → esm}/utils/auto-reset-event.d.ts +1 -1
- package/esm/utils/auto-reset-event.d.ts.map +1 -0
- package/esm/utils/auto-reset-event.js +2 -1
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +5 -0
- package/esm/utils/base64.d.ts.map +1 -0
- package/esm/utils/base64.js +116 -80
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/encoding.d.ts +3 -0
- package/esm/utils/encoding.d.ts.map +1 -0
- package/esm/utils/encoding.js +1 -1
- package/esm/utils/encoding.js.map +1 -1
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +3 -5
- package/esm/utils/index.js.map +1 -1
- package/package.json +50 -44
- package/src/adb.ts +177 -150
- package/src/auth.ts +37 -30
- package/src/backend.ts +3 -12
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +4 -4
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +24 -15
- package/src/commands/power.ts +54 -0
- package/src/commands/reverse.ts +10 -8
- package/src/commands/subprocess/index.ts +139 -0
- package/src/commands/subprocess/protocols/index.ts +3 -0
- package/src/commands/subprocess/protocols/none.ts +68 -0
- package/src/commands/subprocess/protocols/shell.ts +190 -0
- package/src/commands/subprocess/protocols/types.ts +59 -0
- package/src/commands/{shell → subprocess}/utils.ts +0 -0
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +56 -9
- package/src/commands/sync/pull.ts +27 -18
- package/src/commands/sync/push.ts +25 -30
- package/src/commands/sync/request.ts +8 -7
- package/src/commands/sync/response.ts +12 -6
- package/src/commands/sync/stat.ts +43 -14
- package/src/commands/sync/sync.ts +102 -34
- package/src/commands/tcpip.ts +3 -3
- package/src/crypto.ts +95 -84
- package/src/features.ts +6 -2
- package/src/index.ts +11 -10
- package/src/packet.ts +49 -53
- package/src/socket/dispatcher.ts +110 -109
- package/src/socket/index.ts +2 -6
- package/src/socket/socket.ts +125 -17
- package/src/stream/buffered.ts +147 -0
- package/src/stream/detect.native.ts +362 -0
- package/src/stream/detect.polyfill.ts +28 -0
- package/src/stream/detect.ts +5 -0
- package/src/stream/index.ts +3 -2
- package/src/stream/transform.ts +483 -0
- package/src/utils/auto-reset-event.ts +1 -1
- package/src/utils/base64.ts +161 -129
- package/src/utils/index.ts +3 -5
- package/tsconfig.build.json +3 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.test.json +10 -0
- package/dts/adb.d.ts +0 -46
- package/dts/adb.d.ts.map +0 -1
- package/dts/auth.d.ts.map +0 -1
- package/dts/backend.d.ts +0 -13
- package/dts/backend.d.ts.map +0 -1
- package/dts/commands/base.d.ts.map +0 -1
- package/dts/commands/demo-mode.d.ts +0 -41
- package/dts/commands/demo-mode.d.ts.map +0 -1
- package/dts/commands/framebuffer.d.ts.map +0 -1
- package/dts/commands/index.d.ts +0 -9
- package/dts/commands/index.d.ts.map +0 -1
- package/dts/commands/install.d.ts +0 -3
- package/dts/commands/install.d.ts.map +0 -1
- package/dts/commands/reverse.d.ts.map +0 -1
- package/dts/commands/shell/index.d.ts +0 -46
- package/dts/commands/shell/index.d.ts.map +0 -1
- package/dts/commands/shell/legacy.d.ts +0 -38
- package/dts/commands/shell/legacy.d.ts.map +0 -1
- package/dts/commands/shell/protocol.d.ts +0 -45
- package/dts/commands/shell/protocol.d.ts.map +0 -1
- package/dts/commands/shell/types.d.ts +0 -47
- package/dts/commands/shell/types.d.ts.map +0 -1
- package/dts/commands/shell/utils.d.ts.map +0 -1
- package/dts/commands/sync/index.d.ts +0 -8
- package/dts/commands/sync/index.d.ts.map +0 -1
- package/dts/commands/sync/list.d.ts +0 -17
- package/dts/commands/sync/list.d.ts.map +0 -1
- package/dts/commands/sync/pull.d.ts +0 -11
- package/dts/commands/sync/pull.d.ts.map +0 -1
- package/dts/commands/sync/push.d.ts +0 -8
- package/dts/commands/sync/push.d.ts.map +0 -1
- package/dts/commands/sync/request.d.ts.map +0 -1
- package/dts/commands/sync/response.d.ts.map +0 -1
- package/dts/commands/sync/stat.d.ts.map +0 -1
- package/dts/commands/sync/sync.d.ts +0 -68
- package/dts/commands/sync/sync.d.ts.map +0 -1
- package/dts/crypto.d.ts +0 -24
- package/dts/crypto.d.ts.map +0 -1
- package/dts/features.d.ts +0 -6
- package/dts/features.d.ts.map +0 -1
- package/dts/index.d.ts +0 -11
- package/dts/index.d.ts.map +0 -1
- package/dts/packet.d.ts +0 -27
- package/dts/packet.d.ts.map +0 -1
- package/dts/socket/close-event-emitter.d.ts +0 -8
- package/dts/socket/close-event-emitter.d.ts.map +0 -1
- package/dts/socket/controller.d.ts +0 -43
- package/dts/socket/controller.d.ts.map +0 -1
- package/dts/socket/data-event-emitter.d.ts +0 -10
- package/dts/socket/data-event-emitter.d.ts.map +0 -1
- package/dts/socket/dispatcher.d.ts +0 -53
- package/dts/socket/dispatcher.d.ts.map +0 -1
- package/dts/socket/index.d.ts +0 -7
- package/dts/socket/index.d.ts.map +0 -1
- package/dts/socket/logger.d.ts +0 -9
- package/dts/socket/logger.d.ts.map +0 -1
- package/dts/socket/socket.d.ts +0 -22
- package/dts/socket/socket.d.ts.map +0 -1
- package/dts/stream/buffered-stream.d.ts +0 -28
- package/dts/stream/buffered-stream.d.ts.map +0 -1
- package/dts/stream/index.d.ts +0 -3
- package/dts/stream/index.d.ts.map +0 -1
- package/dts/stream/stream.d.ts +0 -15
- package/dts/stream/stream.d.ts.map +0 -1
- package/dts/utils/auto-reset-event.d.ts.map +0 -1
- package/dts/utils/base64.d.ts +0 -7
- package/dts/utils/base64.d.ts.map +0 -1
- package/dts/utils/chunk.d.ts +0 -3
- package/dts/utils/chunk.d.ts.map +0 -1
- package/dts/utils/encoding.d.ts +0 -3
- package/dts/utils/encoding.d.ts.map +0 -1
- package/dts/utils/event-queue.d.ts +0 -35
- package/dts/utils/event-queue.d.ts.map +0 -1
- package/dts/utils/index.d.ts +0 -6
- package/dts/utils/index.d.ts.map +0 -1
- package/esm/commands/demo-mode.js +0 -170
- package/esm/commands/demo-mode.js.map +0 -1
- package/esm/commands/shell/index.js +0 -62
- package/esm/commands/shell/index.js.map +0 -1
- package/esm/commands/shell/legacy.js +0 -49
- package/esm/commands/shell/legacy.js.map +0 -1
- package/esm/commands/shell/protocol.js +0 -106
- package/esm/commands/shell/protocol.js.map +0 -1
- package/esm/commands/shell/utils.js.map +0 -1
- package/esm/socket/close-event-emitter.js +0 -28
- package/esm/socket/close-event-emitter.js.map +0 -1
- package/esm/socket/data-event-emitter.js +0 -25
- package/esm/socket/data-event-emitter.js.map +0 -1
- package/esm/socket/logger.js +0 -2
- package/esm/socket/logger.js.map +0 -1
- package/esm/stream/buffered-stream.js +0 -67
- package/esm/stream/buffered-stream.js.map +0 -1
- package/esm/stream/stream.js +0 -41
- package/esm/stream/stream.js.map +0 -1
- package/esm/utils/chunk.js +0 -70
- package/esm/utils/chunk.js.map +0 -1
- package/esm/utils/event-queue.js +0 -104
- package/esm/utils/event-queue.js.map +0 -1
- package/src/commands/demo-mode.ts +0 -160
- package/src/commands/shell/index.ts +0 -87
- package/src/commands/shell/legacy.ts +0 -59
- package/src/commands/shell/protocol.ts +0 -121
- package/src/commands/shell/types.ts +0 -55
- package/src/socket/close-event-emitter.ts +0 -28
- package/src/socket/controller.ts +0 -105
- package/src/socket/data-event-emitter.ts +0 -27
- package/src/socket/logger.ts +0 -12
- package/src/stream/buffered-stream.ts +0 -92
- package/src/stream/stream.ts +0 -50
- package/src/utils/chunk.ts +0 -70
- package/src/utils/encoding.ts +0 -13
- package/src/utils/event-queue.ts +0 -145
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DecodeUtf8Stream, GatherStringStream } from "../../stream/index.js";
|
|
2
|
+
import { AdbSubprocessNoneProtocol, AdbSubprocessShellProtocol } from './protocols/index.js';
|
|
3
|
+
export * from './protocols/index.js';
|
|
4
|
+
export * from './utils.js';
|
|
5
|
+
const DEFAULT_OPTIONS = {
|
|
6
|
+
protocols: [AdbSubprocessShellProtocol, AdbSubprocessNoneProtocol],
|
|
7
|
+
};
|
|
8
|
+
export class AdbSubprocess {
|
|
9
|
+
adb;
|
|
10
|
+
constructor(adb) {
|
|
11
|
+
this.adb = adb;
|
|
12
|
+
}
|
|
13
|
+
async createProtocol(mode, command, options) {
|
|
14
|
+
const { protocols } = { ...DEFAULT_OPTIONS, ...options };
|
|
15
|
+
let Constructor;
|
|
16
|
+
for (const item of protocols) {
|
|
17
|
+
// It's async so can't use `Array#find`
|
|
18
|
+
if (await item.isSupported(this.adb)) {
|
|
19
|
+
Constructor = item;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (!Constructor) {
|
|
24
|
+
throw new Error('No specified protocol is supported by the device');
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(command)) {
|
|
27
|
+
command = command.join(' ');
|
|
28
|
+
}
|
|
29
|
+
else if (command === undefined) {
|
|
30
|
+
// spawn the default shell
|
|
31
|
+
command = '';
|
|
32
|
+
}
|
|
33
|
+
return await Constructor[mode](this.adb, command);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Spawns an executable in PTY (interactive) mode.
|
|
37
|
+
* @param command The command to run. If omitted, the default shell will be spawned.
|
|
38
|
+
* @param options The options for creating the `AdbSubprocessProtocol`
|
|
39
|
+
* @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
|
|
40
|
+
*/
|
|
41
|
+
shell(command, options) {
|
|
42
|
+
return this.createProtocol('pty', command, options);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Spawns an executable and pipe the output.
|
|
46
|
+
* @param command The command to run, or an array of strings containing both command and args.
|
|
47
|
+
* @param options The options for creating the `AdbSubprocessProtocol`
|
|
48
|
+
* @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
|
|
49
|
+
*/
|
|
50
|
+
spawn(command, options) {
|
|
51
|
+
return this.createProtocol('raw', command, options);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Spawns a new process, waits until it exits, and returns the entire output.
|
|
55
|
+
* @param command The command to run
|
|
56
|
+
* @param options The options for creating the `AdbSubprocessProtocol`
|
|
57
|
+
* @returns The entire output of the command
|
|
58
|
+
*/
|
|
59
|
+
async spawnAndWait(command, options) {
|
|
60
|
+
const shell = await this.spawn(command, options);
|
|
61
|
+
const stdout = new GatherStringStream();
|
|
62
|
+
const stderr = new GatherStringStream();
|
|
63
|
+
const [, , exitCode] = await Promise.all([
|
|
64
|
+
shell.stdout
|
|
65
|
+
.pipeThrough(new DecodeUtf8Stream())
|
|
66
|
+
.pipeTo(stdout),
|
|
67
|
+
shell.stderr
|
|
68
|
+
.pipeThrough(new DecodeUtf8Stream())
|
|
69
|
+
.pipeTo(stderr),
|
|
70
|
+
shell.exit
|
|
71
|
+
]);
|
|
72
|
+
return {
|
|
73
|
+
stdout: stdout.result,
|
|
74
|
+
stderr: stderr.result,
|
|
75
|
+
exitCode,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Spawns a new process, waits until it exits, and returns the entire output.
|
|
80
|
+
* @param command The command to run
|
|
81
|
+
* @returns The entire output of the command
|
|
82
|
+
*/
|
|
83
|
+
async spawnAndWaitLegacy(command) {
|
|
84
|
+
const { stdout } = await this.spawnAndWait(command, { protocols: [AdbSubprocessNoneProtocol] });
|
|
85
|
+
return stdout;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/subprocess/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAqE,MAAM,sBAAsB,CAAC;AAEhK,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAiB3B,MAAM,eAAe,GAAyB;IAC1C,SAAS,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IACI,KAAK,CAAC,YAAY,CACrB,OAA0B,EAC1B,OAAuC;QAEvC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAEjD,MAAM,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAExC,MAAM,CAAC,EAAE,AAAD,EAAG,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACrC,KAAK,CAAC,MAAM;iBACP,WAAW,CAAC,IAAI,gBAAgB,EAAE,CAAC;iBACnC,MAAM,CAAC,MAAM,CAAC;YACnB,KAAK,CAAC,MAAM;iBACP,WAAW,CAAC,IAAI,gBAAgB,EAAE,CAAC;iBACnC,MAAM,CAAC,MAAM,CAAC;YACnB,KAAK,CAAC,IAAI;SACb,CAAC,CAAC;QAEH,OAAO;YACH,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ;SACX,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,kBAAkB,CAAC,OAA0B;QACtD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CACtC,OAAO,EACP,EAAE,SAAS,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAC7C,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Adb } from "../../../../src/adb.js";
|
|
2
|
+
import type { AdbSocket } from "../../../../src/socket/index.js";
|
|
3
|
+
import { type ReadableStream } from "../../../../src/stream/index.js";
|
|
4
|
+
import type { AdbSubprocessProtocol } from "../../../../src/commands/subprocess/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=legacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjF,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 } 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
|
+
// Native ADB client doesn't allow none protocol + raw mode,
|
|
17
|
+
// But ADB daemon supports it.
|
|
18
|
+
return new AdbSubprocessNoneProtocol(await adb.createSocket(`shell,raw:${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.createWrapReadable(this.socket.readable);
|
|
43
|
+
this._stderr = factory.createReadable();
|
|
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=legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../src/commands/subprocess/legacy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAuB,MAAM,uBAAuB,CAAC;AAGjF;;;;;;;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,yBAAyB,CAAC,MAAM,GAAG,CAAC,YAAY,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAQ,EAAE,OAAe;QAC7C,4DAA4D;QAC5D,8BAA8B;QAC9B,OAAO,IAAI,yBAAyB,CAAC,MAAM,GAAG,CAAC,YAAY,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;IAEgB,MAAM,CAAY;IAEnC,2CAA2C;IAC3C,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3C,OAAO,CAA6B;IAC5C;;OAEG;IACH,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpC,OAAO,CAA6B;IAC5C;;OAEG;IACH,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpC,KAAK,CAAkB;IAC/B,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAExC,YAAmB,MAAiB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAyB;YAC5D,KAAK,EAAE,KAAK,IAAI,EAAE;gBACd,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IAEM,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=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/protocol.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAsB,cAAc,EAAmE,cAAc,EAAkE,MAAM,uBAAuB,CAAC;AAE5N,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;IA0CvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAYvC,IAAI;CAGd"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
import Struct, { placeholder } from "@yume-chan/struct";
|
|
3
|
+
import { AdbFeatures } from "../../features.js";
|
|
4
|
+
import { 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 `StdoutTransformStream` 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
|
+
const { readable, writable } = new StdinSerializeStream();
|
|
139
|
+
this._stdin = writable;
|
|
140
|
+
readable.pipeTo(multiplexer.createWriteable());
|
|
141
|
+
this._socketWriter = multiplexer.createWriteable().getWriter();
|
|
142
|
+
}
|
|
143
|
+
async resize(rows, cols) {
|
|
144
|
+
await this._socketWriter.write({
|
|
145
|
+
id: AdbShellProtocolId.WindowSizeChange,
|
|
146
|
+
data: encodeUtf8(
|
|
147
|
+
// The "correct" format is `${rows}x${cols},${x_pixels}x${y_pixels}`
|
|
148
|
+
// However, according to https://linux.die.net/man/4/tty_ioctl
|
|
149
|
+
// `x_pixels` and `y_pixels` are not used, so always passing `0` is fine.
|
|
150
|
+
`${rows}x${cols},0x0\0`),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
kill() {
|
|
154
|
+
return this._socket.close();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/commands/subprocess/protocol.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,mBAAmB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAkB,uBAAuB,EAAE,qBAAqB,EAAE,eAAe,EAAE,cAAc,EAAkE,MAAM,uBAAuB,CAAC;AAC5N,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC1B,6DAAK,CAAA;IACL,+DAAM,C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1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/subprocess/protocols/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Adb } from "../../../adb.js";
|
|
2
|
+
import type { AdbSocket } from "../../../socket/index.js";
|
|
3
|
+
import { type 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,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACpF,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 } 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
|
+
// Native ADB client doesn't allow none protocol + raw mode,
|
|
17
|
+
// But ADB daemon supports it.
|
|
18
|
+
return new AdbSubprocessNoneProtocol(await adb.createSocket(`shell,raw:${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.createWrapReadable(this.socket.readable);
|
|
43
|
+
this._stderr = factory.createReadable();
|
|
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,EAAuB,MAAM,0BAA0B,CAAC;AAGpF;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IAC3B,MAAM,CAAC,WAAW,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAErC,MAAM,CAAC,KAAK,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CAAC,CAAC,CAAC;IAC9C,CAAC;IAEM,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"}
|