@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.
- package/CHANGELOG.json +18 -0
- package/CHANGELOG.md +10 -1
- package/README.md +111 -61
- package/bin/scrcpy-server +0 -0
- package/bin/version.d.ts +1 -1
- package/bin/version.js +1 -1
- package/esm/adb/client.d.ts +40 -40
- package/esm/adb/client.d.ts.map +1 -1
- package/esm/adb/client.js +223 -242
- package/esm/adb/client.js.map +1 -1
- package/esm/adb/connection.d.ts +48 -46
- package/esm/adb/connection.d.ts.map +1 -1
- package/esm/adb/connection.js +121 -109
- package/esm/adb/connection.js.map +1 -1
- package/esm/adb/index.d.ts +3 -3
- package/esm/adb/index.js +3 -3
- package/esm/adb/options/1_16.d.ts +7 -7
- package/esm/adb/options/1_16.d.ts.map +1 -1
- package/esm/adb/options/1_16.js +19 -19
- package/esm/adb/options/1_16.js.map +1 -1
- package/esm/adb/options/1_22.d.ts +7 -7
- package/esm/adb/options/1_22.d.ts.map +1 -1
- package/esm/adb/options/1_22.js +16 -16
- package/esm/adb/options/1_22.js.map +1 -1
- package/esm/adb/options/1_26.d.ts +9 -0
- package/esm/adb/options/1_26.d.ts.map +1 -0
- package/esm/adb/options/1_26.js +11 -0
- package/esm/adb/options/1_26.js.map +1 -0
- package/esm/adb/options/2_0.d.ts +8 -0
- package/esm/adb/options/2_0.d.ts.map +1 -0
- package/esm/adb/options/2_0.js +13 -0
- package/esm/adb/options/2_0.js.map +1 -0
- package/esm/adb/options/index.d.ts +3 -3
- package/esm/adb/options/index.js +3 -3
- package/esm/adb/options/types.d.ts +23 -23
- package/esm/adb/options/types.d.ts.map +1 -1
- package/esm/adb/options/types.js +36 -36
- package/esm/codec/av1.d.ts +33 -0
- package/esm/codec/av1.d.ts.map +1 -0
- package/esm/codec/av1.js +35 -0
- package/esm/codec/av1.js.map +1 -0
- package/esm/codec/h264.d.ts +98 -0
- package/esm/codec/h264.d.ts.map +1 -0
- package/esm/codec/h264.js +477 -0
- package/esm/codec/h264.js.map +1 -0
- package/esm/codec/h265.d.ts +36 -0
- package/esm/codec/h265.d.ts.map +1 -0
- package/esm/codec/h265.js +38 -0
- package/esm/codec/h265.js.map +1 -0
- package/esm/codec/index.d.ts +4 -0
- package/esm/codec/index.d.ts.map +1 -0
- package/esm/codec/index.js +4 -0
- package/esm/codec/index.js.map +1 -0
- package/esm/codec.d.ts +33 -33
- package/esm/codec.js +36 -36
- package/esm/control/back-or-screen-on.d.ts +2 -2
- package/esm/control/back-or-screen-on.d.ts.map +1 -1
- package/esm/control/back-or-screen-on.js +1 -1
- package/esm/control/basic.d.ts +5 -0
- package/esm/control/basic.d.ts.map +1 -0
- package/esm/control/basic.js +3 -0
- package/esm/control/basic.js.map +1 -0
- package/esm/control/hover-helper.d.ts +17 -17
- package/esm/control/hover-helper.d.ts.map +1 -1
- package/esm/control/hover-helper.js +43 -43
- package/esm/control/hover-helper.js.map +1 -1
- package/esm/control/index.d.ts +11 -11
- package/esm/control/index.js +11 -11
- package/esm/control/inject-keycode.d.ts +194 -60
- package/esm/control/inject-keycode.d.ts.map +1 -1
- package/esm/control/inject-keycode.js +199 -61
- package/esm/control/inject-keycode.js.map +1 -1
- package/esm/control/inject-scroll.d.ts +2 -2
- package/esm/control/inject-scroll.d.ts.map +1 -1
- package/esm/control/inject-scroll.js +1 -1
- package/esm/control/inject-text.d.ts +8 -8
- package/esm/control/inject-text.d.ts.map +1 -1
- package/esm/control/inject-text.js +6 -6
- package/esm/control/inject-text.js.map +1 -1
- package/esm/control/inject-touch.d.ts +37 -37
- package/esm/control/inject-touch.d.ts.map +1 -1
- package/esm/control/inject-touch.js +62 -62
- package/esm/control/rotate-device.d.ts +6 -6
- package/esm/control/rotate-device.d.ts.map +1 -1
- package/esm/control/rotate-device.js +3 -4
- package/esm/control/rotate-device.js.map +1 -1
- package/esm/control/serializer.d.ts +35 -33
- package/esm/control/serializer.d.ts.map +1 -1
- package/esm/control/serializer.js +82 -78
- package/esm/control/serializer.js.map +1 -1
- package/esm/control/set-clipboard.d.ts +2 -2
- package/esm/control/set-clipboard.d.ts.map +1 -1
- package/esm/control/set-clipboard.js +1 -1
- package/esm/control/set-screen-power-mode.d.ts +11 -11
- package/esm/control/set-screen-power-mode.d.ts.map +1 -1
- package/esm/control/set-screen-power-mode.js +11 -11
- package/esm/control/set-screen-power-mode.js.map +1 -1
- package/esm/control/simple.d.ts +5 -0
- package/esm/control/simple.d.ts.map +1 -0
- package/esm/control/simple.js +3 -0
- package/esm/control/simple.js.map +1 -0
- package/esm/control/type.d.ts +14 -14
- package/esm/control/type.js +18 -18
- package/esm/decoder.d.ts +2 -0
- package/esm/decoder.d.ts.map +1 -0
- package/esm/decoder.js +2 -0
- package/esm/decoder.js.map +1 -0
- package/esm/device-message/ack-clipboard.d.ts +8 -8
- package/esm/device-message/ack-clipboard.d.ts.map +1 -1
- package/esm/device-message/ack-clipboard.js +5 -5
- package/esm/device-message/clipboard.d.ts +9 -9
- package/esm/device-message/clipboard.d.ts.map +1 -1
- package/esm/device-message/clipboard.js +6 -6
- package/esm/device-message/index.d.ts +4 -4
- package/esm/device-message/index.js +4 -4
- package/esm/device-message/stream.d.ts +7 -7
- package/esm/device-message/stream.js +19 -19
- package/esm/device-message/type.d.ts +4 -4
- package/esm/device-message/type.js +6 -6
- package/esm/index.d.ts +5 -5
- package/esm/index.js +5 -5
- package/esm/options/1.17.d.ts +3 -0
- package/esm/options/1.17.d.ts.map +1 -0
- package/esm/options/1.17.js +2 -0
- package/esm/options/1.17.js.map +1 -0
- package/esm/options/1_16/codec-options.d.ts +20 -19
- package/esm/options/1_16/codec-options.d.ts.map +1 -1
- package/esm/options/1_16/codec-options.js +25 -25
- package/esm/options/1_16/codec-options.js.map +1 -1
- package/esm/options/1_16/float-to-uint16.d.ts +5 -0
- package/esm/options/1_16/float-to-uint16.d.ts.map +1 -0
- package/esm/options/1_16/float-to-uint16.js +27 -0
- package/esm/options/1_16/float-to-uint16.js.map +1 -0
- package/esm/options/1_16/h264-configuration.d.ts +48 -48
- package/esm/options/1_16/h264-configuration.js +413 -413
- package/esm/options/1_16/index.d.ts +4 -4
- package/esm/options/1_16/index.js +4 -4
- package/esm/options/1_16/init.d.ts +66 -0
- package/esm/options/1_16/init.d.ts.map +1 -0
- package/esm/options/1_16/init.js +16 -0
- package/esm/options/1_16/init.js.map +1 -0
- package/esm/options/1_16/message.d.ts +32 -0
- package/esm/options/1_16/message.d.ts.map +1 -0
- package/esm/options/1_16/message.js +37 -0
- package/esm/options/1_16/message.js.map +1 -0
- package/esm/options/1_16/options.d.ts +102 -93
- package/esm/options/1_16/options.d.ts.map +1 -1
- package/esm/options/1_16/options.js +189 -189
- package/esm/options/1_16/options.js.map +1 -1
- package/esm/options/1_16/scroll.d.ts +27 -26
- package/esm/options/1_16/scroll.d.ts.map +1 -1
- package/esm/options/1_16/scroll.js +55 -55
- package/esm/options/1_16/scroll.js.map +1 -1
- package/esm/options/1_17.d.ts +32 -0
- package/esm/options/1_17.d.ts.map +1 -0
- package/esm/options/1_17.js +36 -0
- package/esm/options/1_17.js.map +1 -0
- package/esm/options/1_18.d.ts +21 -19
- package/esm/options/1_18.d.ts.map +1 -1
- package/esm/options/1_18.js +45 -45
- package/esm/options/1_18.js.map +1 -1
- package/esm/options/1_21.d.ts +22 -20
- package/esm/options/1_21.d.ts.map +1 -1
- package/esm/options/1_21.js +36 -36
- package/esm/options/1_21.js.map +1 -1
- package/esm/options/1_22/index.d.ts +2 -2
- package/esm/options/1_22/index.js +2 -2
- package/esm/options/1_22/init.d.ts +17 -0
- package/esm/options/1_22/init.d.ts.map +1 -0
- package/esm/options/1_22/init.js +2 -0
- package/esm/options/1_22/init.js.map +1 -0
- package/esm/options/1_22/options.d.ts +29 -28
- package/esm/options/1_22/options.d.ts.map +1 -1
- package/esm/options/1_22/options.js +25 -25
- package/esm/options/1_22/options.js.map +1 -1
- package/esm/options/1_22/scroll.d.ts +16 -16
- package/esm/options/1_22/scroll.d.ts.map +1 -1
- package/esm/options/1_22/scroll.js +14 -14
- package/esm/options/1_23.d.ts +12 -11
- package/esm/options/1_23.d.ts.map +1 -1
- package/esm/options/1_23.js +34 -34
- package/esm/options/1_23.js.map +1 -1
- package/esm/options/1_24.d.ts +9 -8
- package/esm/options/1_24.d.ts.map +1 -1
- package/esm/options/1_24.js +12 -12
- package/esm/options/1_24.js.map +1 -1
- package/esm/options/1_25/index.d.ts +2 -2
- package/esm/options/1_25/index.js +2 -2
- package/esm/options/1_25/options.d.ts +6 -5
- package/esm/options/1_25/options.d.ts.map +1 -1
- package/esm/options/1_25/options.js +7 -7
- package/esm/options/1_25/options.js.map +1 -1
- package/esm/options/1_25/scroll.d.ts +19 -18
- package/esm/options/1_25/scroll.d.ts.map +1 -1
- package/esm/options/1_25/scroll.js +32 -32
- package/esm/options/1_25/scroll.js.map +1 -1
- package/esm/options/1_26.d.ts +57 -0
- package/esm/options/1_26.d.ts.map +1 -0
- package/esm/options/1_26.js +67 -0
- package/esm/options/1_26.js.map +1 -0
- package/esm/options/2.d.ts +57 -0
- package/esm/options/2.d.ts.map +1 -0
- package/esm/options/2.js +67 -0
- package/esm/options/2.js.map +1 -0
- package/esm/options/2_0.d.ts +87 -0
- package/esm/options/2_0.d.ts.map +1 -0
- package/esm/options/2_0.js +175 -0
- package/esm/options/2_0.js.map +1 -0
- package/esm/options/codec.d.ts +52 -0
- package/esm/options/codec.d.ts.map +1 -0
- package/esm/options/codec.js +26 -0
- package/esm/options/codec.js.map +1 -0
- package/esm/options/index.d.ts +8 -8
- package/esm/options/index.js +8 -8
- package/esm/options/latest.d.ts +12 -0
- package/esm/options/latest.d.ts.map +1 -0
- package/esm/options/latest.js +8 -0
- package/esm/options/latest.js.map +1 -0
- package/esm/options/types.d.ts +46 -46
- package/esm/options/types.d.ts.map +1 -1
- package/esm/options/types.js +17 -17
- package/package.json +11 -10
- package/src/adb/client.ts +72 -88
- package/src/adb/connection.ts +42 -25
- package/src/adb/index.ts +3 -3
- package/src/adb/options/1_16.ts +6 -4
- package/src/adb/options/1_22.ts +3 -3
- package/src/adb/options/index.ts +3 -3
- package/src/adb/options/types.ts +10 -10
- package/src/control/back-or-screen-on.ts +1 -1
- package/src/control/hover-helper.ts +2 -4
- package/src/control/inject-keycode.ts +193 -48
- package/src/control/inject-scroll.ts +1 -1
- package/src/control/inject-text.ts +7 -8
- package/src/control/inject-touch.ts +1 -1
- package/src/control/rotate-device.ts +7 -6
- package/src/control/serializer.ts +29 -26
- package/src/control/set-clipboard.ts +1 -1
- package/src/control/set-screen-power-mode.ts +7 -8
- package/src/device-message/ack-clipboard.ts +1 -1
- package/src/device-message/clipboard.ts +1 -1
- package/src/index.ts +5 -5
- package/src/options/1_16/codec-options.ts +4 -6
- package/src/options/1_16/options.ts +17 -12
- package/src/options/1_16/scroll.ts +2 -4
- package/src/options/1_18.ts +6 -6
- package/src/options/1_21.ts +5 -6
- package/src/options/1_22/options.ts +3 -2
- package/src/options/1_22/scroll.ts +1 -1
- package/src/options/1_23.ts +3 -5
- package/src/options/1_24.ts +5 -3
- package/src/options/1_25/options.ts +3 -2
- package/src/options/1_25/scroll.ts +4 -7
- package/src/options/index.ts +3 -3
- package/src/options/types.ts +8 -8
- 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
|
|
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(
|
|
88
|
-
const path: string = require.resolve(
|
|
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
|
|
96
|
-
import { createRequire } from
|
|
95
|
+
import fs from "node:fs/promises";
|
|
96
|
+
import { createRequire } from "node:module";
|
|
97
97
|
|
|
98
|
-
const path: string = createRequire(import.meta.url).resolve(
|
|
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
|
-
|
|
106
|
+
Or with the `--experimental-import-meta-resolve` command line flag, you can use `import.meta.resolve`:
|
|
105
107
|
|
|
106
108
|
```ts
|
|
107
|
-
|
|
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
|
|
116
|
-
const buffer: ArrayBuffer = await fetch(SCRCPY_SERVER_URL).then(
|
|
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(
|
|
125
|
-
|
|
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
|
|
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 `
|
|
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 `
|
|
185
|
+
Example using a `ReadableStream`:
|
|
172
186
|
|
|
173
187
|
```ts
|
|
174
|
-
import {
|
|
188
|
+
import { WrapReadableStream } from "@yume-chan/adb";
|
|
189
|
+
import { AdbScrcpyClient } from "@yume-chan/scrcpy";
|
|
175
190
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
await
|
|
179
|
-
|
|
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 `
|
|
202
|
+
Example using an `ArrayBuffer`:
|
|
183
203
|
|
|
184
204
|
```ts
|
|
185
|
-
import {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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 {
|
|
202
|
-
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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> =
|
|
215
|
-
|
|
216
|
-
const
|
|
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
|
|
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> =
|
|
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 {
|
|
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(
|
|
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 {
|
|
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> =
|
|
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(
|
|
302
|
-
|
|
303
|
-
|
|
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(
|
|
310
|
-
|
|
311
|
-
|
|
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:
|
|
373
|
+
type: "configuration";
|
|
324
374
|
data: H264Configuration;
|
|
325
375
|
}
|
|
326
376
|
|
|
327
377
|
export interface ScrcpyVideoStreamFramePacket {
|
|
328
|
-
type:
|
|
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
|
-
|
|
340
|
-
|
|
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
|
+
export default '2.0';
|
package/bin/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '
|
|
1
|
+
export default '2.0';
|
package/esm/adb/client.d.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ScrcpyControlMessageSerializer } from "../control/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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,
|
|
13
|
-
static start(adb: Adb, path: string, version: string, options: AdbScrcpyOptions<
|
|
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<
|
|
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<
|
|
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<
|
|
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
|
package/esm/adb/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/adb/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/adb/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAKjE,OAAO,KAAK,EACR,UAAU,EACV,cAAc,EACd,oBAAoB,EACvB,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EACR,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAwB3D,qBAAa,iBAAkB,SAAQ,KAAK;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEL,MAAM,EAAE,MAAM,EAAE;CAItC;AAED,qBAAa,eAAe;WACJ,UAAU,CAC1B,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAC5C,QAAQ,SAAsB;WAad,KAAK,CACrB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC;IAyFpD;;;OAGG;WACiB,WAAW,CAC3B,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,GACjD,OAAO,CAAC,MAAM,EAAE,CAAC;IA+BpB;;;OAGG;WACiB,WAAW,CAC3B,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,GACjD,OAAO,CAAC,MAAM,EAAE,CAAC;IA8BpB,OAAO,CAAC,OAAO,CAAwB;IAEvC,OAAO,CAAC,OAAO,CAAyB;IACxC,IAAW,MAAM,2BAEhB;IAED,IAAW,IAAI,oBAEd;IAED,OAAO,CAAC,YAAY,CAAqB;IACzC,IAAW,WAAW,uBAErB;IAED,OAAO,CAAC,aAAa,CAAqB;IAC1C,IAAW,YAAY,uBAEtB;IAED,OAAO,CAAC,YAAY,CAA0C;IAC9D,IAAW,WAAW,4CAErB;IAED,OAAO,CAAC,yBAAyB,CAEjB;IAChB,IAAW,wBAAwB,+CAElC;IAED,OAAO,CAAC,oBAAoB,CAEZ;IAChB,IAAW,mBAAmB,oDAE7B;gBAGG,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,EAChD,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAC9B,WAAW,EAAE,cAAc,CAAC,UAAU,CAAC,EACvC,aAAa,EACP,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,GACxD,SAAS;IA2BN,KAAK;CAGrB"}
|