@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/2_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,
|
|
@@ -56,12 +56,22 @@ export class ScrcpyOptions2_1<TVideo extends boolean>
|
|
|
56
56
|
|
|
57
57
|
#ackClipboardHandler: AckClipboardHandler | undefined;
|
|
58
58
|
|
|
59
|
+
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
|
60
|
+
get deviceMessageParsers() {
|
|
61
|
+
return this.#deviceMessageParsers;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
constructor(init: Init<TVideo>) {
|
|
60
65
|
this.value = { ...Defaults, ...init } as never;
|
|
61
66
|
|
|
62
67
|
if (this.value.control && this.value.clipboardAutosync) {
|
|
63
|
-
this.#clipboard =
|
|
64
|
-
|
|
68
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
69
|
+
new ClipboardStream(),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
73
|
+
new AckClipboardHandler(),
|
|
74
|
+
);
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
77
|
|
|
@@ -97,31 +107,6 @@ export class ScrcpyOptions2_1<TVideo extends boolean>
|
|
|
97
107
|
return parseAudioStreamMetadata(stream, this.value);
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
async parseDeviceMessage(
|
|
101
|
-
id: number,
|
|
102
|
-
stream: ExactReadable | AsyncExactReadable,
|
|
103
|
-
): Promise<void> {
|
|
104
|
-
if (await this.#clipboard?.parse(id, stream)) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (await this.#ackClipboardHandler?.parse(id, stream)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
throw new Error("Unknown device message");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
endDeviceMessageStream(e?: unknown): void {
|
|
116
|
-
if (e) {
|
|
117
|
-
this.#clipboard?.error(e);
|
|
118
|
-
this.#ackClipboardHandler?.error(e);
|
|
119
|
-
} else {
|
|
120
|
-
this.#clipboard?.close();
|
|
121
|
-
this.#ackClipboardHandler?.close();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
110
|
createMediaStreamTransformer(): TransformStream<
|
|
126
111
|
Uint8Array,
|
|
127
112
|
ScrcpyMediaStreamPacket
|
package/src/2_2/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,
|
|
@@ -56,6 +56,11 @@ export class ScrcpyOptions2_2<TVideo extends boolean>
|
|
|
56
56
|
|
|
57
57
|
#ackClipboardHandler: AckClipboardHandler | undefined;
|
|
58
58
|
|
|
59
|
+
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
|
60
|
+
get deviceMessageParsers() {
|
|
61
|
+
return this.#deviceMessageParsers;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
constructor(init: Init<TVideo>) {
|
|
60
65
|
this.value = { ...Defaults, ...init } as never;
|
|
61
66
|
|
|
@@ -64,8 +69,13 @@ export class ScrcpyOptions2_2<TVideo extends boolean>
|
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
if (this.value.control && this.value.clipboardAutosync) {
|
|
67
|
-
this.#clipboard =
|
|
68
|
-
|
|
72
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
73
|
+
new ClipboardStream(),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
77
|
+
new AckClipboardHandler(),
|
|
78
|
+
);
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
@@ -101,31 +111,6 @@ export class ScrcpyOptions2_2<TVideo extends boolean>
|
|
|
101
111
|
return parseAudioStreamMetadata(stream, this.value);
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
async parseDeviceMessage(
|
|
105
|
-
id: number,
|
|
106
|
-
stream: ExactReadable | AsyncExactReadable,
|
|
107
|
-
): Promise<void> {
|
|
108
|
-
if (await this.#clipboard?.parse(id, stream)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (await this.#ackClipboardHandler?.parse(id, stream)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
throw new Error("Unknown device message");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
endDeviceMessageStream(e?: unknown): void {
|
|
120
|
-
if (e) {
|
|
121
|
-
this.#clipboard?.error(e);
|
|
122
|
-
this.#ackClipboardHandler?.error(e);
|
|
123
|
-
} else {
|
|
124
|
-
this.#clipboard?.close();
|
|
125
|
-
this.#ackClipboardHandler?.close();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
114
|
createMediaStreamTransformer(): TransformStream<
|
|
130
115
|
Uint8Array,
|
|
131
116
|
ScrcpyMediaStreamPacket
|
package/src/2_3/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,
|
|
@@ -56,6 +56,11 @@ export class ScrcpyOptions2_3<TVideo extends boolean>
|
|
|
56
56
|
|
|
57
57
|
#ackClipboardHandler: AckClipboardHandler | undefined;
|
|
58
58
|
|
|
59
|
+
#deviceMessageParsers = new ScrcpyDeviceMessageParsers();
|
|
60
|
+
get deviceMessageParsers() {
|
|
61
|
+
return this.#deviceMessageParsers;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
constructor(init: Init<TVideo>) {
|
|
60
65
|
this.value = { ...Defaults, ...init } as never;
|
|
61
66
|
|
|
@@ -64,8 +69,13 @@ export class ScrcpyOptions2_3<TVideo extends boolean>
|
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
if (this.value.control && this.value.clipboardAutosync) {
|
|
67
|
-
this.#clipboard =
|
|
68
|
-
|
|
72
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
73
|
+
new ClipboardStream(),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
77
|
+
new AckClipboardHandler(),
|
|
78
|
+
);
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
@@ -101,31 +111,6 @@ export class ScrcpyOptions2_3<TVideo extends boolean>
|
|
|
101
111
|
return parseAudioStreamMetadata(stream, this.value);
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
async parseDeviceMessage(
|
|
105
|
-
id: number,
|
|
106
|
-
stream: ExactReadable | AsyncExactReadable,
|
|
107
|
-
): Promise<void> {
|
|
108
|
-
if (await this.#clipboard?.parse(id, stream)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (await this.#ackClipboardHandler?.parse(id, stream)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
throw new Error("Unknown device message");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
endDeviceMessageStream(e?: unknown): void {
|
|
120
|
-
if (e) {
|
|
121
|
-
this.#clipboard?.error(e);
|
|
122
|
-
this.#ackClipboardHandler?.error(e);
|
|
123
|
-
} else {
|
|
124
|
-
this.#clipboard?.close();
|
|
125
|
-
this.#ackClipboardHandler?.close();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
114
|
createMediaStreamTransformer(): TransformStream<
|
|
130
115
|
Uint8Array,
|
|
131
116
|
ScrcpyMediaStreamPacket
|
|
@@ -23,6 +23,8 @@ export class UHidOutputStream
|
|
|
23
23
|
{
|
|
24
24
|
#controller: PushReadableStreamController<UHidOutputDeviceMessage>;
|
|
25
25
|
|
|
26
|
+
readonly id = 2;
|
|
27
|
+
|
|
26
28
|
constructor() {
|
|
27
29
|
let controller!: PushReadableStreamController<UHidOutputDeviceMessage>;
|
|
28
30
|
super((controller_) => {
|
|
@@ -31,14 +33,9 @@ export class UHidOutputStream
|
|
|
31
33
|
this.#controller = controller;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
async parse(
|
|
35
|
-
if (id !== 2) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
36
|
+
async parse(_id: number, stream: AsyncExactReadable): Promise<undefined> {
|
|
39
37
|
const message = await UHidOutputDeviceMessage.deserialize(stream);
|
|
40
38
|
await this.#controller.enqueue(message);
|
|
41
|
-
return true;
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
close() {
|
package/src/2_4/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 ScrcpyOptions2_4<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
|
|
|
@@ -76,11 +81,18 @@ export class ScrcpyOptions2_4<TVideo extends boolean>
|
|
|
76
81
|
|
|
77
82
|
if (this.value.control) {
|
|
78
83
|
if (this.value.clipboardAutosync) {
|
|
79
|
-
this.#clipboard =
|
|
80
|
-
|
|
84
|
+
this.#clipboard = this.#deviceMessageParsers.add(
|
|
85
|
+
new ClipboardStream(),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
this.#ackClipboardHandler = this.#deviceMessageParsers.add(
|
|
89
|
+
new AckClipboardHandler(),
|
|
90
|
+
);
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
this.#uHidOutput =
|
|
93
|
+
this.#uHidOutput = this.#deviceMessageParsers.add(
|
|
94
|
+
new UHidOutputStream(),
|
|
95
|
+
);
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
98
|
|
|
@@ -116,37 +128,6 @@ export class ScrcpyOptions2_4<TVideo extends boolean>
|
|
|
116
128
|
return parseAudioStreamMetadata(stream, this.value);
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
async parseDeviceMessage(
|
|
120
|
-
id: number,
|
|
121
|
-
stream: ExactReadable | AsyncExactReadable,
|
|
122
|
-
): Promise<void> {
|
|
123
|
-
if (await this.#clipboard?.parse(id, stream)) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (await this.#ackClipboardHandler?.parse(id, stream)) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (await this.#uHidOutput?.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
|
-
this.#uHidOutput?.error(e);
|
|
143
|
-
} else {
|
|
144
|
-
this.#clipboard?.close();
|
|
145
|
-
this.#ackClipboardHandler?.close();
|
|
146
|
-
this.#uHidOutput?.close();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
131
|
createMediaStreamTransformer(): TransformStream<
|
|
151
132
|
Uint8Array,
|
|
152
133
|
ScrcpyMediaStreamPacket
|
package/src/2_6/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 ScrcpyOptions2_6<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 ScrcpyOptions2_6<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 ScrcpyOptions2_6<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
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { StructInit } from "@yume-chan/struct";
|
|
2
2
|
import { buffer, string, struct, u16, u8 } from "@yume-chan/struct";
|
|
3
3
|
|
|
4
|
-
import { ScrcpyControlMessageType } from "../../base/control-message-type.js";
|
|
5
4
|
import type { ScrcpyUHidCreateControlMessage } from "../../latest.js";
|
|
6
5
|
|
|
7
|
-
export const UHidCreateControlMessage =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
))();
|
|
6
|
+
export const UHidCreateControlMessage = struct(
|
|
7
|
+
{
|
|
8
|
+
type: u8,
|
|
9
|
+
id: u16,
|
|
10
|
+
name: string(u8),
|
|
11
|
+
data: buffer(u16),
|
|
12
|
+
},
|
|
13
|
+
{ littleEndian: false },
|
|
14
|
+
);
|
|
17
15
|
|
|
18
16
|
export type UHidCreateControlMessage = StructInit<
|
|
19
17
|
typeof UHidCreateControlMessage
|
package/src/2_7/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 ScrcpyOptions2_7<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 ScrcpyOptions2_7<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 ScrcpyOptions2_7<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
|
package/src/3_0/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_0<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_0<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_0<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
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import type { StructInit } from "@yume-chan/struct";
|
|
2
2
|
import { buffer, string, struct, u16, u8 } from "@yume-chan/struct";
|
|
3
3
|
|
|
4
|
-
import { ScrcpyControlMessageType } from "../../base/control-message-type.js";
|
|
5
4
|
import type { ScrcpyUHidCreateControlMessage } from "../../latest.js";
|
|
6
5
|
|
|
7
|
-
export const UHidCreateControlMessage =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
))();
|
|
6
|
+
export const UHidCreateControlMessage = struct(
|
|
7
|
+
{
|
|
8
|
+
type: u8,
|
|
9
|
+
id: u16,
|
|
10
|
+
vendorId: u16,
|
|
11
|
+
productId: u16,
|
|
12
|
+
name: string(u8),
|
|
13
|
+
data: buffer(u16),
|
|
14
|
+
},
|
|
15
|
+
{ littleEndian: false },
|
|
16
|
+
);
|
|
19
17
|
|
|
20
18
|
export type UHidCreateControlMessage = StructInit<
|
|
21
19
|
typeof UHidCreateControlMessage
|