@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 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAEA,oBAAY,WAAW;IACnB,OAAO,aAAa;IACpB,GAAG,QAAQ;IACX,MAAM,YAAY;IAClB,MAAM,UAAU;IAChB,cAAc,qBAAqB;CACtC"}
|
package/esm/features.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// The order follows
|
|
2
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
|
|
1
3
|
export var AdbFeatures;
|
|
2
4
|
(function (AdbFeatures) {
|
|
3
|
-
AdbFeatures["StatV2"] = "stat_v2";
|
|
4
|
-
AdbFeatures["Cmd"] = "cmd";
|
|
5
5
|
AdbFeatures["ShellV2"] = "shell_v2";
|
|
6
|
-
|
|
6
|
+
AdbFeatures["Cmd"] = "cmd";
|
|
7
|
+
AdbFeatures["StatV2"] = "stat_v2";
|
|
8
|
+
AdbFeatures["ListV2"] = "ls_v2";
|
|
9
|
+
AdbFeatures["FixedPushMkdir"] = "fixed_push_mkdir";
|
|
10
|
+
})(AdbFeatures = AdbFeatures || (AdbFeatures = {}));
|
|
7
11
|
//# sourceMappingURL=features.js.map
|
package/esm/features.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+HAA+H;AAC/H,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACnB,mCAAoB,CAAA;IACpB,0BAAW,CAAA;IACX,iCAAkB,CAAA;IAClB,+BAAgB,CAAA;IAChB,kDAAmC,CAAA;AACvC,CAAC,EANW,WAAW,GAAX,WAAW,KAAX,WAAW,QAMtB"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './adb.js';
|
|
2
|
+
export * from './auth.js';
|
|
3
|
+
export * from './backend.js';
|
|
4
|
+
export * from './commands/index.js';
|
|
5
|
+
export * from './crypto.js';
|
|
6
|
+
export * from './features.js';
|
|
7
|
+
export * from './packet.js';
|
|
8
|
+
export * from './socket/index.js';
|
|
9
|
+
export * from './stream/index.js';
|
|
10
|
+
export * from './utils/index.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './adb';
|
|
2
|
-
export * from './auth';
|
|
3
|
-
export * from './backend';
|
|
4
|
-
export * from './commands';
|
|
5
|
-
export * from './crypto';
|
|
6
|
-
export * from './features';
|
|
7
|
-
export * from './packet';
|
|
8
|
-
export * from './socket';
|
|
9
|
-
export * from './stream';
|
|
10
|
-
export * from './utils';
|
|
1
|
+
export * from './adb.js';
|
|
2
|
+
export * from './auth.js';
|
|
3
|
+
export * from './backend.js';
|
|
4
|
+
export * from './commands/index.js';
|
|
5
|
+
export * from './crypto.js';
|
|
6
|
+
export * from './features.js';
|
|
7
|
+
export * from './packet.js';
|
|
8
|
+
export * from './socket/index.js';
|
|
9
|
+
export * from './stream/index.js';
|
|
10
|
+
export * from './utils/index.js';
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/esm/packet.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
import { TransformStream } from "./stream/index.js";
|
|
3
|
+
export declare enum AdbCommand {
|
|
4
|
+
Auth = 1213486401,
|
|
5
|
+
Close = 1163086915,
|
|
6
|
+
Connect = 1314410051,
|
|
7
|
+
OK = 1497451343,
|
|
8
|
+
Open = 1313165391,
|
|
9
|
+
Write = 1163154007
|
|
10
|
+
}
|
|
11
|
+
export declare const AdbPacketHeader: Struct<{
|
|
12
|
+
command: number;
|
|
13
|
+
arg0: number;
|
|
14
|
+
arg1: number;
|
|
15
|
+
payloadLength: number;
|
|
16
|
+
checksum: number;
|
|
17
|
+
magic: number;
|
|
18
|
+
}, never, {}, undefined>;
|
|
19
|
+
export declare type AdbPacketHeader = typeof AdbPacketHeader['TDeserializeResult'];
|
|
20
|
+
export declare const AdbPacket: Struct<{
|
|
21
|
+
command: number;
|
|
22
|
+
arg0: number;
|
|
23
|
+
arg1: number;
|
|
24
|
+
payloadLength: number;
|
|
25
|
+
checksum: number;
|
|
26
|
+
magic: number;
|
|
27
|
+
payload: Uint8Array;
|
|
28
|
+
}, "payloadLength", {}, undefined>;
|
|
29
|
+
export declare type AdbPacket = typeof AdbPacket['TDeserializeResult'];
|
|
30
|
+
/**
|
|
31
|
+
* `AdbPacketData` contains all the useful fields of `AdbPacket`.
|
|
32
|
+
*
|
|
33
|
+
* `AdbBackend#connect` will return a `ReadableStream<AdbPacketData>`,
|
|
34
|
+
* so each backend can encode `AdbPacket` in different ways.
|
|
35
|
+
*
|
|
36
|
+
* `AdbBackend#connect` will return a `WritableStream<AdbPacketInit>`,
|
|
37
|
+
* however, `AdbPacketDispatcher` will transform `AdbPacketData` to `AdbPacketInit` for you,
|
|
38
|
+
* so `AdbSocket#writable#write` only needs `AdbPacketData`.
|
|
39
|
+
*/
|
|
40
|
+
export declare type AdbPacketData = Omit<typeof AdbPacket['TInit'], 'checksum' | 'magic'>;
|
|
41
|
+
export declare type AdbPacketInit = Omit<typeof AdbPacket['TInit'], 'magic'>;
|
|
42
|
+
export declare function calculateChecksum(payload: Uint8Array): number;
|
|
43
|
+
export declare function calculateChecksum(init: AdbPacketData): AdbPacketInit;
|
|
44
|
+
export declare class AdbPacketSerializeStream extends TransformStream<AdbPacketInit, Uint8Array> {
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=packet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packet.d.ts","sourceRoot":"","sources":["../src/packet.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,oBAAY,UAAU;IAClB,IAAI,aAAa;IACjB,KAAK,aAAa;IAClB,OAAO,aAAa;IACpB,EAAE,aAAa;IACf,IAAI,aAAa;IACjB,KAAK,aAAa;CACrB;AAED,eAAO,MAAM,eAAe;;;;;;;wBAOL,CAAC;AAExB,oBAAY,eAAe,GAAG,OAAO,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAI3E,eAAO,MAAM,SAAS;;;;;;;;kCAG0C,CAAC;AAEjE,oBAAY,SAAS,GAAG,OAAO,SAAS,CAAC,oBAAoB,CAAC,CAAC;AAE/D;;;;;;;;;GASG;AACH,oBAAY,aAAa,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC;AAGlF,oBAAY,aAAa,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAErE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC;AAC/D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAAC;AAUtE,qBAAa,wBAAyB,SAAQ,eAAe,CAAC,aAAa,EAAE,UAAU,CAAC;;CAqBvF"}
|
package/esm/packet.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
1
|
import Struct from '@yume-chan/struct';
|
|
3
|
-
import {
|
|
2
|
+
import { TransformStream } from "./stream/index.js";
|
|
4
3
|
export var AdbCommand;
|
|
5
4
|
(function (AdbCommand) {
|
|
6
5
|
AdbCommand[AdbCommand["Auth"] = 1213486401] = "Auth";
|
|
@@ -9,64 +8,40 @@ export var AdbCommand;
|
|
|
9
8
|
AdbCommand[AdbCommand["OK"] = 1497451343] = "OK";
|
|
10
9
|
AdbCommand[AdbCommand["Open"] = 1313165391] = "Open";
|
|
11
10
|
AdbCommand[AdbCommand["Write"] = 1163154007] = "Write";
|
|
12
|
-
})(AdbCommand || (AdbCommand = {}));
|
|
13
|
-
const AdbPacketHeader = new Struct({ littleEndian: true })
|
|
11
|
+
})(AdbCommand = AdbCommand || (AdbCommand = {}));
|
|
12
|
+
export const AdbPacketHeader = new Struct({ littleEndian: true })
|
|
14
13
|
.uint32('command')
|
|
15
14
|
.uint32('arg0')
|
|
16
15
|
.uint32('arg1')
|
|
17
16
|
.uint32('payloadLength')
|
|
18
17
|
.uint32('checksum')
|
|
19
18
|
.int32('magic');
|
|
20
|
-
const
|
|
19
|
+
export const AdbPacket = new Struct({ littleEndian: true })
|
|
21
20
|
.fields(AdbPacketHeader)
|
|
22
|
-
.
|
|
23
|
-
export
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
// Detect boundary
|
|
28
|
-
// Note that it relies on the backend to only return data from one write operation
|
|
29
|
-
let buffer;
|
|
30
|
-
do {
|
|
31
|
-
// Maybe it's a payload from last connection.
|
|
32
|
-
// Ignore and try again
|
|
33
|
-
buffer = yield backend.read(24);
|
|
34
|
-
} while (buffer.byteLength !== 24);
|
|
35
|
-
let bufferUsed = false;
|
|
36
|
-
const stream = new BufferedStream({
|
|
37
|
-
read(length) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (!bufferUsed) {
|
|
40
|
-
bufferUsed = true;
|
|
41
|
-
return buffer;
|
|
42
|
-
}
|
|
43
|
-
return backend.read(length);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return AdbPacketStruct.deserialize(stream);
|
|
48
|
-
});
|
|
21
|
+
.uint8Array('payload', { lengthField: 'payloadLength' });
|
|
22
|
+
export function calculateChecksum(payload) {
|
|
23
|
+
if (payload instanceof Uint8Array) {
|
|
24
|
+
return payload.reduce((result, item) => result + item, 0);
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
26
|
+
else {
|
|
27
|
+
payload.checksum = calculateChecksum(payload.payload);
|
|
28
|
+
return payload;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class AdbPacketSerializeStream extends TransformStream {
|
|
32
|
+
constructor() {
|
|
33
|
+
super({
|
|
34
|
+
transform: async (init, controller) => {
|
|
35
|
+
// This syntax is ugly, but I don't want to create a new object.
|
|
36
|
+
init.magic = init.command ^ 0xFFFFFFFF;
|
|
37
|
+
init.payloadLength = init.payload.byteLength;
|
|
38
|
+
controller.enqueue(AdbPacketHeader.serialize(init));
|
|
39
|
+
if (init.payload.byteLength) {
|
|
40
|
+
// Enqueue payload separately to avoid copying
|
|
41
|
+
controller.enqueue(init.payload);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
68
44
|
});
|
|
69
45
|
}
|
|
70
|
-
|
|
71
|
-
})(AdbPacket || (AdbPacket = {}));
|
|
46
|
+
}
|
|
72
47
|
//# sourceMappingURL=packet.js.map
|
package/esm/packet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packet.js","sourceRoot":"","sources":["../src/packet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"packet.js","sourceRoot":"","sources":["../src/packet.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IAClB,oDAAiB,CAAA;IACjB,sDAAkB,CAAA;IAClB,0DAAoB,CAAA;IACpB,gDAAe,CAAA;IACf,oDAAiB,CAAA;IACjB,sDAAkB,CAAA;AACtB,CAAC,EAPW,UAAU,GAAV,UAAU,KAAV,UAAU,QAOrB;AAED,MAAM,CAAC,MAAM,eAAe,GACxB,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAC7B,MAAM,CAAC,SAAS,CAAC;KACjB,MAAM,CAAC,MAAM,CAAC;KACd,MAAM,CAAC,MAAM,CAAC;KACd,MAAM,CAAC,eAAe,CAAC;KACvB,MAAM,CAAC,UAAU,CAAC;KAClB,KAAK,CAAC,OAAO,CAAC,CAAC;AAMxB,MAAM,CAAC,MAAM,SAAS,GAClB,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAC7B,MAAM,CAAC,eAAe,CAAC;KACvB,UAAU,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;AAqBjE,MAAM,UAAU,iBAAiB,CAAC,OAAmC;IACjE,IAAI,OAAO,YAAY,UAAU,EAAE;QAC/B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;KAC7D;SAAM;QACF,OAAyB,CAAC,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzE,OAAO,OAAwB,CAAC;KACnC;AACL,CAAC;AAED,MAAM,OAAO,wBAAyB,SAAQ,eAA0C;IACpF;QACI,KAAK,CAAC;YACF,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE;gBAClC,gEAAgE;gBAC/D,IAAuC,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;gBAC1E,IAAuC,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;gBAEjF,UAAU,CAAC,OAAO,CACd,eAAe,CAAC,SAAS,CACrB,IAAsC,CACzC,CACJ,CAAC;gBAEF,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;oBACzB,8CAA8C;oBAC9C,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACpC;YACL,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReadableStream, WritableStream } from '../stream';
|
|
2
|
+
import { AdbPacketDispatcher } from './dispatcher';
|
|
3
|
+
export interface AdbSocketInfo {
|
|
4
|
+
localId: number;
|
|
5
|
+
remoteId: number;
|
|
6
|
+
localCreated: boolean;
|
|
7
|
+
serviceString: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AdbSocketConstructionOptions {
|
|
10
|
+
dispatcher: AdbPacketDispatcher;
|
|
11
|
+
localId: number;
|
|
12
|
+
remoteId: number;
|
|
13
|
+
localCreated: boolean;
|
|
14
|
+
serviceString: string;
|
|
15
|
+
highWaterMark?: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare class AdbSocketController implements AdbSocketInfo {
|
|
18
|
+
private readonly dispatcher;
|
|
19
|
+
readonly localId: number;
|
|
20
|
+
readonly remoteId: number;
|
|
21
|
+
readonly localCreated: boolean;
|
|
22
|
+
readonly serviceString: string;
|
|
23
|
+
private _factory;
|
|
24
|
+
private _readable;
|
|
25
|
+
private _readableController;
|
|
26
|
+
get readable(): ReadableStream<Uint8Array>;
|
|
27
|
+
private _writePromise;
|
|
28
|
+
readonly writable: WritableStream<Uint8Array>;
|
|
29
|
+
private _closed;
|
|
30
|
+
get closed(): boolean;
|
|
31
|
+
constructor(options: AdbSocketConstructionOptions);
|
|
32
|
+
enqueue(packet: Uint8Array): Promise<void>;
|
|
33
|
+
ack(): void;
|
|
34
|
+
close(): Promise<void>;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/socket/controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4E,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACrI,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,EAAE,OAAO,CAAC;IAEtB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IACzC,UAAU,EAAE,mBAAmB,CAAC;IAEhC,OAAO,EAAE,MAAM,CAAC;IAEhB,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,EAAE,OAAO,CAAC;IAEtB,aAAa,EAAE,MAAM,CAAC;IAEtB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,qBAAa,mBAAoB,YAAW,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAElD,SAAgB,OAAO,EAAG,MAAM,CAAC;IACjC,SAAgB,QAAQ,EAAG,MAAM,CAAC;IAClC,SAAgB,YAAY,EAAG,OAAO,CAAC;IACvC,SAAgB,aAAa,EAAG,MAAM,CAAC;IAEvC,OAAO,CAAC,QAAQ,CAA8C;IAE9D,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,mBAAmB,CAA4C;IACvE,IAAW,QAAQ,+BAA6B;IAEhD,OAAO,CAAC,aAAa,CAAoC;IACzD,SAAgB,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAErD,OAAO,CAAC,OAAO,CAAS;IACxB,IAAW,MAAM,YAA2B;gBAEzB,OAAO,EAAE,4BAA4B;IAsC3C,OAAO,CAAC,MAAM,EAAE,UAAU;IAIhC,GAAG;IAIG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB5B,OAAO;CAQjB"}
|
package/esm/socket/controller.js
CHANGED
|
@@ -1,80 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AutoDisposable } from '@yume-chan/event';
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
3
2
|
import { AdbCommand } from '../packet';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { ChunkStream, DuplexStreamFactory, pipeFrom } from '../stream';
|
|
4
|
+
export class AdbSocketController {
|
|
5
|
+
dispatcher;
|
|
6
|
+
localId;
|
|
7
|
+
remoteId;
|
|
8
|
+
localCreated;
|
|
9
|
+
serviceString;
|
|
10
|
+
_factory;
|
|
11
|
+
_readable;
|
|
12
|
+
_readableController;
|
|
13
|
+
get readable() { return this._readable; }
|
|
14
|
+
_writePromise;
|
|
15
|
+
writable;
|
|
16
|
+
_closed = false;
|
|
17
|
+
get closed() { return this._closed; }
|
|
8
18
|
constructor(options) {
|
|
9
|
-
super();
|
|
10
|
-
this.writeChunkLock = this.addDisposable(new AutoResetEvent());
|
|
11
|
-
this.writeLock = this.addDisposable(new AutoResetEvent());
|
|
12
|
-
this.dataEvent = this.addDisposable(new DataEventEmitter());
|
|
13
|
-
this._closed = false;
|
|
14
|
-
this.closeEvent = this.addDisposable(new CloseEventEmitter());
|
|
15
19
|
Object.assign(this, options);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Wait for an ack packet
|
|
24
|
-
yield this.writeChunkLock.wait();
|
|
25
|
-
}
|
|
26
|
-
catch (_a) {
|
|
27
|
-
// Lock has been disposed, which means the socket has been closed
|
|
28
|
-
throw new Error('Can not write after closed');
|
|
29
|
-
}
|
|
30
|
-
yield this.dispatcher.sendPacket(AdbCommand.Write, this.localId, this.remoteId, data);
|
|
20
|
+
// Check this image to help you understand the stream graph
|
|
21
|
+
// cspell: disable-next-line
|
|
22
|
+
// https://www.plantuml.com/plantuml/png/TL0zoeGm4ErpYc3l5JxyS0yWM6mX5j4C6p4cxcJ25ejttuGX88ZftizxUKmJI275pGhXl0PP_UkfK_CAz5Z2hcWsW9Ny2fdU4C1f5aSchFVxA8vJjlTPRhqZzDQMRB7AklwJ0xXtX0ZSKH1h24ghoKAdGY23FhxC4nS2pDvxzIvxb-8THU0XlEQJ-ZB7SnXTAvc_LhOckhMdLBnbtndpb-SB7a8q2SRD_W00
|
|
23
|
+
this._factory = new DuplexStreamFactory({
|
|
24
|
+
close: async () => {
|
|
25
|
+
await this.close();
|
|
26
|
+
},
|
|
31
27
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Keep write operations in order
|
|
38
|
-
yield this.writeLock.wait();
|
|
39
|
-
}
|
|
40
|
-
catch (_b) {
|
|
41
|
-
// Lock has been disposed, which means the socket has been closed
|
|
42
|
-
throw new Error('Can not write after closed');
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
for (var _c = __asyncValues(chunkArrayLike(data, this.dispatcher.maxPayloadSize)), _d; _d = yield _c.next(), !_d.done;) {
|
|
46
|
-
const chunk = _d.value;
|
|
47
|
-
yield this.writeChunk(chunk);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
51
|
-
finally {
|
|
52
|
-
try {
|
|
53
|
-
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
|
|
54
|
-
}
|
|
55
|
-
finally { if (e_1) throw e_1.error; }
|
|
56
|
-
}
|
|
57
|
-
this.writeLock.notify();
|
|
28
|
+
this._readable = this._factory.createPushReadable(controller => {
|
|
29
|
+
this._readableController = controller;
|
|
30
|
+
}, {
|
|
31
|
+
highWaterMark: options.highWaterMark ?? 16 * 1024,
|
|
32
|
+
size(chunk) { return chunk.byteLength; }
|
|
58
33
|
});
|
|
34
|
+
this.writable = pipeFrom(this._factory.createWritable({
|
|
35
|
+
write: async (chunk) => {
|
|
36
|
+
// Wait for an ack packet
|
|
37
|
+
this._writePromise = new PromiseResolver();
|
|
38
|
+
await this.dispatcher.sendPacket(AdbCommand.Write, this.localId, this.remoteId, chunk);
|
|
39
|
+
await this._writePromise.promise;
|
|
40
|
+
},
|
|
41
|
+
}), new ChunkStream(this.dispatcher.maxPayloadSize));
|
|
42
|
+
}
|
|
43
|
+
async enqueue(packet) {
|
|
44
|
+
await this._readableController.enqueue(packet);
|
|
59
45
|
}
|
|
60
46
|
ack() {
|
|
61
|
-
this.
|
|
47
|
+
this._writePromise?.resolve();
|
|
62
48
|
}
|
|
63
|
-
close() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
49
|
+
async close() {
|
|
50
|
+
// Error out the pending writes
|
|
51
|
+
this._writePromise?.reject(new Error('Socket closed'));
|
|
52
|
+
if (!this._closed) {
|
|
53
|
+
this._closed = true;
|
|
54
|
+
// Only send close packet when `close` is called before `dispose`
|
|
55
|
+
// (the client initiated the close)
|
|
56
|
+
await this.dispatcher.sendPacket(AdbCommand.Close, this.localId, this.remoteId);
|
|
57
|
+
}
|
|
73
58
|
}
|
|
74
59
|
dispose() {
|
|
75
60
|
this._closed = true;
|
|
76
|
-
this.
|
|
77
|
-
|
|
61
|
+
this._factory.close();
|
|
62
|
+
// Close `writable` side
|
|
63
|
+
this.close();
|
|
78
64
|
}
|
|
79
65
|
}
|
|
80
66
|
//# sourceMappingURL=controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/socket/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/socket/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAgE,MAAM,WAAW,CAAC;AA0BrI,MAAM,OAAO,mBAAmB;IACX,UAAU,CAAuB;IAElC,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,YAAY,CAAW;IACvB,aAAa,CAAU;IAE/B,QAAQ,CAA8C;IAEtD,SAAS,CAA6B;IACtC,mBAAmB,CAA4C;IACvE,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC,aAAa,CAAoC;IACzC,QAAQ,CAA6B;IAE7C,OAAO,GAAG,KAAK,CAAC;IACxB,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5C,YAAmB,OAAqC;QACpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7B,2DAA2D;QAC3D,4BAA4B;QAC5B,6QAA6Q;QAE7Q,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAmB,CAAyB;YAC5D,KAAK,EAAE,KAAK,IAAI,EAAE;gBACd,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE;YAC3D,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC;QAC1C,CAAC,EAAE;YACC,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,EAAE,GAAG,IAAI;YACjD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;SAC3C,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CACpB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;YACzB,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;gBACnB,yBAAyB;gBACzB,IAAI,CAAC,aAAa,GAAG,IAAI,eAAe,EAAE,CAAC;gBAC3C,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAC5B,UAAU,CAAC,KAAK,EAChB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,QAAQ,EACb,KAAK,CACR,CAAC;gBACF,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YACrC,CAAC;SACJ,CAAC,EACF,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAClD,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,MAAkB;QACnC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAEM,GAAG;QACN,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,+BAA+B;QAC/B,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;QAEvD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YAEpB,iEAAiE;YACjE,mCAAmC;YACnC,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAC5B,UAAU,CAAC,KAAK,EAChB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,QAAQ,CAChB,CAAC;SACL;IACL,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEtB,wBAAwB;QACxB,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AutoDisposable } from '@yume-chan/event';
|
|
2
|
+
import { AdbCommand, type AdbPacketData, type AdbPacketInit } from '../packet.js';
|
|
3
|
+
import { type ReadableWritablePair } from '../stream/index.js';
|
|
4
|
+
import { AdbSocket } from './socket.js';
|
|
5
|
+
export interface AdbIncomingSocketEventArgs {
|
|
6
|
+
handled: boolean;
|
|
7
|
+
packet: AdbPacketData;
|
|
8
|
+
serviceString: string;
|
|
9
|
+
socket: AdbSocket;
|
|
10
|
+
}
|
|
11
|
+
export interface AdbPacketDispatcherOptions {
|
|
12
|
+
calculateChecksum: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Before Android 9.0, ADB uses `char*` to parse service string,
|
|
15
|
+
* thus requires a null character to terminate.
|
|
16
|
+
*
|
|
17
|
+
* Usually it should have the same value as `calculateChecksum`.
|
|
18
|
+
*/
|
|
19
|
+
appendNullToServiceString: boolean;
|
|
20
|
+
maxPayloadSize: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class AdbPacketDispatcher extends AutoDisposable {
|
|
23
|
+
private readonly initializers;
|
|
24
|
+
private readonly sockets;
|
|
25
|
+
private _writer;
|
|
26
|
+
readonly options: AdbPacketDispatcherOptions;
|
|
27
|
+
private _disconnected;
|
|
28
|
+
get disconnected(): Promise<void>;
|
|
29
|
+
private readonly incomingSocketEvent;
|
|
30
|
+
get onIncomingSocket(): {
|
|
31
|
+
(listener: import("@yume-chan/event").EventListener<AdbIncomingSocketEventArgs, unknown, [], unknown>): import("@yume-chan/event").RemoveEventListener;
|
|
32
|
+
<TThis, TArgs extends unknown[]>(listener: import("@yume-chan/event").EventListener<AdbIncomingSocketEventArgs, TThis, TArgs, unknown>, thisArg: TThis, ...args: TArgs): import("@yume-chan/event").RemoveEventListener;
|
|
33
|
+
};
|
|
34
|
+
private _abortController;
|
|
35
|
+
constructor(connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>, options: AdbPacketDispatcherOptions);
|
|
36
|
+
private handleOk;
|
|
37
|
+
private handleClose;
|
|
38
|
+
private handleOpen;
|
|
39
|
+
createSocket(serviceString: string): Promise<AdbSocket>;
|
|
40
|
+
sendPacket(packet: AdbPacketInit): Promise<void>;
|
|
41
|
+
sendPacket(command: AdbCommand, arg0: number, arg1: number, payload?: string | Uint8Array): Promise<void>;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/socket/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAqB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAgE,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE7H,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAE7D,MAAM,WAAW,0BAA0B;IACvC,OAAO,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,aAAa,CAAC;IAEtB,aAAa,EAAE,MAAM,CAAC;IAEtB,MAAM,EAAE,SAAS,CAAC;CACrB;AAID,MAAM,WAAW,0BAA0B;IACvC,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,yBAAyB,EAAE,OAAO,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,mBAAoB,SAAQ,cAAc;IAGnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;IAElE,OAAO,CAAC,OAAO,CAA8C;IAE7D,SAAgB,OAAO,EAAE,0BAA0B,CAAC;IAEpD,OAAO,CAAC,aAAa,CAA+B;IACpD,IAAW,YAAY,kBAAyC;IAEhE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAsE;IAC1G,IAAW,gBAAgB;;;MAA6C;IAExE,OAAO,CAAC,gBAAgB,CAAyB;gBAG7C,UAAU,EAAE,oBAAoB,CAAC,aAAa,EAAE,aAAa,CAAC,EAC9D,OAAO,EAAE,0BAA0B;IAkDvC,OAAO,CAAC,QAAQ;YAkBF,WAAW;YA8BX,UAAU;IAiCX,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B7D,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAChD,UAAU,CACb,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,GAC9B,OAAO,CAAC,IAAI,CAAC;IAqCA,OAAO;CAiB1B"}
|