Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | import '../shell/shell.js'; |
Nancy Li | 1c65919 | 2022-09-16 09:19:30 | [diff] [blame] | 5 | import '../../panels/mobile_throttling/mobile_throttling-meta.js'; |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 6 | import '../../panels/js_profiler/js_profiler-meta.js'; |
| 7 | import type * as Sources from '../../panels/sources/sources.js'; |
| 8 | import * as i18n from '../../core/i18n/i18n.js'; |
| 9 | import * as UI from '../../ui/legacy/legacy.js'; |
| 10 | import * as Common from '../../core/common/common.js'; |
| 11 | import * as Root from '../../core/root/root.js'; |
| 12 | import * as Main from '../main/main.js'; |
| 13 | |
| 14 | import {NodeMainImpl} from './NodeMain.js'; // eslint-disable-line rulesdir/es_modules_import |
| 15 | import {NodeConnectionsPanel} from './NodeConnectionsPanel.js'; // eslint-disable-line rulesdir/es_modules_import |
| 16 | |
| 17 | const UIStrings = { |
| 18 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame^] | 19 | *@description Text that refers to the network connection |
| 20 | */ |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 21 | connection: 'Connection', |
| 22 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame^] | 23 | *@description A tag of Node.js Connection Panel that can be searched in the command menu |
| 24 | */ |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 25 | node: 'node', |
| 26 | /** |
| 27 | *@description Command for showing the Connection tool |
| 28 | */ |
| 29 | showConnection: 'Show Connection', |
| 30 | /** |
| 31 | *@description Title of the 'Node' tool in the Network Navigator View, which is part of the Sources tool |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame^] | 32 | */ |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 33 | networkTitle: 'Node', |
| 34 | /** |
| 35 | *@description Command for showing the 'Node' tool in the Network Navigator View, which is part of the Sources tool |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame^] | 36 | */ |
Andrés Olivares | 0650b4a | 2022-10-19 10:16:59 | [diff] [blame] | 37 | showNode: 'Show Node', |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | const str_ = i18n.i18n.registerUIStrings('entrypoints/node_app/node_app.ts', UIStrings); |
| 41 | const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_); |
| 42 | |
| 43 | let loadedSourcesModule: (typeof Sources|undefined); |
| 44 | |
| 45 | async function loadSourcesModule(): Promise<typeof Sources> { |
| 46 | if (!loadedSourcesModule) { |
| 47 | loadedSourcesModule = await import('../../panels/sources/sources.js'); |
| 48 | } |
| 49 | return loadedSourcesModule; |
| 50 | } |
| 51 | |
| 52 | UI.ViewManager.registerViewExtension({ |
| 53 | location: UI.ViewManager.ViewLocationValues.PANEL, |
| 54 | id: 'node-connection', |
| 55 | title: i18nLazyString(UIStrings.connection), |
| 56 | commandPrompt: i18nLazyString(UIStrings.showConnection), |
| 57 | order: 0, |
| 58 | async loadView() { |
| 59 | return NodeConnectionsPanel.instance(); |
| 60 | }, |
| 61 | tags: [i18nLazyString(UIStrings.node)], |
| 62 | }); |
| 63 | |
| 64 | UI.ViewManager.registerViewExtension({ |
| 65 | location: UI.ViewManager.ViewLocationValues.NAVIGATOR_VIEW, |
| 66 | id: 'navigator-network', |
| 67 | title: i18nLazyString(UIStrings.networkTitle), |
| 68 | commandPrompt: i18nLazyString(UIStrings.showNode), |
| 69 | order: 2, |
| 70 | persistence: UI.ViewManager.ViewPersistence.PERMANENT, |
| 71 | async loadView() { |
| 72 | const Sources = await loadSourcesModule(); |
| 73 | return Sources.SourcesNavigator.NetworkNavigatorView.instance(); |
| 74 | }, |
| 75 | }); |
| 76 | |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 77 | // @ts-ignore Exposed for legacy layout tests |
Tim van der Lippe | d3b32d5 | 2021-12-02 12:55:56 | [diff] [blame] | 78 | self.runtime = Root.Runtime.Runtime.instance({forceNew: true}); |
Tim van der Lippe | 67872d6 | 2021-11-30 14:00:17 | [diff] [blame] | 79 | Common.Runnable.registerEarlyInitializationRunnable(NodeMainImpl.instance); |
| 80 | new Main.MainImpl.MainImpl(); |