Skip to content

Commit

Permalink
Add NetworkNavigatorView to rn_inspector (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
motiz88 authored Mar 22, 2024
1 parent 1173d79 commit a96803a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions front_end/entrypoints/rn_inspector/rn_inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ import '../../panels/network/network-meta.js';
import '../../panels/js_profiler/js_profiler-meta.js';
import '../../panels/rn_welcome/rn_welcome-meta.js';

import * as i18n from '../../core/i18n/i18n.js';
import * as Host from '../../core/host/host.js';
import * as Root from '../../core/root/root.js';
import * as SDK from '../../core/sdk/sdk.js';
import * as Main from '../main/main.js';
import * as UI from '../../ui/legacy/legacy.js';
import type * as InspectorBackend from '../../core/protocol_client/InspectorBackend.js';
import type * as Sources from '../../panels/sources/sources.js';

Host.RNPerfMetrics.registerPerfMetricsGlobalPostMessageHandler();

Expand Down Expand Up @@ -75,6 +78,42 @@ SDK.SDKModel.SDKModel.register(
},
);

const UIStrings = {
/**
*@description Title of the 'React Native' tool in the Network Navigator View, which is part of the Sources tool
*/
networkTitle: 'React Native',
/**
*@description Command for showing the 'React Native' tool in the Network Navigator View, which is part of the Sources tool
*/
showReactNative: 'Show React Native',
};

const str_ = i18n.i18n.registerUIStrings('entrypoints/rn_inspector/rn_inspector.ts', UIStrings);
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);

let loadedSourcesModule: (typeof Sources|undefined);

async function loadSourcesModule(): Promise<typeof Sources> {
if (!loadedSourcesModule) {
loadedSourcesModule = await import('../../panels/sources/sources.js');
}
return loadedSourcesModule;
}

UI.ViewManager.registerViewExtension({
location: UI.ViewManager.ViewLocationValues.NAVIGATOR_VIEW,
id: 'navigator-network',
title: i18nLazyString(UIStrings.networkTitle),
commandPrompt: i18nLazyString(UIStrings.showReactNative),
order: 2,
persistence: UI.ViewManager.ViewPersistence.PERMANENT,
async loadView() {
const Sources = await loadSourcesModule();
return Sources.SourcesNavigator.NetworkNavigatorView.instance();
},
});

// @ts-ignore Exposed for legacy layout tests
self.runtime = Root.Runtime.Runtime.instance({forceNew: true});
new Main.MainImpl.MainImpl();

0 comments on commit a96803a

Please sign in to comment.