Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions packages/react-devtools-fusebox/src/frontend.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
* LICENSE file in the root directory of this source tree.
*/

export type MessagePayload = null | string | number | boolean | { [key: string]: MessagePayload } | MessagePayload[];
export type Message = { event: string, payload?: MessagePayload };
export type MessagePayload =
| null
| string
| number
| boolean
| {[key: string]: MessagePayload}
| MessagePayload[];
export type Message = {event: string; payload?: MessagePayload};

export type WallListener = (message: Message) => void;
export type Wall = {
listen: (fn: WallListener) => Function,
send: (event: string, payload?: MessagePayload) => void,
listen: (fn: WallListener) => Function;
send: (event: string, payload?: MessagePayload) => void;
};

export type Bridge = {
Expand All @@ -22,7 +28,7 @@ export type Bridge = {
export type Store = Object;
export type BrowserTheme = 'dark' | 'light';
export type Config = {
supportsReloadAndProfile?: boolean,
supportsReloadAndProfile?: boolean;
};

export function createBridge(wall: Wall): Bridge;
Expand Down Expand Up @@ -55,15 +61,23 @@ export type CanViewElementSource = (
source: ReactFunctionLocation | ReactCallSite,
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
) => boolean;
export type FetchFileWithCaching = (url: string) => Promise<string>;

export type InitializationOptions = {
bridge: Bridge,
store: Store,
theme?: BrowserTheme,
viewAttributeSourceFunction?: ViewAttributeSource,
viewElementSourceFunction?: ViewElementSource,
canViewElementSourceFunction?: CanViewElementSource,
bridge: Bridge;
store: Store;
theme?: BrowserTheme;
viewAttributeSourceFunction?: ViewAttributeSource;
viewElementSourceFunction?: ViewElementSource;
canViewElementSourceFunction?: CanViewElementSource;
fetchFileWithCaching?: FetchFileWithCaching;
};

export function initializeComponents(node: Element | Document, options: InitializationOptions): void;
export function initializeProfiler(node: Element | Document, options: InitializationOptions): void;
export function initializeComponents(
node: Element | Document,
options: InitializationOptions,
): void;
export function initializeProfiler(
node: Element | Document,
options: InitializationOptions,
): void;
4 changes: 4 additions & 0 deletions packages/react-devtools-fusebox/src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
ViewAttributeSource,
ViewElementSource,
} from 'react-devtools-shared/src/devtools/views/DevTools';
import type {FetchFileWithCaching} from 'react-devtools-shared/src/devtools/views/Components/FetchFileWithCachingContext';
import type {Config} from 'react-devtools-shared/src/devtools/store';

export function createBridge(wall?: Wall): FrontendBridge {
Expand All @@ -50,6 +51,7 @@ type InitializationOptions = {
viewAttributeSourceFunction?: ViewAttributeSource,
viewElementSourceFunction?: ViewElementSource,
canViewElementSourceFunction?: CanViewElementSource,
fetchFileWithCaching?: FetchFileWithCaching,
};

function initializeTab(
Expand All @@ -64,6 +66,7 @@ function initializeTab(
viewAttributeSourceFunction,
viewElementSourceFunction,
canViewElementSourceFunction,
fetchFileWithCaching,
} = options;
const root = createRoot(contentWindow);

Expand All @@ -79,6 +82,7 @@ function initializeTab(
viewAttributeSourceFunction={viewAttributeSourceFunction}
viewElementSourceFunction={viewElementSourceFunction}
canViewElementSourceFunction={canViewElementSourceFunction}
fetchFileWithCaching={fetchFileWithCaching}
/>,
);
}
Expand Down
Loading