@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
@@ -7,58 +7,203 @@ export enum AndroidKeyEventAction {
7
7
  Up = 1,
8
8
  }
9
9
 
10
- // https://github.com/Genymobile/scrcpy/blob/cabb102a04153f9c237b18257d3269a058558c63/app/src/android/keycodes.h#L26
10
+ // https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/KeyEvent.java;l=993;drc=95c1165bb895dd844e1793460710f7163dd330a3
11
+ export enum AndroidKeyEventMeta {
12
+ AltOn = 0x02,
13
+ AltLeftOn = 0x10,
14
+ AltRightOn = 0x20,
15
+ ShiftOn = 0x01,
16
+ ShiftLeftOn = 0x40,
17
+ ShiftRightOn = 0x80,
18
+ CtrlOn = 0x1000,
19
+ CtrlLeftOn = 0x2000,
20
+ CtrlRightOn = 0x4000,
21
+ MetaOn = 0x10000,
22
+ MetaLeftOn = 0x20000,
23
+ MetaRightOn = 0x40000,
24
+ CapsLockOn = 0x100000,
25
+ NumLockOn = 0x200000,
26
+ ScrollLockOn = 0x400000,
27
+ }
28
+
29
+ // https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/KeyEvent.java;l=97;drc=95c1165bb895dd844e1793460710f7163dd330a3
30
+ // Most names follow Web API `KeyboardEvent.code`,
31
+ // Android-only (not exist in HID keyboard standard) keys are prefixed by `Android`.
11
32
  export enum AndroidKeyCode {
12
- Home = 3,
13
- Back = 4,
14
-
15
- DPadUp = 19,
16
- DPadDown,
17
- DPadLeft,
18
- DPadRight,
19
-
20
- VolumeUp = 24,
21
- VolumeDown,
22
-
23
- A = 29,
24
- B,
25
- C,
26
- D,
27
- E,
28
- F,
29
- G,
30
- H,
31
- I,
32
- J,
33
- K,
34
- L,
35
- M,
36
- N,
37
- O,
38
- P,
39
- Q,
40
- R,
41
- S,
42
- T,
43
- U,
44
- V,
45
- W,
46
- X,
47
- Y,
48
- Z,
49
-
50
- Tab = 61,
33
+ AndroidHome = 3,
34
+ AndroidBack = 4,
35
+ AndroidCall,
36
+ AndroidEndCall,
37
+
38
+ Digit0,
39
+ Digit1,
40
+ Digit2,
41
+ Digit3,
42
+ Digit4,
43
+ Digit5,
44
+ Digit6,
45
+ Digit7,
46
+ Digit8,
47
+ Digit9,
48
+ /**
49
+ * '*' key.
50
+ */
51
+ Star, // Name not verified
52
+ /**
53
+ * '#' key.
54
+ */
55
+ Pound, // Name not verified
56
+
57
+ /**
58
+ * Directional Pad Up key.
59
+ */
60
+ ArrowUp,
61
+ /**
62
+ * Directional Pad Down key.
63
+ */
64
+ ArrowDown,
65
+ /**
66
+ * Directional Pad Left key.
67
+ */
68
+ ArrowLeft,
69
+ /**
70
+ * Directional Pad Right key.
71
+ */
72
+ ArrowRight,
73
+ /**
74
+ * Directional Pad Center key.
75
+ */
76
+ AndroidDPadCenter,
77
+
78
+ VolumeUp, // Name not verified
79
+ VolumeDown, // Name not verified
80
+ Power, // Name not verified
81
+ AndroidCamera,
82
+ Clear, // Name not verified
83
+
84
+ KeyA,
85
+ KeyB,
86
+ KeyC,
87
+ KeyD,
88
+ KeyE,
89
+ KeyF,
90
+ KeyG,
91
+ KeyH,
92
+ KeyI,
93
+ KeyJ,
94
+ KeyK,
95
+ KeyL,
96
+ KeyM,
97
+ KeyN,
98
+ KeyO,
99
+ KeyP,
100
+ KeyQ,
101
+ KeyR,
102
+ KeyS,
103
+ KeyT,
104
+ KeyU,
105
+ KeyV,
106
+ KeyW,
107
+ KeyX,
108
+ KeyY,
109
+ KeyZ,
110
+ Comma,
111
+ Period,
112
+ AltLeft,
113
+ AltRight,
114
+ ShiftLeft,
115
+ ShiftRight,
116
+ Tab,
51
117
  Space,
52
- Enter = 66,
53
- Delete,
118
+ AndroidSymbol,
119
+ AndroidExplorer,
120
+ AndroidEnvelope,
121
+ Enter,
122
+ Backspace,
123
+ Backquote,
124
+ Minus,
125
+ Equal,
126
+ BracketLeft,
127
+ BracketRight,
128
+ Backslash,
129
+ Semicolon,
130
+ Quote,
131
+ Slash,
132
+ At, // Name not verified
133
+
134
+ AndroidNum,
135
+ AndroidHeadsetHook,
136
+ /**
137
+ * Camera Focus key。
138
+ */
139
+ AndroidFocus,
140
+
141
+ Plus, // Name not verified
142
+ ContextMenu,
143
+ AndroidNotification,
144
+ AndroidSearch,
145
+
146
+ PageUp = 92,
147
+ PageDown,
148
+
54
149
  Escape = 111,
55
- ForwardDelete,
150
+ Delete,
151
+ ControlLeft,
152
+ ControlRight,
153
+ CapsLock,
154
+ ScrollLock,
155
+ MetaLeft,
156
+ MetaRight,
157
+ AndroidFunction,
158
+ PrintScreen,
159
+ Pause,
160
+
161
+ Home,
162
+ End,
163
+ Insert,
164
+ AndroidForward,
165
+
166
+ F1 = 131,
167
+ F2,
168
+ F3,
169
+ F4,
170
+ F5,
171
+ F6,
172
+ F7,
173
+ F8,
174
+ F9,
175
+ F10,
176
+ F11,
177
+ F12,
178
+
179
+ NumLock,
180
+ Numpad0,
181
+ Numpad1,
182
+ Numpad2,
183
+ Numpad3,
184
+ Numpad4,
185
+ Numpad5,
186
+ Numpad6,
187
+ Numpad7,
188
+ Numpad8,
189
+ Numpad9,
190
+ NumpadDivide,
191
+ NumpadMultiply,
192
+ NumpadSubtract,
193
+ NumpadAdd,
194
+ NumpadDecimal,
195
+ NumpadComma, // Name not verified
196
+ NumpadEnter,
197
+ NumpadEquals, // Name not verified
198
+ NumpadLeftParen, // Name not verified
199
+ NumpadRightParen, // Name not verified
56
200
 
57
- MoveHome = 122,
58
- MoveEnd = 123,
201
+ VolumeMute = 164, // Name not verified
202
+ AndroidAppSwitch = 187,
59
203
 
60
- VolumeMute = 164,
61
- AppSwitch = 187,
204
+ AndroidCut = 277,
205
+ AndroidCopy,
206
+ AndroidPaste,
62
207
  }
63
208
 
64
209
  export const ScrcpyInjectKeyCodeControlMessage = new Struct()
@@ -69,4 +214,4 @@ export const ScrcpyInjectKeyCodeControlMessage = new Struct()
69
214
  .uint32("metaState");
70
215
 
71
216
  export type ScrcpyInjectKeyCodeControlMessage =
72
- typeof ScrcpyInjectKeyCodeControlMessage["TInit"];
217
+ (typeof ScrcpyInjectKeyCodeControlMessage)["TInit"];
@@ -1,4 +1,4 @@
1
- import { type ScrcpyInjectScrollControlMessage1_25 } from "../options/index.js";
1
+ import type { ScrcpyInjectScrollControlMessage1_25 } from "../options/index.js";
2
2
 
3
3
  export type ScrcpyInjectScrollControlMessage =
4
4
  ScrcpyInjectScrollControlMessage1_25;
@@ -1,12 +1,11 @@
1
- import Struct from '@yume-chan/struct';
1
+ import Struct from "@yume-chan/struct";
2
2
 
3
- import { ScrcpyControlMessageType } from './type.js';
3
+ import { ScrcpyControlMessageType } from "./type.js";
4
4
 
5
- export const ScrcpyInjectTextControlMessage =
6
- new Struct()
7
- .uint8('type', ScrcpyControlMessageType.InjectText as const)
8
- .uint32('length')
9
- .string('text', { lengthField: 'length' });
5
+ export const ScrcpyInjectTextControlMessage = new Struct()
6
+ .uint8("type", ScrcpyControlMessageType.InjectText as const)
7
+ .uint32("length")
8
+ .string("text", { lengthField: "length" });
10
9
 
11
10
  export type ScrcpyInjectTextControlMessage =
12
- typeof ScrcpyInjectTextControlMessage['TInit'];
11
+ (typeof ScrcpyInjectTextControlMessage)["TInit"];
@@ -75,4 +75,4 @@ export const ScrcpyInjectTouchControlMessage = new Struct()
75
75
  .uint32("buttons");
76
76
 
77
77
  export type ScrcpyInjectTouchControlMessage =
78
- typeof ScrcpyInjectTouchControlMessage["TInit"];
78
+ (typeof ScrcpyInjectTouchControlMessage)["TInit"];
@@ -1,10 +1,11 @@
1
- import Struct from '@yume-chan/struct';
1
+ import Struct from "@yume-chan/struct";
2
2
 
3
- import { ScrcpyControlMessageType } from './type.js';
3
+ import { ScrcpyControlMessageType } from "./type.js";
4
4
 
5
- export const ScrcpyRotateDeviceControlMessage =
6
- new Struct()
7
- .uint8('type', ScrcpyControlMessageType.RotateDevice as const)
5
+ export const ScrcpyRotateDeviceControlMessage = new Struct().uint8(
6
+ "type",
7
+ ScrcpyControlMessageType.RotateDevice as const
8
+ );
8
9
 
9
10
  export type ScrcpyRotateDeviceControlMessage =
10
- typeof ScrcpyRotateDeviceControlMessage['TInit'];
11
+ (typeof ScrcpyRotateDeviceControlMessage)["TInit"];
@@ -1,37 +1,36 @@
1
- import {
2
- type WritableStream,
3
- type WritableStreamDefaultWriter,
1
+ import type {
2
+ Consumable,
3
+ WritableStream,
4
+ WritableStreamDefaultWriter,
4
5
  } from "@yume-chan/stream-extra";
6
+ import { ConsumableWritableStream } from "@yume-chan/stream-extra";
5
7
 
6
- import {
7
- type ScrcpyOptions,
8
- type ScrcpyScrollController,
8
+ import type {
9
+ ScrcpyOptions,
10
+ ScrcpyOptionsInit1_16,
11
+ ScrcpyScrollController,
9
12
  } from "../options/index.js";
10
13
 
11
- import {
12
- ScrcpyInjectKeyCodeControlMessage,
13
- type AndroidKeyEventAction,
14
- } from "./inject-keycode.js";
15
- import { type ScrcpyInjectScrollControlMessage } from "./inject-scroll.js";
14
+ import type { AndroidKeyEventAction } from "./inject-keycode.js";
15
+ import { ScrcpyInjectKeyCodeControlMessage } from "./inject-keycode.js";
16
+ import type { ScrcpyInjectScrollControlMessage } from "./inject-scroll.js";
16
17
  import { ScrcpyInjectTextControlMessage } from "./inject-text.js";
17
18
  import { ScrcpyInjectTouchControlMessage } from "./inject-touch.js";
18
19
  import { ScrcpyRotateDeviceControlMessage } from "./rotate-device.js";
19
- import {
20
- ScrcpySetScreenPowerModeControlMessage,
21
- type AndroidScreenPowerMode,
22
- } from "./set-screen-power-mode.js";
20
+ import type { AndroidScreenPowerMode } from "./set-screen-power-mode.js";
21
+ import { ScrcpySetScreenPowerModeControlMessage } from "./set-screen-power-mode.js";
23
22
  import { ScrcpyControlMessageType } from "./type.js";
24
23
 
25
24
  export class ScrcpyControlMessageSerializer {
26
- private options: ScrcpyOptions<object>;
25
+ private options: ScrcpyOptions<ScrcpyOptionsInit1_16>;
27
26
  /** Control message type values for current version of server */
28
27
  private types: ScrcpyControlMessageType[];
29
- private writer: WritableStreamDefaultWriter<Uint8Array>;
28
+ private writer: WritableStreamDefaultWriter<Consumable<Uint8Array>>;
30
29
  private scrollController: ScrcpyScrollController;
31
30
 
32
31
  public constructor(
33
- stream: WritableStream<Uint8Array>,
34
- options: ScrcpyOptions<object>
32
+ stream: WritableStream<Consumable<Uint8Array>>,
33
+ options: ScrcpyOptions<ScrcpyOptionsInit1_16>
35
34
  ) {
36
35
  this.writer = stream.getWriter();
37
36
 
@@ -56,10 +55,14 @@ export class ScrcpyControlMessageSerializer {
56
55
  return message as T;
57
56
  }
58
57
 
58
+ private async write(data: Uint8Array) {
59
+ await ConsumableWritableStream.write(this.writer, data);
60
+ }
61
+
59
62
  public injectKeyCode(
60
63
  message: Omit<ScrcpyInjectKeyCodeControlMessage, "type">
61
64
  ) {
62
- return this.writer.write(
65
+ return this.write(
63
66
  ScrcpyInjectKeyCodeControlMessage.serialize(
64
67
  this.addMessageType(
65
68
  message,
@@ -70,7 +73,7 @@ export class ScrcpyControlMessageSerializer {
70
73
  }
71
74
 
72
75
  public injectText(text: string) {
73
- return this.writer.write(
76
+ return this.write(
74
77
  ScrcpyInjectTextControlMessage.serialize({
75
78
  text,
76
79
  type: this.getActualMessageType(
@@ -84,7 +87,7 @@ export class ScrcpyControlMessageSerializer {
84
87
  * `pressure` is a float value between 0 and 1.
85
88
  */
86
89
  public injectTouch(message: Omit<ScrcpyInjectTouchControlMessage, "type">) {
87
- return this.writer.write(
90
+ return this.write(
88
91
  ScrcpyInjectTouchControlMessage.serialize(
89
92
  this.addMessageType(
90
93
  message,
@@ -108,7 +111,7 @@ export class ScrcpyControlMessageSerializer {
108
111
  return;
109
112
  }
110
113
 
111
- return this.writer.write(data);
114
+ return this.write(data);
112
115
  }
113
116
 
114
117
  public async backOrScreenOn(action: AndroidKeyEventAction) {
@@ -120,12 +123,12 @@ export class ScrcpyControlMessageSerializer {
120
123
  });
121
124
 
122
125
  if (buffer) {
123
- return await this.writer.write(buffer);
126
+ return await this.write(buffer);
124
127
  }
125
128
  }
126
129
 
127
130
  public setScreenPowerMode(mode: AndroidScreenPowerMode) {
128
- return this.writer.write(
131
+ return this.write(
129
132
  ScrcpySetScreenPowerModeControlMessage.serialize({
130
133
  mode,
131
134
  type: this.getActualMessageType(
@@ -136,7 +139,7 @@ export class ScrcpyControlMessageSerializer {
136
139
  }
137
140
 
138
141
  public rotateDevice() {
139
- return this.writer.write(
142
+ return this.write(
140
143
  ScrcpyRotateDeviceControlMessage.serialize({
141
144
  type: this.getActualMessageType(
142
145
  ScrcpyControlMessageType.RotateDevice
@@ -1,4 +1,4 @@
1
- import { type ScrcpySetClipboardControlMessage1_21 } from "../options/index.js";
1
+ import type { ScrcpySetClipboardControlMessage1_21 } from "../options/index.js";
2
2
 
3
3
  export type ScrcpySetClipboardControlMessage =
4
4
  ScrcpySetClipboardControlMessage1_21;
@@ -1,17 +1,16 @@
1
- import Struct, { placeholder } from '@yume-chan/struct';
1
+ import Struct, { placeholder } from "@yume-chan/struct";
2
2
 
3
- import { ScrcpyControlMessageType } from './type.js';
3
+ import { ScrcpyControlMessageType } from "./type.js";
4
4
 
5
5
  // https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/SurfaceControl.java;l=659;drc=20303e05bf73796124ab70a279cf849b61b97905
6
6
  export enum AndroidScreenPowerMode {
7
7
  Off = 0,
8
- Normal = 2
8
+ Normal = 2,
9
9
  }
10
10
 
11
- export const ScrcpySetScreenPowerModeControlMessage =
12
- new Struct()
13
- .uint8('type', ScrcpyControlMessageType.SetScreenPowerMode as const)
14
- .uint8('mode', placeholder<AndroidScreenPowerMode>());
11
+ export const ScrcpySetScreenPowerModeControlMessage = new Struct()
12
+ .uint8("type", ScrcpyControlMessageType.SetScreenPowerMode as const)
13
+ .uint8("mode", placeholder<AndroidScreenPowerMode>());
15
14
 
16
15
  export type ScrcpySetScreenPowerModeControlMessage =
17
- typeof ScrcpySetScreenPowerModeControlMessage['TInit'];
16
+ (typeof ScrcpySetScreenPowerModeControlMessage)["TInit"];
@@ -7,4 +7,4 @@ export const ScrcpyAckClipboardDeviceMessage = new Struct()
7
7
  .extra({ type: ScrcpyDeviceMessageType.AckClipboard as const });
8
8
 
9
9
  export type ScrcpyAckClipboardDeviceMessage =
10
- typeof ScrcpyAckClipboardDeviceMessage["TDeserializeResult"];
10
+ (typeof ScrcpyAckClipboardDeviceMessage)["TDeserializeResult"];
@@ -8,4 +8,4 @@ export const ScrcpyClipboardDeviceMessage = new Struct()
8
8
  .extra({ type: ScrcpyDeviceMessageType.Clipboard as const });
9
9
 
10
10
  export type ScrcpyClipboardDeviceMessage =
11
- typeof ScrcpyClipboardDeviceMessage["TDeserializeResult"];
11
+ (typeof ScrcpyClipboardDeviceMessage)["TDeserializeResult"];
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './adb/index.js';
2
- export * from './codec.js';
3
- export * from './control/index.js';
4
- export * from './device-message/index.js';
5
- export * from './options/index.js';
1
+ export * from "./adb/index.js";
2
+ export * from "./codec.js";
3
+ export * from "./control/index.js";
4
+ export * from "./device-message/index.js";
5
+ export * from "./options/index.js";
@@ -1,8 +1,5 @@
1
- import {
2
- type AndroidCodecLevel,
3
- type AndroidCodecProfile,
4
- } from "../../codec.js";
5
- import { type ScrcpyOptionValue } from "../types.js";
1
+ import type { AndroidCodecLevel, AndroidCodecProfile } from "../../codec.js";
2
+ import type { ScrcpyOptionValue } from "../types.js";
6
3
 
7
4
  /**
8
5
  * If the option you need is not in this type,
@@ -16,6 +13,7 @@ export interface CodecOptionsInit {
16
13
  maxBframes: number;
17
14
  repeatPreviousFrameAfter: number;
18
15
  maxPtsGapToEncoder: number;
16
+ intraRefreshPeriod: number;
19
17
  }
20
18
 
21
19
  function toDashCase(input: string) {
@@ -32,7 +30,7 @@ const CODEC_OPTION_TYPES: Partial<
32
30
  export class CodecOptions implements ScrcpyOptionValue {
33
31
  public value: Partial<CodecOptionsInit>;
34
32
 
35
- public constructor(value: Partial<CodecOptionsInit>) {
33
+ public constructor(value: Partial<CodecOptionsInit> = {}) {
36
34
  this.value = value;
37
35
  }
38
36
 
@@ -4,17 +4,16 @@ import {
4
4
  } from "@yume-chan/stream-extra";
5
5
  import Struct from "@yume-chan/struct";
6
6
 
7
+ import type {
8
+ ScrcpyBackOrScreenOnControlMessage,
9
+ ScrcpySetClipboardControlMessage,
10
+ } from "../../control/index.js";
7
11
  import {
8
12
  AndroidKeyEventAction,
9
13
  ScrcpyControlMessageType,
10
- type ScrcpyBackOrScreenOnControlMessage,
11
- type ScrcpySetClipboardControlMessage,
12
14
  } from "../../control/index.js";
13
- import {
14
- toScrcpyOptionValue,
15
- type ScrcpyOptions,
16
- type ScrcpyVideoStreamPacket,
17
- } from "../types.js";
15
+ import type { ScrcpyOptions, ScrcpyVideoStreamPacket } from "../types.js";
16
+ import { toScrcpyOptionValue } from "../types.js";
18
17
 
19
18
  import { CodecOptions } from "./codec-options.js";
20
19
  import {
@@ -22,10 +21,8 @@ import {
22
21
  parseSequenceParameterSet,
23
22
  removeH264Emulation,
24
23
  } from "./h264-configuration.js";
25
- import {
26
- ScrcpyScrollController1_16,
27
- type ScrcpyScrollController,
28
- } from "./scroll.js";
24
+ import type { ScrcpyScrollController } from "./scroll.js";
25
+ import { ScrcpyScrollController1_16 } from "./scroll.js";
29
26
 
30
27
  export enum ScrcpyLogLevel {
31
28
  Verbose = "verbose",
@@ -69,6 +66,14 @@ export interface ScrcpyOptionsInit1_16 {
69
66
  */
70
67
  lockVideoOrientation: ScrcpyVideoOrientation;
71
68
 
69
+ /**
70
+ * Use ADB forward tunnel instead of reverse tunnel.
71
+ *
72
+ * This option is mainly used for working around the bug that on Android <9,
73
+ * ADB daemon can't create reverse tunnels if connected wirelessly (ADB over WiFi).
74
+ *
75
+ * When using `AdbScrcpyClient`, it can detect this situation and enable this option automatically.
76
+ */
72
77
  tunnelForward: boolean;
73
78
 
74
79
  crop: string;
@@ -120,7 +125,7 @@ export const ScrcpySetClipboardControlMessage1_15 = new Struct()
120
125
  .string("content", { lengthField: "length" });
121
126
 
122
127
  export type ScrcpySetClipboardControlMessage1_15 =
123
- typeof ScrcpySetClipboardControlMessage1_15["TInit"];
128
+ (typeof ScrcpySetClipboardControlMessage1_15)["TInit"];
124
129
 
125
130
  export class ScrcpyOptions1_16<
126
131
  T extends ScrcpyOptionsInit1_16 = ScrcpyOptionsInit1_16
@@ -1,9 +1,7 @@
1
1
  import Struct from "@yume-chan/struct";
2
2
 
3
- import {
4
- ScrcpyControlMessageType,
5
- type ScrcpyInjectScrollControlMessage,
6
- } from "../../control/index.js";
3
+ import type { ScrcpyInjectScrollControlMessage } from "../../control/index.js";
4
+ import { ScrcpyControlMessageType } from "../../control/index.js";
7
5
 
8
6
  export interface ScrcpyScrollController {
9
7
  serializeScrollMessage(
@@ -1,15 +1,15 @@
1
1
  import Struct, { placeholder } from "@yume-chan/struct";
2
2
 
3
- import {
4
- ScrcpyControlMessageType,
5
- type AndroidKeyEventAction,
6
- type ScrcpyBackOrScreenOnControlMessage,
3
+ import type {
4
+ AndroidKeyEventAction,
5
+ ScrcpyBackOrScreenOnControlMessage,
7
6
  } from "../control/index.js";
7
+ import { ScrcpyControlMessageType } from "../control/index.js";
8
8
 
9
+ import type { ScrcpyOptionsInit1_16 } from "./1_16/options.js";
9
10
  import {
10
11
  ScrcpyBackOrScreenOnControlMessage1_16,
11
12
  ScrcpyOptions1_16,
12
- type ScrcpyOptionsInit1_16,
13
13
  } from "./1_16/options.js";
14
14
 
15
15
  export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
@@ -21,7 +21,7 @@ export const ScrcpyBackOrScreenOnControlMessage1_18 = new Struct()
21
21
  .uint8("action", placeholder<AndroidKeyEventAction>());
22
22
 
23
23
  export type ScrcpyBackOrScreenOnControlMessage1_18 =
24
- typeof ScrcpyBackOrScreenOnControlMessage1_18["TInit"];
24
+ (typeof ScrcpyBackOrScreenOnControlMessage1_18)["TInit"];
25
25
 
26
26
  export class ScrcpyOptions1_18<
27
27
  T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18
@@ -2,12 +2,11 @@
2
2
 
3
3
  import Struct from "@yume-chan/struct";
4
4
 
5
- import {
6
- ScrcpyControlMessageType,
7
- type ScrcpySetClipboardControlMessage,
8
- } from "../control/index.js";
5
+ import type { ScrcpySetClipboardControlMessage } from "../control/index.js";
6
+ import { ScrcpyControlMessageType } from "../control/index.js";
9
7
 
10
- import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from "./1_18.js";
8
+ import type { ScrcpyOptionsInit1_18 } from "./1_18.js";
9
+ import { ScrcpyOptions1_18 } from "./1_18.js";
11
10
  import { toScrcpyOptionValue } from "./types.js";
12
11
 
13
12
  export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
@@ -26,7 +25,7 @@ export const ScrcpySetClipboardControlMessage1_21 = new Struct()
26
25
  .string("content", { lengthField: "length" });
27
26
 
28
27
  export type ScrcpySetClipboardControlMessage1_21 =
29
- typeof ScrcpySetClipboardControlMessage1_21["TInit"];
28
+ (typeof ScrcpySetClipboardControlMessage1_21)["TInit"];
30
29
 
31
30
  export class ScrcpyOptions1_21<
32
31
  T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21
@@ -1,5 +1,6 @@
1
- import { type ScrcpyScrollController } from "../1_16/index.js";
2
- import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "../1_21.js";
1
+ import type { ScrcpyScrollController } from "../1_16/index.js";
2
+ import type { ScrcpyOptionsInit1_21 } from "../1_21.js";
3
+ import { ScrcpyOptions1_21 } from "../1_21.js";
3
4
 
4
5
  import { ScrcpyScrollController1_22 } from "./scroll.js";
5
6
 
@@ -10,7 +10,7 @@ export const ScrcpyInjectScrollControlMessage1_22 = new Struct()
10
10
  .int32("buttons");
11
11
 
12
12
  export type ScrcpyInjectScrollControlMessage1_22 =
13
- typeof ScrcpyInjectScrollControlMessage1_22["TInit"];
13
+ (typeof ScrcpyInjectScrollControlMessage1_22)["TInit"];
14
14
 
15
15
  export class ScrcpyScrollController1_22 extends ScrcpyScrollController1_16 {
16
16
  public override serializeScrollMessage(