Skip to content

Commit

Permalink
Inspector: Support /open-debugger specifying target param (facebo…
Browse files Browse the repository at this point in the history
…ok#45138)

Summary:
Pull Request resolved: facebook#45138

Add a new `/open-debugger` endpoint format that allows specifying `target` - the proxy-unique target `id`. This is logically equivalent to specifying both device and page.

Changelog:
[General][Added]: Inspector: Support `/open-debugger` specifying `target` param

Differential Revision: D58950622
  • Loading branch information
robhogan authored and facebook-github-bot committed Jun 24, 2024
1 parent bfeb1c9 commit 54b0361
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 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,13 +80,18 @@ 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)...',
);
target = targets.find(
_target =>
(targetId == null || _target.id === targetId) &&
(appId == null || _target.description === appId) &&
(device == null || _target.reactNative.logicalDeviceId === device),
);
Expand Down

0 comments on commit 54b0361

Please sign in to comment.