@limrun/ui 0.14.0-rc.1 → 0.14.0-rc.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.
@@ -14,6 +14,18 @@ interface RemoteControlProps {
14
14
  openUrl?: string;
15
15
  showFrame?: boolean;
16
16
  autoReconnect?: boolean;
17
+ /**
18
+ * Fires once when the component concludes the instance is permanently
19
+ * gone rather than suffering a recoverable connection blip.
20
+ *
21
+ * After a drop, the component probes the instance endpoint over HTTP;
22
+ * a 404 means the instance no longer exists (terminated/deleted). When
23
+ * that happens the component stops reconnecting and renders a built-in
24
+ * "terminated" message in place of the "Retry" button, and invokes this
25
+ * callback so the host can react (navigate away, surface its own UI,
26
+ * etc.). It is not called for ordinary network drops.
27
+ */
28
+ onTerminated?: () => void;
17
29
  /**
18
30
  * Enable the inspect overlay. When set, the component starts polling the
19
31
  * accessibility tree and draws boxes over each element on top of the
@@ -93,6 +105,150 @@ interface RemoteControlProps {
93
105
  * @default 2000
94
106
  */
95
107
  axMaxBackoffMs?: number;
108
+ /**
109
+ * Fires whenever the iOS simulator's camera demand state changes —
110
+ * i.e. an app inside the sim called
111
+ * `[AVCaptureSession startRunning]` or `[stopRunning]`. The
112
+ * component handles the `navigator.mediaDevices.getUserMedia` prompt
113
+ * and SDP plumbing internally; this callback is purely so the host
114
+ * UI can render a status indicator ("simulator is using your
115
+ * camera", etc.).
116
+ *
117
+ * `active` reflects whether the sim is currently asking for
118
+ * frames. `granted` is set only on the call that follows a
119
+ * `getUserMedia` attempt: `true` when the user accepted the
120
+ * browser prompt, `false` when they denied or the call failed
121
+ * (in which case the limulator side switches to a black-frame
122
+ * fallback so the app keeps ticking).
123
+ *
124
+ * `camera` (optional, only meaningful when `granted === true`)
125
+ * carries what `MediaStreamTrack.getSettings()` reported for the
126
+ * active capture: resolution, framerate, device label, facing
127
+ * mode. Use it to render a richer status indicator (e.g.
128
+ * "Camera · 1920×1080 · 30 fps · FaceTime HD").
129
+ *
130
+ * Only iOS instances ever fire this callback; Android instances
131
+ * have no camera-injector path and stay silent.
132
+ */
133
+ onCameraDemandChange?: (active: boolean, granted?: boolean, camera?: CameraCaptureInfo) => void;
134
+ /**
135
+ * Periodically (~1Hz) fires with a snapshot of the outbound
136
+ * camera stream's live WebRTC stats — codec, encoder
137
+ * implementation, hardware acceleration, encoded fps, bitrate,
138
+ * round-trip-time, and the encoder's
139
+ * `qualityLimitationReason` (which is what Meet/Zoom use to
140
+ * decide whether to show "Bandwidth limited" or "CPU limited"
141
+ * banners).
142
+ *
143
+ * Only fires while the simulator is actively pulling the
144
+ * camera AND `getUserMedia` was granted. `null` is emitted
145
+ * once when the stream goes back to idle so consumers can
146
+ * clear their UI without having to maintain their own
147
+ * timeout. The host app does not need to poll `getStats()`
148
+ * itself — this is the canonical place.
149
+ */
150
+ onCameraStats?: (stats: CameraStreamStats | null) => void;
151
+ /**
152
+ * Optional resolution cap for outbound camera capture.
153
+ *
154
+ * - `'auto'` (default): no extra constraint. The browser captures
155
+ * at its webcam's native max; WebRTC's quality scaler may step
156
+ * down resolution on the encoder side under bandwidth pressure
157
+ * while still feeding the simulator at the pool's native size.
158
+ * - `'1080p'` / `'720p'` / `'480p'`: hard cap applied via
159
+ * `getUserMedia` constraints (for new captures) and
160
+ * `track.applyConstraints` (for the currently-active track),
161
+ * matching the way Meet/Zoom expose a "Send resolution" picker.
162
+ *
163
+ * Bumping or lowering the cap mid-stream is supported; the
164
+ * change takes effect within a frame or two as the webcam
165
+ * re-negotiates.
166
+ */
167
+ cameraResolutionCap?: CameraResolutionCap;
168
+ /**
169
+ * Aspect ratio the simulator's virtual camera should report to apps.
170
+ * Picking a value here triggers a `cameraAspect` WS message to the
171
+ * host, which rebuilds its IOSurface ring at the matching dimensions
172
+ * (16:9 → 1920×1080, 4:3 → 1440×1080, 1:1 → 1080×1080, 9:16 →
173
+ * 1080×1920) and signals the in-sim dylib to re-handshake. iOS apps
174
+ * see CMSampleBuffers at the new dimensions within a frame or two.
175
+ *
176
+ * The browser still captures whatever the webcam offers; the host
177
+ * aspect-fills (cover, center-crop) into the new pool. Switching
178
+ * aspect at runtime is intentionally cheap so users can A/B preview
179
+ * styles without restarting the simulator.
180
+ *
181
+ * `undefined` leaves the pool untouched (the host's boot default —
182
+ * 16:9 / 1920×1080 — applies).
183
+ */
184
+ cameraAspect?: CameraAspect;
185
+ }
186
+ /**
187
+ * Resolution caps a host app can request on the outbound camera.
188
+ * `'auto'` is "let the browser decide" (no constraints beyond the
189
+ * 30 fps ceiling); the other options clamp width/height to the
190
+ * named target. Aspect ratio is preserved.
191
+ */
192
+ export type CameraResolutionCap = 'auto' | '1080p' | '720p' | '480p';
193
+ /**
194
+ * Aspect ratios exposed to the operator for the simulated camera.
195
+ * The host maps each label to concrete IOSurface dimensions; values
196
+ * the host doesn't recognise are silently ignored.
197
+ */
198
+ export type CameraAspect = '16:9' | '4:3' | '1:1' | '9:16';
199
+ /**
200
+ * Snapshot of the browser's webcam capture, mirrored from
201
+ * `MediaStreamTrack.getSettings()`. Forwarded to the host alongside
202
+ * `cameraResult` and exposed to the host app via
203
+ * `onCameraDemandChange` so it can render a status indicator without
204
+ * having to call `getStats()` itself.
205
+ */
206
+ export interface CameraCaptureInfo {
207
+ width?: number;
208
+ height?: number;
209
+ frameRate?: number;
210
+ deviceId?: string;
211
+ label?: string;
212
+ facingMode?: string;
213
+ }
214
+ /**
215
+ * Live outbound-camera quality snapshot. Derived from
216
+ * `RTCPeerConnection.getStats()` and rate-derived deltas, sampled
217
+ * once per second while the camera is sending. All fields optional:
218
+ * some browsers omit fields (Safari rarely reports
219
+ * `encoderImplementation`), and the first sample after camera start
220
+ * has no delta-derived numbers yet.
221
+ */
222
+ export interface CameraStreamStats {
223
+ /** "H264", "HEVC"/"H265", "VP9", "VP8", "AV1", etc. (uppercased). */
224
+ codec?: string;
225
+ /** e.g. "VideoToolbox" (hw), "OpenH264" (sw), "ExternalEncoder". */
226
+ encoderImplementation?: string;
227
+ /**
228
+ * Browser-reported hardware-acceleration hint. Some Chromium
229
+ * versions expose this via `powerEfficientEncoder`; we mirror it
230
+ * here so consumers don't have to know the spec quirk.
231
+ */
232
+ hardwareAccelerated?: boolean;
233
+ /** Outbound encoded fps over the last sample window. */
234
+ framesPerSecond?: number;
235
+ /** Cumulative encoded frame count. */
236
+ framesEncoded?: number;
237
+ /** Outbound encoded bitrate (bits/s) over the last window. */
238
+ bitrateBps?: number;
239
+ /** Width/height the encoder is currently producing. */
240
+ width?: number;
241
+ height?: number;
242
+ /**
243
+ * One of `'none' | 'cpu' | 'bandwidth' | 'other'`. Mirrors
244
+ * Meet/Zoom's "limited by …" banners. Anything other than
245
+ * `'none'` means the encoder dropped resolution to keep up.
246
+ */
247
+ qualityLimitationReason?: string;
248
+ /** Round-trip time in milliseconds, from the matching RTCP. */
249
+ rttMs?: number;
250
+ /** Packet-loss percentage over the last sample window (0..100). */
251
+ packetsLostPct?: number;
96
252
  }
97
253
  interface ScreenshotData {
98
254
  dataUri: string;