main
js 55 lines 1.66 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 import type {ReactContext} from 'shared/ReactTypes';
11 import {createContext} from 'react';
12 import Store from '../store';
13
14 import type {ViewAttributeSource} from 'react-devtools-shared/src/devtools/views/DevTools';
15 import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
16
17 export const BridgeContext: ReactContext<FrontendBridge> =
18 createContext<FrontendBridge>(null as any as FrontendBridge);
19 BridgeContext.displayName = 'BridgeContext';
20
21 export const StoreContext: ReactContext<Store> = createContext<Store>(
22 null as any as Store,
23 );
24 StoreContext.displayName = 'StoreContext';
25
26 export type ContextMenuContextType = {
27 isEnabledForInspectedElement: boolean,
28 viewAttributeSourceFunction: ViewAttributeSource | null,
29 };
30
31 export const ContextMenuContext: ReactContext<ContextMenuContextType> =
32 createContext<ContextMenuContextType>({
33 isEnabledForInspectedElement: false,
34 viewAttributeSourceFunction: null,
35 });
36 ContextMenuContext.displayName = 'ContextMenuContext';
37
38 export type OptionsContextType = {
39 readOnly: boolean,
40 hideSettings: boolean,
41 hideToggleErrorAction: boolean,
42 hideToggleSuspenseAction: boolean,
43 hideLogAction: boolean,
44 hideViewSourceAction: boolean,
45 };
46
47 export const OptionsContext: ReactContext<OptionsContextType> =
48 createContext<OptionsContextType>({
49 readOnly: false,
50 hideSettings: false,
51 hideToggleErrorAction: false,
52 hideToggleSuspenseAction: false,
53 hideLogAction: false,
54 hideViewSourceAction: false,
55 });