Skip to content

Commit

Permalink
Allow string device ids in inspector proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed May 27, 2023
1 parent 3050e27 commit c52f355
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/metro-inspector-proxy/src/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const REACT_NATIVE_RELOADABLE_PAGE_ID = '-1';
*/
class Device {
// ID of the device.
_id: number;
_id: string;

// Name of the device.
_name: string;
Expand Down
10 changes: 5 additions & 5 deletions packages/metro-inspector-proxy/src/InspectorProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class InspectorProxy {
_projectRoot: string;

// Maps device ID to Device instance.
_devices: Map<number, Device>;
_devices: Map<string, Device>;

// Internal counter for device IDs -- just gets incremented for each new device.
_deviceCounter: number = 0;
Expand Down Expand Up @@ -111,7 +111,7 @@ class InspectorProxy {
// Converts page information received from device into PageDescription object
// that is sent to debugger.
_buildPageDescription(
deviceId: number,
deviceId: string,
device: Device,
page: Page,
): PageDescription {
Expand Down Expand Up @@ -165,9 +165,9 @@ class InspectorProxy {
const query = url.parse(req.url || '', true).query || {};
const deviceName = query.name || 'Unknown';
const appName = query.app || 'Unknown';
const deviceId = this._deviceCounter++;
const deviceId = String(this._deviceCounter++);
this._devices.set(
deviceId,
SdeviceId,
new Device(deviceId, deviceName, appName, socket, this._projectRoot),
);

Expand Down Expand Up @@ -206,7 +206,7 @@ class InspectorProxy {
throw new Error('Incorrect URL - must provide device and page IDs');
}

const device = this._devices.get(parseInt(deviceId, 10));
const device = this._devices.get(deviceId);
if (device == null) {
throw new Error('Unknown device with ID ' + deviceId);
}
Expand Down

0 comments on commit c52f355

Please sign in to comment.