Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions packages/dev-middleware/src/middleware/openDebuggerMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -73,19 +80,21 @@ export default function openDebuggerMiddleware({
const launchType: 'launch' | 'redirect' =
req.method === 'POST' ? 'launch' : 'redirect';

if (typeof appId === 'string' || typeof device === 'string') {
if (
typeof targetId === 'string' ||
typeof appId === 'string' ||
typeof device === 'string'
) {
logger?.info(
(launchType === 'launch' ? 'Launching' : 'Redirecting to') +
' JS debugger (experimental)...',
);
if (typeof device === 'string') {
target = targets.find(
_target => _target.reactNative.logicalDeviceId === device,
);
}
if (!target && typeof appId === 'string') {
target = targets.find(_target => _target.description === appId);
}
target = targets.find(
_target =>
(targetId == null || _target.id === targetId) &&
(appId == null || _target.description === appId) &&
(device == null || _target.reactNative.logicalDeviceId === device),
);
} else if (targets.length > 0) {
logger?.info(
(launchType === 'launch' ? 'Launching' : 'Redirecting to') +
Expand Down