serve-emul 0.0.4
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.md +29 -0
- package/LICENSE +201 -0
- package/README.md +196 -0
- package/dist/ui/assets/index-Cm5-Tjhs.css +1 -0
- package/dist/ui/assets/index-CyUIa9dV.js +42 -0
- package/dist/ui/index.html +13 -0
- package/package.json +67 -0
- package/scripts/fetch-scrcpy.ts +28 -0
- package/scripts/release.ts +136 -0
- package/src/accessibility.ts +88 -0
- package/src/adb.ts +209 -0
- package/src/app-info.ts +114 -0
- package/src/app-management.ts +150 -0
- package/src/cli.ts +149 -0
- package/src/emulator.ts +229 -0
- package/src/input.ts +258 -0
- package/src/location.ts +135 -0
- package/src/route-playback.ts +359 -0
- package/src/scrcpy.ts +466 -0
- package/src/server.ts +1260 -0
- package/src/session-recorder.ts +149 -0
- package/src/ui/app.tsx +111 -0
- package/src/ui/components/accessibility-panel.tsx +113 -0
- package/src/ui/components/app-management-panel.tsx +256 -0
- package/src/ui/components/control-bar.tsx +24 -0
- package/src/ui/components/device-panel.tsx +532 -0
- package/src/ui/components/device-stream.tsx +142 -0
- package/src/ui/components/location-panel.tsx +584 -0
- package/src/ui/components/logcat-panel.tsx +100 -0
- package/src/ui/components/session-panel.tsx +127 -0
- package/src/ui/components/status-bar.tsx +19 -0
- package/src/ui/index.html +12 -0
- package/src/ui/lib/h264.ts +35 -0
- package/src/ui/lib/use-stream.ts +368 -0
- package/src/ui/main.tsx +7 -0
- package/src/ui/styles.css +708 -0
- package/src/ui/tsconfig.json +17 -0
- package/src/update-check.ts +93 -0
- package/vendor/scrcpy-server-v2.7 +0 -0
- package/vendor/scrcpy-server-v3.1 +0 -0
- package/vendor/scrcpy-server-v3.3.4 +0 -0
- package/vendor/scrcpy-server-v4.0 +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `serve-emul` are documented here.
|
|
4
|
+
|
|
5
|
+
This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html):
|
|
6
|
+
|
|
7
|
+
- `patch` for fixes and small internal improvements
|
|
8
|
+
- `minor` for backwards-compatible user-facing features or APIs
|
|
9
|
+
- `major` for breaking CLI, HTTP API, WebSocket protocol, package, or runtime behavior
|
|
10
|
+
|
|
11
|
+
## 0.0.4 - 2026-06-21
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Release helper for patch, minor, major, and exact-version bumps.
|
|
16
|
+
- Release validation script that runs tests, server typecheck, UI typecheck, and the production UI build.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Bump the package version from 0.0.3 to 0.0.4.
|
|
21
|
+
- Document the release process and align README status text with the package version.
|
|
22
|
+
|
|
23
|
+
## 0.0.3 - 2026-06-21
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Device orientation, night mode, font scale, and multi-device routing controls.
|
|
28
|
+
- Logcat streaming, accessibility inspection, app management, route playback, and session replay workflows.
|
|
29
|
+
- H.264 WebSocket streaming with WebCodecs browser decoding and REST/WebSocket input controls.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 serve-emul contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# serve-emul
|
|
2
|
+
|
|
3
|
+
The `npx serve` of Android devices.
|
|
4
|
+
|
|
5
|
+
Host your Android emulator (or real device) for use with agent tools like Codex, Cursor, or Claude Desktop — locally, over your LAN, or tunnel anywhere.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bunx serve-emul@latest
|
|
9
|
+
# or: npx serve-emul@latest
|
|
10
|
+
# → Preview at http://localhost:3300
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Use `@latest` for one-off runs so Bun/npm fetches the newest published version instead of reusing a cached or locally installed copy.
|
|
14
|
+
|
|
15
|
+
`serve-emul` spawns the scrcpy server on the device, opens an adb forward tunnel, pipes H.264 frames over a WebSocket, and decodes them in the browser with WebCodecs. Input events flow back over the same socket to scrcpy's control channel.
|
|
16
|
+
|
|
17
|
+
## Package Rename
|
|
18
|
+
|
|
19
|
+
The npm package name is `serve-emul`. npm package names cannot be renamed in place, so releases under this name should be published as a new package:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm publish --workspace packages/serve-emul
|
|
23
|
+
npm deprecate serve-emu "Package renamed to serve-emul. Use: npm install serve-emul"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Status
|
|
27
|
+
|
|
28
|
+
Current package version: see [`package.json`](package.json) and [`CHANGELOG.md`](CHANGELOG.md).
|
|
29
|
+
|
|
30
|
+
Working:
|
|
31
|
+
|
|
32
|
+
- Live H.264 video stream from device → WebCodecs canvas
|
|
33
|
+
- Taps, swipes, hardware buttons (Back / Home / Recents / Power)
|
|
34
|
+
- Text injection, keyevents
|
|
35
|
+
- Multi-client (multiple browser tabs share one stream)
|
|
36
|
+
- Auto-replay of SPS/PPS to clients joining mid-stream
|
|
37
|
+
- Emulator GPS location control from the browser UI and `POST /api/location`
|
|
38
|
+
- Route playback from GPX, GeoJSON, KML, or waypoint JSON
|
|
39
|
+
- Logcat forwarding over SSE with browser-side filter, pause, and copy controls
|
|
40
|
+
- Network on/off control from the browser UI and `POST /api/network`
|
|
41
|
+
- Agent-friendly REST input APIs plus session event replay
|
|
42
|
+
- App management controls for APK install, launch, clear data, force stop, and permission grants
|
|
43
|
+
|
|
44
|
+
Planned:
|
|
45
|
+
|
|
46
|
+
- Multi-device routing
|
|
47
|
+
- Embeddable Connect-style middleware (`serve-emul/middleware`)
|
|
48
|
+
- Compiled single binary
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
- Node.js 18+ or Bun 1.1+
|
|
53
|
+
- `adb` on PATH (Android platform-tools)
|
|
54
|
+
- A booted device/emulator (`adb devices` shows it), or an AVD name passed with `--avd`
|
|
55
|
+
- Chrome / Edge / Safari 16.4+ (for WebCodecs)
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
bun install
|
|
61
|
+
bun run --filter serve-emul setup # downloads scrcpy-server-v4.0 into vendor/
|
|
62
|
+
bun run packages/serve-emul/src/cli.ts
|
|
63
|
+
# → http://localhost:3300
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The `setup` step is also run lazily on first start, so you can skip it.
|
|
67
|
+
|
|
68
|
+
## CLI
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
serve-emul [-p <port>] [-s <serial>] [--max-fps N] [--bit-rate N] [--max-size N] [--key-frame-interval sec]
|
|
72
|
+
serve-emul --avd <name> [--restart-avd]
|
|
73
|
+
serve-emul --avd-list
|
|
74
|
+
serve-emul --running-avds
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| flag | default | meaning |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `-p, --port` | `3300` | HTTP port for the preview server |
|
|
80
|
+
| `-s, --serial` | auto | adb device serial (only required when multiple devices are attached) |
|
|
81
|
+
| `--max-fps` | `60` | cap source frame rate |
|
|
82
|
+
| `--bit-rate` | `8000000` | H.264 bit rate in bps |
|
|
83
|
+
| `--max-size` | `1920` | downscale longest edge to N pixels; `0` = native (encoders on many emulators reject above ~2560, so the default trims) |
|
|
84
|
+
| `--key-frame-interval` | `1` | ask the encoder for regular keyframes so clients can recover without resetting video capture; `0` disables this codec option |
|
|
85
|
+
| `--avd` | none | launch this Android Virtual Device before streaming |
|
|
86
|
+
| `--restart-avd` | false | stop a running matching AVD before launching it |
|
|
87
|
+
| `--avd-list` | false | list available Android Virtual Device names |
|
|
88
|
+
| `--running-avds` | false | list currently running emulator serials and AVD names |
|
|
89
|
+
| `--emulator` | auto | Android Emulator binary path; defaults to PATH or Android SDK env vars |
|
|
90
|
+
| `--emulator-port` | auto | emulator console port for `--avd`; must be an even port from 5554 through 5682 |
|
|
91
|
+
|
|
92
|
+
## HTTP API
|
|
93
|
+
|
|
94
|
+
Set an Android Emulator GPS fix:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
curl -X POST http://localhost:3300/api/location \
|
|
98
|
+
-H 'Content-Type: application/json' \
|
|
99
|
+
-d '{"latitude":37.5665,"longitude":126.978}'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Location control uses the Android Emulator `geo fix` command and is currently emulator-only.
|
|
103
|
+
|
|
104
|
+
Start route playback from waypoints:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
curl -X POST http://localhost:3300/api/route \
|
|
108
|
+
-H 'Content-Type: application/json' \
|
|
109
|
+
-d '{"speedKph":30,"multiplier":1,"loop":false,"waypoints":[{"latitude":37.5665,"longitude":126.978},{"latitude":37.5651,"longitude":126.98955}]}'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Pause, resume, or stop playback:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
curl -X POST http://localhost:3300/api/route/control \
|
|
116
|
+
-H 'Content-Type: application/json' \
|
|
117
|
+
-d '{"action":"pause"}'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Drive the device with REST:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
curl -X POST http://localhost:3300/api/tap \
|
|
124
|
+
-H 'Content-Type: application/json' \
|
|
125
|
+
-d '{"x":0.5,"y":0.5}'
|
|
126
|
+
|
|
127
|
+
curl -X POST http://localhost:3300/api/text \
|
|
128
|
+
-H 'Content-Type: application/json' \
|
|
129
|
+
-d '{"text":"hello"}'
|
|
130
|
+
|
|
131
|
+
curl http://localhost:3300/api/screenshot --output screen.png
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Stream logcat over SSE:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
curl -N 'http://localhost:3300/api/logcat?package=com.example.app&search=error'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Toggle device network:
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
curl http://localhost:3300/api/network
|
|
144
|
+
|
|
145
|
+
curl -X POST http://localhost:3300/api/network \
|
|
146
|
+
-H 'Content-Type: application/json' \
|
|
147
|
+
-d '{"enabled":false}'
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Replay recorded input and location events:
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
curl -X POST http://localhost:3300/api/session/replay \
|
|
154
|
+
-H 'Content-Type: application/json' \
|
|
155
|
+
-d '{"multiplier":2}'
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Manage apps:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
curl -X POST http://localhost:3300/api/apps/install \
|
|
162
|
+
-F apk=@/path/to/app.apk
|
|
163
|
+
|
|
164
|
+
curl -X POST http://localhost:3300/api/apps/launch \
|
|
165
|
+
-H 'Content-Type: application/json' \
|
|
166
|
+
-d '{"packageName":"com.example.app","activity":".MainActivity"}'
|
|
167
|
+
|
|
168
|
+
curl -X POST http://localhost:3300/api/apps/clear \
|
|
169
|
+
-H 'Content-Type: application/json' \
|
|
170
|
+
-d '{"packageName":"com.example.app"}'
|
|
171
|
+
|
|
172
|
+
curl -X POST http://localhost:3300/api/apps/grant \
|
|
173
|
+
-H 'Content-Type: application/json' \
|
|
174
|
+
-d '{"packageName":"com.example.app","permission":"android.permission.POST_NOTIFICATIONS"}'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## How it works
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
┌──────────────────┐ adb forward ┌─────────────┐ H264 / WS ┌─────────┐
|
|
181
|
+
│ scrcpy-server.jar│ ◄──────────► │ serve-emul │ ────────────► │ Browser │
|
|
182
|
+
│ on device │ TCP tunnel │ (Bun) │ WebCodecs │ <canvas>│
|
|
183
|
+
│ • video socket │ │ │ ◄──────────── │ │
|
|
184
|
+
│ • control socket│ │ │ input JSON │ │
|
|
185
|
+
└──────────────────┘ └─────────────┘ └─────────┘
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
1. The CLI pushes `scrcpy-server-v4.0` to `/data/local/tmp/scrcpy-server.jar`.
|
|
189
|
+
2. It opens `adb forward tcp:<localPort> localabstract:scrcpy_<scid>`.
|
|
190
|
+
3. It spawns `app_process` with the scrcpy server class on the device, then connects two sockets through the tunnel: video and control.
|
|
191
|
+
4. The Bun server reads scrcpy's framed H.264 stream (12-byte header + Annex-B payload) and forwards each Access Unit as a binary WebSocket message. Raw `/ws` clients receive the Annex-B payload unchanged; the built-in browser UI opts into a 16-byte frame metadata header with keyframe and PTS data.
|
|
192
|
+
5. The browser configures a `VideoDecoder` from the SPS, uses server-provided frame metadata to avoid per-frame NAL scans, and draws frames to a `<canvas>`. Pointer events are normalized to device coordinates and written back to scrcpy's control socket as 32-byte touch packets.
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
Apache-2.0. Bundles the upstream [scrcpy](https://github.com/Genymobile/scrcpy) server binary (Apache-2.0) at runtime.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,system-ui,sans-serif}body{margin:0;min-height:100vh;background:#0b0b0e;color:#e5e5ea;display:grid;grid-template-rows:auto 1fr auto}header{padding:12px 16px;border-bottom:1px solid #1f1f24;display:flex;gap:12px;align-items:center;justify-content:space-between}header h1{font-size:14px;font-weight:600;margin:0;letter-spacing:.02em}header .meta{font-size:12px;color:#8a8a93;font-variant-numeric:tabular-nums}main{display:grid;grid-template-columns:minmax(0,1fr) 380px;align-items:center;gap:20px;padding:24px}.app-layout{min-height:0;align-items:stretch;transition:grid-template-columns .18s ease}.app-layout.devices-open{grid-template-columns:300px minmax(0,1fr) 380px}.app-layout.devices-collapsed{grid-template-columns:46px minmax(0,1fr) 380px}.device-sidebar{align-self:stretch;min-height:0;max-height:calc(100vh - 140px);overflow:hidden;border-right:1px solid #1f1f24;padding-right:16px;display:flex;flex-direction:column;gap:12px}.device-sidebar-header{display:flex;align-items:center;gap:8px;min-height:34px;color:#b8b8c0;font-size:13px;font-weight:700}.sidebar-toggle{display:grid;place-items:center;width:32px;height:32px;padding:0;border-radius:8px;line-height:1}.sidebar-icon{width:18px;height:18px;color:#b8b8c0}.sidebar-icon.collapsed{transform:scaleX(-1)}.devices-collapsed .device-sidebar{align-items:center;padding-right:0}.devices-collapsed .device-sidebar-header{justify-content:center}.device{justify-self:center;align-self:center;position:relative;max-width:100%;background:#000;border-radius:24px;overflow:hidden;box-shadow:0 30px 80px #0009}canvas{display:block;max-height:80vh;max-width:100%;height:auto;cursor:default;-webkit-user-select:none;user-select:none;touch-action:none}.stream-surface{position:relative}.ax-overlay{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none}.ax-box{position:absolute;box-sizing:border-box;border:1px solid rgba(92,200,255,.58);background:#5cc8ff14}.ax-box.active{border-color:#fc6;background:#ffcc662e;box-shadow:0 0 0 1px #ffcc6659}footer{display:flex;gap:8px;padding:12px 16px;border-top:1px solid #1f1f24;justify-content:center}button{background:#1c1c22;color:#e5e5ea;border:1px solid #2a2a32;border-radius:8px;padding:8px 14px;font-size:13px;cursor:pointer}button:hover{background:#25252d}button:disabled{cursor:not-allowed;opacity:.55}input{box-sizing:border-box;width:100%;background:#111116;color:#f2f2f7;border:1px solid #2a2a32;border-radius:8px;padding:8px 10px;font-size:13px;font-variant-numeric:tabular-nums}input[type=file]{color:#b8b8c0;padding:7px}input[type=checkbox]{width:16px;height:16px;accent-color:#f2f2f7}.side-panel{align-self:stretch;min-height:0;max-height:calc(100vh - 140px);overflow:auto;border-left:1px solid #1f1f24;padding-left:20px;display:flex;flex-direction:column;gap:16px}.device-panel{min-height:0;display:flex;flex-direction:column;gap:12px}.device-sidebar .device-panel{flex:1}.location-panel,.tool-panel{display:flex;flex-direction:column;gap:12px}.panel-heading{display:flex;justify-content:space-between;gap:12px;align-items:baseline}.panel-heading h2{margin:0;font-size:14px;font-weight:600}.location-status{min-width:0;color:#9a9aa3;font-size:12px;line-height:1.35;text-align:right;overflow-wrap:anywhere}.map{position:relative;height:220px;overflow:hidden;border:1px solid #25252d;border-radius:8px;background:#15151a;cursor:crosshair;-webkit-user-select:none;user-select:none;touch-action:none}.map-tile{position:absolute;width:256px;height:256px;-webkit-user-select:none;user-select:none;pointer-events:none}.map-marker{position:absolute;left:0;top:0;width:18px;height:18px;margin:-18px 0 0 -9px;pointer-events:none}.map-marker:before{content:"";position:absolute;left:4px;top:1px;width:10px;height:10px;background:#ff4d5e;border:2px solid #ffffff;border-radius:50%;box-shadow:0 2px 10px #00000080}.map-marker:after{content:"";position:absolute;left:8px;top:12px;width:2px;height:9px;background:#fff;border-radius:2px;box-shadow:0 2px 8px #00000080}.route-overlay{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;pointer-events:none}.route-overlay polyline{fill:none;stroke:#1f8bff;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;paint-order:stroke;filter:drop-shadow(0 1px 2px rgba(0,0,0,.7))}.map-attribution{position:absolute;right:6px;bottom:5px;padding:2px 5px;border-radius:4px;background:#0b0b0eb3;color:#d8d8de;font-size:10px;pointer-events:none}.map-controls,.preset-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.coordinate-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.coordinate-grid label,.stacked-field{display:grid;gap:5px;color:#9a9aa3;font-size:11px}.primary-action{width:100%;background:#f2f2f7;color:#0b0b0e;border-color:#f2f2f7;font-weight:600}.primary-action:hover{background:#fff}.route-panel{display:flex;flex-direction:column;gap:10px;border-top:1px solid #1f1f24;padding-top:12px}.route-meta{color:#9a9aa3;font-size:12px;font-variant-numeric:tabular-nums}.toggle-row{display:flex;align-items:center;gap:8px;color:#d8d8de;font-size:13px}.route-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.panel-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.app-actions{grid-template-columns:repeat(3,minmax(0,1fr))}.ax-actions{grid-template-columns:repeat(2,minmax(0,1fr))}.ax-list{display:grid;gap:6px;max-height:220px;overflow:auto;padding-right:2px}.ax-node{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;min-width:0;padding:7px 8px;text-align:left}.ax-node.active{border-color:#5cc8ff;background:#18303d}.ax-node span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ax-node code{color:#9a9aa3;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:10px}.ax-empty{padding:12px;border:1px dashed #2a2a32;border-radius:8px;color:#8a8a93;font-size:12px;text-align:center}.device-list{display:grid;gap:6px}.device-search{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px}.device-search button{padding-inline:10px}.android-grid-list{flex:1;min-height:0;max-height:none;overflow:auto;padding-right:2px;align-content:start;align-items:start}.device-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;padding:8px 10px;border:1px solid #25252d;border-radius:8px;background:#111116}.device-row.current{border-color:#3f7d5c;background:#132219}.grid-device-row{grid-template-columns:minmax(0,1fr) auto;align-items:center;min-height:58px;padding:8px}.device-row-main{display:grid;grid-template-columns:34px minmax(0,1fr);grid-template-rows:auto auto;column-gap:10px;align-items:center;min-width:0;padding:0;border:0;background:transparent;text-align:left}.device-row-main:hover{background:transparent}.device-kind{grid-row:1 / 3;display:grid;place-items:center;width:34px;height:34px;border-radius:8px;background:#1c1c22;color:#8a8a93;font-size:11px;font-weight:700;letter-spacing:0;text-transform:none}.device-kind:first-letter{text-transform:uppercase}.device-row .device-name{color:#f2f2f7;font-size:12px;font-weight:600}.device-subtitle{color:#9a9aa3;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:10px}.device-row-actions{display:flex;flex-direction:row;gap:8px;align-items:flex-end;justify-content:center}.device-row-actions button{min-width:52px;padding:5px 8px;font-size:11px}.device-row span{min-width:0;overflow:hidden;color:#f2f2f7;font-size:12px;text-overflow:ellipsis;white-space:nowrap}.device-row code{color:#9a9aa3;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:10px}.device-empty{padding:12px;border:1px dashed #2a2a32;border-radius:8px;color:#8a8a93;font-size:12px;text-align:center}.segmented-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.segmented-row button{min-width:0;padding:8px 6px}.segmented-row button.selected{border-color:#3f7d5c;background:#173522;color:#f2f2f7}.network-row{grid-template-columns:repeat(2,minmax(0,1fr))}.font-scale-row{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.font-scale-row button{min-width:0;padding:8px 4px;font-size:12px}.font-scale-row button.selected{border-color:#3f7d5c;background:#173522;color:#f2f2f7}.foreground-card{display:grid;gap:8px;padding:10px;border:1px solid #25252d;border-radius:8px;background:#111116}.foreground-title{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}.foreground-title span{min-width:0;overflow:hidden;color:#f2f2f7;font-size:13px;font-weight:600;text-overflow:ellipsis;white-space:nowrap}.foreground-title button{flex:0 0 auto;padding:5px 9px;font-size:11px}.foreground-card dl{display:grid;gap:5px;margin:0}.foreground-card dl div{display:grid;grid-template-columns:72px minmax(0,1fr);gap:8px}.foreground-card dt{color:#8a8a93;font-size:11px}.foreground-card dd{min-width:0;margin:0;overflow:hidden;color:#d8d8de;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.foreground-empty{color:#8a8a93;font-size:12px;overflow-wrap:anywhere}.file-drop{display:grid;gap:4px;padding:14px;border:1px dashed #34343d;border-radius:8px;background:#111116;color:#d8d8de;text-align:center}.file-drop.active{border-color:#5cc8ff;background:#13242d}.file-drop span{font-size:13px;font-weight:600}.file-drop small{color:#8a8a93;font-size:11px}.logcat-output{box-sizing:border-box;height:220px;width:100%;margin:0;padding:10px;overflow:auto;border:1px solid #25252d;border-radius:8px;background:#070709;color:#d8d8de;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:11px;line-height:1.45;white-space:pre-wrap;overflow-wrap:anywhere}.session-list{display:grid;gap:6px;color:#d8d8de;font-size:12px}.session-list div{display:grid;grid-template-columns:72px minmax(0,1fr);gap:8px;min-width:0;overflow-wrap:anywhere}.session-list span{color:#9a9aa3;font-variant-numeric:tabular-nums}@media (max-width: 920px){body{min-height:100dvh}main{grid-template-columns:1fr;align-items:start;padding:16px}.app-layout.devices-open,.app-layout.devices-collapsed{grid-template-columns:1fr}.device-sidebar{border-right:0;border-bottom:1px solid #1f1f24;padding-right:0;padding-bottom:16px;width:min(100%,520px);max-height:360px;justify-self:center}.devices-collapsed .device-sidebar{max-height:none;padding-bottom:8px}.devices-collapsed .device-sidebar-header{flex-direction:row}.side-panel{border-left:0;border-top:1px solid #1f1f24;padding-left:0;padding-top:16px;width:min(100%,520px);max-height:none;justify-self:center}canvas{max-width:100%;max-height:60vh}}
|