@yume-chan/adb 3.0.0-beta.1 → 3.0.0-beta.2
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/esm/adb.d.ts +7 -2
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +2 -2
- package/esm/adb.js.map +1 -1
- package/esm/banner.spec.d.ts +2 -0
- package/esm/banner.spec.d.ts.map +1 -0
- package/esm/daemon/auth/packet-processor.spec.d.ts +2 -0
- package/esm/daemon/auth/packet-processor.spec.d.ts.map +1 -0
- package/esm/daemon/auth/public-key.spec.d.ts +2 -0
- package/esm/daemon/auth/public-key.spec.d.ts.map +1 -0
- package/esm/daemon/crypto.spec.d.ts +2 -0
- package/esm/daemon/crypto.spec.d.ts.map +1 -0
- package/esm/server/client.spec.d.ts +2 -0
- package/esm/server/client.spec.d.ts.map +1 -0
- package/esm/server/transport.d.ts +1 -1
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +2 -2
- package/esm/server/transport.js.map +1 -1
- package/esm/service/reverse/response.spec.d.ts +2 -0
- package/esm/service/reverse/response.spec.d.ts.map +1 -0
- package/esm/service/subprocess/none/process.spec.d.ts +2 -0
- package/esm/service/subprocess/none/process.spec.d.ts.map +1 -0
- package/esm/service/subprocess/none/spawner.spec.d.ts +2 -0
- package/esm/service/subprocess/none/spawner.spec.d.ts.map +1 -0
- package/esm/service/subprocess/shell/process.spec.d.ts +2 -0
- package/esm/service/subprocess/shell/process.spec.d.ts.map +1 -0
- package/esm/service/subprocess/shell/shared.spec.d.ts +2 -0
- package/esm/service/subprocess/shell/shared.spec.d.ts.map +1 -0
- package/esm/service/subprocess/shell/spawner.spec.d.ts +2 -0
- package/esm/service/subprocess/shell/spawner.spec.d.ts.map +1 -0
- package/esm/service/subprocess/utils.spec.d.ts +2 -0
- package/esm/service/subprocess/utils.spec.d.ts.map +1 -0
- package/esm/service/sync/compression/adapters.d.ts +16 -0
- package/esm/service/sync/compression/adapters.d.ts.map +1 -0
- package/esm/service/sync/compression/adapters.js +84 -0
- package/esm/service/sync/compression/adapters.js.map +1 -0
- package/esm/service/sync/compression/format-ns.d.ts.map +1 -1
- package/esm/service/sync/compression/format-ns.js +1 -0
- package/esm/service/sync/compression/format-ns.js.map +1 -1
- package/esm/service/sync/compression/format.d.ts +1 -0
- package/esm/service/sync/compression/format.d.ts.map +1 -1
- package/esm/service/sync/compression/format.js +1 -0
- package/esm/service/sync/compression/format.js.map +1 -1
- package/esm/service/sync/compression/index.d.ts +1 -1
- package/esm/service/sync/compression/index.d.ts.map +1 -1
- package/esm/service/sync/compression/index.js +1 -1
- package/esm/service/sync/compression/index.js.map +1 -1
- package/esm/service/sync/compression/mode.d.ts +6 -0
- package/esm/service/sync/compression/mode.d.ts.map +1 -0
- package/esm/service/sync/compression/mode.js +5 -0
- package/esm/service/sync/compression/mode.js.map +1 -0
- package/esm/service/sync/compression/native.d.ts +8 -0
- package/esm/service/sync/compression/native.d.ts.map +1 -0
- package/esm/service/sync/compression/native.js +53 -0
- package/esm/service/sync/compression/native.js.map +1 -0
- package/esm/service/sync/id/request.d.ts +1 -0
- package/esm/service/sync/id/request.d.ts.map +1 -1
- package/esm/service/sync/id/request.js +1 -0
- package/esm/service/sync/id/request.js.map +1 -1
- package/esm/service/sync/request/flag.d.ts +9 -0
- package/esm/service/sync/request/flag.d.ts.map +1 -0
- package/esm/service/sync/request/flag.js +8 -0
- package/esm/service/sync/request/flag.js.map +1 -0
- package/esm/service/sync/request/pull.d.ts +25 -2
- package/esm/service/sync/request/pull.d.ts.map +1 -1
- package/esm/service/sync/request/pull.js +76 -16
- package/esm/service/sync/request/pull.js.map +1 -1
- package/esm/service/sync/request/push.d.ts +36 -14
- package/esm/service/sync/request/push.d.ts.map +1 -1
- package/esm/service/sync/request/push.js +176 -60
- package/esm/service/sync/request/push.js.map +1 -1
- package/esm/service/sync/service.d.ts +32 -16
- package/esm/service/sync/service.d.ts.map +1 -1
- package/esm/service/sync/service.js +58 -13
- package/esm/service/sync/service.js.map +1 -1
- package/esm/service/sync/socket-pool.d.ts +1 -0
- package/esm/service/sync/socket-pool.d.ts.map +1 -1
- package/esm/service/sync/socket-pool.js +45 -9
- package/esm/service/sync/socket-pool.js.map +1 -1
- package/esm/service/sync/socket-pool.spec.d.ts +2 -0
- package/esm/service/sync/socket-pool.spec.d.ts.map +1 -0
- package/esm/service/sync/socket.d.ts +4 -0
- package/esm/service/sync/socket.d.ts.map +1 -1
- package/esm/service/sync/socket.js +16 -0
- package/esm/service/sync/socket.js.map +1 -1
- package/esm/service/sync/socket.spec.d.ts +2 -0
- package/esm/service/sync/socket.spec.d.ts.map +1 -0
- package/esm/utils/base64.spec.d.ts +2 -0
- package/esm/utils/base64.spec.d.ts.map +1 -0
- package/esm/utils/md5.spec.d.ts +2 -0
- package/esm/utils/md5.spec.d.ts.map +1 -0
- package/esm/utils/ref.d.ts +3 -5
- package/esm/utils/ref.d.ts.map +1 -1
- package/esm/utils/ref.js +12 -6
- package/esm/utils/ref.js.map +1 -1
- package/package.json +5 -5
- package/src/adb.ts +15 -3
- package/src/server/transport.ts +5 -1
- package/src/service/sync/compression/adapters.ts +137 -0
- package/src/service/sync/compression/format-ns.ts +2 -0
- package/src/service/sync/compression/format.ts +5 -0
- package/src/service/sync/compression/index.ts +1 -1
- package/src/service/sync/compression/mode.ts +6 -0
- package/src/service/sync/compression/native.ts +73 -0
- package/src/service/sync/id/request.ts +1 -0
- package/src/service/sync/request/flag.ts +9 -0
- package/src/service/sync/request/pull.ts +135 -27
- package/src/service/sync/request/push.ts +241 -91
- package/src/service/sync/service.ts +87 -27
- package/src/service/sync/socket-pool.ts +50 -9
- package/src/service/sync/socket.ts +23 -1
- package/src/utils/ref.ts +17 -7
- package/yume-chan-adb-3.0.0-beta.0.tgz +0 -0
- package/esm/service/sync/compression/compression.d.ts +0 -17
- package/esm/service/sync/compression/compression.d.ts.map +0 -1
- package/esm/service/sync/compression/compression.js +0 -92
- package/esm/service/sync/compression/compression.js.map +0 -1
- package/src/service/sync/compression/compression.ts +0 -126
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { TransformStream } from "@yume-chan/stream-extra";
|
|
2
|
+
|
|
3
|
+
import type { Adb } from "../../../adb.js";
|
|
4
|
+
import { AdbFeature } from "../../../features.js";
|
|
5
|
+
|
|
6
|
+
import { Format, FormatNameMap } from "./format.js";
|
|
7
|
+
import { Mode } from "./mode.js";
|
|
8
|
+
import {
|
|
9
|
+
createNativeCompressionStream,
|
|
10
|
+
createNativeDecompressionStream,
|
|
11
|
+
hasNativeSupport,
|
|
12
|
+
} from "./native.js";
|
|
13
|
+
|
|
14
|
+
export { Format, FormatNameMap, Mode };
|
|
15
|
+
|
|
16
|
+
export type Adapter = () => TransformStream<Uint8Array, Uint8Array>;
|
|
17
|
+
|
|
18
|
+
const CompressionRegistry: Partial<
|
|
19
|
+
Record<Exclude<Format, typeof Format.None>, Adapter>
|
|
20
|
+
> = {};
|
|
21
|
+
|
|
22
|
+
const DecompressionRegistry: Partial<
|
|
23
|
+
Record<Exclude<Format, typeof Format.None>, Adapter>
|
|
24
|
+
> = {};
|
|
25
|
+
|
|
26
|
+
export function registerCompressionAdapter(
|
|
27
|
+
format: Exclude<Format, typeof Format.None>,
|
|
28
|
+
adapter: Adapter,
|
|
29
|
+
) {
|
|
30
|
+
CompressionRegistry[format] = adapter;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function registerDecompressionAdapter(
|
|
34
|
+
format: Exclude<Format, typeof Format.None>,
|
|
35
|
+
adapter: Adapter,
|
|
36
|
+
) {
|
|
37
|
+
DecompressionRegistry[format] = adapter;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function hasAdapterOrNativeSupport(format: Format, mode: Mode) {
|
|
41
|
+
if (format === Format.None) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const Registry =
|
|
46
|
+
mode === Mode.Compress ? CompressionRegistry : DecompressionRegistry;
|
|
47
|
+
if (Registry[format]) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return hasNativeSupport(format, mode);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function canUseBrotli(adb: Adb, mode: Mode) {
|
|
55
|
+
return (
|
|
56
|
+
adb.canUseFeature(AdbFeature.SendReceive2Brotli) &&
|
|
57
|
+
hasAdapterOrNativeSupport(Format.Brotli, mode)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function canUseLz4(adb: Adb, mode: Mode) {
|
|
62
|
+
return (
|
|
63
|
+
adb.canUseFeature(AdbFeature.SendReceive2Lz4) &&
|
|
64
|
+
hasAdapterOrNativeSupport(Format.Lz4, mode)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function canUseZstd(adb: Adb, mode: Mode) {
|
|
69
|
+
return (
|
|
70
|
+
adb.canUseFeature(AdbFeature.SendReceive2Zstd) &&
|
|
71
|
+
hasAdapterOrNativeSupport(Format.Zstd, mode)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function canUseFormat(adb: Adb, format: Format, mode: Mode) {
|
|
76
|
+
switch (format) {
|
|
77
|
+
case Format.None:
|
|
78
|
+
return true;
|
|
79
|
+
case Format.Brotli:
|
|
80
|
+
return canUseBrotli(adb, mode);
|
|
81
|
+
case Format.Lz4:
|
|
82
|
+
return canUseLz4(adb, mode);
|
|
83
|
+
case Format.Zstd:
|
|
84
|
+
return canUseZstd(adb, mode);
|
|
85
|
+
default:
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function chooseFormat(adb: Adb, mode: Mode) {
|
|
91
|
+
// The order follows
|
|
92
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/3da39565cad412a743a58b94b875a43ed3c640d3/client/file_sync_client.cpp#277
|
|
93
|
+
|
|
94
|
+
if (canUseZstd(adb, mode)) {
|
|
95
|
+
return Format.Zstd;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (canUseLz4(adb, mode)) {
|
|
99
|
+
return Format.Lz4;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (canUseBrotli(adb, mode)) {
|
|
103
|
+
return Format.Brotli;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return Format.None;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function createCompressionStream(
|
|
110
|
+
format: Exclude<Format, typeof Format.None>,
|
|
111
|
+
): TransformStream<Uint8Array, Uint8Array> {
|
|
112
|
+
const adapter = CompressionRegistry[format];
|
|
113
|
+
if (adapter) {
|
|
114
|
+
return adapter();
|
|
115
|
+
}
|
|
116
|
+
if (hasNativeSupport(format, Mode.Compress)) {
|
|
117
|
+
return createNativeCompressionStream(format);
|
|
118
|
+
}
|
|
119
|
+
throw new Error(
|
|
120
|
+
`No adapter registered for format ${FormatNameMap[format]}`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function createDecompressionStream(
|
|
125
|
+
format: Exclude<Format, typeof Format.None>,
|
|
126
|
+
): TransformStream<Uint8Array, Uint8Array> {
|
|
127
|
+
const adapter = DecompressionRegistry[format];
|
|
128
|
+
if (adapter) {
|
|
129
|
+
return adapter();
|
|
130
|
+
}
|
|
131
|
+
if (hasNativeSupport(format, Mode.Decompress)) {
|
|
132
|
+
return createNativeDecompressionStream(format);
|
|
133
|
+
}
|
|
134
|
+
throw new Error(
|
|
135
|
+
`No adapter registered for format ${FormatNameMap[format]}`,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -2,4 +2,9 @@ import * as Format from "./format-ns.js";
|
|
|
2
2
|
|
|
3
3
|
type Format = (typeof Format)[keyof typeof Format];
|
|
4
4
|
|
|
5
|
+
export const FormatNameMap = /* #__PURE__ */ (() =>
|
|
6
|
+
Object.fromEntries(
|
|
7
|
+
Object.entries(Format).map(([key, value]) => [value, key]),
|
|
8
|
+
))() as Record<Format, string>;
|
|
9
|
+
|
|
5
10
|
export { Format };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as Compression from "./
|
|
1
|
+
export * as Compression from "./adapters.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompressionStream,
|
|
3
|
+
DecompressionStream,
|
|
4
|
+
TransformStream,
|
|
5
|
+
} from "@yume-chan/stream-extra";
|
|
6
|
+
|
|
7
|
+
import { NOOP } from "../../../utils/no-op.js";
|
|
8
|
+
|
|
9
|
+
import { Format } from "./format.js";
|
|
10
|
+
import { Mode } from "./mode.js";
|
|
11
|
+
|
|
12
|
+
export const FormatMap: Record<Format, string> = {
|
|
13
|
+
[Format.None]: "",
|
|
14
|
+
// https://github.com/whatwg/compression/issues/54
|
|
15
|
+
[Format.Zstd]: "zstd",
|
|
16
|
+
// placeholder
|
|
17
|
+
[Format.Lz4]: "lz4",
|
|
18
|
+
// https://github.com/whatwg/compression/pull/80
|
|
19
|
+
[Format.Brotli]: "brotli",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const CompressionFormatCache = new Map<Format, boolean>();
|
|
23
|
+
const DecompressionFormatCache = new Map<Format, boolean>();
|
|
24
|
+
|
|
25
|
+
export function hasNativeSupport(format: Format, mode: Mode) {
|
|
26
|
+
if (format === Format.None) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const Cache =
|
|
31
|
+
mode === Mode.Compress
|
|
32
|
+
? CompressionFormatCache
|
|
33
|
+
: DecompressionFormatCache;
|
|
34
|
+
if (Cache.has(format)) {
|
|
35
|
+
return Cache.get(format)!;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const Stream =
|
|
39
|
+
mode === Mode.Compress ? CompressionStream : DecompressionStream;
|
|
40
|
+
if (!Stream) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const stream = new Stream(FormatMap[format]);
|
|
46
|
+
void stream.writable.abort().catch(NOOP);
|
|
47
|
+
Cache.set(format, true);
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
Cache.set(format, false);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createNativeCompressionStream(
|
|
56
|
+
format: Format,
|
|
57
|
+
): CompressionStream {
|
|
58
|
+
if (format === Format.None) {
|
|
59
|
+
return new TransformStream();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return new CompressionStream(FormatMap[format]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function createNativeDecompressionStream(
|
|
66
|
+
format: Format,
|
|
67
|
+
): DecompressionStream {
|
|
68
|
+
if (format === Format.None) {
|
|
69
|
+
return new TransformStream();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return new DecompressionStream(FormatMap[format]);
|
|
73
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TransformStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import { InspectStream, ReadableStream } from "@yume-chan/stream-extra";
|
|
2
3
|
import type { StructValue } from "@yume-chan/struct";
|
|
3
4
|
import { buffer, struct, u32 } from "@yume-chan/struct";
|
|
4
5
|
|
|
5
6
|
import { RequestId, ResponseId } from "../id/index.js";
|
|
7
|
+
import { Compression } from "../index-ns.js";
|
|
6
8
|
import type { SocketPool } from "../socket-pool.js";
|
|
7
9
|
import { Error as AdbSyncError } from "../socket.js";
|
|
8
10
|
|
|
11
|
+
import { SyncFlag } from "./flag.js";
|
|
12
|
+
|
|
9
13
|
export const DataResponse = struct(
|
|
10
14
|
{ data: buffer(u32) },
|
|
11
15
|
{ littleEndian: true },
|
|
@@ -13,37 +17,141 @@ export const DataResponse = struct(
|
|
|
13
17
|
|
|
14
18
|
export type DataResponse = StructValue<typeof DataResponse>;
|
|
15
19
|
|
|
16
|
-
export
|
|
20
|
+
export interface ReceiveSession {
|
|
21
|
+
/**
|
|
22
|
+
* The readable stream to read the file content from.
|
|
23
|
+
*/
|
|
24
|
+
readable: ReadableStream<Uint8Array>;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the number of bytes read from {@link readable}.
|
|
27
|
+
*/
|
|
28
|
+
bytesRead: number;
|
|
29
|
+
/**
|
|
30
|
+
* When using Pull v2, gets the compression format used (might be `None`).
|
|
31
|
+
*
|
|
32
|
+
* When using Pull v1, this will always be `undefined`.
|
|
33
|
+
*/
|
|
34
|
+
compression?: Compression.Format | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* When using Pull v2, gets the size of the compressed data received from the device.
|
|
37
|
+
* Might be same as {@link bytesRead} if no compression was applied.
|
|
38
|
+
*/
|
|
39
|
+
bytesCompressed: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function receiveV1(pool: SocketPool, path: string): ReceiveSession {
|
|
43
|
+
let bytesReceived = 0;
|
|
44
|
+
return {
|
|
45
|
+
readable: ReadableStream.from(
|
|
46
|
+
pool.withSocketGenerator(async function* (socket) {
|
|
47
|
+
await socket.writeRequest(RequestId.Receive, path);
|
|
48
|
+
|
|
49
|
+
for await (const packet of socket.readResponses(
|
|
50
|
+
ResponseId.Data,
|
|
51
|
+
DataResponse,
|
|
52
|
+
)) {
|
|
53
|
+
bytesReceived += packet.data.length;
|
|
54
|
+
yield packet.data;
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
58
|
+
get bytesRead() {
|
|
59
|
+
return bytesReceived;
|
|
60
|
+
},
|
|
61
|
+
compression: undefined,
|
|
62
|
+
get bytesCompressed() {
|
|
63
|
+
return bytesReceived;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function receiveV2(
|
|
17
69
|
pool: SocketPool,
|
|
18
70
|
path: string,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
71
|
+
compression?: Compression.Format,
|
|
72
|
+
): ReceiveSession {
|
|
73
|
+
let flags: SyncFlag = SyncFlag.None;
|
|
74
|
+
let decompressStream: TransformStream<Uint8Array, Uint8Array> | undefined;
|
|
75
|
+
switch (compression) {
|
|
76
|
+
case Compression.Format.Brotli:
|
|
77
|
+
flags |= SyncFlag.Brotli;
|
|
78
|
+
decompressStream = Compression.createDecompressionStream(
|
|
79
|
+
Compression.Format.Brotli,
|
|
80
|
+
);
|
|
81
|
+
break;
|
|
82
|
+
case Compression.Format.Lz4:
|
|
83
|
+
flags |= SyncFlag.Lz4;
|
|
84
|
+
decompressStream = Compression.createDecompressionStream(
|
|
85
|
+
Compression.Format.Lz4,
|
|
86
|
+
);
|
|
87
|
+
break;
|
|
88
|
+
case Compression.Format.Zstd:
|
|
89
|
+
flags |= SyncFlag.Zstd;
|
|
90
|
+
decompressStream = Compression.createDecompressionStream(
|
|
91
|
+
Compression.Format.Zstd,
|
|
92
|
+
);
|
|
93
|
+
break;
|
|
41
94
|
}
|
|
95
|
+
|
|
96
|
+
let bytesReceived = 0;
|
|
97
|
+
const raw = ReadableStream.from(
|
|
98
|
+
pool.withSocketGenerator(async function* (socket) {
|
|
99
|
+
await socket.writeRequest(RequestId.ReceiveV2, path);
|
|
100
|
+
await socket.writeRequest(RequestId.ReceiveV2, flags);
|
|
101
|
+
|
|
102
|
+
for await (const packet of socket.readResponses(
|
|
103
|
+
ResponseId.Data,
|
|
104
|
+
DataResponse,
|
|
105
|
+
)) {
|
|
106
|
+
bytesReceived += packet.data.length;
|
|
107
|
+
yield packet.data;
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
if (decompressStream) {
|
|
113
|
+
let bytesRead = 0;
|
|
114
|
+
return {
|
|
115
|
+
readable: raw.pipeThrough(decompressStream).pipeThrough(
|
|
116
|
+
new InspectStream((chunk) => {
|
|
117
|
+
bytesRead += chunk.length;
|
|
118
|
+
}),
|
|
119
|
+
),
|
|
120
|
+
get bytesRead() {
|
|
121
|
+
return bytesRead;
|
|
122
|
+
},
|
|
123
|
+
compression,
|
|
124
|
+
get bytesCompressed() {
|
|
125
|
+
return bytesReceived;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
readable: raw,
|
|
132
|
+
get bytesRead() {
|
|
133
|
+
return bytesReceived;
|
|
134
|
+
},
|
|
135
|
+
compression: Compression.Format.None,
|
|
136
|
+
get bytesCompressed() {
|
|
137
|
+
return bytesReceived;
|
|
138
|
+
},
|
|
139
|
+
};
|
|
42
140
|
}
|
|
43
141
|
|
|
44
|
-
export function
|
|
142
|
+
export function receive(
|
|
143
|
+
version: 1 | 2,
|
|
45
144
|
pool: SocketPool,
|
|
46
145
|
path: string,
|
|
47
|
-
|
|
48
|
-
|
|
146
|
+
compression?: Compression.Format,
|
|
147
|
+
) {
|
|
148
|
+
if (version === 2) {
|
|
149
|
+
return receiveV2(pool, path, compression);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (compression !== undefined && compression !== Compression.Format.None) {
|
|
153
|
+
throw new AdbSyncError("compression is not supported in v1");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return receiveV1(pool, path);
|
|
49
157
|
}
|