@yume-chan/scrcpy 1.1.0 → 2.0.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.
Files changed (331) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +1 -1
  3. package/esm/1_15/impl/back-or-screen-on.d.ts +1 -1
  4. package/esm/1_15/impl/clipboard-stream.d.ts +3 -3
  5. package/esm/1_15/impl/inject-touch.d.ts +9 -9
  6. package/esm/1_15/impl/inject-touch.d.ts.map +1 -1
  7. package/esm/1_15/impl/inject-touch.js +14 -18
  8. package/esm/1_15/impl/inject-touch.js.map +1 -1
  9. package/esm/1_15/impl/media-stream-transformer.d.ts +3 -3
  10. package/esm/1_15/impl/scroll-controller.d.ts +5 -5
  11. package/esm/1_15/impl/scroll-controller.js +2 -2
  12. package/esm/1_15/impl/scroll-controller.js.map +1 -1
  13. package/esm/1_15/impl/set-clipboard.d.ts +3 -3
  14. package/esm/1_15/index.d.ts +0 -1
  15. package/esm/1_15/index.d.ts.map +1 -1
  16. package/esm/1_15/index.js +0 -1
  17. package/esm/1_15/index.js.map +1 -1
  18. package/esm/1_15/options.d.ts +3 -4
  19. package/esm/1_15/options.d.ts.map +1 -1
  20. package/esm/1_15/options.js +1 -3
  21. package/esm/1_15/options.js.map +1 -1
  22. package/esm/1_15_1.d.ts +4 -2
  23. package/esm/1_15_1.d.ts.map +1 -1
  24. package/esm/1_15_1.js +2 -3
  25. package/esm/1_15_1.js.map +1 -1
  26. package/esm/1_16.d.ts +4 -2
  27. package/esm/1_16.d.ts.map +1 -1
  28. package/esm/1_16.js +2 -3
  29. package/esm/1_16.js.map +1 -1
  30. package/esm/1_17/index.d.ts +0 -1
  31. package/esm/1_17/index.d.ts.map +1 -1
  32. package/esm/1_17/index.js +0 -1
  33. package/esm/1_17/index.js.map +1 -1
  34. package/esm/1_17/options.d.ts +5 -6
  35. package/esm/1_17/options.d.ts.map +1 -1
  36. package/esm/1_17/options.js +1 -3
  37. package/esm/1_17/options.js.map +1 -1
  38. package/esm/1_18/impl/back-or-screen-on.d.ts +5 -3
  39. package/esm/1_18/impl/back-or-screen-on.d.ts.map +1 -1
  40. package/esm/1_18/impl/back-or-screen-on.js +2 -5
  41. package/esm/1_18/impl/back-or-screen-on.js.map +1 -1
  42. package/esm/1_18/index.d.ts +0 -1
  43. package/esm/1_18/index.d.ts.map +1 -1
  44. package/esm/1_18/index.js +0 -1
  45. package/esm/1_18/index.js.map +1 -1
  46. package/esm/1_18/options.d.ts +5 -6
  47. package/esm/1_18/options.d.ts.map +1 -1
  48. package/esm/1_18/options.js +1 -3
  49. package/esm/1_18/options.js.map +1 -1
  50. package/esm/1_19.d.ts +4 -2
  51. package/esm/1_19.d.ts.map +1 -1
  52. package/esm/1_19.js +2 -3
  53. package/esm/1_19.js.map +1 -1
  54. package/esm/1_20.d.ts +4 -2
  55. package/esm/1_20.d.ts.map +1 -1
  56. package/esm/1_20.js +2 -3
  57. package/esm/1_20.js.map +1 -1
  58. package/esm/1_21/impl/set-clipboard.d.ts +6 -6
  59. package/esm/1_21/index.d.ts +0 -1
  60. package/esm/1_21/index.d.ts.map +1 -1
  61. package/esm/1_21/index.js +0 -1
  62. package/esm/1_21/index.js.map +1 -1
  63. package/esm/1_21/options.d.ts +5 -6
  64. package/esm/1_21/options.d.ts.map +1 -1
  65. package/esm/1_21/options.js +1 -3
  66. package/esm/1_21/options.js.map +1 -1
  67. package/esm/1_22/impl/scroll-controller.d.ts +8 -6
  68. package/esm/1_22/impl/scroll-controller.d.ts.map +1 -1
  69. package/esm/1_22/impl/scroll-controller.js +2 -5
  70. package/esm/1_22/impl/scroll-controller.js.map +1 -1
  71. package/esm/1_22/index.d.ts +0 -1
  72. package/esm/1_22/index.d.ts.map +1 -1
  73. package/esm/1_22/index.js +0 -1
  74. package/esm/1_22/index.js.map +1 -1
  75. package/esm/1_22/options.d.ts +5 -6
  76. package/esm/1_22/options.d.ts.map +1 -1
  77. package/esm/1_22/options.js +1 -3
  78. package/esm/1_22/options.js.map +1 -1
  79. package/esm/1_23/index.d.ts +0 -1
  80. package/esm/1_23/index.d.ts.map +1 -1
  81. package/esm/1_23/index.js +0 -1
  82. package/esm/1_23/index.js.map +1 -1
  83. package/esm/1_23/options.d.ts +5 -6
  84. package/esm/1_23/options.d.ts.map +1 -1
  85. package/esm/1_23/options.js +1 -3
  86. package/esm/1_23/options.js.map +1 -1
  87. package/esm/1_24/index.d.ts +0 -1
  88. package/esm/1_24/index.d.ts.map +1 -1
  89. package/esm/1_24/index.js +0 -1
  90. package/esm/1_24/index.js.map +1 -1
  91. package/esm/1_24/options.d.ts +5 -6
  92. package/esm/1_24/options.d.ts.map +1 -1
  93. package/esm/1_24/options.js +1 -3
  94. package/esm/1_24/options.js.map +1 -1
  95. package/esm/1_25/impl/scroll-controller.d.ts +11 -11
  96. package/esm/1_25/impl/scroll-controller.d.ts.map +1 -1
  97. package/esm/1_25/impl/scroll-controller.js +14 -18
  98. package/esm/1_25/impl/scroll-controller.js.map +1 -1
  99. package/esm/1_25/index.d.ts +0 -1
  100. package/esm/1_25/index.d.ts.map +1 -1
  101. package/esm/1_25/index.js +0 -1
  102. package/esm/1_25/index.js.map +1 -1
  103. package/esm/1_25/options.d.ts +5 -6
  104. package/esm/1_25/options.d.ts.map +1 -1
  105. package/esm/1_25/options.js +1 -3
  106. package/esm/1_25/options.js.map +1 -1
  107. package/esm/2_0/impl/inject-touch.d.ts +11 -11
  108. package/esm/2_0/impl/inject-touch.js +2 -2
  109. package/esm/2_0/impl/inject-touch.js.map +1 -1
  110. package/esm/2_0/impl/parse-audio-stream-metadata.d.ts +1 -1
  111. package/esm/2_0/impl/parse-audio-stream-metadata.d.ts.map +1 -1
  112. package/esm/2_0/impl/parse-audio-stream-metadata.js.map +1 -1
  113. package/esm/2_0/index.d.ts +0 -1
  114. package/esm/2_0/index.d.ts.map +1 -1
  115. package/esm/2_0/index.js +0 -1
  116. package/esm/2_0/index.js.map +1 -1
  117. package/esm/2_0/options.d.ts +5 -6
  118. package/esm/2_0/options.d.ts.map +1 -1
  119. package/esm/2_0/options.js +1 -3
  120. package/esm/2_0/options.js.map +1 -1
  121. package/esm/2_1/impl/defaults.d.ts.map +1 -1
  122. package/esm/2_1/impl/defaults.js.map +1 -1
  123. package/esm/2_1/impl/init.d.ts +2 -2
  124. package/esm/2_1/impl/init.d.ts.map +1 -1
  125. package/esm/2_1/index.d.ts +0 -1
  126. package/esm/2_1/index.d.ts.map +1 -1
  127. package/esm/2_1/index.js +0 -1
  128. package/esm/2_1/index.js.map +1 -1
  129. package/esm/2_1/options.d.ts +8 -9
  130. package/esm/2_1/options.d.ts.map +1 -1
  131. package/esm/2_1/options.js +1 -3
  132. package/esm/2_1/options.js.map +1 -1
  133. package/esm/2_1_1.d.ts +5 -3
  134. package/esm/2_1_1.d.ts.map +1 -1
  135. package/esm/2_1_1.js +2 -3
  136. package/esm/2_1_1.js.map +1 -1
  137. package/esm/2_2/impl/defaults.d.ts.map +1 -1
  138. package/esm/2_2/impl/defaults.js.map +1 -1
  139. package/esm/2_2/impl/init.d.ts +1 -1
  140. package/esm/2_2/impl/init.d.ts.map +1 -1
  141. package/esm/2_2/index.d.ts +0 -1
  142. package/esm/2_2/index.d.ts.map +1 -1
  143. package/esm/2_2/index.js +0 -1
  144. package/esm/2_2/index.js.map +1 -1
  145. package/esm/2_2/options.d.ts +8 -9
  146. package/esm/2_2/options.d.ts.map +1 -1
  147. package/esm/2_2/options.js +1 -3
  148. package/esm/2_2/options.js.map +1 -1
  149. package/esm/2_3/impl/init.d.ts +2 -2
  150. package/esm/2_3/impl/init.d.ts.map +1 -1
  151. package/esm/2_3/index.d.ts +0 -1
  152. package/esm/2_3/index.d.ts.map +1 -1
  153. package/esm/2_3/index.js +0 -1
  154. package/esm/2_3/index.js.map +1 -1
  155. package/esm/2_3/options.d.ts +8 -9
  156. package/esm/2_3/options.d.ts.map +1 -1
  157. package/esm/2_3/options.js +1 -3
  158. package/esm/2_3/options.js.map +1 -1
  159. package/esm/2_3_1.d.ts +5 -3
  160. package/esm/2_3_1.d.ts.map +1 -1
  161. package/esm/2_3_1.js +2 -3
  162. package/esm/2_3_1.js.map +1 -1
  163. package/esm/2_4/impl/serialize-uhid-create.d.ts +3 -3
  164. package/esm/2_4/impl/uhid-output-stream.d.ts +3 -3
  165. package/esm/2_4/index.d.ts +0 -1
  166. package/esm/2_4/index.d.ts.map +1 -1
  167. package/esm/2_4/index.js +0 -1
  168. package/esm/2_4/index.js.map +1 -1
  169. package/esm/2_4/options.d.ts +8 -9
  170. package/esm/2_4/options.d.ts.map +1 -1
  171. package/esm/2_4/options.js +1 -3
  172. package/esm/2_4/options.js.map +1 -1
  173. package/esm/2_5.d.ts +5 -3
  174. package/esm/2_5.d.ts.map +1 -1
  175. package/esm/2_5.js +2 -3
  176. package/esm/2_5.js.map +1 -1
  177. package/esm/2_6/impl/defaults.d.ts.map +1 -1
  178. package/esm/2_6/impl/defaults.js.map +1 -1
  179. package/esm/2_6/impl/init.d.ts +2 -2
  180. package/esm/2_6/impl/init.d.ts.map +1 -1
  181. package/esm/2_6/index.d.ts +0 -1
  182. package/esm/2_6/index.d.ts.map +1 -1
  183. package/esm/2_6/index.js +0 -1
  184. package/esm/2_6/index.js.map +1 -1
  185. package/esm/2_6/options.d.ts +8 -9
  186. package/esm/2_6/options.d.ts.map +1 -1
  187. package/esm/2_6/options.js +1 -3
  188. package/esm/2_6/options.js.map +1 -1
  189. package/esm/2_6_1.d.ts +5 -3
  190. package/esm/2_6_1.d.ts.map +1 -1
  191. package/esm/2_6_1.js +2 -3
  192. package/esm/2_6_1.js.map +1 -1
  193. package/esm/2_7/impl/serialize-uhid-create.d.ts +7 -7
  194. package/esm/2_7/index.d.ts +0 -1
  195. package/esm/2_7/index.d.ts.map +1 -1
  196. package/esm/2_7/index.js +0 -1
  197. package/esm/2_7/index.js.map +1 -1
  198. package/esm/2_7/options.d.ts +8 -9
  199. package/esm/2_7/options.d.ts.map +1 -1
  200. package/esm/2_7/options.js +1 -3
  201. package/esm/2_7/options.js.map +1 -1
  202. package/esm/3_0/impl/defaults.d.ts.map +1 -1
  203. package/esm/3_0/impl/defaults.js.map +1 -1
  204. package/esm/3_0/impl/init.d.ts +1 -1
  205. package/esm/3_0/impl/init.d.ts.map +1 -1
  206. package/esm/3_0/index.d.ts +0 -1
  207. package/esm/3_0/index.d.ts.map +1 -1
  208. package/esm/3_0/index.js +0 -1
  209. package/esm/3_0/index.js.map +1 -1
  210. package/esm/3_0/options.d.ts +8 -9
  211. package/esm/3_0/options.d.ts.map +1 -1
  212. package/esm/3_0/options.js +1 -3
  213. package/esm/3_0/options.js.map +1 -1
  214. package/esm/3_0_1.d.ts +5 -3
  215. package/esm/3_0_1.d.ts.map +1 -1
  216. package/esm/3_0_1.js +2 -3
  217. package/esm/3_0_1.js.map +1 -1
  218. package/esm/3_0_2.d.ts +5 -3
  219. package/esm/3_0_2.d.ts.map +1 -1
  220. package/esm/3_0_2.js +2 -3
  221. package/esm/3_0_2.js.map +1 -1
  222. package/esm/3_1/impl/defaults.d.ts.map +1 -1
  223. package/esm/3_1/impl/defaults.js.map +1 -1
  224. package/esm/3_1/impl/init.d.ts +1 -1
  225. package/esm/3_1/impl/init.d.ts.map +1 -1
  226. package/esm/3_1/impl/serialize-uhid-create.d.ts +7 -7
  227. package/esm/3_1/index.d.ts +0 -1
  228. package/esm/3_1/index.d.ts.map +1 -1
  229. package/esm/3_1/index.js +0 -1
  230. package/esm/3_1/index.js.map +1 -1
  231. package/esm/3_1/options.d.ts +8 -9
  232. package/esm/3_1/options.d.ts.map +1 -1
  233. package/esm/3_1/options.js +1 -3
  234. package/esm/3_1/options.js.map +1 -1
  235. package/esm/android/key-event.d.ts.map +1 -1
  236. package/esm/android/key-event.js +3 -2
  237. package/esm/android/key-event.js.map +1 -1
  238. package/esm/base/options.d.ts +6 -5
  239. package/esm/base/options.d.ts.map +1 -1
  240. package/esm/codec/h265.d.ts +23 -2
  241. package/esm/codec/h265.d.ts.map +1 -1
  242. package/esm/codec/h265.js +25 -3
  243. package/esm/codec/h265.js.map +1 -1
  244. package/esm/control/empty.d.ts +1 -1
  245. package/esm/control/inject-key-code.d.ts +9 -9
  246. package/esm/control/inject-text.d.ts +3 -3
  247. package/esm/control/set-screen-power-mode.d.ts +3 -3
  248. package/esm/control/start-app.d.ts +3 -3
  249. package/esm/control/uhid.d.ts +6 -6
  250. package/esm/latest.d.ts +5 -3
  251. package/esm/latest.d.ts.map +1 -1
  252. package/esm/latest.js +2 -3
  253. package/esm/latest.js.map +1 -1
  254. package/esm/utils/index.d.ts +0 -1
  255. package/esm/utils/index.d.ts.map +1 -1
  256. package/esm/utils/index.js +0 -1
  257. package/esm/utils/index.js.map +1 -1
  258. package/package.json +9 -9
  259. package/src/1_15/impl/inject-touch.ts +13 -12
  260. package/src/1_15/impl/scroll-controller.ts +2 -2
  261. package/src/1_15/index.ts +0 -1
  262. package/src/1_15/options.ts +3 -6
  263. package/src/1_15_1.ts +5 -3
  264. package/src/1_16.ts +5 -3
  265. package/src/1_17/index.ts +0 -1
  266. package/src/1_17/options.ts +7 -7
  267. package/src/1_18/impl/back-or-screen-on.ts +5 -9
  268. package/src/1_18/index.ts +0 -1
  269. package/src/1_18/options.ts +7 -7
  270. package/src/1_19.ts +5 -3
  271. package/src/1_20.ts +5 -3
  272. package/src/1_21/index.ts +0 -1
  273. package/src/1_21/options.ts +7 -7
  274. package/src/1_22/impl/scroll-controller.ts +5 -9
  275. package/src/1_22/index.ts +0 -1
  276. package/src/1_22/options.ts +7 -7
  277. package/src/1_23/index.ts +0 -1
  278. package/src/1_23/options.ts +7 -7
  279. package/src/1_24/index.ts +0 -1
  280. package/src/1_24/options.ts +7 -7
  281. package/src/1_25/impl/scroll-controller.ts +10 -9
  282. package/src/1_25/index.ts +0 -1
  283. package/src/1_25/options.ts +7 -7
  284. package/src/2_0/impl/inject-touch.ts +2 -2
  285. package/src/2_0/impl/parse-audio-stream-metadata.ts +1 -1
  286. package/src/2_0/index.ts +0 -1
  287. package/src/2_0/options.ts +7 -7
  288. package/src/2_1/impl/defaults.ts +1 -1
  289. package/src/2_1/impl/init.ts +2 -2
  290. package/src/2_1/index.ts +0 -1
  291. package/src/2_1/options.ts +12 -12
  292. package/src/2_1_1.ts +9 -4
  293. package/src/2_2/impl/defaults.ts +1 -1
  294. package/src/2_2/impl/init.ts +1 -1
  295. package/src/2_2/index.ts +0 -1
  296. package/src/2_2/options.ts +12 -12
  297. package/src/2_3/impl/init.ts +3 -2
  298. package/src/2_3/index.ts +0 -1
  299. package/src/2_3/options.ts +12 -12
  300. package/src/2_3_1.ts +9 -4
  301. package/src/2_4/index.ts +0 -1
  302. package/src/2_4/options.ts +12 -12
  303. package/src/2_5.ts +9 -4
  304. package/src/2_6/impl/defaults.ts +1 -1
  305. package/src/2_6/impl/init.ts +3 -2
  306. package/src/2_6/index.ts +0 -1
  307. package/src/2_6/options.ts +12 -12
  308. package/src/2_6_1.ts +9 -4
  309. package/src/2_7/index.ts +0 -1
  310. package/src/2_7/options.ts +12 -12
  311. package/src/3_0/impl/defaults.ts +1 -1
  312. package/src/3_0/impl/init.ts +2 -1
  313. package/src/3_0/index.ts +0 -1
  314. package/src/3_0/options.ts +12 -12
  315. package/src/3_0_1.ts +9 -4
  316. package/src/3_0_2.ts +9 -4
  317. package/src/3_1/impl/defaults.ts +1 -1
  318. package/src/3_1/impl/init.ts +1 -1
  319. package/src/3_1/index.ts +0 -1
  320. package/src/3_1/options.ts +12 -12
  321. package/src/android/key-event.ts +3 -2
  322. package/src/base/options.ts +11 -8
  323. package/src/codec/h265.ts +31 -5
  324. package/src/latest.ts +9 -4
  325. package/src/utils/index.ts +0 -1
  326. package/tsconfig.build.tsbuildinfo +1 -1
  327. package/esm/utils/wrapper.d.ts +0 -38
  328. package/esm/utils/wrapper.d.ts.map +0 -1
  329. package/esm/utils/wrapper.js +0 -79
  330. package/esm/utils/wrapper.js.map +0 -1
  331. package/src/utils/wrapper.ts +0 -135
@@ -1,6 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
3
- import type { AsyncExactReadable } from "@yume-chan/struct";
3
+ import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
4
4
 
5
5
  import type {
6
6
  ScrcpyAudioStreamMetadata,
@@ -9,6 +9,7 @@ import type {
9
9
  ScrcpyEncoder,
10
10
  ScrcpyMediaStreamPacket,
11
11
  ScrcpyOptions,
12
+ ScrcpyOptionsListEncoders,
12
13
  ScrcpyScrollController,
13
14
  ScrcpyVideoStream,
14
15
  } from "../base/index.js";
@@ -41,12 +42,12 @@ import {
41
42
  UHidOutputStream,
42
43
  } from "./impl/index.js";
43
44
 
44
- export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
45
+ export class ScrcpyOptions2_6<TVideo extends boolean>
46
+ implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
47
+ {
45
48
  static readonly Defaults = Defaults;
46
49
 
47
- readonly version: string;
48
-
49
- readonly value: Required<Init>;
50
+ readonly value: Required<Init<TVideo>>;
50
51
 
51
52
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
52
53
  return ControlMessageTypes;
@@ -66,9 +67,8 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
66
67
  return this.#uHidOutput;
67
68
  }
68
69
 
69
- constructor(init: Init, version = "2.6") {
70
- this.value = { ...Defaults, ...init };
71
- this.version = version;
70
+ constructor(init: Init<TVideo>) {
71
+ this.value = { ...Defaults, ...init } as never;
72
72
 
73
73
  if (this.value.videoSource === "camera") {
74
74
  this.value.control = false;
@@ -89,7 +89,7 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
89
89
  }
90
90
 
91
91
  serialize(): string[] {
92
- return serialize(this.value, Defaults);
92
+ return serialize<Init<boolean>>(this.value, Defaults);
93
93
  }
94
94
 
95
95
  setListDisplays(): void {
@@ -122,7 +122,7 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
122
122
 
123
123
  async parseDeviceMessage(
124
124
  id: number,
125
- stream: AsyncExactReadable,
125
+ stream: ExactReadable | AsyncExactReadable,
126
126
  ): Promise<void> {
127
127
  if (await this.#clipboard?.parse(id, stream)) {
128
128
  return;
@@ -183,8 +183,8 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
183
183
  }
184
184
  }
185
185
 
186
- type Init_ = Init;
186
+ type Init_<TVideo extends boolean> = Init<TVideo>;
187
187
 
188
188
  export namespace ScrcpyOptions2_6 {
189
- export type Init = Init_;
189
+ export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
190
190
  }
package/src/2_6_1.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { ScrcpyOptions2_6 } from "./2_6/index.js";
2
2
 
3
- export class ScrcpyOptions2_6_1 extends ScrcpyOptions2_6 {
4
- constructor(init: ScrcpyOptions2_6.Init, version = "2.6.1") {
5
- super(init, version);
3
+ export class ScrcpyOptions2_6_1<
4
+ TVideo extends boolean,
5
+ > extends ScrcpyOptions2_6<TVideo> {
6
+ constructor(init: ScrcpyOptions2_6.Init<TVideo>) {
7
+ super(init);
6
8
  }
7
9
  }
8
10
 
9
- export { ScrcpyOptions2_6Impl as ScrcpyOptions2_6_1Impl } from "./2_6/index.js";
11
+ export namespace ScrcpyOptions2_6_1 {
12
+ export type Init<TVideo extends boolean = boolean> =
13
+ ScrcpyOptions2_6.Init<TVideo>;
14
+ }
package/src/2_7/index.ts CHANGED
@@ -1,2 +1 @@
1
- export * as ScrcpyOptions2_7Impl from "./impl/index.js";
2
1
  export * from "./options.js";
@@ -1,6 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
3
- import type { AsyncExactReadable } from "@yume-chan/struct";
3
+ import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
4
4
 
5
5
  import type {
6
6
  ScrcpyAudioStreamMetadata,
@@ -9,6 +9,7 @@ import type {
9
9
  ScrcpyEncoder,
10
10
  ScrcpyMediaStreamPacket,
11
11
  ScrcpyOptions,
12
+ ScrcpyOptionsListEncoders,
12
13
  ScrcpyScrollController,
13
14
  ScrcpyVideoStream,
14
15
  } from "../base/index.js";
@@ -41,12 +42,12 @@ import {
41
42
  UHidOutputStream,
42
43
  } from "./impl/index.js";
43
44
 
44
- export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
45
+ export class ScrcpyOptions2_7<TVideo extends boolean>
46
+ implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
47
+ {
45
48
  static readonly Defaults = Defaults;
46
49
 
47
- readonly version: string;
48
-
49
- readonly value: Required<Init>;
50
+ readonly value: Required<Init<TVideo>>;
50
51
 
51
52
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
52
53
  return ControlMessageTypes;
@@ -66,9 +67,8 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
66
67
  return this.#uHidOutput;
67
68
  }
68
69
 
69
- constructor(init: Init, version = "2.7") {
70
- this.value = { ...Defaults, ...init };
71
- this.version = version;
70
+ constructor(init: Init<TVideo>) {
71
+ this.value = { ...Defaults, ...init } as never;
72
72
 
73
73
  if (this.value.videoSource === "camera") {
74
74
  this.value.control = false;
@@ -89,7 +89,7 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
89
89
  }
90
90
 
91
91
  serialize(): string[] {
92
- return serialize(this.value, Defaults);
92
+ return serialize<Init<boolean>>(this.value, Defaults);
93
93
  }
94
94
 
95
95
  setListDisplays(): void {
@@ -122,7 +122,7 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
122
122
 
123
123
  async parseDeviceMessage(
124
124
  id: number,
125
- stream: AsyncExactReadable,
125
+ stream: ExactReadable | AsyncExactReadable,
126
126
  ): Promise<void> {
127
127
  if (await this.#clipboard?.parse(id, stream)) {
128
128
  return;
@@ -183,8 +183,8 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
183
183
  }
184
184
  }
185
185
 
186
- type Init_ = Init;
186
+ type Init_<TVideo extends boolean> = Init<TVideo>;
187
187
 
188
188
  export namespace ScrcpyOptions2_7 {
189
- export type Init = Init_;
189
+ export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
190
190
  }
@@ -12,4 +12,4 @@ export const Defaults = /* #__PURE__ */ (() =>
12
12
  listApps: false,
13
13
  newDisplay: undefined,
14
14
  vdSystemDecorations: true,
15
- }) as const satisfies Required<Init>)();
15
+ }) as const satisfies Required<Init<true>>)();
@@ -106,7 +106,8 @@ export class NewDisplay implements ScrcpyOptionValue {
106
106
  }
107
107
  }
108
108
 
109
- export interface Init extends Omit<PrevImpl.Init, "lockVideoOrientation"> {
109
+ export interface Init<TVideo extends boolean>
110
+ extends Omit<PrevImpl.Init<TVideo>, "lockVideoOrientation"> {
110
111
  captureOrientation?: CaptureOrientation | string | undefined;
111
112
  angle?: number;
112
113
  screenOffTimeout?: number | undefined;
package/src/3_0/index.ts CHANGED
@@ -1,2 +1 @@
1
- export * as ScrcpyOptions3_0Impl from "./impl/index.js";
2
1
  export * from "./options.js";
@@ -1,6 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
3
- import type { AsyncExactReadable } from "@yume-chan/struct";
3
+ import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
4
4
 
5
5
  import type {
6
6
  ScrcpyAudioStreamMetadata,
@@ -9,6 +9,7 @@ import type {
9
9
  ScrcpyEncoder,
10
10
  ScrcpyMediaStreamPacket,
11
11
  ScrcpyOptions,
12
+ ScrcpyOptionsListEncoders,
12
13
  ScrcpyScrollController,
13
14
  ScrcpyVideoStream,
14
15
  } from "../base/index.js";
@@ -41,12 +42,12 @@ import {
41
42
  UHidOutputStream,
42
43
  } from "./impl/index.js";
43
44
 
44
- export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
45
+ export class ScrcpyOptions3_0<TVideo extends boolean>
46
+ implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
47
+ {
45
48
  static readonly Defaults = Defaults;
46
49
 
47
- readonly version: string;
48
-
49
- readonly value: Required<Init>;
50
+ readonly value: Required<Init<TVideo>>;
50
51
 
51
52
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
52
53
  return ControlMessageTypes;
@@ -66,9 +67,8 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
66
67
  return this.#uHidOutput;
67
68
  }
68
69
 
69
- constructor(init: Init, version = "3.0") {
70
- this.value = { ...Defaults, ...init };
71
- this.version = version;
70
+ constructor(init: Init<TVideo>) {
71
+ this.value = { ...Defaults, ...init } as never;
72
72
 
73
73
  if (this.value.videoSource === "camera") {
74
74
  this.value.control = false;
@@ -89,7 +89,7 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
89
89
  }
90
90
 
91
91
  serialize(): string[] {
92
- return serialize(this.value, Defaults);
92
+ return serialize<Init<boolean>>(this.value, Defaults);
93
93
  }
94
94
 
95
95
  setListDisplays(): void {
@@ -122,7 +122,7 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
122
122
 
123
123
  async parseDeviceMessage(
124
124
  id: number,
125
- stream: AsyncExactReadable,
125
+ stream: ExactReadable | AsyncExactReadable,
126
126
  ): Promise<void> {
127
127
  if (await this.#clipboard?.parse(id, stream)) {
128
128
  return;
@@ -183,8 +183,8 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
183
183
  }
184
184
  }
185
185
 
186
- type Init_ = Init;
186
+ type Init_<TVideo extends boolean> = Init<TVideo>;
187
187
 
188
188
  export namespace ScrcpyOptions3_0 {
189
- export type Init = Init_;
189
+ export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
190
190
  }
package/src/3_0_1.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { ScrcpyOptions3_0 } from "./3_0/index.js";
2
2
 
3
- export class ScrcpyOptions3_0_1 extends ScrcpyOptions3_0 {
4
- constructor(init: ScrcpyOptions3_0.Init, version = "3.0.1") {
5
- super(init, version);
3
+ export class ScrcpyOptions3_0_1<
4
+ TVideo extends boolean,
5
+ > extends ScrcpyOptions3_0<TVideo> {
6
+ constructor(init: ScrcpyOptions3_0.Init<TVideo>) {
7
+ super(init);
6
8
  }
7
9
  }
8
10
 
9
- export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_1Impl } from "./3_0/index.js";
11
+ export namespace ScrcpyOptions3_0_1 {
12
+ export type Init<TVideo extends boolean = boolean> =
13
+ ScrcpyOptions3_0.Init<TVideo>;
14
+ }
package/src/3_0_2.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { ScrcpyOptions3_0 } from "./3_0/index.js";
2
2
 
3
- export class ScrcpyOptions3_0_2 extends ScrcpyOptions3_0 {
4
- constructor(init: ScrcpyOptions3_0.Init, version = "3.0.2") {
5
- super(init, version);
3
+ export class ScrcpyOptions3_0_2<
4
+ TVideo extends boolean,
5
+ > extends ScrcpyOptions3_0<TVideo> {
6
+ constructor(init: ScrcpyOptions3_0.Init<TVideo>) {
7
+ super(init);
6
8
  }
7
9
  }
8
10
 
9
- export { ScrcpyOptions3_0Impl as ScrcpyOptions3_0_2Impl } from "./3_0/index.js";
11
+ export namespace ScrcpyOptions3_0_2 {
12
+ export type Init<TVideo extends boolean = boolean> =
13
+ ScrcpyOptions3_0.Init<TVideo>;
14
+ }
@@ -5,4 +5,4 @@ export const Defaults = /* #__PURE__ */ (() =>
5
5
  ({
6
6
  ...PrevImpl.Defaults,
7
7
  vdDestroyContent: false,
8
- }) as const satisfies Required<Init>)();
8
+ }) as const satisfies Required<Init<true>>)();
@@ -1,5 +1,5 @@
1
1
  import type { PrevImpl } from "./prev.js";
2
2
 
3
- export interface Init extends PrevImpl.Init {
3
+ export interface Init<TVideo extends boolean> extends PrevImpl.Init<TVideo> {
4
4
  vdDestroyContent?: boolean;
5
5
  }
package/src/3_1/index.ts CHANGED
@@ -1,2 +1 @@
1
- export * as ScrcpyOptions3_1Impl from "./impl/index.js";
2
1
  export * from "./options.js";
@@ -1,6 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
3
- import type { AsyncExactReadable } from "@yume-chan/struct";
3
+ import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
4
4
 
5
5
  import type {
6
6
  ScrcpyAudioStreamMetadata,
@@ -9,6 +9,7 @@ import type {
9
9
  ScrcpyEncoder,
10
10
  ScrcpyMediaStreamPacket,
11
11
  ScrcpyOptions,
12
+ ScrcpyOptionsListEncoders,
12
13
  ScrcpyScrollController,
13
14
  ScrcpyVideoStream,
14
15
  } from "../base/index.js";
@@ -41,12 +42,12 @@ import {
41
42
  UHidOutputStream,
42
43
  } from "./impl/index.js";
43
44
 
44
- export class ScrcpyOptions3_1 implements ScrcpyOptions<Init> {
45
+ export class ScrcpyOptions3_1<TVideo extends boolean>
46
+ implements ScrcpyOptions<Init<TVideo>>, ScrcpyOptionsListEncoders
47
+ {
45
48
  static readonly Defaults = Defaults;
46
49
 
47
- readonly version: string;
48
-
49
- readonly value: Required<Init>;
50
+ readonly value: Required<Init<TVideo>>;
50
51
 
51
52
  get controlMessageTypes(): readonly ScrcpyControlMessageType[] {
52
53
  return ControlMessageTypes;
@@ -66,9 +67,8 @@ export class ScrcpyOptions3_1 implements ScrcpyOptions<Init> {
66
67
  return this.#uHidOutput;
67
68
  }
68
69
 
69
- constructor(init: Init, version = "3.1") {
70
- this.value = { ...Defaults, ...init };
71
- this.version = version;
70
+ constructor(init: Init<TVideo>) {
71
+ this.value = { ...Defaults, ...init } as never;
72
72
 
73
73
  if (this.value.videoSource === "camera") {
74
74
  this.value.control = false;
@@ -89,7 +89,7 @@ export class ScrcpyOptions3_1 implements ScrcpyOptions<Init> {
89
89
  }
90
90
 
91
91
  serialize(): string[] {
92
- return serialize(this.value, Defaults);
92
+ return serialize<Init<boolean>>(this.value, Defaults);
93
93
  }
94
94
 
95
95
  setListDisplays(): void {
@@ -122,7 +122,7 @@ export class ScrcpyOptions3_1 implements ScrcpyOptions<Init> {
122
122
 
123
123
  async parseDeviceMessage(
124
124
  id: number,
125
- stream: AsyncExactReadable,
125
+ stream: ExactReadable | AsyncExactReadable,
126
126
  ): Promise<void> {
127
127
  if (await this.#clipboard?.parse(id, stream)) {
128
128
  return;
@@ -183,8 +183,8 @@ export class ScrcpyOptions3_1 implements ScrcpyOptions<Init> {
183
183
  }
184
184
  }
185
185
 
186
- type Init_ = Init;
186
+ type Init_<TVideo extends boolean> = Init<TVideo>;
187
187
 
188
188
  export namespace ScrcpyOptions3_1 {
189
- export type Init = Init_;
189
+ export type Init<TVideo extends boolean = boolean> = Init_<TVideo>;
190
190
  }
@@ -30,8 +30,9 @@ export type AndroidKeyEventMeta =
30
30
  (typeof AndroidKeyEventMeta)[keyof typeof AndroidKeyEventMeta];
31
31
 
32
32
  // https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/KeyEvent.java;l=97;drc=95c1165bb895dd844e1793460710f7163dd330a3
33
- // Most names follow Web API `KeyboardEvent.code`,
34
- // Android-only (not exist in HID keyboard standard) keys are prefixed by `Android`.
33
+ // Android key code to Chrome key code: https://source.chromium.org/chromium/chromium/src/+/main:ui/events/keycodes/keyboard_code_conversion_android.cc
34
+ // Chrome key code to DOM key code: https://source.chromium.org/chromium/chromium/src/+/main:ui/events/keycodes/dom/dom_code_data.inc
35
+ // Some keys are not mapped to `KeyboardEvent.code`, only to `KeyboardEvent.key`: https://source.chromium.org/chromium/chromium/src/+/main:ui/events/keycodes/dom/dom_key_data.inc
35
36
  export const AndroidKeyCode = {
36
37
  AndroidHome: 3,
37
38
  AndroidBack: 4,
@@ -1,6 +1,6 @@
1
1
  import type { MaybePromiseLike } from "@yume-chan/async";
2
2
  import type { ReadableStream, TransformStream } from "@yume-chan/stream-extra";
3
- import type { AsyncExactReadable } from "@yume-chan/struct";
3
+ import type { AsyncExactReadable, ExactReadable } from "@yume-chan/struct";
4
4
 
5
5
  import type {
6
6
  ScrcpyBackOrScreenOnControlMessage,
@@ -19,8 +19,6 @@ 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
-
24
22
  get controlMessageTypes(): readonly ScrcpyControlMessageType[];
25
23
 
26
24
  value: Required<T>;
@@ -37,10 +35,6 @@ export interface ScrcpyOptions<T extends object> {
37
35
 
38
36
  parseDisplay(line: string): ScrcpyDisplay | undefined;
39
37
 
40
- setListEncoders?(): void;
41
-
42
- parseEncoder?(line: string): ScrcpyEncoder | undefined;
43
-
44
38
  parseVideoStreamMetadata(
45
39
  stream: ReadableStream<Uint8Array>,
46
40
  ): MaybePromiseLike<ScrcpyVideoStream>;
@@ -49,7 +43,10 @@ export interface ScrcpyOptions<T extends object> {
49
43
  stream: ReadableStream<Uint8Array>,
50
44
  ): MaybePromiseLike<ScrcpyAudioStreamMetadata>;
51
45
 
52
- parseDeviceMessage(id: number, stream: AsyncExactReadable): Promise<void>;
46
+ parseDeviceMessage(
47
+ id: number,
48
+ stream: ExactReadable | AsyncExactReadable,
49
+ ): Promise<void>;
53
50
 
54
51
  endDeviceMessageStream(e?: unknown): void;
55
52
 
@@ -76,3 +73,9 @@ export interface ScrcpyOptions<T extends object> {
76
73
  message: ScrcpyUHidCreateControlMessage,
77
74
  ): Uint8Array;
78
75
  }
76
+
77
+ export interface ScrcpyOptionsListEncoders {
78
+ setListEncoders(): void;
79
+
80
+ parseEncoder(line: string): ScrcpyEncoder | undefined;
81
+ }
package/src/codec/h265.ts CHANGED
@@ -330,8 +330,10 @@ export function h265ParseSequenceParameterSet(nalu: Uint8Array) {
330
330
  if (pcm_enabled_flag) {
331
331
  pcm_sample_bit_depth_luma_minus1 = reader.read(4);
332
332
  pcm_sample_bit_depth_chroma_minus1 = reader.read(4);
333
- log2_min_pcm_luma_coding_block_size_minus3 = reader.read(4);
334
- log2_diff_max_min_pcm_luma_coding_block_size = reader.read(4);
333
+ log2_min_pcm_luma_coding_block_size_minus3 =
334
+ reader.decodeExponentialGolombNumber();
335
+ log2_diff_max_min_pcm_luma_coding_block_size =
336
+ reader.decodeExponentialGolombNumber();
335
337
  pcm_loop_filter_disabled_flag = !!reader.next();
336
338
  }
337
339
 
@@ -894,6 +896,30 @@ export function h265ParseShortTermReferencePictureSet(
894
896
  };
895
897
  }
896
898
 
899
+ export const H265AspectRatioIndicator = {
900
+ Unspecified: 0,
901
+ Square: 1,
902
+ _12_11: 2,
903
+ _10_11: 3,
904
+ _16_11: 4,
905
+ _40_33: 5,
906
+ _24_11: 6,
907
+ _20_11: 7,
908
+ _32_11: 8,
909
+ _80_33: 9,
910
+ _18_11: 10,
911
+ _15_11: 11,
912
+ _64_33: 12,
913
+ _160_99: 13,
914
+ _4_3: 15,
915
+ _3_2: 16,
916
+ _2_1: 17,
917
+ Extended: 255,
918
+ } as const;
919
+
920
+ export type H265AspectRatioIndicator =
921
+ (typeof H265AspectRatioIndicator)[keyof typeof H265AspectRatioIndicator];
922
+
897
923
  /**
898
924
  * E.2.1 VUI parameters syntax
899
925
  */
@@ -902,12 +928,12 @@ export function h265ParseVuiParameters(
902
928
  sps_max_sub_layers_minus1: number,
903
929
  ) {
904
930
  const aspect_ratio_info_present_flag = !!reader.next();
905
- let aspect_ratio_idc: number | undefined;
931
+ let aspect_ratio_idc: H265AspectRatioIndicator | undefined;
906
932
  let sar_width: number | undefined;
907
933
  let sar_height: number | undefined;
908
934
  if (aspect_ratio_info_present_flag) {
909
- aspect_ratio_idc = reader.read(8);
910
- if (aspect_ratio_idc === 255) {
935
+ aspect_ratio_idc = reader.read(8) as H265AspectRatioIndicator;
936
+ if (aspect_ratio_idc === H265AspectRatioIndicator.Extended) {
911
937
  sar_width = reader.read(16);
912
938
  sar_height = reader.read(16);
913
939
  }
package/src/latest.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  import { ScrcpyOptions3_1 } from "./3_1/options.js";
2
2
 
3
- export class ScrcpyOptionsLatest extends ScrcpyOptions3_1 {
4
- constructor(init: ScrcpyOptions3_1.Init, version: string) {
5
- super(init, version);
3
+ export class ScrcpyOptionsLatest<
4
+ TVideo extends boolean,
5
+ > extends ScrcpyOptions3_1<TVideo> {
6
+ constructor(init: ScrcpyOptions3_1.Init<TVideo>) {
7
+ super(init);
6
8
  }
7
9
  }
8
10
 
9
- export { ScrcpyOptions3_1Impl as ScrcpyOptionsLatestImpl } from "./3_1/index.js";
11
+ export namespace ScrcpyOptionsLatest {
12
+ export type Init<TVideo extends boolean = boolean> =
13
+ ScrcpyOptions3_1.Init<TVideo>;
14
+ }
10
15
 
11
16
  export {
12
17
  BackOrScreenOnControlMessage as ScrcpyBackOrScreenOnControlMessage,
@@ -1,4 +1,3 @@
1
1
  export * from "./clamp.js";
2
2
  export * from "./constants.js";
3
3
  export * from "./omit.js";
4
- export * from "./wrapper.js";