@yume-chan/adb 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +27 -0
- package/CHANGELOG.md +16 -1
- package/LICENSE +1 -1
- package/esm/adb.d.ts +63 -60
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +257 -229
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +51 -51
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +95 -96
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +8 -8
- package/esm/backend.d.ts.map +1 -1
- package/esm/backend.js +1 -1
- package/esm/commands/base.d.ts +6 -6
- package/esm/commands/base.js +8 -8
- package/esm/commands/framebuffer.d.ts +53 -53
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +46 -47
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +7 -8
- package/esm/commands/index.d.ts.map +1 -1
- package/esm/commands/index.js +7 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/install.d.ts +9 -3
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +27 -21
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +22 -22
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +48 -44
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +41 -28
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +125 -98
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +57 -51
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +86 -82
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +3 -3
- package/esm/commands/subprocess/index.js +3 -3
- package/esm/commands/subprocess/protocols/index.d.ts +3 -3
- package/esm/commands/subprocess/protocols/index.js +3 -3
- package/esm/commands/subprocess/protocols/none.d.ts +35 -35
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +65 -55
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +166 -154
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +49 -49
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/types.js +1 -1
- package/esm/commands/subprocess/utils.d.ts +1 -1
- package/esm/commands/subprocess/utils.js +18 -18
- package/esm/commands/sync/index.d.ts +8 -7
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +8 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +42 -40
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +67 -35
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +13 -11
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +35 -36
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +46 -7
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +89 -23
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +26 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +40 -42
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +19 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +54 -54
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +27 -0
- package/esm/commands/sync/socket.d.ts.map +1 -0
- package/esm/commands/sync/socket.js +66 -0
- package/esm/commands/sync/socket.js.map +1 -0
- package/esm/commands/sync/stat.d.ts +72 -72
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +116 -94
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +72 -60
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +127 -148
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +5 -5
- package/esm/commands/tcpip.js +18 -18
- package/esm/crypto.d.ts +36 -36
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +248 -238
- package/esm/crypto.js.map +1 -1
- package/esm/features.d.ts +10 -7
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +13 -10
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +9 -9
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -9
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +45 -46
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +43 -46
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +59 -59
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +223 -231
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +2 -2
- package/esm/socket/index.js +2 -2
- package/esm/socket/socket.d.ts +59 -59
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +118 -98
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/auto-reset-event.d.ts +9 -9
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +33 -33
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +27 -27
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +246 -245
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +9 -0
- package/esm/utils/conditional-variable.d.ts.map +1 -0
- package/esm/utils/conditional-variable.js +34 -0
- package/esm/utils/conditional-variable.js.map +1 -0
- package/esm/utils/index.d.ts +4 -3
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +4 -3
- package/esm/utils/index.js.map +1 -1
- package/package.json +17 -13
- package/src/adb.ts +160 -101
- package/src/auth.ts +31 -22
- package/src/backend.ts +6 -4
- package/src/commands/base.ts +2 -2
- package/src/commands/framebuffer.ts +37 -41
- package/src/commands/index.ts +7 -8
- package/src/commands/power.ts +15 -11
- package/src/commands/reverse.ts +74 -30
- package/src/commands/subprocess/command.ts +34 -23
- package/src/commands/subprocess/index.ts +3 -3
- package/src/commands/subprocess/protocols/index.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +26 -11
- package/src/commands/subprocess/protocols/shell.ts +110 -56
- package/src/commands/subprocess/protocols/types.ts +10 -6
- package/src/commands/subprocess/utils.ts +1 -1
- package/src/commands/sync/index.ts +8 -7
- package/src/commands/sync/list.ts +74 -28
- package/src/commands/sync/pull.ts +49 -37
- package/src/commands/sync/push.ts +153 -32
- package/src/commands/sync/request.ts +37 -34
- package/src/commands/sync/response.ts +34 -27
- package/src/commands/sync/socket.ts +97 -0
- package/src/commands/sync/stat.ts +98 -70
- package/src/commands/sync/sync.ts +78 -97
- package/src/commands/tcpip.ts +5 -5
- package/src/crypto.ts +60 -32
- package/src/features.ts +9 -6
- package/src/index.ts +9 -10
- package/src/packet.ts +41 -46
- package/src/socket/dispatcher.ts +130 -108
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +84 -34
- package/src/utils/auto-reset-event.ts +16 -17
- package/src/utils/base64.ts +51 -41
- package/src/utils/conditional-variable.ts +45 -0
- package/src/utils/index.ts +4 -3
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/commands/install.ts +0 -32
package/esm/packet.d.ts
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Struct from
|
|
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,
|
|
19
|
-
export
|
|
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",
|
|
29
|
-
export
|
|
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
|
|
41
|
-
export
|
|
42
|
-
export declare function calculateChecksum(payload: Uint8Array): number;
|
|
43
|
-
export declare
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
1
|
+
import { ConsumableTransformStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import Struct from "@yume-chan/struct";
|
|
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, Record<never, never>, undefined>;
|
|
19
|
+
export 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", Record<never, never>, undefined>;
|
|
29
|
+
export 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 type AdbPacketData = Omit<(typeof AdbPacket)["TInit"], "checksum" | "magic">;
|
|
41
|
+
export type AdbPacketInit = (typeof AdbPacket)["TInit"];
|
|
42
|
+
export declare function calculateChecksum(payload: Uint8Array): number;
|
|
43
|
+
export declare class AdbPacketSerializeStream extends ConsumableTransformStream<AdbPacketInit, Uint8Array> {
|
|
44
|
+
constructor();
|
|
45
|
+
}
|
|
47
46
|
//# sourceMappingURL=packet.d.ts.map
|
package/esm/packet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packet.d.ts","sourceRoot":"","sources":["../src/packet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"packet.d.ts","sourceRoot":"","sources":["../src/packet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,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;;;;;;;0CAMT,CAAC;AAEpB,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAI7E,eAAO,MAAM,SAAS;;;;;;;;oDAEsC,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAEjE;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAC5B,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,EAC3B,UAAU,GAAG,OAAO,CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC;AAExD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAE7D;AAED,qBAAa,wBAAyB,SAAQ,yBAAyB,CACnE,aAAa,EACb,UAAU,CACb;;CAoBA"}
|
package/esm/packet.js
CHANGED
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Struct from
|
|
3
|
-
export var AdbCommand;
|
|
4
|
-
(function (AdbCommand) {
|
|
5
|
-
AdbCommand[AdbCommand["Auth"] = 1213486401] = "Auth";
|
|
6
|
-
AdbCommand[AdbCommand["Close"] = 1163086915] = "Close";
|
|
7
|
-
AdbCommand[AdbCommand["Connect"] = 1314410051] = "Connect";
|
|
8
|
-
AdbCommand[AdbCommand["OK"] = 1497451343] = "OK";
|
|
9
|
-
AdbCommand[AdbCommand["Open"] = 1313165391] = "Open";
|
|
10
|
-
AdbCommand[AdbCommand["Write"] = 1163154007] = "Write";
|
|
11
|
-
})(AdbCommand = AdbCommand || (AdbCommand = {}));
|
|
12
|
-
export const AdbPacketHeader = new Struct({ littleEndian: true })
|
|
13
|
-
.uint32(
|
|
14
|
-
.uint32(
|
|
15
|
-
.uint32(
|
|
16
|
-
.uint32(
|
|
17
|
-
.uint32(
|
|
18
|
-
.int32(
|
|
19
|
-
export const AdbPacket = new Struct({ littleEndian: true })
|
|
20
|
-
.fields(AdbPacketHeader)
|
|
21
|
-
.uint8Array(
|
|
22
|
-
export function calculateChecksum(payload) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { ConsumableTransformStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import Struct from "@yume-chan/struct";
|
|
3
|
+
export var AdbCommand;
|
|
4
|
+
(function (AdbCommand) {
|
|
5
|
+
AdbCommand[AdbCommand["Auth"] = 1213486401] = "Auth";
|
|
6
|
+
AdbCommand[AdbCommand["Close"] = 1163086915] = "Close";
|
|
7
|
+
AdbCommand[AdbCommand["Connect"] = 1314410051] = "Connect";
|
|
8
|
+
AdbCommand[AdbCommand["OK"] = 1497451343] = "OK";
|
|
9
|
+
AdbCommand[AdbCommand["Open"] = 1313165391] = "Open";
|
|
10
|
+
AdbCommand[AdbCommand["Write"] = 1163154007] = "Write";
|
|
11
|
+
})(AdbCommand = AdbCommand || (AdbCommand = {}));
|
|
12
|
+
export const AdbPacketHeader = new Struct({ littleEndian: true })
|
|
13
|
+
.uint32("command")
|
|
14
|
+
.uint32("arg0")
|
|
15
|
+
.uint32("arg1")
|
|
16
|
+
.uint32("payloadLength")
|
|
17
|
+
.uint32("checksum")
|
|
18
|
+
.int32("magic");
|
|
19
|
+
export const AdbPacket = new Struct({ littleEndian: true })
|
|
20
|
+
.fields(AdbPacketHeader)
|
|
21
|
+
.uint8Array("payload", { lengthField: "payloadLength" });
|
|
22
|
+
export function calculateChecksum(payload) {
|
|
23
|
+
return payload.reduce((result, item) => result + item, 0);
|
|
24
|
+
}
|
|
25
|
+
export class AdbPacketSerializeStream extends ConsumableTransformStream {
|
|
26
|
+
constructor() {
|
|
27
|
+
const headerBuffer = new Uint8Array(AdbPacketHeader.size);
|
|
28
|
+
super({
|
|
29
|
+
transform: async (chunk, controller) => {
|
|
30
|
+
const init = chunk;
|
|
31
|
+
init.payloadLength = init.payload.byteLength;
|
|
32
|
+
AdbPacketHeader.serialize(init, headerBuffer);
|
|
33
|
+
await controller.enqueue(headerBuffer);
|
|
34
|
+
if (init.payload.byteLength) {
|
|
35
|
+
// USB protocol preserves packet boundaries,
|
|
36
|
+
// so we must write payload separately as native ADB does,
|
|
37
|
+
// otherwise the read operation on device will fail.
|
|
38
|
+
await controller.enqueue(init.payload);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
47
44
|
//# 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":"AAAA,OAAO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E;gBACnC,MAAM,IAAI,GAAG,KAA4C,CAAC;gBAC1D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;gBAE7C,eAAe,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;gBAC9C,MAAM,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBAEvC,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;oBACzB,4CAA4C;oBAC5C,0DAA0D;oBAC1D,oDAAoD;oBACpD,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBAC1C;YACL,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import type { RemoveEventListener } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
sendPacket(command: AdbCommand, arg0: number, arg1: number, payload?: string | Uint8Array): Promise<void>;
|
|
57
|
-
close(): Promise<void>;
|
|
58
|
-
private dispose;
|
|
59
|
-
}
|
|
1
|
+
import type { RemoveEventListener } from "@yume-chan/event";
|
|
2
|
+
import type { Consumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
3
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
4
|
+
import type { AdbPacketData, AdbPacketInit } from "../packet.js";
|
|
5
|
+
import { AdbCommand } from "../packet.js";
|
|
6
|
+
import type { AdbSocket } from "./socket.js";
|
|
7
|
+
export interface AdbPacketDispatcherOptions {
|
|
8
|
+
calculateChecksum: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Before Android 9.0, ADB uses `char*` to parse service string,
|
|
11
|
+
* thus requires a null character to terminate.
|
|
12
|
+
*
|
|
13
|
+
* Usually it should have the same value as `calculateChecksum`.
|
|
14
|
+
*/
|
|
15
|
+
appendNullToServiceString: boolean;
|
|
16
|
+
maxPayloadSize: number;
|
|
17
|
+
}
|
|
18
|
+
export type AdbIncomingSocketHandler = (socket: AdbSocket) => ValueOrPromise<boolean>;
|
|
19
|
+
export interface Closeable {
|
|
20
|
+
close(): ValueOrPromise<void>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The dispatcher is the "dumb" part of the connection handling logic.
|
|
24
|
+
*
|
|
25
|
+
* Except some options to change some minor behaviors,
|
|
26
|
+
* its only job is forwarding packets between authenticated underlying streams
|
|
27
|
+
* and abstracted socket objects.
|
|
28
|
+
*
|
|
29
|
+
* The `Adb` class is responsible for doing the authentication,
|
|
30
|
+
* negotiating the options, and has shortcuts to high-level services.
|
|
31
|
+
*/
|
|
32
|
+
export declare class AdbPacketDispatcher implements Closeable {
|
|
33
|
+
private readonly initializers;
|
|
34
|
+
/**
|
|
35
|
+
* Socket local ID to the socket controller.
|
|
36
|
+
*/
|
|
37
|
+
private readonly sockets;
|
|
38
|
+
private _writer;
|
|
39
|
+
readonly options: AdbPacketDispatcherOptions;
|
|
40
|
+
private _closed;
|
|
41
|
+
private _disconnected;
|
|
42
|
+
get disconnected(): Promise<void>;
|
|
43
|
+
private _incomingSocketHandlers;
|
|
44
|
+
private _abortController;
|
|
45
|
+
constructor(connection: ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>, options: AdbPacketDispatcherOptions);
|
|
46
|
+
private handleOk;
|
|
47
|
+
private handleClose;
|
|
48
|
+
/**
|
|
49
|
+
* Add a handler for incoming socket.
|
|
50
|
+
* @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
|
|
51
|
+
* @returns A function to remove the handler.
|
|
52
|
+
*/
|
|
53
|
+
onIncomingSocket(handler: AdbIncomingSocketHandler): RemoveEventListener;
|
|
54
|
+
private handleOpen;
|
|
55
|
+
createSocket(serviceString: string): Promise<AdbSocket>;
|
|
56
|
+
sendPacket(command: AdbCommand, arg0: number, arg1: number, payload?: string | Uint8Array): Promise<void>;
|
|
57
|
+
close(): Promise<void>;
|
|
58
|
+
private dispose;
|
|
59
|
+
}
|
|
60
60
|
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/socket/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/socket/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EACR,UAAU,EACV,oBAAoB,EAEvB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjE,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