@yume-chan/adb 0.0.17 → 0.0.18
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 +6 -0
- package/CHANGELOG.md +6 -1
- package/LICENSE +1 -1
- package/esm/adb.d.ts +6 -6
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +55 -35
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +4 -4
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +6 -6
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +3 -3
- package/esm/backend.d.ts.map +1 -1
- package/esm/commands/base.d.ts +2 -2
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js +1 -1
- package/esm/commands/framebuffer.d.ts +7 -7
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +32 -33
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/install.d.ts +2 -2
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +12 -6
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +14 -10
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +3 -3
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +14 -12
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +2 -2
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +14 -16
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +4 -4
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +4 -4
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +23 -15
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +4 -4
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.d.ts +6 -6
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +23 -11
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +4 -4
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +12 -11
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +3 -3
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +6 -7
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +4 -4
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +7 -7
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +4 -4
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +7 -7
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +5 -5
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +37 -27
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +6 -6
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +20 -19
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +25 -15
- package/esm/crypto.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 +8 -8
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +14 -12
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +6 -6
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +22 -19
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/socket.d.ts +4 -4
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +37 -17
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/auto-reset-event.d.ts +1 -1
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +2 -2
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +30 -29
- package/esm/utils/base64.js.map +1 -1
- package/package.json +16 -13
- package/src/adb.ts +133 -84
- package/src/auth.ts +27 -19
- package/src/backend.ts +6 -4
- package/src/commands/base.ts +2 -2
- package/src/commands/framebuffer.ts +37 -41
- package/src/commands/install.ts +19 -11
- package/src/commands/power.ts +15 -11
- package/src/commands/reverse.ts +48 -29
- package/src/commands/subprocess/command.ts +24 -21
- package/src/commands/subprocess/protocols/none.ts +4 -3
- package/src/commands/subprocess/protocols/shell.ts +65 -33
- package/src/commands/subprocess/protocols/types.ts +8 -5
- package/src/commands/sync/list.ts +51 -24
- package/src/commands/sync/pull.ts +51 -34
- package/src/commands/sync/push.ts +25 -11
- package/src/commands/sync/request.ts +20 -22
- package/src/commands/sync/response.ts +31 -25
- package/src/commands/sync/stat.ts +78 -55
- package/src/commands/sync/sync.ts +47 -26
- package/src/crypto.ts +60 -32
- package/src/index.ts +9 -10
- package/src/packet.ts +40 -30
- package/src/socket/dispatcher.ts +115 -78
- package/src/socket/socket.ts +68 -27
- package/src/utils/auto-reset-event.ts +3 -3
- package/src/utils/base64.ts +51 -41
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/esm/socket/socket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,
|
|
1
|
+
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AC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAEM,GAAG;QACN,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IAGV,WAAW,CAAsB;IAEzC,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IACpC,CAAC;IACD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACrC,CAAC;IACD,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;IACzC,CAAC;IACD,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;IAC1C,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACrC,CAAC;IACD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACrC,CAAC;IAED,YAAmB,UAA+B;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-reset-event.d.ts","sourceRoot":"","sources":["../../src/utils/auto-reset-event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"auto-reset-event.d.ts","sourceRoot":"","sources":["../../src/utils/auto-reset-event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAa,cAAe,YAAW,UAAU;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA+B;IAEpD,OAAO,CAAC,QAAQ,CAAU;gBAEP,UAAU,UAAQ;IAI9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAcrB,MAAM;IAQN,OAAO;CAMjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PromiseResolver } from
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
2
|
export class AutoResetEvent {
|
|
3
3
|
list = [];
|
|
4
4
|
blocking;
|
|
@@ -26,7 +26,7 @@ export class AutoResetEvent {
|
|
|
26
26
|
}
|
|
27
27
|
dispose() {
|
|
28
28
|
for (const item of this.list) {
|
|
29
|
-
item.reject(new Error(
|
|
29
|
+
item.reject(new Error("The AutoResetEvent has been disposed"));
|
|
30
30
|
}
|
|
31
31
|
this.list.length = 0;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,MAAM,GACpB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAI/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC;AAC5D;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;AAiO5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CA4DtD"}
|
package/esm/utils/base64.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
const charToIndex =
|
|
1
|
+
// Array is faster than object literal or `Map`
|
|
2
|
+
const charToIndex = [];
|
|
3
3
|
const indexToChar = [];
|
|
4
|
-
const paddingChar =
|
|
4
|
+
const paddingChar = "=".charCodeAt(0);
|
|
5
5
|
function addRange(start, end) {
|
|
6
6
|
const charCodeStart = start.charCodeAt(0);
|
|
7
7
|
const charCodeEnd = end.charCodeAt(0);
|
|
8
8
|
for (let charCode = charCodeStart; charCode <= charCodeEnd; charCode += 1) {
|
|
9
|
-
charToIndex[
|
|
9
|
+
charToIndex[charCode] = indexToChar.length;
|
|
10
10
|
indexToChar.push(charCode);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
addRange(
|
|
14
|
-
addRange(
|
|
15
|
-
addRange(
|
|
16
|
-
addRange(
|
|
17
|
-
addRange(
|
|
13
|
+
addRange("A", "Z");
|
|
14
|
+
addRange("a", "z");
|
|
15
|
+
addRange("0", "9");
|
|
16
|
+
addRange("+", "+");
|
|
17
|
+
addRange("/", "/");
|
|
18
18
|
/**
|
|
19
19
|
* Calculate the required length of the output buffer for the given input length.
|
|
20
20
|
*
|
|
@@ -24,7 +24,7 @@ addRange('/', '/');
|
|
|
24
24
|
export function calculateBase64EncodedLength(inputLength) {
|
|
25
25
|
const remainder = inputLength % 3;
|
|
26
26
|
const paddingLength = remainder !== 0 ? 3 - remainder : 0;
|
|
27
|
-
return [(inputLength + paddingLength) / 3 * 4, paddingLength];
|
|
27
|
+
return [((inputLength + paddingLength) / 3) * 4, paddingLength];
|
|
28
28
|
}
|
|
29
29
|
export function encodeBase64(input, output) {
|
|
30
30
|
const [outputLength, paddingLength] = calculateBase64EncodedLength(input.length);
|
|
@@ -35,7 +35,7 @@ export function encodeBase64(input, output) {
|
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
if (output.length < outputLength) {
|
|
38
|
-
throw new Error(
|
|
38
|
+
throw new Error("output buffer is too small");
|
|
39
39
|
}
|
|
40
40
|
output = output.subarray(0, outputLength);
|
|
41
41
|
// When input and output are on same ArrayBuffer,
|
|
@@ -43,7 +43,8 @@ export function encodeBase64(input, output) {
|
|
|
43
43
|
if (input.buffer !== output.buffer) {
|
|
44
44
|
encodeForward(input, output, paddingLength);
|
|
45
45
|
}
|
|
46
|
-
else if (output.byteOffset + output.length - (paddingLength + 1) <=
|
|
46
|
+
else if (output.byteOffset + output.length - (paddingLength + 1) <=
|
|
47
|
+
input.byteOffset + input.length) {
|
|
47
48
|
// Output ends before input ends
|
|
48
49
|
// So output won't catch up with input.
|
|
49
50
|
// Depends on padding length,
|
|
@@ -76,7 +77,7 @@ export function encodeBase64(input, output) {
|
|
|
76
77
|
else {
|
|
77
78
|
// Input is in the middle of output,
|
|
78
79
|
// not possible to read neither first or last three bytes,
|
|
79
|
-
throw new Error(
|
|
80
|
+
throw new Error("input and output cannot overlap");
|
|
80
81
|
}
|
|
81
82
|
return outputLength;
|
|
82
83
|
}
|
|
@@ -113,7 +114,7 @@ function encodeForward(input, output, paddingLength) {
|
|
|
113
114
|
inputIndex += 1;
|
|
114
115
|
output[outputIndex] = indexToChar[x >> 2];
|
|
115
116
|
outputIndex += 1;
|
|
116
|
-
output[outputIndex] = indexToChar[(
|
|
117
|
+
output[outputIndex] = indexToChar[(x & 0b11) << 4];
|
|
117
118
|
outputIndex += 1;
|
|
118
119
|
output[outputIndex] = paddingChar;
|
|
119
120
|
outputIndex += 1;
|
|
@@ -132,7 +133,7 @@ function encodeForward(input, output, paddingLength) {
|
|
|
132
133
|
outputIndex += 1;
|
|
133
134
|
output[outputIndex] = indexToChar[((x & 0b11) << 4) | (y >> 4)];
|
|
134
135
|
outputIndex += 1;
|
|
135
|
-
output[outputIndex] = indexToChar[(
|
|
136
|
+
output[outputIndex] = indexToChar[(y & 0b1111) << 2];
|
|
136
137
|
outputIndex += 1;
|
|
137
138
|
output[outputIndex] = paddingChar;
|
|
138
139
|
}
|
|
@@ -149,7 +150,7 @@ function encodeBackward(input, output, paddingLength) {
|
|
|
149
150
|
outputIndex -= 1;
|
|
150
151
|
output[outputIndex] = paddingChar;
|
|
151
152
|
outputIndex -= 1;
|
|
152
|
-
output[outputIndex] = indexToChar[(
|
|
153
|
+
output[outputIndex] = indexToChar[(x & 0b11) << 4];
|
|
153
154
|
outputIndex -= 1;
|
|
154
155
|
output[outputIndex] = indexToChar[x >> 2];
|
|
155
156
|
outputIndex -= 1;
|
|
@@ -165,7 +166,7 @@ function encodeBackward(input, output, paddingLength) {
|
|
|
165
166
|
inputIndex -= 1;
|
|
166
167
|
output[outputIndex] = paddingChar;
|
|
167
168
|
outputIndex -= 1;
|
|
168
|
-
output[outputIndex] = indexToChar[(
|
|
169
|
+
output[outputIndex] = indexToChar[(y & 0b1111) << 2];
|
|
169
170
|
outputIndex -= 1;
|
|
170
171
|
output[outputIndex] = indexToChar[((x & 0b11) << 4) | (y >> 4)];
|
|
171
172
|
outputIndex -= 1;
|
|
@@ -197,26 +198,26 @@ function encodeBackward(input, output, paddingLength) {
|
|
|
197
198
|
}
|
|
198
199
|
export function decodeBase64(input) {
|
|
199
200
|
let padding;
|
|
200
|
-
if (input[input.length - 2] ===
|
|
201
|
+
if (input[input.length - 2] === "=") {
|
|
201
202
|
padding = 2;
|
|
202
203
|
}
|
|
203
|
-
else if (input[input.length - 1] ===
|
|
204
|
+
else if (input[input.length - 1] === "=") {
|
|
204
205
|
padding = 1;
|
|
205
206
|
}
|
|
206
207
|
else {
|
|
207
208
|
padding = 0;
|
|
208
209
|
}
|
|
209
|
-
const result = new Uint8Array(input.length / 4 * 3 - padding);
|
|
210
|
+
const result = new Uint8Array((input.length / 4) * 3 - padding);
|
|
210
211
|
let sIndex = 0;
|
|
211
212
|
let dIndex = 0;
|
|
212
213
|
while (sIndex < input.length - (padding !== 0 ? 4 : 0)) {
|
|
213
|
-
const a = charToIndex[input
|
|
214
|
+
const a = charToIndex[input.charCodeAt(sIndex)];
|
|
214
215
|
sIndex += 1;
|
|
215
|
-
const b = charToIndex[input
|
|
216
|
+
const b = charToIndex[input.charCodeAt(sIndex)];
|
|
216
217
|
sIndex += 1;
|
|
217
|
-
const c = charToIndex[input
|
|
218
|
+
const c = charToIndex[input.charCodeAt(sIndex)];
|
|
218
219
|
sIndex += 1;
|
|
219
|
-
const d = charToIndex[input
|
|
220
|
+
const d = charToIndex[input.charCodeAt(sIndex)];
|
|
220
221
|
sIndex += 1;
|
|
221
222
|
result[dIndex] = (a << 2) | ((b & 48) >> 4);
|
|
222
223
|
dIndex += 1;
|
|
@@ -226,19 +227,19 @@ export function decodeBase64(input) {
|
|
|
226
227
|
dIndex += 1;
|
|
227
228
|
}
|
|
228
229
|
if (padding === 1) {
|
|
229
|
-
const a = charToIndex[input
|
|
230
|
+
const a = charToIndex[input.charCodeAt(sIndex)];
|
|
230
231
|
sIndex += 1;
|
|
231
|
-
const b = charToIndex[input
|
|
232
|
+
const b = charToIndex[input.charCodeAt(sIndex)];
|
|
232
233
|
sIndex += 1;
|
|
233
|
-
const c = charToIndex[input
|
|
234
|
+
const c = charToIndex[input.charCodeAt(sIndex)];
|
|
234
235
|
result[dIndex] = (a << 2) | ((b & 48) >> 4);
|
|
235
236
|
dIndex += 1;
|
|
236
237
|
result[dIndex] = ((b & 0b1111) << 4) | ((c & 60) >> 2);
|
|
237
238
|
}
|
|
238
239
|
else if (padding === 2) {
|
|
239
|
-
const a = charToIndex[input
|
|
240
|
+
const a = charToIndex[input.charCodeAt(sIndex)];
|
|
240
241
|
sIndex += 1;
|
|
241
|
-
const b = charToIndex[input
|
|
242
|
+
const b = charToIndex[input.charCodeAt(sIndex)];
|
|
242
243
|
result[dIndex] = (a << 2) | ((b & 48) >> 4);
|
|
243
244
|
}
|
|
244
245
|
return result;
|
package/esm/utils/base64.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"A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C,CAAC;KACjE;SAAM,IAAI,OAAO,KAAK,CAAC,EAAE;QACtB,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAE,CAAC;QACjD,MAAM,IAAI,CAAC,CAAC;QAEZ,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAE,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KACtD;IAED,OAAO,MAAM,CAAC;AAClB,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.18",
|
|
4
4
|
"description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -26,24 +26,27 @@
|
|
|
26
26
|
"types": "esm/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@yume-chan/async": "^2.2.0",
|
|
29
|
-
"@yume-chan/dataview-bigint-polyfill": "^0.0.
|
|
30
|
-
"@yume-chan/event": "^0.0.
|
|
31
|
-
"@yume-chan/stream-extra": "^0.0.
|
|
32
|
-
"@yume-chan/struct": "^0.0.
|
|
33
|
-
"tslib": "^2.4.
|
|
29
|
+
"@yume-chan/dataview-bigint-polyfill": "^0.0.18",
|
|
30
|
+
"@yume-chan/event": "^0.0.18",
|
|
31
|
+
"@yume-chan/stream-extra": "^0.0.18",
|
|
32
|
+
"@yume-chan/struct": "^0.0.18",
|
|
33
|
+
"tslib": "^2.4.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@jest/globals": "^
|
|
37
|
-
"@types/node": "^
|
|
38
|
-
"@yume-chan/
|
|
36
|
+
"@jest/globals": "^29.3.1",
|
|
37
|
+
"@types/node": "^18.11.18",
|
|
38
|
+
"@yume-chan/eslint-config": "^1.0.0",
|
|
39
|
+
"@yume-chan/tsconfig": "^1.0.0",
|
|
39
40
|
"cross-env": "^7.0.3",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"eslint": "^8.31.0",
|
|
42
|
+
"jest": "^29.3.1",
|
|
43
|
+
"ts-jest": "^29.0.4",
|
|
44
|
+
"typescript": "^4.9.4"
|
|
43
45
|
},
|
|
44
46
|
"scripts": {
|
|
45
47
|
"build": "tsc -b tsconfig.build.json",
|
|
46
48
|
"build:watch": "tsc -b tsconfig.build.json",
|
|
47
|
-
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
49
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
|
|
50
|
+
"lint": "eslint src/**/*.ts --fix"
|
|
48
51
|
}
|
|
49
52
|
}
|
package/src/adb.ts
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
1
|
// cspell: ignore libusb
|
|
2
2
|
|
|
3
|
-
import { PromiseResolver } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
4
|
+
import {
|
|
5
|
+
AbortController,
|
|
6
|
+
DecodeUtf8Stream,
|
|
7
|
+
GatherStringStream,
|
|
8
|
+
WritableStream,
|
|
9
|
+
type ReadableWritablePair,
|
|
10
|
+
} from "@yume-chan/stream-extra";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
ADB_DEFAULT_AUTHENTICATORS,
|
|
14
|
+
AdbAuthenticationProcessor,
|
|
15
|
+
type AdbCredentialStore,
|
|
16
|
+
} from "./auth.js";
|
|
17
|
+
import {
|
|
18
|
+
AdbPower,
|
|
19
|
+
AdbReverseCommand,
|
|
20
|
+
AdbSubprocess,
|
|
21
|
+
AdbSync,
|
|
22
|
+
AdbTcpIpCommand,
|
|
23
|
+
escapeArg,
|
|
24
|
+
framebuffer,
|
|
25
|
+
install,
|
|
26
|
+
type AdbFrameBuffer,
|
|
27
|
+
} from "./commands/index.js";
|
|
28
|
+
import { AdbFeatures } from "./features.js";
|
|
29
|
+
import {
|
|
30
|
+
AdbCommand,
|
|
31
|
+
calculateChecksum,
|
|
32
|
+
type AdbPacketData,
|
|
33
|
+
type AdbPacketInit,
|
|
34
|
+
} from "./packet.js";
|
|
35
|
+
import {
|
|
36
|
+
AdbPacketDispatcher,
|
|
37
|
+
type AdbIncomingSocketHandler,
|
|
38
|
+
type AdbSocket,
|
|
39
|
+
type Closeable,
|
|
40
|
+
} from "./socket/index.js";
|
|
41
|
+
import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
|
|
12
42
|
|
|
13
43
|
export enum AdbPropKey {
|
|
14
|
-
Product =
|
|
15
|
-
Model =
|
|
16
|
-
Device =
|
|
17
|
-
Features =
|
|
44
|
+
Product = "ro.product.name",
|
|
45
|
+
Model = "ro.product.model",
|
|
46
|
+
Device = "ro.product.device",
|
|
47
|
+
Features = "features",
|
|
18
48
|
}
|
|
19
49
|
|
|
20
50
|
export const VERSION_OMIT_CHECKSUM = 0x01000001;
|
|
@@ -28,45 +58,57 @@ export class Adb implements Closeable {
|
|
|
28
58
|
public static async authenticate(
|
|
29
59
|
connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>,
|
|
30
60
|
credentialStore: AdbCredentialStore,
|
|
31
|
-
authenticators = ADB_DEFAULT_AUTHENTICATORS
|
|
61
|
+
authenticators = ADB_DEFAULT_AUTHENTICATORS
|
|
32
62
|
): Promise<Adb> {
|
|
33
63
|
// Initially, set to highest-supported version and payload size.
|
|
34
64
|
let version = 0x01000001;
|
|
35
65
|
let maxPayloadSize = 0x100000;
|
|
36
66
|
|
|
37
67
|
const resolver = new PromiseResolver<string>();
|
|
38
|
-
const authProcessor = new AdbAuthenticationProcessor(
|
|
68
|
+
const authProcessor = new AdbAuthenticationProcessor(
|
|
69
|
+
authenticators,
|
|
70
|
+
credentialStore
|
|
71
|
+
);
|
|
39
72
|
|
|
40
73
|
// Here is similar to `AdbPacketDispatcher`,
|
|
41
74
|
// But the received packet types and send packet processing are different.
|
|
42
75
|
const abortController = new AbortController();
|
|
43
76
|
const pipe = connection.readable
|
|
44
|
-
.pipeTo(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
.pipeTo(
|
|
78
|
+
new WritableStream({
|
|
79
|
+
async write(packet) {
|
|
80
|
+
switch (packet.command) {
|
|
81
|
+
case AdbCommand.Connect:
|
|
82
|
+
version = Math.min(version, packet.arg0);
|
|
83
|
+
maxPayloadSize = Math.min(
|
|
84
|
+
maxPayloadSize,
|
|
85
|
+
packet.arg1
|
|
86
|
+
);
|
|
87
|
+
resolver.resolve(decodeUtf8(packet.payload));
|
|
88
|
+
break;
|
|
89
|
+
case AdbCommand.Auth: {
|
|
90
|
+
const response = await authProcessor.process(
|
|
91
|
+
packet
|
|
92
|
+
);
|
|
93
|
+
await sendPacket(response);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
// Maybe the previous ADB client exited without reading all packets,
|
|
98
|
+
// so they are still waiting in OS internal buffer.
|
|
99
|
+
// Just ignore them.
|
|
100
|
+
// Because a `Connect` packet will reset the device,
|
|
101
|
+
// Eventually there will be `Connect` and `Auth` response packets.
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
{
|
|
107
|
+
// Don't cancel the source ReadableStream on AbortSignal abort.
|
|
108
|
+
preventCancel: true,
|
|
109
|
+
signal: abortController.signal,
|
|
64
110
|
}
|
|
65
|
-
|
|
66
|
-
// Don't cancel the source ReadableStream on AbortSignal abort.
|
|
67
|
-
preventCancel: true,
|
|
68
|
-
signal: abortController.signal,
|
|
69
|
-
})
|
|
111
|
+
)
|
|
70
112
|
.catch((e) => {
|
|
71
113
|
resolver.reject(e);
|
|
72
114
|
});
|
|
@@ -88,20 +130,20 @@ export class Adb implements Closeable {
|
|
|
88
130
|
AdbFeatures.StatV2,
|
|
89
131
|
AdbFeatures.ListV2,
|
|
90
132
|
AdbFeatures.FixedPushMkdir,
|
|
91
|
-
|
|
92
|
-
|
|
133
|
+
"apex",
|
|
134
|
+
"abb",
|
|
93
135
|
// only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
|
|
94
136
|
// No special handling required.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
].join(
|
|
137
|
+
"fixed_push_symlink_timestamp",
|
|
138
|
+
"abb_exec",
|
|
139
|
+
"remount_shell",
|
|
140
|
+
"track_app",
|
|
141
|
+
"sendrecv_v2",
|
|
142
|
+
"sendrecv_v2_brotli",
|
|
143
|
+
"sendrecv_v2_lz4",
|
|
144
|
+
"sendrecv_v2_zstd",
|
|
145
|
+
"sendrecv_v2_dry_run_send",
|
|
146
|
+
].join(",");
|
|
105
147
|
|
|
106
148
|
await sendPacket({
|
|
107
149
|
command: AdbCommand.Connect,
|
|
@@ -123,32 +165,39 @@ export class Adb implements Closeable {
|
|
|
123
165
|
await pipe;
|
|
124
166
|
}
|
|
125
167
|
|
|
126
|
-
return new Adb(
|
|
127
|
-
connection,
|
|
128
|
-
version,
|
|
129
|
-
maxPayloadSize,
|
|
130
|
-
banner,
|
|
131
|
-
);
|
|
168
|
+
return new Adb(connection, version, maxPayloadSize, banner);
|
|
132
169
|
}
|
|
133
170
|
|
|
134
171
|
private readonly dispatcher: AdbPacketDispatcher;
|
|
135
172
|
|
|
136
|
-
public get disconnected() {
|
|
173
|
+
public get disconnected() {
|
|
174
|
+
return this.dispatcher.disconnected;
|
|
175
|
+
}
|
|
137
176
|
|
|
138
177
|
private _protocolVersion: number | undefined;
|
|
139
|
-
public get protocolVersion() {
|
|
178
|
+
public get protocolVersion() {
|
|
179
|
+
return this._protocolVersion;
|
|
180
|
+
}
|
|
140
181
|
|
|
141
182
|
private _product: string | undefined;
|
|
142
|
-
public get product() {
|
|
183
|
+
public get product() {
|
|
184
|
+
return this._product;
|
|
185
|
+
}
|
|
143
186
|
|
|
144
187
|
private _model: string | undefined;
|
|
145
|
-
public get model() {
|
|
188
|
+
public get model() {
|
|
189
|
+
return this._model;
|
|
190
|
+
}
|
|
146
191
|
|
|
147
192
|
private _device: string | undefined;
|
|
148
|
-
public get device() {
|
|
193
|
+
public get device() {
|
|
194
|
+
return this._device;
|
|
195
|
+
}
|
|
149
196
|
|
|
150
197
|
private _features: AdbFeatures[] = [];
|
|
151
|
-
public get features() {
|
|
198
|
+
public get features() {
|
|
199
|
+
return this._features;
|
|
200
|
+
}
|
|
152
201
|
|
|
153
202
|
public readonly subprocess: AdbSubprocess;
|
|
154
203
|
public readonly power: AdbPower;
|
|
@@ -159,7 +208,7 @@ export class Adb implements Closeable {
|
|
|
159
208
|
connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>,
|
|
160
209
|
version: number,
|
|
161
210
|
maxPayloadSize: number,
|
|
162
|
-
banner: string
|
|
211
|
+
banner: string
|
|
163
212
|
) {
|
|
164
213
|
this.parseBanner(banner);
|
|
165
214
|
|
|
@@ -173,14 +222,11 @@ export class Adb implements Closeable {
|
|
|
173
222
|
appendNullToServiceString = true;
|
|
174
223
|
}
|
|
175
224
|
|
|
176
|
-
this.dispatcher = new AdbPacketDispatcher(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
maxPayloadSize,
|
|
182
|
-
}
|
|
183
|
-
);
|
|
225
|
+
this.dispatcher = new AdbPacketDispatcher(connection, {
|
|
226
|
+
calculateChecksum,
|
|
227
|
+
appendNullToServiceString,
|
|
228
|
+
maxPayloadSize,
|
|
229
|
+
});
|
|
184
230
|
|
|
185
231
|
this._protocolVersion = version;
|
|
186
232
|
|
|
@@ -191,15 +237,15 @@ export class Adb implements Closeable {
|
|
|
191
237
|
}
|
|
192
238
|
|
|
193
239
|
private parseBanner(banner: string): void {
|
|
194
|
-
const pieces = banner.split(
|
|
240
|
+
const pieces = banner.split("::");
|
|
195
241
|
if (pieces.length > 1) {
|
|
196
242
|
const props = pieces[1]!;
|
|
197
|
-
for (const prop of props.split(
|
|
243
|
+
for (const prop of props.split(";")) {
|
|
198
244
|
if (!prop) {
|
|
199
245
|
continue;
|
|
200
246
|
}
|
|
201
247
|
|
|
202
|
-
const keyValue = prop.split(
|
|
248
|
+
const keyValue = prop.split("=");
|
|
203
249
|
if (keyValue.length !== 2) {
|
|
204
250
|
continue;
|
|
205
251
|
}
|
|
@@ -216,7 +262,7 @@ export class Adb implements Closeable {
|
|
|
216
262
|
this._device = value;
|
|
217
263
|
break;
|
|
218
264
|
case AdbPropKey.Features:
|
|
219
|
-
this._features = value!.split(
|
|
265
|
+
this._features = value!.split(",") as AdbFeatures[];
|
|
220
266
|
break;
|
|
221
267
|
}
|
|
222
268
|
}
|
|
@@ -246,16 +292,19 @@ export class Adb implements Closeable {
|
|
|
246
292
|
}
|
|
247
293
|
|
|
248
294
|
public async getProp(key: string): Promise<string> {
|
|
249
|
-
const stdout = await this.subprocess.spawnAndWaitLegacy(
|
|
250
|
-
|
|
251
|
-
|
|
295
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy([
|
|
296
|
+
"getprop",
|
|
297
|
+
key,
|
|
298
|
+
]);
|
|
252
299
|
return stdout.trim();
|
|
253
300
|
}
|
|
254
301
|
|
|
255
302
|
public async rm(...filenames: string[]): Promise<string> {
|
|
256
|
-
const stdout = await this.subprocess.spawnAndWaitLegacy(
|
|
257
|
-
|
|
258
|
-
|
|
303
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy([
|
|
304
|
+
"rm",
|
|
305
|
+
"-rf",
|
|
306
|
+
...filenames.map((arg) => escapeArg(arg)),
|
|
307
|
+
]);
|
|
259
308
|
return stdout;
|
|
260
309
|
}
|
|
261
310
|
|
|
@@ -264,7 +313,7 @@ export class Adb implements Closeable {
|
|
|
264
313
|
}
|
|
265
314
|
|
|
266
315
|
public async sync(): Promise<AdbSync> {
|
|
267
|
-
const socket = await this.createSocket(
|
|
316
|
+
const socket = await this.createSocket("sync:");
|
|
268
317
|
return new AdbSync(this, socket);
|
|
269
318
|
}
|
|
270
319
|
|