@yume-chan/scrcpy 0.0.13 → 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 +45 -0
- package/CHANGELOG.md +25 -1
- package/LICENSE +21 -21
- package/README.md +90 -89
- package/bin/scrcpy-server +0 -0
- package/bin/version.d.ts +1 -1
- package/bin/version.js +1 -1
- package/esm/client.d.ts +14 -2
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +275 -143
- package/esm/client.js.map +1 -1
- package/esm/connection.d.ts.map +1 -1
- package/esm/connection.js +74 -86
- package/esm/connection.js.map +1 -1
- package/esm/decoder/tinyh264/index.js +48 -48
- package/esm/decoder/tinyh264/index.js.map +1 -1
- package/esm/decoder/tinyh264/wrapper.js +3 -2
- package/esm/decoder/tinyh264/wrapper.js.map +1 -1
- package/esm/decoder/web-codecs/index.js +26 -21
- package/esm/decoder/web-codecs/index.js.map +1 -1
- package/esm/message.d.ts +13 -8
- package/esm/message.d.ts.map +1 -1
- package/esm/message.js +14 -8
- package/esm/message.js.map +1 -1
- package/esm/options/1_16/index.d.ts +8 -4
- package/esm/options/1_16/index.d.ts.map +1 -1
- package/esm/options/1_16/index.js +44 -18
- package/esm/options/1_16/index.js.map +1 -1
- package/esm/options/1_16/sps.js +3 -2
- package/esm/options/1_16/sps.js.map +1 -1
- package/esm/options/1_18.d.ts +3 -2
- package/esm/options/1_18.d.ts.map +1 -1
- package/esm/options/1_18.js +24 -1
- package/esm/options/1_18.js.map +1 -1
- package/esm/options/1_21.js +4 -1
- package/esm/options/1_21.js.map +1 -1
- package/esm/options/1_22.d.ts +3 -3
- package/esm/options/1_22.d.ts.map +1 -1
- package/esm/options/1_22.js +9 -6
- package/esm/options/1_22.js.map +1 -1
- package/esm/options/1_23.js +4 -1
- package/esm/options/1_23.js.map +1 -1
- package/esm/options/1_24.d.ts +9 -0
- package/esm/options/1_24.d.ts.map +1 -0
- package/esm/options/1_24.js +13 -0
- package/esm/options/1_24.js.map +1 -0
- package/esm/options/common.d.ts +2 -0
- package/esm/options/common.d.ts.map +1 -1
- package/esm/options/common.js.map +1 -1
- package/esm/options/index.d.ts +1 -0
- package/esm/options/index.d.ts.map +1 -1
- package/esm/options/index.js +1 -0
- package/esm/options/index.js.map +1 -1
- package/esm/push-server.js +5 -10
- package/esm/push-server.js.map +1 -1
- package/package.json +8 -8
- package/scrcpy.LICENSE +203 -203
- package/scripts/fetch-server.cjs +28 -28
- package/src/client.ts +435 -275
- package/src/codec.ts +35 -35
- package/src/connection.ts +148 -145
- package/src/decoder/index.ts +3 -3
- package/src/decoder/tinyh264/index.ts +112 -112
- package/src/decoder/tinyh264/types.d.ts +137 -137
- package/src/decoder/tinyh264/worker.ts +2 -2
- package/src/decoder/tinyh264/wrapper.ts +89 -89
- package/src/decoder/types.ts +35 -35
- package/src/decoder/web-codecs/index.ts +99 -99
- package/src/index.ts +8 -8
- package/src/message.ts +113 -105
- package/src/options/1_16/index.ts +345 -315
- package/src/options/1_16/sps.ts +300 -300
- package/src/options/1_18.ts +61 -41
- package/src/options/1_21.ts +34 -34
- package/src/options/1_22.ts +78 -80
- package/src/options/1_24.ts +18 -0
- package/src/options/common.ts +66 -63
- package/src/options/index.ts +7 -6
- package/src/push-server.ts +24 -24
- package/src/utils.ts +5 -5
package/src/options/1_18.ts
CHANGED
|
@@ -1,41 +1,61 @@
|
|
|
1
|
-
import Struct, { placeholder } from "@yume-chan/struct";
|
|
2
|
-
import
|
|
3
|
-
import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16/index.js";
|
|
4
|
-
|
|
5
|
-
export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
|
|
6
|
-
powerOffOnClose: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const ScrcpyBackOrScreenOnEvent1_18 =
|
|
10
|
-
new Struct()
|
|
11
|
-
.fields(ScrcpyBackOrScreenOnEvent1_16)
|
|
12
|
-
.uint8('action', placeholder<AndroidKeyEventAction>());
|
|
13
|
-
|
|
14
|
-
export type ScrcpyBackOrScreenOnEvent1_18 = typeof ScrcpyBackOrScreenOnEvent1_18["TInit"];
|
|
15
|
-
|
|
16
|
-
export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18> extends ScrcpyOptions1_16<T> {
|
|
17
|
-
constructor(value: Partial<ScrcpyOptionsInit1_18>) {
|
|
18
|
-
super(value);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
protected override getArgumentOrder(): (keyof T)[] {
|
|
22
|
-
return super.getArgumentOrder().concat(['powerOffOnClose']);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
protected override getDefaultValue(): T {
|
|
26
|
-
return {
|
|
27
|
-
...super.getDefaultValue(),
|
|
28
|
-
powerOffOnClose: false,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public override getOutputEncoderNameRegex(): RegExp {
|
|
33
|
-
return /\s+scrcpy --encoder '(.*?)'/;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public override
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
import Struct, { placeholder } from "@yume-chan/struct";
|
|
2
|
+
import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../message.js";
|
|
3
|
+
import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16/index.js";
|
|
4
|
+
|
|
5
|
+
export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
|
|
6
|
+
powerOffOnClose: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const ScrcpyBackOrScreenOnEvent1_18 =
|
|
10
|
+
new Struct()
|
|
11
|
+
.fields(ScrcpyBackOrScreenOnEvent1_16)
|
|
12
|
+
.uint8('action', placeholder<AndroidKeyEventAction>());
|
|
13
|
+
|
|
14
|
+
export type ScrcpyBackOrScreenOnEvent1_18 = typeof ScrcpyBackOrScreenOnEvent1_18["TInit"];
|
|
15
|
+
|
|
16
|
+
export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18> extends ScrcpyOptions1_16<T> {
|
|
17
|
+
constructor(value: Partial<ScrcpyOptionsInit1_18>) {
|
|
18
|
+
super(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected override getArgumentOrder(): (keyof T)[] {
|
|
22
|
+
return super.getArgumentOrder().concat(['powerOffOnClose']);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected override getDefaultValue(): T {
|
|
26
|
+
return {
|
|
27
|
+
...super.getDefaultValue(),
|
|
28
|
+
powerOffOnClose: false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public override getOutputEncoderNameRegex(): RegExp {
|
|
33
|
+
return /\s+scrcpy --encoder '(.*?)'/;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public override getControlMessageTypes(): ScrcpyControlMessageType[] {
|
|
37
|
+
/**
|
|
38
|
+
* 0 InjectKeycode
|
|
39
|
+
* 1 InjectText
|
|
40
|
+
* 2 InjectTouch
|
|
41
|
+
* 3 InjectScroll
|
|
42
|
+
* 4 BackOrScreenOn
|
|
43
|
+
* 5 ExpandNotificationPanel
|
|
44
|
+
* 6 ExpandSettingsPanel
|
|
45
|
+
* 7 CollapseNotificationPanel
|
|
46
|
+
* 8 GetClipboard
|
|
47
|
+
* 9 SetClipboard
|
|
48
|
+
* 10 SetScreenPowerMode
|
|
49
|
+
* 11 RotateDevice
|
|
50
|
+
*/
|
|
51
|
+
const types = super.getControlMessageTypes();
|
|
52
|
+
types.splice(6, 0, ScrcpyControlMessageType.ExpandSettingPanel);
|
|
53
|
+
return types;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public override serializeBackOrScreenOnControlMessage(
|
|
57
|
+
message: ScrcpyBackOrScreenOnEvent1_18,
|
|
58
|
+
) {
|
|
59
|
+
return ScrcpyBackOrScreenOnEvent1_18.serialize(message);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/options/1_21.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
// cspell: ignore autosync
|
|
2
|
-
|
|
3
|
-
import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js';
|
|
4
|
-
import { toScrcpyOptionValue } from "./common.js";
|
|
5
|
-
|
|
6
|
-
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
|
|
7
|
-
clipboardAutosync?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function toSnakeCase(input: string): string {
|
|
11
|
-
return input.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21> extends ScrcpyOptions1_18<T> {
|
|
15
|
-
public constructor(init: Partial<ScrcpyOptionsInit1_21>) {
|
|
16
|
-
super(init);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
protected override getDefaultValue(): T {
|
|
20
|
-
return {
|
|
21
|
-
...super.getDefaultValue(),
|
|
22
|
-
clipboardAutosync: true,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public override formatServerArguments(): string[] {
|
|
27
|
-
// 1.21 changed the format of arguments
|
|
28
|
-
// So `getArgumentOrder()` is no longer needed
|
|
29
|
-
return Object.entries(this.value)
|
|
30
|
-
.map(([key, value]) => [key, toScrcpyOptionValue(value, undefined)] as const)
|
|
31
|
-
.filter((pair): pair is [string, string] => pair[1] !== undefined)
|
|
32
|
-
.map(([key, value]) => `${toSnakeCase(key)}=${value}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
// cspell: ignore autosync
|
|
2
|
+
|
|
3
|
+
import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js';
|
|
4
|
+
import { toScrcpyOptionValue } from "./common.js";
|
|
5
|
+
|
|
6
|
+
export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
|
|
7
|
+
clipboardAutosync?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function toSnakeCase(input: string): string {
|
|
11
|
+
return input.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21> extends ScrcpyOptions1_18<T> {
|
|
15
|
+
public constructor(init: Partial<ScrcpyOptionsInit1_21>) {
|
|
16
|
+
super(init);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
protected override getDefaultValue(): T {
|
|
20
|
+
return {
|
|
21
|
+
...super.getDefaultValue(),
|
|
22
|
+
clipboardAutosync: true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public override formatServerArguments(): string[] {
|
|
27
|
+
// 1.21 changed the format of arguments
|
|
28
|
+
// So `getArgumentOrder()` is no longer needed
|
|
29
|
+
return Object.entries(this.value)
|
|
30
|
+
.map(([key, value]) => [key, toScrcpyOptionValue(value, undefined)] as const)
|
|
31
|
+
.filter((pair): pair is [string, string] => pair[1] !== undefined)
|
|
32
|
+
.map(([key, value]) => `${toSnakeCase(key)}=${value}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/options/1_22.ts
CHANGED
|
@@ -1,80 +1,78 @@
|
|
|
1
|
-
import type { Adb } from "@yume-chan/adb";
|
|
2
|
-
import Struct from "@yume-chan/struct";
|
|
3
|
-
import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection
|
|
4
|
-
import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16/index.js";
|
|
5
|
-
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21.js";
|
|
6
|
-
|
|
7
|
-
export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
|
|
8
|
-
downsizeOnError: boolean;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Send device name and size
|
|
12
|
-
*
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
sendDeviceMeta: boolean;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
sendDummyByte: boolean;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Implies `sendDeviceMeta: false`, `sendFrameMeta: false` and `sendDummyByte: false`
|
|
26
|
-
*
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
rawVideoStream: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const ScrcpyInjectScrollControlMessage1_22 =
|
|
33
|
-
new Struct()
|
|
34
|
-
.fields(ScrcpyInjectScrollControlMessage1_16)
|
|
35
|
-
.int32("buttons");
|
|
36
|
-
|
|
37
|
-
export type ScrcpyInjectScrollControlMessage1_22 = typeof ScrcpyInjectScrollControlMessage1_22["TInit"];
|
|
38
|
-
|
|
39
|
-
export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsInit1_22> extends ScrcpyOptions1_21<T> {
|
|
40
|
-
public constructor(init: Partial<ScrcpyOptionsInit1_22>) {
|
|
41
|
-
if (init.rawVideoStream) {
|
|
42
|
-
// Set implied options for client-side processing
|
|
43
|
-
init.sendDeviceMeta = false;
|
|
44
|
-
init.sendFrameMeta = false;
|
|
45
|
-
init.sendDummyByte = false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
super(init);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected override getDefaultValue(): T {
|
|
52
|
-
return {
|
|
53
|
-
...super.getDefaultValue(),
|
|
54
|
-
downsizeOnError: true,
|
|
55
|
-
sendDeviceMeta: true,
|
|
56
|
-
sendDummyByte: true,
|
|
57
|
-
rawVideoStream: false,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public override createConnection(device: Adb): ScrcpyClientConnection {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return new
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
import type { Adb } from "@yume-chan/adb";
|
|
2
|
+
import Struct from "@yume-chan/struct";
|
|
3
|
+
import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection } from "../connection.js";
|
|
4
|
+
import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16/index.js";
|
|
5
|
+
import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21.js";
|
|
6
|
+
|
|
7
|
+
export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
|
|
8
|
+
downsizeOnError: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Send device name and size at start of video stream.
|
|
12
|
+
*
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
sendDeviceMeta: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Send a `0` byte on start of video stream to detect connection issues
|
|
19
|
+
*
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
sendDummyByte: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Implies `sendDeviceMeta: false`, `sendFrameMeta: false` and `sendDummyByte: false`
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
rawVideoStream: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const ScrcpyInjectScrollControlMessage1_22 =
|
|
33
|
+
new Struct()
|
|
34
|
+
.fields(ScrcpyInjectScrollControlMessage1_16)
|
|
35
|
+
.int32("buttons");
|
|
36
|
+
|
|
37
|
+
export type ScrcpyInjectScrollControlMessage1_22 = typeof ScrcpyInjectScrollControlMessage1_22["TInit"];
|
|
38
|
+
|
|
39
|
+
export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsInit1_22> extends ScrcpyOptions1_21<T> {
|
|
40
|
+
public constructor(init: Partial<ScrcpyOptionsInit1_22>) {
|
|
41
|
+
if (init.rawVideoStream) {
|
|
42
|
+
// Set implied options for client-side processing
|
|
43
|
+
init.sendDeviceMeta = false;
|
|
44
|
+
init.sendFrameMeta = false;
|
|
45
|
+
init.sendDummyByte = false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
super(init);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected override getDefaultValue(): T {
|
|
52
|
+
return {
|
|
53
|
+
...super.getDefaultValue(),
|
|
54
|
+
downsizeOnError: true,
|
|
55
|
+
sendDeviceMeta: true,
|
|
56
|
+
sendDummyByte: true,
|
|
57
|
+
rawVideoStream: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public override createConnection(device: Adb): ScrcpyClientConnection {
|
|
62
|
+
const options = {
|
|
63
|
+
...this.getDefaultValue(),
|
|
64
|
+
...this.value,
|
|
65
|
+
};
|
|
66
|
+
if (this.value.tunnelForward) {
|
|
67
|
+
return new ScrcpyClientForwardConnection(device, options);
|
|
68
|
+
} else {
|
|
69
|
+
return new ScrcpyClientReverseConnection(device, options);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public override serializeInjectScrollControlMessage(
|
|
74
|
+
message: ScrcpyInjectScrollControlMessage1_22,
|
|
75
|
+
): Uint8Array {
|
|
76
|
+
return ScrcpyInjectScrollControlMessage1_22.serialize(message);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ScrcpyOptions1_23, type ScrcpyOptionsInit1_23 } from './1_23.js';
|
|
2
|
+
|
|
3
|
+
export interface ScrcpyOptionsInit1_24 extends ScrcpyOptionsInit1_23 {
|
|
4
|
+
powerOn: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24> extends ScrcpyOptions1_23<T> {
|
|
8
|
+
public constructor(init: Partial<ScrcpyOptionsInit1_24>) {
|
|
9
|
+
super(init);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
protected override getDefaultValue(): T {
|
|
13
|
+
return {
|
|
14
|
+
...super.getDefaultValue(),
|
|
15
|
+
powerOn: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/options/common.ts
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
|
-
import type { Adb, TransformStream } from "@yume-chan/adb";
|
|
2
|
-
import type { ScrcpyClientConnection } from "../connection.js";
|
|
3
|
-
import type { H264Configuration } from "../decoder/index.js";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import type { Adb, TransformStream } from "@yume-chan/adb";
|
|
2
|
+
import type { ScrcpyClientConnection } from "../connection.js";
|
|
3
|
+
import type { H264Configuration } from "../decoder/index.js";
|
|
4
|
+
import type { ScrcpyControlMessageType } from "../message.js";
|
|
5
|
+
import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18.js";
|
|
6
|
+
import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22.js";
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar';
|
|
9
|
+
|
|
10
|
+
export interface ScrcpyOptionValue {
|
|
11
|
+
toOptionValue(): string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isScrcpyOptionValue(value: any): value is ScrcpyOptionValue {
|
|
15
|
+
return typeof value === 'object' &&
|
|
16
|
+
value !== null &&
|
|
17
|
+
typeof value.toOptionValue === 'function';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function toScrcpyOptionValue<T>(value: any, empty: T): string | T {
|
|
21
|
+
if (isScrcpyOptionValue(value)) {
|
|
22
|
+
value = value.toOptionValue();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
return empty;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return `${value}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface VideoStreamConfigurationPacket {
|
|
33
|
+
type: 'configuration';
|
|
34
|
+
data: H264Configuration;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface VideoStreamFramePacket {
|
|
38
|
+
type: 'frame';
|
|
39
|
+
keyframe?: boolean | undefined;
|
|
40
|
+
pts?: bigint | undefined;
|
|
41
|
+
data: Uint8Array;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type VideoStreamPacket = VideoStreamConfigurationPacket | VideoStreamFramePacket;
|
|
45
|
+
|
|
46
|
+
export interface ScrcpyOptions<T> {
|
|
47
|
+
value: Partial<T>;
|
|
48
|
+
|
|
49
|
+
formatServerArguments(): string[];
|
|
50
|
+
|
|
51
|
+
getOutputEncoderNameRegex(): RegExp;
|
|
52
|
+
|
|
53
|
+
createConnection(adb: Adb): ScrcpyClientConnection;
|
|
54
|
+
|
|
55
|
+
createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
|
|
56
|
+
|
|
57
|
+
getControlMessageTypes(): ScrcpyControlMessageType[];
|
|
58
|
+
|
|
59
|
+
serializeBackOrScreenOnControlMessage(
|
|
60
|
+
message: ScrcpyBackOrScreenOnEvent1_18,
|
|
61
|
+
): Uint8Array | undefined;
|
|
62
|
+
|
|
63
|
+
serializeInjectScrollControlMessage(
|
|
64
|
+
message: ScrcpyInjectScrollControlMessage1_22,
|
|
65
|
+
): Uint8Array;
|
|
66
|
+
}
|
package/src/options/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './1_16/index.js';
|
|
2
|
-
export * from './1_18.js';
|
|
3
|
-
export * from './1_21.js';
|
|
4
|
-
export * from './1_22.js';
|
|
5
|
-
export * from './1_23.js';
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './1_16/index.js';
|
|
2
|
+
export * from './1_18.js';
|
|
3
|
+
export * from './1_21.js';
|
|
4
|
+
export * from './1_22.js';
|
|
5
|
+
export * from './1_23.js';
|
|
6
|
+
export * from './1_24.js';
|
|
7
|
+
export * from './common.js';
|
package/src/push-server.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { WrapWritableStream, type Adb, type AdbSync } from "@yume-chan/adb";
|
|
2
|
-
import { DEFAULT_SERVER_PATH } from "./options/index.js";
|
|
3
|
-
|
|
4
|
-
export interface PushServerOptions {
|
|
5
|
-
path?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function pushServer(
|
|
9
|
-
device: Adb,
|
|
10
|
-
options: PushServerOptions = {}
|
|
11
|
-
) {
|
|
12
|
-
const { path = DEFAULT_SERVER_PATH } = options;
|
|
13
|
-
|
|
14
|
-
let sync!: AdbSync;
|
|
15
|
-
return new WrapWritableStream<Uint8Array>({
|
|
16
|
-
async start() {
|
|
17
|
-
sync = await device.sync();
|
|
18
|
-
return sync.write(path);
|
|
19
|
-
},
|
|
20
|
-
async close() {
|
|
21
|
-
await sync.dispose();
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
1
|
+
import { WrapWritableStream, type Adb, type AdbSync } from "@yume-chan/adb";
|
|
2
|
+
import { DEFAULT_SERVER_PATH } from "./options/index.js";
|
|
3
|
+
|
|
4
|
+
export interface PushServerOptions {
|
|
5
|
+
path?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function pushServer(
|
|
9
|
+
device: Adb,
|
|
10
|
+
options: PushServerOptions = {}
|
|
11
|
+
) {
|
|
12
|
+
const { path = DEFAULT_SERVER_PATH } = options;
|
|
13
|
+
|
|
14
|
+
let sync!: AdbSync;
|
|
15
|
+
return new WrapWritableStream<Uint8Array>({
|
|
16
|
+
async start() {
|
|
17
|
+
sync = await device.sync();
|
|
18
|
+
return sync.write(path);
|
|
19
|
+
},
|
|
20
|
+
async close() {
|
|
21
|
+
await sync.dispose();
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function delay(time: number): Promise<void> {
|
|
2
|
-
return new Promise(resolve => {
|
|
3
|
-
(globalThis as any).setTimeout(resolve, time);
|
|
4
|
-
});
|
|
5
|
-
}
|
|
1
|
+
export function delay(time: number): Promise<void> {
|
|
2
|
+
return new Promise(resolve => {
|
|
3
|
+
(globalThis as any).setTimeout(resolve, time);
|
|
4
|
+
});
|
|
5
|
+
}
|