@yume-chan/scrcpy 0.0.18 → 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 (256) hide show
  1. package/CHANGELOG.json +18 -0
  2. package/CHANGELOG.md +10 -1
  3. package/README.md +111 -61
  4. package/bin/scrcpy-server +0 -0
  5. package/bin/version.d.ts +1 -1
  6. package/bin/version.js +1 -1
  7. package/esm/adb/client.d.ts +40 -40
  8. package/esm/adb/client.d.ts.map +1 -1
  9. package/esm/adb/client.js +223 -242
  10. package/esm/adb/client.js.map +1 -1
  11. package/esm/adb/connection.d.ts +48 -46
  12. package/esm/adb/connection.d.ts.map +1 -1
  13. package/esm/adb/connection.js +121 -109
  14. package/esm/adb/connection.js.map +1 -1
  15. package/esm/adb/index.d.ts +3 -3
  16. package/esm/adb/index.js +3 -3
  17. package/esm/adb/options/1_16.d.ts +7 -7
  18. package/esm/adb/options/1_16.d.ts.map +1 -1
  19. package/esm/adb/options/1_16.js +19 -19
  20. package/esm/adb/options/1_16.js.map +1 -1
  21. package/esm/adb/options/1_22.d.ts +7 -7
  22. package/esm/adb/options/1_22.d.ts.map +1 -1
  23. package/esm/adb/options/1_22.js +16 -16
  24. package/esm/adb/options/1_22.js.map +1 -1
  25. package/esm/adb/options/1_26.d.ts +9 -0
  26. package/esm/adb/options/1_26.d.ts.map +1 -0
  27. package/esm/adb/options/1_26.js +11 -0
  28. package/esm/adb/options/1_26.js.map +1 -0
  29. package/esm/adb/options/2_0.d.ts +8 -0
  30. package/esm/adb/options/2_0.d.ts.map +1 -0
  31. package/esm/adb/options/2_0.js +13 -0
  32. package/esm/adb/options/2_0.js.map +1 -0
  33. package/esm/adb/options/index.d.ts +3 -3
  34. package/esm/adb/options/index.js +3 -3
  35. package/esm/adb/options/types.d.ts +23 -23
  36. package/esm/adb/options/types.d.ts.map +1 -1
  37. package/esm/adb/options/types.js +36 -36
  38. package/esm/codec/av1.d.ts +33 -0
  39. package/esm/codec/av1.d.ts.map +1 -0
  40. package/esm/codec/av1.js +35 -0
  41. package/esm/codec/av1.js.map +1 -0
  42. package/esm/codec/h264.d.ts +98 -0
  43. package/esm/codec/h264.d.ts.map +1 -0
  44. package/esm/codec/h264.js +477 -0
  45. package/esm/codec/h264.js.map +1 -0
  46. package/esm/codec/h265.d.ts +36 -0
  47. package/esm/codec/h265.d.ts.map +1 -0
  48. package/esm/codec/h265.js +38 -0
  49. package/esm/codec/h265.js.map +1 -0
  50. package/esm/codec/index.d.ts +4 -0
  51. package/esm/codec/index.d.ts.map +1 -0
  52. package/esm/codec/index.js +4 -0
  53. package/esm/codec/index.js.map +1 -0
  54. package/esm/codec.d.ts +33 -33
  55. package/esm/codec.js +36 -36
  56. package/esm/control/back-or-screen-on.d.ts +2 -2
  57. package/esm/control/back-or-screen-on.d.ts.map +1 -1
  58. package/esm/control/back-or-screen-on.js +1 -1
  59. package/esm/control/basic.d.ts +5 -0
  60. package/esm/control/basic.d.ts.map +1 -0
  61. package/esm/control/basic.js +3 -0
  62. package/esm/control/basic.js.map +1 -0
  63. package/esm/control/hover-helper.d.ts +17 -17
  64. package/esm/control/hover-helper.d.ts.map +1 -1
  65. package/esm/control/hover-helper.js +43 -43
  66. package/esm/control/hover-helper.js.map +1 -1
  67. package/esm/control/index.d.ts +11 -11
  68. package/esm/control/index.js +11 -11
  69. package/esm/control/inject-keycode.d.ts +194 -60
  70. package/esm/control/inject-keycode.d.ts.map +1 -1
  71. package/esm/control/inject-keycode.js +199 -61
  72. package/esm/control/inject-keycode.js.map +1 -1
  73. package/esm/control/inject-scroll.d.ts +2 -2
  74. package/esm/control/inject-scroll.d.ts.map +1 -1
  75. package/esm/control/inject-scroll.js +1 -1
  76. package/esm/control/inject-text.d.ts +8 -8
  77. package/esm/control/inject-text.d.ts.map +1 -1
  78. package/esm/control/inject-text.js +6 -6
  79. package/esm/control/inject-text.js.map +1 -1
  80. package/esm/control/inject-touch.d.ts +37 -37
  81. package/esm/control/inject-touch.d.ts.map +1 -1
  82. package/esm/control/inject-touch.js +62 -62
  83. package/esm/control/rotate-device.d.ts +6 -6
  84. package/esm/control/rotate-device.d.ts.map +1 -1
  85. package/esm/control/rotate-device.js +3 -4
  86. package/esm/control/rotate-device.js.map +1 -1
  87. package/esm/control/serializer.d.ts +35 -33
  88. package/esm/control/serializer.d.ts.map +1 -1
  89. package/esm/control/serializer.js +82 -78
  90. package/esm/control/serializer.js.map +1 -1
  91. package/esm/control/set-clipboard.d.ts +2 -2
  92. package/esm/control/set-clipboard.d.ts.map +1 -1
  93. package/esm/control/set-clipboard.js +1 -1
  94. package/esm/control/set-screen-power-mode.d.ts +11 -11
  95. package/esm/control/set-screen-power-mode.d.ts.map +1 -1
  96. package/esm/control/set-screen-power-mode.js +11 -11
  97. package/esm/control/set-screen-power-mode.js.map +1 -1
  98. package/esm/control/simple.d.ts +5 -0
  99. package/esm/control/simple.d.ts.map +1 -0
  100. package/esm/control/simple.js +3 -0
  101. package/esm/control/simple.js.map +1 -0
  102. package/esm/control/type.d.ts +14 -14
  103. package/esm/control/type.js +18 -18
  104. package/esm/decoder.d.ts +2 -0
  105. package/esm/decoder.d.ts.map +1 -0
  106. package/esm/decoder.js +2 -0
  107. package/esm/decoder.js.map +1 -0
  108. package/esm/device-message/ack-clipboard.d.ts +8 -8
  109. package/esm/device-message/ack-clipboard.d.ts.map +1 -1
  110. package/esm/device-message/ack-clipboard.js +5 -5
  111. package/esm/device-message/clipboard.d.ts +9 -9
  112. package/esm/device-message/clipboard.d.ts.map +1 -1
  113. package/esm/device-message/clipboard.js +6 -6
  114. package/esm/device-message/index.d.ts +4 -4
  115. package/esm/device-message/index.js +4 -4
  116. package/esm/device-message/stream.d.ts +7 -7
  117. package/esm/device-message/stream.js +19 -19
  118. package/esm/device-message/type.d.ts +4 -4
  119. package/esm/device-message/type.js +6 -6
  120. package/esm/index.d.ts +5 -5
  121. package/esm/index.js +5 -5
  122. package/esm/options/1.17.d.ts +3 -0
  123. package/esm/options/1.17.d.ts.map +1 -0
  124. package/esm/options/1.17.js +2 -0
  125. package/esm/options/1.17.js.map +1 -0
  126. package/esm/options/1_16/codec-options.d.ts +20 -19
  127. package/esm/options/1_16/codec-options.d.ts.map +1 -1
  128. package/esm/options/1_16/codec-options.js +25 -25
  129. package/esm/options/1_16/codec-options.js.map +1 -1
  130. package/esm/options/1_16/float-to-uint16.d.ts +5 -0
  131. package/esm/options/1_16/float-to-uint16.d.ts.map +1 -0
  132. package/esm/options/1_16/float-to-uint16.js +27 -0
  133. package/esm/options/1_16/float-to-uint16.js.map +1 -0
  134. package/esm/options/1_16/h264-configuration.d.ts +48 -48
  135. package/esm/options/1_16/h264-configuration.js +413 -413
  136. package/esm/options/1_16/index.d.ts +4 -4
  137. package/esm/options/1_16/index.js +4 -4
  138. package/esm/options/1_16/init.d.ts +66 -0
  139. package/esm/options/1_16/init.d.ts.map +1 -0
  140. package/esm/options/1_16/init.js +16 -0
  141. package/esm/options/1_16/init.js.map +1 -0
  142. package/esm/options/1_16/message.d.ts +32 -0
  143. package/esm/options/1_16/message.d.ts.map +1 -0
  144. package/esm/options/1_16/message.js +37 -0
  145. package/esm/options/1_16/message.js.map +1 -0
  146. package/esm/options/1_16/options.d.ts +102 -93
  147. package/esm/options/1_16/options.d.ts.map +1 -1
  148. package/esm/options/1_16/options.js +189 -189
  149. package/esm/options/1_16/options.js.map +1 -1
  150. package/esm/options/1_16/scroll.d.ts +27 -26
  151. package/esm/options/1_16/scroll.d.ts.map +1 -1
  152. package/esm/options/1_16/scroll.js +55 -55
  153. package/esm/options/1_16/scroll.js.map +1 -1
  154. package/esm/options/1_17.d.ts +32 -0
  155. package/esm/options/1_17.d.ts.map +1 -0
  156. package/esm/options/1_17.js +36 -0
  157. package/esm/options/1_17.js.map +1 -0
  158. package/esm/options/1_18.d.ts +21 -19
  159. package/esm/options/1_18.d.ts.map +1 -1
  160. package/esm/options/1_18.js +45 -45
  161. package/esm/options/1_18.js.map +1 -1
  162. package/esm/options/1_21.d.ts +22 -20
  163. package/esm/options/1_21.d.ts.map +1 -1
  164. package/esm/options/1_21.js +36 -36
  165. package/esm/options/1_21.js.map +1 -1
  166. package/esm/options/1_22/index.d.ts +2 -2
  167. package/esm/options/1_22/index.js +2 -2
  168. package/esm/options/1_22/init.d.ts +17 -0
  169. package/esm/options/1_22/init.d.ts.map +1 -0
  170. package/esm/options/1_22/init.js +2 -0
  171. package/esm/options/1_22/init.js.map +1 -0
  172. package/esm/options/1_22/options.d.ts +29 -28
  173. package/esm/options/1_22/options.d.ts.map +1 -1
  174. package/esm/options/1_22/options.js +25 -25
  175. package/esm/options/1_22/options.js.map +1 -1
  176. package/esm/options/1_22/scroll.d.ts +16 -16
  177. package/esm/options/1_22/scroll.d.ts.map +1 -1
  178. package/esm/options/1_22/scroll.js +14 -14
  179. package/esm/options/1_23.d.ts +12 -11
  180. package/esm/options/1_23.d.ts.map +1 -1
  181. package/esm/options/1_23.js +34 -34
  182. package/esm/options/1_23.js.map +1 -1
  183. package/esm/options/1_24.d.ts +9 -8
  184. package/esm/options/1_24.d.ts.map +1 -1
  185. package/esm/options/1_24.js +12 -12
  186. package/esm/options/1_24.js.map +1 -1
  187. package/esm/options/1_25/index.d.ts +2 -2
  188. package/esm/options/1_25/index.js +2 -2
  189. package/esm/options/1_25/options.d.ts +6 -5
  190. package/esm/options/1_25/options.d.ts.map +1 -1
  191. package/esm/options/1_25/options.js +7 -7
  192. package/esm/options/1_25/options.js.map +1 -1
  193. package/esm/options/1_25/scroll.d.ts +19 -18
  194. package/esm/options/1_25/scroll.d.ts.map +1 -1
  195. package/esm/options/1_25/scroll.js +32 -32
  196. package/esm/options/1_25/scroll.js.map +1 -1
  197. package/esm/options/1_26.d.ts +57 -0
  198. package/esm/options/1_26.d.ts.map +1 -0
  199. package/esm/options/1_26.js +67 -0
  200. package/esm/options/1_26.js.map +1 -0
  201. package/esm/options/2.d.ts +57 -0
  202. package/esm/options/2.d.ts.map +1 -0
  203. package/esm/options/2.js +67 -0
  204. package/esm/options/2.js.map +1 -0
  205. package/esm/options/2_0.d.ts +87 -0
  206. package/esm/options/2_0.d.ts.map +1 -0
  207. package/esm/options/2_0.js +175 -0
  208. package/esm/options/2_0.js.map +1 -0
  209. package/esm/options/codec.d.ts +52 -0
  210. package/esm/options/codec.d.ts.map +1 -0
  211. package/esm/options/codec.js +26 -0
  212. package/esm/options/codec.js.map +1 -0
  213. package/esm/options/index.d.ts +8 -8
  214. package/esm/options/index.js +8 -8
  215. package/esm/options/latest.d.ts +12 -0
  216. package/esm/options/latest.d.ts.map +1 -0
  217. package/esm/options/latest.js +8 -0
  218. package/esm/options/latest.js.map +1 -0
  219. package/esm/options/types.d.ts +46 -46
  220. package/esm/options/types.d.ts.map +1 -1
  221. package/esm/options/types.js +17 -17
  222. package/package.json +11 -10
  223. package/src/adb/client.ts +72 -88
  224. package/src/adb/connection.ts +42 -25
  225. package/src/adb/index.ts +3 -3
  226. package/src/adb/options/1_16.ts +6 -4
  227. package/src/adb/options/1_22.ts +3 -3
  228. package/src/adb/options/index.ts +3 -3
  229. package/src/adb/options/types.ts +10 -10
  230. package/src/control/back-or-screen-on.ts +1 -1
  231. package/src/control/hover-helper.ts +2 -4
  232. package/src/control/inject-keycode.ts +193 -48
  233. package/src/control/inject-scroll.ts +1 -1
  234. package/src/control/inject-text.ts +7 -8
  235. package/src/control/inject-touch.ts +1 -1
  236. package/src/control/rotate-device.ts +7 -6
  237. package/src/control/serializer.ts +29 -26
  238. package/src/control/set-clipboard.ts +1 -1
  239. package/src/control/set-screen-power-mode.ts +7 -8
  240. package/src/device-message/ack-clipboard.ts +1 -1
  241. package/src/device-message/clipboard.ts +1 -1
  242. package/src/index.ts +5 -5
  243. package/src/options/1_16/codec-options.ts +4 -6
  244. package/src/options/1_16/options.ts +17 -12
  245. package/src/options/1_16/scroll.ts +2 -4
  246. package/src/options/1_18.ts +6 -6
  247. package/src/options/1_21.ts +5 -6
  248. package/src/options/1_22/options.ts +3 -2
  249. package/src/options/1_22/scroll.ts +1 -1
  250. package/src/options/1_23.ts +3 -5
  251. package/src/options/1_24.ts +5 -3
  252. package/src/options/1_25/options.ts +3 -2
  253. package/src/options/1_25/scroll.ts +4 -7
  254. package/src/options/index.ts +3 -3
  255. package/src/options/types.ts +8 -8
  256. package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.json CHANGED
@@ -1,6 +1,24 @@
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
+ },
4
22
  {
5
23
  "version": "0.0.18",
6
24
  "tag": "@yume-chan/scrcpy_v0.0.18",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Change Log - @yume-chan/scrcpy
2
2
 
3
- This log was last generated on Wed, 25 Jan 2023 21:33:49 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`
4
13
 
5
14
  ## 0.0.18
6
15
  Wed, 25 Jan 2023 21:33:49 GMT
package/README.md CHANGED
@@ -84,27 +84,34 @@ To name a few:
84
84
  #### Node.js CommonJS
85
85
 
86
86
  ```ts
87
- const fs = require('fs');
88
- 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
89
89
  const buffer: Buffer = fs.readFileSync(path);
90
90
  ```
91
91
 
92
92
  #### Node.js ES module
93
93
 
94
94
  ```ts
95
- import fs from 'node:fs/promises';
96
- import { createRequire } from 'node:module';
95
+ import fs from "node:fs/promises";
96
+ import { createRequire } from "node:module";
97
97
 
98
- 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
99
101
  const buffer: Buffer = await fs.readFile(path);
100
102
  ```
101
103
 
102
104
  Currently, ES Module doesn't have a `resolve` function like `require.resolve` in CommonJS, so `createRequire` is used to create a CommonJS resolver.
103
105
 
104
- `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`:
105
107
 
106
108
  ```ts
107
- 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);
108
115
  ```
109
116
 
110
117
  #### Webpack 4
@@ -112,8 +119,10 @@ const path: string = import.meta.resolve('@yume-chan/scrcpy/bin/scrcpy-server');
112
119
  Requires installing and configuring file-loader (https://v4.webpack.js.org/loaders/file-loader/)
113
120
 
114
121
  ```ts
115
- import SCRCPY_SERVER_URL from '@yume-chan/scrcpy/bin/scrcpy-server'; // Or your own server binary path
116
- 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
+ );
117
126
  ```
118
127
 
119
128
  #### Webpack 5
@@ -121,8 +130,13 @@ const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(res => res.array
121
130
  Requires configuring Asset Modules (https://webpack.js.org/guides/asset-modules/)
122
131
 
123
132
  ```ts
124
- const SCRCPY_SERVER_URL = new URL('@yume-chan/scrcpy/bin/scrcpy-server', import.meta.url); // Or your own server binary path
125
- 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
+ );
126
140
  ```
127
141
 
128
142
  ### Read the server version
@@ -130,7 +144,7 @@ const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(res => res.array
130
144
  The correct version number is required to launch the server, so `fetch-scrcpy-server` also writes the version number to `bin/version.js`.
131
145
 
132
146
  ```js
133
- import SCRCPY_SERVER_VERSION from '@yume-chan/scrcpy/bin/version.js';
147
+ import SCRCPY_SERVER_VERSION from "@yume-chan/scrcpy/bin/version.js";
134
148
 
135
149
  console.log(SCRCPY_SERVER_VERSION); // "1.25"
136
150
  ```
@@ -164,33 +178,41 @@ When using `AdbScrcpyClient`, there are `AdbScrcpyOptions` containing `@yume-cha
164
178
 
165
179
  ### Push server binary
166
180
 
167
- 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).
168
182
 
169
183
  This package also provides the `AdbScrcpyClient.pushServer()` static method as a shortcut, plus it will automatically close the `AdbSync` object on completion.
170
184
 
171
- Example using `write()`:
185
+ Example using a `ReadableStream`:
172
186
 
173
187
  ```ts
174
- import { AdbScrcpyClient } from '@yume-chan/scrcpy';
188
+ import { WrapReadableStream } from "@yume-chan/adb";
189
+ import { AdbScrcpyClient } from "@yume-chan/scrcpy";
175
190
 
176
- const stream: WritableStream<Uint8Array> = AdbScrcpyClient.pushServer(adb);
177
- const writer = stream.getWriter();
178
- await writer.write(new Uint8Array(buffer));
179
- 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
+ );
180
200
  ```
181
201
 
182
- Example using `pipeTo()`:
202
+ Example using an `ArrayBuffer`:
183
203
 
184
204
  ```ts
185
- import { WrapReadableStream } from '@yume-chan/adb';
186
- import { AdbScrcpyClient } from '@yume-chan/scrcpy';
187
-
188
- await fetch(SCRCPY_SERVER_URL)
189
- // `WrapReadableStream` is required because native `ReadableStream` (from `fetch`)
190
- // doesn't support `pipeTo()` non-native `WritableStream`s
191
- // (`@yume-chan/adb` is using `web-streams-polyfill`)
192
- .then(response => new WrapReadableStream(response.body))
193
- .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
+ );
194
216
  ```
195
217
 
196
218
  ### Start server on device
@@ -198,22 +220,33 @@ await fetch(SCRCPY_SERVER_URL)
198
220
  To start the server, use the `AdbScrcpyClient.start()` method. It automatically sets up port forwarding, launches the server, and connects to it.
199
221
 
200
222
  ```js
201
- import { AdbScrcpyClient, AdbScrcpyOptions1_22, DEFAULT_SERVER_PATH, ScrcpyOptions1_24 } from '@yume-chan/scrcpy';
202
- 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";
203
230
 
204
231
  const client: AdbScrcpyClient = await AdbScrcpyClient.start(
205
232
  adb,
206
233
  DEFAULT_SERVER_PATH,
207
- SCRCPY_SERVER_VERSION, // If server binary was downloaded manually, must provide the correct version
208
- new AdbScrcpyOptions1_22(ScrcpyOptions1_24({
209
- // options
210
- }))
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
+ )
211
241
  );
212
242
 
213
243
  const stdout: ReadableStream<string> = client.stdout;
214
- const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> = client.videoStream;
215
- const controlMessageSerializer: ScrcpyControlMessageSerializer | undefined = client.controlMessageSerializer;
216
- 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;
217
250
 
218
251
  // to stop the server
219
252
  client.close();
@@ -230,7 +263,7 @@ Requires a `ReadableStream<Uint8Array>` that reads from the video socket, preser
230
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).
231
264
 
232
265
  ```ts
233
- import { ScrcpyOptions1_24, ScrcpyVideoStreamPacket } from '@yume-chan/scrcpy';
266
+ import { ScrcpyOptions1_24, ScrcpyVideoStreamPacket } from "@yume-chan/scrcpy";
234
267
 
235
268
  const videoStream: ReadableStream<Uint8Array>; // get the stream yourself
236
269
 
@@ -238,7 +271,8 @@ const options = new ScrcpyOptions1_24({
238
271
  // use the same version and options
239
272
  });
240
273
 
241
- const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> = videoStream.pipeThrough(options.createVideoStreamTransformer());
274
+ const videoPacketStream: ReadableStream<ScrcpyVideoStreamPacket> =
275
+ videoStream.pipeThrough(options.createVideoStreamTransformer());
242
276
  // Read from `videoPacketStream`
243
277
  ```
244
278
 
@@ -249,15 +283,21 @@ Requires a `WritableStream<Uint8Array>` that writes to the control socket.
249
283
  Control socket is optional if control is not enabled. Video socket and control socket can run completely separately.
250
284
 
251
285
  ```ts
252
- import { ScrcpyControlMessageSerializer, ScrcpyOptions1_24 } from '@yume-chan/scrcpy';
286
+ import {
287
+ ScrcpyControlMessageSerializer,
288
+ ScrcpyOptions1_24,
289
+ } from "@yume-chan/scrcpy";
253
290
 
254
- const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined // get the stream yourself
291
+ const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined; // get the stream yourself
255
292
 
256
293
  const options = new ScrcpyOptions1_24({
257
294
  // use the same version and options
258
295
  });
259
296
 
260
- const controlMessageSerializer = new ScrcpyControlMessageSerializer(controlStream.writable, options);
297
+ const controlMessageSerializer = new ScrcpyControlMessageSerializer(
298
+ controlStream.writable,
299
+ options
300
+ );
261
301
  // Call methods on `controlMessageSerializer`
262
302
  controlMessageSerializer.injectText("Hello World!");
263
303
  ```
@@ -269,11 +309,17 @@ Requires a `ReadableStream<Uint8Array>` that reads from the control socket.
269
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).
270
310
 
271
311
  ```ts
272
- import { ScrcpyDeviceMessageDeserializeStream, ScrcpyOptions1_24 } from '@yume-chan/scrcpy';
312
+ import {
313
+ ScrcpyDeviceMessageDeserializeStream,
314
+ ScrcpyOptions1_24,
315
+ } from "@yume-chan/scrcpy";
273
316
 
274
- const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined // get the stream yourself
317
+ const controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined; // get the stream yourself
275
318
 
276
- const deviceMessageStream: ReadableStream<ScrcpyDeviceMessage> = controlStream.readable.pipeThrough(new ScrcpyDeviceMessageDeserializeStream());
319
+ const deviceMessageStream: ReadableStream<ScrcpyDeviceMessage> =
320
+ controlStream.readable.pipeThrough(
321
+ new ScrcpyDeviceMessageDeserializeStream()
322
+ );
277
323
  ```
278
324
 
279
325
  ## Always read the streams
@@ -290,7 +336,7 @@ stdout
290
336
  write: (line) => {
291
337
  // Handle or ignore the stdout line
292
338
  },
293
- }),
339
+ })
294
340
  )
295
341
  .catch(() => {})
296
342
  .then(() => {
@@ -298,19 +344,23 @@ stdout
298
344
  });
299
345
 
300
346
  videoPacketStream
301
- .pipeTo(new WritableStream<ScrcpyVideoStreamPacket>({
302
- write: (packet) => {
303
- // Handle or ignore the video packet
304
- },
305
- }))
347
+ .pipeTo(
348
+ new WritableStream<ScrcpyVideoStreamPacket>({
349
+ write: (packet) => {
350
+ // Handle or ignore the video packet
351
+ },
352
+ })
353
+ )
306
354
  .catch(() => {});
307
355
 
308
356
  deviceMessageStream
309
- .pipeTo(new WritableStream<ScrcpyDeviceMessage>({
310
- write: (message) => {
311
- // Handle or ignore the device message
312
- },
313
- }))
357
+ .pipeTo(
358
+ new WritableStream<ScrcpyDeviceMessage>({
359
+ write: (message) => {
360
+ // Handle or ignore the device message
361
+ },
362
+ })
363
+ )
314
364
  .catch(() => {});
315
365
  ```
316
366
 
@@ -320,12 +370,12 @@ The data from `videoPacketStream` has two types: `configuration` and `frame`. So
320
370
 
321
371
  ```ts
322
372
  export interface ScrcpyVideoStreamConfigurationPacket {
323
- type: 'configuration';
373
+ type: "configuration";
324
374
  data: H264Configuration;
325
375
  }
326
376
 
327
377
  export interface ScrcpyVideoStreamFramePacket {
328
- type: 'frame';
378
+ type: "frame";
329
379
  keyframe?: boolean | undefined;
330
380
  pts?: bigint | undefined;
331
381
  data: Uint8Array;
@@ -336,8 +386,8 @@ When `sendFrameMeta: false` is set, `videoPacketStream` only contains `frame` pa
336
386
 
337
387
  Otherwise, both `configuration` and `frame` packets are available.
338
388
 
339
- * `configuration` packets contain the parsed SPS data, and can be used to initialize a video decoder.
340
- * `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.
341
391
 
342
392
  ## Decode video stream
343
393
 
package/bin/scrcpy-server CHANGED
Binary file
package/bin/version.d.ts CHANGED
@@ -1 +1 @@
1
- export default '1.25';
1
+ export default '2.0';
package/bin/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.25';
1
+ export default '2.0';
@@ -1,41 +1,41 @@
1
- import { type Adb, type AdbSubprocessProtocol } from "@yume-chan/adb";
2
- import { ReadableStream, WrapWritableStream, type ReadableWritablePair } from "@yume-chan/stream-extra";
3
- import { ScrcpyControlMessageSerializer } from "../control/index.js";
4
- import { type ScrcpyDeviceMessage } from "../device-message/index.js";
5
- import { type ScrcpyVideoStreamPacket } from "../options/index.js";
6
- import { type AdbScrcpyOptions } from "./options/index.js";
7
- export declare class ScrcpyExitedError extends Error {
8
- output: string[];
9
- constructor(output: string[]);
10
- }
11
- export declare class AdbScrcpyClient {
12
- static pushServer(adb: Adb, path?: string): WrapWritableStream<Uint8Array>;
13
- static start(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<object>): Promise<AdbScrcpyClient>;
14
- /**
15
- * This method will modify the given `options`,
16
- * so don't reuse it elsewhere.
17
- */
18
- static getEncoders(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<object>): Promise<string[]>;
19
- /**
20
- * This method will modify the given `options`,
21
- * so don't reuse it elsewhere.
22
- */
23
- static getDisplays(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<object>): Promise<number[]>;
24
- private process;
25
- private _stdout;
26
- get stdout(): ReadableStream<string>;
27
- get exit(): Promise<number>;
28
- private _screenWidth;
29
- get screenWidth(): number | undefined;
30
- private _screenHeight;
31
- get screenHeight(): number | undefined;
32
- private _videoStream;
33
- get videoStream(): ReadableStream<ScrcpyVideoStreamPacket>;
34
- private _controlMessageSerializer;
35
- get controlMessageSerializer(): ScrcpyControlMessageSerializer | undefined;
36
- private _deviceMessageStream;
37
- get deviceMessageStream(): ReadableStream<ScrcpyDeviceMessage> | undefined;
38
- constructor(options: AdbScrcpyOptions<object>, process: AdbSubprocessProtocol, stdout: ReadableStream<string>, videoStream: ReadableStream<Uint8Array>, controlStream: ReadableWritablePair<Uint8Array, Uint8Array> | undefined);
39
- close(): Promise<void>;
40
- }
1
+ import type { Adb, AdbSubprocessProtocol } from "@yume-chan/adb";
2
+ import type { Consumable, ReadableStream, ReadableWritablePair } from "@yume-chan/stream-extra";
3
+ import { ScrcpyControlMessageSerializer } from "../control/index.js";
4
+ import type { ScrcpyDeviceMessage } from "../device-message/index.js";
5
+ import type { ScrcpyOptionsInit1_16, ScrcpyVideoStreamPacket } from "../options/index.js";
6
+ import type { AdbScrcpyOptions } from "./options/index.js";
7
+ export declare class ScrcpyExitedError extends Error {
8
+ output: string[];
9
+ constructor(output: string[]);
10
+ }
11
+ export declare class AdbScrcpyClient {
12
+ static pushServer(adb: Adb, file: ReadableStream<Consumable<Uint8Array>>, filename?: string): Promise<void>;
13
+ static start(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<ScrcpyOptionsInit1_16>): Promise<AdbScrcpyClient>;
14
+ /**
15
+ * This method will modify the given `options`,
16
+ * so don't reuse it elsewhere.
17
+ */
18
+ static getEncoders(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<ScrcpyOptionsInit1_16>): Promise<string[]>;
19
+ /**
20
+ * This method will modify the given `options`,
21
+ * so don't reuse it elsewhere.
22
+ */
23
+ static getDisplays(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<ScrcpyOptionsInit1_16>): Promise<number[]>;
24
+ private process;
25
+ private _stdout;
26
+ get stdout(): ReadableStream<string>;
27
+ get exit(): Promise<number>;
28
+ private _screenWidth;
29
+ get screenWidth(): number | undefined;
30
+ private _screenHeight;
31
+ get screenHeight(): number | undefined;
32
+ private _videoStream;
33
+ get videoStream(): ReadableStream<ScrcpyVideoStreamPacket>;
34
+ private _controlMessageSerializer;
35
+ get controlMessageSerializer(): ScrcpyControlMessageSerializer | undefined;
36
+ private _deviceMessageStream;
37
+ get deviceMessageStream(): ReadableStream<ScrcpyDeviceMessage> | undefined;
38
+ constructor(options: AdbScrcpyOptions<ScrcpyOptionsInit1_16>, process: AdbSubprocessProtocol, stdout: ReadableStream<string>, videoStream: ReadableStream<Uint8Array>, controlStream: ReadableWritablePair<Uint8Array, Consumable<Uint8Array>> | undefined);
39
+ close(): Promise<void>;
40
+ }
41
41
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/adb/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,GAAG,EACR,KAAK,qBAAqB,EAE7B,MAAM,gBAAg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