@@ -14,6 +14,7 @@ import {
1414 resolveIosSimulatorDeviceSetPath ,
1515} from '../utils/device-isolation.ts' ;
1616import type { CliFlags } from '../utils/cli-flags.ts' ;
17+ import { listLocalDeviceInventory , type DeviceInventoryRequest } from './platform-inventory.ts' ;
1718type ResolveDeviceFlags = Pick <
1819 CliFlags ,
1920 | 'platform'
@@ -28,15 +29,7 @@ type ResolveDeviceFlags = Pick<
2829const resolveTargetDeviceCacheScope = new AsyncLocalStorage < Map < string , DeviceInfo > > ( ) ;
2930const deviceInventoryProviderScope = new AsyncLocalStorage < DeviceInventoryProvider > ( ) ;
3031
31- export type DeviceInventoryRequest = {
32- platform ?: PlatformSelector ;
33- target ?: DeviceTarget ;
34- deviceName ?: string ;
35- udid ?: string ;
36- serial ?: string ;
37- iosSimulatorSetPath ?: string ;
38- androidSerialAllowlist ?: string [ ] ;
39- } ;
32+ export type { DeviceInventoryRequest } ;
4033
4134export type DeviceInventoryProvider = (
4235 request : DeviceInventoryRequest ,
@@ -219,16 +212,6 @@ export async function resolveTargetDevice(flags: ResolveDeviceFlags): Promise<De
219212 ) ;
220213}
221214
222- function shouldUseHostMacFastPath ( selector : {
223- platform ?: PlatformSelector ;
224- target ?: DeviceTarget ;
225- } ) : boolean {
226- return (
227- selector . platform === 'macos' ||
228- ( selector . platform === 'apple' && selector . target === 'desktop' )
229- ) ;
230- }
231-
232215export async function withResolveTargetDeviceCacheScope < T > ( task : ( ) => Promise < T > ) : Promise < T > {
233216 if ( resolveTargetDeviceCacheScope . getStore ( ) ) return await task ( ) ;
234217 return await resolveTargetDeviceCacheScope . run ( new Map ( ) , task ) ;
@@ -266,63 +249,6 @@ async function readInjectedDeviceInventory(
266249 return devices . map ( ( device ) => ( { ...device } ) ) ;
267250}
268251
269- async function listLocalDeviceInventory ( request : DeviceInventoryRequest ) : Promise < DeviceInfo [ ] > {
270- if ( shouldUseHostMacFastPath ( request ) ) {
271- const { listMacosDevices } = await import ( '../platforms/macos/devices.ts' ) ;
272- return await listMacosDevices ( ) ;
273- }
274-
275- if ( request . platform === 'linux' ) {
276- const { listLinuxDevices } = await import ( '../platforms/linux/devices.ts' ) ;
277- return await listLinuxDevices ( ) ;
278- }
279-
280- if ( request . platform === 'android' ) {
281- const { listAndroidDevices } = await import ( '../platforms/android/devices.ts' ) ;
282- return await listAndroidDevices ( {
283- serialAllowlist : request . androidSerialAllowlist
284- ? new Set ( request . androidSerialAllowlist )
285- : undefined ,
286- } ) ;
287- }
288-
289- if ( request . platform ) {
290- const { listAppleDevices } = await import ( '../platforms/ios/devices.ts' ) ;
291- return await listAppleDevices ( {
292- simulatorSetPath : request . iosSimulatorSetPath ,
293- udid : request . udid ,
294- } ) ;
295- }
296-
297- const devices : DeviceInfo [ ] = [ ] ;
298- try {
299- const { listAndroidDevices } = await import ( '../platforms/android/devices.ts' ) ;
300- devices . push (
301- ...( await listAndroidDevices ( {
302- serialAllowlist : request . androidSerialAllowlist
303- ? new Set ( request . androidSerialAllowlist )
304- : undefined ,
305- } ) ) ,
306- ) ;
307- } catch { }
308- try {
309- const { listAppleDevices } = await import ( '../platforms/ios/devices.ts' ) ;
310- devices . push (
311- ...( await listAppleDevices ( {
312- simulatorSetPath : request . iosSimulatorSetPath ,
313- udid : request . udid ,
314- } ) ) ,
315- ) ;
316- } catch { }
317- // Linux local device is appended last so it does not displace
318- // connected Android/Apple devices in implicit auto-selection.
319- try {
320- const { listLinuxDevices } = await import ( '../platforms/linux/devices.ts' ) ;
321- devices . push ( ...( await listLinuxDevices ( ) ) ) ;
322- } catch { }
323- return devices ;
324- }
325-
326252function isAppleResolutionSelector ( selector : {
327253 platform ?: PlatformSelector ;
328254 target ?: DeviceTarget ;
0 commit comments