@yume-chan/adb 0.0.23 → 1.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 +51 -2
- package/LICENSE +1 -1
- package/README.md +4 -1
- package/esm/adb.d.ts +15 -9
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +5 -2
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +7 -6
- package/esm/banner.d.ts.map +1 -1
- package/esm/banner.js +6 -7
- package/esm/banner.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +63 -34
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +35 -33
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +6 -5
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +12 -12
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +60 -39
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.js +3 -3
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +2 -2
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +3 -5
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +22 -14
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +21 -27
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +8 -8
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.d.ts +49 -30
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +9 -11
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +7 -9
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +4 -6
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +25 -22
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +14 -21
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +20 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +26 -35
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +25 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +49 -26
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +3 -3
- package/esm/commands/sync/socket.d.ts.map +1 -1
- package/esm/commands/sync/socket.js +10 -5
- package/esm/commands/sync/socket.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +75 -54
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +73 -69
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +18 -17
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +8 -8
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +0 -1
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +9 -9
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/daemon/auth.d.ts +8 -7
- package/esm/daemon/auth.d.ts.map +1 -1
- package/esm/daemon/auth.js +8 -9
- package/esm/daemon/auth.js.map +1 -1
- package/esm/daemon/crypto.d.ts +4 -3
- package/esm/daemon/crypto.d.ts.map +1 -1
- package/esm/daemon/crypto.js +57 -49
- package/esm/daemon/crypto.js.map +1 -1
- package/esm/daemon/device.d.ts +2 -2
- package/esm/daemon/device.d.ts.map +1 -1
- package/esm/daemon/dispatcher.d.ts +35 -10
- package/esm/daemon/dispatcher.d.ts.map +1 -1
- package/esm/daemon/dispatcher.js +46 -33
- package/esm/daemon/dispatcher.js.map +1 -1
- package/esm/daemon/packet.d.ts +48 -32
- package/esm/daemon/packet.d.ts.map +1 -1
- package/esm/daemon/packet.js +36 -32
- package/esm/daemon/packet.js.map +1 -1
- package/esm/daemon/socket.d.ts +11 -11
- package/esm/daemon/socket.d.ts.map +1 -1
- package/esm/daemon/socket.js +19 -40
- package/esm/daemon/socket.js.map +1 -1
- package/esm/daemon/transport.d.ts +60 -20
- package/esm/daemon/transport.d.ts.map +1 -1
- package/esm/daemon/transport.js +12 -15
- package/esm/daemon/transport.js.map +1 -1
- package/esm/device-observer.d.ts +10 -0
- package/esm/device-observer.d.ts.map +1 -0
- package/esm/device-observer.js +2 -0
- package/esm/device-observer.js.map +1 -0
- package/esm/features.d.ts +12 -11
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +11 -12
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +140 -50
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +396 -180
- package/esm/server/client.js.map +1 -1
- package/esm/server/transport.d.ts +2 -2
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +4 -6
- package/esm/server/transport.js.map +1 -1
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +52 -38
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/hex.d.ts +1 -1
- package/esm/utils/hex.d.ts.map +1 -1
- package/esm/utils/hex.js +12 -14
- package/esm/utils/hex.js.map +1 -1
- package/esm/utils/index.d.ts +1 -1
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/no-op.d.ts.map +1 -1
- package/esm/utils/no-op.js +1 -0
- package/esm/utils/no-op.js.map +1 -1
- package/esm/utils/sequence-equal.d.ts +2 -0
- package/esm/utils/sequence-equal.d.ts.map +1 -0
- package/esm/utils/sequence-equal.js +12 -0
- package/esm/utils/sequence-equal.js.map +1 -0
- package/package.json +14 -19
- package/src/adb.ts +20 -11
- package/src/banner.ts +8 -6
- package/src/commands/framebuffer.ts +44 -35
- package/src/commands/power.ts +7 -5
- package/src/commands/reverse.ts +78 -47
- package/src/commands/subprocess/command.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +5 -7
- package/src/commands/subprocess/protocols/shell.ts +33 -35
- package/src/commands/subprocess/protocols/types.ts +8 -8
- package/src/commands/sync/list.ts +20 -15
- package/src/commands/sync/pull.ts +9 -8
- package/src/commands/sync/push.ts +25 -24
- package/src/commands/sync/request.ts +37 -38
- package/src/commands/sync/response.ts +63 -37
- package/src/commands/sync/socket.ts +13 -8
- package/src/commands/sync/stat.ts +93 -73
- package/src/commands/sync/sync.ts +12 -11
- package/src/commands/tcpip.ts +9 -9
- package/src/daemon/auth.ts +12 -10
- package/src/daemon/crypto.ts +66 -55
- package/src/daemon/device.ts +2 -2
- package/src/daemon/dispatcher.ts +106 -44
- package/src/daemon/packet.ts +57 -38
- package/src/daemon/socket.ts +30 -50
- package/src/daemon/transport.ts +98 -50
- package/src/device-observer.ts +10 -0
- package/src/features.ts +13 -11
- package/src/index.ts +1 -0
- package/src/server/client.ts +505 -268
- package/src/server/transport.ts +7 -9
- package/src/utils/base64.ts +59 -40
- package/src/utils/hex.ts +16 -14
- package/src/utils/index.ts +1 -1
- package/src/utils/no-op.ts +1 -0
- package/src/utils/sequence-equal.ts +13 -0
- package/tsconfig.build.json +1 -12
- package/tsconfig.build.tsbuildinfo +1 -1
- package/CHANGELOG.json +0 -265
- package/esm/utils/conditional-variable.d.ts +0 -8
- package/esm/utils/conditional-variable.d.ts.map +0 -1
- package/esm/utils/conditional-variable.js +0 -34
- package/esm/utils/conditional-variable.js.map +0 -1
- package/src/utils/conditional-variable.ts +0 -45
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
3
|
+
import { Consumable } from "@yume-chan/stream-extra";
|
|
3
4
|
import type { AdbIncomingSocketHandler, AdbSocket, AdbTransport } from "../adb.js";
|
|
4
5
|
import { AdbBanner } from "../banner.js";
|
|
5
6
|
import { AdbFeature } from "../features.js";
|
|
@@ -9,7 +10,7 @@ export declare const ADB_DAEMON_VERSION_OMIT_CHECKSUM = 16777217;
|
|
|
9
10
|
export declare const ADB_DAEMON_DEFAULT_FEATURES: AdbFeature[];
|
|
10
11
|
export declare const ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE: number;
|
|
11
12
|
export type AdbDaemonConnection = ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>;
|
|
12
|
-
interface AdbDaemonAuthenticationOptions {
|
|
13
|
+
export interface AdbDaemonAuthenticationOptions {
|
|
13
14
|
serial: string;
|
|
14
15
|
connection: AdbDaemonConnection;
|
|
15
16
|
credentialStore: AdbCredentialStore;
|
|
@@ -17,18 +18,41 @@ interface AdbDaemonAuthenticationOptions {
|
|
|
17
18
|
features?: readonly AdbFeature[];
|
|
18
19
|
/**
|
|
19
20
|
* The number of bytes the device can send before receiving an ack packet.
|
|
21
|
+
* Using delayed ack can improve the throughput,
|
|
22
|
+
* especially when the device is connected over Wi-Fi (so the latency is higher).
|
|
20
23
|
*
|
|
21
24
|
* Set to 0 or any negative value to disable delayed ack in handshake.
|
|
22
25
|
* Otherwise the value must be in the range of unsigned 32-bit integer.
|
|
23
26
|
*
|
|
24
|
-
* Delayed ack
|
|
27
|
+
* Delayed ack was added in Android 14,
|
|
28
|
+
* this option will be ignored when the device doesn't support it.
|
|
29
|
+
*
|
|
30
|
+
* @default ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE
|
|
25
31
|
*/
|
|
26
32
|
initialDelayedAckBytes?: number;
|
|
27
33
|
/**
|
|
28
|
-
* Whether to
|
|
34
|
+
* Whether to keep the `connection` open (don't call `writable.close` and `readable.cancel`)
|
|
35
|
+
* when `AdbDaemonTransport.close` is called.
|
|
36
|
+
*
|
|
37
|
+
* Note that when `authenticate` fails,
|
|
38
|
+
* no matter which value this option has,
|
|
39
|
+
* the `connection` is always kept open, so it can be used in another `authenticate` call.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
29
42
|
*/
|
|
30
43
|
preserveConnection?: boolean | undefined;
|
|
31
|
-
|
|
44
|
+
/**
|
|
45
|
+
* When set, the transport will throw an error when
|
|
46
|
+
* one of the socket readable stalls for this amount of milliseconds.
|
|
47
|
+
*
|
|
48
|
+
* Because ADB is a multiplexed protocol, blocking one socket will also block all other sockets.
|
|
49
|
+
* It's important to always read from all sockets to prevent stalling.
|
|
50
|
+
*
|
|
51
|
+
* This option is helpful to detect bugs in the client code.
|
|
52
|
+
*
|
|
53
|
+
* @default undefined
|
|
54
|
+
*/
|
|
55
|
+
readTimeLimit?: number | undefined;
|
|
32
56
|
}
|
|
33
57
|
interface AdbDaemonSocketConnectorConstructionOptions {
|
|
34
58
|
serial: string;
|
|
@@ -40,27 +64,43 @@ interface AdbDaemonSocketConnectorConstructionOptions {
|
|
|
40
64
|
/**
|
|
41
65
|
* The number of bytes the device can send before receiving an ack packet.
|
|
42
66
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
67
|
+
* On Android 14 and newer, the Delayed Acknowledgement feature is added to
|
|
68
|
+
* improve performance, especially for high-latency connections like ADB over Wi-Fi.
|
|
45
69
|
*
|
|
46
|
-
*
|
|
70
|
+
* When `features` doesn't include `AdbFeature.DelayedAck`, it must be set to 0. Otherwise,
|
|
71
|
+
* the value must be in the range of unsigned 32-bit integer.
|
|
72
|
+
*
|
|
73
|
+
* If the device enabled delayed ack but the client didn't, the device will throw an error
|
|
74
|
+
* when the client sends the first data packet. And vice versa.
|
|
47
75
|
*/
|
|
48
|
-
initialDelayedAckBytes
|
|
76
|
+
initialDelayedAckBytes: number;
|
|
49
77
|
/**
|
|
50
|
-
* Whether to
|
|
78
|
+
* Whether to keep the `connection` open (don't call `writable.close` and `readable.cancel`)
|
|
79
|
+
* when `AdbDaemonTransport.close` is called.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
51
82
|
*/
|
|
52
83
|
preserveConnection?: boolean | undefined;
|
|
53
|
-
|
|
84
|
+
/**
|
|
85
|
+
* When set, the transport will throw an error when
|
|
86
|
+
* one of the socket readable stalls for this amount of milliseconds.
|
|
87
|
+
*
|
|
88
|
+
* Because ADB is a multiplexed protocol, blocking one socket will also block all other sockets.
|
|
89
|
+
* It's important to always read from all sockets to prevent stalling.
|
|
90
|
+
*
|
|
91
|
+
* This option is helpful to detect bugs in the client code.
|
|
92
|
+
*
|
|
93
|
+
* @default undefined
|
|
94
|
+
*/
|
|
95
|
+
readTimeLimit?: number | undefined;
|
|
54
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* An ADB Transport that connects to ADB Daemons directly.
|
|
99
|
+
*/
|
|
55
100
|
export declare class AdbDaemonTransport implements AdbTransport {
|
|
56
101
|
#private;
|
|
57
102
|
/**
|
|
58
|
-
*
|
|
59
|
-
* that can be used by `Adb` class.
|
|
60
|
-
*
|
|
61
|
-
* If an authentication process failed, it's possible to call `authenticate` again
|
|
62
|
-
* on the same connection. Because every time the device receives a `CNXN` packet,
|
|
63
|
-
* it resets all internal state, and starts a new authentication process.
|
|
103
|
+
* Authenticate with the ADB Daemon and create a new transport.
|
|
64
104
|
*/
|
|
65
105
|
static authenticate({ serial, connection, credentialStore, authenticators, features, initialDelayedAckBytes, ...options }: AdbDaemonAuthenticationOptions): Promise<AdbDaemonTransport>;
|
|
66
106
|
get connection(): AdbDaemonConnection;
|
|
@@ -71,11 +111,11 @@ export declare class AdbDaemonTransport implements AdbTransport {
|
|
|
71
111
|
get disconnected(): Promise<void>;
|
|
72
112
|
get clientFeatures(): readonly AdbFeature[];
|
|
73
113
|
constructor({ serial, connection, version, banner, features, initialDelayedAckBytes, ...options }: AdbDaemonSocketConnectorConstructionOptions);
|
|
74
|
-
connect(service: string):
|
|
114
|
+
connect(service: string): MaybePromiseLike<AdbSocket>;
|
|
75
115
|
addReverseTunnel(handler: AdbIncomingSocketHandler, address?: string): string;
|
|
76
116
|
removeReverseTunnel(address: string): void;
|
|
77
117
|
clearReverseTunnels(): void;
|
|
78
|
-
close():
|
|
118
|
+
close(): MaybePromiseLike<void>;
|
|
79
119
|
}
|
|
80
120
|
export {};
|
|
81
121
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/daemon/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/daemon/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAEH,UAAU,EAEb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EACR,wBAAwB,EACxB,SAAS,EACT,YAAY,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAMtE,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGhE,eAAO,MAAM,gCAAgC,WAAa,CAAC;AAG3D,eAAO,MAAM,2BAA2B,cAqBhB,CAAC;AACzB,eAAO,MAAM,uCAAuC,QAAmB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAClD,aAAa,EACb,UAAU,CAAC,aAAa,CAAC,CAC5B,CAAC;AAE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jB;gBAEW,EACR,MAAM,EACN,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAsC,EACtC,sBAAsB,EACtB,GAAG,OAAO,EACb,EAAE,2CAA2C;IAwC9C,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC;IAIrD,gBAAgB,CACZ,OAAO,EAAE,wBAAwB,EACjC,OAAO,CAAC,EAAE,MAAM,GACjB,MAAM;IAST,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI1C,mBAAmB,IAAI,IAAI;IAI3B,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC;CAGlC"}
|
package/esm/daemon/transport.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
-
import { AbortController,
|
|
2
|
+
import { AbortController, Consumable, WritableStream, } from "@yume-chan/stream-extra";
|
|
3
3
|
import { decodeUtf8, encodeUtf8 } from "@yume-chan/struct";
|
|
4
4
|
import { AdbBanner } from "../banner.js";
|
|
5
5
|
import { AdbFeature } from "../features.js";
|
|
@@ -9,7 +9,7 @@ import { AdbCommand, calculateChecksum } from "./packet.js";
|
|
|
9
9
|
export const ADB_DAEMON_VERSION_OMIT_CHECKSUM = 0x01000001;
|
|
10
10
|
// https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
|
|
11
11
|
// There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
|
|
12
|
-
export const ADB_DAEMON_DEFAULT_FEATURES = [
|
|
12
|
+
export const ADB_DAEMON_DEFAULT_FEATURES = /* #__PURE__ */ (() => [
|
|
13
13
|
AdbFeature.ShellV2,
|
|
14
14
|
AdbFeature.Cmd,
|
|
15
15
|
AdbFeature.StatV2,
|
|
@@ -29,16 +29,14 @@ export const ADB_DAEMON_DEFAULT_FEATURES = [
|
|
|
29
29
|
"sendrecv_v2_zstd",
|
|
30
30
|
"sendrecv_v2_dry_run_send",
|
|
31
31
|
AdbFeature.DelayedAck,
|
|
32
|
-
];
|
|
32
|
+
])();
|
|
33
33
|
export const ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE = 32 * 1024 * 1024;
|
|
34
|
+
/**
|
|
35
|
+
* An ADB Transport that connects to ADB Daemons directly.
|
|
36
|
+
*/
|
|
34
37
|
export class AdbDaemonTransport {
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
37
|
-
* that can be used by `Adb` class.
|
|
38
|
-
*
|
|
39
|
-
* If an authentication process failed, it's possible to call `authenticate` again
|
|
40
|
-
* on the same connection. Because every time the device receives a `CNXN` packet,
|
|
41
|
-
* it resets all internal state, and starts a new authentication process.
|
|
39
|
+
* Authenticate with the ADB Daemon and create a new transport.
|
|
42
40
|
*/
|
|
43
41
|
static async authenticate({ serial, connection, credentialStore, authenticators = ADB_DEFAULT_AUTHENTICATORS, features = ADB_DAEMON_DEFAULT_FEATURES, initialDelayedAckBytes = ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE, ...options }) {
|
|
44
42
|
// Initially, set to highest-supported version and payload size.
|
|
@@ -79,9 +77,8 @@ export class AdbDaemonTransport {
|
|
|
79
77
|
signal: abortController.signal,
|
|
80
78
|
})
|
|
81
79
|
.then(() => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
80
|
+
// If `resolver` is already settled, call `reject` won't do anything.
|
|
81
|
+
resolver.reject(new Error("Connection closed unexpectedly"));
|
|
85
82
|
}, (e) => {
|
|
86
83
|
resolver.reject(e);
|
|
87
84
|
});
|
|
@@ -91,7 +88,7 @@ export class AdbDaemonTransport {
|
|
|
91
88
|
// Because we don't know if the device needs it or not.
|
|
92
89
|
init.checksum = calculateChecksum(init.payload);
|
|
93
90
|
init.magic = init.command ^ 0xffffffff;
|
|
94
|
-
await
|
|
91
|
+
await Consumable.WritableStream.write(writer, init);
|
|
95
92
|
}
|
|
96
93
|
const actualFeatures = features.slice();
|
|
97
94
|
if (initialDelayedAckBytes <= 0) {
|
|
@@ -158,14 +155,14 @@ export class AdbDaemonTransport {
|
|
|
158
155
|
get clientFeatures() {
|
|
159
156
|
return this.#clientFeatures;
|
|
160
157
|
}
|
|
161
|
-
constructor({ serial, connection, version, banner, features = ADB_DAEMON_DEFAULT_FEATURES, initialDelayedAckBytes
|
|
158
|
+
constructor({ serial, connection, version, banner, features = ADB_DAEMON_DEFAULT_FEATURES, initialDelayedAckBytes, ...options }) {
|
|
162
159
|
this.#serial = serial;
|
|
163
160
|
this.#connection = connection;
|
|
164
161
|
this.#banner = AdbBanner.parse(banner);
|
|
165
162
|
this.#clientFeatures = features;
|
|
166
163
|
if (features.includes(AdbFeature.DelayedAck)) {
|
|
167
164
|
if (initialDelayedAckBytes <= 0) {
|
|
168
|
-
throw new
|
|
165
|
+
throw new TypeError("`initialDelayedAckBytes` must be greater than 0 when DelayedAck feature is enabled.");
|
|
169
166
|
}
|
|
170
167
|
if (!this.#banner.features.includes(AdbFeature.DelayedAck)) {
|
|
171
168
|
initialDelayedAckBytes = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/daemon/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/daemon/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EACH,eAAe,EACf,UAAU,EACV,cAAc,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO3D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EACH,0BAA0B,EAC1B,0BAA0B,GAC7B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,mBAAmB,EAAE,MA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W,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { Event } from "@yume-chan/event";
|
|
3
|
+
export interface DeviceObserver<T> {
|
|
4
|
+
onDeviceAdd: Event<T[]>;
|
|
5
|
+
onDeviceRemove: Event<T[]>;
|
|
6
|
+
onListChange: Event<T[]>;
|
|
7
|
+
current: T[];
|
|
8
|
+
stop(): MaybePromiseLike<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=device-observer.d.ts.map
|
|
@@ -0,0 +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;IACxB,cAAc,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3B,YAAY,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACzB,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-observer.js","sourceRoot":"","sources":["../src/device-observer.ts"],"names":[],"mappings":""}
|
package/esm/features.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
ShellV2
|
|
3
|
-
Cmd
|
|
4
|
-
StatV2
|
|
5
|
-
ListV2
|
|
6
|
-
FixedPushMkdir
|
|
7
|
-
Abb
|
|
8
|
-
AbbExec
|
|
9
|
-
SendReceiveV2
|
|
10
|
-
DelayedAck
|
|
11
|
-
}
|
|
1
|
+
export declare const AdbFeature: {
|
|
2
|
+
readonly ShellV2: "shell_v2";
|
|
3
|
+
readonly Cmd: "cmd";
|
|
4
|
+
readonly StatV2: "stat_v2";
|
|
5
|
+
readonly ListV2: "ls_v2";
|
|
6
|
+
readonly FixedPushMkdir: "fixed_push_mkdir";
|
|
7
|
+
readonly Abb: "abb";
|
|
8
|
+
readonly AbbExec: "abb_exec";
|
|
9
|
+
readonly SendReceiveV2: "sendrecv_v2";
|
|
10
|
+
readonly DelayedAck: "delayed_ack";
|
|
11
|
+
};
|
|
12
|
+
export type AdbFeature = (typeof AdbFeature)[keyof typeof AdbFeature];
|
|
12
13
|
//# sourceMappingURL=features.d.ts.map
|
package/esm/features.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;CAUb,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC"}
|
package/esm/features.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// The order follows
|
|
2
2
|
// https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/transport.cpp;l=77;drc=6d14d35d0241f6fee145f8e54ffd77252e8d29fd
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})(AdbFeature || (AdbFeature = {}));
|
|
3
|
+
export const AdbFeature = {
|
|
4
|
+
ShellV2: "shell_v2",
|
|
5
|
+
Cmd: "cmd",
|
|
6
|
+
StatV2: "stat_v2",
|
|
7
|
+
ListV2: "ls_v2",
|
|
8
|
+
FixedPushMkdir: "fixed_push_mkdir",
|
|
9
|
+
Abb: "abb",
|
|
10
|
+
AbbExec: "abb_exec",
|
|
11
|
+
SendReceiveV2: "sendrecv_v2",
|
|
12
|
+
DelayedAck: "delayed_ack",
|
|
13
|
+
};
|
|
15
14
|
//# 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,oBAAoB;AACpB,qJAAqJ;AACrJ,MAAM,
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,qJAAqJ;AACrJ,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,OAAO,EAAE,UAAU;IACnB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,kBAAkB;IAClC,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,UAAU;IACnB,aAAa,EAAE,aAAa;IAC5B,UAAU,EAAE,aAAa;CACnB,CAAC"}
|
package/esm/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./adb.js";
|
|
|
2
2
|
export * from "./banner.js";
|
|
3
3
|
export * from "./commands/index.js";
|
|
4
4
|
export * from "./daemon/index.js";
|
|
5
|
+
export * from "./device-observer.js";
|
|
5
6
|
export * from "./features.js";
|
|
6
7
|
export * from "./server/index.js";
|
|
7
8
|
export * from "./utils/index.js";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./adb.js";
|
|
|
2
2
|
export * from "./banner.js";
|
|
3
3
|
export * from "./commands/index.js";
|
|
4
4
|
export * from "./daemon/index.js";
|
|
5
|
+
export * from "./device-observer.js";
|
|
5
6
|
export * from "./features.js";
|
|
6
7
|
export * from "./server/index.js";
|
|
7
8
|
export * from "./utils/index.js";
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/esm/server/client.d.ts
CHANGED
|
@@ -1,57 +1,64 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { Event } from "@yume-chan/event";
|
|
3
|
+
import type { AbortSignal, MaybeConsumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
3
4
|
import type { AdbIncomingSocketHandler, AdbSocket, Closeable } from "../adb.js";
|
|
5
|
+
import type { DeviceObserver as DeviceObserverBase } from "../device-observer.js";
|
|
4
6
|
import type { AdbFeature } from "../features.js";
|
|
5
7
|
import { AdbServerTransport } from "./transport.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
transportId: bigint;
|
|
21
|
-
}
|
|
22
|
-
export type AdbServerDeviceSelector = {
|
|
23
|
-
transportId: bigint;
|
|
24
|
-
} | {
|
|
25
|
-
serial: string;
|
|
26
|
-
} | {
|
|
27
|
-
usb: true;
|
|
28
|
-
} | {
|
|
29
|
-
tcp: true;
|
|
30
|
-
} | undefined;
|
|
31
|
-
export interface AdbServerDevice {
|
|
32
|
-
serial: string;
|
|
33
|
-
product?: string | undefined;
|
|
34
|
-
model?: string | undefined;
|
|
35
|
-
device?: string | undefined;
|
|
36
|
-
transportId: bigint;
|
|
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>;
|
|
37
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Client for the ADB Server.
|
|
25
|
+
*/
|
|
38
26
|
export declare class AdbServerClient {
|
|
39
27
|
static readonly VERSION = 41;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
static parseDeviceList(value: string): AdbServerClient.Device[];
|
|
29
|
+
static formatDeviceService(device: AdbServerClient.DeviceSelector, command: string): string;
|
|
30
|
+
readonly connector: AdbServerClient.ServerConnector;
|
|
31
|
+
readonly wireless: AdbServerClient.WirelessCommands;
|
|
32
|
+
readonly mDns: AdbServerClient.MDnsCommands;
|
|
33
|
+
constructor(connector: AdbServerClient.ServerConnector);
|
|
34
|
+
createConnection(request: string, options?: AdbServerClient.ServerConnectionOptions): Promise<AdbServerStream>;
|
|
35
|
+
/**
|
|
36
|
+
* `adb version`
|
|
37
|
+
*/
|
|
47
38
|
getVersion(): Promise<number>;
|
|
48
39
|
validateVersion(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* `adb kill-server`
|
|
42
|
+
*/
|
|
49
43
|
killServer(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* `adb host-features`
|
|
46
|
+
*/
|
|
50
47
|
getServerFeatures(): Promise<AdbFeature[]>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Get a list of connected devices from ADB Server.
|
|
50
|
+
*
|
|
51
|
+
* Equivalent ADB Command: `adb devices -l`
|
|
52
|
+
*/
|
|
53
|
+
getDevices(): Promise<AdbServerClient.Device[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Monitors device list changes.
|
|
56
|
+
*/
|
|
57
|
+
trackDevices(): Promise<AdbServerClient.DeviceObserver>;
|
|
58
|
+
/**
|
|
59
|
+
* `adb -s <device> reconnect` or `adb reconnect offline`
|
|
60
|
+
*/
|
|
61
|
+
reconnectDevice(device: AdbServerClient.DeviceSelector | "offline"): Promise<void>;
|
|
55
62
|
/**
|
|
56
63
|
* Gets the features supported by the device.
|
|
57
64
|
* The transport ID of the selected device is also returned,
|
|
@@ -59,7 +66,7 @@ export declare class AdbServerClient {
|
|
|
59
66
|
* @param device The device selector
|
|
60
67
|
* @returns The transport ID of the selected device, and the features supported by the device.
|
|
61
68
|
*/
|
|
62
|
-
getDeviceFeatures(device:
|
|
69
|
+
getDeviceFeatures(device: AdbServerClient.DeviceSelector): Promise<{
|
|
63
70
|
transportId: bigint;
|
|
64
71
|
features: AdbFeature[];
|
|
65
72
|
}>;
|
|
@@ -67,18 +74,101 @@ export declare class AdbServerClient {
|
|
|
67
74
|
* Creates a connection that will forward the service to device.
|
|
68
75
|
* @param device The device selector
|
|
69
76
|
* @param service The service to forward
|
|
70
|
-
* @returns An `
|
|
77
|
+
* @returns An `AdbServerClient.Socket` that can be used to communicate with the service
|
|
71
78
|
*/
|
|
72
|
-
|
|
79
|
+
createDeviceConnection(device: AdbServerClient.DeviceSelector, service: string): Promise<AdbServerClient.Socket>;
|
|
73
80
|
/**
|
|
74
81
|
* Wait for a device to be connected or disconnected.
|
|
82
|
+
*
|
|
83
|
+
* `adb wait-for-<state>`
|
|
84
|
+
*
|
|
75
85
|
* @param device The device selector
|
|
76
86
|
* @param state The state to wait for
|
|
77
87
|
* @param options The options
|
|
78
88
|
* @returns A promise that resolves when the condition is met.
|
|
79
89
|
*/
|
|
80
|
-
waitFor(device:
|
|
81
|
-
|
|
90
|
+
waitFor(device: AdbServerClient.DeviceSelector, state: "device" | "disconnect", options?: AdbServerClient.ServerConnectionOptions): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Creates an ADB Transport for the specified device.
|
|
93
|
+
*/
|
|
94
|
+
createTransport(device: AdbServerClient.DeviceSelector): Promise<AdbServerTransport>;
|
|
95
|
+
}
|
|
96
|
+
export declare function raceSignal<T>(callback: () => PromiseLike<T>, ...signals: (AbortSignal | undefined)[]): Promise<T>;
|
|
97
|
+
export declare namespace AdbServerClient {
|
|
98
|
+
interface ServerConnectionOptions {
|
|
99
|
+
unref?: boolean | undefined;
|
|
100
|
+
signal?: AbortSignal | undefined;
|
|
101
|
+
}
|
|
102
|
+
interface ServerConnection extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>, Closeable {
|
|
103
|
+
get closed(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
interface ServerConnector {
|
|
106
|
+
connect(options?: ServerConnectionOptions): MaybePromiseLike<ServerConnection>;
|
|
107
|
+
addReverseTunnel(handler: AdbIncomingSocketHandler, address?: string): MaybePromiseLike<string>;
|
|
108
|
+
removeReverseTunnel(address: string): MaybePromiseLike<void>;
|
|
109
|
+
clearReverseTunnels(): MaybePromiseLike<void>;
|
|
110
|
+
}
|
|
111
|
+
interface Socket extends AdbSocket {
|
|
112
|
+
transportId: bigint;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A union type for selecting a device.
|
|
116
|
+
*/
|
|
117
|
+
type DeviceSelector = {
|
|
118
|
+
transportId: bigint;
|
|
119
|
+
} | {
|
|
120
|
+
serial: string;
|
|
121
|
+
} | {
|
|
122
|
+
usb: true;
|
|
123
|
+
} | {
|
|
124
|
+
tcp: true;
|
|
125
|
+
} | undefined;
|
|
126
|
+
interface Device {
|
|
127
|
+
serial: string;
|
|
128
|
+
authenticating: boolean;
|
|
129
|
+
product?: string | undefined;
|
|
130
|
+
model?: string | undefined;
|
|
131
|
+
device?: string | undefined;
|
|
132
|
+
transportId: bigint;
|
|
133
|
+
}
|
|
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
|
+
interface DeviceObserver extends DeviceObserverBase<Device> {
|
|
170
|
+
onError: Event<Error>;
|
|
171
|
+
}
|
|
82
172
|
}
|
|
83
|
-
export
|
|
173
|
+
export {};
|
|
84
174
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"
|
|
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;AAG9C,OAAO,KAAK,EACR,WAAW,EACX,eAAe,EACf,oBAAoB,EAEvB,MAAM,yBAAyB,CAAC;AAajC,OAAO,KAAK,EA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