Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/server/src/device/DeviceHubOperations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ describe("DeviceHubOperations list", () => {
devices: [
{ device: "aaaa-1", name: "iPhone 17", runtime: "iOS-27-2", state: "Booted" },
{ device: "BBBB-2", name: "iPhone 17e", runtime: "iOS-27-2", state: "Shutdown" },
{
device: "DDDD-4",
name: "iPhone Duo",
runtime: "iOS-27-2-iPhone19-4",
state: "Shutdown",
},
{ device: "CCCC-3", name: "Apple Watch", runtime: "watchOS-12-0", state: "Shutdown" },
],
},
Expand All @@ -71,6 +77,8 @@ describe("DeviceHubOperations list", () => {
expect(listed.devices.map((device) => [device.id, device.version, device.booted])).toEqual([
["AAAA-1", "iOS 27.2", true],
["BBBB-2", "iOS 27.2", false],
// A runtime made for one model (the iPhone Duo's) is still iOS 27.2.
["DDDD-4", "iOS 27.2", false],
]);
}).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer)),
);
Expand Down
10 changes: 8 additions & 2 deletions apps/server/src/device/DeviceHubOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const HubDeviceList = Schema.Struct({
Schema.Array(Schema.Struct({ message: Schema.String, error: Schema.optional(Schema.String) })),
),
});
/** An iOS simulator runtime's name: its version, then a model for a device-specific build. */
const IOS_RUNTIME = /^iOS-(\d+(?:-\d+)*)(?:-[A-Za-z][A-Za-z0-9-]*)?$/;

/** serve-sim's grid inventory, which, unlike `/api/devices`, includes simulators never booted. */
const IosGridDeviceList = Schema.Struct({
devices: Schema.Array(
Expand Down Expand Up @@ -423,11 +426,14 @@ export const makeDeviceHubOperations = (options: DeviceHubOperationsOptions): De
(listed) =>
listed.platform === "ios" && listed.id.toUpperCase() === device.device.toUpperCase(),
);
if (known || !/^iOS-\d+(?:-\d+)*$/.test(device.runtime)) continue;
// `iOS-27-2`, or a runtime made for one model, such as the iPhone
// Duo's `iOS-27-2-iPhone19-4`.
const iosVersion = IOS_RUNTIME.exec(device.runtime)?.[1];
if (known || iosVersion === undefined) continue;
devices.push({
id: device.device,
name: device.name,
version: device.runtime.replace("iOS-", "iOS ").replaceAll("-", "."),
version: `iOS ${iosVersion.replaceAll("-", ".")}`,
platform: "ios",
booted: device.state === "Booted",
physical: false,
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/components/device/DeviceBody.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CSSProperties, ReactNode } from "react";

import { cn } from "~/lib/utils";
import { type BodyBox, DEVICE_BUTTON_DEPTH, type QuarterTurn } from "./deviceFrameLayout";
import type { DeviceBody } from "./deviceShapes";

Expand Down Expand Up @@ -175,11 +176,18 @@ export function DeviceBodyView(props: {
) : cutout?.kind === "punch" ? (
<span
aria-hidden
className="pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-full bg-black"
data-testid="device-punch"
className={cn(
"pointer-events-none absolute rounded-full bg-black",
cutout.centerX === undefined && "left-1/2 -translate-x-1/2",
)}
style={{
top: cutout.top * scale,
width: cutout.diameter * scale,
height: cutout.diameter * scale,
...(cutout.centerX === undefined
? {}
: { left: (cutout.centerX - cutout.diameter / 2) * scale }),
}}
/>
) : null}
Expand Down
13 changes: 11 additions & 2 deletions apps/web/src/components/device/deviceShapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export type DeviceCutout =
readonly top: number;
}
| { readonly kind: "notch"; readonly width: number; readonly height: number }
| { readonly kind: "punch"; readonly diameter: number; readonly top: number };
| {
readonly kind: "punch";
readonly diameter: number;
readonly top: number;
/** The hole's center from the screen's left edge; centered when left out. */
readonly centerX?: number;
};

export interface DeviceBody {
/** The screen, upright. The simulator's reported aspect replaces `height` when it differs. */
Expand Down Expand Up @@ -142,7 +148,10 @@ const DUO_COVER: DeviceBody = {
{ edge: "top", offset: 316, length: 66 },
{ edge: "right", offset: 202, length: 113 },
],
cutout: ISLAND,
// A round camera hole near the top right, as the simulator draws it into the
// cover's framebuffer (measured on iOS 27.2 24B91016s: 111 px across, centered
// at 1254 × 143 px of 1398 × 2034, at 3x), not the iPhones' island.
cutout: { kind: "punch", diameter: 37, top: 29.2, centerX: 418 },
};
const DUO_INNER: DeviceBody = {
screen: { width: 951, height: 669 },
Expand Down
Loading