@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/options/1_23.ts
CHANGED
|
@@ -16,27 +16,27 @@ export class ScrcpyOptions1_23 extends ScrcpyOptionsBase<
|
|
|
16
16
|
ScrcpyOptionsInit1_23,
|
|
17
17
|
ScrcpyOptions1_22
|
|
18
18
|
> {
|
|
19
|
-
|
|
19
|
+
static readonly DEFAULTS = {
|
|
20
20
|
...ScrcpyOptions1_22.DEFAULTS,
|
|
21
21
|
cleanup: true,
|
|
22
22
|
} as const satisfies Required<ScrcpyOptionsInit1_23>;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
override get defaults(): Required<ScrcpyOptionsInit1_23> {
|
|
25
25
|
return ScrcpyOptions1_23.DEFAULTS;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
constructor(init: ScrcpyOptionsInit1_22) {
|
|
29
29
|
super(new ScrcpyOptions1_22(init), {
|
|
30
30
|
...ScrcpyOptions1_23.DEFAULTS,
|
|
31
31
|
...init,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
override serialize(): string[] {
|
|
36
36
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
override createMediaStreamTransformer(): TransformStream<
|
|
40
40
|
Uint8Array,
|
|
41
41
|
ScrcpyMediaStreamPacket
|
|
42
42
|
> {
|
|
@@ -61,7 +61,7 @@ export class ScrcpyOptions1_23 extends ScrcpyOptionsBase<
|
|
|
61
61
|
|
|
62
62
|
controller.enqueue(packet);
|
|
63
63
|
},
|
|
64
|
-
})
|
|
64
|
+
}),
|
|
65
65
|
),
|
|
66
66
|
};
|
|
67
67
|
}
|
package/src/options/1_24.ts
CHANGED
|
@@ -11,23 +11,23 @@ export class ScrcpyOptions1_24 extends ScrcpyOptionsBase<
|
|
|
11
11
|
ScrcpyOptionsInit1_24,
|
|
12
12
|
ScrcpyOptions1_23
|
|
13
13
|
> {
|
|
14
|
-
|
|
14
|
+
static readonly DEFAULTS = {
|
|
15
15
|
...ScrcpyOptions1_23.DEFAULTS,
|
|
16
16
|
powerOn: true,
|
|
17
17
|
} as const satisfies Required<ScrcpyOptionsInit1_24>;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
override get defaults(): Required<ScrcpyOptionsInit1_24> {
|
|
20
20
|
return ScrcpyOptions1_24.DEFAULTS;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
constructor(init: ScrcpyOptionsInit1_24) {
|
|
24
24
|
super(new ScrcpyOptions1_23(init), {
|
|
25
25
|
...ScrcpyOptions1_24.DEFAULTS,
|
|
26
26
|
...init,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
override serialize(): string[] {
|
|
31
31
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -10,22 +10,22 @@ export class ScrcpyOptions1_25 extends ScrcpyOptionsBase<
|
|
|
10
10
|
ScrcpyOptionsInit1_24,
|
|
11
11
|
ScrcpyOptions1_24
|
|
12
12
|
> {
|
|
13
|
-
|
|
13
|
+
override get defaults(): Required<ScrcpyOptionsInit1_24> {
|
|
14
14
|
return ScrcpyOptions1_24.DEFAULTS;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
constructor(init: ScrcpyOptionsInit1_24) {
|
|
18
18
|
super(new ScrcpyOptions1_24(init), {
|
|
19
19
|
...ScrcpyOptions1_24.DEFAULTS,
|
|
20
20
|
...init,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
override serialize(): string[] {
|
|
25
25
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
override createScrollController(): ScrcpyScrollController {
|
|
29
29
|
return new ScrcpyScrollController1_25();
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -25,7 +25,7 @@ export const ScrcpyFloatToInt16NumberType: NumberFieldType = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const ScrcpyFloatToInt16FieldDefinition = new NumberFieldDefinition(
|
|
28
|
-
ScrcpyFloatToInt16NumberType
|
|
28
|
+
ScrcpyFloatToInt16NumberType,
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
export const ScrcpyInjectScrollControlMessage1_25 = new Struct()
|
|
@@ -43,7 +43,7 @@ export type ScrcpyInjectScrollControlMessage1_25 =
|
|
|
43
43
|
|
|
44
44
|
export class ScrcpyScrollController1_25 implements ScrcpyScrollController {
|
|
45
45
|
serializeScrollMessage(
|
|
46
|
-
message: ScrcpyInjectScrollControlMessage
|
|
46
|
+
message: ScrcpyInjectScrollControlMessage,
|
|
47
47
|
): Uint8Array | undefined {
|
|
48
48
|
return ScrcpyInjectScrollControlMessage1_25.serialize(message);
|
|
49
49
|
}
|
package/src/options/2_0.ts
CHANGED
|
@@ -45,20 +45,20 @@ export type ScrcpyInjectTouchControlMessage2_0 =
|
|
|
45
45
|
(typeof ScrcpyInjectTouchControlMessage2_0)["TInit"];
|
|
46
46
|
|
|
47
47
|
export class ScrcpyInstanceId implements ScrcpyOptionValue {
|
|
48
|
-
|
|
48
|
+
static readonly NONE = new ScrcpyInstanceId(-1);
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
static random(): ScrcpyInstanceId {
|
|
51
51
|
// A random 31-bit unsigned integer
|
|
52
52
|
return new ScrcpyInstanceId((Math.random() * 0x80000000) | 0);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
value: number;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
constructor(value: number) {
|
|
58
58
|
this.value = value;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
toOptionValue(): string | undefined {
|
|
62
62
|
if (this.value < 0) {
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
@@ -91,7 +91,7 @@ export interface ScrcpyOptionsInit2_0
|
|
|
91
91
|
|
|
92
92
|
function omit<T extends object, K extends keyof T>(
|
|
93
93
|
obj: T,
|
|
94
|
-
keys: K[]
|
|
94
|
+
keys: K[],
|
|
95
95
|
): Omit<T, K> {
|
|
96
96
|
const result: Record<PropertyKey, unknown> = {};
|
|
97
97
|
for (const key in obj) {
|
|
@@ -106,7 +106,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
106
106
|
ScrcpyOptionsInit2_0,
|
|
107
107
|
ScrcpyOptions1_25
|
|
108
108
|
> {
|
|
109
|
-
|
|
109
|
+
static readonly DEFAULTS = {
|
|
110
110
|
...omit(ScrcpyOptions1_24.DEFAULTS, [
|
|
111
111
|
"bitRate",
|
|
112
112
|
"codecOptions",
|
|
@@ -130,32 +130,32 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
130
130
|
sendCodecMeta: true,
|
|
131
131
|
} as const satisfies Required<ScrcpyOptionsInit2_0>;
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
override get defaults(): Required<ScrcpyOptionsInit2_0> {
|
|
134
134
|
return ScrcpyOptions2_0.DEFAULTS;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
constructor(init: ScrcpyOptionsInit2_0) {
|
|
138
138
|
super(new ScrcpyOptions1_25(init), {
|
|
139
139
|
...ScrcpyOptions2_0.DEFAULTS,
|
|
140
140
|
...init,
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
override serialize(): string[] {
|
|
145
145
|
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
override setListEncoders(): void {
|
|
149
149
|
this.value.listEncoders = true;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
override setListDisplays(): void {
|
|
153
153
|
this.value.listDisplays = true;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
override parseEncoder(line: string): ScrcpyEncoder | undefined {
|
|
157
157
|
let match = line.match(
|
|
158
|
-
/\s+--video-codec=(.*)\s+--video-encoder='(.*)'
|
|
158
|
+
/\s+--video-codec=(.*)\s+--video-encoder='(.*)'/,
|
|
159
159
|
);
|
|
160
160
|
if (match) {
|
|
161
161
|
return {
|
|
@@ -177,7 +177,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
177
177
|
return undefined;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
override parseDisplay(line: string): ScrcpyDisplay | undefined {
|
|
181
181
|
const match = line.match(/\s+--display=(\d+)\s+\((.*?)\)/);
|
|
182
182
|
if (match) {
|
|
183
183
|
const display: ScrcpyDisplay = {
|
|
@@ -191,8 +191,8 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
191
191
|
return undefined;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
stream: ReadableStream<Uint8Array
|
|
194
|
+
override parseVideoStreamMetadata(
|
|
195
|
+
stream: ReadableStream<Uint8Array>,
|
|
196
196
|
): ValueOrPromise<ScrcpyVideoStream> {
|
|
197
197
|
const { sendDeviceMeta, sendCodecMeta } = this.value;
|
|
198
198
|
if (!sendDeviceMeta && !sendCodecMeta) {
|
|
@@ -249,18 +249,18 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
249
249
|
})();
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
stream: ReadableStream<Uint8Array
|
|
252
|
+
override parseAudioStreamMetadata(
|
|
253
|
+
stream: ReadableStream<Uint8Array>,
|
|
254
254
|
): ValueOrPromise<ScrcpyAudioStreamMetadata> {
|
|
255
255
|
return (async (): Promise<ScrcpyAudioStreamMetadata> => {
|
|
256
256
|
const buffered = new BufferedReadableStream(stream);
|
|
257
257
|
const buffer = await buffered.readExactly(
|
|
258
|
-
NumberFieldType.Uint32.size
|
|
258
|
+
NumberFieldType.Uint32.size,
|
|
259
259
|
);
|
|
260
260
|
|
|
261
261
|
const codecMetadataValue = NumberFieldType.Uint32.deserialize(
|
|
262
262
|
buffer,
|
|
263
|
-
false
|
|
263
|
+
false,
|
|
264
264
|
);
|
|
265
265
|
// Server will send `0x00_00_00_00` and `0x00_00_00_01` even if `sendCodecMeta` is false
|
|
266
266
|
switch (codecMetadataValue) {
|
|
@@ -288,7 +288,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
288
288
|
break;
|
|
289
289
|
default:
|
|
290
290
|
throw new Error(
|
|
291
|
-
`Unknown audio codec metadata value: ${codecMetadataValue}
|
|
291
|
+
`Unknown audio codec metadata value: ${codecMetadataValue}`,
|
|
292
292
|
);
|
|
293
293
|
}
|
|
294
294
|
return {
|
|
@@ -328,14 +328,14 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
|
|
|
328
328
|
}
|
|
329
329
|
await controller.enqueue(value);
|
|
330
330
|
}
|
|
331
|
-
}
|
|
331
|
+
},
|
|
332
332
|
),
|
|
333
333
|
};
|
|
334
334
|
})();
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
|
|
338
|
-
message: ScrcpyInjectTouchControlMessage
|
|
337
|
+
override serializeInjectTouchControlMessage(
|
|
338
|
+
message: ScrcpyInjectTouchControlMessage,
|
|
339
339
|
): Uint8Array {
|
|
340
340
|
return ScrcpyInjectTouchControlMessage2_0.serialize(message);
|
|
341
341
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ScrcpyOptions1_21 } from "./1_21.js";
|
|
2
|
+
import type { ScrcpyOptionsInit2_0 } from "./2_0.js";
|
|
3
|
+
import { ScrcpyOptions2_0 } from "./2_0.js";
|
|
4
|
+
import { ScrcpyOptionsBase } from "./types.js";
|
|
5
|
+
|
|
6
|
+
export interface ScrcpyOptionsInit2_1 extends ScrcpyOptionsInit2_0 {
|
|
7
|
+
video?: boolean;
|
|
8
|
+
audioSource?: "output" | "mic";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ScrcpyOptions2_1 extends ScrcpyOptionsBase<
|
|
12
|
+
ScrcpyOptionsInit2_1,
|
|
13
|
+
ScrcpyOptions2_0
|
|
14
|
+
> {
|
|
15
|
+
static readonly DEFAULTS = {
|
|
16
|
+
...ScrcpyOptions2_0.DEFAULTS,
|
|
17
|
+
video: true,
|
|
18
|
+
audioSource: "output",
|
|
19
|
+
} as const satisfies Required<ScrcpyOptionsInit2_1>;
|
|
20
|
+
|
|
21
|
+
override get defaults(): Required<ScrcpyOptionsInit2_1> {
|
|
22
|
+
return ScrcpyOptions2_1.DEFAULTS;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
constructor(init: ScrcpyOptionsInit2_1) {
|
|
26
|
+
super(new ScrcpyOptions2_0(init), {
|
|
27
|
+
...ScrcpyOptions2_1.DEFAULTS,
|
|
28
|
+
...init,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override serialize(): string[] {
|
|
33
|
+
return ScrcpyOptions1_21.serialize(this.value, this.defaults);
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/options/codec.ts
CHANGED
|
@@ -21,35 +21,35 @@ export interface ScrcpyVideoStream {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class ScrcpyAudioCodec implements ScrcpyOptionValue {
|
|
24
|
-
|
|
24
|
+
static readonly OPUS = new ScrcpyAudioCodec(
|
|
25
25
|
"opus",
|
|
26
26
|
0x6f_70_75_73,
|
|
27
27
|
"audio/opus",
|
|
28
|
-
"opus"
|
|
28
|
+
"opus",
|
|
29
29
|
);
|
|
30
|
-
|
|
30
|
+
static readonly AAC = new ScrcpyAudioCodec(
|
|
31
31
|
"aac",
|
|
32
32
|
0x00_61_61_63,
|
|
33
33
|
"audio/aac",
|
|
34
|
-
"mp4a.66"
|
|
34
|
+
"mp4a.66",
|
|
35
35
|
);
|
|
36
|
-
|
|
36
|
+
static readonly RAW = new ScrcpyAudioCodec(
|
|
37
37
|
"raw",
|
|
38
38
|
0x00_72_61_77,
|
|
39
39
|
"audio/raw",
|
|
40
|
-
"1"
|
|
40
|
+
"1",
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
readonly optionValue: string;
|
|
44
|
+
readonly metadataValue: number;
|
|
45
|
+
readonly mimeType: string;
|
|
46
|
+
readonly webCodecId: string;
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
constructor(
|
|
49
49
|
optionValue: string,
|
|
50
50
|
metadataValue: number,
|
|
51
51
|
mimeType: string,
|
|
52
|
-
webCodecId: string
|
|
52
|
+
webCodecId: string,
|
|
53
53
|
) {
|
|
54
54
|
this.optionValue = optionValue;
|
|
55
55
|
this.metadataValue = metadataValue;
|
|
@@ -57,7 +57,7 @@ export class ScrcpyAudioCodec implements ScrcpyOptionValue {
|
|
|
57
57
|
this.webCodecId = webCodecId;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
toOptionValue(): string {
|
|
61
61
|
return this.optionValue;
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/options/index.ts
CHANGED
package/src/options/latest.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ScrcpyLogLevel1_18, ScrcpyVideoOrientation1_18 } from "./1_18.js";
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { ScrcpyOptionsInit2_1 } from "./2_1.js";
|
|
3
|
+
import { ScrcpyOptions2_1 } from "./2_1.js";
|
|
4
4
|
|
|
5
5
|
export const ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
|
6
6
|
export type ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
|
@@ -8,7 +8,5 @@ export type ScrcpyLogLevel = ScrcpyLogLevel1_18;
|
|
|
8
8
|
export const ScrcpyVideoOrientation = ScrcpyVideoOrientation1_18;
|
|
9
9
|
export type ScrcpyVideoOrientation = ScrcpyVideoOrientation1_18;
|
|
10
10
|
|
|
11
|
-
export type ScrcpyOptionsInitLatest =
|
|
12
|
-
export class ScrcpyOptionsLatest extends
|
|
13
|
-
|
|
14
|
-
export const ScrcpyLatestVersion = "2.0";
|
|
11
|
+
export type ScrcpyOptionsInitLatest = ScrcpyOptionsInit2_1;
|
|
12
|
+
export class ScrcpyOptionsLatest extends ScrcpyOptions2_1 {}
|
package/src/options/types.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface ScrcpyOptionValue {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function isScrcpyOptionValue(
|
|
25
|
-
value: unknown
|
|
25
|
+
value: unknown,
|
|
26
26
|
): value is ScrcpyOptionValue {
|
|
27
27
|
return (
|
|
28
28
|
typeof value === "object" &&
|
|
@@ -96,11 +96,11 @@ export interface ScrcpyOptions<T extends object> {
|
|
|
96
96
|
* The returned video stream may be different from the input stream, and should be used for further processing.
|
|
97
97
|
*/
|
|
98
98
|
parseVideoStreamMetadata(
|
|
99
|
-
stream: ReadableStream<Uint8Array
|
|
99
|
+
stream: ReadableStream<Uint8Array>,
|
|
100
100
|
): ValueOrPromise<ScrcpyVideoStream>;
|
|
101
101
|
|
|
102
102
|
parseAudioStreamMetadata(
|
|
103
|
-
stream: ReadableStream<Uint8Array
|
|
103
|
+
stream: ReadableStream<Uint8Array>,
|
|
104
104
|
): ValueOrPromise<ScrcpyAudioStreamMetadata>;
|
|
105
105
|
|
|
106
106
|
createMediaStreamTransformer(): TransformStream<
|
|
@@ -109,15 +109,15 @@ export interface ScrcpyOptions<T extends object> {
|
|
|
109
109
|
>;
|
|
110
110
|
|
|
111
111
|
serializeInjectTouchControlMessage(
|
|
112
|
-
message: ScrcpyInjectTouchControlMessage
|
|
112
|
+
message: ScrcpyInjectTouchControlMessage,
|
|
113
113
|
): Uint8Array;
|
|
114
114
|
|
|
115
115
|
serializeBackOrScreenOnControlMessage(
|
|
116
|
-
message: ScrcpyBackOrScreenOnControlMessage
|
|
116
|
+
message: ScrcpyBackOrScreenOnControlMessage,
|
|
117
117
|
): Uint8Array | undefined;
|
|
118
118
|
|
|
119
119
|
serializeSetClipboardControlMessage(
|
|
120
|
-
message: ScrcpySetClipboardControlMessage
|
|
120
|
+
message: ScrcpySetClipboardControlMessage,
|
|
121
121
|
): Uint8Array;
|
|
122
122
|
|
|
123
123
|
createScrollController(): ScrcpyScrollController;
|
|
@@ -125,39 +125,50 @@ export interface ScrcpyOptions<T extends object> {
|
|
|
125
125
|
|
|
126
126
|
export abstract class ScrcpyOptionsBase<
|
|
127
127
|
T extends object,
|
|
128
|
-
B extends ScrcpyOptions<object
|
|
128
|
+
B extends ScrcpyOptions<object>,
|
|
129
129
|
> implements ScrcpyOptions<T>
|
|
130
130
|
{
|
|
131
131
|
protected _base: B;
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
abstract get defaults(): Required<T>;
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
|
136
136
|
return this._base.controlMessageTypes;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
readonly value: Required<T>;
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
constructor(base: B, value: Required<T>) {
|
|
142
142
|
this._base = base;
|
|
143
143
|
this.value = value;
|
|
144
|
+
this.#setValue();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#setValue() {
|
|
148
|
+
// Share `value` with `_base` class,
|
|
149
|
+
// so updating `_base.value` in `_base.setListEncoders()`/
|
|
150
|
+
// `_base.setListDisplays()` will also update `this.value`.
|
|
151
|
+
Object.assign(this._base, { value: this.value });
|
|
152
|
+
if (this._base instanceof ScrcpyOptionsBase) {
|
|
153
|
+
this._base.#setValue();
|
|
154
|
+
}
|
|
144
155
|
}
|
|
145
156
|
|
|
146
|
-
|
|
157
|
+
abstract serialize(): string[];
|
|
147
158
|
|
|
148
|
-
|
|
159
|
+
setListEncoders(): void {
|
|
149
160
|
this._base.setListEncoders();
|
|
150
161
|
}
|
|
151
162
|
|
|
152
|
-
|
|
163
|
+
setListDisplays(): void {
|
|
153
164
|
this._base.setListDisplays();
|
|
154
165
|
}
|
|
155
166
|
|
|
156
|
-
|
|
167
|
+
parseEncoder(line: string): ScrcpyEncoder | undefined {
|
|
157
168
|
return this._base.parseEncoder(line);
|
|
158
169
|
}
|
|
159
170
|
|
|
160
|
-
|
|
171
|
+
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
|
161
172
|
return this._base.parseDisplay(line);
|
|
162
173
|
}
|
|
163
174
|
|
|
@@ -169,44 +180,44 @@ export abstract class ScrcpyOptionsBase<
|
|
|
169
180
|
*
|
|
170
181
|
* The returned video stream may be different from the input stream, and should be used for further processing.
|
|
171
182
|
*/
|
|
172
|
-
|
|
173
|
-
stream: ReadableStream<Uint8Array
|
|
183
|
+
parseVideoStreamMetadata(
|
|
184
|
+
stream: ReadableStream<Uint8Array>,
|
|
174
185
|
): ValueOrPromise<ScrcpyVideoStream> {
|
|
175
186
|
return this._base.parseVideoStreamMetadata(stream);
|
|
176
187
|
}
|
|
177
188
|
|
|
178
|
-
|
|
179
|
-
stream: ReadableStream<Uint8Array
|
|
189
|
+
parseAudioStreamMetadata(
|
|
190
|
+
stream: ReadableStream<Uint8Array>,
|
|
180
191
|
): ValueOrPromise<ScrcpyAudioStreamMetadata> {
|
|
181
192
|
return this._base.parseAudioStreamMetadata(stream);
|
|
182
193
|
}
|
|
183
194
|
|
|
184
|
-
|
|
195
|
+
createMediaStreamTransformer(): TransformStream<
|
|
185
196
|
Uint8Array,
|
|
186
197
|
ScrcpyMediaStreamPacket
|
|
187
198
|
> {
|
|
188
199
|
return this._base.createMediaStreamTransformer();
|
|
189
200
|
}
|
|
190
201
|
|
|
191
|
-
|
|
192
|
-
message: ScrcpyInjectTouchControlMessage
|
|
202
|
+
serializeInjectTouchControlMessage(
|
|
203
|
+
message: ScrcpyInjectTouchControlMessage,
|
|
193
204
|
): Uint8Array {
|
|
194
205
|
return this._base.serializeInjectTouchControlMessage(message);
|
|
195
206
|
}
|
|
196
207
|
|
|
197
|
-
|
|
198
|
-
message: ScrcpyBackOrScreenOnControlMessage
|
|
208
|
+
serializeBackOrScreenOnControlMessage(
|
|
209
|
+
message: ScrcpyBackOrScreenOnControlMessage,
|
|
199
210
|
): Uint8Array | undefined {
|
|
200
211
|
return this._base.serializeBackOrScreenOnControlMessage(message);
|
|
201
212
|
}
|
|
202
213
|
|
|
203
|
-
|
|
204
|
-
message: ScrcpySetClipboardControlMessage
|
|
214
|
+
serializeSetClipboardControlMessage(
|
|
215
|
+
message: ScrcpySetClipboardControlMessage,
|
|
205
216
|
): Uint8Array {
|
|
206
217
|
return this._base.serializeSetClipboardControlMessage(message);
|
|
207
218
|
}
|
|
208
219
|
|
|
209
|
-
|
|
220
|
+
createScrollController(): ScrcpyScrollController {
|
|
210
221
|
return this._base.createScrollController();
|
|
211
222
|
}
|
|
212
223
|
}
|