@yume-chan/adb 0.0.9 → 0.0.12
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 +55 -0
- package/CHANGELOG.md +35 -0
- package/LICENSE +21 -21
- package/README.md +240 -257
- package/esm/adb.d.ts +48 -0
- package/esm/adb.d.ts.map +1 -0
- package/esm/adb.js +141 -145
- package/esm/adb.js.map +1 -1
- package/{dts → esm}/auth.d.ts +17 -7
- package/esm/auth.d.ts.map +1 -0
- package/esm/auth.js +69 -109
- 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 +21 -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 +50 -60
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +57 -0
- package/esm/commands/subprocess/index.d.ts.map +1 -0
- package/esm/commands/subprocess/index.js +83 -0
- package/esm/commands/subprocess/index.js.map +1 -0
- package/esm/commands/subprocess/legacy.d.ts +28 -0
- package/esm/commands/subprocess/legacy.d.ts.map +1 -0
- package/esm/commands/subprocess/legacy.js +44 -0
- package/esm/commands/subprocess/legacy.js.map +1 -0
- package/esm/commands/subprocess/protocol.d.ts +38 -0
- package/esm/commands/subprocess/protocol.d.ts.map +1 -0
- package/esm/commands/subprocess/protocol.js +155 -0
- package/esm/commands/subprocess/protocol.js.map +1 -0
- package/esm/commands/subprocess/types.d.ts +47 -0
- package/esm/commands/subprocess/types.d.ts.map +1 -0
- package/esm/commands/{shell → subprocess}/types.js +0 -0
- package/{cjs/commands/shell → esm/commands/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/{dts → esm}/commands/sync/list.d.ts +4 -4
- package/esm/commands/sync/list.d.ts.map +1 -0
- package/esm/commands/sync/list.js +16 -19
- 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 +3 -3
- package/esm/commands/sync/request.d.ts.map +1 -0
- package/esm/commands/sync/request.js +24 -26
- package/esm/commands/sync/request.js.map +1 -1
- package/{dts → esm}/commands/sync/response.d.ts +3 -3
- package/esm/commands/sync/response.d.ts.map +1 -0
- package/esm/commands/sync/response.js +16 -19
- package/esm/commands/sync/response.js.map +1 -1
- package/{dts → esm}/commands/sync/stat.d.ts +4 -4
- package/esm/commands/sync/stat.d.ts.map +1 -0
- package/esm/commands/sync/stat.js +22 -27
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +83 -0
- package/esm/commands/sync/sync.d.ts.map +1 -0
- package/esm/commands/sync/sync.js +92 -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 +24 -0
- package/esm/crypto.d.ts.map +1 -0
- package/esm/crypto.js +33 -31
- package/esm/crypto.js.map +1 -1
- package/{dts → esm}/features.d.ts +0 -0
- package/{dts → esm}/features.d.ts.map +0 -0
- package/esm/features.js +1 -1
- 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 +28 -0
- package/esm/packet.d.ts.map +1 -0
- package/esm/packet.js +26 -53
- 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/{dts → esm}/socket/dispatcher.d.ts +10 -23
- package/esm/socket/dispatcher.d.ts.map +1 -0
- package/esm/socket/dispatcher.js +148 -164
- 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 +34 -0
- package/esm/socket/socket.d.ts.map +1 -0
- package/esm/socket/socket.js +69 -14
- 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 +18 -0
- package/esm/stream/detect.d.ts.map +1 -0
- package/esm/stream/detect.js +6 -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 +6 -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 +352 -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 +11 -0
- package/esm/utils/encoding.js.map +1 -0
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +3 -4
- package/esm/utils/index.js.map +1 -1
- package/package.json +49 -50
- package/src/adb.ts +247 -242
- package/src/auth.ts +170 -156
- package/src/backend.ts +11 -24
- package/src/commands/base.ts +11 -11
- package/src/commands/framebuffer.ts +73 -73
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +32 -21
- package/src/commands/power.ts +54 -0
- package/src/commands/reverse.ts +136 -133
- package/src/commands/subprocess/index.ts +124 -0
- package/src/commands/subprocess/legacy.ts +58 -0
- package/src/commands/subprocess/protocol.ts +185 -0
- package/src/commands/subprocess/types.ts +55 -0
- package/src/commands/{shell → subprocess}/utils.ts +20 -20
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +40 -39
- package/src/commands/sync/pull.ts +43 -34
- package/src/commands/sync/push.ts +41 -46
- package/src/commands/sync/request.ts +49 -48
- package/src/commands/sync/response.ts +58 -57
- package/src/commands/sync/stat.ts +123 -121
- package/src/commands/sync/sync.ts +145 -113
- package/src/commands/tcpip.ts +21 -21
- package/src/crypto.ts +280 -280
- package/src/features.ts +5 -5
- package/src/index.ts +11 -10
- package/src/packet.ts +69 -89
- package/src/socket/dispatcher.ts +256 -269
- package/src/socket/index.ts +2 -6
- package/src/socket/socket.ts +129 -28
- package/src/stream/buffered.ts +147 -0
- package/src/stream/detect.native.ts +362 -0
- package/src/stream/detect.polyfill.ts +25 -0
- package/src/stream/detect.ts +25 -0
- package/src/stream/index.ts +3 -2
- package/src/stream/transform.ts +427 -0
- package/src/utils/auto-reset-event.ts +41 -41
- package/src/utils/base64.ts +306 -274
- package/src/utils/encoding.ts +13 -0
- package/src/utils/index.ts +3 -4
- package/tsconfig.build.json +3 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.test.json +10 -0
- package/cjs/adb.js +0 -205
- package/cjs/adb.js.map +0 -1
- package/cjs/auth.js +0 -141
- package/cjs/auth.js.map +0 -1
- package/cjs/backend.js +0 -3
- package/cjs/backend.js.map +0 -1
- package/cjs/commands/base.js +0 -12
- package/cjs/commands/base.js.map +0 -1
- package/cjs/commands/demo-mode.js +0 -174
- package/cjs/commands/demo-mode.js.map +0 -1
- package/cjs/commands/framebuffer.js +0 -66
- package/cjs/commands/framebuffer.js.map +0 -1
- package/cjs/commands/index.js +0 -12
- package/cjs/commands/index.js.map +0 -1
- package/cjs/commands/install.js +0 -20
- package/cjs/commands/install.js.map +0 -1
- package/cjs/commands/reverse.js +0 -105
- package/cjs/commands/reverse.js.map +0 -1
- package/cjs/commands/shell/index.js +0 -56
- package/cjs/commands/shell/index.js.map +0 -1
- package/cjs/commands/shell/legacy.js +0 -37
- package/cjs/commands/shell/legacy.js.map +0 -1
- package/cjs/commands/shell/protocol.js +0 -83
- package/cjs/commands/shell/protocol.js.map +0 -1
- package/cjs/commands/shell/types.js +0 -3
- package/cjs/commands/shell/utils.js +0 -23
- package/cjs/commands/shell/utils.js.map +0 -1
- package/cjs/commands/sync/index.js +0 -11
- package/cjs/commands/sync/index.js.map +0 -1
- package/cjs/commands/sync/list.js +0 -36
- package/cjs/commands/sync/list.js.map +0 -1
- package/cjs/commands/sync/pull.js +0 -34
- package/cjs/commands/sync/pull.js.map +0 -1
- package/cjs/commands/sync/push.js +0 -49
- package/cjs/commands/sync/push.js.map +0 -1
- package/cjs/commands/sync/request.js +0 -48
- package/cjs/commands/sync/request.js.map +0 -1
- package/cjs/commands/sync/response.js +0 -53
- package/cjs/commands/sync/response.js.map +0 -1
- package/cjs/commands/sync/stat.js +0 -109
- package/cjs/commands/sync/stat.js.map +0 -1
- package/cjs/commands/sync/sync.js +0 -118
- package/cjs/commands/sync/sync.js.map +0 -1
- package/cjs/commands/tcpip.js +0 -28
- package/cjs/commands/tcpip.js.map +0 -1
- package/cjs/crypto.js +0 -231
- package/cjs/crypto.js.map +0 -1
- package/cjs/features.js +0 -10
- package/cjs/features.js.map +0 -1
- package/cjs/index.js +0 -14
- package/cjs/index.js.map +0 -1
- package/cjs/packet.js +0 -77
- package/cjs/packet.js.map +0 -1
- package/cjs/socket/close-event-emitter.js +0 -32
- package/cjs/socket/close-event-emitter.js.map +0 -1
- package/cjs/socket/controller.js +0 -84
- package/cjs/socket/controller.js.map +0 -1
- package/cjs/socket/data-event-emitter.js +0 -29
- package/cjs/socket/data-event-emitter.js.map +0 -1
- package/cjs/socket/dispatcher.js +0 -219
- package/cjs/socket/dispatcher.js.map +0 -1
- package/cjs/socket/index.js +0 -10
- package/cjs/socket/index.js.map +0 -1
- package/cjs/socket/logger.js +0 -3
- package/cjs/socket/logger.js.map +0 -1
- package/cjs/socket/socket.js +0 -24
- package/cjs/socket/socket.js.map +0 -1
- package/cjs/stream/buffered-stream.js +0 -78
- package/cjs/stream/buffered-stream.js.map +0 -1
- package/cjs/stream/index.js +0 -6
- package/cjs/stream/index.js.map +0 -1
- package/cjs/stream/stream.js +0 -45
- package/cjs/stream/stream.js.map +0 -1
- package/cjs/utils/auto-reset-event.js +0 -37
- package/cjs/utils/auto-reset-event.js.map +0 -1
- package/cjs/utils/base64.js +0 -210
- package/cjs/utils/base64.js.map +0 -1
- package/cjs/utils/chunk.js +0 -75
- package/cjs/utils/chunk.js.map +0 -1
- package/cjs/utils/event-queue.js +0 -108
- package/cjs/utils/event-queue.js.map +0 -1
- package/cjs/utils/index.js +0 -8
- package/cjs/utils/index.js.map +0 -1
- 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 -15
- 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 -20
- package/dts/commands/shell/index.d.ts.map +0 -1
- package/dts/commands/shell/legacy.d.ts +0 -27
- package/dts/commands/shell/legacy.d.ts.map +0 -1
- package/dts/commands/shell/protocol.d.ts +0 -37
- package/dts/commands/shell/protocol.d.ts.map +0 -1
- package/dts/commands/shell/types.d.ts +0 -15
- 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.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 -17
- package/dts/crypto.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.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 -30
- 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/event-queue.d.ts +0 -35
- package/dts/utils/event-queue.d.ts.map +0 -1
- package/dts/utils/index.d.ts +0 -5
- 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 -52
- package/esm/commands/shell/index.js.map +0 -1
- package/esm/commands/shell/legacy.js +0 -33
- package/esm/commands/shell/legacy.js.map +0 -1
- package/esm/commands/shell/protocol.js +0 -79
- package/esm/commands/shell/protocol.js.map +0 -1
- package/esm/commands/shell/types.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 -73
- 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 -68
- package/src/commands/shell/legacy.ts +0 -42
- package/src/commands/shell/protocol.ts +0 -94
- package/src/commands/shell/types.ts +0 -21
- 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 -100
- package/src/stream/stream.ts +0 -50
- package/src/utils/chunk.ts +0 -70
- package/src/utils/event-queue.ts +0 -145
- package/tsconfig.cjs.json +0 -11
- package/tsconfig.esm.json +0 -28
- package/tsconfig.esm.tsbuildinfo +0 -1305
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
2
|
+
import type { Adb } from "../../adb.js";
|
|
3
|
+
import type { AdbSocket } from "../../socket/index.js";
|
|
4
|
+
import type { ReadableStream, WritableStream } from "../../stream/index.js";
|
|
5
|
+
|
|
6
|
+
export interface AdbSubprocessProtocol {
|
|
7
|
+
/**
|
|
8
|
+
* A WritableStream that writes to the `stdin` pipe.
|
|
9
|
+
*/
|
|
10
|
+
readonly stdin: WritableStream<Uint8Array>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `stdout` pipe of the process.
|
|
14
|
+
*/
|
|
15
|
+
readonly stdout: ReadableStream<Uint8Array>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The `stderr` pipe of the process.
|
|
19
|
+
*
|
|
20
|
+
* Note: Some `AdbShell` doesn't separate `stdout` and `stderr`,
|
|
21
|
+
* All output will be sent to `stdout`.
|
|
22
|
+
*/
|
|
23
|
+
readonly stderr: ReadableStream<Uint8Array>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A `Promise` that resolves to the exit code of the process.
|
|
27
|
+
*
|
|
28
|
+
* Note: Some `AdbShell` doesn't support exit code,
|
|
29
|
+
* They will always resolve with `0`.
|
|
30
|
+
*/
|
|
31
|
+
readonly exit: Promise<number>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resizes the current shell.
|
|
35
|
+
*
|
|
36
|
+
* Some `AdbShell`s may not support resizing and will always ignore calls to this method.
|
|
37
|
+
*/
|
|
38
|
+
resize(rows: number, cols: number): ValueOrPromise<void>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Kills the current process.
|
|
42
|
+
*/
|
|
43
|
+
kill(): ValueOrPromise<void>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface AdbSubprocessProtocolConstructor {
|
|
47
|
+
/** Returns `true` if the `adb` instance supports this shell */
|
|
48
|
+
isSupported(adb: Adb): ValueOrPromise<boolean>;
|
|
49
|
+
|
|
50
|
+
/** Creates a new `AdbShell` using the specified `Adb` and `command` */
|
|
51
|
+
spawn(adb: Adb, command: string): ValueOrPromise<AdbSubprocessProtocol>;
|
|
52
|
+
|
|
53
|
+
/** Creates a new `AdbShell` by attaching to an exist `AdbSocket` */
|
|
54
|
+
new(socket: AdbSocket): AdbSubprocessProtocol;
|
|
55
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export function escapeArg(s: string) {
|
|
2
|
-
let result = '';
|
|
3
|
-
result += `'`;
|
|
4
|
-
|
|
5
|
-
let base = 0;
|
|
6
|
-
while (true) {
|
|
7
|
-
const found = s.indexOf(`'`, base);
|
|
8
|
-
if (found === -1) {
|
|
9
|
-
result += s.substring(base);
|
|
10
|
-
break;
|
|
11
|
-
}
|
|
12
|
-
result += s.substring(base, found);
|
|
13
|
-
// a'b becomes a'\'b
|
|
14
|
-
result += String.raw`'\''`;
|
|
15
|
-
base = found + 1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
result += `'`;
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
1
|
+
export function escapeArg(s: string) {
|
|
2
|
+
let result = '';
|
|
3
|
+
result += `'`;
|
|
4
|
+
|
|
5
|
+
let base = 0;
|
|
6
|
+
while (true) {
|
|
7
|
+
const found = s.indexOf(`'`, base);
|
|
8
|
+
if (found === -1) {
|
|
9
|
+
result += s.substring(base);
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
result += s.substring(base, found);
|
|
13
|
+
// a'b becomes a'\'b
|
|
14
|
+
result += String.raw`'\''`;
|
|
15
|
+
base = found + 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
result += `'`;
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './list';
|
|
2
|
-
export * from './pull';
|
|
3
|
-
export * from './request';
|
|
4
|
-
export * from './response';
|
|
5
|
-
export * from './push';
|
|
6
|
-
export * from './stat';
|
|
7
|
-
export * from './sync';
|
|
1
|
+
export * from './list.js';
|
|
2
|
+
export * from './pull.js';
|
|
3
|
+
export * from './request.js';
|
|
4
|
+
export * from './response.js';
|
|
5
|
+
export * from './push.js';
|
|
6
|
+
export * from './stat.js';
|
|
7
|
+
export * from './sync.js';
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import Struct from '@yume-chan/struct';
|
|
2
|
-
import { AdbBufferedStream } from '../../stream';
|
|
3
|
-
import { AdbSyncRequestId, adbSyncWriteRequest } from './request';
|
|
4
|
-
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response';
|
|
5
|
-
import { AdbSyncLstatResponse } from './stat';
|
|
6
|
-
|
|
7
|
-
export const AdbSyncEntryResponse =
|
|
8
|
-
new Struct({ littleEndian: true })
|
|
9
|
-
.fields(AdbSyncLstatResponse)
|
|
10
|
-
.uint32('nameLength')
|
|
11
|
-
.string('name', { lengthField: 'nameLength' })
|
|
12
|
-
.extra({ id: AdbSyncResponseId.Entry as const });
|
|
13
|
-
|
|
14
|
-
export type AdbSyncEntryResponse = typeof AdbSyncEntryResponse['TDeserializeResult'];
|
|
15
|
-
|
|
16
|
-
const ResponseTypes = {
|
|
17
|
-
[AdbSyncResponseId.Entry]: AdbSyncEntryResponse,
|
|
18
|
-
[AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncEntryResponse.size),
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export async function* adbSyncOpenDir(
|
|
22
|
-
stream: AdbBufferedStream,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
import type { AdbBufferedStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
|
3
|
+
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
|
4
|
+
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
|
5
|
+
import { AdbSyncLstatResponse } from './stat.js';
|
|
6
|
+
|
|
7
|
+
export const AdbSyncEntryResponse =
|
|
8
|
+
new Struct({ littleEndian: true })
|
|
9
|
+
.fields(AdbSyncLstatResponse)
|
|
10
|
+
.uint32('nameLength')
|
|
11
|
+
.string('name', { lengthField: 'nameLength' })
|
|
12
|
+
.extra({ id: AdbSyncResponseId.Entry as const });
|
|
13
|
+
|
|
14
|
+
export type AdbSyncEntryResponse = typeof AdbSyncEntryResponse['TDeserializeResult'];
|
|
15
|
+
|
|
16
|
+
const ResponseTypes = {
|
|
17
|
+
[AdbSyncResponseId.Entry]: AdbSyncEntryResponse,
|
|
18
|
+
[AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncEntryResponse.size),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export async function* adbSyncOpenDir(
|
|
22
|
+
stream: AdbBufferedStream,
|
|
23
|
+
writer: WritableStreamDefaultWriter<Uint8Array>,
|
|
24
|
+
path: string,
|
|
25
|
+
): AsyncGenerator<AdbSyncEntryResponse, void, void> {
|
|
26
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.List, path);
|
|
27
|
+
|
|
28
|
+
while (true) {
|
|
29
|
+
const response = await adbSyncReadResponse(stream, ResponseTypes);
|
|
30
|
+
switch (response.id) {
|
|
31
|
+
case AdbSyncResponseId.Entry:
|
|
32
|
+
yield response;
|
|
33
|
+
break;
|
|
34
|
+
case AdbSyncResponseId.Done:
|
|
35
|
+
return;
|
|
36
|
+
default:
|
|
37
|
+
throw new Error('Unexpected response id');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import Struct from '@yume-chan/struct';
|
|
2
|
-
import { AdbBufferedStream } from '../../stream';
|
|
3
|
-
import { AdbSyncRequestId, adbSyncWriteRequest } from './request';
|
|
4
|
-
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response';
|
|
5
|
-
|
|
6
|
-
export const AdbSyncDataResponse =
|
|
7
|
-
new Struct({ littleEndian: true })
|
|
8
|
-
.uint32('dataLength')
|
|
9
|
-
.
|
|
10
|
-
.extra({ id: AdbSyncResponseId.Data as const });
|
|
11
|
-
|
|
12
|
-
const ResponseTypes = {
|
|
13
|
-
[AdbSyncResponseId.Data]: AdbSyncDataResponse,
|
|
14
|
-
[AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncDataResponse.size),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
stream: AdbBufferedStream,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
import { AdbBufferedStream, ReadableStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
|
3
|
+
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
|
4
|
+
import { AdbSyncDoneResponse, adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
|
5
|
+
|
|
6
|
+
export const AdbSyncDataResponse =
|
|
7
|
+
new Struct({ littleEndian: true })
|
|
8
|
+
.uint32('dataLength')
|
|
9
|
+
.uint8Array('data', { lengthField: 'dataLength' })
|
|
10
|
+
.extra({ id: AdbSyncResponseId.Data as const });
|
|
11
|
+
|
|
12
|
+
const ResponseTypes = {
|
|
13
|
+
[AdbSyncResponseId.Data]: AdbSyncDataResponse,
|
|
14
|
+
[AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncDataResponse.size),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function adbSyncPull(
|
|
18
|
+
stream: AdbBufferedStream,
|
|
19
|
+
writer: WritableStreamDefaultWriter<Uint8Array>,
|
|
20
|
+
path: string,
|
|
21
|
+
): ReadableStream<Uint8Array> {
|
|
22
|
+
return new ReadableStream<Uint8Array>({
|
|
23
|
+
async start() {
|
|
24
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.Receive, path);
|
|
25
|
+
},
|
|
26
|
+
async pull(controller) {
|
|
27
|
+
const response = await adbSyncReadResponse(stream, ResponseTypes);
|
|
28
|
+
switch (response.id) {
|
|
29
|
+
case AdbSyncResponseId.Data:
|
|
30
|
+
controller.enqueue(response.data!);
|
|
31
|
+
break;
|
|
32
|
+
case AdbSyncResponseId.Done:
|
|
33
|
+
controller.close();
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
throw new Error('Unexpected response id');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
highWaterMark: 16 * 1024,
|
|
41
|
+
size(chunk) { return chunk.byteLength; }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
import Struct from '@yume-chan/struct';
|
|
2
|
-
import { AdbBufferedStream } from '../../stream';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
filename: string,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
await adbSyncWriteRequest(stream, AdbSyncRequestId.Done, mtime);
|
|
45
|
-
await adbSyncReadResponse(stream, ResponseTypes);
|
|
46
|
-
}
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
import { AdbBufferedStream, ChunkStream, pipeFrom, WritableStream, WritableStreamDefaultWriter } from '../../stream/index.js';
|
|
3
|
+
import { AdbSyncRequestId, adbSyncWriteRequest } from './request.js';
|
|
4
|
+
import { adbSyncReadResponse, AdbSyncResponseId } from './response.js';
|
|
5
|
+
import { LinuxFileType } from './stat.js';
|
|
6
|
+
|
|
7
|
+
export const AdbSyncOkResponse =
|
|
8
|
+
new Struct({ littleEndian: true })
|
|
9
|
+
.uint32('unused');
|
|
10
|
+
|
|
11
|
+
const ResponseTypes = {
|
|
12
|
+
[AdbSyncResponseId.Ok]: AdbSyncOkResponse,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ADB_SYNC_MAX_PACKET_SIZE = 64 * 1024;
|
|
16
|
+
|
|
17
|
+
export function adbSyncPush(
|
|
18
|
+
stream: AdbBufferedStream,
|
|
19
|
+
writer: WritableStreamDefaultWriter<Uint8Array>,
|
|
20
|
+
filename: string,
|
|
21
|
+
mode: number = (LinuxFileType.File << 12) | 0o666,
|
|
22
|
+
mtime: number = (Date.now() / 1000) | 0,
|
|
23
|
+
packetSize: number = ADB_SYNC_MAX_PACKET_SIZE,
|
|
24
|
+
): WritableStream<Uint8Array> {
|
|
25
|
+
return pipeFrom(
|
|
26
|
+
new WritableStream<Uint8Array>({
|
|
27
|
+
async start() {
|
|
28
|
+
const pathAndMode = `${filename},${mode.toString()}`;
|
|
29
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.Send, pathAndMode);
|
|
30
|
+
},
|
|
31
|
+
async write(chunk) {
|
|
32
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.Data, chunk);
|
|
33
|
+
},
|
|
34
|
+
async close() {
|
|
35
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.Done, mtime);
|
|
36
|
+
await adbSyncReadResponse(stream, ResponseTypes);
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
new ChunkStream(packetSize)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import Struct from '@yume-chan/struct';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
import type { WritableStreamDefaultWriter } from "../../stream/index.js";
|
|
3
|
+
import { encodeUtf8 } from "../../utils/index.js";
|
|
4
|
+
|
|
5
|
+
export enum AdbSyncRequestId {
|
|
6
|
+
List = 'LIST',
|
|
7
|
+
Send = 'SEND',
|
|
8
|
+
Lstat = 'STAT',
|
|
9
|
+
Stat = 'STA2',
|
|
10
|
+
Lstat2 = 'LST2',
|
|
11
|
+
Data = 'DATA',
|
|
12
|
+
Done = 'DONE',
|
|
13
|
+
Receive = 'RECV',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const AdbSyncNumberRequest =
|
|
17
|
+
new Struct({ littleEndian: true })
|
|
18
|
+
.string('id', { length: 4 })
|
|
19
|
+
.uint32('arg');
|
|
20
|
+
|
|
21
|
+
export const AdbSyncDataRequest =
|
|
22
|
+
new Struct({ littleEndian: true })
|
|
23
|
+
.fields(AdbSyncNumberRequest)
|
|
24
|
+
.uint8Array('data', { lengthField: 'arg' });
|
|
25
|
+
|
|
26
|
+
export async function adbSyncWriteRequest(
|
|
27
|
+
writer: WritableStreamDefaultWriter<Uint8Array>,
|
|
28
|
+
id: AdbSyncRequestId | string,
|
|
29
|
+
value: number | string | Uint8Array
|
|
30
|
+
): Promise<void> {
|
|
31
|
+
let buffer: Uint8Array;
|
|
32
|
+
if (typeof value === 'number') {
|
|
33
|
+
buffer = AdbSyncNumberRequest.serialize({
|
|
34
|
+
id,
|
|
35
|
+
arg: value,
|
|
36
|
+
});
|
|
37
|
+
} else if (typeof value === 'string') {
|
|
38
|
+
buffer = AdbSyncDataRequest.serialize({
|
|
39
|
+
id,
|
|
40
|
+
data: encodeUtf8(value),
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
buffer = AdbSyncDataRequest.serialize({
|
|
44
|
+
id,
|
|
45
|
+
data: value,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
await writer.write(buffer);
|
|
49
|
+
}
|
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import Struct, {
|
|
2
|
-
import { AdbBufferedStream } from '../../stream';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import Struct, { type StructAsyncDeserializeStream, type StructLike, type StructValueType } from '@yume-chan/struct';
|
|
2
|
+
import type { AdbBufferedStream } from '../../stream/index.js';
|
|
3
|
+
import { decodeUtf8 } from "../../utils/index.js";
|
|
4
|
+
|
|
5
|
+
export enum AdbSyncResponseId {
|
|
6
|
+
Entry = 'DENT',
|
|
7
|
+
Lstat = 'STAT',
|
|
8
|
+
Stat = 'STA2',
|
|
9
|
+
Lstat2 = 'LST2',
|
|
10
|
+
Done = 'DONE',
|
|
11
|
+
Data = 'DATA',
|
|
12
|
+
Ok = 'OKAY',
|
|
13
|
+
Fail = 'FAIL',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// DONE responses' size are always same as the request's normal response.
|
|
17
|
+
// For example DONE responses for LIST requests are 16 bytes (same as DENT responses),
|
|
18
|
+
// but DONE responses for STAT requests are 12 bytes (same as STAT responses)
|
|
19
|
+
// So we need to know responses' size in advance.
|
|
20
|
+
export class AdbSyncDoneResponse implements StructLike<AdbSyncDoneResponse> {
|
|
21
|
+
private length: number;
|
|
22
|
+
|
|
23
|
+
public readonly id = AdbSyncResponseId.Done;
|
|
24
|
+
|
|
25
|
+
public constructor(length: number) {
|
|
26
|
+
this.length = length;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public async deserialize(stream: StructAsyncDeserializeStream): Promise<this> {
|
|
30
|
+
await stream.read(this.length);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const AdbSyncFailResponse =
|
|
36
|
+
new Struct({ littleEndian: true })
|
|
37
|
+
.uint32('messageLength')
|
|
38
|
+
.string('message', { lengthField: 'messageLength' })
|
|
39
|
+
.postDeserialize(object => {
|
|
40
|
+
throw new Error(object.message);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export async function adbSyncReadResponse<T extends Record<string, StructLike<any>>>(
|
|
44
|
+
stream: AdbBufferedStream,
|
|
45
|
+
types: T,
|
|
46
|
+
): Promise<StructValueType<T[keyof T]>> {
|
|
47
|
+
const id = decodeUtf8(await stream.read(4));
|
|
48
|
+
|
|
49
|
+
if (id === AdbSyncResponseId.Fail) {
|
|
50
|
+
await AdbSyncFailResponse.deserialize(stream);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (types[id]) {
|
|
54
|
+
return types[id]!.deserialize(stream);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
throw new Error('Unexpected response id');
|
|
58
|
+
}
|