Skip to content

Commit

Permalink
Add human-readable device name to /json[/list] endpoint (#921)
Browse files Browse the repository at this point in the history
Summary:
This is a proposal to add a human-readable reference to each inspector entries/pages.

### Context

I've been experimenting with adding Hermes inspector support to [`vscode-expo`](https://github.com/expo/vscode-expo#readme) by reusing the existing [`vscode-js-debug`](https://github.com/microsoft/vscode-js-debug) tooling.

Unfortunately, this method of debugging only supports a single target. When multiple devices are connected, we have to ask the user to select one. Currently, there is no way to differentiate devices. In my case, I have both an Android and iOS device, which I simultaneously use to test things.

By adding a human-readable reference, such as `deviceName`, we can ask the user which device they would like to use.

### Does this break the `/json[/list]` endpoint?

I've tested this locally, and it doesn't seem to break anything. Note, we already deviate a bit [from the original spec](https://chromedevtools.github.io/devtools-protocol/#get-json-or-jsonlist) with the `vm` property.

Pull Request resolved: #921

Test Plan:
- Start metro
- Connect a device
- Open `http://localhost:8081/json`, and check if `deviceName` matches the expected name.

Reviewed By: huntie

Differential Revision: D42925209

Pulled By: robhogan

fbshipit-source-id: 6f2d782a424105f4ea48bd2fddae018e67209fc9
  • Loading branch information
byCedric authored and facebook-github-bot committed Feb 1, 2023
1 parent b1aa1c7 commit 80e6fd8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/metro-inspector-proxy/src/InspectorProxy.js
Expand Up @@ -129,6 +129,7 @@ class InspectorProxy {
type: 'node',
webSocketDebuggerUrl,
vm: page.vm,
deviceName: device.getName(),
};
}

Expand Down

0 comments on commit 80e6fd8

Please sign in to comment.