|
| 1 | +// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +// Copyright 2026 The Chromium Authors. All rights reserved. |
| 3 | +// Use of this source code is governed by a BSD-style license that can be |
| 4 | +// found in the LICENSE file. |
| 5 | + |
| 6 | +import * as i18n from '../../core/i18n/i18n.js'; |
| 7 | +import * as UI from '../../ui/legacy/legacy.js'; |
| 8 | + |
| 9 | +import type * as ReactDevToolsPanelModule from './react_devtools.js'; |
| 10 | + |
| 11 | +const UIStrings = { |
| 12 | + /** |
| 13 | + * @description React DevTools panel title |
| 14 | + */ |
| 15 | + title: 'Suspense ⚛', |
| 16 | + |
| 17 | + /** |
| 18 | + * @description Command for showing the React DevTools panel |
| 19 | + */ |
| 20 | + command: 'Show React DevTools Suspense panel', |
| 21 | +} as const; |
| 22 | +const str_ = i18n.i18n.registerUIStrings('panels/react_devtools/react_devtools_suspense-meta.ts', UIStrings); |
| 23 | +const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_); |
| 24 | + |
| 25 | +let loadedModule: (typeof ReactDevToolsPanelModule|undefined); |
| 26 | + |
| 27 | +async function loadModule(): Promise<typeof ReactDevToolsPanelModule> { |
| 28 | + if (!loadedModule) { |
| 29 | + loadedModule = await import('./react_devtools.js'); |
| 30 | + } |
| 31 | + return loadedModule; |
| 32 | +} |
| 33 | + |
| 34 | +UI.ViewManager.registerViewExtension({ |
| 35 | + location: UI.ViewManager.ViewLocationValues.PANEL, |
| 36 | + id: 'react-devtools-suspense', |
| 37 | + title: i18nLazyString(UIStrings.title), |
| 38 | + commandPrompt: i18nLazyString(UIStrings.command), |
| 39 | + persistence: UI.ViewManager.ViewPersistence.PERMANENT, |
| 40 | + order: 1000, |
| 41 | + async loadView() { |
| 42 | + const Module = await loadModule(); |
| 43 | + return new Module.ReactDevToolsSuspenseView.ReactDevToolsSuspenseViewImpl(); |
| 44 | + }, |
| 45 | +}); |
| 46 | + |
0 commit comments