@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAQ,EAAE,IAAgC;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,mBAAmB,QAAQ,MAAM,CAAC;IAEnD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI;QACA,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;KAC1D;YAAS;QACN,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;KACxB;IAED,IAAI;QACA,MAAM,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC;YACpC,IAAI;YACJ,SAAS;YACT,SAAS,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAC;KACN;YAAS;QACN,MAAM,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC1B;AACL,CAAC"}
|
package/esm/commands/power.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { AdbCommandBase } from
|
|
2
|
-
export declare class AdbPower extends AdbCommandBase {
|
|
3
|
-
reboot(name?: string): Promise<string>;
|
|
4
|
-
bootloader(): Promise<string>;
|
|
5
|
-
fastboot(): Promise<string>;
|
|
6
|
-
recovery(): Promise<string>;
|
|
7
|
-
sideload(): Promise<string>;
|
|
8
|
-
/**
|
|
9
|
-
* Reboot to Qualcomm Emergency Download (EDL) Mode.
|
|
10
|
-
*
|
|
11
|
-
* Only works on some Qualcomm devices.
|
|
12
|
-
*/
|
|
13
|
-
qualcommEdlMode(): Promise<string>;
|
|
14
|
-
powerOff(): Promise<string>;
|
|
15
|
-
powerButton(longPress?: boolean): Promise<string>;
|
|
16
|
-
/**
|
|
17
|
-
* Reboot to Samsung Odin download mode.
|
|
18
|
-
*
|
|
19
|
-
* Only works on Samsung devices.
|
|
20
|
-
*/
|
|
21
|
-
samsungOdin(): Promise<string>;
|
|
22
|
-
}
|
|
1
|
+
import { AdbCommandBase } from "./base.js";
|
|
2
|
+
export declare class AdbPower extends AdbCommandBase {
|
|
3
|
+
reboot(name?: string): Promise<string>;
|
|
4
|
+
bootloader(): Promise<string>;
|
|
5
|
+
fastboot(): Promise<string>;
|
|
6
|
+
recovery(): Promise<string>;
|
|
7
|
+
sideload(): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Reboot to Qualcomm Emergency Download (EDL) Mode.
|
|
10
|
+
*
|
|
11
|
+
* Only works on some Qualcomm devices.
|
|
12
|
+
*/
|
|
13
|
+
qualcommEdlMode(): Promise<string>;
|
|
14
|
+
powerOff(): Promise<string>;
|
|
15
|
+
powerButton(longPress?: boolean): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Reboot to Samsung Odin download mode.
|
|
18
|
+
*
|
|
19
|
+
* Only works on Samsung devices.
|
|
20
|
+
*/
|
|
21
|
+
samsungOdin(): Promise<string>;
|
|
22
|
+
}
|
|
23
23
|
//# sourceMappingURL=power.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,QAAS,SAAQ,cAAc;IACjC,MAAM,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,QAAS,SAAQ,cAAc;IACjC,MAAM,CAAC,IAAI,SAAK;IAIhB,UAAU;IAIV,QAAQ;IAIR,QAAQ;IAIR,QAAQ;IAIf;;;;OAIG;IACI,eAAe;IAIf,QAAQ;IAIR,WAAW,CAAC,SAAS,UAAQ;IAQpC;;;;OAIG;IACI,WAAW;CAGrB"}
|
package/esm/commands/power.js
CHANGED
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
// cspell: ignore bootloader
|
|
2
|
-
// cspell: ignore fastboot
|
|
3
|
-
// cspell: ignore keyevent
|
|
4
|
-
// cspell: ignore longpress
|
|
5
|
-
import { AdbCommandBase } from
|
|
6
|
-
export class AdbPower extends AdbCommandBase {
|
|
7
|
-
reboot(name =
|
|
8
|
-
return this.adb.createSocketAndWait(`reboot:${name}`);
|
|
9
|
-
}
|
|
10
|
-
bootloader() {
|
|
11
|
-
return this.reboot(
|
|
12
|
-
}
|
|
13
|
-
fastboot() {
|
|
14
|
-
return this.reboot(
|
|
15
|
-
}
|
|
16
|
-
recovery() {
|
|
17
|
-
return this.reboot(
|
|
18
|
-
}
|
|
19
|
-
sideload() {
|
|
20
|
-
return this.reboot(
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Reboot to Qualcomm Emergency Download (EDL) Mode.
|
|
24
|
-
*
|
|
25
|
-
* Only works on some Qualcomm devices.
|
|
26
|
-
*/
|
|
27
|
-
qualcommEdlMode() {
|
|
28
|
-
return this.reboot(
|
|
29
|
-
}
|
|
30
|
-
powerOff() {
|
|
31
|
-
return this.adb.subprocess.spawnAndWaitLegacy([
|
|
32
|
-
}
|
|
33
|
-
powerButton(longPress = false) {
|
|
34
|
-
return this.adb.subprocess.spawnAndWaitLegacy([
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
// cspell: ignore bootloader
|
|
2
|
+
// cspell: ignore fastboot
|
|
3
|
+
// cspell: ignore keyevent
|
|
4
|
+
// cspell: ignore longpress
|
|
5
|
+
import { AdbCommandBase } from "./base.js";
|
|
6
|
+
export class AdbPower extends AdbCommandBase {
|
|
7
|
+
reboot(name = "") {
|
|
8
|
+
return this.adb.createSocketAndWait(`reboot:${name}`);
|
|
9
|
+
}
|
|
10
|
+
bootloader() {
|
|
11
|
+
return this.reboot("bootloader");
|
|
12
|
+
}
|
|
13
|
+
fastboot() {
|
|
14
|
+
return this.reboot("fastboot");
|
|
15
|
+
}
|
|
16
|
+
recovery() {
|
|
17
|
+
return this.reboot("recovery");
|
|
18
|
+
}
|
|
19
|
+
sideload() {
|
|
20
|
+
return this.reboot("sideload");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reboot to Qualcomm Emergency Download (EDL) Mode.
|
|
24
|
+
*
|
|
25
|
+
* Only works on some Qualcomm devices.
|
|
26
|
+
*/
|
|
27
|
+
qualcommEdlMode() {
|
|
28
|
+
return this.reboot("edl");
|
|
29
|
+
}
|
|
30
|
+
powerOff() {
|
|
31
|
+
return this.adb.subprocess.spawnAndWaitLegacy(["reboot", "-p"]);
|
|
32
|
+
}
|
|
33
|
+
powerButton(longPress = false) {
|
|
34
|
+
return this.adb.subprocess.spawnAndWaitLegacy([
|
|
35
|
+
"input",
|
|
36
|
+
"keyevent",
|
|
37
|
+
longPress ? "--longpress POWER" : "POWER",
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Reboot to Samsung Odin download mode.
|
|
42
|
+
*
|
|
43
|
+
* Only works on Samsung devices.
|
|
44
|
+
*/
|
|
45
|
+
samsungOdin() {
|
|
46
|
+
return this.reboot("download");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
45
49
|
//# sourceMappingURL=power.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"power.js","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,0BAA0B;AAC1B,0BAA0B;AA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IG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACJ"}
|
|
@@ -1,29 +1,42 @@
|
|
|
1
|
-
import { AutoDisposable } from
|
|
2
|
-
import type { Adb } from
|
|
3
|
-
import type { AdbIncomingSocketHandler, AdbSocket } from
|
|
4
|
-
export interface AdbForwardListener {
|
|
5
|
-
deviceSerial: string;
|
|
6
|
-
localName: string;
|
|
7
|
-
remoteName: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { AutoDisposable } from "@yume-chan/event";
|
|
2
|
+
import type { Adb } from "../adb.js";
|
|
3
|
+
import type { AdbIncomingSocketHandler, AdbSocket } from "../socket/index.js";
|
|
4
|
+
export interface AdbForwardListener {
|
|
5
|
+
deviceSerial: string;
|
|
6
|
+
localName: string;
|
|
7
|
+
remoteName: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class AdbReverseError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class AdbReverseNotSupportedError extends Error {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare class AdbReverseCommand extends AutoDisposable {
|
|
16
|
+
protected localAddressToHandler: Map<string, AdbIncomingSocketHandler>;
|
|
17
|
+
protected deviceAddressToLocalAddress: Map<string, string>;
|
|
18
|
+
protected adb: Adb;
|
|
19
|
+
protected listening: boolean;
|
|
20
|
+
constructor(adb: Adb);
|
|
21
|
+
protected handleIncomingSocket: (socket: AdbSocket) => Promise<boolean>;
|
|
22
|
+
private createBufferedStream;
|
|
23
|
+
private sendRequest;
|
|
24
|
+
list(): Promise<AdbForwardListener[]>;
|
|
25
|
+
/**
|
|
26
|
+
* @param deviceAddress
|
|
27
|
+
* The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
|
|
28
|
+
* @param localAddress
|
|
29
|
+
* An identifier for the reverse tunnel.
|
|
30
|
+
*
|
|
31
|
+
* When a socket wants to connect to {@link deviceAddress}, native ADB client will forward that connection to {@link localAddress}.
|
|
32
|
+
* However in this library, the {@link handler} is invoked instead. So this parameter is only used to identify the reverse tunnel.
|
|
33
|
+
* @param handler A callback to handle incoming connections. It must return `true` if it accepts the connection.
|
|
34
|
+
* @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
|
|
35
|
+
* @throws {AdbReverseNotSupportedError} If ADB reverse tunnel is not supported on this device when connected wirelessly.
|
|
36
|
+
* @throws {AdbReverseError} If ADB daemon returns an error.
|
|
37
|
+
*/
|
|
38
|
+
add(deviceAddress: string, localAddress: string, handler: AdbIncomingSocketHandler): Promise<string>;
|
|
39
|
+
remove(deviceAddress: string): Promise<void>;
|
|
40
|
+
removeAll(): Promise<void>;
|
|
41
|
+
}
|
|
29
42
|
//# sourceMappingURL=reverse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9E,MAAM,WAAW,kBAAkB;IAC/B,YAAY,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,EAAE,MAAM,CAAC;CACtB;AAMD,qBAAa,eAAgB,SAAQ,KAAK;gBACnB,OAAO,EAAE,MAAM;CAIrC;AAED,qBAAa,2BAA4B,SAAQ,KAAK;;CAOrD;AAeD,qBAAa,iBAAkB,SAAQ,cAAc;IACjD,SAAS,CAAC,qBAAqB,wCAG3B;IAEJ,SAAS,CAAC,2BAA2B,sBAA6B;IAElE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEnB,SAAS,CAAC,SAAS,UAAS;gBAET,GAAG,EAAE,GAAG;IAS3B,SAAS,CAAC,oBAAoB,WAAkB,SAAS,sBAKvD;YAEY,oBAAoB;YAKpB,WAAW;IASZ,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAgBlD;;;;;;;;;;;;OAYG;IACU,GAAG,CACZ,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,MAAM,CAAC;IAkCL,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa5C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ1C"}
|
package/esm/commands/reverse.js
CHANGED
|
@@ -1,99 +1,126 @@
|
|
|
1
|
-
// cspell: ignore killforward
|
|
2
|
-
import { AutoDisposable } from
|
|
3
|
-
import { BufferedReadableStream, BufferedReadableStreamEndedError } from
|
|
4
|
-
import Struct from
|
|
5
|
-
import { decodeUtf8 } from
|
|
6
|
-
const AdbReverseStringResponse = new Struct()
|
|
7
|
-
.string(
|
|
8
|
-
.string(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
async
|
|
85
|
-
await this.sendRequest(`reverse:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
// cspell: ignore killforward
|
|
2
|
+
import { AutoDisposable } from "@yume-chan/event";
|
|
3
|
+
import { BufferedReadableStream, BufferedReadableStreamEndedError, } from "@yume-chan/stream-extra";
|
|
4
|
+
import Struct from "@yume-chan/struct";
|
|
5
|
+
import { decodeUtf8 } from "../utils/index.js";
|
|
6
|
+
const AdbReverseStringResponse = new Struct()
|
|
7
|
+
.string("length", { length: 4 })
|
|
8
|
+
.string("content", { lengthField: "length", lengthFieldRadix: 16 });
|
|
9
|
+
export class AdbReverseError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
Object.setPrototypeOf(this, AdbReverseError.prototype);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class AdbReverseNotSupportedError extends Error {
|
|
16
|
+
constructor() {
|
|
17
|
+
super("ADB reverse tunnel is not supported on this device when connected wirelessly.");
|
|
18
|
+
Object.setPrototypeOf(this, AdbReverseNotSupportedError.prototype);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const AdbReverseErrorResponse = new Struct()
|
|
22
|
+
.fields(AdbReverseStringResponse)
|
|
23
|
+
.postDeserialize((value) => {
|
|
24
|
+
// https://issuetracker.google.com/issues/37066218
|
|
25
|
+
// ADB on Android <9 can't create reverse tunnels when connected wirelessly (ADB over WiFi),
|
|
26
|
+
// and returns this confusing "more than one device/emulator" error.
|
|
27
|
+
if (value.content === "more than one device/emulator") {
|
|
28
|
+
throw new AdbReverseNotSupportedError();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new AdbReverseError(value.content);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export class AdbReverseCommand extends AutoDisposable {
|
|
35
|
+
localAddressToHandler = new Map();
|
|
36
|
+
deviceAddressToLocalAddress = new Map();
|
|
37
|
+
adb;
|
|
38
|
+
listening = false;
|
|
39
|
+
constructor(adb) {
|
|
40
|
+
super();
|
|
41
|
+
this.adb = adb;
|
|
42
|
+
this.addDisposable(this.adb.onIncomingSocket(this.handleIncomingSocket));
|
|
43
|
+
}
|
|
44
|
+
handleIncomingSocket = async (socket) => {
|
|
45
|
+
let address = socket.serviceString;
|
|
46
|
+
// ADB daemon appends `\0` to the service string
|
|
47
|
+
address = address.replace(/\0/g, "");
|
|
48
|
+
return !!(await this.localAddressToHandler.get(address)?.(socket));
|
|
49
|
+
};
|
|
50
|
+
async createBufferedStream(service) {
|
|
51
|
+
const socket = await this.adb.createSocket(service);
|
|
52
|
+
return new BufferedReadableStream(socket.readable);
|
|
53
|
+
}
|
|
54
|
+
async sendRequest(service) {
|
|
55
|
+
const stream = await this.createBufferedStream(service);
|
|
56
|
+
const success = decodeUtf8(await stream.read(4)) === "OKAY";
|
|
57
|
+
if (!success) {
|
|
58
|
+
await AdbReverseErrorResponse.deserialize(stream);
|
|
59
|
+
}
|
|
60
|
+
return stream;
|
|
61
|
+
}
|
|
62
|
+
async list() {
|
|
63
|
+
const stream = await this.createBufferedStream("reverse:list-forward");
|
|
64
|
+
const response = await AdbReverseStringResponse.deserialize(stream);
|
|
65
|
+
return response.content.split("\n").map((line) => {
|
|
66
|
+
const [deviceSerial, localName, remoteName] = line.split(" ");
|
|
67
|
+
return { deviceSerial, localName, remoteName };
|
|
68
|
+
});
|
|
69
|
+
// No need to close the stream, device will close it
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @param deviceAddress
|
|
73
|
+
* The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
|
|
74
|
+
* @param localAddress
|
|
75
|
+
* An identifier for the reverse tunnel.
|
|
76
|
+
*
|
|
77
|
+
* When a socket wants to connect to {@link deviceAddress}, native ADB client will forward that connection to {@link localAddress}.
|
|
78
|
+
* However in this library, the {@link handler} is invoked instead. So this parameter is only used to identify the reverse tunnel.
|
|
79
|
+
* @param handler A callback to handle incoming connections. It must return `true` if it accepts the connection.
|
|
80
|
+
* @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
|
|
81
|
+
* @throws {AdbReverseNotSupportedError} If ADB reverse tunnel is not supported on this device when connected wirelessly.
|
|
82
|
+
* @throws {AdbReverseError} If ADB daemon returns an error.
|
|
83
|
+
*/
|
|
84
|
+
async add(deviceAddress, localAddress, handler) {
|
|
85
|
+
const stream = await this.sendRequest(`reverse:forward:${deviceAddress};${localAddress}`);
|
|
86
|
+
// `tcp:0` tells the device to pick an available port.
|
|
87
|
+
// On Android >=8, device will respond with the selected port for all `tcp:` requests.
|
|
88
|
+
if (deviceAddress.startsWith("tcp:")) {
|
|
89
|
+
let length;
|
|
90
|
+
try {
|
|
91
|
+
length = Number.parseInt(decodeUtf8(await stream.read(4)), 16);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
if (!(e instanceof BufferedReadableStreamEndedError)) {
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
// Android <8 doesn't have this response.
|
|
98
|
+
// (the stream is closed now)
|
|
99
|
+
// Can be safely ignored.
|
|
100
|
+
}
|
|
101
|
+
if (length !== undefined) {
|
|
102
|
+
const port = decodeUtf8(await stream.read(length));
|
|
103
|
+
deviceAddress = `tcp:${Number.parseInt(port, 10)}`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
this.localAddressToHandler.set(localAddress, handler);
|
|
107
|
+
this.deviceAddressToLocalAddress.set(deviceAddress, localAddress);
|
|
108
|
+
return deviceAddress;
|
|
109
|
+
// No need to close the stream, device will close it
|
|
110
|
+
}
|
|
111
|
+
async remove(deviceAddress) {
|
|
112
|
+
await this.sendRequest(`reverse:killforward:${deviceAddress}`);
|
|
113
|
+
if (this.deviceAddressToLocalAddress.has(deviceAddress)) {
|
|
114
|
+
this.localAddressToHandler.delete(this.deviceAddressToLocalAddress.get(deviceAddress));
|
|
115
|
+
this.deviceAddressToLocalAddress.delete(deviceAddress);
|
|
116
|
+
}
|
|
117
|
+
// No need to close the stream, device will close it
|
|
118
|
+
}
|
|
119
|
+
async removeAll() {
|
|
120
|
+
await this.sendRequest(`reverse:killforward-all`);
|
|
121
|
+
this.deviceAddressToLocalAddress.clear();
|
|
122
|
+
this.localAddressToHandler.clear();
|
|
123
|
+
// No need to close the stream, device will close it
|
|
124
|
+
}
|
|
125
|
+
}
|
|
99
126
|
//# sourceMappingURL=reverse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACH,sBAAsB,EACtB,gCAAgC,GACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAIvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,MAAM,wBAAwB,GAAG,IAAI,MAAM,EAAE;KACxC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAC/B,MAAM,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;AAExE,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtC,YAAmB,OAAe;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACJ;AAED,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAClD;QACI,KAAK,CACD,+EAA+E,CAClF,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;CACJ;AAED,MAAM,uBAAuB,GAAG,IAAI,MAAM,EAAE;KACvC,MAAM,CAAC,wBAAwB,CAAC;KAChC,eAAe,CAAC,CAAC,KAAK,EAAE,EAAE;IACvB,kDAAkD;IAClD,4FAA4F;IAC5F,oEAAoE;IACpE,IAAI,KAAK,CAAC,OAAO,KAAK,+BAA+B,EAAE;QACnD,MAAM,IAAI,2BAA2B,EAAE,CA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I,MAAM,KAAK,SAAS,EAAE;gBACtB,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;gBACnD,aAAa,GAAG,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;aACtD;SACJ;QAED,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAClE,OAAO,aAAa,CAAC;QAErB,oDAAoD;IACxD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,aAAqB;QACrC,MAAM,IAAI,CAAC,WAAW,CAAC,uBAAuB,aAAa,EAAE,CAAC,CAAC;QAE/D,IAAI,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACrD,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAC7B,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,aAAa,CAAE,CACvD,CAAC;YACF,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;SAC1D;QAED,oDAAoD;IACxD,CAAC;IAEM,KAAK,CAAC,SAAS;QAClB,MAAM,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;QAElD,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QAEnC,oDAAoD;IACxD,CAAC;CACJ"}
|
|
@@ -1,52 +1,58 @@
|
|
|
1
|
-
import { AdbCommandBase } from
|
|
2
|
-
import { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from
|
|
3
|
-
export interface AdbSubprocessOptions {
|
|
4
|
-
/**
|
|
5
|
-
* A list of `AdbSubprocessProtocolConstructor`s to be used.
|
|
6
|
-
*
|
|
7
|
-
* Different `AdbSubprocessProtocol` has different capabilities, thus requires specific adaptations.
|
|
8
|
-
* Check their documentations for details.
|
|
9
|
-
*
|
|
10
|
-
* The first protocol whose `isSupported` returns `true` will be used.
|
|
11
|
-
* If no `AdbSubprocessProtocol` is supported, an error will be thrown.
|
|
12
|
-
*
|
|
13
|
-
* @default [AdbSubprocessShellProtocol, AdbSubprocessNoneProtocol]
|
|
14
|
-
*/
|
|
15
|
-
protocols: AdbSubprocessProtocolConstructor[];
|
|
16
|
-
}
|
|
17
|
-
export interface AdbSubprocessWaitResult {
|
|
18
|
-
stdout: string;
|
|
19
|
-
stderr: string;
|
|
20
|
-
exitCode: number;
|
|
21
|
-
}
|
|
22
|
-
export declare class AdbSubprocess extends AdbCommandBase {
|
|
23
|
-
private createProtocol;
|
|
24
|
-
/**
|
|
25
|
-
* Spawns an executable in PTY
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
* @param
|
|
41
|
-
* @
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
48
|
-
* @returns The entire output of the command
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { AdbCommandBase } from "../base.js";
|
|
2
|
+
import type { AdbSubprocessProtocol, AdbSubprocessProtocolConstructor } from "./protocols/index.js";
|
|
3
|
+
export interface AdbSubprocessOptions {
|
|
4
|
+
/**
|
|
5
|
+
* A list of `AdbSubprocessProtocolConstructor`s to be used.
|
|
6
|
+
*
|
|
7
|
+
* Different `AdbSubprocessProtocol` has different capabilities, thus requires specific adaptations.
|
|
8
|
+
* Check their documentations for details.
|
|
9
|
+
*
|
|
10
|
+
* The first protocol whose `isSupported` returns `true` will be used.
|
|
11
|
+
* If no `AdbSubprocessProtocol` is supported, an error will be thrown.
|
|
12
|
+
*
|
|
13
|
+
* @default [AdbSubprocessShellProtocol, AdbSubprocessNoneProtocol]
|
|
14
|
+
*/
|
|
15
|
+
protocols: AdbSubprocessProtocolConstructor[];
|
|
16
|
+
}
|
|
17
|
+
export interface AdbSubprocessWaitResult {
|
|
18
|
+
stdout: string;
|
|
19
|
+
stderr: string;
|
|
20
|
+
exitCode: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class AdbSubprocess extends AdbCommandBase {
|
|
23
|
+
private createProtocol;
|
|
24
|
+
/**
|
|
25
|
+
* Spawns an executable in PTY mode.
|
|
26
|
+
*
|
|
27
|
+
* Redirection mode is enough for most simple commands, but PTY mode is required for
|
|
28
|
+
* commands that manipulate the terminal, such as `vi` and `less`.
|
|
29
|
+
* @param command The command to run. If omitted, the default shell will be spawned.
|
|
30
|
+
* @param options The options for creating the `AdbSubprocessProtocol`
|
|
31
|
+
* @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
|
|
32
|
+
*/
|
|
33
|
+
shell(command?: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessProtocol>;
|
|
34
|
+
/**
|
|
35
|
+
* Spawns an executable and redirect the standard input/output stream.
|
|
36
|
+
*
|
|
37
|
+
* Redirection mode is enough for most simple commands, but PTY mode is required for
|
|
38
|
+
* commands that manipulate the terminal, such as `vi` and `less`.
|
|
39
|
+
* @param command The command to run, or an array of strings containing both command and args.
|
|
40
|
+
* @param options The options for creating the `AdbSubprocessProtocol`
|
|
41
|
+
* @returns A new `AdbSubprocessProtocol` instance connecting to the spawned process.
|
|
42
|
+
*/
|
|
43
|
+
spawn(command: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessProtocol>;
|
|
44
|
+
/**
|
|
45
|
+
* Spawns a new process, waits until it exits, and returns the entire output.
|
|
46
|
+
* @param command The command to run
|
|
47
|
+
* @param options The options for creating the `AdbSubprocessProtocol`
|
|
48
|
+
* @returns The entire output of the command
|
|
49
|
+
*/
|
|
50
|
+
spawnAndWait(command: string | string[], options?: Partial<AdbSubprocessOptions>): Promise<AdbSubprocessWaitResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Spawns a new process, waits until it exits, and returns the entire output.
|
|
53
|
+
* @param command The command to run
|
|
54
|
+
* @returns The entire output of the command
|
|
55
|
+
*/
|
|
56
|
+
spawnAndWaitLegacy(command: string | string[]): Promise<string>;
|
|
57
|
+
}
|
|
52
58
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/subprocess/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EACR,qBAAqB,EACrB,gCAAgC,EACnC,MAAM,sBAAsB,CAAC;AAM9B,MAAM,WAAW,oBAAoB;IACjC;;;;;;;;;;OAUG;IACH,SAAS,EAAE,gCAAgC,EAAE,CAAC;CACjD;AAMD,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,aAAc,SAAQ,cAAc;YAC/B,cAAc;IA6B5B;;;;;;;;OAQG;IACI,KAAK,CACR,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;;;;OAQG;IACI,KAAK,CACR,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;OAKG;IACU,YAAY,CACrB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,uBAAuB,CAAC;IAmBnC;;;;OAIG;IACU,kBAAkB,CAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAC3B,OAAO,CAAC,MAAM,CAAC;CAMrB"}
|