( request: DeviceInventoryRequest, )
| 40 | }; |
| 41 | |
| 42 | export async function listLocalDeviceInventory( |
| 43 | request: DeviceInventoryRequest, |
| 44 | ): Promise<DeviceInfo[]> { |
| 45 | if (request.platform === 'web') { |
| 46 | return [WEB_DESKTOP_DEVICE]; |
| 47 | } |
| 48 | |
| 49 | if (shouldUseHostMacFastPath(request)) { |
| 50 | const { listMacosDevices } = await import('../platforms/apple/os/macos/devices.ts'); |
| 51 | return await listMacosDevices(); |
| 52 | } |
| 53 | |
| 54 | if (request.platform === 'linux') { |
| 55 | const { listLinuxDevices } = await import('../platforms/linux/devices.ts'); |
| 56 | return await listLinuxDevices(); |
| 57 | } |
| 58 | |
| 59 | if (request.platform === 'android') { |
| 60 | const { listAndroidDevices } = await import('../platforms/android/devices.ts'); |
| 61 | return await listAndroidDevices({ |
| 62 | serialAllowlist: request.androidSerialAllowlist |
| 63 | ? new Set(request.androidSerialAllowlist) |
| 64 | : undefined, |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | if (request.platform) { |
| 69 | const { listAppleDevices } = await import('../platforms/apple/core/devices.ts'); |
| 70 | return await listAppleDevices({ |
| 71 | simulatorSetPath: request.iosSimulatorSetPath, |
| 72 | udid: request.udid, |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | const devices: DeviceInfo[] = []; |
| 77 | // Linux local device is appended last so it does not displace |
| 78 | // connected Android/Apple devices in implicit auto-selection. |
| 79 | for (const platform of LOCAL_DEVICE_INVENTORY_PLATFORM_SELECTORS) { |
| 80 | try { |
| 81 | devices.push(...(await listLocalDeviceInventory({ ...request, platform }))); |
| 82 | } catch {} |
| 83 | } |
| 84 | return devices; |
| 85 | } |
| 86 | |
| 87 | export function countDeviceInventoryByGroup(devices: DeviceInfo[]): DeviceInventoryGroupCounts { |
| 88 | const counts = emptyDeviceInventoryGroupCounts(); |
no test coverage detected