@yume-chan/adb 1.0.0 → 2.0.0
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.md +26 -0
- package/LICENSE +1 -1
- package/esm/adb.d.ts +7 -6
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +22 -22
- package/esm/adb.js.map +1 -1
- package/esm/banner.js.map +1 -1
- package/esm/commands/base.d.ts +3 -2
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js +6 -3
- package/esm/commands/base.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +6 -6
- package/esm/commands/power.d.ts +2 -2
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +4 -4
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +3 -4
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +5 -10
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +3 -2
- package/esm/commands/subprocess/index.d.ts.map +1 -1
- package/esm/commands/subprocess/index.js +3 -2
- package/esm/commands/subprocess/index.js.map +1 -1
- package/esm/commands/subprocess/none/index.d.ts +5 -0
- package/esm/commands/subprocess/none/index.d.ts.map +1 -0
- package/esm/commands/subprocess/none/index.js +5 -0
- package/esm/commands/subprocess/none/index.js.map +1 -0
- package/esm/commands/subprocess/none/process.d.ts +13 -0
- package/esm/commands/subprocess/none/process.d.ts.map +1 -0
- package/esm/commands/subprocess/none/process.js +36 -0
- package/esm/commands/subprocess/none/process.js.map +1 -0
- package/esm/commands/subprocess/none/pty.d.ts +15 -0
- package/esm/commands/subprocess/none/pty.d.ts.map +1 -0
- package/esm/commands/subprocess/none/pty.js +29 -0
- package/esm/commands/subprocess/none/pty.js.map +1 -0
- package/esm/commands/subprocess/none/service.d.ts +10 -0
- package/esm/commands/subprocess/none/service.d.ts.map +1 -0
- package/esm/commands/subprocess/none/service.js +32 -0
- package/esm/commands/subprocess/none/service.js.map +1 -0
- package/esm/commands/subprocess/none/spawner.d.ts +19 -0
- package/esm/commands/subprocess/none/spawner.d.ts.map +1 -0
- package/esm/commands/subprocess/none/spawner.js +26 -0
- package/esm/commands/subprocess/none/spawner.js.map +1 -0
- package/esm/commands/subprocess/pty.d.ts +10 -0
- package/esm/commands/subprocess/pty.d.ts.map +1 -0
- package/esm/commands/subprocess/pty.js +2 -0
- package/esm/commands/subprocess/pty.js.map +1 -0
- package/esm/commands/subprocess/service.d.ts +11 -0
- package/esm/commands/subprocess/service.d.ts.map +1 -0
- package/esm/commands/subprocess/service.js +25 -0
- package/esm/commands/subprocess/service.js.map +1 -0
- package/esm/commands/subprocess/shell/index.d.ts +6 -0
- package/esm/commands/subprocess/shell/index.d.ts.map +1 -0
- package/esm/commands/subprocess/shell/index.js +6 -0
- package/esm/commands/subprocess/shell/index.js.map +1 -0
- package/esm/commands/subprocess/shell/process.d.ts +15 -0
- package/esm/commands/subprocess/shell/process.d.ts.map +1 -0
- package/esm/commands/subprocess/{protocols/shell.js → shell/process.js} +27 -54
- package/esm/commands/subprocess/shell/process.js.map +1 -0
- package/esm/commands/subprocess/shell/pty.d.ts +15 -0
- package/esm/commands/subprocess/shell/pty.d.ts.map +1 -0
- package/esm/commands/subprocess/shell/pty.js +76 -0
- package/esm/commands/subprocess/shell/pty.js.map +1 -0
- package/esm/commands/subprocess/shell/service.d.ts +14 -0
- package/esm/commands/subprocess/shell/service.d.ts.map +1 -0
- package/esm/commands/subprocess/shell/service.js +41 -0
- package/esm/commands/subprocess/shell/service.js.map +1 -0
- package/esm/commands/subprocess/shell/shared.d.ts +19 -0
- package/esm/commands/subprocess/shell/shared.d.ts.map +1 -0
- package/esm/commands/subprocess/shell/shared.js +15 -0
- package/esm/commands/subprocess/shell/shared.js.map +1 -0
- package/esm/commands/subprocess/shell/spawner.d.ts +24 -0
- package/esm/commands/subprocess/shell/spawner.d.ts.map +1 -0
- package/esm/commands/subprocess/shell/spawner.js +38 -0
- package/esm/commands/subprocess/shell/spawner.js.map +1 -0
- package/esm/commands/subprocess/utils.d.ts +1 -0
- package/esm/commands/subprocess/utils.d.ts.map +1 -1
- package/esm/commands/subprocess/utils.js +37 -0
- package/esm/commands/subprocess/utils.js.map +1 -1
- package/esm/commands/sync/list.d.ts +12 -8
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +5 -7
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +4 -4
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +2 -7
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +4 -4
- package/esm/commands/sync/request.d.ts +1 -1
- package/esm/commands/sync/response.d.ts +5 -5
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +2 -1
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +4 -4
- package/esm/commands/sync/sync.d.ts +2 -2
- package/esm/commands/sync/sync.js +1 -1
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +2 -2
- package/esm/commands/tcpip.js +2 -2
- package/esm/daemon/dispatcher.d.ts.map +1 -1
- package/esm/daemon/dispatcher.js.map +1 -1
- package/esm/daemon/packet.d.ts +6 -4
- package/esm/daemon/packet.d.ts.map +1 -1
- package/esm/daemon/packet.js +3 -5
- package/esm/daemon/packet.js.map +1 -1
- package/esm/daemon/socket.d.ts +2 -2
- package/esm/daemon/socket.d.ts.map +1 -1
- package/esm/daemon/socket.js +1 -1
- package/esm/daemon/socket.js.map +1 -1
- package/esm/device-observer.d.ts +4 -4
- package/esm/device-observer.d.ts.map +1 -1
- package/esm/server/client.d.ts +15 -57
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +66 -263
- package/esm/server/client.js.map +1 -1
- package/esm/server/commands/index.d.ts +3 -0
- package/esm/server/commands/index.d.ts.map +1 -0
- package/esm/server/commands/index.js +3 -0
- package/esm/server/commands/index.js.map +1 -0
- package/esm/server/commands/m-dns.d.ts +12 -0
- package/esm/server/commands/m-dns.d.ts.map +1 -0
- package/esm/server/commands/m-dns.js +38 -0
- package/esm/server/commands/m-dns.js.map +1 -0
- package/esm/server/commands/wireless.d.ts +27 -0
- package/esm/server/commands/wireless.d.ts.map +1 -0
- package/esm/server/commands/wireless.js +82 -0
- package/esm/server/commands/wireless.js.map +1 -0
- package/esm/server/index.d.ts +2 -0
- package/esm/server/index.d.ts.map +1 -1
- package/esm/server/index.js +2 -0
- package/esm/server/index.js.map +1 -1
- package/esm/server/observer.d.ts +9 -0
- package/esm/server/observer.d.ts.map +1 -0
- package/esm/server/observer.js +128 -0
- package/esm/server/observer.js.map +1 -0
- package/esm/server/stream.d.ts +19 -0
- package/esm/server/stream.d.ts.map +1 -0
- package/esm/server/stream.js +77 -0
- package/esm/server/stream.js.map +1 -0
- package/esm/server/transport.d.ts +3 -4
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +18 -16
- package/esm/server/transport.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/ref.d.ts +18 -0
- package/esm/utils/ref.d.ts.map +1 -0
- package/esm/utils/ref.js +29 -0
- package/esm/utils/ref.js.map +1 -0
- package/package.json +10 -10
- package/src/adb.ts +29 -28
- package/src/banner.ts +4 -4
- package/src/commands/base.ts +6 -3
- package/src/commands/power.ts +6 -6
- package/src/commands/reverse.ts +9 -12
- package/src/commands/subprocess/index.ts +3 -2
- package/src/commands/subprocess/none/index.ts +4 -0
- package/src/commands/subprocess/none/process.ts +56 -0
- package/src/commands/subprocess/none/pty.ts +45 -0
- package/src/commands/subprocess/none/service.ts +42 -0
- package/src/commands/subprocess/none/spawner.ts +68 -0
- package/src/commands/subprocess/pty.ts +15 -0
- package/src/commands/subprocess/service.ts +32 -0
- package/src/commands/subprocess/shell/index.ts +5 -0
- package/src/commands/subprocess/shell/process.ts +127 -0
- package/src/commands/subprocess/shell/pty.ts +112 -0
- package/src/commands/subprocess/shell/service.ts +58 -0
- package/src/commands/subprocess/shell/shared.ts +25 -0
- package/src/commands/subprocess/shell/spawner.ts +90 -0
- package/src/commands/subprocess/utils.ts +41 -0
- package/src/commands/sync/list.ts +7 -17
- package/src/commands/sync/pull.ts +2 -8
- package/src/commands/sync/response.ts +6 -4
- package/src/commands/sync/sync.ts +1 -1
- package/src/commands/tcpip.ts +2 -2
- package/src/daemon/dispatcher.ts +7 -4
- package/src/daemon/packet.ts +4 -8
- package/src/daemon/socket.ts +6 -6
- package/src/device-observer.ts +4 -4
- package/src/server/client.ts +100 -305
- package/src/server/commands/index.ts +2 -0
- package/src/server/commands/m-dns.ts +43 -0
- package/src/server/commands/wireless.ts +94 -0
- package/src/server/index.ts +2 -0
- package/src/server/observer.ts +172 -0
- package/src/server/stream.ts +100 -0
- package/src/server/transport.ts +38 -34
- package/src/utils/index.ts +1 -0
- package/src/utils/ref.ts +37 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/commands/subprocess/command.d.ts +0 -58
- package/esm/commands/subprocess/command.d.ts.map +0 -1
- package/esm/commands/subprocess/command.js +0 -89
- package/esm/commands/subprocess/command.js.map +0 -1
- package/esm/commands/subprocess/protocols/index.d.ts +0 -4
- package/esm/commands/subprocess/protocols/index.d.ts.map +0 -1
- package/esm/commands/subprocess/protocols/index.js +0 -4
- package/esm/commands/subprocess/protocols/index.js.map +0 -1
- package/esm/commands/subprocess/protocols/none.d.ts +0 -32
- package/esm/commands/subprocess/protocols/none.d.ts.map +0 -1
- package/esm/commands/subprocess/protocols/none.js +0 -61
- package/esm/commands/subprocess/protocols/none.js.map +0 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +0 -42
- package/esm/commands/subprocess/protocols/shell.d.ts.map +0 -1
- package/esm/commands/subprocess/protocols/shell.js.map +0 -1
- package/esm/commands/subprocess/protocols/types.d.ts +0 -49
- package/esm/commands/subprocess/protocols/types.d.ts.map +0 -1
- package/esm/commands/subprocess/protocols/types.js +0 -2
- package/esm/commands/subprocess/protocols/types.js.map +0 -1
- package/src/commands/subprocess/command.ts +0 -141
- package/src/commands/subprocess/protocols/index.ts +0 -3
- package/src/commands/subprocess/protocols/none.ts +0 -81
- package/src/commands/subprocess/protocols/shell.ts +0 -171
- package/src/commands/subprocess/protocols/types.ts +0 -63
package/esm/daemon/socket.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class AdbDaemonSocketController implements AdbDaemonSocketInfo, A
|
|
|
25
25
|
readonly service: string;
|
|
26
26
|
get readable(): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
27
27
|
readonly writable: WritableStream<MaybeConsumable<Uint8Array>>;
|
|
28
|
-
get closed(): Promise<
|
|
28
|
+
get closed(): Promise<undefined>;
|
|
29
29
|
get socket(): AdbDaemonSocket;
|
|
30
30
|
constructor(options: AdbDaemonSocketInit);
|
|
31
31
|
enqueue(data: Uint8Array): Promise<void>;
|
|
@@ -44,7 +44,7 @@ export declare class AdbDaemonSocket implements AdbDaemonSocketInfo, AdbSocket {
|
|
|
44
44
|
get service(): string;
|
|
45
45
|
get readable(): ReadableStream<Uint8Array>;
|
|
46
46
|
get writable(): WritableStream<MaybeConsumable<Uint8Array>>;
|
|
47
|
-
get closed(): Promise<
|
|
47
|
+
get closed(): Promise<undefined>;
|
|
48
48
|
constructor(controller: AdbDaemonSocketController);
|
|
49
49
|
close(): Promise<void>;
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/daemon/socket.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAER,cAAc,EACd,cAAc,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAsB,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AC,SAAS,CAAC,CAE/B;gBAEW,UAAU,EAAE,yBAAyB;IAIjD,KAAK;CAGR"}
|
package/esm/daemon/socket.js
CHANGED
package/esm/daemon/socket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/daemon/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQnD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqBzC,MAAM,OAAO,yBAAyB;IAGzB,WAAW,CAAuB;IAElC,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,YAAY,CAAW;IACvB,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/daemon/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQnD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqBzC,MAAM,OAAO,yBAAyB;IAGzB,WAAW,CAAuB;IAElC,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,YAAY,CAAW;IACvB,OAAO,CAAU;IAEjB,SAAS,CAA6B;IAC/C,mBAAmB,CAA4C;IAC/D,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,mBAAmB,CAAmC;IAC7C,QAAQ,CAA8C;IAE/D,OAAO,GAAG,KAAK,CAAC;IAEP,cAAc,GAAG,IAAI,eAAe,EAAa,CAAC;IAC3D,IAAI,MAAM;QACN,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,CAAC;IACrC,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACnC,CAAC;IAED,YAAY,UAAqC;QAC7C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,KAAK;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
package/esm/device-observer.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
2
|
import type { Event } from "@yume-chan/event";
|
|
3
3
|
export interface DeviceObserver<T> {
|
|
4
|
-
onDeviceAdd: Event<T[]>;
|
|
5
|
-
onDeviceRemove: Event<T[]>;
|
|
6
|
-
onListChange: Event<T[]>;
|
|
7
|
-
current: T[];
|
|
4
|
+
readonly onDeviceAdd: Event<readonly T[]>;
|
|
5
|
+
readonly onDeviceRemove: Event<readonly T[]>;
|
|
6
|
+
readonly onListChange: Event<readonly T[]>;
|
|
7
|
+
readonly current: readonly T[];
|
|
8
8
|
stop(): MaybePromiseLike<void>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=device-observer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-observer.d.ts","sourceRoot":"","sources":["../src/device-observer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"device-observer.d.ts","sourceRoot":"","sources":["../src/device-observer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;IAC/B,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
package/esm/server/client.d.ts
CHANGED
|
@@ -4,39 +4,29 @@ import type { AbortSignal, MaybeConsumable, ReadableWritablePair } from "@yume-c
|
|
|
4
4
|
import type { AdbIncomingSocketHandler, AdbSocket, Closeable } from "../adb.js";
|
|
5
5
|
import type { DeviceObserver as DeviceObserverBase } from "../device-observer.js";
|
|
6
6
|
import type { AdbFeature } from "../features.js";
|
|
7
|
+
import { MDnsCommands, WirelessCommands, AlreadyConnectedError as _AlreadyConnectedError, NetworkError as _NetworkError, UnauthorizedError as _UnauthorizedError } from "./commands/index.js";
|
|
8
|
+
import { AdbServerStream } from "./stream.js";
|
|
7
9
|
import { AdbServerTransport } from "./transport.js";
|
|
8
|
-
declare class AdbServerStream {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(connection: AdbServerClient.ServerConnection);
|
|
11
|
-
readExactly(length: number): MaybePromiseLike<Uint8Array>;
|
|
12
|
-
readString: (this: AdbServerStream) => MaybePromiseLike<string>;
|
|
13
|
-
writeString(value: string): Promise<void>;
|
|
14
|
-
readOkay(): Promise<void>;
|
|
15
|
-
release(): {
|
|
16
|
-
readable: import("@yume-chan/stream-extra").ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
17
|
-
writable: import("@yume-chan/stream-extra/esm/types.js").WritableStream<MaybeConsumable<Uint8Array<ArrayBufferLike>>>;
|
|
18
|
-
closed: Promise<void>;
|
|
19
|
-
close: () => MaybePromiseLike<void>;
|
|
20
|
-
};
|
|
21
|
-
dispose(): Promise<void>;
|
|
22
|
-
}
|
|
23
10
|
/**
|
|
24
11
|
* Client for the ADB Server.
|
|
25
12
|
*/
|
|
26
13
|
export declare class AdbServerClient {
|
|
27
|
-
|
|
14
|
+
#private;
|
|
15
|
+
static NetworkError: typeof _NetworkError;
|
|
16
|
+
static UnauthorizedError: typeof _UnauthorizedError;
|
|
17
|
+
static AlreadyConnectedError: typeof _AlreadyConnectedError;
|
|
28
18
|
static parseDeviceList(value: string): AdbServerClient.Device[];
|
|
29
19
|
static formatDeviceService(device: AdbServerClient.DeviceSelector, command: string): string;
|
|
30
20
|
readonly connector: AdbServerClient.ServerConnector;
|
|
31
|
-
readonly wireless:
|
|
32
|
-
readonly mDns:
|
|
21
|
+
readonly wireless: WirelessCommands;
|
|
22
|
+
readonly mDns: MDnsCommands;
|
|
33
23
|
constructor(connector: AdbServerClient.ServerConnector);
|
|
34
24
|
createConnection(request: string, options?: AdbServerClient.ServerConnectionOptions): Promise<AdbServerStream>;
|
|
35
25
|
/**
|
|
36
26
|
* `adb version`
|
|
37
27
|
*/
|
|
38
28
|
getVersion(): Promise<number>;
|
|
39
|
-
validateVersion(): Promise<void>;
|
|
29
|
+
validateVersion(minimalVersion: number): Promise<void>;
|
|
40
30
|
/**
|
|
41
31
|
* `adb kill-server`
|
|
42
32
|
*/
|
|
@@ -54,7 +44,7 @@ export declare class AdbServerClient {
|
|
|
54
44
|
/**
|
|
55
45
|
* Monitors device list changes.
|
|
56
46
|
*/
|
|
57
|
-
trackDevices(): Promise<AdbServerClient.DeviceObserver>;
|
|
47
|
+
trackDevices(options?: AdbServerClient.ServerConnectionOptions): Promise<AdbServerClient.DeviceObserver>;
|
|
58
48
|
/**
|
|
59
49
|
* `adb -s <device> reconnect` or `adb reconnect offline`
|
|
60
50
|
*/
|
|
@@ -88,6 +78,7 @@ export declare class AdbServerClient {
|
|
|
88
78
|
* @returns A promise that resolves when the condition is met.
|
|
89
79
|
*/
|
|
90
80
|
waitFor(device: AdbServerClient.DeviceSelector, state: "device" | "disconnect", options?: AdbServerClient.ServerConnectionOptions): Promise<void>;
|
|
81
|
+
waitForDisconnect(transportId: bigint, options?: AdbServerClient.ServerConnectionOptions): Promise<void>;
|
|
91
82
|
/**
|
|
92
83
|
* Creates an ADB Transport for the specified device.
|
|
93
84
|
*/
|
|
@@ -100,7 +91,7 @@ export declare namespace AdbServerClient {
|
|
|
100
91
|
signal?: AbortSignal | undefined;
|
|
101
92
|
}
|
|
102
93
|
interface ServerConnection extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>, Closeable {
|
|
103
|
-
get closed(): Promise<
|
|
94
|
+
get closed(): Promise<undefined>;
|
|
104
95
|
}
|
|
105
96
|
interface ServerConnector {
|
|
106
97
|
connect(options?: ServerConnectionOptions): MaybePromiseLike<ServerConnection>;
|
|
@@ -131,44 +122,11 @@ export declare namespace AdbServerClient {
|
|
|
131
122
|
device?: string | undefined;
|
|
132
123
|
transportId: bigint;
|
|
133
124
|
}
|
|
134
|
-
class NetworkError extends Error {
|
|
135
|
-
constructor(message: string);
|
|
136
|
-
}
|
|
137
|
-
class UnauthorizedError extends Error {
|
|
138
|
-
constructor(message: string);
|
|
139
|
-
}
|
|
140
|
-
class AlreadyConnectedError extends Error {
|
|
141
|
-
constructor(message: string);
|
|
142
|
-
}
|
|
143
|
-
class WirelessCommands {
|
|
144
|
-
#private;
|
|
145
|
-
constructor(client: AdbServerClient);
|
|
146
|
-
/**
|
|
147
|
-
* `adb pair <password> <address>`
|
|
148
|
-
*/
|
|
149
|
-
pair(address: string, password: string): Promise<void>;
|
|
150
|
-
/**
|
|
151
|
-
* `adb connect <address>`
|
|
152
|
-
*/
|
|
153
|
-
connect(address: string): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* `adb disconnect <address>`
|
|
156
|
-
*/
|
|
157
|
-
disconnect(address: string): Promise<void>;
|
|
158
|
-
}
|
|
159
|
-
class MDnsCommands {
|
|
160
|
-
#private;
|
|
161
|
-
constructor(client: AdbServerClient);
|
|
162
|
-
check(): Promise<boolean>;
|
|
163
|
-
getServices(): Promise<{
|
|
164
|
-
name: string;
|
|
165
|
-
service: string;
|
|
166
|
-
address: string;
|
|
167
|
-
}[]>;
|
|
168
|
-
}
|
|
169
125
|
interface DeviceObserver extends DeviceObserverBase<Device> {
|
|
170
126
|
onError: Event<Error>;
|
|
171
127
|
}
|
|
128
|
+
type NetworkError = _NetworkError;
|
|
129
|
+
type UnauthorizedError = _UnauthorizedError;
|
|
130
|
+
type AlreadyConnectedError = _AlreadyConnectedError;
|
|
172
131
|
}
|
|
173
|
-
export {};
|
|
174
132
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EACR,WAAW,EACX,eAAe,EACf,oBAAoB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EACH,YAAY,EACZ,gBA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chan/async";
|
|
3
|
-
import { EventEmitter } from "@yume-chan/event";
|
|
4
3
|
import { getUint64LittleEndian } from "@yume-chan/no-data-view";
|
|
5
|
-
import {
|
|
6
|
-
import { bipedal, decodeUtf8, encodeUtf8, TextDecoder, } from "@yume-chan/struct";
|
|
4
|
+
import { AbortController } from "@yume-chan/stream-extra";
|
|
7
5
|
import { AdbBanner } from "../banner.js";
|
|
8
|
-
import { hexToNumber
|
|
6
|
+
import { hexToNumber } from "../utils/index.js";
|
|
7
|
+
import { MDnsCommands, WirelessCommands, AlreadyConnectedError as _AlreadyConnectedError, NetworkError as _NetworkError, UnauthorizedError as _UnauthorizedError, } from "./commands/index.js";
|
|
8
|
+
import { AdbServerDeviceObserverOwner } from "./observer.js";
|
|
9
|
+
import { AdbServerStream } from "./stream.js";
|
|
9
10
|
import { AdbServerTransport } from "./transport.js";
|
|
10
|
-
const OKAY = encodeUtf8("OKAY");
|
|
11
|
-
const FAIL = encodeUtf8("FAIL");
|
|
12
|
-
class AdbServerStream {
|
|
13
|
-
#connection;
|
|
14
|
-
#buffered;
|
|
15
|
-
#writer;
|
|
16
|
-
constructor(connection) {
|
|
17
|
-
this.#connection = connection;
|
|
18
|
-
this.#buffered = new BufferedReadableStream(connection.readable);
|
|
19
|
-
this.#writer = connection.writable.getWriter();
|
|
20
|
-
}
|
|
21
|
-
readExactly(length) {
|
|
22
|
-
return this.#buffered.readExactly(length);
|
|
23
|
-
}
|
|
24
|
-
readString = bipedal(function* (then) {
|
|
25
|
-
const data = yield* then(this.readExactly(4));
|
|
26
|
-
const length = hexToNumber(data);
|
|
27
|
-
if (length === 0) {
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const decoder = new TextDecoder();
|
|
32
|
-
let result = "";
|
|
33
|
-
const iterator = this.#buffered.iterateExactly(length);
|
|
34
|
-
while (true) {
|
|
35
|
-
const { done, value } = iterator.next();
|
|
36
|
-
if (done) {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
result += decoder.decode(yield* then(value), { stream: true });
|
|
40
|
-
}
|
|
41
|
-
result += decoder.decode();
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
async writeString(value) {
|
|
46
|
-
// TODO: investigate using `encodeUtf8("0000" + value)` then modifying the length
|
|
47
|
-
// That way allocates a new string (hopefully only a rope) instead of a new buffer
|
|
48
|
-
const encoded = encodeUtf8(value);
|
|
49
|
-
const buffer = new Uint8Array(4 + encoded.length);
|
|
50
|
-
write4HexDigits(buffer, 0, encoded.length);
|
|
51
|
-
buffer.set(encoded, 4);
|
|
52
|
-
await this.#writer.write(buffer);
|
|
53
|
-
}
|
|
54
|
-
async readOkay() {
|
|
55
|
-
const response = await this.readExactly(4);
|
|
56
|
-
if (sequenceEqual(response, OKAY)) {
|
|
57
|
-
// `OKAY` is followed by data length and data
|
|
58
|
-
// But different services want to parse the data differently
|
|
59
|
-
// So don't read the data here
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (sequenceEqual(response, FAIL)) {
|
|
63
|
-
const reason = await this.readString();
|
|
64
|
-
throw new Error(reason);
|
|
65
|
-
}
|
|
66
|
-
throw new Error(`Unexpected response: ${decodeUtf8(response)}`);
|
|
67
|
-
}
|
|
68
|
-
release() {
|
|
69
|
-
this.#writer.releaseLock();
|
|
70
|
-
return {
|
|
71
|
-
readable: this.#buffered.release(),
|
|
72
|
-
writable: this.#connection.writable,
|
|
73
|
-
closed: this.#connection.closed,
|
|
74
|
-
close: () => this.#connection.close(),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
async dispose() {
|
|
78
|
-
void tryCancel(this.#buffered);
|
|
79
|
-
void tryClose(this.#writer);
|
|
80
|
-
await this.#connection.close();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
11
|
/**
|
|
84
12
|
* Client for the ADB Server.
|
|
85
13
|
*/
|
|
86
14
|
export class AdbServerClient {
|
|
87
|
-
static
|
|
15
|
+
static NetworkError = _NetworkError;
|
|
16
|
+
static UnauthorizedError = _UnauthorizedError;
|
|
17
|
+
static AlreadyConnectedError = _AlreadyConnectedError;
|
|
88
18
|
static parseDeviceList(value) {
|
|
89
19
|
const devices = [];
|
|
90
20
|
for (const line of value.split("\n")) {
|
|
@@ -151,8 +81,9 @@ export class AdbServerClient {
|
|
|
151
81
|
throw new TypeError("Invalid device selector");
|
|
152
82
|
}
|
|
153
83
|
connector;
|
|
154
|
-
wireless = new
|
|
155
|
-
mDns = new
|
|
84
|
+
wireless = new WirelessCommands(this);
|
|
85
|
+
mDns = new MDnsCommands(this);
|
|
86
|
+
#observerOwner = new AdbServerDeviceObserverOwner(this);
|
|
156
87
|
constructor(connector) {
|
|
157
88
|
this.connector = connector;
|
|
158
89
|
}
|
|
@@ -191,10 +122,10 @@ export class AdbServerClient {
|
|
|
191
122
|
await connection.dispose();
|
|
192
123
|
}
|
|
193
124
|
}
|
|
194
|
-
async validateVersion() {
|
|
125
|
+
async validateVersion(minimalVersion) {
|
|
195
126
|
const version = await this.getVersion();
|
|
196
|
-
if (version
|
|
197
|
-
throw new Error(`adb server version (${version}) doesn't match this client (${
|
|
127
|
+
if (version < minimalVersion) {
|
|
128
|
+
throw new Error(`adb server version (${version}) doesn't match this client (${minimalVersion})`);
|
|
198
129
|
}
|
|
199
130
|
}
|
|
200
131
|
/**
|
|
@@ -235,52 +166,8 @@ export class AdbServerClient {
|
|
|
235
166
|
/**
|
|
236
167
|
* Monitors device list changes.
|
|
237
168
|
*/
|
|
238
|
-
async trackDevices() {
|
|
239
|
-
|
|
240
|
-
let current = [];
|
|
241
|
-
const onError = new EventEmitter();
|
|
242
|
-
const onDeviceAdd = new EventEmitter();
|
|
243
|
-
const onDeviceRemove = new EventEmitter();
|
|
244
|
-
const onListChange = new EventEmitter();
|
|
245
|
-
void (async () => {
|
|
246
|
-
try {
|
|
247
|
-
while (true) {
|
|
248
|
-
const response = await connection.readString();
|
|
249
|
-
const next = AdbServerClient.parseDeviceList(response);
|
|
250
|
-
const added = [];
|
|
251
|
-
for (const nextDevice of next) {
|
|
252
|
-
const index = current.findIndex((device) => device.transportId === nextDevice.transportId);
|
|
253
|
-
if (index === -1) {
|
|
254
|
-
added.push(nextDevice);
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
current[index] = current[current.length - 1];
|
|
258
|
-
current.length -= 1;
|
|
259
|
-
}
|
|
260
|
-
if (added.length) {
|
|
261
|
-
onDeviceAdd.fire(added);
|
|
262
|
-
}
|
|
263
|
-
if (current.length) {
|
|
264
|
-
onDeviceRemove.fire(current);
|
|
265
|
-
}
|
|
266
|
-
current = next;
|
|
267
|
-
onListChange.fire(current);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
catch (e) {
|
|
271
|
-
onError.fire(e);
|
|
272
|
-
}
|
|
273
|
-
})();
|
|
274
|
-
return {
|
|
275
|
-
onError: onError.event,
|
|
276
|
-
onDeviceAdd: onDeviceAdd.event,
|
|
277
|
-
onDeviceRemove: onDeviceRemove.event,
|
|
278
|
-
onListChange: onListChange.event,
|
|
279
|
-
get current() {
|
|
280
|
-
return current;
|
|
281
|
-
},
|
|
282
|
-
stop: () => connection.dispose(),
|
|
283
|
-
};
|
|
169
|
+
async trackDevices(options) {
|
|
170
|
+
return this.#observerOwner.createObserver(options);
|
|
284
171
|
}
|
|
285
172
|
/**
|
|
286
173
|
* `adb -s <device> reconnect` or `adb reconnect offline`
|
|
@@ -339,10 +226,10 @@ export class AdbServerClient {
|
|
|
339
226
|
* @returns An `AdbServerClient.Socket` that can be used to communicate with the service
|
|
340
227
|
*/
|
|
341
228
|
async createDeviceConnection(device, service) {
|
|
342
|
-
await this.validateVersion();
|
|
343
229
|
let switchService;
|
|
344
230
|
let transportId;
|
|
345
231
|
if (!device) {
|
|
232
|
+
await this.validateVersion(41);
|
|
346
233
|
switchService = `host:tport:any`;
|
|
347
234
|
}
|
|
348
235
|
else if ("transportId" in device) {
|
|
@@ -350,12 +237,15 @@ export class AdbServerClient {
|
|
|
350
237
|
transportId = device.transportId;
|
|
351
238
|
}
|
|
352
239
|
else if ("serial" in device) {
|
|
240
|
+
await this.validateVersion(41);
|
|
353
241
|
switchService = `host:tport:serial:${device.serial}`;
|
|
354
242
|
}
|
|
355
243
|
else if ("usb" in device) {
|
|
244
|
+
await this.validateVersion(41);
|
|
356
245
|
switchService = `host:tport:usb`;
|
|
357
246
|
}
|
|
358
247
|
else if ("tcp" in device) {
|
|
248
|
+
await this.validateVersion(41);
|
|
359
249
|
switchService = `host:tport:local`;
|
|
360
250
|
}
|
|
361
251
|
else {
|
|
@@ -394,17 +284,7 @@ export class AdbServerClient {
|
|
|
394
284
|
throw e;
|
|
395
285
|
}
|
|
396
286
|
}
|
|
397
|
-
|
|
398
|
-
* Wait for a device to be connected or disconnected.
|
|
399
|
-
*
|
|
400
|
-
* `adb wait-for-<state>`
|
|
401
|
-
*
|
|
402
|
-
* @param device The device selector
|
|
403
|
-
* @param state The state to wait for
|
|
404
|
-
* @param options The options
|
|
405
|
-
* @returns A promise that resolves when the condition is met.
|
|
406
|
-
*/
|
|
407
|
-
async waitFor(device, state, options) {
|
|
287
|
+
async #waitForUnchecked(device, state, options) {
|
|
408
288
|
let type;
|
|
409
289
|
if (!device) {
|
|
410
290
|
type = "any";
|
|
@@ -435,6 +315,43 @@ export class AdbServerClient {
|
|
|
435
315
|
await connection.dispose();
|
|
436
316
|
}
|
|
437
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Wait for a device to be connected or disconnected.
|
|
320
|
+
*
|
|
321
|
+
* `adb wait-for-<state>`
|
|
322
|
+
*
|
|
323
|
+
* @param device The device selector
|
|
324
|
+
* @param state The state to wait for
|
|
325
|
+
* @param options The options
|
|
326
|
+
* @returns A promise that resolves when the condition is met.
|
|
327
|
+
*/
|
|
328
|
+
async waitFor(device, state, options) {
|
|
329
|
+
if (state === "disconnect") {
|
|
330
|
+
await this.validateVersion(41);
|
|
331
|
+
}
|
|
332
|
+
return this.#waitForUnchecked(device, state, options);
|
|
333
|
+
}
|
|
334
|
+
async waitForDisconnect(transportId, options) {
|
|
335
|
+
const serverVersion = await this.getVersion();
|
|
336
|
+
if (serverVersion >= 41) {
|
|
337
|
+
return this.#waitForUnchecked({ transportId }, "disconnect", options);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const observer = await this.trackDevices(options);
|
|
341
|
+
return new Promise((resolve, reject) => {
|
|
342
|
+
observer.onDeviceRemove((devices) => {
|
|
343
|
+
if (devices.some((device) => device.transportId === transportId)) {
|
|
344
|
+
observer.stop();
|
|
345
|
+
resolve();
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
observer.onError((e) => {
|
|
349
|
+
observer.stop();
|
|
350
|
+
reject(e);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
438
355
|
/**
|
|
439
356
|
* Creates an ADB Transport for the specified device.
|
|
440
357
|
*/
|
|
@@ -443,7 +360,14 @@ export class AdbServerClient {
|
|
|
443
360
|
const devices = await this.getDevices();
|
|
444
361
|
const info = devices.find((device) => device.transportId === transportId);
|
|
445
362
|
const banner = new AdbBanner(info?.product, info?.model, info?.device, features);
|
|
446
|
-
|
|
363
|
+
const waitAbortController = new AbortController();
|
|
364
|
+
const disconnected = this.waitForDisconnect(transportId, {
|
|
365
|
+
unref: true,
|
|
366
|
+
signal: waitAbortController.signal,
|
|
367
|
+
});
|
|
368
|
+
const transport = new AdbServerTransport(this, info?.serial ?? "", banner, transportId, disconnected);
|
|
369
|
+
void transport.disconnected.finally(() => waitAbortController.abort());
|
|
370
|
+
return transport;
|
|
447
371
|
}
|
|
448
372
|
}
|
|
449
373
|
export async function raceSignal(callback, ...signals) {
|
|
@@ -472,125 +396,4 @@ export async function raceSignal(callback, ...signals) {
|
|
|
472
396
|
}
|
|
473
397
|
}
|
|
474
398
|
}
|
|
475
|
-
(function (AdbServerClient) {
|
|
476
|
-
class NetworkError extends Error {
|
|
477
|
-
constructor(message) {
|
|
478
|
-
super(message);
|
|
479
|
-
this.name = "NetworkError";
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
AdbServerClient.NetworkError = NetworkError;
|
|
483
|
-
class UnauthorizedError extends Error {
|
|
484
|
-
constructor(message) {
|
|
485
|
-
super(message);
|
|
486
|
-
this.name = "UnauthorizedError";
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
AdbServerClient.UnauthorizedError = UnauthorizedError;
|
|
490
|
-
class AlreadyConnectedError extends Error {
|
|
491
|
-
constructor(message) {
|
|
492
|
-
super(message);
|
|
493
|
-
this.name = "AlreadyConnectedError";
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
AdbServerClient.AlreadyConnectedError = AlreadyConnectedError;
|
|
497
|
-
class WirelessCommands {
|
|
498
|
-
#client;
|
|
499
|
-
constructor(client) {
|
|
500
|
-
this.#client = client;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* `adb pair <password> <address>`
|
|
504
|
-
*/
|
|
505
|
-
async pair(address, password) {
|
|
506
|
-
const connection = await this.#client.createConnection(`host:pair:${password}:${address}`);
|
|
507
|
-
try {
|
|
508
|
-
const response = await connection.readExactly(4);
|
|
509
|
-
// `response` is either `FAIL`, or 4 hex digits for length of the string
|
|
510
|
-
if (sequenceEqual(response, FAIL)) {
|
|
511
|
-
throw new Error(await connection.readString());
|
|
512
|
-
}
|
|
513
|
-
const length = hexToNumber(response);
|
|
514
|
-
// Ignore the string as it's always `Successful ...`
|
|
515
|
-
await connection.readExactly(length);
|
|
516
|
-
}
|
|
517
|
-
finally {
|
|
518
|
-
await connection.dispose();
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* `adb connect <address>`
|
|
523
|
-
*/
|
|
524
|
-
async connect(address) {
|
|
525
|
-
const connection = await this.#client.createConnection(`host:connect:${address}`);
|
|
526
|
-
try {
|
|
527
|
-
const response = await connection.readString();
|
|
528
|
-
switch (response) {
|
|
529
|
-
case `already connected to ${address}`:
|
|
530
|
-
throw new AdbServerClient.AlreadyConnectedError(response);
|
|
531
|
-
case `failed to connect to ${address}`: // `adb pair` mode not authorized
|
|
532
|
-
case `failed to authenticate to ${address}`: // `adb tcpip` mode not authorized
|
|
533
|
-
throw new AdbServerClient.UnauthorizedError(response);
|
|
534
|
-
case `connected to ${address}`:
|
|
535
|
-
return;
|
|
536
|
-
default:
|
|
537
|
-
throw new AdbServerClient.NetworkError(response);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
finally {
|
|
541
|
-
await connection.dispose();
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* `adb disconnect <address>`
|
|
546
|
-
*/
|
|
547
|
-
async disconnect(address) {
|
|
548
|
-
const connection = await this.#client.createConnection(`host:disconnect:${address}`);
|
|
549
|
-
try {
|
|
550
|
-
await connection.readString();
|
|
551
|
-
}
|
|
552
|
-
finally {
|
|
553
|
-
await connection.dispose();
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
AdbServerClient.WirelessCommands = WirelessCommands;
|
|
558
|
-
class MDnsCommands {
|
|
559
|
-
#client;
|
|
560
|
-
constructor(client) {
|
|
561
|
-
this.#client = client;
|
|
562
|
-
}
|
|
563
|
-
async check() {
|
|
564
|
-
const connection = await this.#client.createConnection("host:mdns:check");
|
|
565
|
-
try {
|
|
566
|
-
const response = await connection.readString();
|
|
567
|
-
return !response.startsWith("ERROR:");
|
|
568
|
-
}
|
|
569
|
-
finally {
|
|
570
|
-
await connection.dispose();
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
async getServices() {
|
|
574
|
-
const connection = await this.#client.createConnection("host:mdns:services");
|
|
575
|
-
try {
|
|
576
|
-
const response = await connection.readString();
|
|
577
|
-
return response
|
|
578
|
-
.split("\n")
|
|
579
|
-
.filter(Boolean)
|
|
580
|
-
.map((line) => {
|
|
581
|
-
const parts = line.split("\t");
|
|
582
|
-
return {
|
|
583
|
-
name: parts[0],
|
|
584
|
-
service: parts[1],
|
|
585
|
-
address: parts[2],
|
|
586
|
-
};
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
finally {
|
|
590
|
-
await connection.dispose();
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
AdbServerClient.MDnsCommands = MDnsCommands;
|
|
595
|
-
})(AdbServerClient || (AdbServerClient = {}));
|
|
596
399
|
//# sourceMappingURL=client.js.map
|