14
* Be mindful of backwards compatibility when making changes.
15
*/
16
17
+import type {Source} from 'shared/ReactElementType';
18
+import type {
19
+ Dehydrated,
20
+ Unserializable,
21
+} from 'react-devtools-shared/src/hydration';
22
+
23
export type BrowserTheme = 'dark' | 'light';
24
25
export type Wall = {
118
};
119
120
export const StrictMode = 1;
121
+
122
+// Each element on the frontend corresponds to a Fiber on the backend.
123
+// Some of its information (e.g. id, type, displayName) come from the backend.
124
+// Other bits (e.g. weight and depth) are computed on the frontend for windowing and display purposes.
125
+// Elements are updated on a push basis– meaning the backend pushes updates to the frontend when needed.
126
+export type Element = {
127
+ id: number,
128
+ parentID: number,
129
+ children: Array<number>,
130
+ type: ElementType,
131
+ displayName: string | null,
132
+ key: number | string | null,
133
+
134
+ hocDisplayNames: null | Array<string>,
135
+
136
+ // Should the elements children be visible in the tree?
137
+ isCollapsed: boolean,
138
+
139
+ // Owner (if available)
140
+ ownerID: number,
141
+
142
+ // How many levels deep within the tree is this element?
143
+ // This determines how much indentation (left padding) should be used in the Elements tree.
144
+ depth: number,
145
+
146
+ // How many nodes (including itself) are below this Element within the tree.
147
+ // This property is used to quickly determine the total number of Elements,
148
+ // and the Element at any given index (for windowing purposes).
149
+ weight: number,
150
+
151
+ // This element is not in a StrictMode compliant subtree.
152
+ // Only true for React versions supporting StrictMode.
153
+ isStrictModeNonCompliant: boolean,
154
+};
155
+
156
+export type SerializedElement = {
157
+ displayName: string | null,
158
+ id: number,
159
+ key: number | string | null,
160
+ hocDisplayNames: Array<string> | null,
161
+ type: ElementType,
162
+};
163
+
164
+export type OwnersList = {
165
+ id: number,
166
+ owners: Array<SerializedElement> | null,
167
+};
168
+
169
+export type InspectedElementResponseType =
170
+ | 'error'
171
+ | 'full-data'
172
+ | 'hydrated-path'
173
+ | 'no-change'
174
+ | 'not-found';
175
+
176
+export type InspectedElementPath = Array<string | number>;
177
+
178
+export type InspectedElement = {
179
+ id: number,
180
+
181
+ // Does the current renderer support editable hooks and function props?
182
+ canEditHooks: boolean,
183
+ canEditFunctionProps: boolean,
184
+
185
+ // Does the current renderer support advanced editing interface?
186
+ canEditHooksAndDeletePaths: boolean,
187
+ canEditHooksAndRenamePaths: boolean,
188
+ canEditFunctionPropsDeletePaths: boolean,
189
+ canEditFunctionPropsRenamePaths: boolean,
190
+
191
+ // Is this Error, and can its value be overridden now?
192
+ isErrored: boolean,
193
+ canToggleError: boolean,
194
+ targetErrorBoundaryID: ?number,
195
+
196
+ // Is this Suspense, and can its value be overridden now?
197
+ canToggleSuspense: boolean,
198
+
199
+ // Can view component source location.
200
+ canViewSource: boolean,
201
+
202
+ // Does the component have legacy context attached to it.
203
+ hasLegacyContext: boolean,
204
+
205
+ // Inspectable properties.
206
+ context: Object | null,
207
+ hooks: Object | null,
208
+ props: Object | null,
209
+ state: Object | null,
210
+ key: number | string | null,
211
+ errors: Array<[string, number]>,
212
+ warnings: Array<[string, number]>,
213
+
214
+ // List of owners
215
+ owners: Array<SerializedElement> | null,
216
+
217
+ // Location of component in source code.
218
+ source: Source | null,
219
+
220
+ type: ElementType,
221
+
222
+ // Meta information about the root this element belongs to.
223
+ rootType: string | null,
224
+
225
+ // Meta information about the renderer that created this element.
226
+ rendererPackageName: string | null,
227
+ rendererVersion: string | null,
228
+
229
+ // UI plugins/visualizations for the inspected element.
230
+ plugins: Plugins,
231
+};
232
+
233
+// TODO: Add profiling type
234
+
235
+type Data =
236
+ | string
237
+ | Dehydrated
238
+ | Unserializable
239
+ | Array<Dehydrated>
240
+ | Array<Unserializable>
241
+ | {[string]: Data};
242
+
243
+export type DehydratedData = {
244
+ cleaned: Array<Array<string | number>>,
245
+ data: Data,
246
+ unserializable: Array<Array<string | number>>,
247
+};