serve-sim 0.1.43 → 0.1.44-beta.91.2
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/README.md +20 -3
- package/bin/serve-sim-bin +0 -0
- package/dist/middleware.js +42 -28
- package/dist/serve-sim.js +84 -66
- package/package.json +2 -2
- package/src/middleware.ts +455 -67
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ I develop the Expo framework, but this tool is completely agnostic to React Nati
|
|
|
31
31
|
|
|
32
32
|
## Install
|
|
33
33
|
|
|
34
|
-
Requires macOS with Xcode command line tools (`xcrun simctl`) and Node.js
|
|
34
|
+
Requires macOS with Xcode command line tools (`xcrun simctl`) and a [maintained Node.js LTS release](https://nodejs.org/en/about/previous-releases) (currently Node 20+). Older or end-of-life Node versions are not supported. `bun` is **not** required to run the CLI. Camera injection uses a host-side helper built for macOS 14+.
|
|
35
35
|
|
|
36
36
|
> **Note:** Apple Silicon (arm64) only. The bundled `serve-sim-bin` helper ships as an arm64 binary and does not run on Intel (x86_64) Macs.
|
|
37
37
|
|
|
@@ -64,10 +64,13 @@ serve-sim camera --stop-webcam [-d udid]
|
|
|
64
64
|
Stop the camera helper for a device
|
|
65
65
|
|
|
66
66
|
Options:
|
|
67
|
-
-p, --port <port> Starting port (preview default: 3200
|
|
67
|
+
-p, --port <port> Starting port (preview default: 3200; helper default: 3100)
|
|
68
68
|
-d, --detach Spawn helper and exit (daemon mode)
|
|
69
69
|
-q, --quiet JSON-only output
|
|
70
70
|
--no-preview Skip the web UI; stream in foreground only
|
|
71
|
+
--codec <codec> Stream codec for the preview UI: 'auto' (H.264 when the
|
|
72
|
+
browser can decode it) or 'mjpeg' (force software JPEG —
|
|
73
|
+
e.g. on VMs without H.264 encode)
|
|
71
74
|
--list [device] List running streams
|
|
72
75
|
--kill [device] Kill running stream(s)
|
|
73
76
|
|
|
@@ -206,7 +209,21 @@ app.use(simMiddleware({ basePath: "/.sim" }));
|
|
|
206
209
|
// → state JSON at /.sim/api
|
|
207
210
|
```
|
|
208
211
|
|
|
209
|
-
The middleware reads the helper's state from `$TMPDIR/serve-sim/` and
|
|
212
|
+
The middleware reads the helper's state from `$TMPDIR/serve-sim/` and points the browser at the helper's stream, interaction WebSocket, and WebKit DevTools endpoints. By default those URLs target the helper's own port directly (CORS is wide-open on the helper), so a plain `app.use(...)` mount works without touching your server's WebSocket handling.
|
|
213
|
+
|
|
214
|
+
### Single-port / remote proxying
|
|
215
|
+
|
|
216
|
+
To expose the preview to remote viewers behind a single port (the way standalone `serve-sim` does), pass `proxyHelpers: true`. The browser then reaches the stream, control socket, and DevTools through same-origin `/.sim/helper/<device>` and `/.sim/devtools` URLs, so the per-device helper port and inspect-webkit bridge can stay local to the host. This routes WebSockets through the middleware, so you must forward your server's `upgrade` events to `handleUpgrade`:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
const middleware = simMiddleware({ basePath: "/.sim", proxyHelpers: true });
|
|
220
|
+
app.use(middleware);
|
|
221
|
+
|
|
222
|
+
const server = app.listen(3000);
|
|
223
|
+
server.on("upgrade", (req, socket, head) => middleware.handleUpgrade(req, socket, head));
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
If you enable `proxyHelpers` but don't wire `upgrade`, the page still loads video over HTTP but loses simulator input and DevTools (their sockets never reach the proxy). When terminating TLS at a reverse proxy, forward `X-Forwarded-Proto` so the helper URLs use `https`/`wss` and avoid mixed-content blocks.
|
|
210
227
|
|
|
211
228
|
## How it works
|
|
212
229
|
|
package/bin/serve-sim-bin
CHANGED
|
Binary file
|