@yume-chan/scrcpy 1.0.0 → 1.1.0

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.
Files changed (253) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/1_15/impl/defaults.d.ts +1 -2
  3. package/esm/1_15/impl/defaults.d.ts.map +1 -1
  4. package/esm/1_15/impl/defaults.js +2 -2
  5. package/esm/1_15/impl/defaults.js.map +1 -1
  6. package/esm/1_15/impl/init.d.ts +10 -2
  7. package/esm/1_15/impl/init.d.ts.map +1 -1
  8. package/esm/1_15/impl/init.js +15 -0
  9. package/esm/1_15/impl/init.js.map +1 -1
  10. package/esm/1_15/options.d.ts +3 -2
  11. package/esm/1_15/options.d.ts.map +1 -1
  12. package/esm/1_15/options.js +3 -1
  13. package/esm/1_15/options.js.map +1 -1
  14. package/esm/1_15_1.d.ts +6 -0
  15. package/esm/1_15_1.d.ts.map +1 -0
  16. package/esm/1_15_1.js +8 -0
  17. package/esm/1_15_1.js.map +1 -0
  18. package/esm/1_16.d.ts +5 -1
  19. package/esm/1_16.d.ts.map +1 -1
  20. package/esm/1_16.js +7 -1
  21. package/esm/1_16.js.map +1 -1
  22. package/esm/1_17/impl/defaults.d.ts +1 -2
  23. package/esm/1_17/impl/defaults.d.ts.map +1 -1
  24. package/esm/1_17/options.d.ts +3 -2
  25. package/esm/1_17/options.d.ts.map +1 -1
  26. package/esm/1_17/options.js +3 -1
  27. package/esm/1_17/options.js.map +1 -1
  28. package/esm/1_18/impl/defaults.d.ts +1 -2
  29. package/esm/1_18/impl/defaults.d.ts.map +1 -1
  30. package/esm/1_18/options.d.ts +3 -2
  31. package/esm/1_18/options.d.ts.map +1 -1
  32. package/esm/1_18/options.js +3 -1
  33. package/esm/1_18/options.js.map +1 -1
  34. package/esm/1_19.d.ts +5 -1
  35. package/esm/1_19.d.ts.map +1 -1
  36. package/esm/1_19.js +7 -1
  37. package/esm/1_19.js.map +1 -1
  38. package/esm/1_20.d.ts +5 -1
  39. package/esm/1_20.d.ts.map +1 -1
  40. package/esm/1_20.js +7 -1
  41. package/esm/1_20.js.map +1 -1
  42. package/esm/1_21/impl/defaults.d.ts +1 -2
  43. package/esm/1_21/impl/defaults.d.ts.map +1 -1
  44. package/esm/1_21/options.d.ts +3 -2
  45. package/esm/1_21/options.d.ts.map +1 -1
  46. package/esm/1_21/options.js +3 -1
  47. package/esm/1_21/options.js.map +1 -1
  48. package/esm/1_22/impl/defaults.d.ts +1 -2
  49. package/esm/1_22/impl/defaults.d.ts.map +1 -1
  50. package/esm/1_22/impl/index.d.ts +1 -1
  51. package/esm/1_22/impl/index.d.ts.map +1 -1
  52. package/esm/1_22/impl/index.js +1 -1
  53. package/esm/1_22/impl/index.js.map +1 -1
  54. package/esm/1_22/impl/scroll-controller.d.ts +2 -0
  55. package/esm/1_22/impl/scroll-controller.d.ts.map +1 -1
  56. package/esm/1_22/impl/scroll-controller.js +3 -0
  57. package/esm/1_22/impl/scroll-controller.js.map +1 -1
  58. package/esm/1_22/options.d.ts +3 -2
  59. package/esm/1_22/options.d.ts.map +1 -1
  60. package/esm/1_22/options.js +3 -1
  61. package/esm/1_22/options.js.map +1 -1
  62. package/esm/1_23/impl/defaults.d.ts +1 -2
  63. package/esm/1_23/impl/defaults.d.ts.map +1 -1
  64. package/esm/1_23/options.d.ts +3 -2
  65. package/esm/1_23/options.d.ts.map +1 -1
  66. package/esm/1_23/options.js +3 -1
  67. package/esm/1_23/options.js.map +1 -1
  68. package/esm/1_24/impl/defaults.d.ts +1 -2
  69. package/esm/1_24/impl/defaults.d.ts.map +1 -1
  70. package/esm/1_24/options.d.ts +3 -2
  71. package/esm/1_24/options.d.ts.map +1 -1
  72. package/esm/1_24/options.js +3 -1
  73. package/esm/1_24/options.js.map +1 -1
  74. package/esm/1_25/impl/index.d.ts +1 -1
  75. package/esm/1_25/impl/index.d.ts.map +1 -1
  76. package/esm/1_25/impl/index.js +1 -1
  77. package/esm/1_25/impl/index.js.map +1 -1
  78. package/esm/1_25/impl/scroll-controller.d.ts +1 -0
  79. package/esm/1_25/impl/scroll-controller.d.ts.map +1 -1
  80. package/esm/1_25/impl/scroll-controller.js +3 -0
  81. package/esm/1_25/impl/scroll-controller.js.map +1 -1
  82. package/esm/1_25/options.d.ts +3 -2
  83. package/esm/1_25/options.d.ts.map +1 -1
  84. package/esm/1_25/options.js +3 -1
  85. package/esm/1_25/options.js.map +1 -1
  86. package/esm/2_0/impl/defaults.d.ts +4 -6
  87. package/esm/2_0/impl/defaults.d.ts.map +1 -1
  88. package/esm/2_0/impl/defaults.js +3 -4
  89. package/esm/2_0/impl/defaults.js.map +1 -1
  90. package/esm/2_0/impl/init.d.ts +3 -3
  91. package/esm/2_0/impl/init.d.ts.map +1 -1
  92. package/esm/2_0/options.d.ts +6 -5
  93. package/esm/2_0/options.d.ts.map +1 -1
  94. package/esm/2_0/options.js +3 -1
  95. package/esm/2_0/options.js.map +1 -1
  96. package/esm/2_1/impl/defaults.d.ts +4 -5
  97. package/esm/2_1/impl/defaults.d.ts.map +1 -1
  98. package/esm/2_1/options.d.ts +6 -5
  99. package/esm/2_1/options.d.ts.map +1 -1
  100. package/esm/2_1/options.js +3 -1
  101. package/esm/2_1/options.js.map +1 -1
  102. package/esm/2_1_1.d.ts +6 -0
  103. package/esm/2_1_1.d.ts.map +1 -0
  104. package/esm/2_1_1.js +8 -0
  105. package/esm/2_1_1.js.map +1 -0
  106. package/esm/2_2/impl/defaults.d.ts +4 -5
  107. package/esm/2_2/impl/defaults.d.ts.map +1 -1
  108. package/esm/2_2/options.d.ts +6 -5
  109. package/esm/2_2/options.d.ts.map +1 -1
  110. package/esm/2_2/options.js +3 -1
  111. package/esm/2_2/options.js.map +1 -1
  112. package/esm/2_3/options.d.ts +6 -5
  113. package/esm/2_3/options.d.ts.map +1 -1
  114. package/esm/2_3/options.js +3 -1
  115. package/esm/2_3/options.js.map +1 -1
  116. package/esm/2_3_1.d.ts +6 -0
  117. package/esm/2_3_1.d.ts.map +1 -0
  118. package/esm/2_3_1.js +8 -0
  119. package/esm/2_3_1.js.map +1 -0
  120. package/esm/2_4/options.d.ts +6 -5
  121. package/esm/2_4/options.d.ts.map +1 -1
  122. package/esm/2_4/options.js +3 -1
  123. package/esm/2_4/options.js.map +1 -1
  124. package/esm/2_5.d.ts +5 -1
  125. package/esm/2_5.d.ts.map +1 -1
  126. package/esm/2_5.js +7 -1
  127. package/esm/2_5.js.map +1 -1
  128. package/esm/2_6/impl/defaults.d.ts +4 -5
  129. package/esm/2_6/impl/defaults.d.ts.map +1 -1
  130. package/esm/2_6/options.d.ts +6 -5
  131. package/esm/2_6/options.d.ts.map +1 -1
  132. package/esm/2_6/options.js +3 -1
  133. package/esm/2_6/options.js.map +1 -1
  134. package/esm/2_6_1.d.ts +6 -0
  135. package/esm/2_6_1.d.ts.map +1 -0
  136. package/esm/2_6_1.js +8 -0
  137. package/esm/2_6_1.js.map +1 -0
  138. package/esm/2_7/options.d.ts +6 -5
  139. package/esm/2_7/options.d.ts.map +1 -1
  140. package/esm/2_7/options.js +3 -1
  141. package/esm/2_7/options.js.map +1 -1
  142. package/esm/3_0/impl/defaults.d.ts +5 -7
  143. package/esm/3_0/impl/defaults.d.ts.map +1 -1
  144. package/esm/3_0/impl/defaults.js +1 -2
  145. package/esm/3_0/impl/defaults.js.map +1 -1
  146. package/esm/3_0/impl/init.d.ts +2 -2
  147. package/esm/3_0/impl/init.d.ts.map +1 -1
  148. package/esm/3_0/options.d.ts +7 -6
  149. package/esm/3_0/options.d.ts.map +1 -1
  150. package/esm/3_0/options.js +3 -1
  151. package/esm/3_0/options.js.map +1 -1
  152. package/esm/3_0_1.d.ts +6 -0
  153. package/esm/3_0_1.d.ts.map +1 -0
  154. package/esm/3_0_1.js +8 -0
  155. package/esm/3_0_1.js.map +1 -0
  156. package/esm/3_0_2.d.ts +6 -0
  157. package/esm/3_0_2.d.ts.map +1 -0
  158. package/esm/3_0_2.js +8 -0
  159. package/esm/3_0_2.js.map +1 -0
  160. package/esm/3_1/impl/defaults.d.ts +56 -0
  161. package/esm/3_1/impl/defaults.d.ts.map +1 -0
  162. package/esm/3_1/impl/defaults.js +6 -0
  163. package/esm/3_1/impl/defaults.js.map +1 -0
  164. package/esm/3_1/impl/index.d.ts +5 -0
  165. package/esm/3_1/impl/index.d.ts.map +1 -0
  166. package/esm/3_1/impl/index.js +4 -0
  167. package/esm/3_1/impl/index.js.map +1 -0
  168. package/esm/3_1/impl/init.d.ts +5 -0
  169. package/esm/3_1/impl/init.d.ts.map +1 -0
  170. package/esm/3_1/impl/init.js +2 -0
  171. package/esm/3_1/impl/init.js.map +1 -0
  172. package/esm/3_1/impl/prev.d.ts +2 -0
  173. package/esm/3_1/impl/prev.d.ts.map +1 -0
  174. package/esm/3_1/impl/prev.js +2 -0
  175. package/esm/3_1/impl/prev.js.map +1 -0
  176. package/esm/3_1/impl/serialize-uhid-create.d.ts +20 -0
  177. package/esm/3_1/impl/serialize-uhid-create.d.ts.map +1 -0
  178. package/esm/3_1/impl/serialize-uhid-create.js +14 -0
  179. package/esm/3_1/impl/serialize-uhid-create.js.map +1 -0
  180. package/esm/3_1/index.d.ts +3 -0
  181. package/esm/3_1/index.d.ts.map +1 -0
  182. package/esm/3_1/index.js +3 -0
  183. package/esm/3_1/index.js.map +1 -0
  184. package/esm/3_1/options.d.ts +91 -0
  185. package/esm/3_1/options.d.ts.map +1 -0
  186. package/esm/3_1/options.js +94 -0
  187. package/esm/3_1/options.js.map +1 -0
  188. package/esm/base/option-value.js +2 -2
  189. package/esm/base/option-value.js.map +1 -1
  190. package/esm/base/options.d.ts +1 -0
  191. package/esm/base/options.d.ts.map +1 -1
  192. package/esm/index.d.ts +7 -0
  193. package/esm/index.d.ts.map +1 -1
  194. package/esm/index.js +7 -0
  195. package/esm/index.js.map +1 -1
  196. package/esm/latest.d.ts +6 -1
  197. package/esm/latest.d.ts.map +1 -1
  198. package/esm/latest.js +8 -1
  199. package/esm/latest.js.map +1 -1
  200. package/esm/utils/wrapper.d.ts +1 -0
  201. package/esm/utils/wrapper.d.ts.map +1 -1
  202. package/esm/utils/wrapper.js +3 -0
  203. package/esm/utils/wrapper.js.map +1 -1
  204. package/package.json +5 -5
  205. package/src/1_15/impl/defaults.ts +2 -2
  206. package/src/1_15/impl/init.ts +20 -2
  207. package/src/1_15/options.ts +4 -1
  208. package/src/1_15_1.ts +9 -0
  209. package/src/1_16.ts +9 -4
  210. package/src/1_17/options.ts +4 -1
  211. package/src/1_18/options.ts +4 -1
  212. package/src/1_19.ts +9 -4
  213. package/src/1_20.ts +9 -4
  214. package/src/1_21/options.ts +4 -1
  215. package/src/1_22/impl/index.ts +1 -0
  216. package/src/1_22/impl/scroll-controller.ts +5 -0
  217. package/src/1_22/options.ts +4 -1
  218. package/src/1_23/options.ts +4 -1
  219. package/src/1_24/options.ts +4 -1
  220. package/src/1_25/impl/index.ts +1 -0
  221. package/src/1_25/impl/scroll-controller.ts +5 -1
  222. package/src/1_25/options.ts +4 -1
  223. package/src/2_0/impl/defaults.ts +3 -4
  224. package/src/2_0/impl/init.ts +3 -3
  225. package/src/2_0/options.ts +4 -1
  226. package/src/2_1/options.ts +4 -1
  227. package/src/2_1_1.ts +9 -0
  228. package/src/2_2/options.ts +4 -1
  229. package/src/2_3/options.ts +4 -1
  230. package/src/2_3_1.ts +9 -0
  231. package/src/2_4/options.ts +4 -1
  232. package/src/2_5.ts +9 -4
  233. package/src/2_6/options.ts +5 -2
  234. package/src/2_6_1.ts +9 -0
  235. package/src/2_7/options.ts +4 -1
  236. package/src/3_0/impl/defaults.ts +1 -2
  237. package/src/3_0/impl/init.ts +2 -2
  238. package/src/3_0/options.ts +4 -1
  239. package/src/3_0_1.ts +9 -0
  240. package/src/3_0_2.ts +9 -0
  241. package/src/3_1/impl/defaults.ts +8 -0
  242. package/src/3_1/impl/index.ts +7 -0
  243. package/src/3_1/impl/init.ts +5 -0
  244. package/src/3_1/impl/prev.ts +1 -0
  245. package/src/3_1/impl/serialize-uhid-create.ts +28 -0
  246. package/src/3_1/index.ts +2 -0
  247. package/src/3_1/options.ts +190 -0
  248. package/src/base/option-value.ts +2 -2
  249. package/src/base/options.ts +2 -0
  250. package/src/index.ts +7 -0
  251. package/src/latest.ts +12 -1
  252. package/src/utils/wrapper.ts +4 -0
  253. package/tsconfig.build.tsbuildinfo +1 -1
@@ -39,6 +39,8 @@ import {
39
39
  export class ScrcpyOptions1_25 implements ScrcpyOptions<Init> {
40
40
  static readonly Defaults = Defaults;
41
41
 
42
+ readonly version: string;
43
+
42
44
  readonly value: Required<Init>;
43
45
 
44
46
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -52,8 +54,9 @@ export class ScrcpyOptions1_25 implements ScrcpyOptions<Init> {
52
54
 
53
55
  #ackClipboardHandler: AckClipboardHandler | undefined;
54
56
 
55
- constructor(init: Init) {
57
+ constructor(init: Init, version = "1.25") {
56
58
  this.value = { ...Defaults, ...init };
59
+ this.version = version;
57
60
 
58
61
  if (this.value.control && this.value.clipboardAutosync) {
59
62
  this.#clipboard = new ClipboardStream();
@@ -1,23 +1,22 @@
1
1
  import { omit } from "../../utils/index.js";
2
2
 
3
3
  import type { Init } from "./init.js";
4
- import { InstanceId } from "./init.js";
5
4
  import { PrevImpl } from "./prev.js";
6
5
 
7
6
  export const Defaults = /* #__PURE__ */ (() =>
8
7
  ({
9
8
  ...omit(PrevImpl.Defaults, "bitRate", "codecOptions", "encoderName"),
10
- scid: InstanceId.NONE,
9
+ scid: undefined,
11
10
 
12
11
  videoCodec: "h264",
13
12
  videoBitRate: 8000000,
14
- videoCodecOptions: PrevImpl.CodecOptions.Empty,
13
+ videoCodecOptions: undefined,
15
14
  videoEncoder: undefined,
16
15
 
17
16
  audio: true,
18
17
  audioCodec: "opus",
19
18
  audioBitRate: 128000,
20
- audioCodecOptions: PrevImpl.CodecOptions.Empty,
19
+ audioCodecOptions: undefined,
21
20
  audioEncoder: undefined,
22
21
 
23
22
  listEncoders: false,
@@ -26,17 +26,17 @@ export class InstanceId implements ScrcpyOptionValue {
26
26
 
27
27
  export interface Init
28
28
  extends Omit<PrevImpl.Init, "bitRate" | "codecOptions" | "encoderName"> {
29
- scid?: InstanceId;
29
+ scid?: InstanceId | string | undefined;
30
30
 
31
31
  videoCodec?: "h264" | "h265" | "av1";
32
32
  videoBitRate?: number;
33
- videoCodecOptions?: PrevImpl.CodecOptions;
33
+ videoCodecOptions?: PrevImpl.CodecOptions | string | undefined;
34
34
  videoEncoder?: string | undefined;
35
35
 
36
36
  audio?: boolean;
37
37
  audioCodec?: "raw" | "opus" | "aac";
38
38
  audioBitRate?: number;
39
- audioCodecOptions?: PrevImpl.CodecOptions;
39
+ audioCodecOptions?: PrevImpl.CodecOptions | string | undefined;
40
40
  audioEncoder?: string | undefined;
41
41
 
42
42
  listEncoders?: boolean;
@@ -40,6 +40,8 @@ import {
40
40
  export class ScrcpyOptions2_0 implements ScrcpyOptions<Init> {
41
41
  static readonly Defaults = Defaults;
42
42
 
43
+ readonly version: string;
44
+
43
45
  readonly value: Required<Init>;
44
46
 
45
47
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -53,8 +55,9 @@ export class ScrcpyOptions2_0 implements ScrcpyOptions<Init> {
53
55
 
54
56
  #ackClipboardHandler: AckClipboardHandler | undefined;
55
57
 
56
- constructor(init: Init) {
58
+ constructor(init: Init, version = "2.0") {
57
59
  this.value = { ...Defaults, ...init };
60
+ this.version = version;
58
61
 
59
62
  if (this.value.control && this.value.clipboardAutosync) {
60
63
  this.#clipboard = new ClipboardStream();
@@ -40,6 +40,8 @@ import {
40
40
  export class ScrcpyOptions2_1 implements ScrcpyOptions<Init> {
41
41
  static readonly Defaults = Defaults;
42
42
 
43
+ readonly version: string;
44
+
43
45
  readonly value: Required<Init>;
44
46
 
45
47
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -53,8 +55,9 @@ export class ScrcpyOptions2_1 implements ScrcpyOptions<Init> {
53
55
 
54
56
  #ackClipboardHandler: AckClipboardHandler | undefined;
55
57
 
56
- constructor(init: Init) {
58
+ constructor(init: Init, version = "2.1") {
57
59
  this.value = { ...Defaults, ...init };
60
+ this.version = version;
58
61
 
59
62
  if (this.value.control && this.value.clipboardAutosync) {
60
63
  this.#clipboard = new ClipboardStream();
package/src/2_1_1.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ScrcpyOptions2_1 } from "./2_1/index.js";
2
+
3
+ export class ScrcpyOptions2_1_1 extends ScrcpyOptions2_1 {
4
+ constructor(init: ScrcpyOptions2_1.Init, version = "2.1.1") {
5
+ super(init, version);
6
+ }
7
+ }
8
+
9
+ export { ScrcpyOptions2_1Impl as ScrcpyOptions2_1_1Impl } from "./2_1/index.js";
@@ -40,6 +40,8 @@ import {
40
40
  export class ScrcpyOptions2_2 implements ScrcpyOptions<Init> {
41
41
  static readonly Defaults = Defaults;
42
42
 
43
+ readonly version: string;
44
+
43
45
  readonly value: Required<Init>;
44
46
 
45
47
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -53,8 +55,9 @@ export class ScrcpyOptions2_2 implements ScrcpyOptions<Init> {
53
55
 
54
56
  #ackClipboardHandler: AckClipboardHandler | undefined;
55
57
 
56
- constructor(init: Init) {
58
+ constructor(init: Init, version = "v2.2") {
57
59
  this.value = { ...Defaults, ...init };
60
+ this.version = version;
58
61
 
59
62
  if (this.value.videoSource === "camera") {
60
63
  this.value.control = false;
@@ -40,6 +40,8 @@ import {
40
40
  export class ScrcpyOptions2_3 implements ScrcpyOptions<Init> {
41
41
  static readonly Defaults = Defaults;
42
42
 
43
+ readonly version: string;
44
+
43
45
  readonly value: Required<Init>;
44
46
 
45
47
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -53,8 +55,9 @@ export class ScrcpyOptions2_3 implements ScrcpyOptions<Init> {
53
55
 
54
56
  #ackClipboardHandler: AckClipboardHandler | undefined;
55
57
 
56
- constructor(init: Init) {
58
+ constructor(init: Init, version = "2.3") {
57
59
  this.value = { ...Defaults, ...init };
60
+ this.version = version;
58
61
 
59
62
  if (this.value.videoSource === "camera") {
60
63
  this.value.control = false;
package/src/2_3_1.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ScrcpyOptions2_3 } from "./2_3/index.js";
2
+
3
+ export class ScrcpyOptions2_3_1 extends ScrcpyOptions2_3 {
4
+ constructor(init: ScrcpyOptions2_3.Init, version = "2.3.1") {
5
+ super(init, version);
6
+ }
7
+ }
8
+
9
+ export { ScrcpyOptions2_3Impl as ScrcpyOptions2_3_1Impl } from "./2_3/index.js";
@@ -44,6 +44,8 @@ import {
44
44
  export class ScrcpyOptions2_4 implements ScrcpyOptions<Init> {
45
45
  static readonly Defaults = Defaults;
46
46
 
47
+ readonly version: string;
48
+
47
49
  readonly value: Required<Init>;
48
50
 
49
51
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -64,8 +66,9 @@ export class ScrcpyOptions2_4 implements ScrcpyOptions<Init> {
64
66
  return this.#uHidOutput;
65
67
  }
66
68
 
67
- constructor(init: Init) {
69
+ constructor(init: Init, version = "2.4") {
68
70
  this.value = { ...Defaults, ...init };
71
+ this.version = version;
69
72
 
70
73
  if (this.value.videoSource === "camera") {
71
74
  this.value.control = false;
package/src/2_5.ts CHANGED
@@ -1,4 +1,9 @@
1
- export {
2
- ScrcpyOptions2_4 as ScrcpyOptions2_5,
3
- ScrcpyOptions2_4Impl as ScrcpyOptions2_5Impl,
4
- } from "./2_4/index.js";
1
+ import { ScrcpyOptions2_4 } from "./2_4/index.js";
2
+
3
+ export class ScrcpyOptions2_5 extends ScrcpyOptions2_4 {
4
+ constructor(init: ScrcpyOptions2_4.Init, version = "2.5") {
5
+ super(init, version);
6
+ }
7
+ }
8
+
9
+ export { ScrcpyOptions2_4Impl as ScrcpyOptions2_5Impl } from "./2_4/index.js";
@@ -20,6 +20,7 @@ import type {
20
20
  ScrcpyUHidOutputDeviceMessage,
21
21
  } from "../latest.js";
22
22
 
23
+ import type { Init } from "./impl/index.js";
23
24
  import {
24
25
  AckClipboardHandler,
25
26
  ClipboardStream,
@@ -39,11 +40,12 @@ import {
39
40
  setListEncoders,
40
41
  UHidOutputStream,
41
42
  } from "./impl/index.js";
42
- import type { Init } from "./impl/index.js";
43
43
 
44
44
  export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
45
45
  static readonly Defaults = Defaults;
46
46
 
47
+ readonly version: string;
48
+
47
49
  readonly value: Required<Init>;
48
50
 
49
51
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -64,8 +66,9 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
64
66
  return this.#uHidOutput;
65
67
  }
66
68
 
67
- constructor(init: Init) {
69
+ constructor(init: Init, version = "2.6") {
68
70
  this.value = { ...Defaults, ...init };
71
+ this.version = version;
69
72
 
70
73
  if (this.value.videoSource === "camera") {
71
74
  this.value.control = false;
package/src/2_6_1.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ScrcpyOptions2_6 } from "./2_6/index.js";
2
+
3
+ export class ScrcpyOptions2_6_1 extends ScrcpyOptions2_6 {
4
+ constructor(init: ScrcpyOptions2_6.Init, version = "2.6.1") {
5
+ super(init, version);
6
+ }
7
+ }
8
+
9
+ export { ScrcpyOptions2_6Impl as ScrcpyOptions2_6_1Impl } from "./2_6/index.js";
@@ -44,6 +44,8 @@ import {
44
44
  export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
45
45
  static readonly Defaults = Defaults;
46
46
 
47
+ readonly version: string;
48
+
47
49
  readonly value: Required<Init>;
48
50
 
49
51
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -64,8 +66,9 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
64
66
  return this.#uHidOutput;
65
67
  }
66
68
 
67
- constructor(init: Init) {
69
+ constructor(init: Init, version = "2.7") {
68
70
  this.value = { ...Defaults, ...init };
71
+ this.version = version;
69
72
 
70
73
  if (this.value.videoSource === "camera") {
71
74
  this.value.control = false;
@@ -1,13 +1,12 @@
1
1
  import { omit } from "../../utils/index.js";
2
2
 
3
3
  import type { Init } from "./init.js";
4
- import { CaptureOrientation } from "./init.js";
5
4
  import { PrevImpl } from "./prev.js";
6
5
 
7
6
  export const Defaults = /* #__PURE__ */ (() =>
8
7
  ({
9
8
  ...omit(PrevImpl.Defaults, "lockVideoOrientation"),
10
- captureOrientation: CaptureOrientation.Unlocked,
9
+ captureOrientation: undefined,
11
10
  angle: 0,
12
11
  screenOffTimeout: undefined,
13
12
  listApps: false,
@@ -107,7 +107,7 @@ export class NewDisplay implements ScrcpyOptionValue {
107
107
  }
108
108
 
109
109
  export interface Init extends Omit<PrevImpl.Init, "lockVideoOrientation"> {
110
- captureOrientation?: CaptureOrientation;
110
+ captureOrientation?: CaptureOrientation | string | undefined;
111
111
  angle?: number;
112
112
  screenOffTimeout?: number | undefined;
113
113
 
@@ -116,6 +116,6 @@ export interface Init extends Omit<PrevImpl.Init, "lockVideoOrientation"> {
116
116
  // `display_id` and `new_display` can't be specified at the same time
117
117
  // but `serialize` method will exclude options that are same as the default value
118
118
  // so `displayId: 0` will be ignored
119
- newDisplay?: NewDisplay | undefined;
119
+ newDisplay?: NewDisplay | string | undefined;
120
120
  vdSystemDecorations?: boolean;
121
121
  }
@@ -44,6 +44,8 @@ import {
44
44
  export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
45
45
  static readonly Defaults = Defaults;
46
46
 
47
+ readonly version: string;
48
+
47
49
  readonly value: Required<Init>;
48
50
 
49
51
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
@@ -64,8 +66,9 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
64
66
  return this.#uHidOutput;
65
67
  }
66
68
 
67
- constructor(init: Init) {
69
+ constructor(init: Init, version = "3.0") {
68
70
  this.value = { ...Defaults, ...init };
71
+ this.version = version;
69
72
 
70
73
  if (this.value.videoSource === "camera") {
71
74
  this.value.control = false;
package/src/3_0_1.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ScrcpyOptions3_0 } from "./3_0/index.js";
2
+
3
+ export class ScrcpyOptions3_0_1 extends ScrcpyOptions3_0 {
4
+ constructor(init: ScrcpyOptions3_0.Init, version = "3.0.1") {
5
+ super(init, version);
6
+ }
7
+ }
8
+
9
+ export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_1Impl } from "./3_0/index.js";
package/src/3_0_2.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ScrcpyOptions3_0 } from "./3_0/index.js";
2
+
3
+ export class ScrcpyOptions3_0_2 extends ScrcpyOptions3_0 {
4
+ constructor(init: ScrcpyOptions3_0.Init, version = "3.0.2") {
5
+ super(init, version);
6
+ }
7
+ }
8
+
9
+ export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_2Impl } from "./3_0/index.js";
@@ -0,0 +1,8 @@
1
+ import type { Init } from "./init.js";
2
+ import { PrevImpl } from "./prev.js";
3
+
4
+ export const Defaults = /* #__PURE__ */ (() =>
5
+ ({
6
+ ...PrevImpl.Defaults,
7
+ vdDestroyContent: false,
8
+ }) as const satisfies Required<Init>)();
@@ -0,0 +1,7 @@
1
+ export * from "../../3_0/impl/index.js";
2
+ export { Defaults } from "./defaults.js";
3
+ export type { Init } from "./init.js";
4
+ export {
5
+ serializeUHidCreateControlMessage,
6
+ UHidCreateControlMessage,
7
+ } from "./serialize-uhid-create.js";
@@ -0,0 +1,5 @@
1
+ import type { PrevImpl } from "./prev.js";
2
+
3
+ export interface Init extends PrevImpl.Init {
4
+ vdDestroyContent?: boolean;
5
+ }
@@ -0,0 +1 @@
1
+ export * as PrevImpl from "../../3_0/impl/index.js";
@@ -0,0 +1,28 @@
1
+ import type { StructInit } from "@yume-chan/struct";
2
+ import { buffer, string, struct, u16, u8 } from "@yume-chan/struct";
3
+
4
+ import { ScrcpyControlMessageType } from "../../base/control-message-type.js";
5
+ import type { ScrcpyUHidCreateControlMessage } from "../../latest.js";
6
+
7
+ export const UHidCreateControlMessage = /* #__PURE__ */ (() =>
8
+ struct(
9
+ {
10
+ type: u8(ScrcpyControlMessageType.UHidCreate),
11
+ id: u16,
12
+ vendorId: u16,
13
+ productId: u16,
14
+ name: string(u8),
15
+ data: buffer(u16),
16
+ },
17
+ { littleEndian: false },
18
+ ))();
19
+
20
+ export type UHidCreateControlMessage = StructInit<
21
+ typeof UHidCreateControlMessage
22
+ >;
23
+
24
+ export function serializeUHidCreateControlMessage(
25
+ message: ScrcpyUHidCreateControlMessage,
26
+ ) {
27
+ return UHidCreateControlMessage.serialize(message);
28
+ }
@@ -0,0 +1,2 @@
1
+ export * as ScrcpyOptions3_1Impl from "./impl/index.js";
2
+ export * from "./options.js";
@@ -0,0 +1,190 @@
1
+ import type { MaybePromiseLike } from "@yume-chan/async";
2
+ import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
3
+ import type { AsyncExactReadable } from "@yume-chan/struct";
4
+
5
+ import type {
6
+ ScrcpyAudioStreamMetadata,
7
+ ScrcpyControlMessageType,
8
+ ScrcpyDisplay,
9
+ ScrcpyEncoder,
10
+ ScrcpyMediaStreamPacket,
11
+ ScrcpyOptions,
12
+ ScrcpyScrollController,
13
+ ScrcpyVideoStream,
14
+ } from "../base/index.js";
15
+ import type {
16
+ ScrcpyBackOrScreenOnControlMessage,
17
+ ScrcpyInjectTouchControlMessage,
18
+ ScrcpySetClipboardControlMessage,
19
+ ScrcpyUHidCreateControlMessage,
20
+ ScrcpyUHidOutputDeviceMessage,
21
+ } from "../latest.js";
22
+
23
+ import type { Init } from "./impl/index.js";
24
+ import {
25
+ AckClipboardHandler,
26
+ ClipboardStream,
27
+ ControlMessageTypes,
28
+ createMediaStreamTransformer,
29
+ createScrollController,
30
+ Defaults,
31
+ parseAudioStreamMetadata,
32
+ parseDisplay,
33
+ parseEncoder,
34
+ parseVideoStreamMetadata,
35
+ serialize,
36
+ serializeBackOrScreenOnControlMessage,
37
+ serializeInjectTouchControlMessage,
38
+ serializeUHidCreateControlMessage,
39
+ setListDisplays,
40
+ setListEncoders,
41
+ UHidOutputStream,
42
+ } from "./impl/index.js";
43
+
44
+ export class ScrcpyOptions3_1 implements ScrcpyOptions<Init> {
45
+ static readonly Defaults = Defaults;
46
+
47
+ readonly version: string;
48
+
49
+ readonly value: Required<Init>;
50
+
51
+ get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
52
+ return ControlMessageTypes;
53
+ }
54
+
55
+ #clipboard: ClipboardStream | undefined;
56
+ get clipboard(): ReadableStream<string> | undefined {
57
+ return this.#clipboard;
58
+ }
59
+
60
+ #ackClipboardHandler: AckClipboardHandler | undefined;
61
+
62
+ #uHidOutput: UHidOutputStream | undefined;
63
+ get uHidOutput():
64
+ | ReadableStream<ScrcpyUHidOutputDeviceMessage>
65
+ | undefined {
66
+ return this.#uHidOutput;
67
+ }
68
+
69
+ constructor(init: Init, version = "3.1") {
70
+ this.value = { ...Defaults, ...init };
71
+ this.version = version;
72
+
73
+ if (this.value.videoSource === "camera") {
74
+ this.value.control = false;
75
+ }
76
+
77
+ if (this.value.audioDup) {
78
+ this.value.audioSource = "playback";
79
+ }
80
+
81
+ if (this.value.control) {
82
+ if (this.value.clipboardAutosync) {
83
+ this.#clipboard = new ClipboardStream();
84
+ this.#ackClipboardHandler = new AckClipboardHandler();
85
+ }
86
+
87
+ this.#uHidOutput = new UHidOutputStream();
88
+ }
89
+ }
90
+
91
+ serialize(): string[] {
92
+ return serialize(this.value, Defaults);
93
+ }
94
+
95
+ setListDisplays(): void {
96
+ setListDisplays(this.value);
97
+ }
98
+
99
+ parseDisplay(line: string): ScrcpyDisplay | undefined {
100
+ return parseDisplay(line);
101
+ }
102
+
103
+ setListEncoders() {
104
+ setListEncoders(this.value);
105
+ }
106
+
107
+ parseEncoder(line: string): ScrcpyEncoder | undefined {
108
+ return parseEncoder(line);
109
+ }
110
+
111
+ parseVideoStreamMetadata(
112
+ stream: ReadableStream<Uint8Array>,
113
+ ): MaybePromiseLike<ScrcpyVideoStream> {
114
+ return parseVideoStreamMetadata(this.value, stream);
115
+ }
116
+
117
+ parseAudioStreamMetadata(
118
+ stream: ReadableStream<Uint8Array>,
119
+ ): MaybePromiseLike<ScrcpyAudioStreamMetadata> {
120
+ return parseAudioStreamMetadata(stream, this.value);
121
+ }
122
+
123
+ async parseDeviceMessage(
124
+ id: number,
125
+ stream: 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
+ createMediaStreamTransformer(): TransformStream<
149
+ Uint8Array,
150
+ ScrcpyMediaStreamPacket
151
+ > {
152
+ return createMediaStreamTransformer(this.value);
153
+ }
154
+
155
+ serializeInjectTouchControlMessage(
156
+ message: ScrcpyInjectTouchControlMessage,
157
+ ): Uint8Array {
158
+ return serializeInjectTouchControlMessage(message);
159
+ }
160
+
161
+ serializeBackOrScreenOnControlMessage(
162
+ message: ScrcpyBackOrScreenOnControlMessage,
163
+ ): Uint8Array | undefined {
164
+ return serializeBackOrScreenOnControlMessage(message);
165
+ }
166
+
167
+ serializeSetClipboardControlMessage(
168
+ message: ScrcpySetClipboardControlMessage,
169
+ ): Uint8Array | [Uint8Array, Promise<void>] {
170
+ return this.#ackClipboardHandler!.serializeSetClipboardControlMessage(
171
+ message,
172
+ );
173
+ }
174
+
175
+ createScrollController(): ScrcpyScrollController {
176
+ return createScrollController();
177
+ }
178
+
179
+ serializeUHidCreateControlMessage(
180
+ message: ScrcpyUHidCreateControlMessage,
181
+ ): Uint8Array {
182
+ return serializeUHidCreateControlMessage(message);
183
+ }
184
+ }
185
+
186
+ type Init_ = Init;
187
+
188
+ export namespace ScrcpyOptions3_1 {
189
+ export type Init = Init_;
190
+ }
@@ -28,8 +28,8 @@ export function toScrcpyOptionValue<T>(value: unknown, empty: T): string | T {
28
28
  typeof value !== "number" &&
29
29
  typeof value !== "boolean"
30
30
  ) {
31
- throw new TypeError(`Invalid option value: ${String(value)}`);
31
+ throw new TypeError(`Invalid option value: ${JSON.stringify(value)}`);
32
32
  }
33
33
 
34
- return String(value);
34
+ return value.toString();
35
35
  }
@@ -19,6 +19,8 @@ import type { ScrcpyScrollController } from "./scroll-controller.js";
19
19
  import type { ScrcpyVideoStream } from "./video.js";
20
20
 
21
21
  export interface ScrcpyOptions<T extends object> {
22
+ get version(): string;
23
+
22
24
  get controlMessageTypes(): readonly ScrcpyControlMessageType[];
23
25
 
24
26
  value: Required<T>;
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./1_15/index.js";
2
+ export * from "./1_15_1.js";
2
3
  export * from "./1_16.js";
3
4
  export * from "./1_17/index.js";
4
5
  export * from "./1_18/index.js";
@@ -11,13 +12,19 @@ export * from "./1_24/index.js";
11
12
  export * from "./1_25/index.js";
12
13
  export * from "./2_0/index.js";
13
14
  export * from "./2_1/index.js";
15
+ export * from "./2_1_1.js";
14
16
  export * from "./2_2/index.js";
15
17
  export * from "./2_3/index.js";
18
+ export * from "./2_3_1.js";
16
19
  export * from "./2_4/index.js";
17
20
  export * from "./2_5.js";
18
21
  export * from "./2_6/index.js";
22
+ export * from "./2_6_1.js";
19
23
  export * from "./2_7/index.js";
20
24
  export * from "./3_0/index.js";
25
+ export * from "./3_0_1.js";
26
+ export * from "./3_0_2.js";
27
+ export * from "./3_1/index.js";
21
28
  export * from "./android/index.js";
22
29
  export * from "./base/index.js";
23
30
  export * from "./codec/index.js";