@yume-chan/scrcpy 0.0.15 → 0.0.17

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 (214) hide show
  1. package/CHANGELOG.json +33 -0
  2. package/CHANGELOG.md +18 -1
  3. package/LICENSE +21 -21
  4. package/README.md +327 -89
  5. package/esm/adb/client.d.ts +40 -0
  6. package/esm/adb/client.d.ts.map +1 -0
  7. package/esm/adb/client.js +218 -0
  8. package/esm/adb/client.js.map +1 -0
  9. package/esm/adb/connection.d.ts +38 -0
  10. package/esm/adb/connection.d.ts.map +1 -0
  11. package/esm/{connection.js → adb/connection.js} +20 -24
  12. package/esm/adb/connection.js.map +1 -0
  13. package/esm/adb/index.d.ts +4 -0
  14. package/esm/adb/index.d.ts.map +1 -0
  15. package/esm/adb/index.js +4 -0
  16. package/esm/adb/index.js.map +1 -0
  17. package/esm/adb/options/1_16.d.ts +8 -0
  18. package/esm/adb/options/1_16.d.ts.map +1 -0
  19. package/esm/adb/options/1_16.js +20 -0
  20. package/esm/adb/options/1_16.js.map +1 -0
  21. package/esm/adb/options/1_22.d.ts +8 -0
  22. package/esm/adb/options/1_22.d.ts.map +1 -0
  23. package/esm/adb/options/1_22.js +17 -0
  24. package/esm/adb/options/1_22.js.map +1 -0
  25. package/esm/adb/options/index.d.ts +4 -0
  26. package/esm/adb/options/index.d.ts.map +1 -0
  27. package/esm/adb/options/index.js +4 -0
  28. package/esm/adb/options/index.js.map +1 -0
  29. package/esm/adb/options/types.d.ts +23 -0
  30. package/esm/adb/options/types.d.ts.map +1 -0
  31. package/esm/adb/options/types.js +30 -0
  32. package/esm/adb/options/types.js.map +1 -0
  33. package/esm/codec.js +2 -2
  34. package/esm/codec.js.map +1 -1
  35. package/esm/control/index.d.ts +8 -0
  36. package/esm/control/index.d.ts.map +1 -0
  37. package/esm/control/index.js +8 -0
  38. package/esm/control/index.js.map +1 -0
  39. package/esm/control/inject-keycode.d.ts +53 -0
  40. package/esm/control/inject-keycode.d.ts.map +1 -0
  41. package/esm/control/inject-keycode.js +54 -0
  42. package/esm/control/inject-keycode.js.map +1 -0
  43. package/esm/control/inject-text.d.ts +9 -0
  44. package/esm/control/inject-text.d.ts.map +1 -0
  45. package/esm/control/inject-text.js +7 -0
  46. package/esm/control/inject-text.js.map +1 -0
  47. package/esm/control/inject-touch.d.ts +30 -0
  48. package/esm/control/inject-touch.d.ts.map +1 -0
  49. package/esm/control/inject-touch.js +30 -0
  50. package/esm/control/inject-touch.js.map +1 -0
  51. package/esm/control/rotate-device.d.ts +7 -0
  52. package/esm/control/rotate-device.d.ts.map +1 -0
  53. package/esm/control/rotate-device.js +5 -0
  54. package/esm/control/rotate-device.js.map +1 -0
  55. package/esm/control/serializer.d.ts +23 -0
  56. package/esm/control/serializer.d.ts.map +1 -0
  57. package/esm/control/serializer.js +73 -0
  58. package/esm/control/serializer.js.map +1 -0
  59. package/esm/control/set-screen-power-mode.d.ts +12 -0
  60. package/esm/control/set-screen-power-mode.d.ts.map +1 -0
  61. package/esm/control/set-screen-power-mode.js +12 -0
  62. package/esm/control/set-screen-power-mode.js.map +1 -0
  63. package/esm/control/type.d.ts +15 -0
  64. package/esm/control/type.d.ts.map +1 -0
  65. package/esm/control/type.js +19 -0
  66. package/esm/control/type.js.map +1 -0
  67. package/esm/decoder/index.d.ts +27 -3
  68. package/esm/decoder/index.d.ts.map +1 -1
  69. package/esm/decoder/index.js +1 -3
  70. package/esm/decoder/index.js.map +1 -1
  71. package/esm/decoder/tinyh264/index.d.ts +5 -5
  72. package/esm/decoder/tinyh264/index.d.ts.map +1 -1
  73. package/esm/decoder/tinyh264/index.js +4 -4
  74. package/esm/decoder/tinyh264/index.js.map +1 -1
  75. package/esm/decoder/tinyh264/worker.js.map +1 -1
  76. package/esm/decoder/tinyh264/wrapper.d.ts.map +1 -1
  77. package/esm/decoder/tinyh264/wrapper.js +14 -8
  78. package/esm/decoder/tinyh264/wrapper.js.map +1 -1
  79. package/esm/decoder/types.d.ts +1 -27
  80. package/esm/decoder/types.d.ts.map +1 -1
  81. package/esm/decoder/web-codecs/index.d.ts +4 -4
  82. package/esm/decoder/web-codecs/index.d.ts.map +1 -1
  83. package/esm/decoder/web-codecs/index.js +1 -1
  84. package/esm/decoder/web-codecs/index.js.map +1 -1
  85. package/esm/device-message/clipboard.d.ts +10 -0
  86. package/esm/device-message/clipboard.d.ts.map +1 -0
  87. package/esm/device-message/clipboard.js +7 -0
  88. package/esm/device-message/clipboard.js.map +1 -0
  89. package/esm/device-message/index.d.ts +4 -0
  90. package/esm/device-message/index.d.ts.map +1 -0
  91. package/esm/device-message/index.js +4 -0
  92. package/esm/device-message/index.js.map +1 -0
  93. package/esm/device-message/stream.d.ts +7 -0
  94. package/esm/device-message/stream.d.ts.map +1 -0
  95. package/esm/device-message/stream.js +16 -0
  96. package/esm/device-message/stream.js.map +1 -0
  97. package/esm/device-message/type.d.ts +5 -0
  98. package/esm/device-message/type.d.ts.map +1 -0
  99. package/esm/device-message/type.js +7 -0
  100. package/esm/device-message/type.js.map +1 -0
  101. package/esm/index.d.ts +3 -6
  102. package/esm/index.d.ts.map +1 -1
  103. package/esm/index.js +3 -6
  104. package/esm/index.js.map +1 -1
  105. package/esm/options/1_16/codec-options.d.ts +19 -0
  106. package/esm/options/1_16/codec-options.d.ts.map +1 -0
  107. package/esm/options/1_16/codec-options.js +27 -0
  108. package/esm/options/1_16/codec-options.js.map +1 -0
  109. package/esm/options/1_16/index.d.ts +3 -107
  110. package/esm/options/1_16/index.d.ts.map +1 -1
  111. package/esm/options/1_16/index.js +3 -216
  112. package/esm/options/1_16/index.js.map +1 -1
  113. package/esm/options/1_16/options.d.ts +97 -0
  114. package/esm/options/1_16/options.d.ts.map +1 -0
  115. package/esm/options/1_16/options.js +188 -0
  116. package/esm/options/1_16/options.js.map +1 -0
  117. package/esm/options/1_18.d.ts +8 -8
  118. package/esm/options/1_18.d.ts.map +1 -1
  119. package/esm/options/1_18.js +6 -6
  120. package/esm/options/1_18.js.map +1 -1
  121. package/esm/options/1_21.d.ts +1 -1
  122. package/esm/options/1_21.d.ts.map +1 -1
  123. package/esm/options/1_21.js +1 -1
  124. package/esm/options/1_21.js.map +1 -1
  125. package/esm/options/1_22.d.ts +5 -8
  126. package/esm/options/1_22.d.ts.map +1 -1
  127. package/esm/options/1_22.js +4 -17
  128. package/esm/options/1_22.js.map +1 -1
  129. package/esm/options/1_23.d.ts +4 -4
  130. package/esm/options/1_23.d.ts.map +1 -1
  131. package/esm/options/1_23.js +1 -1
  132. package/esm/options/1_23.js.map +1 -1
  133. package/esm/options/1_24.d.ts +1 -1
  134. package/esm/options/1_24.d.ts.map +1 -1
  135. package/esm/options/1_24.js.map +1 -1
  136. package/esm/options/index.d.ts +1 -1
  137. package/esm/options/index.d.ts.map +1 -1
  138. package/esm/options/index.js +1 -1
  139. package/esm/options/index.js.map +1 -1
  140. package/esm/options/types.d.ts +45 -0
  141. package/esm/options/types.d.ts.map +1 -0
  142. package/esm/options/{common.js → types.js} +1 -1
  143. package/esm/options/types.js.map +1 -0
  144. package/package.json +24 -24
  145. package/scrcpy.LICENSE +203 -203
  146. package/scripts/fetch-server.cjs +28 -28
  147. package/src/adb/client.ts +292 -0
  148. package/src/{connection.ts → adb/connection.ts} +145 -148
  149. package/src/adb/index.ts +3 -0
  150. package/src/adb/options/1_16.ts +23 -0
  151. package/src/adb/options/1_22.ts +20 -0
  152. package/src/adb/options/index.ts +3 -0
  153. package/src/adb/options/types.ts +55 -0
  154. package/src/codec.ts +35 -35
  155. package/src/control/index.ts +7 -0
  156. package/src/control/inject-keycode.ts +59 -0
  157. package/src/control/inject-text.ts +12 -0
  158. package/src/control/inject-touch.ts +34 -0
  159. package/src/control/rotate-device.ts +10 -0
  160. package/src/control/serializer.ts +86 -0
  161. package/src/control/set-screen-power-mode.ts +17 -0
  162. package/src/control/type.ts +17 -0
  163. package/src/device-message/clipboard.ts +11 -0
  164. package/src/device-message/index.ts +3 -0
  165. package/src/device-message/stream.ts +19 -0
  166. package/src/device-message/type.ts +5 -0
  167. package/src/index.ts +5 -8
  168. package/src/options/1_16/codec-options.ts +48 -0
  169. package/src/options/1_16/index.ts +3 -330
  170. package/src/options/1_16/options.ts +294 -0
  171. package/src/options/1_16/sps.ts +300 -300
  172. package/src/options/1_18.ts +63 -61
  173. package/src/options/1_21.ts +44 -34
  174. package/src/options/1_22.ts +67 -78
  175. package/src/options/1_23.ts +7 -5
  176. package/src/options/1_24.ts +3 -2
  177. package/src/options/index.ts +7 -7
  178. package/src/options/{common.ts → types.ts} +85 -66
  179. package/tsconfig.build.json +3 -0
  180. package/tsconfig.build.tsbuildinfo +1 -0
  181. package/tsconfig.test.tsbuildinfo +1 -0
  182. package/esm/client.d.ts +0 -48
  183. package/esm/client.d.ts.map +0 -1
  184. package/esm/client.js +0 -341
  185. package/esm/client.js.map +0 -1
  186. package/esm/connection.d.ts +0 -37
  187. package/esm/connection.d.ts.map +0 -1
  188. package/esm/connection.js.map +0 -1
  189. package/esm/message.d.ts +0 -97
  190. package/esm/message.d.ts.map +0 -1
  191. package/esm/message.js +0 -97
  192. package/esm/message.js.map +0 -1
  193. package/esm/options/common.d.ts +0 -34
  194. package/esm/options/common.d.ts.map +0 -1
  195. package/esm/options/common.js.map +0 -1
  196. package/esm/push-server.d.ts +0 -6
  197. package/esm/push-server.d.ts.map +0 -1
  198. package/esm/push-server.js +0 -16
  199. package/esm/push-server.js.map +0 -1
  200. package/esm/utils.d.ts +0 -2
  201. package/esm/utils.d.ts.map +0 -1
  202. package/esm/utils.js +0 -6
  203. package/esm/utils.js.map +0 -1
  204. package/src/client.ts +0 -435
  205. package/src/decoder/index.ts +0 -3
  206. package/src/decoder/tinyh264/index.ts +0 -112
  207. package/src/decoder/tinyh264/types.d.ts +0 -137
  208. package/src/decoder/tinyh264/worker.ts +0 -2
  209. package/src/decoder/tinyh264/wrapper.ts +0 -89
  210. package/src/decoder/types.ts +0 -35
  211. package/src/decoder/web-codecs/index.ts +0 -99
  212. package/src/message.ts +0 -112
  213. package/src/push-server.ts +0 -24
  214. package/src/utils.ts +0 -5
@@ -1,61 +1,63 @@
1
- import Struct, { placeholder } from "@yume-chan/struct";
2
- import { AndroidKeyEventAction, ScrcpyControlMessageType } from "../message.js";
3
- import { ScrcpyBackOrScreenOnEvent1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from "./1_16/index.js";
4
-
5
- export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
6
- powerOffOnClose: boolean;
7
- }
8
-
9
- export const ScrcpyBackOrScreenOnEvent1_18 =
10
- new Struct()
11
- .fields(ScrcpyBackOrScreenOnEvent1_16)
12
- .uint8('action', placeholder<AndroidKeyEventAction>());
13
-
14
- export type ScrcpyBackOrScreenOnEvent1_18 = typeof ScrcpyBackOrScreenOnEvent1_18["TInit"];
15
-
16
- export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18> extends ScrcpyOptions1_16<T> {
17
- constructor(value: Partial<ScrcpyOptionsInit1_18>) {
18
- super(value);
19
- }
20
-
21
- protected override getArgumentOrder(): (keyof T)[] {
22
- return super.getArgumentOrder().concat(['powerOffOnClose']);
23
- }
24
-
25
- protected override getDefaultValue(): T {
26
- return {
27
- ...super.getDefaultValue(),
28
- powerOffOnClose: false,
29
- };
30
- }
31
-
32
- public override getOutputEncoderNameRegex(): RegExp {
33
- return /\s+scrcpy --encoder '(.*?)'/;
34
- }
35
-
36
- public override getControlMessageTypes(): ScrcpyControlMessageType[] {
37
- /**
38
- * 0 InjectKeycode
39
- * 1 InjectText
40
- * 2 InjectTouch
41
- * 3 InjectScroll
42
- * 4 BackOrScreenOn
43
- * 5 ExpandNotificationPanel
44
- * 6 ExpandSettingsPanel
45
- * 7 CollapseNotificationPanel
46
- * 8 GetClipboard
47
- * 9 SetClipboard
48
- * 10 SetScreenPowerMode
49
- * 11 RotateDevice
50
- */
51
- const types = super.getControlMessageTypes();
52
- types.splice(6, 0, ScrcpyControlMessageType.ExpandSettingPanel);
53
- return types;
54
- }
55
-
56
- public override serializeBackOrScreenOnControlMessage(
57
- message: ScrcpyBackOrScreenOnEvent1_18,
58
- ) {
59
- return ScrcpyBackOrScreenOnEvent1_18.serialize(message);
60
- }
61
- }
1
+ import Struct, { placeholder } from '@yume-chan/struct';
2
+
3
+ import { AndroidKeyEventAction, ScrcpyControlMessageType } from '../control/index.js';
4
+ import { ScrcpyBackOrScreenOnControlMessage1_16, ScrcpyOptions1_16, type ScrcpyOptionsInit1_16 } from './1_16/options.js';
5
+
6
+ export interface ScrcpyOptionsInit1_18 extends ScrcpyOptionsInit1_16 {
7
+ powerOffOnClose: boolean;
8
+ }
9
+
10
+ export const ScrcpyBackOrScreenOnControlMessage1_18 =
11
+ new Struct()
12
+ .fields(ScrcpyBackOrScreenOnControlMessage1_16)
13
+ .uint8('action', placeholder<AndroidKeyEventAction>());
14
+
15
+ export type ScrcpyBackOrScreenOnControlMessage1_18 = typeof ScrcpyBackOrScreenOnControlMessage1_18['TInit'];
16
+
17
+ export class ScrcpyOptions1_18<T extends ScrcpyOptionsInit1_18 = ScrcpyOptionsInit1_18>
18
+ extends ScrcpyOptions1_16<T> {
19
+ constructor(value: Partial<ScrcpyOptionsInit1_18>) {
20
+ super(value);
21
+ }
22
+
23
+ protected override getArgumentOrder(): (keyof T)[] {
24
+ return super.getArgumentOrder().concat(['powerOffOnClose']);
25
+ }
26
+
27
+ public override getDefaultValue(): T {
28
+ return {
29
+ ...super.getDefaultValue(),
30
+ powerOffOnClose: false,
31
+ };
32
+ }
33
+
34
+ public override getOutputEncoderNameRegex(): RegExp {
35
+ return /\s+scrcpy --encoder '(.*?)'/;
36
+ }
37
+
38
+ public override getControlMessageTypes(): ScrcpyControlMessageType[] {
39
+ /**
40
+ * 0 InjectKeycode
41
+ * 1 InjectText
42
+ * 2 InjectTouch
43
+ * 3 InjectScroll
44
+ * 4 BackOrScreenOn
45
+ * 5 ExpandNotificationPanel
46
+ * 6 ExpandSettingsPanel
47
+ * 7 CollapseNotificationPanel
48
+ * 8 GetClipboard
49
+ * 9 SetClipboard
50
+ * 10 SetScreenPowerMode
51
+ * 11 RotateDevice
52
+ */
53
+ const types = super.getControlMessageTypes();
54
+ types.splice(6, 0, ScrcpyControlMessageType.ExpandSettingPanel);
55
+ return types;
56
+ }
57
+
58
+ public override serializeBackOrScreenOnControlMessage(
59
+ message: ScrcpyBackOrScreenOnControlMessage1_18,
60
+ ) {
61
+ return ScrcpyBackOrScreenOnControlMessage1_18.serialize(message);
62
+ }
63
+ }
@@ -1,34 +1,44 @@
1
- // cspell: ignore autosync
2
-
3
- import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js';
4
- import { toScrcpyOptionValue } from "./common.js";
5
-
6
- export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
7
- clipboardAutosync?: boolean;
8
- }
9
-
10
- function toSnakeCase(input: string): string {
11
- return input.replace(/([A-Z])/g, '_$1').toLowerCase();
12
- }
13
-
14
- export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21> extends ScrcpyOptions1_18<T> {
15
- public constructor(init: Partial<ScrcpyOptionsInit1_21>) {
16
- super(init);
17
- }
18
-
19
- protected override getDefaultValue(): T {
20
- return {
21
- ...super.getDefaultValue(),
22
- clipboardAutosync: true,
23
- };
24
- }
25
-
26
- public override formatServerArguments(): string[] {
27
- // 1.21 changed the format of arguments
28
- // So `getArgumentOrder()` is no longer needed
29
- return Object.entries(this.value)
30
- .map(([key, value]) => [key, toScrcpyOptionValue(value, undefined)] as const)
31
- .filter((pair): pair is [string, string] => pair[1] !== undefined)
32
- .map(([key, value]) => `${toSnakeCase(key)}=${value}`);
33
- }
34
- }
1
+ // cspell: ignore autosync
2
+
3
+ import { ScrcpyOptions1_18, type ScrcpyOptionsInit1_18 } from './1_18.js';
4
+ import { toScrcpyOptionValue } from './types.js';
5
+
6
+ export interface ScrcpyOptionsInit1_21 extends ScrcpyOptionsInit1_18 {
7
+ clipboardAutosync?: boolean;
8
+ }
9
+
10
+ function toSnakeCase(input: string): string {
11
+ return input.replace(/([A-Z])/g, '_$1').toLowerCase();
12
+ }
13
+
14
+ export class ScrcpyOptions1_21<T extends ScrcpyOptionsInit1_21 = ScrcpyOptionsInit1_21>
15
+ extends ScrcpyOptions1_18<T> {
16
+ public constructor(init: Partial<ScrcpyOptionsInit1_21>) {
17
+ super(init);
18
+ }
19
+
20
+ public override getDefaultValue(): T {
21
+ return {
22
+ ...super.getDefaultValue(),
23
+ clipboardAutosync: true,
24
+ };
25
+ }
26
+
27
+ public override formatServerArguments(): string[] {
28
+ // 1.21 changed the format of arguments
29
+ // So `getArgumentOrder()` is no longer needed
30
+ return Object.entries(this.value)
31
+ .map(
32
+ ([key, value]) =>
33
+ [key, toScrcpyOptionValue(value, undefined)] as const
34
+ )
35
+ .filter(
36
+ (pair): pair is [string, string] =>
37
+ pair[1] !== undefined
38
+ )
39
+ .map(
40
+ ([key, value]) =>
41
+ `${toSnakeCase(key)}=${value}`
42
+ );
43
+ }
44
+ }
@@ -1,78 +1,67 @@
1
- import type { Adb } from "@yume-chan/adb";
2
- import Struct from "@yume-chan/struct";
3
- import { ScrcpyClientForwardConnection, ScrcpyClientReverseConnection, type ScrcpyClientConnection } from "../connection.js";
4
- import { ScrcpyInjectScrollControlMessage1_16 } from "./1_16/index.js";
5
- import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from "./1_21.js";
6
-
7
- export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
8
- downsizeOnError: boolean;
9
-
10
- /**
11
- * Send device name and size at start of video stream.
12
- *
13
- * @default true
14
- */
15
- sendDeviceMeta: boolean;
16
-
17
- /**
18
- * Send a `0` byte on start of video stream to detect connection issues
19
- *
20
- * @default true
21
- */
22
- sendDummyByte: boolean;
23
-
24
- /**
25
- * Implies `sendDeviceMeta: false`, `sendFrameMeta: false` and `sendDummyByte: false`
26
- *
27
- * @default false
28
- */
29
- rawVideoStream: boolean;
30
- }
31
-
32
- export const ScrcpyInjectScrollControlMessage1_22 =
33
- new Struct()
34
- .fields(ScrcpyInjectScrollControlMessage1_16)
35
- .int32("buttons");
36
-
37
- export type ScrcpyInjectScrollControlMessage1_22 = typeof ScrcpyInjectScrollControlMessage1_22["TInit"];
38
-
39
- export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsInit1_22> extends ScrcpyOptions1_21<T> {
40
- public constructor(init: Partial<ScrcpyOptionsInit1_22>) {
41
- if (init.rawVideoStream) {
42
- // Set implied options for client-side processing
43
- init.sendDeviceMeta = false;
44
- init.sendFrameMeta = false;
45
- init.sendDummyByte = false;
46
- }
47
-
48
- super(init);
49
- }
50
-
51
- protected override getDefaultValue(): T {
52
- return {
53
- ...super.getDefaultValue(),
54
- downsizeOnError: true,
55
- sendDeviceMeta: true,
56
- sendDummyByte: true,
57
- rawVideoStream: false,
58
- };
59
- }
60
-
61
- public override createConnection(device: Adb): ScrcpyClientConnection {
62
- const options = {
63
- ...this.getDefaultValue(),
64
- ...this.value,
65
- };
66
- if (this.value.tunnelForward) {
67
- return new ScrcpyClientForwardConnection(device, options);
68
- } else {
69
- return new ScrcpyClientReverseConnection(device, options);
70
- }
71
- }
72
-
73
- public override serializeInjectScrollControlMessage(
74
- message: ScrcpyInjectScrollControlMessage1_22,
75
- ): Uint8Array {
76
- return ScrcpyInjectScrollControlMessage1_22.serialize(message);
77
- }
78
- }
1
+ import Struct from '@yume-chan/struct';
2
+
3
+ import { ScrcpyInjectScrollControlMessage1_16 } from './1_16/options.js';
4
+ import { ScrcpyOptions1_21, type ScrcpyOptionsInit1_21 } from './1_21.js';
5
+
6
+ export interface ScrcpyOptionsInit1_22 extends ScrcpyOptionsInit1_21 {
7
+ downsizeOnError: boolean;
8
+
9
+ /**
10
+ * Send device name and size at start of video stream.
11
+ *
12
+ * @default true
13
+ */
14
+ sendDeviceMeta: boolean;
15
+
16
+ /**
17
+ * Send a `0` byte on start of video stream to detect connection issues
18
+ *
19
+ * @default true
20
+ */
21
+ sendDummyByte: boolean;
22
+
23
+ /**
24
+ * Implies `sendDeviceMeta: false`, `sendFrameMeta: false` and `sendDummyByte: false`
25
+ *
26
+ * @default false
27
+ */
28
+ rawVideoStream: boolean;
29
+ }
30
+
31
+ export const ScrcpyInjectScrollControlMessage1_22 =
32
+ new Struct()
33
+ .fields(ScrcpyInjectScrollControlMessage1_16)
34
+ .int32('buttons');
35
+
36
+ export type ScrcpyInjectScrollControlMessage1_22 =
37
+ typeof ScrcpyInjectScrollControlMessage1_22['TInit'];
38
+
39
+ export class ScrcpyOptions1_22<T extends ScrcpyOptionsInit1_22 = ScrcpyOptionsInit1_22>
40
+ extends ScrcpyOptions1_21<T> {
41
+ public constructor(init: Partial<ScrcpyOptionsInit1_22>) {
42
+ if (init.rawVideoStream) {
43
+ // Set implied options for client-side processing
44
+ init.sendDeviceMeta = false;
45
+ init.sendFrameMeta = false;
46
+ init.sendDummyByte = false;
47
+ }
48
+
49
+ super(init);
50
+ }
51
+
52
+ public override getDefaultValue(): T {
53
+ return {
54
+ ...super.getDefaultValue(),
55
+ downsizeOnError: true,
56
+ sendDeviceMeta: true,
57
+ sendDummyByte: true,
58
+ rawVideoStream: false,
59
+ };
60
+ }
61
+
62
+ public override serializeInjectScrollControlMessage(
63
+ message: ScrcpyInjectScrollControlMessage1_22,
64
+ ): Uint8Array {
65
+ return ScrcpyInjectScrollControlMessage1_22.serialize(message);
66
+ }
67
+ }
@@ -1,6 +1,7 @@
1
- import { TransformStream } from "@yume-chan/adb";
1
+ import { TransformStream } from '@yume-chan/stream-extra';
2
+
2
3
  import { ScrcpyOptions1_22, type ScrcpyOptionsInit1_22 } from './1_22.js';
3
- import type { VideoStreamPacket } from "./common.js";
4
+ import type { ScrcpyVideoStreamPacket } from './types.js';
4
5
 
5
6
  export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
6
7
  cleanup: boolean;
@@ -8,19 +9,20 @@ export interface ScrcpyOptionsInit1_23 extends ScrcpyOptionsInit1_22 {
8
9
 
9
10
  const KEYFRAME_PTS = BigInt(1) << BigInt(62);
10
11
 
11
- export class ScrcpyOptions1_23<T extends ScrcpyOptionsInit1_23 = ScrcpyOptionsInit1_23> extends ScrcpyOptions1_22<T> {
12
+ export class ScrcpyOptions1_23<T extends ScrcpyOptionsInit1_23 = ScrcpyOptionsInit1_23>
13
+ extends ScrcpyOptions1_22<T> {
12
14
  public constructor(init: Partial<ScrcpyOptionsInit1_23>) {
13
15
  super(init);
14
16
  }
15
17
 
16
- protected override getDefaultValue(): T {
18
+ public override getDefaultValue(): T {
17
19
  return {
18
20
  ...super.getDefaultValue(),
19
21
  cleanup: true,
20
22
  };
21
23
  }
22
24
 
23
- public override createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket> {
25
+ public override createVideoStreamTransformer(): TransformStream<Uint8Array, ScrcpyVideoStreamPacket> {
24
26
  const superStream = super.createVideoStreamTransformer();
25
27
  return {
26
28
  writable: superStream.writable,
@@ -4,12 +4,13 @@ export interface ScrcpyOptionsInit1_24 extends ScrcpyOptionsInit1_23 {
4
4
  powerOn: boolean;
5
5
  }
6
6
 
7
- export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24> extends ScrcpyOptions1_23<T> {
7
+ export class ScrcpyOptions1_24<T extends ScrcpyOptionsInit1_24 = ScrcpyOptionsInit1_24>
8
+ extends ScrcpyOptions1_23<T> {
8
9
  public constructor(init: Partial<ScrcpyOptionsInit1_24>) {
9
10
  super(init);
10
11
  }
11
12
 
12
- protected override getDefaultValue(): T {
13
+ public override getDefaultValue(): T {
13
14
  return {
14
15
  ...super.getDefaultValue(),
15
16
  powerOn: true,
@@ -1,7 +1,7 @@
1
- export * from './1_16/index.js';
2
- export * from './1_18.js';
3
- export * from './1_21.js';
4
- export * from './1_22.js';
5
- export * from './1_23.js';
6
- export * from './1_24.js';
7
- export * from './common.js';
1
+ export * from './1_16/index.js';
2
+ export * from './1_18.js';
3
+ export * from './1_21.js';
4
+ export * from './1_22.js';
5
+ export * from './1_23.js';
6
+ export * from './1_24.js';
7
+ export * from './types.js';
@@ -1,66 +1,85 @@
1
- import type { Adb, TransformStream } from "@yume-chan/adb";
2
- import type { ScrcpyClientConnection } from "../connection.js";
3
- import type { H264Configuration } from "../decoder/index.js";
4
- import type { ScrcpyControlMessageType } from "../message.js";
5
- import type { ScrcpyBackOrScreenOnEvent1_18 } from "./1_18.js";
6
- import type { ScrcpyInjectScrollControlMessage1_22 } from "./1_22.js";
7
-
8
- export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar';
9
-
10
- export interface ScrcpyOptionValue {
11
- toOptionValue(): string | undefined;
12
- }
13
-
14
- export function isScrcpyOptionValue(value: any): value is ScrcpyOptionValue {
15
- return typeof value === 'object' &&
16
- value !== null &&
17
- typeof value.toOptionValue === 'function';
18
- }
19
-
20
- export function toScrcpyOptionValue<T>(value: any, empty: T): string | T {
21
- if (isScrcpyOptionValue(value)) {
22
- value = value.toOptionValue();
23
- }
24
-
25
- if (value === undefined) {
26
- return empty;
27
- }
28
-
29
- return `${value}`;
30
- }
31
-
32
- export interface VideoStreamConfigurationPacket {
33
- type: 'configuration';
34
- data: H264Configuration;
35
- }
36
-
37
- export interface VideoStreamFramePacket {
38
- type: 'frame';
39
- keyframe?: boolean | undefined;
40
- pts?: bigint | undefined;
41
- data: Uint8Array;
42
- }
43
-
44
- export type VideoStreamPacket = VideoStreamConfigurationPacket | VideoStreamFramePacket;
45
-
46
- export interface ScrcpyOptions<T> {
47
- value: Partial<T>;
48
-
49
- formatServerArguments(): string[];
50
-
51
- getOutputEncoderNameRegex(): RegExp;
52
-
53
- createConnection(adb: Adb): ScrcpyClientConnection;
54
-
55
- createVideoStreamTransformer(): TransformStream<Uint8Array, VideoStreamPacket>;
56
-
57
- getControlMessageTypes(): ScrcpyControlMessageType[];
58
-
59
- serializeBackOrScreenOnControlMessage(
60
- message: ScrcpyBackOrScreenOnEvent1_18,
61
- ): Uint8Array | undefined;
62
-
63
- serializeInjectScrollControlMessage(
64
- message: ScrcpyInjectScrollControlMessage1_22,
65
- ): Uint8Array;
66
- }
1
+ import type { TransformStream } from '@yume-chan/stream-extra';
2
+
3
+ import type { ScrcpyControlMessageType } from '../control/index.js';
4
+ import type { ScrcpyBackOrScreenOnControlMessage1_18 } from './1_18.js';
5
+ import type { ScrcpyInjectScrollControlMessage1_22 } from './1_22.js';
6
+
7
+ export const DEFAULT_SERVER_PATH = '/data/local/tmp/scrcpy-server.jar';
8
+
9
+ export interface ScrcpyOptionValue {
10
+ toOptionValue(): string | undefined;
11
+ }
12
+
13
+ export function isScrcpyOptionValue(value: any): value is ScrcpyOptionValue {
14
+ return typeof value === 'object' &&
15
+ value !== null &&
16
+ typeof value.toOptionValue === 'function';
17
+ }
18
+
19
+ export function toScrcpyOptionValue<T>(value: any, empty: T): string | T {
20
+ if (isScrcpyOptionValue(value)) {
21
+ value = value.toOptionValue();
22
+ }
23
+
24
+ if (value === undefined) {
25
+ return empty;
26
+ }
27
+
28
+ return `${value}`;
29
+ }
30
+
31
+ export interface H264Configuration {
32
+ profileIndex: number;
33
+ constraintSet: number;
34
+ levelIndex: number;
35
+
36
+ encodedWidth: number;
37
+ encodedHeight: number;
38
+
39
+ cropLeft: number;
40
+ cropRight: number;
41
+
42
+ cropTop: number;
43
+ cropBottom: number;
44
+
45
+ croppedWidth: number;
46
+ croppedHeight: number;
47
+ }
48
+
49
+ export interface ScrcpyVideoStreamConfigurationPacket {
50
+ type: 'configuration';
51
+ data: H264Configuration;
52
+ }
53
+
54
+ export interface ScrcpyVideoStreamFramePacket {
55
+ type: 'frame';
56
+ keyframe?: boolean | undefined;
57
+ pts?: bigint | undefined;
58
+ data: Uint8Array;
59
+ }
60
+
61
+ export type ScrcpyVideoStreamPacket =
62
+ | ScrcpyVideoStreamConfigurationPacket
63
+ | ScrcpyVideoStreamFramePacket;
64
+
65
+ export interface ScrcpyOptions<T> {
66
+ value: Partial<T>;
67
+
68
+ getDefaultValue(): T;
69
+
70
+ formatServerArguments(): string[];
71
+
72
+ getOutputEncoderNameRegex(): RegExp;
73
+
74
+ createVideoStreamTransformer(): TransformStream<Uint8Array, ScrcpyVideoStreamPacket>;
75
+
76
+ getControlMessageTypes(): ScrcpyControlMessageType[];
77
+
78
+ serializeBackOrScreenOnControlMessage(
79
+ message: ScrcpyBackOrScreenOnControlMessage1_18,
80
+ ): Uint8Array | undefined;
81
+
82
+ serializeInjectScrollControlMessage(
83
+ message: ScrcpyInjectScrollControlMessage1_22,
84
+ ): Uint8Array;
85
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./node_modules/@yume-chan/ts-package-builder/tsconfig.base.json"
3
+ }