From 3c20e0c432916cd6561c98632099a301c1471aa7 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Wed, 14 Aug 2024 17:08:28 +0100 Subject: [PATCH] [DevTools] Separate RDT Fusebox into single-panel entry points --- .../react-devtools-fusebox/src/frontend.d.ts | 3 ++- .../react-devtools-fusebox/src/frontend.js | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/react-devtools-fusebox/src/frontend.d.ts b/packages/react-devtools-fusebox/src/frontend.d.ts index 4074baf507745..8a62ad54e504c 100644 --- a/packages/react-devtools-fusebox/src/frontend.d.ts +++ b/packages/react-devtools-fusebox/src/frontend.d.ts @@ -50,4 +50,5 @@ export type InitializationOptions = { canViewElementSourceFunction?: CanViewElementSource, }; -export function initialize(node: Element | Document, options: InitializationOptions): void; +export function initializeComponents(node: Element | Document, options: InitializationOptions): void; +export function initializeProfiler(node: Element | Document, options: InitializationOptions): void; diff --git a/packages/react-devtools-fusebox/src/frontend.js b/packages/react-devtools-fusebox/src/frontend.js index d55241fec7f29..2bcd897c4622c 100644 --- a/packages/react-devtools-fusebox/src/frontend.js +++ b/packages/react-devtools-fusebox/src/frontend.js @@ -19,9 +19,10 @@ import type { } from 'react-devtools-shared/src/frontend/types'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type { + CanViewElementSource, + TabID, ViewAttributeSource, ViewElementSource, - CanViewElementSource, } from 'react-devtools-shared/src/devtools/views/DevTools'; import type {Config} from 'react-devtools-shared/src/devtools/store'; @@ -51,10 +52,11 @@ type InitializationOptions = { canViewElementSourceFunction?: CanViewElementSource, }; -export function initialize( +function initializeTab( + tab: TabID, contentWindow: Element | Document, options: InitializationOptions, -): void { +) { const { bridge, store, @@ -70,7 +72,8 @@ export function initialize( bridge={bridge} browserTheme={theme} store={store} - showTabBar={true} + showTabBar={false} + overrideTab={tab} warnIfLegacyBackendDetected={true} enabledInspectedElementContextMenu={true} viewAttributeSourceFunction={viewAttributeSourceFunction} @@ -79,3 +82,17 @@ export function initialize( />, ); } + +export function initializeComponents( + contentWindow: Element | Document, + options: InitializationOptions, +): void { + initializeTab('components', contentWindow, options); +} + +export function initializeProfiler( + contentWindow: Element | Document, + options: InitializationOptions, +): void { + initializeTab('profiler', contentWindow, options); +}