import type {
Dehydrated,
Unserializable,
} from 'react-devtools-shared/src/hydration';
import type {ReactFunctionLocation, ReactStackTrace} from 'shared/ReactTypes';
import type {UnknownSuspendersReason} from '../constants';
export type BrowserTheme = 'dark' | 'light';
export type Wall = {
listen: (fn: Function) => Function,
send: (event: string, payload: any, transferable?: Array<any>) => void,
};
export const ElementTypeClass = 1;
export const ElementTypeContext = 2;
export const ElementTypeFunction = 5;
export const ElementTypeForwardRef = 6;
export const ElementTypeHostComponent = 7;
export const ElementTypeMemo = 8;
export const ElementTypeOtherOrUnknown = 9;
export const ElementTypeProfiler = 10;
export const ElementTypeRoot = 11;
export const ElementTypeSuspense = 12;
export const ElementTypeSuspenseList = 13;
export const ElementTypeTracingMarker = 14;
export const ElementTypeVirtual = 15;
export const ElementTypeViewTransition = 16;
export const ElementTypeActivity = 17;
export type ElementType =
| 1
| 2
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17;
export const ComponentFilterElementType = 1;
export const ComponentFilterDisplayName = 2;
export const ComponentFilterLocation = 3;
export const ComponentFilterHOC = 4;
export const ComponentFilterEnvironmentName = 5;
export const ComponentFilterActivitySlice = 6;
export type ComponentFilterType = 1 | 2 | 3 | 4 | 5 | 6;
export type ElementTypeComponentFilter = {
isEnabled: boolean,
type: 1,
value: ElementType,
};
export type RegExpComponentFilter = {
isEnabled: boolean,
isValid: boolean,
type: 2 | 3,
value: string,
};
export type BooleanComponentFilter = {
isEnabled: boolean,
isValid: boolean,
type: 4,
};
export type EnvironmentNameComponentFilter = {
isEnabled: boolean,
isValid: boolean,
type: 5,
value: string,
};
export type ActivitySliceFilter = {
type: 6,
activityID: Element['id'],
rendererID: number,
isValid: boolean,
isEnabled: boolean,
};
export type ComponentFilter =
| BooleanComponentFilter
| ElementTypeComponentFilter
| RegExpComponentFilter
| EnvironmentNameComponentFilter
| ActivitySliceFilter;
export type HookName = string | null;
export type HookSourceLocationKey = string;
export type HookNames = Map<HookSourceLocationKey, HookName>;
export type LRUCache<K, V> = {
del: (key: K) => void,
get: (key: K) => V,
has: (key: K) => boolean,
reset: () => void,
set: (key: K, value: V) => void,
};
export type StyleXPlugin = {
sources: Array<string>,
resolvedStyles: Object,
};
export type Plugins = {
stylex: StyleXPlugin | null,
};
export const StrictMode = 1;
export type Element = {
id: number,
parentID: number,
children: Array<number>,
type: ElementType,
displayName: string | null,
key: number | string | null,
nameProp: null | string,
hocDisplayNames: null | Array<string>,
isCollapsed: boolean,
ownerID: number,
depth: number,
weight: number,
isStrictModeNonCompliant: boolean,
compiledWithForget: boolean,
};
export type Rect = {
x: number,
y: number,
width: number,
height: number,
};
export type SuspenseTimelineStep = {
id: SuspenseNode['id'] | Element['id'],
environment: null | string,
endTime: number,
};
export type SuspenseNode = {
id: Element['id'],
parentID: SuspenseNode['id'] | 0,
children: Array<SuspenseNode['id']>,
name: string | null,
rects: null | Array<Rect>,
hasUniqueSuspenders: boolean,
isSuspended: boolean,
environments: Array<string>,
endTime: number,
};
export type SerializedIOInfo = {
name: string,
description: string,
start: number,
end: number,
byteSize: null | number,
value: null | Promise<mixed>,
env: null | string,
owner: null | SerializedElement,
stack: null | ReactStackTrace,
};
export type SerializedAsyncInfo = {
awaited: SerializedIOInfo,
env: null | string,
owner: null | SerializedElement,
stack: null | ReactStackTrace,
};
export type SerializedElement = {
displayName: string | null,
id: number,
key: number | string | null,
env: null | string,
stack: null | ReactStackTrace,
hocDisplayNames: Array<string> | null,
compiledWithForget: boolean,
type: ElementType,
};
export type OwnersList = {
id: number,
owners: Array<SerializedElement> | null,
};
export type InspectedElementResponseType =
| 'error'
| 'full-data'
| 'hydrated-path'
| 'no-change'
| 'not-found';
export type InspectedElementPath = Array<string | number>;
export type InspectedElement = {
id: number,
canEditHooks: boolean,
canEditFunctionProps: boolean,
canEditHooksAndDeletePaths: boolean,
canEditHooksAndRenamePaths: boolean,
canEditFunctionPropsDeletePaths: boolean,
canEditFunctionPropsRenamePaths: boolean,
isErrored: boolean,
canToggleError: boolean,
canToggleSuspense: boolean,
isSuspended: boolean | null,
hasLegacyContext: boolean,
context: Object | null,
hooks: Object | null,
props: Object | null,
state: Object | null,
key: number | string | null,
errors: Array<[string, number]>,
warnings: Array<[string, number]>,
suspendedBy: Object,
suspendedByRange: null | [number, number],
unknownSuspenders: UnknownSuspendersReason,
owners: Array<SerializedElement> | null,
env: string | null,
source: ReactFunctionLocation | null,
stack: ReactStackTrace | null,
type: ElementType,
rootType: string | null,
rendererPackageName: string | null,
rendererVersion: string | null,
plugins: Plugins,
nativeTag: number | null,
};
type Data =
| string
| Dehydrated
| Unserializable
| Array<Dehydrated>
| Array<Unserializable>
| {[string]: Data};
export type DehydratedData = {
cleaned: Array<Array<string | number>>,
data: Data,
unserializable: Array<Array<string | number>>,
};