@yume-chan/adb 0.0.11 → 0.0.14
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 +39 -0
- package/CHANGELOG.md +23 -1
- package/README.md +24 -17
- package/esm/adb.d.ts +10 -9
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +87 -64
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +6 -6
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +8 -6
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +2 -2
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +5 -7
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/reverse.d.ts +7 -10
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +9 -15
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +19 -20
- package/esm/commands/subprocess/index.d.ts.map +1 -1
- package/esm/commands/subprocess/index.js +36 -31
- package/esm/commands/subprocess/index.js.map +1 -1
- package/esm/commands/subprocess/legacy.d.ts +14 -7
- package/esm/commands/subprocess/legacy.d.ts.map +1 -1
- package/esm/commands/subprocess/legacy.js +14 -5
- package/esm/commands/subprocess/legacy.js.map +1 -1
- package/esm/commands/subprocess/protocol.d.ts +3 -2
- package/esm/commands/subprocess/protocol.d.ts.map +1 -1
- package/esm/commands/subprocess/protocol.js +6 -4
- package/esm/commands/subprocess/protocol.js.map +1 -1
- package/esm/commands/subprocess/protocols/index.d.ts +4 -0
- package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/index.js +4 -0
- package/esm/commands/subprocess/protocols/index.js.map +1 -0
- package/esm/commands/subprocess/protocols/none.d.ts +35 -0
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/none.js +53 -0
- package/esm/commands/subprocess/protocols/none.js.map +1 -0
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -0
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/shell.js +155 -0
- package/esm/commands/subprocess/protocols/shell.js.map +1 -0
- package/esm/commands/subprocess/protocols/types.d.ts +50 -0
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/types.js +2 -0
- package/esm/commands/subprocess/protocols/types.js.map +1 -0
- package/esm/commands/subprocess/types.d.ts +9 -6
- package/esm/commands/subprocess/types.d.ts.map +1 -1
- package/esm/commands/sync/list.d.ts +25 -1
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +40 -5
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +6 -3
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/request.d.ts +1 -0
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +1 -0
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +2 -1
- 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 +13 -1
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +20 -7
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +13 -35
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +39 -9
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/crypto.d.ts +23 -10
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +64 -46
- package/esm/crypto.js.map +1 -1
- package/esm/features.d.ts +4 -2
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +6 -2
- package/esm/features.js.map +1 -1
- package/esm/packet.d.ts +21 -2
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +2 -2
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +34 -23
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +92 -70
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/socket.d.ts +29 -8
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +41 -27
- package/esm/socket/socket.js.map +1 -1
- package/esm/stream/detect.d.ts +1 -17
- package/esm/stream/detect.d.ts.map +1 -1
- package/esm/stream/detect.js +4 -5
- package/esm/stream/detect.js.map +1 -1
- package/esm/stream/detect.polyfill.d.ts.map +1 -1
- package/esm/stream/detect.polyfill.js +4 -1
- package/esm/stream/detect.polyfill.js.map +1 -1
- package/esm/stream/transform.d.ts +37 -32
- package/esm/stream/transform.d.ts.map +1 -1
- package/esm/stream/transform.js +106 -92
- package/esm/stream/transform.js.map +1 -1
- package/esm/utils/encoding.d.ts.map +1 -1
- package/esm/utils/encoding.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/package.json +6 -6
- package/src/adb.ts +105 -76
- package/src/auth.ts +21 -18
- package/src/backend.ts +2 -2
- package/src/commands/install.ts +7 -9
- package/src/commands/reverse.ts +13 -24
- package/src/commands/subprocess/index.ts +57 -42
- package/src/commands/subprocess/protocols/index.ts +3 -0
- package/src/commands/subprocess/{legacy.ts → protocols/none.ts} +20 -10
- package/src/commands/subprocess/{protocol.ts → protocols/shell.ts} +22 -17
- package/src/commands/subprocess/{types.ts → protocols/types.ts} +13 -9
- package/src/commands/sync/list.ts +51 -5
- package/src/commands/sync/pull.ts +6 -3
- package/src/commands/sync/request.ts +1 -0
- package/src/commands/sync/response.ts +8 -2
- package/src/commands/sync/stat.ts +36 -9
- package/src/commands/sync/sync.ts +55 -19
- package/src/crypto.ts +72 -56
- package/src/features.ts +6 -2
- package/src/packet.ts +17 -6
- package/src/socket/dispatcher.ts +133 -88
- package/src/socket/socket.ts +61 -48
- package/src/stream/detect.polyfill.ts +4 -1
- package/src/stream/detect.ts +4 -24
- package/src/stream/transform.ts +133 -116
- package/src/utils/index.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/utils/encoding.ts +0 -13
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// cspell: ignore ponyfill
|
|
2
|
-
// TODO:
|
|
2
|
+
// TODO: Upgrade to `web-streams-polyfill@4.0.0-beta.2` once released.
|
|
3
|
+
// `web-streams-polyfill@4.0.0-beta.1` changed the default export to ponyfill,
|
|
4
|
+
// But it forgot to include `type` export so it's unusable.
|
|
5
|
+
// See https://github.com/MattiasBuelens/web-streams-polyfill/pull/107
|
|
3
6
|
export * from 'web-streams-polyfill';
|
|
4
7
|
export let AbortController;
|
|
5
8
|
({ AbortController } = globalThis);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.polyfill.js","sourceRoot":"","sources":["../../src/stream/detect.polyfill.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAG1B,
|
|
1
|
+
{"version":3,"file":"detect.polyfill.js","sourceRoot":"","sources":["../../src/stream/detect.polyfill.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAG1B,sEAAsE;AACtE,8EAA8E;AAC9E,2DAA2D;AAC3D,sEAAsE;AACtE,cAAc,sBAAsB,CAAC;AAerC,MAAM,CAAC,IAAI,eAGV,CAAC;AAEF,CAAC,EAAE,eAAe,EAAE,GAAG,UAAiB,CAAC,CAAC"}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import type Struct from "@yume-chan/struct";
|
|
2
|
-
import type { StructValueType } from "@yume-chan/struct";
|
|
3
|
-
import { AbortSignal, ReadableStream, TransformStream, WritableStream, type QueuingStrategy, type
|
|
2
|
+
import type { StructValueType, ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
+
import { AbortSignal, ReadableStream, TransformStream, WritableStream, type QueuingStrategy, type ReadableStreamDefaultController, type ReadableWritablePair, type UnderlyingSink } from "./detect.js";
|
|
4
4
|
export interface DuplexStreamFactoryOptions {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
close?: (() => ValueOrPromise<boolean | void>) | undefined;
|
|
6
|
+
dispose?: (() => void | Promise<void>) | undefined;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A factory for creating a duplex stream.
|
|
10
|
+
*
|
|
11
|
+
* It can create multiple `ReadableStream`s and `WritableStream`s,
|
|
12
|
+
* when any of them is closed, all other streams will be closed as well.
|
|
13
|
+
*/
|
|
8
14
|
export declare class DuplexStreamFactory<R, W> {
|
|
9
15
|
private readableControllers;
|
|
10
|
-
private
|
|
16
|
+
private _writableClosed;
|
|
17
|
+
get writableClosed(): boolean;
|
|
11
18
|
private _closed;
|
|
12
19
|
get closed(): Promise<void>;
|
|
13
20
|
private options;
|
|
14
|
-
private _closeRequestedByReadable;
|
|
15
|
-
private _writableClosed;
|
|
16
21
|
constructor(options?: DuplexStreamFactoryOptions);
|
|
17
|
-
|
|
18
|
-
createWrapReadable(readable: ReadableStream<R>): WrapReadableStream<R, ReadableStream<R>, void>;
|
|
19
|
-
createReadable(source?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
|
22
|
+
wrapReadable(readable: ReadableStream<R>): WrapReadableStream<R>;
|
|
20
23
|
createWritable(sink: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
|
21
|
-
closeReadableStreams(): Promise<void>;
|
|
22
24
|
close(): Promise<void>;
|
|
25
|
+
dispose(): Promise<void>;
|
|
23
26
|
}
|
|
24
27
|
export declare class DecodeUtf8Stream extends TransformStream<Uint8Array, string> {
|
|
25
28
|
constructor();
|
|
26
29
|
}
|
|
27
|
-
export declare class GatherStringStream extends
|
|
30
|
+
export declare class GatherStringStream extends WritableStream<string> {
|
|
28
31
|
private _result;
|
|
29
32
|
get result(): string;
|
|
30
33
|
constructor();
|
|
@@ -39,31 +42,33 @@ export declare class StructDeserializeStream<T extends Struct<any, any, any, any
|
|
|
39
42
|
export declare class StructSerializeStream<T extends Struct<any, any, any, any>> extends TransformStream<T['TInit'], Uint8Array> {
|
|
40
43
|
constructor(struct: T);
|
|
41
44
|
}
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}>;
|
|
47
|
-
close?(state: S): Promise<void>;
|
|
45
|
+
export declare type WrapWritableStreamStart<T> = () => ValueOrPromise<WritableStream<T>>;
|
|
46
|
+
export interface WritableStreamWrapper<T> {
|
|
47
|
+
start: WrapWritableStreamStart<T>;
|
|
48
|
+
close?(): Promise<void>;
|
|
48
49
|
}
|
|
49
|
-
export declare class WrapWritableStream<T
|
|
50
|
-
writable:
|
|
50
|
+
export declare class WrapWritableStream<T> extends WritableStream<T> {
|
|
51
|
+
writable: WritableStream<T>;
|
|
51
52
|
private writer;
|
|
52
|
-
|
|
53
|
-
constructor(wrapper: WritableStreamWrapper<T, W, S>);
|
|
53
|
+
constructor(wrapper: WritableStream<T> | WrapWritableStreamStart<T> | WritableStreamWrapper<T>);
|
|
54
54
|
}
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
close?(state: S): Promise<void>;
|
|
55
|
+
export declare type WrapReadableStreamStart<T> = (controller: ReadableStreamDefaultController<T>) => ValueOrPromise<ReadableStream<T>>;
|
|
56
|
+
export interface ReadableStreamWrapper<T> {
|
|
57
|
+
start: WrapReadableStreamStart<T>;
|
|
58
|
+
cancel?(reason?: any): ValueOrPromise<void>;
|
|
59
|
+
close?(): ValueOrPromise<void>;
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
/**
|
|
62
|
+
* This class has multiple usages:
|
|
63
|
+
*
|
|
64
|
+
* 1. Get notified when the stream is cancelled or closed.
|
|
65
|
+
* 2. Synchronously create a `ReadableStream` by asynchronously return another `ReadableStream`.
|
|
66
|
+
* 3. Convert native `ReadableStream`s to polyfilled ones so they can `pipe` between.
|
|
67
|
+
*/
|
|
68
|
+
export declare class WrapReadableStream<T> extends ReadableStream<T> {
|
|
69
|
+
readable: ReadableStream<T>;
|
|
64
70
|
private reader;
|
|
65
|
-
|
|
66
|
-
constructor(wrapper: ReadableStreamWrapper<T, R, S>);
|
|
71
|
+
constructor(wrapper: ReadableStream<T> | WrapReadableStreamStart<T> | ReadableStreamWrapper<T>);
|
|
67
72
|
}
|
|
68
73
|
export declare class ChunkStream extends TransformStream<Uint8Array, Uint8Array> {
|
|
69
74
|
constructor(size: number);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAmB,WAAW,EAAE,cAAc,EAA+B,eAAe,EAAE,cAAc,EAA+B,KAAK,eAAe,EAAE,KAAK,+BAA+B,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAElR,MAAM,WAAW,0BAA0B;IACvC,KAAK,CAAC,EAAE,CAAC,MAAM,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IAE3D,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CACtD;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB,CAAC,CAAC,EA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AWlC;AAkBD,qBAAa,eAAgB,SAAQ,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC;;CAUnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,qBAc3F;AAED,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI;CAQ3C;AAED,MAAM,WAAW,4BAA4B,CAAC,CAAC;IAC3C,WAAW,EAAE,WAAW,CAAC;IAEzB,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC,KAAK,IAAI,IAAI,CAAC;IAEd,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CACxB;AAED,oBAAY,wBAAwB,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,4BAA4B,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEhG,qBAAa,kBAAkB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;gBACrC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;CAuCxF"}
|
package/esm/stream/transform.js
CHANGED
|
@@ -2,74 +2,41 @@ import { PromiseResolver } from "@yume-chan/async";
|
|
|
2
2
|
import { decodeUtf8 } from "../utils/index.js";
|
|
3
3
|
import { BufferedStream, BufferedStreamEndedError } from "./buffered.js";
|
|
4
4
|
import { AbortController, ReadableStream, TransformStream, WritableStream } from "./detect.js";
|
|
5
|
+
/**
|
|
6
|
+
* A factory for creating a duplex stream.
|
|
7
|
+
*
|
|
8
|
+
* It can create multiple `ReadableStream`s and `WritableStream`s,
|
|
9
|
+
* when any of them is closed, all other streams will be closed as well.
|
|
10
|
+
*/
|
|
5
11
|
export class DuplexStreamFactory {
|
|
6
12
|
readableControllers = [];
|
|
7
|
-
|
|
13
|
+
_writableClosed = false;
|
|
14
|
+
get writableClosed() { return this._writableClosed; }
|
|
8
15
|
_closed = new PromiseResolver();
|
|
9
16
|
get closed() { return this._closed.promise; }
|
|
10
17
|
options;
|
|
11
|
-
_closeRequestedByReadable = false;
|
|
12
|
-
_writableClosed = false;
|
|
13
18
|
constructor(options) {
|
|
14
19
|
this.options = options ?? {};
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
return new PushReadableStream(controller => {
|
|
18
|
-
this.pushReadableControllers.push(controller);
|
|
19
|
-
controller.abortSignal.addEventListener('abort', async () => {
|
|
20
|
-
this._closeRequestedByReadable = true;
|
|
21
|
-
await this.close();
|
|
22
|
-
});
|
|
23
|
-
source({
|
|
24
|
-
abortSignal: controller.abortSignal,
|
|
25
|
-
async enqueue(chunk) {
|
|
26
|
-
await controller.enqueue(chunk);
|
|
27
|
-
},
|
|
28
|
-
close: async () => {
|
|
29
|
-
controller.close();
|
|
30
|
-
this._closeRequestedByReadable = true;
|
|
31
|
-
await this.close();
|
|
32
|
-
},
|
|
33
|
-
error: async (e) => {
|
|
34
|
-
controller.error(e);
|
|
35
|
-
this._closeRequestedByReadable = true;
|
|
36
|
-
await this.close();
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}, strategy);
|
|
40
|
-
}
|
|
41
|
-
;
|
|
42
|
-
createWrapReadable(readable) {
|
|
21
|
+
wrapReadable(readable) {
|
|
43
22
|
return new WrapReadableStream({
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
readable,
|
|
47
|
-
state: undefined,
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
close: async () => {
|
|
51
|
-
this._closeRequestedByReadable = true;
|
|
52
|
-
await this.close();
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
createReadable(source, strategy) {
|
|
57
|
-
return new ReadableStream({
|
|
58
|
-
start: async (controller) => {
|
|
23
|
+
start: (controller) => {
|
|
59
24
|
this.readableControllers.push(controller);
|
|
60
|
-
|
|
25
|
+
return readable;
|
|
61
26
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
cancel: async (reason) => {
|
|
66
|
-
await source?.cancel?.(reason);
|
|
67
|
-
this._closeRequestedByReadable = true;
|
|
27
|
+
cancel: async () => {
|
|
28
|
+
// cancel means the local peer closes the connection first.
|
|
68
29
|
await this.close();
|
|
69
30
|
},
|
|
70
|
-
|
|
31
|
+
close: async () => {
|
|
32
|
+
// stream end means the remote peer closed the connection first.
|
|
33
|
+
await this.dispose();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
71
36
|
}
|
|
72
37
|
createWritable(sink, strategy) {
|
|
38
|
+
// `WritableStream` has no way to tell if the remote peer has closed the connection.
|
|
39
|
+
// So it only triggers `close`.
|
|
73
40
|
return new WritableStream({
|
|
74
41
|
start: async (controller) => {
|
|
75
42
|
await sink.start?.(controller);
|
|
@@ -80,38 +47,36 @@ export class DuplexStreamFactory {
|
|
|
80
47
|
}
|
|
81
48
|
await sink.write?.(chunk, controller);
|
|
82
49
|
},
|
|
83
|
-
close: async () => {
|
|
84
|
-
await sink.close?.();
|
|
85
|
-
this.close();
|
|
86
|
-
},
|
|
87
50
|
abort: async (reason) => {
|
|
88
51
|
await sink.abort?.(reason);
|
|
89
52
|
await this.close();
|
|
90
53
|
},
|
|
54
|
+
close: async () => {
|
|
55
|
+
await sink.close?.();
|
|
56
|
+
await this.close();
|
|
57
|
+
},
|
|
91
58
|
}, strategy);
|
|
92
59
|
}
|
|
93
|
-
async
|
|
60
|
+
async close() {
|
|
61
|
+
if (this._writableClosed) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._writableClosed = true;
|
|
65
|
+
if (await this.options.close?.() !== false) {
|
|
66
|
+
// `close` can return `false` to disable automatic `dispose`.
|
|
67
|
+
await this.dispose();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async dispose() {
|
|
71
|
+
this._writableClosed = true;
|
|
94
72
|
this._closed.resolve();
|
|
95
|
-
await this.options.close?.();
|
|
96
73
|
for (const controller of this.readableControllers) {
|
|
97
74
|
try {
|
|
98
75
|
controller.close();
|
|
99
76
|
}
|
|
100
77
|
catch { }
|
|
101
78
|
}
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
controller.close();
|
|
105
|
-
}
|
|
106
|
-
catch { }
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async close() {
|
|
110
|
-
this._writableClosed = true;
|
|
111
|
-
if (this._closeRequestedByReadable ||
|
|
112
|
-
!this.options.preventCloseReadableStreams) {
|
|
113
|
-
await this.closeReadableStreams();
|
|
114
|
-
}
|
|
79
|
+
await this.options.dispose?.();
|
|
115
80
|
}
|
|
116
81
|
}
|
|
117
82
|
export class DecodeUtf8Stream extends TransformStream {
|
|
@@ -123,19 +88,19 @@ export class DecodeUtf8Stream extends TransformStream {
|
|
|
123
88
|
});
|
|
124
89
|
}
|
|
125
90
|
}
|
|
126
|
-
export class GatherStringStream extends
|
|
91
|
+
export class GatherStringStream extends WritableStream {
|
|
127
92
|
// Optimization: rope (concat strings) is faster than `[].join('')`
|
|
128
93
|
_result = '';
|
|
129
94
|
get result() { return this._result; }
|
|
130
95
|
constructor() {
|
|
131
96
|
super({
|
|
132
|
-
|
|
97
|
+
write: (chunk) => {
|
|
133
98
|
this._result += chunk;
|
|
134
99
|
},
|
|
135
100
|
});
|
|
136
101
|
}
|
|
137
102
|
}
|
|
138
|
-
// TODO:
|
|
103
|
+
// TODO: StructTransformStream: Looking for better implementation
|
|
139
104
|
export class StructDeserializeStream {
|
|
140
105
|
_readable;
|
|
141
106
|
get readable() { return this._readable; }
|
|
@@ -182,17 +147,32 @@ export class StructSerializeStream extends TransformStream {
|
|
|
182
147
|
});
|
|
183
148
|
}
|
|
184
149
|
}
|
|
150
|
+
async function getWrappedWritableStream(wrapper) {
|
|
151
|
+
if ('start' in wrapper) {
|
|
152
|
+
return await wrapper.start();
|
|
153
|
+
}
|
|
154
|
+
else if (typeof wrapper === 'function') {
|
|
155
|
+
return await wrapper();
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Can't use `wrapper instanceof WritableStream`
|
|
159
|
+
// Because we want to be compatible with any WritableStream-like objects
|
|
160
|
+
return wrapper;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
185
163
|
export class WrapWritableStream extends WritableStream {
|
|
186
164
|
writable;
|
|
187
165
|
writer;
|
|
188
|
-
state;
|
|
189
166
|
constructor(wrapper) {
|
|
190
167
|
super({
|
|
191
168
|
start: async () => {
|
|
192
|
-
|
|
193
|
-
this
|
|
194
|
-
this
|
|
195
|
-
this.
|
|
169
|
+
// `start` is invoked before `ReadableStream`'s constructor finish,
|
|
170
|
+
// so using `this` synchronously causes
|
|
171
|
+
// "Must call super constructor in derived class before accessing 'this' or returning from derived constructor".
|
|
172
|
+
// Queue a microtask to avoid this.
|
|
173
|
+
await Promise.resolve();
|
|
174
|
+
this.writable = await getWrappedWritableStream(wrapper);
|
|
175
|
+
this.writer = this.writable.getWriter();
|
|
196
176
|
},
|
|
197
177
|
write: async (chunk) => {
|
|
198
178
|
// Maintain back pressure
|
|
@@ -201,36 +181,70 @@ export class WrapWritableStream extends WritableStream {
|
|
|
201
181
|
},
|
|
202
182
|
abort: async (reason) => {
|
|
203
183
|
await this.writer.abort(reason);
|
|
204
|
-
wrapper
|
|
184
|
+
if ('close' in wrapper) {
|
|
185
|
+
await wrapper.close?.();
|
|
186
|
+
}
|
|
205
187
|
},
|
|
206
188
|
close: async () => {
|
|
189
|
+
// Close the inner stream first.
|
|
190
|
+
// Usually the inner stream is a logical sub-stream over the outer stream,
|
|
191
|
+
// closing the outer stream first will make the inner stream incapable of
|
|
192
|
+
// sending data in its `close` handler.
|
|
207
193
|
await this.writer.close();
|
|
208
|
-
|
|
194
|
+
if ('close' in wrapper) {
|
|
195
|
+
await wrapper.close?.();
|
|
196
|
+
}
|
|
209
197
|
},
|
|
210
198
|
});
|
|
211
199
|
}
|
|
212
200
|
}
|
|
201
|
+
function getWrappedReadableStream(wrapper, controller) {
|
|
202
|
+
if ('start' in wrapper) {
|
|
203
|
+
return wrapper.start(controller);
|
|
204
|
+
}
|
|
205
|
+
else if (typeof wrapper === 'function') {
|
|
206
|
+
return wrapper(controller);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// Can't use `wrapper instanceof ReadableStream`
|
|
210
|
+
// Because we want to be compatible with any ReadableStream-like objects
|
|
211
|
+
return wrapper;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* This class has multiple usages:
|
|
216
|
+
*
|
|
217
|
+
* 1. Get notified when the stream is cancelled or closed.
|
|
218
|
+
* 2. Synchronously create a `ReadableStream` by asynchronously return another `ReadableStream`.
|
|
219
|
+
* 3. Convert native `ReadableStream`s to polyfilled ones so they can `pipe` between.
|
|
220
|
+
*/
|
|
213
221
|
export class WrapReadableStream extends ReadableStream {
|
|
214
222
|
readable;
|
|
215
223
|
reader;
|
|
216
|
-
state;
|
|
217
224
|
constructor(wrapper) {
|
|
218
225
|
super({
|
|
219
|
-
start: async () => {
|
|
220
|
-
|
|
221
|
-
this
|
|
222
|
-
this
|
|
223
|
-
this.
|
|
226
|
+
start: async (controller) => {
|
|
227
|
+
// `start` is invoked before `ReadableStream`'s constructor finish,
|
|
228
|
+
// so using `this` synchronously causes
|
|
229
|
+
// "Must call super constructor in derived class before accessing 'this' or returning from derived constructor".
|
|
230
|
+
// Queue a microtask to avoid this.
|
|
231
|
+
await Promise.resolve();
|
|
232
|
+
this.readable = await getWrappedReadableStream(wrapper, controller);
|
|
233
|
+
this.reader = this.readable.getReader();
|
|
224
234
|
},
|
|
225
235
|
cancel: async (reason) => {
|
|
226
236
|
await this.reader.cancel(reason);
|
|
227
|
-
wrapper
|
|
237
|
+
if ('cancel' in wrapper) {
|
|
238
|
+
await wrapper.cancel?.(reason);
|
|
239
|
+
}
|
|
228
240
|
},
|
|
229
241
|
pull: async (controller) => {
|
|
230
242
|
const result = await this.reader.read();
|
|
231
243
|
if (result.done) {
|
|
232
|
-
wrapper.close?.(this.state);
|
|
233
244
|
controller.close();
|
|
245
|
+
if ('close' in wrapper) {
|
|
246
|
+
await wrapper.close?.();
|
|
247
|
+
}
|
|
234
248
|
}
|
|
235
249
|
else {
|
|
236
250
|
controller.enqueue(result.value);
|
|
@@ -319,7 +333,7 @@ export class PushReadableStream extends ReadableStream {
|
|
|
319
333
|
source({
|
|
320
334
|
abortSignal: canceled.signal,
|
|
321
335
|
async enqueue(chunk) {
|
|
322
|
-
// Only when the stream
|
|
336
|
+
// Only when the stream is errored, `desiredSize` will be `null`.
|
|
323
337
|
// But since `null <= 0` is `true`
|
|
324
338
|
// (`null <= 0` is evaluated as `!(null > 0)` => `!false` => `true`),
|
|
325
339
|
// not handling it will cause a deadlock.
|
|
@@ -343,8 +357,8 @@ export class PushReadableStream extends ReadableStream {
|
|
|
343
357
|
waterMarkLow?.resolve();
|
|
344
358
|
},
|
|
345
359
|
cancel: async (reason) => {
|
|
346
|
-
waterMarkLow?.reject(reason);
|
|
347
360
|
canceled.abort();
|
|
361
|
+
waterMarkLow?.reject(reason);
|
|
348
362
|
},
|
|
349
363
|
}, strategy);
|
|
350
364
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAe,cAAc,EAA+B,eAAe,EAAE,c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wBACH,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBACxB,CAAC;iBACJ,CAAC,CAAC;YACP,CAAC;YACD,IAAI,EAAE,GAAG,EAAE;gBACP,YAAY,EAAE,OAAO,EAAE,CAAC;YAC5B,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBACrB,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACjB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;SACJ,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,MAAM,CAExE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqC;IAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
package/esm/utils/index.d.ts
CHANGED
package/esm/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
package/esm/utils/index.js
CHANGED
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"types": "esm/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@yume-chan/async": "^2.1.4",
|
|
29
|
-
"@yume-chan/dataview-bigint-polyfill": "0.0.
|
|
30
|
-
"@yume-chan/event": "^0.0.
|
|
31
|
-
"@yume-chan/struct": "^0.0.
|
|
29
|
+
"@yume-chan/dataview-bigint-polyfill": "^0.0.14",
|
|
30
|
+
"@yume-chan/event": "^0.0.14",
|
|
31
|
+
"@yume-chan/struct": "^0.0.14",
|
|
32
32
|
"tslib": "^2.3.1",
|
|
33
33
|
"web-streams-polyfill": "^3.2.0"
|
|
34
34
|
},
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
40
|
"jest": "^27.5.1",
|
|
41
41
|
"ts-jest": "^27.1.3",
|
|
42
|
-
"typescript": "
|
|
42
|
+
"typescript": "4.7.0-beta"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc -b tsconfig.build.json",
|
|
46
46
|
"build:watch": "tsc -b tsconfig.build.json",
|
|
47
47
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
48
48
|
},
|
|
49
|
-
"readme": "# @yume-chan/adb\r\n\r\nTypeScript implementation of Android Debug Bridge (ADB) protocol.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n- [Compatibility](#compatibility)\r\n - [Basic usage](#basic-usage)\r\n - [Use without bundlers](#use-without-bundlers)\r\n- [Connection](#connection)\r\n - [Backend](#backend)\r\n - [`connect`](#connect)\r\n- [Authentication](#authentication)\r\n - [AdbCredentialStore](#adbcredentialstore)\r\n - [`generateKey`](#generatekey)\r\n - [`iterateKeys`](#iteratekeys)\r\n - [Implementations](#implementations)\r\n - [AdbAuthenticator](#adbauthenticator)\r\n - [`authenticate`](#authenticate)\r\n- [Stream multiplex](#stream-multiplex)\r\n - [
|
|
49
|
+
"readme": "# @yume-chan/adb\r\n\r\nTypeScript implementation of Android Debug Bridge (ADB) protocol.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n- [Compatibility](#compatibility)\r\n - [Basic usage](#basic-usage)\r\n - [Use without bundlers](#use-without-bundlers)\r\n- [Connection](#connection)\r\n - [Backend](#backend)\r\n - [`connect`](#connect)\r\n- [Authentication](#authentication)\r\n - [AdbCredentialStore](#adbcredentialstore)\r\n - [`generateKey`](#generatekey)\r\n - [`iterateKeys`](#iteratekeys)\r\n - [Implementations](#implementations)\r\n - [AdbAuthenticator](#adbauthenticator)\r\n - [`authenticate`](#authenticate)\r\n- [Stream multiplex](#stream-multiplex)\r\n- [Commands](#commands)\r\n - [subprocess](#subprocess)\r\n - [raw mode](#raw-mode)\r\n - [pty mode](#pty-mode)\r\n - [usb](#usb)\r\n - [tcpip](#tcpip)\r\n - [sync](#sync)\r\n - [LIST](#list)\r\n - [LIS2](#lis2)\r\n - [STAT](#stat)\r\n - [LST2](#lst2)\r\n - [STA2](#sta2)\r\n - [RECV](#recv)\r\n - [RCV2](#rcv2)\r\n - [SEND](#send)\r\n - [SND2](#snd2)\r\n- [Useful links](#useful-links)\r\n\r\n## Compatibility\r\n\r\nHere is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.\r\n\r\nSome features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.\r\n\r\nEach backend may have different requirements.\r\n\r\n### Basic usage\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |\r\n| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |\r\n| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |\r\n\r\n<sup>1</sup> `uint64` and `string` are used.\r\n\r\n<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.\r\n\r\n### Use without bundlers\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |\r\n| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |\r\n\r\n## Connection\r\n\r\nThis library doesn't tie to a specific transportation method.\r\n\r\nInstead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).\r\n\r\n### Backend\r\n\r\n#### `connect`\r\n\r\n```ts\r\nconnect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>\r\n```\r\n\r\nConnect to a device and create a pair of `AdbPacket` streams.\r\n\r\nThe backend, instead of the core library, is responsible for serializing and deserializing the packets. Because it's extreme slow for WebUSB backend (`@yume-chan/adb-backend-webusb`) to read packets with unknown size.\r\n\r\n## Authentication\r\n\r\nFor how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/webadb-part2-connection/#auth.\r\n\r\nIn this library, authentication comes in two parts:\r\n\r\n#### AdbCredentialStore\r\n\r\nAn interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)\r\n\r\n##### `generateKey`\r\n\r\n```ts\r\ngenerateKey(): ValueOrPromise<Uint8Array>\r\n```\r\n\r\nGenerate and store a RSA private key with modulus length `2048` and public exponent `65537`.\r\n\r\nThe returned `Uint8Array` is the private key in PKCS #8 format.\r\n\r\n##### `iterateKeys`\r\n\r\n```ts\r\niterateKeys(): Iterator<ArrayBuffer> | AsyncIterator<ArrayBuffer>\r\n```\r\n\r\nSynchronously or asynchronously iterate through all stored RSA private keys.\r\n\r\nEach call to `iterateKeys` must return a different iterator that iterate through all stored keys.\r\n\r\n##### Implementations\r\n\r\nThe `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.\r\n\r\n#### AdbAuthenticator\r\n\r\nAn `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from server.\r\n\r\nThis package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.\r\n\r\n#### `authenticate`\r\n\r\n```ts\r\nstatic async authenticate(\r\n connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,\r\n credentialStore: AdbCredentialStore,\r\n authenticators = AdbDefaultAuthenticators,\r\n): Promise<Adb>\r\n```\r\n\r\nCall this method to authenticate the connection and create an `Adb` instance.\r\n\r\nIf an authentication process failed, it's possible to call `authenticate` again on the same connection (`AdbPacket` stream pair). Every time the device receives a `CNXN` packet, it resets all internal state, and starts a new authentication process.\r\n\r\n## Stream multiplex\r\n\r\nADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.\r\n\r\n1. Client sends an `OPEN` packet to create a stream.\r\n2. Server responds with `OKAY` or `FAIL`.\r\n3. Client and server read/write on the stream.\r\n4. Client/server sends a `CLSE` to close the stream.\r\n\r\n## Commands\r\n\r\n### subprocess\r\n\r\nADB has two subprocess invocation modes and two data protocols (4 combinations).\r\n\r\n#### raw mode\r\n\r\nIn raw mode, Shell protocol transfers `stdout` and `stderr` separately. It also supports returning exit code.\r\n\r\n| | Legacy protocol | Shell Protocol |\r\n| --------------------------- | --------------------------- | ---------------------------- |\r\n| Feature flag | - | `shell_v2` |\r\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\r\n| Splitting stdout and stderr | No | Yes |\r\n| Returning exit code | No | Yes |\r\n\r\nUse `spawn` method to create a subprocess in raw mode.\r\n\r\n#### pty mode\r\n\r\nIn PTY mode, the subprocess has a pseudo-terminal, so it can send special control sequences like clear screen and set cursor position. The two protocols both send data in `stdout`, but Shell Protocol also supports resizing the terminal from client.\r\n\r\n| | Legacy protocol | Shell Protocol |\r\n| --------------------------- | --------------------------- | ---------------------------- |\r\n| Feature flag | - | `shell_v2` |\r\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\r\n| Resizing window | No | Yes |\r\n\r\nUse `shell` method to create a subprocess in PTY mode.\r\n\r\n### usb\r\n\r\nDisable ADB over WiFi.\r\n\r\n### tcpip\r\n\r\nEnable ADB over WiFi.\r\n\r\n### sync\r\n\r\nClient and server will communicate with another protocol on the opened stream.\r\n\r\n#### LIST\r\n\r\nRequest server to list the content of a folder.\r\n\r\n#### LIS2\r\n\r\nVersion 2 of the LIST command, contains more information.\r\n\r\nSupported on devices with `ls_v2` feature.\r\n\r\n#### STAT\r\n\r\nRequest server to return the information of a file.\r\n\r\nIf path is a symbolic link, the returned information is about the link itself.\r\n\r\nSo it's actually the [`lstat`](https://linux.die.net/man/2/lstat) system call.\r\n\r\n#### LST2\r\n\r\nVersion 2 of the STAT command, contains more information.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### STA2\r\n\r\nBasically identical to LST2, but if path is a symbolic link, the information is about the file it refers to.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### RECV\r\n\r\nRequest server to send the content of a file.\r\n\r\n#### RCV2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the RECV command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n#### SEND\r\n\r\n*(Not Implemented)*\r\n\r\nSend a file onto server's file system.\r\n\r\n#### SND2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the SEND command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n## Useful links\r\n\r\n* [ADB protocol overview](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/OVERVIEW.TXT)\r\n* [ADB commands](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/SERVICES.TXT#145)\r\n"
|
|
50
50
|
}
|