@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
package/esm/utils/chunk.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
2
|
-
export function* chunkArrayLike(value, size) {
|
|
3
|
-
if ('length' in value) {
|
|
4
|
-
value = new Uint8Array(value).buffer;
|
|
5
|
-
}
|
|
6
|
-
if (value.byteLength <= size) {
|
|
7
|
-
return yield value;
|
|
8
|
-
}
|
|
9
|
-
for (let i = 0; i < value.byteLength; i += size) {
|
|
10
|
-
yield value.slice(i, i + size);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function chunkAsyncIterable(value, size) {
|
|
14
|
-
return __asyncGenerator(this, arguments, function* chunkAsyncIterable_1() {
|
|
15
|
-
var e_1, _a;
|
|
16
|
-
let result = new Uint8Array(size);
|
|
17
|
-
let index = 0;
|
|
18
|
-
try {
|
|
19
|
-
for (var value_1 = __asyncValues(value), value_1_1; value_1_1 = yield __await(value_1.next()), !value_1_1.done;) {
|
|
20
|
-
let buffer = value_1_1.value;
|
|
21
|
-
// `result` has some data, `result + buffer` is enough
|
|
22
|
-
if (index !== 0 && index + buffer.byteLength >= size) {
|
|
23
|
-
const remainder = size - index;
|
|
24
|
-
result.set(new Uint8Array(buffer, 0, remainder), index);
|
|
25
|
-
yield yield __await(result.buffer);
|
|
26
|
-
result = new Uint8Array(size);
|
|
27
|
-
index = 0;
|
|
28
|
-
if (buffer.byteLength > remainder) {
|
|
29
|
-
// `buffer` still has some data
|
|
30
|
-
buffer = buffer.slice(remainder);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// `result` is empty, `buffer` alone is enough
|
|
37
|
-
if (buffer.byteLength >= size) {
|
|
38
|
-
let remainder = false;
|
|
39
|
-
for (const chunk of chunkArrayLike(buffer, size)) {
|
|
40
|
-
if (chunk.byteLength === size) {
|
|
41
|
-
yield yield __await(chunk);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
// `buffer` still has some data
|
|
45
|
-
remainder = true;
|
|
46
|
-
buffer = chunk;
|
|
47
|
-
}
|
|
48
|
-
if (!remainder) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// `result` has some data but `result + buffer` is still not enough
|
|
53
|
-
// or after previous steps `buffer` still has some data
|
|
54
|
-
result.set(new Uint8Array(buffer), index);
|
|
55
|
-
index += buffer.byteLength;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
-
finally {
|
|
60
|
-
try {
|
|
61
|
-
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) yield __await(_a.call(value_1));
|
|
62
|
-
}
|
|
63
|
-
finally { if (e_1) throw e_1.error; }
|
|
64
|
-
}
|
|
65
|
-
if (index !== 0) {
|
|
66
|
-
yield yield __await(result.buffer.slice(0, index));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=chunk.js.map
|
package/esm/utils/chunk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/utils/chunk.ts"],"names":[],"mappings":";AAAA,MAAM,SAAS,CAAC,CAAC,cAAc,CAC3B,KAA0C,EAC1C,IAAY;IAEZ,IAAI,QAAQ,IAAI,KAAK,EAAE;QACnB,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;KACxC;IAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE;QAC1B,OAAO,MAAM,KAAK,CAAC;KACtB;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,IAAI,EAAE;QAC7C,MAAM,KAAK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AAC;qBAClB;oBAED,IAAI,CAAC,SAAS,EAAE;wBACZ,SAAS;qBACZ;iBACJ;gBAED,mEAAmE;gBACnE,uDAAuD;gBACvD,MAAM,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;gBAC1C,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC;aAC9B;;;;;;;;;QAED,IAAI,KAAK,KAAK,CAAC,EAAE;YACb,oBAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA,CAAC;SACvC;IACL,CAAC;CAAA"}
|
package/esm/utils/event-queue.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { PromiseResolver } from '@yume-chan/async';
|
|
2
|
-
import { EventEmitter } from '@yume-chan/event';
|
|
3
|
-
export const EventQueueDefaultOptions = {
|
|
4
|
-
maxWaitCount: Infinity,
|
|
5
|
-
highWaterMark: 10,
|
|
6
|
-
lowWaterMark: 0,
|
|
7
|
-
};
|
|
8
|
-
class LinkedList {
|
|
9
|
-
constructor() {
|
|
10
|
-
this._length = 0;
|
|
11
|
-
}
|
|
12
|
-
get length() { return this._length; }
|
|
13
|
-
push(value) {
|
|
14
|
-
const item = { value };
|
|
15
|
-
if (this._length === 0) {
|
|
16
|
-
this.head = item;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.tail.next = item;
|
|
20
|
-
}
|
|
21
|
-
this._length += 1;
|
|
22
|
-
this.tail = item;
|
|
23
|
-
}
|
|
24
|
-
shift() {
|
|
25
|
-
if (this._length === 0) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const { next, value } = this.head;
|
|
29
|
-
if (!next) {
|
|
30
|
-
this.tail = undefined;
|
|
31
|
-
}
|
|
32
|
-
this.head = next;
|
|
33
|
-
this._length -= 1;
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Basically an object-mode ReadableStream with Promise-based API
|
|
39
|
-
*
|
|
40
|
-
* It's called `EventQueue` because it usually converts events ("push system") to "pull system"
|
|
41
|
-
*
|
|
42
|
-
* https://github.com/nodejs/node/blob/master/lib/internal/streams/readable.js
|
|
43
|
-
*/
|
|
44
|
-
export class EventQueue {
|
|
45
|
-
constructor(options) {
|
|
46
|
-
// Use linked lists for faster shift operation.
|
|
47
|
-
/** Already buffered data ready to be served to consumers */
|
|
48
|
-
this.buffers = new LinkedList();
|
|
49
|
-
/** Waiting consumers because lack of data */
|
|
50
|
-
this.awaiters = new LinkedList();
|
|
51
|
-
this.ended = false;
|
|
52
|
-
this._length = 0;
|
|
53
|
-
this._needDrain = false;
|
|
54
|
-
this.drainEvent = new EventEmitter();
|
|
55
|
-
this.onDrain = this.drainEvent.event;
|
|
56
|
-
this.options = Object.assign(Object.assign({}, EventQueueDefaultOptions), options);
|
|
57
|
-
}
|
|
58
|
-
get length() { return this._length; }
|
|
59
|
-
get needDrain() { return this._needDrain; }
|
|
60
|
-
enqueue(value, length = 1) {
|
|
61
|
-
if (this.ended) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (this.awaiters.length) {
|
|
65
|
-
this.awaiters.shift().resolve(value);
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
this.buffers.push([value, length]);
|
|
69
|
-
this._length += length;
|
|
70
|
-
if (this._length < this.options.highWaterMark) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
this._needDrain = true;
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
dequeue() {
|
|
77
|
-
if (this.buffers.length) {
|
|
78
|
-
const [value, size] = this.buffers.shift();
|
|
79
|
-
this._length -= size;
|
|
80
|
-
if (this._needDrain &&
|
|
81
|
-
this._length <= this.options.lowWaterMark) {
|
|
82
|
-
this.drainEvent.fire();
|
|
83
|
-
}
|
|
84
|
-
return Promise.resolve(value);
|
|
85
|
-
}
|
|
86
|
-
if (this.ended) {
|
|
87
|
-
return Promise.reject(new Error('The EventQueue has already ended'));
|
|
88
|
-
}
|
|
89
|
-
if (this.awaiters.length === this.options.maxWaitCount - 1) {
|
|
90
|
-
throw new Error('Max wait count exceeded');
|
|
91
|
-
}
|
|
92
|
-
const resolver = new PromiseResolver();
|
|
93
|
-
this.awaiters.push(resolver);
|
|
94
|
-
return resolver.promise;
|
|
95
|
-
}
|
|
96
|
-
end() {
|
|
97
|
-
this.ended = true;
|
|
98
|
-
let item;
|
|
99
|
-
while (item = this.awaiters.shift()) {
|
|
100
|
-
item.reject(new Error('The EventQueue has already ended'));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=event-queue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.js","sourceRoot":"","sources":["../../src/utils/event-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACvD,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,CAAC;CAClB,CAAC;AAQF,MAAM,UAAU;IAAhB;QAKY,YAAO,GAAG,CAAC,CAAC;IA8BxB,CAAC;IA7BG,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAErC,IAAI,CAAC,KAAQ;QAChB,MAAM,IAAI,GAAsB,EAAE,KAAK,EAAE,CAAC;QAE1C,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SACpB;aAAM;YACH,IAAI,CAAC,IAAK,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,I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,IAAI,IAAoC,CAAC;QACzC,OAAO,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC,CAAC;SAC9D;IACL,CAAC;CACJ"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { AdbCommandBase } from './base';
|
|
2
|
-
|
|
3
|
-
export enum AdbDemoModeWifiSignalStrength {
|
|
4
|
-
Hidden = 'null',
|
|
5
|
-
Level0 = '0',
|
|
6
|
-
Level1 = '1',
|
|
7
|
-
Level2 = '2',
|
|
8
|
-
Level3 = '3',
|
|
9
|
-
Level4 = '4',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java;l=1073
|
|
13
|
-
export const AdbDemoModeMobileDataTypes = ['1x', '3g', '4g', '4g+', '5g', '5ge', '5g+',
|
|
14
|
-
'e', 'g', 'h', 'h+', 'lte', 'lte+', 'dis', 'not', 'null'] as const;
|
|
15
|
-
|
|
16
|
-
export type AdbDemoModeMobileDataType = (typeof AdbDemoModeMobileDataTypes)[number];
|
|
17
|
-
|
|
18
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3136
|
|
19
|
-
export const AdbDemoModeStatusBarModes = ['opaque', 'translucent', 'semi-transparent', 'transparent', 'warning'] as const;
|
|
20
|
-
|
|
21
|
-
export type AdbDemoModeStatusBarMode = (typeof AdbDemoModeStatusBarModes)[number];
|
|
22
|
-
|
|
23
|
-
export class AdbDemoMode extends AdbCommandBase {
|
|
24
|
-
public static readonly AllowedSettingKey = 'sysui_demo_allowed';
|
|
25
|
-
|
|
26
|
-
// Demo Mode actually doesn't have a setting indicates its enablement
|
|
27
|
-
// However Developer Mode menu uses this key
|
|
28
|
-
// So we can only try our best to guess if it's enabled
|
|
29
|
-
public static readonly EnabledSettingKey = 'sysui_tuner_demo_on';
|
|
30
|
-
|
|
31
|
-
public async getAllowed(): Promise<boolean> {
|
|
32
|
-
const result = await this.adb.childProcess.exec('settings', 'get', 'global', AdbDemoMode.AllowedSettingKey);
|
|
33
|
-
return result.trim() === '1';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public async setAllowed(value: boolean): Promise<void> {
|
|
37
|
-
if (value) {
|
|
38
|
-
await this.adb.childProcess.exec('settings', 'put', 'global', AdbDemoMode.AllowedSettingKey, '1');
|
|
39
|
-
} else {
|
|
40
|
-
await this.setEnabled(false);
|
|
41
|
-
await this.adb.childProcess.exec('settings', 'delete', 'global', AdbDemoMode.AllowedSettingKey);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public async getEnabled(): Promise<boolean> {
|
|
46
|
-
const result = await this.adb.childProcess.exec('settings', 'get', 'global', AdbDemoMode.EnabledSettingKey);
|
|
47
|
-
return result.trim() === '1';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async setEnabled(value: boolean): Promise<void> {
|
|
51
|
-
if (value) {
|
|
52
|
-
await this.adb.childProcess.exec('settings', 'put', 'global', AdbDemoMode.EnabledSettingKey, '1');
|
|
53
|
-
} else {
|
|
54
|
-
await this.adb.childProcess.exec('settings', 'delete', 'global', AdbDemoMode.EnabledSettingKey);
|
|
55
|
-
await this.broadcast('exit');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public async broadcast(command: string, extra?: Record<string, string>): Promise<void> {
|
|
60
|
-
await this.adb.childProcess.exec(
|
|
61
|
-
'am',
|
|
62
|
-
'broadcast',
|
|
63
|
-
'-a',
|
|
64
|
-
'com.android.systemui.demo',
|
|
65
|
-
'-e',
|
|
66
|
-
'command',
|
|
67
|
-
command,
|
|
68
|
-
...(extra ? Object.entries(extra).flatMap(([key, value]) => ['-e', key, value]) : []),
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public async setBatteryLevel(level: number): Promise<void> {
|
|
73
|
-
await this.broadcast('battery', { level: level.toString() });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public async setBatteryCharging(value: boolean): Promise<void> {
|
|
77
|
-
await this.broadcast('battery', { plugged: value.toString() });
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public async setPowerSaveMode(value: boolean): Promise<void> {
|
|
81
|
-
await this.broadcast('battery', { powersave: value.toString() });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public async setAirplaneMode(show: boolean): Promise<void> {
|
|
85
|
-
await this.broadcast('network', { airplane: show ? 'show' : 'hide' });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public async setWifiSignalStrength(value: AdbDemoModeWifiSignalStrength): Promise<void> {
|
|
89
|
-
await this.broadcast('network', { wifi: 'show', level: value });
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public async setMobileDataType(value: AdbDemoModeMobileDataType): Promise<void> {
|
|
93
|
-
for (let i = 0; i < 2; i += 1) {
|
|
94
|
-
await this.broadcast('network', {
|
|
95
|
-
mobile: 'show',
|
|
96
|
-
sims: '1',
|
|
97
|
-
nosim: 'hide',
|
|
98
|
-
slot: '0',
|
|
99
|
-
datatype: value,
|
|
100
|
-
fully: 'true',
|
|
101
|
-
roam: 'false',
|
|
102
|
-
level: '4',
|
|
103
|
-
inflate: 'false',
|
|
104
|
-
activity: 'in',
|
|
105
|
-
carriernetworkchange: 'hide',
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public async setMobileSignalStrength(value: AdbDemoModeWifiSignalStrength): Promise<void> {
|
|
111
|
-
await this.broadcast('network', { mobile: 'show', level: value });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public async setNoSimCardIcon(show: boolean): Promise<void> {
|
|
115
|
-
await this.broadcast('network', { nosim: show ? 'show' : 'hide' });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public async setStatusBarMode(mode: AdbDemoModeStatusBarMode): Promise<void> {
|
|
119
|
-
await this.broadcast('bars', { mode });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public async setVibrateModeEnabled(value: boolean): Promise<void> {
|
|
123
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=103
|
|
124
|
-
await this.broadcast('status', { volume: value ? 'vibrate' : 'hide' });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public async setBluetoothConnected(value: boolean): Promise<void> {
|
|
128
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=114
|
|
129
|
-
await this.broadcast('status', { bluetooth: value ? 'connected' : 'hide' });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public async setLocatingIcon(show: boolean): Promise<void> {
|
|
133
|
-
await this.broadcast('status', { location: show ? 'show' : 'hide' });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public async setAlarmIcon(show: boolean): Promise<void> {
|
|
137
|
-
await this.broadcast('status', { alarm: show ? 'show' : 'hide' });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public async setSyncingIcon(show: boolean): Promise<void> {
|
|
141
|
-
await this.broadcast('status', { sync: show ? 'show' : 'hide' });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public async setMuteIcon(show: boolean): Promise<void> {
|
|
145
|
-
await this.broadcast('status', { mute: show ? 'show' : 'hide' });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public async setSpeakerPhoneIcon(show: boolean): Promise<void> {
|
|
149
|
-
await this.broadcast('status', { speakerphone: show ? 'show' : 'hide' });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public async setNotificationsVisibility(show: boolean): Promise<void> {
|
|
153
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3131
|
|
154
|
-
await this.broadcast('notifications', { visible: show.toString() });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public async setTime(hour: number, minute: number): Promise<void> {
|
|
158
|
-
await this.broadcast('clock', { hhmm: `${hour.toString().padStart(2, '0')}${minute.toString().padStart(2, '0')}` });
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Adb } from '../../adb';
|
|
2
|
-
import { AdbFeatures } from '../../features';
|
|
3
|
-
import { AdbLegacyShell } from './legacy';
|
|
4
|
-
import { AdbShellProtocol } from './protocol';
|
|
5
|
-
import { AdbShell } from './types';
|
|
6
|
-
|
|
7
|
-
export * from './legacy';
|
|
8
|
-
export * from './protocol';
|
|
9
|
-
export * from './types';
|
|
10
|
-
export * from './utils';
|
|
11
|
-
|
|
12
|
-
export type AdbShellProtocolOption = 'auto' | 'enable' | 'disable';
|
|
13
|
-
|
|
14
|
-
export interface AdbChildProcessOptions {
|
|
15
|
-
shellProtocol: 'auto' | 'enable' | 'disable',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const DefaultOptions: AdbChildProcessOptions = {
|
|
19
|
-
shellProtocol: 'auto',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export class AdbChildProcess {
|
|
23
|
-
public readonly adb: Adb;
|
|
24
|
-
|
|
25
|
-
public get supportsShellProtocol(): boolean {
|
|
26
|
-
return this.adb.features!.includes(AdbFeatures.ShellV2);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public constructor(adb: Adb) {
|
|
30
|
-
this.adb = adb;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private async createShell(command: string, options?: Partial<AdbChildProcessOptions>): Promise<AdbShell> {
|
|
34
|
-
let { shellProtocol } = { ...DefaultOptions, ...options };
|
|
35
|
-
switch (shellProtocol) {
|
|
36
|
-
case 'auto':
|
|
37
|
-
shellProtocol = this.supportsShellProtocol ? 'enable' : 'disable';
|
|
38
|
-
break;
|
|
39
|
-
case 'enable':
|
|
40
|
-
if (!shellProtocol) {
|
|
41
|
-
throw new Error('`shellProtocol` has been set to `enable` but the device does not support it');
|
|
42
|
-
}
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (shellProtocol === 'enable') {
|
|
47
|
-
return new AdbShellProtocol(await this.adb.createSocket(`shell,v2,pty:${command}`));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return new AdbLegacyShell(await this.adb.createSocket(`shell:${command}`));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public shell(options?: Partial<AdbChildProcessOptions>): Promise<AdbShell> {
|
|
54
|
-
return this.createShell('', options);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public spawn(command: string | string[], options?: Partial<AdbChildProcessOptions>): Promise<AdbShell> {
|
|
58
|
-
if (Array.isArray(command)) {
|
|
59
|
-
command = command.join(' ');
|
|
60
|
-
}
|
|
61
|
-
return this.createShell(command, options);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public exec(command: string, ...args: string[]): Promise<string> {
|
|
65
|
-
// `exec` only need all output, using Shell Protocol only makes it more complicate.
|
|
66
|
-
return this.adb.createSocketAndReadAll(`shell:${command} ${args.join(' ')}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "@yume-chan/event";
|
|
2
|
-
import { AdbSocket } from "../../socket";
|
|
3
|
-
import { AdbShell } from "./types";
|
|
4
|
-
|
|
5
|
-
export class AdbLegacyShell implements AdbShell {
|
|
6
|
-
private readonly socket: AdbSocket;
|
|
7
|
-
|
|
8
|
-
private readonly stdoutEvent = new EventEmitter<ArrayBuffer>();
|
|
9
|
-
public get onStdout() { return this.stdoutEvent.event; }
|
|
10
|
-
|
|
11
|
-
private readonly stderrEvent = new EventEmitter<ArrayBuffer>();
|
|
12
|
-
public get onStderr() { return this.stderrEvent.event; }
|
|
13
|
-
|
|
14
|
-
private readonly exitEvent = new EventEmitter<number>();
|
|
15
|
-
public get onExit() { return this.exitEvent.event; }
|
|
16
|
-
|
|
17
|
-
public constructor(socket: AdbSocket) {
|
|
18
|
-
this.socket = socket;
|
|
19
|
-
this.socket.onData(this.handleData, this);
|
|
20
|
-
this.socket.onClose(this.handleExit, this);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private handleData(data: ArrayBuffer) {
|
|
24
|
-
this.stdoutEvent.fire(data);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private handleExit() {
|
|
28
|
-
this.exitEvent.fire(0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public async write(data: ArrayBuffer) {
|
|
32
|
-
this.socket.write(data);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public resize() {
|
|
36
|
-
// Not supported
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public kill() {
|
|
40
|
-
return this.socket.close();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "@yume-chan/event";
|
|
2
|
-
import Struct, { placeholder } from "@yume-chan/struct";
|
|
3
|
-
import { AdbSocket } from "../../socket";
|
|
4
|
-
import { AdbBufferedStream } from "../../stream";
|
|
5
|
-
import { AdbShell } from "./types";
|
|
6
|
-
|
|
7
|
-
export enum AdbShellProtocolId {
|
|
8
|
-
Stdin,
|
|
9
|
-
Stdout,
|
|
10
|
-
Stderr,
|
|
11
|
-
Exit,
|
|
12
|
-
CloseStdin,
|
|
13
|
-
WindowSizeChange,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const AdbShellProtocolPacket = new Struct({ littleEndian: true })
|
|
17
|
-
.uint8('id', placeholder<AdbShellProtocolId>())
|
|
18
|
-
.uint32('length')
|
|
19
|
-
.arrayBuffer('data', { lengthField: 'length' });
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Shell v2 is also called Shell Protocol
|
|
23
|
-
*/
|
|
24
|
-
export class AdbShellProtocol implements AdbShell {
|
|
25
|
-
private readonly stream: AdbBufferedStream;
|
|
26
|
-
|
|
27
|
-
private readonly stdoutEvent = new EventEmitter<ArrayBuffer>();
|
|
28
|
-
public get onStdout() { return this.stdoutEvent.event; }
|
|
29
|
-
|
|
30
|
-
private readonly stderrEvent = new EventEmitter<ArrayBuffer>();
|
|
31
|
-
public get onStderr() { return this.stderrEvent.event; }
|
|
32
|
-
|
|
33
|
-
private readonly exitEvent = new EventEmitter<number>();
|
|
34
|
-
public get onExit() { return this.exitEvent.event; }
|
|
35
|
-
|
|
36
|
-
public constructor(socket: AdbSocket) {
|
|
37
|
-
this.stream = new AdbBufferedStream(socket);
|
|
38
|
-
this.readData();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private async readData() {
|
|
42
|
-
while (true) {
|
|
43
|
-
try {
|
|
44
|
-
const packet = await AdbShellProtocolPacket.deserialize(this.stream);
|
|
45
|
-
switch (packet.id) {
|
|
46
|
-
case AdbShellProtocolId.Stdout:
|
|
47
|
-
this.stdoutEvent.fire(packet.data);
|
|
48
|
-
break;
|
|
49
|
-
case AdbShellProtocolId.Stderr:
|
|
50
|
-
this.stderrEvent.fire(packet.data);
|
|
51
|
-
break;
|
|
52
|
-
case AdbShellProtocolId.Exit:
|
|
53
|
-
this.exitEvent.fire(new Uint8Array(packet.data)[0]);
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
} catch {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public async write(data: ArrayBuffer) {
|
|
63
|
-
this.stream.write(
|
|
64
|
-
AdbShellProtocolPacket.serialize(
|
|
65
|
-
{
|
|
66
|
-
id: AdbShellProtocolId.Stdin,
|
|
67
|
-
data,
|
|
68
|
-
},
|
|
69
|
-
this.stream
|
|
70
|
-
)
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public async resize(rows: number, cols: number) {
|
|
75
|
-
this.stream.write(
|
|
76
|
-
AdbShellProtocolPacket.serialize(
|
|
77
|
-
{
|
|
78
|
-
id: AdbShellProtocolId.WindowSizeChange,
|
|
79
|
-
data: this.stream.encodeUtf8(
|
|
80
|
-
// Correct format is ${rows}x${cols},${x_pixels}x${y_pixels}
|
|
81
|
-
// But from https://linux.die.net/man/4/tty_ioctl
|
|
82
|
-
// x_pixels and y_pixels are unused
|
|
83
|
-
`${rows}x${cols},${0}x${0}\0`
|
|
84
|
-
),
|
|
85
|
-
},
|
|
86
|
-
this.stream
|
|
87
|
-
)
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public kill() {
|
|
92
|
-
return this.stream.close();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Event } from "@yume-chan/event";
|
|
2
|
-
import { ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
-
import { AdbSocket } from "../../socket";
|
|
4
|
-
|
|
5
|
-
export interface AdbShell {
|
|
6
|
-
readonly onStdout: Event<ArrayBuffer>;
|
|
7
|
-
|
|
8
|
-
readonly onStderr: Event<ArrayBuffer>;
|
|
9
|
-
|
|
10
|
-
readonly onExit: Event<number>;
|
|
11
|
-
|
|
12
|
-
write(data: ArrayBuffer): Promise<void>;
|
|
13
|
-
|
|
14
|
-
resize(rows: number, cols: number): ValueOrPromise<void>;
|
|
15
|
-
|
|
16
|
-
kill(): ValueOrPromise<void>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface AdbShellConstructor {
|
|
20
|
-
new(socket: AdbSocket): AdbShell;
|
|
21
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { EventEmitter, EventListenerInfo, RemoveEventListener } from '@yume-chan/event';
|
|
2
|
-
|
|
3
|
-
const NoopRemoveEventListener: RemoveEventListener = () => { };
|
|
4
|
-
NoopRemoveEventListener.dispose = NoopRemoveEventListener;
|
|
5
|
-
|
|
6
|
-
export class CloseEventEmitter extends EventEmitter<void, void>{
|
|
7
|
-
private closed = false;
|
|
8
|
-
|
|
9
|
-
protected addEventListener(info: EventListenerInfo<void, void>) {
|
|
10
|
-
if (this.closed) {
|
|
11
|
-
info.listener.apply(info.thisArg, [undefined, ...info.args]);
|
|
12
|
-
return NoopRemoveEventListener;
|
|
13
|
-
} else {
|
|
14
|
-
return super.addEventListener(info);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public fire() {
|
|
19
|
-
super.fire();
|
|
20
|
-
this.closed = true;
|
|
21
|
-
this.listeners.length = 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public dispose() {
|
|
25
|
-
this.fire();
|
|
26
|
-
super.dispose();
|
|
27
|
-
}
|
|
28
|
-
}
|