MCPcopy Index your code
hub / github.com/callstack/agent-device / listLocalDeviceInventory

Function listLocalDeviceInventory

src/core/platform-inventory.ts:42–85  ·  view source on GitHub ↗
(
  request: DeviceInventoryRequest,
)

Source from the content-addressed store, hash-verified

40};
41
42export 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
87export function countDeviceInventoryByGroup(devices: DeviceInfo[]): DeviceInventoryGroupCounts {
88 const counts = emptyDeviceInventoryGroupCounts();

Callers 2

resolveTargetDeviceFunction · 0.90
listDeviceInventoryFunction · 0.90

Calls 6

shouldUseHostMacFastPathFunction · 0.85
listMacosDevicesFunction · 0.85
listLinuxDevicesFunction · 0.85
listAndroidDevicesFunction · 0.85
listAppleDevicesFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected