mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-03 03:39:20 +08:00
R=aerotwist@chromium.org Bug: 1187573 Change-Id: I26a1db130ebb61b2c5b98a72f28116d4ed17cc88 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2843314 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
import * as Root from '../../core/root/root.js';
|
|
import * as UI from '../../ui/legacy/legacy.js';
|
|
|
|
// eslint-disable-next-line rulesdir/es_modules_import
|
|
import type * as NodeMain from './node_main.js';
|
|
|
|
const UIStrings = {
|
|
/**
|
|
*@description Text that refers to the network connection
|
|
*/
|
|
connection: 'Connection',
|
|
/**
|
|
*@description A tag of Node.js Connection Panel that can be searched in the command menu
|
|
*/
|
|
node: 'node',
|
|
/**
|
|
*@description Command for showing the Connection tool
|
|
*/
|
|
showConnection: 'Show Connection',
|
|
};
|
|
|
|
const str_ = i18n.i18n.registerUIStrings('entrypoints/node_main/node_main-meta.ts', UIStrings);
|
|
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
|
|
|
|
let loadedNodeMainModule: (typeof NodeMain|undefined);
|
|
|
|
async function loadNodeMainModule(): Promise<typeof NodeMain> {
|
|
if (!loadedNodeMainModule) {
|
|
// Side-effect import resources in module.json
|
|
await Root.Runtime.Runtime.instance().loadModulePromise('entrypoints/node_main');
|
|
loadedNodeMainModule = await import('./node_main.js');
|
|
}
|
|
return loadedNodeMainModule;
|
|
}
|
|
|
|
UI.ViewManager.registerViewExtension({
|
|
location: UI.ViewManager.ViewLocationValues.PANEL,
|
|
id: 'node-connection',
|
|
title: i18nLazyString(UIStrings.connection),
|
|
commandPrompt: i18nLazyString(UIStrings.showConnection),
|
|
order: 0,
|
|
async loadView() {
|
|
const NodeMain = await loadNodeMainModule();
|
|
return NodeMain.NodeConnectionsPanel.NodeConnectionsPanel.instance();
|
|
},
|
|
tags: [i18nLazyString(UIStrings.node)],
|
|
});
|