@yume-chan/scrcpy 0.0.20 → 0.0.21
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 +15 -0
- package/CHANGELOG.md +9 -1
- package/README.md +8 -122
- package/esm/codec/av1.js +2 -2
- package/esm/codec/av1.js.map +1 -1
- package/esm/codec/h264.js +2 -2
- package/esm/codec/h264.js.map +1 -1
- package/esm/codec/h265.js +2 -2
- package/esm/codec/h265.js.map +1 -1
- package/esm/codec/nalu.d.ts +1 -8
- package/esm/codec/nalu.d.ts.map +1 -1
- package/esm/codec/nalu.js +53 -40
- package/esm/codec/nalu.js.map +1 -1
- package/esm/control/hover-helper.d.ts +1 -1
- package/esm/control/hover-helper.d.ts.map +1 -1
- package/esm/control/hover-helper.js +8 -9
- package/esm/control/hover-helper.js.map +1 -1
- package/esm/control/inject-keycode.js +3 -3
- package/esm/control/inject-keycode.js.map +1 -1
- package/esm/control/inject-touch.js +3 -3
- package/esm/control/inject-touch.js.map +1 -1
- package/esm/control/serializer.d.ts +1 -3
- package/esm/control/serializer.d.ts.map +1 -1
- package/esm/control/serializer.js +14 -14
- package/esm/control/serializer.js.map +1 -1
- package/esm/control/set-screen-power-mode.js +1 -1
- package/esm/control/set-screen-power-mode.js.map +1 -1
- package/esm/control/type.d.ts +1 -1
- package/esm/control/type.d.ts.map +1 -1
- package/esm/control/type.js +4 -4
- package/esm/control/type.js.map +1 -1
- package/esm/control/writer.d.ts +1 -3
- package/esm/control/writer.d.ts.map +1 -1
- package/esm/control/writer.js +17 -17
- package/esm/control/writer.js.map +1 -1
- package/esm/device-message/type.js +1 -1
- package/esm/device-message/type.js.map +1 -1
- package/esm/options/1_16/codec-options.d.ts.map +1 -1
- package/esm/options/1_16/codec-options.js.map +1 -1
- package/esm/options/1_16/init.js +2 -2
- package/esm/options/1_16/init.js.map +1 -1
- package/esm/options/1_16/options.d.ts.map +1 -1
- package/esm/options/1_16/options.js +1 -2
- package/esm/options/1_16/options.js.map +1 -1
- package/esm/options/1_16/scroll.d.ts +1 -2
- package/esm/options/1_16/scroll.d.ts.map +1 -1
- package/esm/options/1_16/scroll.js +12 -12
- package/esm/options/1_16/scroll.js.map +1 -1
- package/esm/options/1_17.d.ts.map +1 -1
- package/esm/options/1_17.js +1 -2
- package/esm/options/1_17.js.map +1 -1
- package/esm/options/1_18.d.ts.map +1 -1
- package/esm/options/1_18.js +3 -4
- package/esm/options/1_18.js.map +1 -1
- package/esm/options/1_21.d.ts.map +1 -1
- package/esm/options/1_21.js +1 -2
- package/esm/options/1_21.js.map +1 -1
- package/esm/options/1_22/options.d.ts.map +1 -1
- package/esm/options/1_22/options.js +1 -2
- package/esm/options/1_22/options.js.map +1 -1
- package/esm/options/1_22/scroll.d.ts.map +1 -1
- package/esm/options/1_22/scroll.js.map +1 -1
- package/esm/options/1_23.d.ts.map +1 -1
- package/esm/options/1_23.js +1 -2
- package/esm/options/1_23.js.map +1 -1
- package/esm/options/1_24.d.ts.map +1 -1
- package/esm/options/1_24.js +1 -2
- package/esm/options/1_24.js.map +1 -1
- package/esm/options/1_25/options.d.ts.map +1 -1
- package/esm/options/1_25/options.js.map +1 -1
- package/esm/options/2_0.d.ts.map +1 -1
- package/esm/options/2_0.js +2 -4
- package/esm/options/2_0.js.map +1 -1
- package/esm/options/2_1.d.ts +48 -0
- package/esm/options/2_1.d.ts.map +1 -0
- package/esm/options/2_1.js +23 -0
- package/esm/options/2_1.js.map +1 -0
- package/esm/options/codec.d.ts.map +1 -1
- package/esm/options/codec.js +2 -3
- package/esm/options/codec.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/options/latest.d.ts +4 -5
- package/esm/options/latest.d.ts.map +1 -1
- package/esm/options/latest.js +2 -3
- package/esm/options/latest.js.map +1 -1
- package/esm/options/types.d.ts +1 -0
- package/esm/options/types.d.ts.map +1 -1
- package/esm/options/types.js +10 -0
- package/esm/options/types.js.map +1 -1
- package/package.json +9 -12
- package/src/codec/h265.ts +14 -14
- package/src/codec/nalu.ts +73 -55
- package/src/control/hover-helper.ts +10 -11
- package/src/control/serializer.ts +31 -35
- package/src/control/type.ts +7 -7
- package/src/control/writer.ts +30 -32
- package/src/device-message/stream.ts +2 -2
- package/src/options/1_16/codec-options.ts +4 -4
- package/src/options/1_16/float-to-uint16.ts +1 -1
- package/src/options/1_16/options.ts +31 -35
- package/src/options/1_16/scroll.ts +16 -16
- package/src/options/1_17.ts +11 -11
- package/src/options/1_18.ts +12 -12
- package/src/options/1_21.ts +9 -9
- package/src/options/1_22/options.ts +7 -7
- package/src/options/1_22/scroll.ts +2 -2
- package/src/options/1_23.ts +6 -6
- package/src/options/1_24.ts +4 -4
- package/src/options/1_25/options.ts +4 -4
- package/src/options/1_25/scroll.ts +2 -2
- package/src/options/2_0.ts +25 -25
- package/src/options/2_1.ts +35 -0
- package/src/options/codec.ts +13 -13
- package/src/options/index.ts +1 -0
- package/src/options/latest.ts +4 -6
- package/src/options/types.ts +39 -28
- package/tsconfig.build.tsbuildinfo +1 -1
- package/bin/scrcpy-server +0 -0
- package/bin/version.d.ts +0 -1
- package/bin/version.js +0 -1
- package/scripts/fetch-server.cjs +0 -38
package/src/control/writer.ts
CHANGED
|
@@ -16,72 +16,70 @@ import { ScrcpyControlMessageSerializer } from "./serializer.js";
|
|
|
16
16
|
import type { AndroidScreenPowerMode } from "./set-screen-power-mode.js";
|
|
17
17
|
|
|
18
18
|
export class ScrcpyControlMessageWriter {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
#writer: WritableStreamDefaultWriter<Consumable<Uint8Array>>;
|
|
20
|
+
#serializer: ScrcpyControlMessageSerializer;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
constructor(
|
|
23
23
|
writer: WritableStreamDefaultWriter<Consumable<Uint8Array>>,
|
|
24
|
-
options: ScrcpyOptions<object
|
|
24
|
+
options: ScrcpyOptions<object>,
|
|
25
25
|
) {
|
|
26
|
-
this
|
|
27
|
-
this
|
|
26
|
+
this.#writer = writer;
|
|
27
|
+
this.#serializer = new ScrcpyControlMessageSerializer(options);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
await ConsumableWritableStream.write(this
|
|
30
|
+
async #write(message: Uint8Array) {
|
|
31
|
+
await ConsumableWritableStream.write(this.#writer, message);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
message: Omit<ScrcpyInjectKeyCodeControlMessage, "type"
|
|
34
|
+
async injectKeyCode(
|
|
35
|
+
message: Omit<ScrcpyInjectKeyCodeControlMessage, "type">,
|
|
36
36
|
) {
|
|
37
|
-
await this
|
|
37
|
+
await this.#write(this.#serializer.injectKeyCode(message));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
await this
|
|
40
|
+
async injectText(text: string) {
|
|
41
|
+
await this.#write(this.#serializer.injectText(text));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* `pressure` is a float value between 0 and 1.
|
|
46
46
|
*/
|
|
47
|
-
|
|
48
|
-
message
|
|
49
|
-
) {
|
|
50
|
-
await this.write(this._serializer.injectTouch(message));
|
|
47
|
+
async injectTouch(message: Omit<ScrcpyInjectTouchControlMessage, "type">) {
|
|
48
|
+
await this.#write(this.#serializer.injectTouch(message));
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
/**
|
|
54
52
|
* `scrollX` and `scrollY` are float values between 0 and 1.
|
|
55
53
|
*/
|
|
56
|
-
|
|
57
|
-
message: Omit<ScrcpyInjectScrollControlMessage, "type"
|
|
54
|
+
async injectScroll(
|
|
55
|
+
message: Omit<ScrcpyInjectScrollControlMessage, "type">,
|
|
58
56
|
) {
|
|
59
|
-
const data = this.
|
|
57
|
+
const data = this.#serializer.injectScroll(message);
|
|
60
58
|
if (data) {
|
|
61
|
-
await this
|
|
59
|
+
await this.#write(data);
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
const data = this.
|
|
63
|
+
async backOrScreenOn(action: AndroidKeyEventAction) {
|
|
64
|
+
const data = this.#serializer.backOrScreenOn(action);
|
|
67
65
|
if (data) {
|
|
68
|
-
await this
|
|
66
|
+
await this.#write(data);
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
await this
|
|
70
|
+
async setScreenPowerMode(mode: AndroidScreenPowerMode) {
|
|
71
|
+
await this.#write(this.#serializer.setScreenPowerMode(mode));
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
await this
|
|
74
|
+
async rotateDevice() {
|
|
75
|
+
await this.#write(this.#serializer.rotateDevice());
|
|
78
76
|
}
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
this.
|
|
78
|
+
releaseLock() {
|
|
79
|
+
this.#writer.releaseLock();
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
await this.
|
|
82
|
+
async close() {
|
|
83
|
+
await this.#writer.close();
|
|
86
84
|
}
|
|
87
85
|
}
|
|
@@ -21,11 +21,11 @@ export class ScrcpyDeviceMessageDeserializeStream extends BufferedTransformStrea
|
|
|
21
21
|
switch (type[0]) {
|
|
22
22
|
case ScrcpyDeviceMessageType.Clipboard:
|
|
23
23
|
return await ScrcpyClipboardDeviceMessage.deserialize(
|
|
24
|
-
stream
|
|
24
|
+
stream,
|
|
25
25
|
);
|
|
26
26
|
case ScrcpyDeviceMessageType.AckClipboard:
|
|
27
27
|
return await ScrcpyAckClipboardDeviceMessage.deserialize(
|
|
28
|
-
stream
|
|
28
|
+
stream,
|
|
29
29
|
);
|
|
30
30
|
default:
|
|
31
31
|
throw new Error("Unsupported control message type");
|
|
@@ -27,15 +27,15 @@ const CODEC_OPTION_TYPES: Partial<
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export class CodecOptions implements ScrcpyOptionValue {
|
|
30
|
-
|
|
30
|
+
value: Partial<CodecOptionsInit>;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
constructor(value: Partial<CodecOptionsInit> = {}) {
|
|
33
33
|
this.value = value;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
toOptionValue(): string | undefined {
|
|
37
37
|
const entries = Object.entries(this.value).filter(
|
|
38
|
-
([, value]) => value !== undefined
|
|
38
|
+
([, value]) => value !== undefined,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
if (entries.length === 0) {
|
|
@@ -38,7 +38,7 @@ import type { ScrcpyScrollController } from "./scroll.js";
|
|
|
38
38
|
import { ScrcpyScrollController1_16 } from "./scroll.js";
|
|
39
39
|
|
|
40
40
|
export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
41
|
-
|
|
41
|
+
static readonly DEFAULTS = {
|
|
42
42
|
logLevel: ScrcpyLogLevel1_16.Debug,
|
|
43
43
|
maxSize: 0,
|
|
44
44
|
bitRate: 8_000_000,
|
|
@@ -54,7 +54,7 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
54
54
|
codecOptions: new CodecOptions(),
|
|
55
55
|
} as const satisfies Required<ScrcpyOptionsInit1_16>;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
static readonly SERIALIZE_ORDER = [
|
|
58
58
|
"logLevel",
|
|
59
59
|
"maxSize",
|
|
60
60
|
"bitRate",
|
|
@@ -70,68 +70,64 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
70
70
|
"codecOptions",
|
|
71
71
|
] as const satisfies readonly (keyof ScrcpyOptionsInit1_16)[];
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
static serialize<T>(options: T, order: readonly (keyof T)[]) {
|
|
74
74
|
return order.map((key) => toScrcpyOptionValue(options[key], "-"));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
static async parseCString(
|
|
78
78
|
stream: AsyncExactReadable,
|
|
79
|
-
maxLength: number
|
|
79
|
+
maxLength: number,
|
|
80
80
|
): Promise<string> {
|
|
81
81
|
let result = decodeUtf8(await stream.readExactly(maxLength));
|
|
82
82
|
result = result.substring(0, result.indexOf("\0"));
|
|
83
83
|
return result;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
stream: AsyncExactReadable
|
|
88
|
-
): Promise<number> {
|
|
86
|
+
static async parseUint16BE(stream: AsyncExactReadable): Promise<number> {
|
|
89
87
|
const buffer = await stream.readExactly(NumberFieldType.Uint16.size);
|
|
90
88
|
return NumberFieldType.Uint16.deserialize(buffer, false);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
stream: AsyncExactReadable
|
|
95
|
-
): Promise<number> {
|
|
91
|
+
static async parseUint32BE(stream: AsyncExactReadable): Promise<number> {
|
|
96
92
|
const buffer = await stream.readExactly(NumberFieldType.Uint32.size);
|
|
97
93
|
return NumberFieldType.Uint32.deserialize(buffer, false);
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
|
|
96
|
+
value: Required<ScrcpyOptionsInit1_16>;
|
|
101
97
|
|
|
102
|
-
|
|
98
|
+
readonly defaults: Required<ScrcpyOptionsInit1_16> =
|
|
103
99
|
ScrcpyOptions1_16.DEFAULTS;
|
|
104
100
|
|
|
105
|
-
|
|
101
|
+
readonly controlMessageTypes: readonly ScrcpyControlMessageType[] =
|
|
106
102
|
SCRCPY_CONTROL_MESSAGE_TYPES_1_16;
|
|
107
103
|
|
|
108
|
-
|
|
104
|
+
constructor(init: ScrcpyOptionsInit1_16) {
|
|
109
105
|
this.value = { ...ScrcpyOptions1_16.DEFAULTS, ...init };
|
|
110
106
|
}
|
|
111
107
|
|
|
112
|
-
|
|
108
|
+
serialize(): string[] {
|
|
113
109
|
return ScrcpyOptions1_16.serialize(
|
|
114
110
|
this.value,
|
|
115
|
-
ScrcpyOptions1_16.SERIALIZE_ORDER
|
|
111
|
+
ScrcpyOptions1_16.SERIALIZE_ORDER,
|
|
116
112
|
);
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
setListEncoders(): void {
|
|
120
116
|
throw new Error("Not supported");
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
|
|
119
|
+
setListDisplays(): void {
|
|
124
120
|
// Set to an invalid value
|
|
125
121
|
// Server will print valid values before crashing
|
|
126
122
|
// (server will crash before opening sockets)
|
|
127
123
|
this.value.displayId = -1;
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
parseEncoder(): ScrcpyEncoder | undefined {
|
|
131
127
|
throw new Error("Not supported");
|
|
132
128
|
}
|
|
133
129
|
|
|
134
|
-
|
|
130
|
+
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
|
135
131
|
const displayIdRegex = /\s+scrcpy --display (\d+)/;
|
|
136
132
|
const match = line.match(displayIdRegex);
|
|
137
133
|
if (match) {
|
|
@@ -142,8 +138,8 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
142
138
|
return undefined;
|
|
143
139
|
}
|
|
144
140
|
|
|
145
|
-
|
|
146
|
-
stream: ReadableStream<Uint8Array
|
|
141
|
+
parseVideoStreamMetadata(
|
|
142
|
+
stream: ReadableStream<Uint8Array>,
|
|
147
143
|
): ValueOrPromise<ScrcpyVideoStream> {
|
|
148
144
|
return (async () => {
|
|
149
145
|
const buffered = new BufferedReadableStream(stream);
|
|
@@ -152,7 +148,7 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
152
148
|
};
|
|
153
149
|
metadata.deviceName = await ScrcpyOptions1_16.parseCString(
|
|
154
150
|
buffered,
|
|
155
|
-
64
|
|
151
|
+
64,
|
|
156
152
|
);
|
|
157
153
|
metadata.width = await ScrcpyOptions1_16.parseUint16BE(buffered);
|
|
158
154
|
metadata.height = await ScrcpyOptions1_16.parseUint16BE(buffered);
|
|
@@ -160,11 +156,11 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
160
156
|
})();
|
|
161
157
|
}
|
|
162
158
|
|
|
163
|
-
|
|
159
|
+
parseAudioStreamMetadata(): never {
|
|
164
160
|
throw new Error("Not supported");
|
|
165
161
|
}
|
|
166
162
|
|
|
167
|
-
|
|
163
|
+
createMediaStreamTransformer(): TransformStream<
|
|
168
164
|
Uint8Array,
|
|
169
165
|
ScrcpyMediaStreamPacket
|
|
170
166
|
> {
|
|
@@ -181,7 +177,7 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
181
177
|
}
|
|
182
178
|
|
|
183
179
|
const deserializeStream = new StructDeserializeStream(
|
|
184
|
-
ScrcpyMediaStreamRawPacket
|
|
180
|
+
ScrcpyMediaStreamRawPacket,
|
|
185
181
|
);
|
|
186
182
|
return {
|
|
187
183
|
writable: deserializeStream.writable,
|
|
@@ -202,19 +198,19 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
202
198
|
data: packet.data,
|
|
203
199
|
});
|
|
204
200
|
},
|
|
205
|
-
})
|
|
201
|
+
}),
|
|
206
202
|
),
|
|
207
203
|
};
|
|
208
204
|
}
|
|
209
205
|
|
|
210
|
-
|
|
211
|
-
message: ScrcpyInjectTouchControlMessage
|
|
206
|
+
serializeInjectTouchControlMessage(
|
|
207
|
+
message: ScrcpyInjectTouchControlMessage,
|
|
212
208
|
): Uint8Array {
|
|
213
209
|
return ScrcpyInjectTouchControlMessage1_16.serialize(message);
|
|
214
210
|
}
|
|
215
211
|
|
|
216
|
-
|
|
217
|
-
message: ScrcpyBackOrScreenOnControlMessage
|
|
212
|
+
serializeBackOrScreenOnControlMessage(
|
|
213
|
+
message: ScrcpyBackOrScreenOnControlMessage,
|
|
218
214
|
) {
|
|
219
215
|
if (message.action === AndroidKeyEventAction.Down) {
|
|
220
216
|
return ScrcpyBackOrScreenOnControlMessage1_16.serialize(message);
|
|
@@ -223,13 +219,13 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
|
|
|
223
219
|
return undefined;
|
|
224
220
|
}
|
|
225
221
|
|
|
226
|
-
|
|
227
|
-
message: ScrcpySetClipboardControlMessage
|
|
222
|
+
serializeSetClipboardControlMessage(
|
|
223
|
+
message: ScrcpySetClipboardControlMessage,
|
|
228
224
|
): Uint8Array {
|
|
229
225
|
return ScrcpySetClipboardControlMessage1_15.serialize(message);
|
|
230
226
|
}
|
|
231
227
|
|
|
232
|
-
|
|
228
|
+
createScrollController(): ScrcpyScrollController {
|
|
233
229
|
return new ScrcpyScrollController1_16();
|
|
234
230
|
}
|
|
235
231
|
}
|
|
@@ -4,7 +4,7 @@ import type { ScrcpyInjectScrollControlMessage } from "../../control/index.js";
|
|
|
4
4
|
|
|
5
5
|
export interface ScrcpyScrollController {
|
|
6
6
|
serializeScrollMessage(
|
|
7
|
-
message: ScrcpyInjectScrollControlMessage
|
|
7
|
+
message: ScrcpyInjectScrollControlMessage,
|
|
8
8
|
): Uint8Array | undefined;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -24,31 +24,31 @@ export const ScrcpyInjectScrollControlMessage1_16 = new Struct()
|
|
|
24
24
|
* reaches 1 or -1.
|
|
25
25
|
*/
|
|
26
26
|
export class ScrcpyScrollController1_16 implements ScrcpyScrollController {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
#accumulatedX = 0;
|
|
28
|
+
#accumulatedY = 0;
|
|
29
29
|
|
|
30
30
|
protected processMessage(
|
|
31
|
-
message: ScrcpyInjectScrollControlMessage
|
|
31
|
+
message: ScrcpyInjectScrollControlMessage,
|
|
32
32
|
): ScrcpyInjectScrollControlMessage | undefined {
|
|
33
|
-
this
|
|
34
|
-
this
|
|
33
|
+
this.#accumulatedX += message.scrollX;
|
|
34
|
+
this.#accumulatedY += message.scrollY;
|
|
35
35
|
|
|
36
36
|
let scrollX = 0;
|
|
37
37
|
let scrollY = 0;
|
|
38
|
-
if (this
|
|
38
|
+
if (this.#accumulatedX >= 1) {
|
|
39
39
|
scrollX = 1;
|
|
40
|
-
this
|
|
41
|
-
} else if (this
|
|
40
|
+
this.#accumulatedX = 0;
|
|
41
|
+
} else if (this.#accumulatedX <= -1) {
|
|
42
42
|
scrollX = -1;
|
|
43
|
-
this
|
|
43
|
+
this.#accumulatedX = 0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
if (this
|
|
46
|
+
if (this.#accumulatedY >= 1) {
|
|
47
47
|
scrollY = 1;
|
|
48
|
-
this
|
|
49
|
-
} else if (this
|
|
48
|
+
this.#accumulatedY = 0;
|
|
49
|
+
} else if (this.#accumulatedY <= -1) {
|
|
50
50
|
scrollY = -1;
|
|
51
|
-
this
|
|
51
|
+
this.#accumulatedY = 0;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (scrollX === 0 && scrollY === 0) {
|
|
@@ -60,8 +60,8 @@ export class ScrcpyScrollController1_16 implements ScrcpyScrollController {
|
|
|
60
60
|
return message;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
message: ScrcpyInjectScrollControlMessage
|
|
63
|
+
serializeScrollMessage(
|
|
64
|
+
message: ScrcpyInjectScrollControlMessage,
|
|
65
65
|
): Uint8Array | undefined {
|
|
66
66
|
const processed = this.processMessage(message);
|
|
67
67
|
if (!processed) {
|
package/src/options/1_17.ts
CHANGED
|
@@ -11,19 +11,19 @@ export class ScrcpyOptions1_17 extends ScrcpyOptionsBase<
|
|
|
11
11
|
ScrcpyOptionsInit1_17,
|
|
12
12
|
ScrcpyOptions1_16
|
|
13
13
|
> {
|
|
14
|
-
|
|
14
|
+
static readonly DEFAULTS = {
|
|
15
15
|
...ScrcpyOptions1_16.DEFAULTS,
|
|
16
16
|
encoderName: undefined,
|
|
17
17
|
} as const satisfies Required<ScrcpyOptionsInit1_17>;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
static readonly SERIALIZE_ORDER = [
|
|
20
20
|
...ScrcpyOptions1_16.SERIALIZE_ORDER,
|
|
21
21
|
"encoderName",
|
|
22
22
|
] as const satisfies readonly (keyof ScrcpyOptionsInit1_17)[];
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
static parseEncoder(
|
|
25
25
|
line: string,
|
|
26
|
-
encoderNameRegex: RegExp
|
|
26
|
+
encoderNameRegex: RegExp,
|
|
27
27
|
): ScrcpyEncoder | undefined {
|
|
28
28
|
const match = line.match(encoderNameRegex);
|
|
29
29
|
if (match) {
|
|
@@ -32,35 +32,35 @@ export class ScrcpyOptions1_17 extends ScrcpyOptionsBase<
|
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
override get defaults(): Required<ScrcpyOptionsInit1_17> {
|
|
36
36
|
return ScrcpyOptions1_17.DEFAULTS;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
constructor(init: ScrcpyOptionsInit1_17) {
|
|
40
40
|
super(new ScrcpyOptions1_16(init), {
|
|
41
41
|
...ScrcpyOptions1_17.DEFAULTS,
|
|
42
42
|
...init,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
override serialize(): string[] {
|
|
47
47
|
return ScrcpyOptions1_16.serialize(
|
|
48
48
|
this.value,
|
|
49
|
-
ScrcpyOptions1_17.SERIALIZE_ORDER
|
|
49
|
+
ScrcpyOptions1_17.SERIALIZE_ORDER,
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
override setListEncoders() {
|
|
54
54
|
// Set to an invalid value
|
|
55
55
|
// Server will print valid values before crashing
|
|
56
56
|
// (server will crash after opening video and control sockets)
|
|
57
57
|
this.value.encoderName = "_";
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
override parseEncoder(line: string): ScrcpyEncoder | undefined {
|
|
61
61
|
return ScrcpyOptions1_17.parseEncoder(
|
|
62
62
|
line,
|
|
63
|
-
/\s+scrcpy --encoder-name '(.*?)'
|
|
63
|
+
/\s+scrcpy --encoder-name '(.*?)'/,
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/options/1_18.ts
CHANGED
|
@@ -56,7 +56,7 @@ export const SCRCPY_CONTROL_MESSAGE_TYPES_1_18 =
|
|
|
56
56
|
SCRCPY_CONTROL_MESSAGE_TYPES_1_18.splice(
|
|
57
57
|
6,
|
|
58
58
|
0,
|
|
59
|
-
ScrcpyControlMessageType.ExpandSettingPanel
|
|
59
|
+
ScrcpyControlMessageType.ExpandSettingPanel,
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
const LOG_LEVEL_MAP = {
|
|
@@ -82,23 +82,23 @@ export class ScrcpyOptions1_18 extends ScrcpyOptionsBase<
|
|
|
82
82
|
ScrcpyOptionsInit1_18,
|
|
83
83
|
ScrcpyOptions1_17
|
|
84
84
|
> {
|
|
85
|
-
|
|
85
|
+
static readonly DEFAULTS = {
|
|
86
86
|
...ScrcpyOptions1_17.DEFAULTS,
|
|
87
87
|
logLevel: ScrcpyLogLevel1_18.Debug,
|
|
88
88
|
lockVideoOrientation: ScrcpyVideoOrientation1_18.Unlocked,
|
|
89
89
|
powerOffOnClose: false,
|
|
90
90
|
} as const satisfies Required<ScrcpyOptionsInit1_18>;
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
static readonly SERIALIZE_ORDER = [
|
|
93
93
|
...ScrcpyOptions1_17.SERIALIZE_ORDER,
|
|
94
94
|
"powerOffOnClose",
|
|
95
95
|
] as const satisfies readonly (keyof ScrcpyOptionsInit1_18)[];
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
override get defaults(): Required<ScrcpyOptionsInit1_18> {
|
|
98
98
|
return ScrcpyOptions1_18.DEFAULTS;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
override get controlMessageTypes() {
|
|
102
102
|
return SCRCPY_CONTROL_MESSAGE_TYPES_1_18;
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -111,26 +111,26 @@ export class ScrcpyOptions1_18 extends ScrcpyOptionsBase<
|
|
|
111
111
|
lockVideoOrientation:
|
|
112
112
|
VIDEO_ORIENTATION_MAP[value.lockVideoOrientation],
|
|
113
113
|
}),
|
|
114
|
-
value
|
|
114
|
+
value,
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
override serialize(): string[] {
|
|
119
119
|
return ScrcpyOptions1_16.serialize(
|
|
120
120
|
this.value,
|
|
121
|
-
ScrcpyOptions1_18.SERIALIZE_ORDER
|
|
121
|
+
ScrcpyOptions1_18.SERIALIZE_ORDER,
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
override parseEncoder(line: string): ScrcpyEncoder | undefined {
|
|
126
126
|
return ScrcpyOptions1_17.parseEncoder(
|
|
127
127
|
line,
|
|
128
|
-
/\s+scrcpy --encoder '(.*?)'
|
|
128
|
+
/\s+scrcpy --encoder '(.*?)'/,
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
message: ScrcpyBackOrScreenOnControlMessage
|
|
132
|
+
override serializeBackOrScreenOnControlMessage(
|
|
133
|
+
message: ScrcpyBackOrScreenOnControlMessage,
|
|
134
134
|
) {
|
|
135
135
|
return ScrcpyBackOrScreenOnControlMessage1_18.serialize(message);
|
|
136
136
|
}
|
package/src/options/1_21.ts
CHANGED
|
@@ -30,14 +30,14 @@ export class ScrcpyOptions1_21 extends ScrcpyOptionsBase<
|
|
|
30
30
|
ScrcpyOptionsInit1_21,
|
|
31
31
|
ScrcpyOptions1_18
|
|
32
32
|
> {
|
|
33
|
-
|
|
33
|
+
static readonly DEFAULTS = {
|
|
34
34
|
...ScrcpyOptions1_18.DEFAULTS,
|
|
35
35
|
clipboardAutosync: true,
|
|
36
36
|
} as const satisfies Required<ScrcpyOptionsInit1_21>;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
static serialize<T extends object>(
|
|
39
39
|
options: T,
|
|
40
|
-
defaults: Required<T
|
|
40
|
+
defaults: Required<T>,
|
|
41
41
|
): string[] {
|
|
42
42
|
// 1.21 changed the format of arguments
|
|
43
43
|
const result: string[] = [];
|
|
@@ -49,7 +49,7 @@ export class ScrcpyOptions1_21 extends ScrcpyOptionsBase<
|
|
|
49
49
|
|
|
50
50
|
const defaultValue = toScrcpyOptionValue(
|
|
51
51
|
defaults[key as keyof T],
|
|
52
|
-
undefined
|
|
52
|
+
undefined,
|
|
53
53
|
);
|
|
54
54
|
if (serializedValue == defaultValue) {
|
|
55
55
|
continue;
|
|
@@ -60,23 +60,23 @@ export class ScrcpyOptions1_21 extends ScrcpyOptionsBase<
|
|
|
60
60
|
return result;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
override get defaults(): Required<ScrcpyOptionsInit1_21> {
|
|
64
64
|
return ScrcpyOptions1_21.DEFAULTS;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
constructor(init: ScrcpyOptionsInit1_21) {
|
|
68
68
|
super(new ScrcpyOptions1_18(init), {
|
|
69
69
|
...ScrcpyOptions1_21.DEFAULTS,
|
|
70
70
|
...init,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
override serialize(): string[] {
|
|
75
75
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
message: ScrcpySetClipboardControlMessage
|
|
78
|
+
override serializeSetClipboardControlMessage(
|
|
79
|
+
message: ScrcpySetClipboardControlMessage,
|
|
80
80
|
): Uint8Array {
|
|
81
81
|
return ScrcpySetClipboardControlMessage1_21.serialize(message);
|
|
82
82
|
}
|
|
@@ -14,26 +14,26 @@ export class ScrcpyOptions1_22 extends ScrcpyOptionsBase<
|
|
|
14
14
|
ScrcpyOptionsInit1_22,
|
|
15
15
|
ScrcpyOptions1_21
|
|
16
16
|
> {
|
|
17
|
-
|
|
17
|
+
static readonly DEFAULTS = {
|
|
18
18
|
...ScrcpyOptions1_21.DEFAULTS,
|
|
19
19
|
downsizeOnError: true,
|
|
20
20
|
sendDeviceMeta: true,
|
|
21
21
|
sendDummyByte: true,
|
|
22
22
|
} as const satisfies Required<ScrcpyOptionsInit1_22>;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
override get defaults(): Required<ScrcpyOptionsInit1_22> {
|
|
25
25
|
return ScrcpyOptions1_22.DEFAULTS;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
constructor(init: ScrcpyOptionsInit1_22) {
|
|
29
29
|
super(new ScrcpyOptions1_21(init), {
|
|
30
30
|
...ScrcpyOptions1_22.DEFAULTS,
|
|
31
31
|
...init,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
stream: ReadableStream<Uint8Array
|
|
35
|
+
override parseVideoStreamMetadata(
|
|
36
|
+
stream: ReadableStream<Uint8Array>,
|
|
37
37
|
): ValueOrPromise<ScrcpyVideoStream> {
|
|
38
38
|
if (!this.value.sendDeviceMeta) {
|
|
39
39
|
return { stream, metadata: { codec: ScrcpyVideoCodecId.H264 } };
|
|
@@ -42,11 +42,11 @@ export class ScrcpyOptions1_22 extends ScrcpyOptionsBase<
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
override serialize(): string[] {
|
|
46
46
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
override createScrollController(): ScrcpyScrollController {
|
|
50
50
|
return new ScrcpyScrollController1_22();
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -13,8 +13,8 @@ export type ScrcpyInjectScrollControlMessage1_22 =
|
|
|
13
13
|
(typeof ScrcpyInjectScrollControlMessage1_22)["TInit"];
|
|
14
14
|
|
|
15
15
|
export class ScrcpyScrollController1_22 extends ScrcpyScrollController1_16 {
|
|
16
|
-
|
|
17
|
-
message: ScrcpyInjectScrollControlMessage1_22
|
|
16
|
+
override serializeScrollMessage(
|
|
17
|
+
message: ScrcpyInjectScrollControlMessage1_22,
|
|
18
18
|
): Uint8Array | undefined {
|
|
19
19
|
const processed = this.processMessage(message);
|
|
20
20
|
if (!processed) {
|