@yume-chan/scrcpy 2.0.1 → 2.1.1
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.md +14 -0
- package/README.md +5 -2
- package/esm/1_15/impl/clipboard-stream.d.ts +2 -1
- package/esm/1_15/impl/clipboard-stream.d.ts.map +1 -1
- package/esm/1_15/impl/clipboard-stream.js +4 -7
- package/esm/1_15/impl/clipboard-stream.js.map +1 -1
- package/esm/1_15/impl/defaults.d.ts.map +1 -1
- package/esm/1_15/impl/defaults.js +2 -2
- package/esm/1_15/impl/defaults.js.map +1 -1
- package/esm/1_15/impl/scroll-controller.d.ts.map +1 -1
- package/esm/1_15/impl/scroll-controller.js +22 -21
- package/esm/1_15/impl/scroll-controller.js.map +1 -1
- package/esm/1_15/options.d.ts +2 -3
- package/esm/1_15/options.d.ts.map +1 -1
- package/esm/1_15/options.js +6 -15
- package/esm/1_15/options.js.map +1 -1
- package/esm/1_17/options.d.ts +2 -3
- package/esm/1_17/options.d.ts.map +1 -1
- package/esm/1_17/options.js +6 -15
- package/esm/1_17/options.js.map +1 -1
- package/esm/1_18/options.d.ts +2 -3
- package/esm/1_18/options.d.ts.map +1 -1
- package/esm/1_18/options.js +6 -15
- package/esm/1_18/options.js.map +1 -1
- package/esm/1_21/impl/set-clipboard.d.ts +2 -1
- package/esm/1_21/impl/set-clipboard.d.ts.map +1 -1
- package/esm/1_21/impl/set-clipboard.js +2 -5
- package/esm/1_21/impl/set-clipboard.js.map +1 -1
- package/esm/1_21/options.d.ts +2 -3
- package/esm/1_21/options.d.ts.map +1 -1
- package/esm/1_21/options.js +7 -21
- package/esm/1_21/options.js.map +1 -1
- package/esm/1_22/options.d.ts +2 -3
- package/esm/1_22/options.d.ts.map +1 -1
- package/esm/1_22/options.js +7 -21
- package/esm/1_22/options.js.map +1 -1
- package/esm/1_23/options.d.ts +2 -3
- package/esm/1_23/options.d.ts.map +1 -1
- package/esm/1_23/options.js +7 -21
- package/esm/1_23/options.js.map +1 -1
- package/esm/1_24/options.d.ts +2 -3
- package/esm/1_24/options.d.ts.map +1 -1
- package/esm/1_24/options.js +7 -21
- package/esm/1_24/options.js.map +1 -1
- package/esm/1_25/options.d.ts +2 -3
- package/esm/1_25/options.d.ts.map +1 -1
- package/esm/1_25/options.js +7 -21
- package/esm/1_25/options.js.map +1 -1
- package/esm/2_0/options.d.ts +2 -3
- package/esm/2_0/options.d.ts.map +1 -1
- package/esm/2_0/options.js +7 -21
- package/esm/2_0/options.js.map +1 -1
- package/esm/2_1/options.d.ts +2 -3
- package/esm/2_1/options.d.ts.map +1 -1
- package/esm/2_1/options.js +7 -21
- package/esm/2_1/options.js.map +1 -1
- package/esm/2_2/options.d.ts +2 -3
- package/esm/2_2/options.d.ts.map +1 -1
- package/esm/2_2/options.js +7 -21
- package/esm/2_2/options.js.map +1 -1
- package/esm/2_3/options.d.ts +2 -3
- package/esm/2_3/options.d.ts.map +1 -1
- package/esm/2_3/options.js +7 -21
- package/esm/2_3/options.js.map +1 -1
- package/esm/2_4/impl/uhid-output-stream.d.ts +2 -1
- package/esm/2_4/impl/uhid-output-stream.d.ts.map +1 -1
- package/esm/2_4/impl/uhid-output-stream.js +2 -5
- package/esm/2_4/impl/uhid-output-stream.js.map +1 -1
- package/esm/2_4/options.d.ts +2 -3
- package/esm/2_4/options.d.ts.map +1 -1
- package/esm/2_4/options.js +8 -27
- package/esm/2_4/options.js.map +1 -1
- package/esm/2_6/options.d.ts +2 -3
- package/esm/2_6/options.d.ts.map +1 -1
- package/esm/2_6/options.js +8 -22
- package/esm/2_6/options.js.map +1 -1
- package/esm/2_7/impl/serialize-uhid-create.d.ts +2 -2
- package/esm/2_7/impl/serialize-uhid-create.d.ts.map +1 -1
- package/esm/2_7/impl/serialize-uhid-create.js +3 -4
- package/esm/2_7/impl/serialize-uhid-create.js.map +1 -1
- package/esm/2_7/options.d.ts +2 -3
- package/esm/2_7/options.d.ts.map +1 -1
- package/esm/2_7/options.js +8 -22
- package/esm/2_7/options.js.map +1 -1
- package/esm/3_0/options.d.ts +2 -3
- package/esm/3_0/options.d.ts.map +1 -1
- package/esm/3_0/options.js +8 -22
- package/esm/3_0/options.js.map +1 -1
- package/esm/3_1/impl/serialize-uhid-create.d.ts +2 -2
- package/esm/3_1/impl/serialize-uhid-create.d.ts.map +1 -1
- package/esm/3_1/impl/serialize-uhid-create.js +3 -4
- package/esm/3_1/impl/serialize-uhid-create.js.map +1 -1
- package/esm/3_1/options.d.ts +2 -3
- package/esm/3_1/options.d.ts.map +1 -1
- package/esm/3_1/options.js +8 -22
- package/esm/3_1/options.js.map +1 -1
- package/esm/3_2/impl/defaults.d.ts +57 -0
- package/esm/3_2/impl/defaults.d.ts.map +1 -0
- package/esm/3_2/impl/defaults.js +6 -0
- package/esm/3_2/impl/defaults.js.map +1 -0
- package/esm/3_2/impl/index.d.ts +4 -0
- package/esm/3_2/impl/index.d.ts.map +1 -0
- package/esm/3_2/impl/index.js +3 -0
- package/esm/3_2/impl/index.js.map +1 -0
- package/esm/3_2/impl/init.d.ts +6 -0
- package/esm/3_2/impl/init.d.ts.map +1 -0
- package/esm/3_2/impl/init.js +2 -0
- package/esm/3_2/impl/init.js.map +1 -0
- package/esm/3_2/impl/prev.d.ts +2 -0
- package/esm/3_2/impl/prev.d.ts.map +1 -0
- package/esm/3_2/impl/prev.js +2 -0
- package/esm/3_2/impl/prev.js.map +1 -0
- package/esm/3_2/index.d.ts +2 -0
- package/esm/3_2/index.d.ts.map +1 -0
- package/esm/3_2/index.js +2 -0
- package/esm/3_2/index.js.map +1 -0
- package/esm/3_2/options.d.ts +90 -0
- package/esm/3_2/options.d.ts.map +1 -0
- package/esm/3_2/options.js +78 -0
- package/esm/3_2/options.js.map +1 -0
- package/esm/3_3.d.ts +8 -0
- package/esm/3_3.d.ts.map +1 -0
- package/esm/3_3.js +7 -0
- package/esm/3_3.js.map +1 -0
- package/esm/3_3_1/impl/index.d.ts +3 -0
- package/esm/3_3_1/impl/index.d.ts.map +1 -0
- package/esm/3_3_1/impl/index.js +3 -0
- package/esm/3_3_1/impl/index.js.map +1 -0
- package/esm/3_3_1/impl/prev.d.ts +2 -0
- package/esm/3_3_1/impl/prev.d.ts.map +1 -0
- package/esm/3_3_1/impl/prev.js +2 -0
- package/esm/3_3_1/impl/prev.js.map +1 -0
- package/esm/3_3_1/impl/scroll-controller.d.ts +7 -0
- package/esm/3_3_1/impl/scroll-controller.d.ts.map +1 -0
- package/esm/3_3_1/impl/scroll-controller.js +15 -0
- package/esm/3_3_1/impl/scroll-controller.js.map +1 -0
- package/esm/3_3_1/index.d.ts +2 -0
- package/esm/3_3_1/index.d.ts.map +1 -0
- package/esm/3_3_1/index.js +2 -0
- package/esm/3_3_1/index.js.map +1 -0
- package/esm/3_3_1/options.d.ts +90 -0
- package/esm/3_3_1/options.d.ts.map +1 -0
- package/esm/3_3_1/options.js +78 -0
- package/esm/3_3_1/options.js.map +1 -0
- package/esm/base/device-message.d.ts +10 -1
- package/esm/base/device-message.d.ts.map +1 -1
- package/esm/base/device-message.js +40 -1
- package/esm/base/device-message.js.map +1 -1
- package/esm/base/options.d.ts +2 -3
- package/esm/base/options.d.ts.map +1 -1
- package/esm/control/message-type-map.d.ts +2 -2
- package/esm/control/message-type-map.d.ts.map +1 -1
- package/esm/control/message-type-map.js.map +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -1
- package/esm/latest.d.ts +5 -5
- package/esm/latest.d.ts.map +1 -1
- package/esm/latest.js +3 -3
- package/esm/latest.js.map +1 -1
- package/package.json +9 -9
- package/src/1_15/impl/clipboard-stream.ts +5 -7
- package/src/1_15/impl/defaults.ts +15 -16
- package/src/1_15/impl/scroll-controller.ts +22 -19
- package/src/1_15/options.ts +9 -21
- package/src/1_17/options.ts +9 -21
- package/src/1_18/options.ts +9 -21
- package/src/1_21/impl/set-clipboard.ts +2 -5
- package/src/1_21/options.ts +13 -28
- package/src/1_22/options.ts +13 -28
- package/src/1_23/options.ts +13 -28
- package/src/1_24/options.ts +13 -28
- package/src/1_25/options.ts +13 -28
- package/src/2_0/options.ts +13 -28
- package/src/2_1/options.ts +13 -28
- package/src/2_2/options.ts +13 -28
- package/src/2_3/options.ts +13 -28
- package/src/2_4/impl/uhid-output-stream.ts +3 -6
- package/src/2_4/options.ts +16 -35
- package/src/2_6/options.ts +16 -29
- package/src/2_7/impl/serialize-uhid-create.ts +9 -11
- package/src/2_7/options.ts +16 -29
- package/src/3_0/options.ts +16 -29
- package/src/3_1/impl/serialize-uhid-create.ts +11 -13
- package/src/3_1/options.ts +16 -29
- package/src/3_2/impl/defaults.ts +8 -0
- package/src/3_2/impl/index.ts +3 -0
- package/src/3_2/impl/init.ts +17 -0
- package/src/3_2/impl/prev.ts +1 -0
- package/src/3_2/index.ts +1 -0
- package/src/3_2/options.ts +177 -0
- package/src/3_3.ts +14 -0
- package/src/3_3_1/impl/index.ts +6 -0
- package/src/3_3_1/impl/prev.ts +1 -0
- package/src/3_3_1/impl/scroll-controller.ts +21 -0
- package/src/3_3_1/index.ts +1 -0
- package/src/3_3_1/options.ts +177 -0
- package/src/base/device-message.ts +50 -1
- package/src/base/options.ts +3 -8
- package/src/control/message-type-map.ts +3 -3
- package/src/index.ts +3 -0
- package/src/latest.ts +5 -5
- package/tsconfig.build.tsbuildinfo +1 -1
package/src/3_1/options.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
2
|
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
|
3
|
-
import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
|
|
4
3
|
|
|
5
4
|
import type {
|
|
6
5
|
ScrcpyAudioStreamMetadata,
|
|
@@ -13,6 +12,7 @@ import type {
|
|
|
13
12
|
ScrcpyScrollController,
|
|
14
13
|
ScrcpyVideoStream,
|
|
15
14
|
} from "../base/index.js";
|
|
15
|
+
import { ScrcpyDeviceMessageParsers } from "../base/index.js";
|
|
16
16
|
import type {
|
|
17
17
|
ScrcpyBackOrScreenOnControlMessage,
|
|
18
18
|
ScrcpyInjectTouchControlMessage,
|
|
@@ -67,6 +67,11 @@ export class ScrcpyOptions3_1<TVideo extends boolean>
|
|
|
67
67
|
return this.#uHidOutput;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
|
71
|
+
get deviceMessageParsers() {
|
|
72
|
+
return this.#deviceMessageParsers;
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
constructor(init: Init<TVideo>) {
|
|
71
76
|
this.value = { ...Defaults, ...init } as never;
|
|
72
77
|
|
|
@@ -80,11 +85,18 @@ export class ScrcpyOptions3_1<TVideo extends boolean>
|
|
|
80
85
|
|
|
81
86
|
if (this.value.control) {
|
|
82
87
|
if (this.value.clipboardAutosync) {
|
|
83
|
-
this.#clipboard =
|
|
84
|
-
|
|
88
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
89
|
+
new ClipboardStream(),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
93
|
+
new AckClipboardHandler(),
|
|
94
|
+
);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
|
-
this.#uHidOutput =
|
|
97
|
+
this.#uHidOutput = this.#deviceMessageParsers.add(
|
|
98
|
+
new UHidOutputStream(),
|
|
99
|
+
);
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
|
|
@@ -120,31 +132,6 @@ export class ScrcpyOptions3_1<TVideo extends boolean>
|
|
|
120
132
|
return parseAudioStreamMetadata(stream, this.value);
|
|
121
133
|
}
|
|
122
134
|
|
|
123
|
-
async parseDeviceMessage(
|
|
124
|
-
id: number,
|
|
125
|
-
stream: ExactReadable | AsyncExactReadable,
|
|
126
|
-
): Promise<void> {
|
|
127
|
-
if (await this.#clipboard?.parse(id, stream)) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (await this.#ackClipboardHandler?.parse(id, stream)) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
throw new Error("Unknown device message");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
endDeviceMessageStream(e?: unknown): void {
|
|
139
|
-
if (e) {
|
|
140
|
-
this.#clipboard?.error(e);
|
|
141
|
-
this.#ackClipboardHandler?.error(e);
|
|
142
|
-
} else {
|
|
143
|
-
this.#clipboard?.close();
|
|
144
|
-
this.#ackClipboardHandler?.close();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
135
|
createMediaStreamTransformer(): TransformStream<
|
|
149
136
|
Uint8Array,
|
|
150
137
|
ScrcpyMediaStreamPacket
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PrevImpl } from "./prev.js";
|
|
2
|
+
|
|
3
|
+
export interface Init<TVideo extends boolean>
|
|
4
|
+
extends Omit<PrevImpl.Init<TVideo>, "audioSource"> {
|
|
5
|
+
audioSource?:
|
|
6
|
+
| PrevImpl.Init<TVideo>["audioSource"]
|
|
7
|
+
| "mic-unprocessed"
|
|
8
|
+
| "mic-camcorder"
|
|
9
|
+
| "mic-voice-recognition"
|
|
10
|
+
| "mic-voice-communication"
|
|
11
|
+
| "voice-call"
|
|
12
|
+
| "voice-call-uplink"
|
|
13
|
+
| "voice-call-downlink"
|
|
14
|
+
| "voice-performance";
|
|
15
|
+
|
|
16
|
+
displayImePolicy?: "local" | "fallback" | "hide" | undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as PrevImpl from "../../3_1/impl/index.js";
|
package/src/3_2/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./options.js";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
ScrcpyAudioStreamMetadata,
|
|
6
|
+
ScrcpyControlMessageType,
|
|
7
|
+
ScrcpyDisplay,
|
|
8
|
+
ScrcpyEncoder,
|
|
9
|
+
ScrcpyMediaStreamPacket,
|
|
10
|
+
ScrcpyOptions,
|
|
11
|
+
ScrcpyOptionsListEncoders,
|
|
12
|
+
ScrcpyScrollController,
|
|
13
|
+
ScrcpyVideoStream,
|
|
14
|
+
} from "../base/index.js";
|
|
15
|
+
import { ScrcpyDeviceMessageParsers } from "../base/index.js";
|
|
16
|
+
import type {
|
|
17
|
+
ScrcpyBackOrScreenOnControlMessage,
|
|
18
|
+
ScrcpyInjectTouchControlMessage,
|
|
19
|
+
ScrcpySetClipboardControlMessage,
|
|
20
|
+
ScrcpyUHidCreateControlMessage,
|
|
21
|
+
ScrcpyUHidOutputDeviceMessage,
|
|
22
|
+
} from "../latest.js";
|
|
23
|
+
|
|
24
|
+
import type { Init } from "./impl/index.js";
|
|
25
|
+
import {
|
|
26
|
+
AckClipboardHandler,
|
|
27
|
+
ClipboardStream,
|
|
28
|
+
ControlMessageTypes,
|
|
29
|
+
createMediaStreamTransformer,
|
|
30
|
+
createScrollController,
|
|
31
|
+
Defaults,
|
|
32
|
+
parseAudioStreamMetadata,
|
|
33
|
+
parseDisplay,
|
|
34
|
+
parseEncoder,
|
|
35
|
+
parseVideoStreamMetadata,
|
|
36
|
+
serialize,
|
|
37
|
+
serializeBackOrScreenOnControlMessage,
|
|
38
|
+
serializeInjectTouchControlMessage,
|
|
39
|
+
serializeUHidCreateControlMessage,
|
|
40
|
+
setListDisplays,
|
|
41
|
+
setListEncoders,
|
|
42
|
+
UHidOutputStream,
|
|
43
|
+
} from "./impl/index.js";
|
|
44
|
+
|
|
45
|
+
export class ScrcpyOptions3_2<TVideo extends boolean>
|
|
46
|
+
implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
|
|
47
|
+
{
|
|
48
|
+
static readonly Defaults = Defaults;
|
|
49
|
+
|
|
50
|
+
readonly value: Required<Init<TVideo>>;
|
|
51
|
+
|
|
52
|
+
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
|
53
|
+
return ControlMessageTypes;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#clipboard: ClipboardStream | undefined;
|
|
57
|
+
get clipboard(): ReadableStream<string> | undefined {
|
|
58
|
+
return this.#clipboard;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#ackClipboardHandler: AckClipboardHandler | undefined;
|
|
62
|
+
|
|
63
|
+
#uHidOutput: UHidOutputStream | undefined;
|
|
64
|
+
get uHidOutput():
|
|
65
|
+
| ReadableStream<ScrcpyUHidOutputDeviceMessage>
|
|
66
|
+
| undefined {
|
|
67
|
+
return this.#uHidOutput;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
|
71
|
+
get deviceMessageParsers() {
|
|
72
|
+
return this.#deviceMessageParsers;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
constructor(init: Init<TVideo>) {
|
|
76
|
+
this.value = { ...Defaults, ...init } as never;
|
|
77
|
+
|
|
78
|
+
if (this.value.videoSource === "camera") {
|
|
79
|
+
this.value.control = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.value.audioDup) {
|
|
83
|
+
this.value.audioSource = "playback";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (this.value.control) {
|
|
87
|
+
if (this.value.clipboardAutosync) {
|
|
88
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
89
|
+
new ClipboardStream(),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
93
|
+
new AckClipboardHandler(),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.#uHidOutput = this.#deviceMessageParsers.add(
|
|
98
|
+
new UHidOutputStream(),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
serialize(): string[] {
|
|
104
|
+
return serialize<Init<boolean>>(this.value, Defaults);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setListDisplays(): void {
|
|
108
|
+
setListDisplays(this.value);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
|
112
|
+
return parseDisplay(line);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setListEncoders() {
|
|
116
|
+
setListEncoders(this.value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
parseEncoder(line: string): ScrcpyEncoder | undefined {
|
|
120
|
+
return parseEncoder(line);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
parseVideoStreamMetadata(
|
|
124
|
+
stream: ReadableStream<Uint8Array>,
|
|
125
|
+
): MaybePromiseLike<ScrcpyVideoStream> {
|
|
126
|
+
return parseVideoStreamMetadata(this.value, stream);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
parseAudioStreamMetadata(
|
|
130
|
+
stream: ReadableStream<Uint8Array>,
|
|
131
|
+
): MaybePromiseLike<ScrcpyAudioStreamMetadata> {
|
|
132
|
+
return parseAudioStreamMetadata(stream, this.value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
createMediaStreamTransformer(): TransformStream<
|
|
136
|
+
Uint8Array,
|
|
137
|
+
ScrcpyMediaStreamPacket
|
|
138
|
+
> {
|
|
139
|
+
return createMediaStreamTransformer(this.value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
serializeInjectTouchControlMessage(
|
|
143
|
+
message: ScrcpyInjectTouchControlMessage,
|
|
144
|
+
): Uint8Array {
|
|
145
|
+
return serializeInjectTouchControlMessage(message);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
serializeBackOrScreenOnControlMessage(
|
|
149
|
+
message: ScrcpyBackOrScreenOnControlMessage,
|
|
150
|
+
): Uint8Array | undefined {
|
|
151
|
+
return serializeBackOrScreenOnControlMessage(message);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
serializeSetClipboardControlMessage(
|
|
155
|
+
message: ScrcpySetClipboardControlMessage,
|
|
156
|
+
): Uint8Array | [Uint8Array, Promise<void>] {
|
|
157
|
+
return this.#ackClipboardHandler!.serializeSetClipboardControlMessage(
|
|
158
|
+
message,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
createScrollController(): ScrcpyScrollController {
|
|
163
|
+
return createScrollController();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
serializeUHidCreateControlMessage(
|
|
167
|
+
message: ScrcpyUHidCreateControlMessage,
|
|
168
|
+
): Uint8Array {
|
|
169
|
+
return serializeUHidCreateControlMessage(message);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type Init_<TVideo extends boolean> = Init<TVideo>;
|
|
174
|
+
|
|
175
|
+
export namespace ScrcpyOptions3_2 {
|
|
176
|
+
export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
|
|
177
|
+
}
|
package/src/3_3.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ScrcpyOptions3_2 } from "./3_2/index.js";
|
|
2
|
+
|
|
3
|
+
export class ScrcpyOptions3_3<
|
|
4
|
+
TVideo extends boolean,
|
|
5
|
+
> extends ScrcpyOptions3_2<TVideo> {
|
|
6
|
+
constructor(init: ScrcpyOptions3_2.Init<TVideo>) {
|
|
7
|
+
super(init);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export namespace ScrcpyOptions3_3 {
|
|
12
|
+
export type Init<TVideo extends boolean = boolean> =
|
|
13
|
+
ScrcpyOptions3_2.Init<TVideo>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as PrevImpl from "../../3_2/impl/index.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ScrcpyScrollController } from "../../base/index.js";
|
|
2
|
+
import type { ScrcpyInjectScrollControlMessage } from "../../latest.js";
|
|
3
|
+
|
|
4
|
+
import { PrevImpl } from "./prev.js";
|
|
5
|
+
|
|
6
|
+
export class ScrollController implements ScrcpyScrollController {
|
|
7
|
+
serializeScrollMessage(
|
|
8
|
+
message: ScrcpyInjectScrollControlMessage,
|
|
9
|
+
): Uint8Array | undefined {
|
|
10
|
+
message = {
|
|
11
|
+
...message,
|
|
12
|
+
scrollX: message.scrollX / 16,
|
|
13
|
+
scrollY: message.scrollY / 16,
|
|
14
|
+
};
|
|
15
|
+
return PrevImpl.InjectScrollControlMessage.serialize(message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createScrollController(): ScrcpyScrollController {
|
|
20
|
+
return new ScrollController();
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./options.js";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
ScrcpyAudioStreamMetadata,
|
|
6
|
+
ScrcpyControlMessageType,
|
|
7
|
+
ScrcpyDisplay,
|
|
8
|
+
ScrcpyEncoder,
|
|
9
|
+
ScrcpyMediaStreamPacket,
|
|
10
|
+
ScrcpyOptions,
|
|
11
|
+
ScrcpyOptionsListEncoders,
|
|
12
|
+
ScrcpyScrollController,
|
|
13
|
+
ScrcpyVideoStream,
|
|
14
|
+
} from "../base/index.js";
|
|
15
|
+
import { ScrcpyDeviceMessageParsers } from "../base/index.js";
|
|
16
|
+
import type {
|
|
17
|
+
ScrcpyBackOrScreenOnControlMessage,
|
|
18
|
+
ScrcpyInjectTouchControlMessage,
|
|
19
|
+
ScrcpySetClipboardControlMessage,
|
|
20
|
+
ScrcpyUHidCreateControlMessage,
|
|
21
|
+
ScrcpyUHidOutputDeviceMessage,
|
|
22
|
+
} from "../latest.js";
|
|
23
|
+
|
|
24
|
+
import type { Init } from "./impl/index.js";
|
|
25
|
+
import {
|
|
26
|
+
AckClipboardHandler,
|
|
27
|
+
ClipboardStream,
|
|
28
|
+
ControlMessageTypes,
|
|
29
|
+
createMediaStreamTransformer,
|
|
30
|
+
createScrollController,
|
|
31
|
+
Defaults,
|
|
32
|
+
parseAudioStreamMetadata,
|
|
33
|
+
parseDisplay,
|
|
34
|
+
parseEncoder,
|
|
35
|
+
parseVideoStreamMetadata,
|
|
36
|
+
serialize,
|
|
37
|
+
serializeBackOrScreenOnControlMessage,
|
|
38
|
+
serializeInjectTouchControlMessage,
|
|
39
|
+
serializeUHidCreateControlMessage,
|
|
40
|
+
setListDisplays,
|
|
41
|
+
setListEncoders,
|
|
42
|
+
UHidOutputStream,
|
|
43
|
+
} from "./impl/index.js";
|
|
44
|
+
|
|
45
|
+
export class ScrcpyOptions3_3_1<TVideo extends boolean>
|
|
46
|
+
implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
|
|
47
|
+
{
|
|
48
|
+
static readonly Defaults = Defaults;
|
|
49
|
+
|
|
50
|
+
readonly value: Required<Init<TVideo>>;
|
|
51
|
+
|
|
52
|
+
get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
|
|
53
|
+
return ControlMessageTypes;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#clipboard: ClipboardStream | undefined;
|
|
57
|
+
get clipboard(): ReadableStream<string> | undefined {
|
|
58
|
+
return this.#clipboard;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#ackClipboardHandler: AckClipboardHandler | undefined;
|
|
62
|
+
|
|
63
|
+
#uHidOutput: UHidOutputStream | undefined;
|
|
64
|
+
get uHidOutput():
|
|
65
|
+
| ReadableStream<ScrcpyUHidOutputDeviceMessage>
|
|
66
|
+
| undefined {
|
|
67
|
+
return this.#uHidOutput;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
|
71
|
+
get deviceMessageParsers() {
|
|
72
|
+
return this.#deviceMessageParsers;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
constructor(init: Init<TVideo>) {
|
|
76
|
+
this.value = { ...Defaults, ...init } as never;
|
|
77
|
+
|
|
78
|
+
if (this.value.videoSource === "camera") {
|
|
79
|
+
this.value.control = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.value.audioDup) {
|
|
83
|
+
this.value.audioSource = "playback";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (this.value.control) {
|
|
87
|
+
if (this.value.clipboardAutosync) {
|
|
88
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
89
|
+
new ClipboardStream(),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
93
|
+
new AckClipboardHandler(),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.#uHidOutput = this.#deviceMessageParsers.add(
|
|
98
|
+
new UHidOutputStream(),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
serialize(): string[] {
|
|
104
|
+
return serialize<Init<boolean>>(this.value, Defaults);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setListDisplays(): void {
|
|
108
|
+
setListDisplays(this.value);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
parseDisplay(line: string): ScrcpyDisplay | undefined {
|
|
112
|
+
return parseDisplay(line);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setListEncoders() {
|
|
116
|
+
setListEncoders(this.value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
parseEncoder(line: string): ScrcpyEncoder | undefined {
|
|
120
|
+
return parseEncoder(line);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
parseVideoStreamMetadata(
|
|
124
|
+
stream: ReadableStream<Uint8Array>,
|
|
125
|
+
): MaybePromiseLike<ScrcpyVideoStream> {
|
|
126
|
+
return parseVideoStreamMetadata(this.value, stream);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
parseAudioStreamMetadata(
|
|
130
|
+
stream: ReadableStream<Uint8Array>,
|
|
131
|
+
): MaybePromiseLike<ScrcpyAudioStreamMetadata> {
|
|
132
|
+
return parseAudioStreamMetadata(stream, this.value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
createMediaStreamTransformer(): TransformStream<
|
|
136
|
+
Uint8Array,
|
|
137
|
+
ScrcpyMediaStreamPacket
|
|
138
|
+
> {
|
|
139
|
+
return createMediaStreamTransformer(this.value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
serializeInjectTouchControlMessage(
|
|
143
|
+
message: ScrcpyInjectTouchControlMessage,
|
|
144
|
+
): Uint8Array {
|
|
145
|
+
return serializeInjectTouchControlMessage(message);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
serializeBackOrScreenOnControlMessage(
|
|
149
|
+
message: ScrcpyBackOrScreenOnControlMessage,
|
|
150
|
+
): Uint8Array | undefined {
|
|
151
|
+
return serializeBackOrScreenOnControlMessage(message);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
serializeSetClipboardControlMessage(
|
|
155
|
+
message: ScrcpySetClipboardControlMessage,
|
|
156
|
+
): Uint8Array | [Uint8Array, Promise<void>] {
|
|
157
|
+
return this.#ackClipboardHandler!.serializeSetClipboardControlMessage(
|
|
158
|
+
message,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
createScrollController(): ScrcpyScrollController {
|
|
163
|
+
return createScrollController();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
serializeUHidCreateControlMessage(
|
|
167
|
+
message: ScrcpyUHidCreateControlMessage,
|
|
168
|
+
): Uint8Array {
|
|
169
|
+
return serializeUHidCreateControlMessage(message);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type Init_<TVideo extends boolean> = Init<TVideo>;
|
|
174
|
+
|
|
175
|
+
export namespace ScrcpyOptions3_3_1 {
|
|
176
|
+
export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
|
|
177
|
+
}
|
|
@@ -1,9 +1,58 @@
|
|
|
1
1
|
import type { AsyncExactReadable } from "@yume-chan/struct";
|
|
2
2
|
|
|
3
3
|
export interface ScrcpyDeviceMessageParser {
|
|
4
|
-
|
|
4
|
+
readonly id: number | readonly number[];
|
|
5
|
+
|
|
6
|
+
parse(id: number, stream: AsyncExactReadable): Promise<undefined>;
|
|
5
7
|
|
|
6
8
|
close(): void;
|
|
7
9
|
|
|
8
10
|
error(e?: unknown): void;
|
|
9
11
|
}
|
|
12
|
+
|
|
13
|
+
export class ScrcpyDeviceMessageParsers {
|
|
14
|
+
#parsers: ScrcpyDeviceMessageParser[] = [];
|
|
15
|
+
get parsers(): readonly ScrcpyDeviceMessageParser[] {
|
|
16
|
+
return this.#parsers;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#add(id: number, parser: ScrcpyDeviceMessageParser) {
|
|
20
|
+
if (this.#parsers[id]) {
|
|
21
|
+
throw new Error(`Duplicate parser for id ${id}`);
|
|
22
|
+
}
|
|
23
|
+
this.#parsers[id] = parser;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
add<T extends ScrcpyDeviceMessageParser>(parser: T): T {
|
|
27
|
+
if (Array.isArray(parser.id)) {
|
|
28
|
+
for (const id of parser.id) {
|
|
29
|
+
this.#add(id as number, parser);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
this.#add(parser.id as number, parser);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return parser;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async parse(id: number, stream: AsyncExactReadable): Promise<undefined> {
|
|
39
|
+
const parser = this.#parsers[id];
|
|
40
|
+
if (!parser) {
|
|
41
|
+
throw new Error(`Unknown device message id ${id}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return parser.parse(id, stream);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
close() {
|
|
48
|
+
for (const parser of this.#parsers) {
|
|
49
|
+
parser.close();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
error(e?: unknown) {
|
|
54
|
+
for (const parser of this.#parsers) {
|
|
55
|
+
parser.error(e);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/base/options.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
2
|
import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
|
|
3
|
-
import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
|
|
4
3
|
|
|
5
4
|
import type {
|
|
6
5
|
ScrcpyBackOrScreenOnControlMessage,
|
|
@@ -12,6 +11,7 @@ import type {
|
|
|
12
11
|
|
|
13
12
|
import type { ScrcpyAudioStreamMetadata } from "./audio.js";
|
|
14
13
|
import type { ScrcpyControlMessageType } from "./control-message-type.js";
|
|
14
|
+
import type { ScrcpyDeviceMessageParsers } from "./device-message.js";
|
|
15
15
|
import type { ScrcpyDisplay } from "./display.js";
|
|
16
16
|
import type { ScrcpyEncoder } from "./encoder.js";
|
|
17
17
|
import type { ScrcpyMediaStreamPacket } from "./media.js";
|
|
@@ -29,6 +29,8 @@ export interface ScrcpyOptions<T extends object> {
|
|
|
29
29
|
| ReadableStream<ScrcpyUHidOutputDeviceMessage>
|
|
30
30
|
| undefined;
|
|
31
31
|
|
|
32
|
+
readonly deviceMessageParsers: ScrcpyDeviceMessageParsers;
|
|
33
|
+
|
|
32
34
|
serialize(): string[];
|
|
33
35
|
|
|
34
36
|
setListDisplays(): void;
|
|
@@ -43,13 +45,6 @@ export interface ScrcpyOptions<T extends object> {
|
|
|
43
45
|
stream: ReadableStream<Uint8Array>,
|
|
44
46
|
): MaybePromiseLike<ScrcpyAudioStreamMetadata>;
|
|
45
47
|
|
|
46
|
-
parseDeviceMessage(
|
|
47
|
-
id: number,
|
|
48
|
-
stream: ExactReadable | AsyncExactReadable,
|
|
49
|
-
): Promise<void>;
|
|
50
|
-
|
|
51
|
-
endDeviceMessageStream(e?: unknown): void;
|
|
52
|
-
|
|
53
48
|
createMediaStreamTransformer(): TransformStream<
|
|
54
49
|
Uint8Array,
|
|
55
50
|
ScrcpyMediaStreamPacket
|
|
@@ -20,11 +20,11 @@ export class ScrcpyControlMessageTypeMap {
|
|
|
20
20
|
return value;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
fillMessageType<T extends { type:
|
|
23
|
+
fillMessageType<T extends { type: number }>(
|
|
24
24
|
message: Omit<T, "type">,
|
|
25
|
-
type:
|
|
25
|
+
type: ScrcpyControlMessageType,
|
|
26
26
|
): T {
|
|
27
|
-
(message as T).type = this.get(type)
|
|
27
|
+
(message as T).type = this.get(type);
|
|
28
28
|
return message as T;
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,9 @@ export * from "./3_0/index.js";
|
|
|
25
25
|
export * from "./3_0_1.js";
|
|
26
26
|
export * from "./3_0_2.js";
|
|
27
27
|
export * from "./3_1/index.js";
|
|
28
|
+
export * from "./3_2/index.js";
|
|
29
|
+
export * from "./3_3.js";
|
|
30
|
+
export * from "./3_3_1/index.js";
|
|
28
31
|
export * from "./android/index.js";
|
|
29
32
|
export * from "./base/index.js";
|
|
30
33
|
export * from "./codec/index.js";
|
package/src/latest.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScrcpyOptions3_3_1 } from "./3_3_1/index.js";
|
|
2
2
|
|
|
3
3
|
export class ScrcpyOptionsLatest<
|
|
4
4
|
TVideo extends boolean,
|
|
5
|
-
> extends
|
|
6
|
-
constructor(init:
|
|
5
|
+
> extends ScrcpyOptions3_3_1<TVideo> {
|
|
6
|
+
constructor(init: ScrcpyOptions3_3_1.Init<TVideo>) {
|
|
7
7
|
super(init);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export namespace ScrcpyOptionsLatest {
|
|
12
12
|
export type Init<TVideo extends boolean = boolean> =
|
|
13
|
-
|
|
13
|
+
ScrcpyOptions3_3_1.Init<TVideo>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export {
|
|
@@ -28,4 +28,4 @@ export {
|
|
|
28
28
|
SetClipboardControlMessage as ScrcpySetClipboardControlMessage,
|
|
29
29
|
UHidCreateControlMessage as ScrcpyUHidCreateControlMessage,
|
|
30
30
|
UHidOutputDeviceMessage as ScrcpyUHidOutputDeviceMessage,
|
|
31
|
-
} from "./
|
|
31
|
+
} from "./3_3_1/impl/index.js";
|