diff --git a/packages/dev-middleware/src/middleware/openDebuggerMiddleware.js b/packages/dev-middleware/src/middleware/openDebuggerMiddleware.js index 413ce6447e1d3e..a44c0b33fdeb23 100644 --- a/packages/dev-middleware/src/middleware/openDebuggerMiddleware.js +++ b/packages/dev-middleware/src/middleware/openDebuggerMiddleware.js @@ -59,7 +59,14 @@ export default function openDebuggerMiddleware({ appId, device, launchId, - }: {appId?: string, device?: string, launchId?: string, ...} = query; + target: targetId, + }: { + appId?: string, + device?: string, + launchId?: string, + target?: string, + ... + } = query; const targets = inspectorProxy.getPageDescriptions().filter( // Only use targets with better reloading support @@ -69,25 +76,21 @@ export default function openDebuggerMiddleware({ ); let target; + let preciseTarget = true; const launchType: 'launch' | 'redirect' = req.method === 'POST' ? 'launch' : 'redirect'; - if (typeof appId === 'string' || typeof device === 'string') { - logger?.info( - (launchType === 'launch' ? 'Launching' : 'Redirecting to') + - ' JS debugger (experimental)...', - ); + if (typeof targetId === 'string') { + target = targets.find(_target => _target.id === targetId); + } else if (typeof appId === 'string' || typeof device === 'string') { target = targets.find( _target => (appId == null || _target.description === appId) && (device == null || _target.reactNative.logicalDeviceId === device), ); } else if (targets.length > 0) { - logger?.info( - (launchType === 'launch' ? 'Launching' : 'Redirecting to') + - ` JS debugger${targets.length === 1 ? '' : ' for most recently connected target'}...`, - ); + preciseTarget = targets.length === 1; target = targets[targets.length - 1]; } @@ -106,6 +109,11 @@ export default function openDebuggerMiddleware({ return; } + logger?.info( + (launchType === 'launch' ? 'Launching' : 'Redirecting to') + + ` JS debugger (Experimental) ${preciseTarget ? '' : ' for most recently connected target'}...`, + ); + const useFuseboxEntryPoint = target.reactNative.capabilities?.prefersFuseboxFrontend;