@yume-chan/adb 0.0.15 → 0.0.16
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 +21 -0
- package/CHANGELOG.md +11 -1
- package/LICENSE +21 -21
- package/README.md +247 -247
- package/esm/adb.d.ts +7 -0
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +7 -0
- package/esm/adb.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +1 -0
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +6 -5
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +4 -1
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +11 -8
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/socket.d.ts +6 -1
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +17 -7
- package/esm/socket/socket.js.map +1 -1
- package/esm/stream/buffered.d.ts +6 -2
- package/esm/stream/buffered.d.ts.map +1 -1
- package/esm/stream/buffered.js +67 -47
- package/esm/stream/buffered.js.map +1 -1
- package/esm/stream/detect.js +1 -0
- package/esm/stream/detect.js.map +1 -1
- package/esm/stream/detect.polyfill.d.ts.map +1 -1
- package/esm/stream/detect.polyfill.js +0 -5
- package/esm/stream/detect.polyfill.js.map +1 -1
- package/esm/stream/transform.d.ts +20 -0
- package/esm/stream/transform.d.ts.map +1 -1
- package/esm/stream/transform.js +7 -1
- package/esm/stream/transform.js.map +1 -1
- package/package.json +10 -10
- package/src/adb.ts +280 -273
- package/src/auth.ts +173 -173
- package/src/backend.ts +11 -11
- package/src/commands/base.ts +11 -11
- package/src/commands/framebuffer.ts +73 -73
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +30 -30
- package/src/commands/power.ts +54 -54
- package/src/commands/reverse.ts +140 -140
- package/src/commands/subprocess/index.ts +139 -139
- package/src/commands/subprocess/protocols/none.ts +70 -68
- package/src/commands/subprocess/protocols/shell.ts +190 -190
- package/src/commands/subprocess/protocols/types.ts +59 -59
- package/src/commands/subprocess/utils.ts +20 -20
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +86 -86
- package/src/commands/sync/pull.ts +46 -46
- package/src/commands/sync/push.ts +41 -41
- package/src/commands/sync/request.ts +50 -50
- package/src/commands/sync/response.ts +64 -64
- package/src/commands/sync/stat.ts +151 -150
- package/src/commands/sync/sync.ts +181 -181
- package/src/commands/tcpip.ts +21 -21
- package/src/crypto.ts +296 -296
- package/src/features.ts +9 -9
- package/src/index.ts +11 -11
- package/src/packet.ts +80 -80
- package/src/socket/dispatcher.ts +305 -304
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +155 -144
- package/src/stream/buffered.ts +168 -147
- package/src/stream/detect.native.ts +362 -362
- package/src/stream/detect.polyfill.ts +22 -28
- package/src/stream/detect.ts +7 -5
- package/src/stream/index.ts +3 -3
- package/src/stream/transform.ts +474 -447
- package/src/utils/auto-reset-event.ts +41 -41
- package/src/utils/base64.ts +306 -306
- package/src/utils/index.ts +3 -3
- package/tsconfig.build.json +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.test.json +9 -10
- package/web-streams-polyfill-4.0.0-beta.2.tgz +0 -0
- package/esm/commands/subprocess/legacy.d.ts +0 -35
- package/esm/commands/subprocess/legacy.d.ts.map +0 -1
- package/esm/commands/subprocess/legacy.js +0 -53
- package/esm/commands/subprocess/legacy.js.map +0 -1
- package/esm/commands/subprocess/protocol.d.ts +0 -39
- package/esm/commands/subprocess/protocol.d.ts.map +0 -1
- package/esm/commands/subprocess/protocol.js +0 -157
- package/esm/commands/subprocess/protocol.js.map +0 -1
- package/esm/commands/subprocess/types.d.ts +0 -50
- package/esm/commands/subprocess/types.d.ts.map +0 -1
- package/esm/commands/subprocess/types.js +0 -2
- package/esm/commands/subprocess/types.js.map +0 -1
- package/esm/socket/controller.d.ts +0 -37
- package/esm/socket/controller.d.ts.map +0 -1
- package/esm/socket/controller.js +0 -66
- package/esm/socket/controller.js.map +0 -1
- package/esm/stream/detect.bak.d.ts +0 -240
- package/esm/stream/detect.bak.d.ts.map +0 -1
- package/esm/stream/detect.bak.js +0 -60
- package/esm/stream/detect.bak.js.map +0 -1
- package/esm/utils/encoding.d.ts +0 -3
- package/esm/utils/encoding.d.ts.map +0 -1
- package/esm/utils/encoding.js +0 -11
- package/esm/utils/encoding.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './adb.js';
|
|
3
|
-
export * from './auth.js';
|
|
4
|
-
export * from './backend.js';
|
|
5
|
-
export * from './commands/index.js';
|
|
6
|
-
export * from './crypto.js';
|
|
7
|
-
export * from './features.js';
|
|
8
|
-
export * from './packet.js';
|
|
9
|
-
export * from './socket/index.js';
|
|
10
|
-
export * from './stream/index.js';
|
|
11
|
-
export * from './utils/index.js';
|
|
1
|
+
|
|
2
|
+
export * from './adb.js';
|
|
3
|
+
export * from './auth.js';
|
|
4
|
+
export * from './backend.js';
|
|
5
|
+
export * from './commands/index.js';
|
|
6
|
+
export * from './crypto.js';
|
|
7
|
+
export * from './features.js';
|
|
8
|
+
export * from './packet.js';
|
|
9
|
+
export * from './socket/index.js';
|
|
10
|
+
export * from './stream/index.js';
|
|
11
|
+
export * from './utils/index.js';
|
package/src/packet.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import Struct from '@yume-chan/struct';
|
|
2
|
-
import { TransformStream } from "./stream/index.js";
|
|
3
|
-
|
|
4
|
-
export enum AdbCommand {
|
|
5
|
-
Auth = 0x48545541, // 'AUTH'
|
|
6
|
-
Close = 0x45534c43, // 'CLSE'
|
|
7
|
-
Connect = 0x4e584e43, // 'CNXN'
|
|
8
|
-
OK = 0x59414b4f, // 'OKAY'
|
|
9
|
-
Open = 0x4e45504f, // 'OPEN'
|
|
10
|
-
Write = 0x45545257, // 'WRTE'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const AdbPacketHeader =
|
|
14
|
-
new Struct({ littleEndian: true })
|
|
15
|
-
.uint32('command')
|
|
16
|
-
.uint32('arg0')
|
|
17
|
-
.uint32('arg1')
|
|
18
|
-
.uint32('payloadLength')
|
|
19
|
-
.uint32('checksum')
|
|
20
|
-
.int32('magic');
|
|
21
|
-
|
|
22
|
-
export type AdbPacketHeader = typeof AdbPacketHeader['TDeserializeResult'];
|
|
23
|
-
|
|
24
|
-
type AdbPacketHeaderInit = typeof AdbPacketHeader['TInit'];
|
|
25
|
-
|
|
26
|
-
export const AdbPacket =
|
|
27
|
-
new Struct({ littleEndian: true })
|
|
28
|
-
.fields(AdbPacketHeader)
|
|
29
|
-
.uint8Array('payload', { lengthField: 'payloadLength' });
|
|
30
|
-
|
|
31
|
-
export type AdbPacket = typeof AdbPacket['TDeserializeResult'];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* `AdbPacketData` contains all the useful fields of `AdbPacket`.
|
|
35
|
-
*
|
|
36
|
-
* `AdbBackend#connect` will return a `ReadableStream<AdbPacketData>`,
|
|
37
|
-
* so each backend can encode `AdbPacket` in different ways.
|
|
38
|
-
*
|
|
39
|
-
* `AdbBackend#connect` will return a `WritableStream<AdbPacketInit>`,
|
|
40
|
-
* however, `AdbPacketDispatcher` will transform `AdbPacketData` to `AdbPacketInit` for you,
|
|
41
|
-
* so `AdbSocket#writable#write` only needs `AdbPacketData`.
|
|
42
|
-
*/
|
|
43
|
-
export type AdbPacketData = Omit<typeof AdbPacket['TInit'], 'checksum' | 'magic'>;
|
|
44
|
-
|
|
45
|
-
// All fields except `magic`, which can be calculated in `AdbPacketSerializeStream`
|
|
46
|
-
export type AdbPacketInit = Omit<typeof AdbPacket['TInit'], 'magic'>;
|
|
47
|
-
|
|
48
|
-
export function calculateChecksum(payload: Uint8Array): number;
|
|
49
|
-
export function calculateChecksum(init: AdbPacketData): AdbPacketInit;
|
|
50
|
-
export function calculateChecksum(payload: Uint8Array | AdbPacketData): number | AdbPacketInit {
|
|
51
|
-
if (payload instanceof Uint8Array) {
|
|
52
|
-
return payload.reduce((result, item) => result + item, 0);
|
|
53
|
-
} else {
|
|
54
|
-
(payload as AdbPacketInit).checksum = calculateChecksum(payload.payload);
|
|
55
|
-
return payload as AdbPacketInit;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export class AdbPacketSerializeStream extends TransformStream<AdbPacketInit, Uint8Array>{
|
|
60
|
-
public constructor() {
|
|
61
|
-
super({
|
|
62
|
-
transform: async (init, controller) => {
|
|
63
|
-
// This syntax is ugly, but I don't want to create a new object.
|
|
64
|
-
(init as unknown as AdbPacketHeaderInit).magic = init.command ^ 0xFFFFFFFF;
|
|
65
|
-
(init as unknown as AdbPacketHeaderInit).payloadLength = init.payload.byteLength;
|
|
66
|
-
|
|
67
|
-
controller.enqueue(
|
|
68
|
-
AdbPacketHeader.serialize(
|
|
69
|
-
init as unknown as AdbPacketHeaderInit
|
|
70
|
-
)
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
if (init.payload.byteLength) {
|
|
74
|
-
// Enqueue payload separately to avoid copying
|
|
75
|
-
controller.enqueue(init.payload);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
import Struct from '@yume-chan/struct';
|
|
2
|
+
import { TransformStream } from "./stream/index.js";
|
|
3
|
+
|
|
4
|
+
export enum AdbCommand {
|
|
5
|
+
Auth = 0x48545541, // 'AUTH'
|
|
6
|
+
Close = 0x45534c43, // 'CLSE'
|
|
7
|
+
Connect = 0x4e584e43, // 'CNXN'
|
|
8
|
+
OK = 0x59414b4f, // 'OKAY'
|
|
9
|
+
Open = 0x4e45504f, // 'OPEN'
|
|
10
|
+
Write = 0x45545257, // 'WRTE'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const AdbPacketHeader =
|
|
14
|
+
new Struct({ littleEndian: true })
|
|
15
|
+
.uint32('command')
|
|
16
|
+
.uint32('arg0')
|
|
17
|
+
.uint32('arg1')
|
|
18
|
+
.uint32('payloadLength')
|
|
19
|
+
.uint32('checksum')
|
|
20
|
+
.int32('magic');
|
|
21
|
+
|
|
22
|
+
export type AdbPacketHeader = typeof AdbPacketHeader['TDeserializeResult'];
|
|
23
|
+
|
|
24
|
+
type AdbPacketHeaderInit = typeof AdbPacketHeader['TInit'];
|
|
25
|
+
|
|
26
|
+
export const AdbPacket =
|
|
27
|
+
new Struct({ littleEndian: true })
|
|
28
|
+
.fields(AdbPacketHeader)
|
|
29
|
+
.uint8Array('payload', { lengthField: 'payloadLength' });
|
|
30
|
+
|
|
31
|
+
export type AdbPacket = typeof AdbPacket['TDeserializeResult'];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `AdbPacketData` contains all the useful fields of `AdbPacket`.
|
|
35
|
+
*
|
|
36
|
+
* `AdbBackend#connect` will return a `ReadableStream<AdbPacketData>`,
|
|
37
|
+
* so each backend can encode `AdbPacket` in different ways.
|
|
38
|
+
*
|
|
39
|
+
* `AdbBackend#connect` will return a `WritableStream<AdbPacketInit>`,
|
|
40
|
+
* however, `AdbPacketDispatcher` will transform `AdbPacketData` to `AdbPacketInit` for you,
|
|
41
|
+
* so `AdbSocket#writable#write` only needs `AdbPacketData`.
|
|
42
|
+
*/
|
|
43
|
+
export type AdbPacketData = Omit<typeof AdbPacket['TInit'], 'checksum' | 'magic'>;
|
|
44
|
+
|
|
45
|
+
// All fields except `magic`, which can be calculated in `AdbPacketSerializeStream`
|
|
46
|
+
export type AdbPacketInit = Omit<typeof AdbPacket['TInit'], 'magic'>;
|
|
47
|
+
|
|
48
|
+
export function calculateChecksum(payload: Uint8Array): number;
|
|
49
|
+
export function calculateChecksum(init: AdbPacketData): AdbPacketInit;
|
|
50
|
+
export function calculateChecksum(payload: Uint8Array | AdbPacketData): number | AdbPacketInit {
|
|
51
|
+
if (payload instanceof Uint8Array) {
|
|
52
|
+
return payload.reduce((result, item) => result + item, 0);
|
|
53
|
+
} else {
|
|
54
|
+
(payload as AdbPacketInit).checksum = calculateChecksum(payload.payload);
|
|
55
|
+
return payload as AdbPacketInit;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class AdbPacketSerializeStream extends TransformStream<AdbPacketInit, Uint8Array>{
|
|
60
|
+
public constructor() {
|
|
61
|
+
super({
|
|
62
|
+
transform: async (init, controller) => {
|
|
63
|
+
// This syntax is ugly, but I don't want to create a new object.
|
|
64
|
+
(init as unknown as AdbPacketHeaderInit).magic = init.command ^ 0xFFFFFFFF;
|
|
65
|
+
(init as unknown as AdbPacketHeaderInit).payloadLength = init.payload.byteLength;
|
|
66
|
+
|
|
67
|
+
controller.enqueue(
|
|
68
|
+
AdbPacketHeader.serialize(
|
|
69
|
+
init as unknown as AdbPacketHeaderInit
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (init.payload.byteLength) {
|
|
74
|
+
// Enqueue payload separately to avoid copying
|
|
75
|
+
controller.enqueue(init.payload);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|