serve-sim 0.1.45 → 0.1.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serve-sim",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Evan Bacon",
@@ -35,6 +35,7 @@
35
35
  "src/camera-helper.ts",
36
36
  "src/middleware.ts",
37
37
  "src/native.ts",
38
+ "src/simctl.ts",
38
39
  "src/state.ts",
39
40
  "Sources/SimCameraInjector/SimCameraInjector.m",
40
41
  "Sources/SimCameraInjector/SimCam*.h",
@@ -48,6 +49,8 @@
48
49
  "dist/native/serve-sim-native.node",
49
50
  "Package.swift",
50
51
  "Sources/SimNative/*.swift",
52
+ "Sources/SimNativeSupport/*.swift",
53
+ "Tests/SimNativeSupportTests/*.swift",
51
54
  "Sources/SimNative/build.sh"
52
55
  ],
53
56
  "exports": {
package/src/middleware.ts CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  import { createExecUpgradeHandler, type UiRequestHandler } from "./exec-ws";
33
33
  import { UI_OPTIONS, getUiStatus, normalizeUiValue, setUiOption } from "./ui-settings";
34
34
  import type { PreviewInitialState } from "./preview-initial-state";
35
+ import { simctlBootStatusArguments } from "./simctl";
35
36
 
36
37
  type SimReq = IncomingMessage;
37
38
  type SimRes = ServerResponse;
@@ -769,7 +770,10 @@ export async function startDeviceInProcess(udid: string, port: number, base: str
769
770
  // `simctl boot` errors when already booted — ignore and let bootstatus confirm.
770
771
  await new Promise<void>((resolve) => execFile("xcrun", ["simctl", "boot", udid], () => resolve()));
771
772
  const ready = await new Promise<boolean>((resolve) => {
772
- execFile("xcrun", ["simctl", "bootstatus", udid, "-b"], { timeout: 180_000 }, (err) => resolve(!err));
773
+ // Boot was already requested above. Passing `-b` redundantly can remain
774
+ // blocked on Xcode 27 even after `simctl list` reports Booted, so only
775
+ // monitor the transition already in progress.
776
+ execFile("xcrun", simctlBootStatusArguments(udid), { timeout: 180_000 }, (err) => resolve(!err));
773
777
  });
774
778
  if (!ready) {
775
779
  // bootstatus can exit non-zero even when the device is actually ready;
package/src/native.ts CHANGED
@@ -33,9 +33,9 @@ interface SimHIDHandle {
33
33
  }
34
34
 
35
35
  interface SimCaptureHandle {
36
- start(): void;
37
- stop(): void;
38
- subscribe(codec: number, onFrame: RawFrameCallback): Promise<() => void>;
36
+ start(): Promise<void>;
37
+ stop(): Promise<void>;
38
+ subscribe(codec: number, onFrame: RawFrameCallback): Promise<() => void | Promise<void>>;
39
39
  }
40
40
 
41
41
  interface NativeAddon {
@@ -196,18 +196,18 @@ export class NativeCapture {
196
196
  this.handle = new (load().SimCapture)(udid);
197
197
  }
198
198
 
199
- /** Begin capturing. Throws if the device isn't booted. */
200
- start(): void {
201
- this.handle.start();
199
+ /** Begin capturing. Rejects if the device isn't booted. */
200
+ start(): Promise<void> {
201
+ return this.handle.start();
202
202
  }
203
203
 
204
- subscribeMjpeg(onFrame: (frame: MjpegFrame) => Promise<void>): Promise<() => void> {
204
+ subscribeMjpeg(onFrame: (frame: MjpegFrame) => Promise<void>): Promise<() => void | Promise<void>> {
205
205
  return this.handle.subscribe(CODEC_MJPEG, (data, width, height, _flags) => {
206
206
  return onFrame({ data, width, height });
207
207
  });
208
208
  }
209
209
 
210
- subscribeAvcc(onFrame: (frame: AvccFrame) => Promise<void>): Promise<() => void> {
210
+ subscribeAvcc(onFrame: (frame: AvccFrame) => Promise<void>): Promise<() => void | Promise<void>> {
211
211
  return this.handle.subscribe(CODEC_AVCC, (data, width, height, flags) => {
212
212
  return onFrame({
213
213
  data,
@@ -220,8 +220,8 @@ export class NativeCapture {
220
220
  }
221
221
 
222
222
  /** Halt frame production. Full teardown happens when this object is GC'd. */
223
- stop(): void {
224
- this.handle.stop();
223
+ stop(): Promise<void> {
224
+ return this.handle.stop();
225
225
  }
226
226
  }
227
227
 
package/src/simctl.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Arguments for monitoring a boot that serve-sim has already requested.
3
+ *
4
+ * `-b` means "boot if needed". Keeping it out is intentional: after a separate
5
+ * `simctl boot`, Xcode 27 can leave the redundant boot-and-monitor form blocked
6
+ * even though the device is already Booted. This form only monitors the boot
7
+ * transition that serve-sim requested.
8
+ */
9
+ export function simctlBootStatusArguments(udid: string): [string, string, string] {
10
+ return ["simctl", "bootstatus", udid];
11
+ }