@yume-chan/scrcpy 0.0.17 → 0.0.19

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 (323) hide show
  1. package/CHANGELOG.json +39 -3
  2. package/CHANGELOG.md +22 -4
  3. package/LICENSE +1 -1
  4. package/README.md +149 -82
  5. package/bin/scrcpy-server +0 -0
  6. package/bin/version.d.ts +1 -1
  7. package/bin/version.js +1 -1
  8. package/esm/adb/client.d.ts +40 -39
  9. package/esm/adb/client.d.ts.map +1 -1
  10. package/esm/adb/client.js +223 -217
  11. package/esm/adb/client.js.map +1 -1
  12. package/esm/adb/connection.d.ts +48 -37
  13. package/esm/adb/connection.d.ts.map +1 -1
  14. package/esm/adb/connection.js +121 -101
  15. package/esm/adb/connection.js.map +1 -1
  16. package/esm/adb/index.d.ts +3 -3
  17. package/esm/adb/index.js +3 -3
  18. package/esm/adb/options/1_16.d.ts +7 -7
  19. package/esm/adb/options/1_16.d.ts.map +1 -1
  20. package/esm/adb/options/1_16.js +19 -19
  21. package/esm/adb/options/1_16.js.map +1 -1
  22. package/esm/adb/options/1_22.d.ts +7 -7
  23. package/esm/adb/options/1_22.d.ts.map +1 -1
  24. package/esm/adb/options/1_22.js +16 -16
  25. package/esm/adb/options/1_22.js.map +1 -1
  26. package/esm/adb/options/1_26.d.ts +9 -0
  27. package/esm/adb/options/1_26.d.ts.map +1 -0
  28. package/esm/adb/options/1_26.js +11 -0
  29. package/esm/adb/options/1_26.js.map +1 -0
  30. package/esm/adb/options/2_0.d.ts +8 -0
  31. package/esm/adb/options/2_0.d.ts.map +1 -0
  32. package/esm/adb/options/2_0.js +13 -0
  33. package/esm/adb/options/2_0.js.map +1 -0
  34. package/esm/adb/options/index.d.ts +3 -3
  35. package/esm/adb/options/index.js +3 -3
  36. package/esm/adb/options/types.d.ts +23 -22
  37. package/esm/adb/options/types.d.ts.map +1 -1
  38. package/esm/adb/options/types.js +36 -29
  39. package/esm/adb/options/types.js.map +1 -1
  40. package/esm/codec/av1.d.ts +33 -0
  41. package/esm/codec/av1.d.ts.map +1 -0
  42. package/esm/codec/av1.js +35 -0
  43. package/esm/codec/av1.js.map +1 -0
  44. package/esm/codec/h264.d.ts +98 -0
  45. package/esm/codec/h264.d.ts.map +1 -0
  46. package/esm/codec/h264.js +477 -0
  47. package/esm/codec/h264.js.map +1 -0
  48. package/esm/codec/h265.d.ts +36 -0
  49. package/esm/codec/h265.d.ts.map +1 -0
  50. package/esm/codec/h265.js +38 -0
  51. package/esm/codec/h265.js.map +1 -0
  52. package/esm/codec/index.d.ts +4 -0
  53. package/esm/codec/index.d.ts.map +1 -0
  54. package/esm/codec/index.js +4 -0
  55. package/esm/codec/index.js.map +1 -0
  56. package/esm/codec.d.ts +33 -33
  57. package/esm/codec.js +36 -36
  58. package/esm/control/back-or-screen-on.d.ts +3 -0
  59. package/esm/control/back-or-screen-on.d.ts.map +1 -0
  60. package/esm/control/back-or-screen-on.js +2 -0
  61. package/esm/control/back-or-screen-on.js.map +1 -0
  62. package/esm/control/basic.d.ts +5 -0
  63. package/esm/control/basic.d.ts.map +1 -0
  64. package/esm/control/basic.js +3 -0
  65. package/esm/control/basic.js.map +1 -0
  66. package/esm/control/hover-helper.d.ts +18 -0
  67. package/esm/control/hover-helper.d.ts.map +1 -0
  68. package/esm/control/hover-helper.js +44 -0
  69. package/esm/control/hover-helper.js.map +1 -0
  70. package/esm/control/index.d.ts +11 -7
  71. package/esm/control/index.d.ts.map +1 -1
  72. package/esm/control/index.js +11 -7
  73. package/esm/control/index.js.map +1 -1
  74. package/esm/control/inject-keycode.d.ts +194 -52
  75. package/esm/control/inject-keycode.d.ts.map +1 -1
  76. package/esm/control/inject-keycode.js +199 -53
  77. package/esm/control/inject-keycode.js.map +1 -1
  78. package/esm/control/inject-scroll.d.ts +3 -0
  79. package/esm/control/inject-scroll.d.ts.map +1 -0
  80. package/esm/control/inject-scroll.js +2 -0
  81. package/esm/control/inject-scroll.js.map +1 -0
  82. package/esm/control/inject-text.d.ts +8 -8
  83. package/esm/control/inject-text.d.ts.map +1 -1
  84. package/esm/control/inject-text.js +6 -6
  85. package/esm/control/inject-text.js.map +1 -1
  86. package/esm/control/inject-touch.d.ts +37 -29
  87. package/esm/control/inject-touch.d.ts.map +1 -1
  88. package/esm/control/inject-touch.js +62 -29
  89. package/esm/control/inject-touch.js.map +1 -1
  90. package/esm/control/rotate-device.d.ts +6 -6
  91. package/esm/control/rotate-device.d.ts.map +1 -1
  92. package/esm/control/rotate-device.js +3 -4
  93. package/esm/control/rotate-device.js.map +1 -1
  94. package/esm/control/serializer.d.ts +35 -22
  95. package/esm/control/serializer.d.ts.map +1 -1
  96. package/esm/control/serializer.js +82 -72
  97. package/esm/control/serializer.js.map +1 -1
  98. package/esm/control/set-clipboard.d.ts +3 -0
  99. package/esm/control/set-clipboard.d.ts.map +1 -0
  100. package/esm/control/set-clipboard.js +2 -0
  101. package/esm/control/set-clipboard.js.map +1 -0
  102. package/esm/control/set-screen-power-mode.d.ts +11 -11
  103. package/esm/control/set-screen-power-mode.d.ts.map +1 -1
  104. package/esm/control/set-screen-power-mode.js +11 -11
  105. package/esm/control/set-screen-power-mode.js.map +1 -1
  106. package/esm/control/simple.d.ts +5 -0
  107. package/esm/control/simple.d.ts.map +1 -0
  108. package/esm/control/simple.js +3 -0
  109. package/esm/control/simple.js.map +1 -0
  110. package/esm/control/type.d.ts +14 -14
  111. package/esm/control/type.js +18 -18
  112. package/esm/decoder.d.ts +2 -0
  113. package/esm/decoder.d.ts.map +1 -0
  114. package/esm/decoder.js +2 -0
  115. package/esm/decoder.js.map +1 -0
  116. package/esm/device-message/ack-clipboard.d.ts +9 -0
  117. package/esm/device-message/ack-clipboard.d.ts.map +1 -0
  118. package/esm/device-message/ack-clipboard.js +6 -0
  119. package/esm/device-message/ack-clipboard.js.map +1 -0
  120. package/esm/device-message/clipboard.d.ts +9 -9
  121. package/esm/device-message/clipboard.d.ts.map +1 -1
  122. package/esm/device-message/clipboard.js +6 -6
  123. package/esm/device-message/clipboard.js.map +1 -1
  124. package/esm/device-message/index.d.ts +4 -3
  125. package/esm/device-message/index.d.ts.map +1 -1
  126. package/esm/device-message/index.js +4 -3
  127. package/esm/device-message/index.js.map +1 -1
  128. package/esm/device-message/stream.d.ts +7 -6
  129. package/esm/device-message/stream.d.ts.map +1 -1
  130. package/esm/device-message/stream.js +19 -15
  131. package/esm/device-message/stream.js.map +1 -1
  132. package/esm/device-message/type.d.ts +4 -4
  133. package/esm/device-message/type.js +6 -6
  134. package/esm/index.d.ts +5 -5
  135. package/esm/index.js +5 -5
  136. package/esm/options/1.17.d.ts +3 -0
  137. package/esm/options/1.17.d.ts.map +1 -0
  138. package/esm/options/1.17.js +2 -0
  139. package/esm/options/1.17.js.map +1 -0
  140. package/esm/options/1_16/codec-options.d.ts +20 -18
  141. package/esm/options/1_16/codec-options.d.ts.map +1 -1
  142. package/esm/options/1_16/codec-options.js +25 -26
  143. package/esm/options/1_16/codec-options.js.map +1 -1
  144. package/esm/options/1_16/float-to-uint16.d.ts +5 -0
  145. package/esm/options/1_16/float-to-uint16.d.ts.map +1 -0
  146. package/esm/options/1_16/float-to-uint16.js +27 -0
  147. package/esm/options/1_16/float-to-uint16.js.map +1 -0
  148. package/esm/options/1_16/h264-configuration.d.ts +49 -0
  149. package/esm/options/1_16/h264-configuration.d.ts.map +1 -0
  150. package/esm/options/1_16/h264-configuration.js +414 -0
  151. package/esm/options/1_16/h264-configuration.js.map +1 -0
  152. package/esm/options/1_16/index.d.ts +4 -3
  153. package/esm/options/1_16/index.d.ts.map +1 -1
  154. package/esm/options/1_16/index.js +4 -3
  155. package/esm/options/1_16/index.js.map +1 -1
  156. package/esm/options/1_16/init.d.ts +66 -0
  157. package/esm/options/1_16/init.d.ts.map +1 -0
  158. package/esm/options/1_16/init.js +16 -0
  159. package/esm/options/1_16/init.js.map +1 -0
  160. package/esm/options/1_16/message.d.ts +32 -0
  161. package/esm/options/1_16/message.d.ts.map +1 -0
  162. package/esm/options/1_16/message.js +37 -0
  163. package/esm/options/1_16/message.js.map +1 -0
  164. package/esm/options/1_16/options.d.ts +102 -96
  165. package/esm/options/1_16/options.d.ts.map +1 -1
  166. package/esm/options/1_16/options.js +189 -187
  167. package/esm/options/1_16/options.js.map +1 -1
  168. package/esm/options/1_16/scroll.d.ts +28 -0
  169. package/esm/options/1_16/scroll.d.ts.map +1 -0
  170. package/esm/options/1_16/scroll.js +56 -0
  171. package/esm/options/1_16/scroll.js.map +1 -0
  172. package/esm/options/1_16/sps.d.ts +1 -1
  173. package/esm/options/1_16/sps.d.ts.map +1 -1
  174. package/esm/options/1_16/sps.js +25 -17
  175. package/esm/options/1_16/sps.js.map +1 -1
  176. package/esm/options/1_17.d.ts +32 -0
  177. package/esm/options/1_17.d.ts.map +1 -0
  178. package/esm/options/1_17.js +36 -0
  179. package/esm/options/1_17.js.map +1 -0
  180. package/esm/options/1_18.d.ts +21 -19
  181. package/esm/options/1_18.d.ts.map +1 -1
  182. package/esm/options/1_18.js +45 -45
  183. package/esm/options/1_18.js.map +1 -1
  184. package/esm/options/1_21.d.ts +22 -9
  185. package/esm/options/1_21.d.ts.map +1 -1
  186. package/esm/options/1_21.js +36 -25
  187. package/esm/options/1_21.js.map +1 -1
  188. package/esm/options/1_22/index.d.ts +3 -0
  189. package/esm/options/1_22/index.d.ts.map +1 -0
  190. package/esm/options/1_22/index.js +3 -0
  191. package/esm/options/1_22/index.js.map +1 -0
  192. package/esm/options/1_22/init.d.ts +17 -0
  193. package/esm/options/1_22/init.d.ts.map +1 -0
  194. package/esm/options/1_22/init.js +2 -0
  195. package/esm/options/1_22/init.js.map +1 -0
  196. package/esm/options/{1_22.d.ts → 1_22/options.d.ts} +30 -40
  197. package/esm/options/1_22/options.d.ts.map +1 -0
  198. package/esm/options/{1_22.js → 1_22/options.js} +26 -30
  199. package/esm/options/1_22/options.js.map +1 -0
  200. package/esm/options/1_22/scroll.d.ts +17 -0
  201. package/esm/options/1_22/scroll.d.ts.map +1 -0
  202. package/esm/options/1_22/scroll.js +15 -0
  203. package/esm/options/1_22/scroll.js.map +1 -0
  204. package/esm/options/1_23.d.ts +12 -11
  205. package/esm/options/1_23.d.ts.map +1 -1
  206. package/esm/options/1_23.js +34 -33
  207. package/esm/options/1_23.js.map +1 -1
  208. package/esm/options/1_24.d.ts +9 -8
  209. package/esm/options/1_24.d.ts.map +1 -1
  210. package/esm/options/1_24.js +12 -12
  211. package/esm/options/1_24.js.map +1 -1
  212. package/esm/options/1_25/index.d.ts +3 -0
  213. package/esm/options/1_25/index.d.ts.map +1 -0
  214. package/esm/options/1_25/index.js +3 -0
  215. package/esm/options/1_25/index.js.map +1 -0
  216. package/esm/options/1_25/options.d.ts +7 -0
  217. package/esm/options/1_25/options.d.ts.map +1 -0
  218. package/esm/options/1_25/options.js +8 -0
  219. package/esm/options/1_25/options.js.map +1 -0
  220. package/esm/options/1_25/scroll.d.ts +20 -0
  221. package/esm/options/1_25/scroll.d.ts.map +1 -0
  222. package/esm/options/1_25/scroll.js +33 -0
  223. package/esm/options/1_25/scroll.js.map +1 -0
  224. package/esm/options/1_26.d.ts +57 -0
  225. package/esm/options/1_26.d.ts.map +1 -0
  226. package/esm/options/1_26.js +67 -0
  227. package/esm/options/1_26.js.map +1 -0
  228. package/esm/options/2.d.ts +57 -0
  229. package/esm/options/2.d.ts.map +1 -0
  230. package/esm/options/2.js +67 -0
  231. package/esm/options/2.js.map +1 -0
  232. package/esm/options/2_0.d.ts +87 -0
  233. package/esm/options/2_0.d.ts.map +1 -0
  234. package/esm/options/2_0.js +175 -0
  235. package/esm/options/2_0.js.map +1 -0
  236. package/esm/options/codec.d.ts +52 -0
  237. package/esm/options/codec.d.ts.map +1 -0
  238. package/esm/options/codec.js +26 -0
  239. package/esm/options/codec.js.map +1 -0
  240. package/esm/options/index.d.ts +8 -7
  241. package/esm/options/index.d.ts.map +1 -1
  242. package/esm/options/index.js +8 -7
  243. package/esm/options/index.js.map +1 -1
  244. package/esm/options/latest.d.ts +12 -0
  245. package/esm/options/latest.d.ts.map +1 -0
  246. package/esm/options/latest.js +8 -0
  247. package/esm/options/latest.js.map +1 -0
  248. package/esm/options/types.d.ts +46 -44
  249. package/esm/options/types.d.ts.map +1 -1
  250. package/esm/options/types.js +17 -15
  251. package/esm/options/types.js.map +1 -1
  252. package/package.json +20 -12
  253. package/scripts/fetch-server.cjs +19 -9
  254. package/src/adb/client.ts +184 -147
  255. package/src/adb/connection.ts +95 -31
  256. package/src/adb/index.ts +3 -3
  257. package/src/adb/options/1_16.ts +15 -6
  258. package/src/adb/options/1_22.ts +12 -6
  259. package/src/adb/options/index.ts +3 -3
  260. package/src/adb/options/types.ts +34 -14
  261. package/src/control/back-or-screen-on.ts +4 -0
  262. package/src/control/hover-helper.ts +54 -0
  263. package/src/control/index.ts +11 -7
  264. package/src/control/inject-keycode.ts +203 -45
  265. package/src/control/inject-scroll.ts +4 -0
  266. package/src/control/inject-text.ts +7 -8
  267. package/src/control/inject-touch.ts +58 -14
  268. package/src/control/rotate-device.ts +7 -6
  269. package/src/control/serializer.ts +111 -43
  270. package/src/control/set-clipboard.ts +4 -0
  271. package/src/control/set-screen-power-mode.ts +7 -8
  272. package/src/device-message/ack-clipboard.ts +10 -0
  273. package/src/device-message/clipboard.ts +8 -8
  274. package/src/device-message/index.ts +4 -3
  275. package/src/device-message/stream.ts +17 -7
  276. package/src/index.ts +5 -5
  277. package/src/options/1_16/codec-options.ts +16 -11
  278. package/src/options/1_16/h264-configuration.ts +485 -0
  279. package/src/options/1_16/index.ts +4 -3
  280. package/src/options/1_16/options.ts +180 -130
  281. package/src/options/1_16/scroll.ts +74 -0
  282. package/src/options/1_18.ts +22 -12
  283. package/src/options/1_21.ts +30 -13
  284. package/src/options/1_22/index.ts +2 -0
  285. package/src/options/{1_22.ts → 1_22/options.ts} +9 -17
  286. package/src/options/1_22/scroll.ts +26 -0
  287. package/src/options/1_23.ts +30 -20
  288. package/src/options/1_24.ts +5 -3
  289. package/src/options/1_25/index.ts +2 -0
  290. package/src/options/1_25/options.ts +13 -0
  291. package/src/options/1_25/scroll.ts +49 -0
  292. package/src/options/index.ts +8 -7
  293. package/src/options/types.ts +36 -19
  294. package/tsconfig.build.json +1 -1
  295. package/tsconfig.build.tsbuildinfo +1 -1
  296. package/esm/decoder/index.d.ts +0 -28
  297. package/esm/decoder/index.d.ts.map +0 -1
  298. package/esm/decoder/index.js +0 -2
  299. package/esm/decoder/index.js.map +0 -1
  300. package/esm/decoder/tinyh264/index.d.ts +0 -20
  301. package/esm/decoder/tinyh264/index.d.ts.map +0 -1
  302. package/esm/decoder/tinyh264/index.js +0 -86
  303. package/esm/decoder/tinyh264/index.js.map +0 -1
  304. package/esm/decoder/tinyh264/worker.d.ts +0 -2
  305. package/esm/decoder/tinyh264/worker.d.ts.map +0 -1
  306. package/esm/decoder/tinyh264/worker.js +0 -3
  307. package/esm/decoder/tinyh264/worker.js.map +0 -1
  308. package/esm/decoder/tinyh264/wrapper.d.ts +0 -21
  309. package/esm/decoder/tinyh264/wrapper.d.ts.map +0 -1
  310. package/esm/decoder/tinyh264/wrapper.js +0 -74
  311. package/esm/decoder/tinyh264/wrapper.js.map +0 -1
  312. package/esm/decoder/types.d.ts +0 -2
  313. package/esm/decoder/types.d.ts.map +0 -1
  314. package/esm/decoder/types.js +0 -2
  315. package/esm/decoder/types.js.map +0 -1
  316. package/esm/decoder/web-codecs/index.d.ts +0 -22
  317. package/esm/decoder/web-codecs/index.d.ts.map +0 -1
  318. package/esm/decoder/web-codecs/index.js +0 -81
  319. package/esm/decoder/web-codecs/index.js.map +0 -1
  320. package/esm/options/1_22.d.ts.map +0 -1
  321. package/esm/options/1_22.js.map +0 -1
  322. package/src/options/1_16/sps.ts +0 -300
  323. package/tsconfig.test.tsbuildinfo +0 -1
package/CHANGELOG.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@yume-chan/scrcpy",
3
3
  "entries": [
4
+ {
5
+ "version": "0.0.19",
6
+ "tag": "@yume-chan/scrcpy_v0.0.19",
7
+ "date": "Sun, 09 Apr 2023 05:55:33 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Change `AdbScrcpyClient#pushServer` to take a `ReadableStream<Uint8Array>` instead of returning a `WritableStream<Uint8Array>`"
12
+ },
13
+ {
14
+ "comment": "Add `AdbReverseNotSupportedError` handling and automatically switch to forward tunnel in `AdbScrcpyClient`."
15
+ },
16
+ {
17
+ "comment": "Update `AndroidKeyCode` enum to align with Web `KeyboardEvent.code`"
18
+ }
19
+ ]
20
+ }
21
+ },
22
+ {
23
+ "version": "0.0.18",
24
+ "tag": "@yume-chan/scrcpy_v0.0.18",
25
+ "date": "Wed, 25 Jan 2023 21:33:49 GMT",
26
+ "comments": {
27
+ "none": [
28
+ {
29
+ "comment": "Move `@yume-chan/adb` to `peerDependencies`"
30
+ },
31
+ {
32
+ "comment": "Add support for Scrcpy server version 1.25"
33
+ },
34
+ {
35
+ "comment": "Add support for `SetClipboard` control message and `AckClipboard` device message"
36
+ }
37
+ ]
38
+ }
39
+ },
4
40
  {
5
41
  "version": "0.0.17",
6
42
  "tag": "@yume-chan/scrcpy_v0.0.17",
@@ -56,7 +92,7 @@
56
92
  "comments": {
57
93
  "none": [
58
94
  {
59
- "comment": "Add support for new option of 1.24"
95
+ "comment": "Add support for Scrcpy server version 1.24"
60
96
  }
61
97
  ]
62
98
  }
@@ -68,7 +104,7 @@
68
104
  "comments": {
69
105
  "none": [
70
106
  {
71
- "comment": "Add support for 1.23"
107
+ "comment": "Add support for Scrcpy server version 1.23"
72
108
  }
73
109
  ]
74
110
  }
@@ -86,7 +122,7 @@
86
122
  "comments": {
87
123
  "none": [
88
124
  {
89
- "comment": "Add support for 1.22 new server options"
125
+ "comment": "Add support for Scrcpy server version 1.22"
90
126
  },
91
127
  {
92
128
  "comment": "Update to use Web Streams API"
package/CHANGELOG.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # Change Log - @yume-chan/scrcpy
2
2
 
3
- This log was last generated on Tue, 18 Oct 2022 09:32:30 GMT and should not be manually modified.
3
+ This log was last generated on Sun, 09 Apr 2023 05:55:33 GMT and should not be manually modified.
4
+
5
+ ## 0.0.19
6
+ Sun, 09 Apr 2023 05:55:33 GMT
7
+
8
+ ### Updates
9
+
10
+ - Change `AdbScrcpyClient#pushServer` to take a `ReadableStream<Uint8Array>` instead of returning a `WritableStream<Uint8Array>`
11
+ - Add `AdbReverseNotSupportedError` handling and automatically switch to forward tunnel in `AdbScrcpyClient`.
12
+ - Update `AndroidKeyCode` enum to align with Web `KeyboardEvent.code`
13
+
14
+ ## 0.0.18
15
+ Wed, 25 Jan 2023 21:33:49 GMT
16
+
17
+ ### Updates
18
+
19
+ - Move `@yume-chan/adb` to `peerDependencies`
20
+ - Add support for Scrcpy server version 1.25
21
+ - Add support for `SetClipboard` control message and `AckClipboard` device message
4
22
 
5
23
  ## 0.0.17
6
24
  Tue, 18 Oct 2022 09:32:30 GMT
@@ -32,14 +50,14 @@ Sat, 30 Apr 2022 14:05:48 GMT
32
50
 
33
51
  ### Updates
34
52
 
35
- - Add support for new option of 1.24
53
+ - Add support for Scrcpy server version 1.24
36
54
 
37
55
  ## 0.0.13
38
56
  Thu, 28 Apr 2022 01:23:53 GMT
39
57
 
40
58
  ### Updates
41
59
 
42
- - Add support for 1.23
60
+ - Add support for Scrcpy server version 1.23
43
61
 
44
62
  ## 0.0.12
45
63
  Sun, 03 Apr 2022 11:18:47 GMT
@@ -51,7 +69,7 @@ Sun, 03 Apr 2022 10:54:15 GMT
51
69
 
52
70
  ### Updates
53
71
 
54
- - Add support for 1.22 new server options
72
+ - Add support for Scrcpy server version 1.22
55
73
  - Update to use Web Streams API
56
74
  - Improve compatibility with Node.js 12 ESM format
57
75
  - Workaround a issue with server crash on Samsung ROM (https://github.com/Genymobile/scrcpy/issues/2841)
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2022 Simon Chan
3
+ Copyright (c) 2020-2023 Simon Chan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -6,7 +6,7 @@ It's compatible with the official Scrcpy server binaries.
6
6
 
7
7
  **WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.
8
8
 
9
- - [Transport agnostic](#transport-agnostic)
9
+ - [Basic information](#basic-information)
10
10
  - [Prepare server binary](#prepare-server-binary)
11
11
  - [`fetch-scrcpy-server`](#fetch-scrcpy-server)
12
12
  - [Use the server binary](#use-the-server-binary)
@@ -15,7 +15,7 @@ It's compatible with the official Scrcpy server binaries.
15
15
  - [Webpack 4](#webpack-4)
16
16
  - [Webpack 5](#webpack-5)
17
17
  - [Read the server version](#read-the-server-version)
18
- - [Option versions](#option-versions)
18
+ - [Server versions](#server-versions)
19
19
  - [Use with `@yume-chan/adb`](#use-with-yume-chanadb)
20
20
  - [Push server binary](#push-server-binary)
21
21
  - [Start server on device](#start-server-on-device)
@@ -23,17 +23,25 @@ It's compatible with the official Scrcpy server binaries.
23
23
  - [Parsing video packets](#parsing-video-packets)
24
24
  - [Sending control messages](#sending-control-messages)
25
25
  - [Reading device messages](#reading-device-messages)
26
- - [Consume the streams](#consume-the-streams)
26
+ - [Always read the streams](#always-read-the-streams)
27
27
  - [Video stream](#video-stream)
28
28
  - [Decode video stream](#decode-video-stream)
29
29
 
30
- ## Transport agnostic
30
+ ## Basic information
31
31
 
32
- It was initially designed to be used with `@yume-chan/adb`, but now it can also to used with any other transportation.
32
+ Although Scrcpy doesn't install any App on the device, it does have a server binary executable to be run on the device.
33
+
34
+ With the official Scrcpy client and server, the client uses ADB to transfer the server binary file to the device, run it, and communicate with it via ADB tunnel (the bootstrap process).
35
+
36
+ This package provides types that can serialize and deserialize Scrcpy protocol messages, but it generally requires you to do the bootstrapping and provide the data stream to the server.
37
+
38
+ If you are also using `@yume-chan/adb`, this package has a helper class that can complete the bootstrap process using it, doing what the official client does.
39
+
40
+ **NOTE:** `@yume-chan/adb` is a peer dependency, you need to install it yourself. Only those types whose names begin with `Adb` requires `@yume-chan/adb`.
33
41
 
34
42
  ## Prepare server binary
35
43
 
36
- Scrcpy needs a server binary running on the device in order to work. This package doesn't ship with one.
44
+ This package doesn't include the server binary. It's compatible with many versions of the official server binary, but may not work with future versions due to protocol changes.
37
45
 
38
46
  You can download the server binary from official releases (https://github.com/Genymobile/scrcpy/releases), or use the built-in `fetch-scrcpy-server` script to automate the process.
39
47
 
@@ -41,9 +49,11 @@ The server binary is subject to [Apache License 2.0](https://github.com/Genymobi
41
49
 
42
50
  ### `fetch-scrcpy-server`
43
51
 
44
- To use the script, first add `gh-release-fetch@3` to `devDependencies` of your `package.json`. It's an optional peer dependency fpr minimized download size.
52
+ This package includes a script that downloads the server binary from official releases for you.
45
53
 
46
- Then you can invoke it in a terminal:
54
+ The `gh-release-fetch@3` package is a peer dependency for this script, thus requires separated installation.
55
+
56
+ Usage:
47
57
 
48
58
  ```
49
59
  $ npx fetch-scrcpy-server <version>
@@ -52,14 +62,14 @@ $ npx fetch-scrcpy-server <version>
52
62
  For example:
53
63
 
54
64
  ```
55
- $ npx fetch-scrcpy-server 1.24
65
+ $ npx fetch-scrcpy-server 1.25
56
66
  ```
57
67
 
58
- You can also add it to the `postinstall` script in your `package.json`. After that, running `npm install` will automatically invoke the script.
68
+ It can also be added to the `postinstall` script in `package.json`, so running `npm install` will automatically invoke the script:
59
69
 
60
70
  ```json
61
71
  "scripts": {
62
- "postinstall": "fetch-scrcpy-server 1.24",
72
+ "postinstall": "fetch-scrcpy-server 1.25",
63
73
  },
64
74
  ```
65
75
 
@@ -67,34 +77,41 @@ The server binary will be named `bin/scrcpy-server` in this package's installati
67
77
 
68
78
  ### Use the server binary
69
79
 
70
- The server binary file needs to be embedded into your application, the exact method depends on the runtime.
80
+ The server binary file needs to be embedded into your application, the exact method depends on the bundler and runtime.
71
81
 
72
82
  To name a few:
73
83
 
74
84
  #### Node.js CommonJS
75
85
 
76
86
  ```ts
77
- const fs = require('fs');
78
- const path: string = require.resolve('@yume-chan/scrcpy/bin/scrcpy-server'); // Or your own server binary path
87
+ const fs = require("fs");
88
+ const path: string = require.resolve("@yume-chan/scrcpy/bin/scrcpy-server"); // Or your own server binary path
79
89
  const buffer: Buffer = fs.readFileSync(path);
80
90
  ```
81
91
 
82
92
  #### Node.js ES module
83
93
 
84
94
  ```ts
85
- import fs from 'node:fs/promises';
86
- import { createRequire } from 'node:module';
95
+ import fs from "node:fs/promises";
96
+ import { createRequire } from "node:module";
87
97
 
88
- const path: string = createRequire(import.meta.url).resolve('@yume-chan/scrcpy/bin/scrcpy-server'); // Or your own server binary path
98
+ const path: string = createRequire(import.meta.url).resolve(
99
+ "@yume-chan/scrcpy/bin/scrcpy-server"
100
+ ); // Or your own server binary path
89
101
  const buffer: Buffer = await fs.readFile(path);
90
102
  ```
91
103
 
92
104
  Currently, ES Module doesn't have a `resolve` function like `require.resolve` in CommonJS, so `createRequire` is used to create a CommonJS resolver.
93
105
 
94
- `import.meta.resolve` (https://github.com/whatwg/html/pull/5572) is a proposal that fills this gap. Node.js already has experimental support for it behind a flag. See https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent for more information.
106
+ Or with the `--experimental-import-meta-resolve` command line flag, you can use `import.meta.resolve`:
95
107
 
96
108
  ```ts
97
- const path: string = import.meta.resolve('@yume-chan/scrcpy/bin/scrcpy-server');
109
+ import fs from "node:fs/promises";
110
+
111
+ const path: string = await import.meta.resolve(
112
+ "@yume-chan/scrcpy/bin/scrcpy-server"
113
+ );
114
+ const buffer: Buffer = await fs.readFile(path);
98
115
  ```
99
116
 
100
117
  #### Webpack 4
@@ -102,8 +119,10 @@ const path: string = import.meta.resolve('@yume-chan/scrcpy/bin/scrcpy-server');
102
119
  Requires installing and configuring file-loader (https://v4.webpack.js.org/loaders/file-loader/)
103
120
 
104
121
  ```ts
105
- import SCRCPY_SERVER_URL from '@yume-chan/scrcpy/bin/scrcpy-server'; // Or your own server binary path
106
- const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(res => res.arrayBuffer());
122
+ import SCRCPY_SERVER_URL from "@yume-chan/scrcpy/bin/scrcpy-server"; // Or your own server binary path
123
+ const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then((response) =>
124
+ response.arrayBuffer()
125
+ );
107
126
  ```
108
127
 
109
128
  #### Webpack 5
@@ -111,8 +130,13 @@ const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(res => res.array
111
130
  Requires configuring Asset Modules (https://webpack.js.org/guides/asset-modules/)
112
131
 
113
132
  ```ts
114
- const SCRCPY_SERVER_URL = new URL('@yume-chan/scrcpy/bin/scrcpy-server', import.meta.url); // Or your own server binary path
115
- const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(res => res.arrayBuffer());
133
+ const SCRCPY_SERVER_URL = new URL(
134
+ "@yume-chan/scrcpy/bin/scrcpy-server",
135
+ import.meta.url
136
+ ); // Or your own server binary path
137
+ const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then((response) =>
138
+ response.arrayBuffer()
139
+ );
116
140
  ```
117
141
 
118
142
  ### Read the server version
@@ -120,14 +144,14 @@ const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(res => res.array
120
144
  The correct version number is required to launch the server, so `fetch-scrcpy-server` also writes the version number to `bin/version.js`.
121
145
 
122
146
  ```js
123
- import SCRCPY_SERVER_VERSION from '@yume-chan/scrcpy/bin/version.js';
147
+ import SCRCPY_SERVER_VERSION from "@yume-chan/scrcpy/bin/version.js";
124
148
 
125
- console.log(SCRCPY_SERVER_VERSION); // "1.24"
149
+ console.log(SCRCPY_SERVER_VERSION); // "1.25"
126
150
  ```
127
151
 
128
- ## Option versions
152
+ ## Server versions
129
153
 
130
- Scrcpy server options changes over time, and some of them are not backwards compatible. This package provides option types for each version (or range). Using wrong option version usually results in errors.
154
+ Scrcpy protocol change over time, and are usually not backwards compatible. This package supports multiple server versions (or ranges), and uses different option types to choose different behaviors. Using incorrect option version usually results in errors.
131
155
 
132
156
  The latest one may continue to work for future server versions, but there is no guarantee.
133
157
 
@@ -139,47 +163,56 @@ The latest one may continue to work for future server versions, but there is no
139
163
  | 1.22 | `ScrcpyOptions1_22` |
140
164
  | 1.23 | `ScrcpyOptions1_23` |
141
165
  | 1.24 | `ScrcpyOptions1_24` |
166
+ | 1.25 | `ScrcpyOptions1_25` |
142
167
 
143
- When using `AdbScrcpyClient`, there is another `AdbScrcpyOptions` contains `@yume-chan/adb` related logics:
168
+ When using `AdbScrcpyClient`, there are `AdbScrcpyOptions` containing `@yume-chan/adb` specific options:
144
169
 
145
170
  | Version | Type |
146
171
  | --------- | ---------------------- |
147
172
  | 1.16~1.21 | `AdbScrcpyOptions1_16` |
148
- | 1.22~1.24 | `AdbScrcpyOptions1_22` |
173
+ | 1.22~1.25 | `AdbScrcpyOptions1_22` |
149
174
 
150
175
  ## Use with `@yume-chan/adb`
151
176
 
152
- The the server binary needs to be copied to the device and run on it.
177
+ `@yume-chan/adb` is a TypeScript ADB implementation that can run on Web browser. It can be used to bootstrap the server on a device.
153
178
 
154
179
  ### Push server binary
155
180
 
156
- The `Adb#sync()#write()` method can be used to push files to the device. Read more at `@yume-chan/adb`'s documentation (https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb#readme).
181
+ The `AdbSync#write()` method can be used to push files to the device. Read more at `@yume-chan/adb`'s documentation (https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb#readme).
157
182
 
158
183
  This package also provides the `AdbScrcpyClient.pushServer()` static method as a shortcut, plus it will automatically close the `AdbSync` object on completion.
159
184
 
160
- Example using `write()`:
185
+ Example using a `ReadableStream`:
161
186
 
162
187
  ```ts
163
- import { AdbScrcpyClient } from '@yume-chan/scrcpy';
188
+ import { WrapReadableStream } from "@yume-chan/adb";
189
+ import { AdbScrcpyClient } from "@yume-chan/scrcpy";
164
190
 
165
- const stream: WritableStream<Uint8Array> = AdbScrcpyClient.pushServer(adb);
166
- const writer = stream.getWriter();
167
- await writer.write(new Uint8Array(buffer));
168
- await writer.close();
191
+ await AdbScrcpyClient.pushServer(
192
+ adb,
193
+ await fetch(SCRCPY_SERVER_URL).then(
194
+ // `WrapReadableStream` is required because native `ReadableStream` (from `fetch`)
195
+ // doesn't support `pipeTo()` non-native `WritableStream`s
196
+ // (`@yume-chan/adb` is using `web-streams-polyfill`)
197
+ (response) => new WrapReadableStream(response.body)
198
+ )
199
+ );
169
200
  ```
170
201
 
171
- Example using `pipeTo()`:
202
+ Example using an `ArrayBuffer`:
172
203
 
173
204
  ```ts
174
- import { WrapReadableStream } from '@yume-chan/adb';
175
- import { AdbScrcpyClient } from '@yume-chan/scrcpy';
176
-
177
- await fetch(SCRCPY_SERVER_URL)
178
- // `WrapReadableStream` is required because native `ReadableStream` (from `fetch`)
179
- // doesn't support `pipeTo()` non-native `WritableStream`s
180
- // (`@yume-chan/adb` is using `web-streams-polyfill`)
181
- .then(response => new WrapReadableStream(response.body))
182
- .then(stream => stream.pipeTo(AdbScrcpyClient.pushServer(adb)));
205
+ import { AdbScrcpyClient } from "@yume-chan/scrcpy";
206
+
207
+ await AdbScrcpyClient.pushServer(
208
+ adb,
209
+ new ReadableStream({
210
+ start(controller) {
211
+ controller.enqueue(new Uint8Array(buffer));
212
+ controller.end();
213
+ },
214
+ })
215
+ );
183
216
  ```
184
217
 
185
218
  ### Start server on device
@@ -187,22 +220,33 @@ await fetch(SCRCPY_SERVER_URL)
187
220
  To start the server, use the `AdbScrcpyClient.start()` method. It automatically sets up port forwarding, launches the server, and connects to it.
188
221
 
189
222
  ```js
190
- import { AdbScrcpyClient, AdbScrcpyOptions1_22, DEFAULT_SERVER_PATH, ScrcpyOptions1_24 } from '@yume-chan/scrcpy';
191
- import SCRCPY_SERVER_VERSION from '@yume-chan/scrcpy/bin/version.js';
223
+ import {
224
+ AdbScrcpyClient,
225
+ AdbScrcpyOptions1_22,
226
+ DEFAULT_SERVER_PATH,
227
+ ScrcpyOptions1_24,
228
+ } from "@yume-chan/scrcpy";
229
+ import SCRCPY_SERVER_VERSION from "@yume-chan/scrcpy/bin/version.js";
192
230
 
193
231
  const client: AdbScrcpyClient = await AdbScrcpyClient.start(
194
232
  adb,
195
233
  DEFAULT_SERVER_PATH,
196
- SCRCPY_SERVER_VERSION, // Or provide your own version number
197
- new AdbScrcpyOptions1_22(ScrcpyOptions1_24({
198
- // options
199
- }))
234
+ // If server binary was downloaded manually, must provide the correct version
235
+ SCRCPY_SERVER_VERSION,
236
+ new AdbScrcpyOptions1_22(
237
+ ScrcpyOptions1_24({
238
+ // options
239
+ })
240
+ )
200
241
  );
201
242
 
202
243
  const stdout: ReadableStream<string> = client.stdout;
203
- const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> = client.videoStream;
204
- const controlMessageSerializer: ScrcpyControlMessageSerializer | undefined = client.controlMessageSerializer;
205
- const deviceMessageStream: ReadableStream<ScrcpyDeviceMessage> | undefined = client.deviceMessageStream;
244
+ const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> =
245
+ client.videoStream;
246
+ const controlMessageSerializer: ScrcpyControlMessageSerializer | undefined =
247
+ client.controlMessageSerializer;
248
+ const deviceMessageStream: ReadableStream<ScrcpyDeviceMessage> | undefined =
249
+ client.deviceMessageStream;
206
250
 
207
251
  // to stop the server
208
252
  client.close();
@@ -216,8 +260,10 @@ If you push, start and connect to the server yourself, you can still use this pa
216
260
 
217
261
  Requires a `ReadableStream<Uint8Array>` that reads from the video socket, preserving packet boundaries.
218
262
 
263
+ **NOTE:** Because this package uses `web-streams-polyfill` NPM package's Web Streams API implementation, the provided `ReadableStream` must also be from `web-streams-polyfill` (or another polyfill that doesn't check object prototype when piping).
264
+
219
265
  ```ts
220
- import { ScrcpyOptions1_24, ScrcpyVideoStreamPacket } from '@yume-chan/scrcpy';
266
+ import { ScrcpyOptions1_24, ScrcpyVideoStreamPacket } from "@yume-chan/scrcpy";
221
267
 
222
268
  const videoStream: ReadableStream<Uint8Array>; // get the stream yourself
223
269
 
@@ -225,7 +271,8 @@ const options = new ScrcpyOptions1_24({
225
271
  // use the same version and options
226
272
  });
227
273
 
228
- const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> = videoStream.pipeThrough(options.createVideoStreamTransformer());
274
+ const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> =
275
+ videoStream.pipeThrough(options.createVideoStreamTransformer());
229
276
  // Read from `videoPacketStream`
230
277
  ```
231
278
 
@@ -236,15 +283,21 @@ Requires a `WritableStream<Uint8Array>` that writes to the control socket.
236
283
  Control socket is optional if control is not enabled. Video socket and control socket can run completely separately.
237
284
 
238
285
  ```ts
239
- import { ScrcpyControlMessageSerializer, ScrcpyOptions1_24 } from '@yume-chan/scrcpy';
286
+ import {
287
+ ScrcpyControlMessageSerializer,
288
+ ScrcpyOptions1_24,
289
+ } from "@yume-chan/scrcpy";
240
290
 
241
- const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined // get the stream yourself
291
+ const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined; // get the stream yourself
242
292
 
243
293
  const options = new ScrcpyOptions1_24({
244
294
  // use the same version and options
245
295
  });
246
296
 
247
- const controlMessageSerializer = new ScrcpyControlMessageSerializer(controlStream.writable, options);
297
+ const controlMessageSerializer = new ScrcpyControlMessageSerializer(
298
+ controlStream.writable,
299
+ options
300
+ );
248
301
  // Call methods on `controlMessageSerializer`
249
302
  controlMessageSerializer.injectText("Hello World!");
250
303
  ```
@@ -253,17 +306,27 @@ controlMessageSerializer.injectText("Hello World!");
253
306
 
254
307
  Requires a `ReadableStream<Uint8Array>` that reads from the control socket.
255
308
 
309
+ **NOTE:** Because this package uses `web-streams-polyfill` NPM package's Web Streams API implementation, the provided `ReadableStream` must also be from `web-streams-polyfill` (or another polyfill that doesn't check object prototype when piping).
310
+
256
311
  ```ts
257
- import { ScrcpyDeviceMessageDeserializeStream, ScrcpyOptions1_24 } from '@yume-chan/scrcpy';
312
+ import {
313
+ ScrcpyDeviceMessageDeserializeStream,
314
+ ScrcpyOptions1_24,
315
+ } from "@yume-chan/scrcpy";
258
316
 
259
- const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined // get the stream yourself
317
+ const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined; // get the stream yourself
260
318
 
261
- const deviceMessageStream: ReadableStream<ScrcpyDeviceMessage> = controlStream.readable.pipeThrough(new ScrcpyDeviceMessageDeserializeStream());
319
+ const deviceMessageStream: ReadableStream<ScrcpyDeviceMessage> =
320
+ controlStream.readable.pipeThrough(
321
+ new ScrcpyDeviceMessageDeserializeStream()
322
+ );
262
323
  ```
263
324
 
264
- ## Consume the streams
325
+ ## Always read the streams
265
326
 
266
- Any `ReadableStream` (`stdout` when using `AdbScrcpyClient`, `videoPacketStream` and `deviceMessageStream` when control is enabled) must be continuously read (even if you don't care about the data), otherwise the whole connection will stall.
327
+ In Web Streams API, `ReadableStream` will block its upstream when too many chunks are kept not read. If multiple streams are from the same upstream source, block one stream means blocking all of them.
328
+
329
+ For Scrcpy, usually all streams are originated from the same ADB connection (either USB or TCP), so it's important to always read from all streams, even if you don't care about their data.
267
330
 
268
331
  ```ts
269
332
  // when using `AdbScrcpyClient`
@@ -271,9 +334,9 @@ stdout
271
334
  .pipeTo(
272
335
  new WritableStream<string>({
273
336
  write: (line) => {
274
- // Handle the stdout line
337
+ // Handle or ignore the stdout line
275
338
  },
276
- }),
339
+ })
277
340
  )
278
341
  .catch(() => {})
279
342
  .then(() => {
@@ -281,19 +344,23 @@ stdout
281
344
  });
282
345
 
283
346
  videoPacketStream
284
- .pipeTo(new WritableStream<ScrcpyVideoStreamPacket>({
285
- write: (packet) => {
286
- // Handle the video packet
287
- },
288
- }))
347
+ .pipeTo(
348
+ new WritableStream<ScrcpyVideoStreamPacket>({
349
+ write: (packet) => {
350
+ // Handle or ignore the video packet
351
+ },
352
+ })
353
+ )
289
354
  .catch(() => {});
290
355
 
291
356
  deviceMessageStream
292
- .pipeTo(new WritableStream<ScrcpyDeviceMessage>({
293
- write: (message) => {
294
- // Handle the device message
295
- },
296
- }))
357
+ .pipeTo(
358
+ new WritableStream<ScrcpyDeviceMessage>({
359
+ write: (message) => {
360
+ // Handle or ignore the device message
361
+ },
362
+ })
363
+ )
297
364
  .catch(() => {});
298
365
  ```
299
366
 
@@ -303,12 +370,12 @@ The data from `videoPacketStream` has two types: `configuration` and `frame`. So
303
370
 
304
371
  ```ts
305
372
  export interface ScrcpyVideoStreamConfigurationPacket {
306
- type: 'configuration';
373
+ type: "configuration";
307
374
  data: H264Configuration;
308
375
  }
309
376
 
310
377
  export interface ScrcpyVideoStreamFramePacket {
311
- type: 'frame';
378
+ type: "frame";
312
379
  keyframe?: boolean | undefined;
313
380
  pts?: bigint | undefined;
314
381
  data: Uint8Array;
@@ -319,8 +386,8 @@ When `sendFrameMeta: false` is set, `videoPacketStream` only contains `frame` pa
319
386
 
320
387
  Otherwise, both `configuration` and `frame` packets are available.
321
388
 
322
- * `configuration` packets contain the parsed SPS data, and can be used to initialize a video decoder.
323
- * `pts` (and `keyframe` field from server version 1.23) fields in `frame` packets are available to help decode the video.
389
+ - `configuration` packets contain the parsed SPS data, and can be used to initialize a video decoder.
390
+ - `pts` (and `keyframe` field from server version 1.23) fields in `frame` packets are available to help decode the video.
324
391
 
325
392
  ## Decode video stream
326
393
 
package/bin/scrcpy-server CHANGED
Binary file
package/bin/version.d.ts CHANGED
@@ -1 +1 @@
1
- export default '1.24';
1
+ export default '2.0';
package/bin/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.24';
1
+ export default '2.0';