serve-sim 0.1.23 → 0.1.25

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 CHANGED
@@ -48,6 +48,17 @@ serve-sim ca-debug <option> <on|off> [-d udid]
48
48
  (blended|copies|misaligned|offscreen|slow-animations)
49
49
  serve-sim memory-warning [-d udid] Simulate a memory warning
50
50
 
51
+ serve-sim camera <bundle-id> [-d udid] [source-options]
52
+ Inject a synthetic camera feed and (re)launch the app
53
+ serve-sim camera switch <placeholder|webcam|file> [arg] [-d udid]
54
+ Hot-swap the running helper's source (no relaunch)
55
+ serve-sim camera mirror <auto|on|off> [-d udid]
56
+ Hot-swap preview-layer mirror mode
57
+ serve-sim camera status [-d udid] Print helper state as JSON ({alive, source, ...})
58
+ serve-sim camera --list-webcams List host camera devices
59
+ serve-sim camera --stop-webcam [-d udid]
60
+ Stop the camera helper for a device
61
+
51
62
  Options:
52
63
  -p, --port <port> Starting port (preview default: 3200, stream default: 3100)
53
64
  -d, --detach Spawn helper and exit (daemon mode)
@@ -55,6 +66,17 @@ Options:
55
66
  --no-preview Skip the web UI; stream in foreground only
56
67
  --list [device] List running streams
57
68
  --kill [device] Kill running stream(s)
69
+
70
+ Camera options (used with `serve-sim camera <bundle-id>`):
71
+ -f, --file <path> Image or video file (kind auto-detected from
72
+ extension/magic bytes; videos loop at native FPS)
73
+ --webcam [name] Live host webcam (defaults to the built-in
74
+ front camera when [name] is omitted)
75
+ --mirror [on|off|auto] Override preview-layer mirroring (default: auto =
76
+ front mirrored, back not). Data-output buffers
77
+ are never auto-mirrored, matching AVF defaults.
78
+ --no-mirror Shortcut for --mirror off
79
+ --build Rebuild the dylib + helper from source
58
80
  ```
59
81
 
60
82
  ### Examples
@@ -65,10 +87,40 @@ serve-sim "iPhone 16 Pro" # target a specific device
65
87
  serve-sim --detach # start a background helper, return JSON
66
88
  serve-sim --list # show running streams
67
89
  serve-sim --kill # stop all helpers
90
+
91
+ # Camera injection
92
+ serve-sim camera com.acme.MyApp # animated placeholder
93
+ serve-sim camera com.acme.MyApp --webcam # default webcam
94
+ serve-sim camera com.acme.MyApp --webcam "MacBook Pro Camera"
95
+ serve-sim camera com.acme.MyApp --file ~/Pictures/face.png # static image
96
+ serve-sim camera com.acme.MyApp --file ~/Movies/loop.mp4 # looping video
97
+
98
+ # Hot-swap source on a running helper (no app relaunch)
99
+ serve-sim camera switch placeholder
100
+ serve-sim camera switch webcam
101
+ serve-sim camera switch ~/Movies/loop.mp4 # auto-detects file kind
102
+
103
+ # Other helpers
104
+ serve-sim camera mirror on
105
+ serve-sim camera status # JSON: alive, source, mirror
106
+ serve-sim camera --list-webcams
107
+ serve-sim camera --stop-webcam
68
108
  ```
69
109
 
70
110
  Multiple booted simulators are supported — pass several device names, or leave it empty to attach to all of them.
71
111
 
112
+ ### Camera
113
+
114
+ `serve-sim camera <bundle-id>` replaces the simulator's camera feed for a single app. A small host-side helper writes BGRA frames into a POSIX shared-memory region; an injected dylib (`DYLD_INSERT_LIBRARIES`) swizzles AVFoundation inside the simulator process so the app reads from that region instead of the simulator's stub camera.
115
+
116
+ The helper is one-per-device and outlives any single app launch, so multiple apps on the same simulator can share the feed — just run `serve-sim camera <other-bundle-id>` again to relaunch the next app with the dylib attached. Source changes (`camera switch`) and mirror changes (`camera mirror`) flow through the helper's control socket and don't relaunch the app.
117
+
118
+ Sources:
119
+
120
+ - **placeholder** — animated programmatic frames (default).
121
+ - **file** — image (PNG/JPEG/HEIC/…) or video (mp4/mov/m4v/webm/…). The CLI sniffs the kind from the extension and falls back to magic bytes for files without an extension.
122
+ - **webcam** — live `AVCaptureDevice` (built-in, Continuity, external).
123
+
72
124
  ## Connectors
73
125
 
74
126
  `serve-sim` can be used with dev servers, browser, and AI editors for more seamless integration.
@@ -82,10 +134,10 @@ Create a `.claude/launch.json` and define a server:
82
134
  "version": "0.0.1",
83
135
  "configurations": [
84
136
  {
85
- "name": "ios",
137
+ "name": "Apple",
86
138
  "runtimeExecutable": "npx",
87
139
  "runtimeArgs": ["serve-sim"],
88
- "url": "http://localhost:8081/.sim"
140
+ "port": 3200
89
141
  }
90
142
  ]
91
143
  }
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ HERE="$(cd "$(dirname "$0")" && pwd)"
4
+ OUT_DIR="${1:-$HERE/../../dist/simcam}"
5
+ mkdir -p "$OUT_DIR"
6
+
7
+ SDK="$(xcrun --sdk macosx --show-sdk-path)"
8
+ BIN="$OUT_DIR/serve-sim-camera-helper"
9
+
10
+ xcrun --sdk macosx clang \
11
+ -arch arm64 -arch x86_64 \
12
+ -mmacosx-version-min=12.0 \
13
+ -isysroot "$SDK" \
14
+ -fobjc-arc -fmodules \
15
+ -framework Foundation \
16
+ -framework AVFoundation \
17
+ -framework CoreMedia \
18
+ -framework CoreVideo \
19
+ -framework CoreGraphics \
20
+ -framework CoreImage \
21
+ -framework CoreText \
22
+ -framework ImageIO \
23
+ -framework Accelerate \
24
+ -O2 \
25
+ -o "$BIN" \
26
+ "$HERE/main.m"
27
+
28
+ # Re-sign so the camera privacy prompt persists per-build instead of restarting.
29
+ codesign -s - -f "$BIN" 2>/dev/null || true
30
+
31
+ echo "Built: $BIN"
32
+ file "$BIN"