Open History to see the last commit
1import {
2 resolveDeviceModelId,
3 type DeviceAccessorySource,
4 type DeviceModelSource,
5} from "@t3tools/client-runtime/device/model";
6import type { DevicePlatform } from "@t3tools/contracts";
7import iphone18Pro from "./models/iphone-18-pro.glb?url";
8import iphone18ProMax from "./models/iphone-18-pro-max.glb?url";
9import magicKeyboard from "./models/ipad-pro-13-m5-magic-keyboard.glb?url";
10import ipadPro13M5 from "./models/ipad-pro-13-m5.glb?url";
11
12// Bundled URLs follow the client origin in local, desktop, hosted and remote sessions.
13const models: Record<DeviceModelSource["id"], DeviceModelSource> = {
14 "iphone-18-pro": { id: "iphone-18-pro", url: iphone18Pro },
15 "iphone-18-pro-max": { id: "iphone-18-pro-max", url: iphone18ProMax },
16 "ipad-pro-13-m5": { id: "ipad-pro-13-m5", url: ipadPro13M5 },
17};
18
19export function deviceModel(platform: DevicePlatform, name: string): DeviceModelSource | null {
20 const id = resolveDeviceModelId(platform, name);
21 return id ? models[id] : null;
22}
23
24const keyboard: DeviceAccessorySource = {
25 id: "ipad-pro-13-m5-magic-keyboard",
26 modelId: "ipad-pro-13-m5",
27 url: magicKeyboard,
28};
29
30export function deviceKeyboard(
31 platform: DevicePlatform,
32 name: string,
33): DeviceAccessorySource | null {
34 return resolveDeviceModelId(platform, name) === keyboard.modelId ? keyboard : null;
35}