Flow: remove explicit object syntax (#25223)
Jan Kassens committed
Sep 9, 2022 at 16:03 UTC
8003ab9cf5c711eb00f741bbd89def56b066b999
259 files changed
+1439
-1444
packages/react-cache/src/LRU.js
+2
-2
@@ -16,12 +16,12 @@ const {
16
unstable_IdlePriority: IdlePriority,
17
} = Scheduler;
18
19
-type Entry<T> = {|
19
+type Entry<T> = {
20
value: T,
21
onDelete: () => mixed,
22
previous: Entry<T>,
23
next: Entry<T>,
24
-|};
24
+};
25
26
export function createLRU<T>(limit: number) {
27
let LIMIT = limit;
packages/react-cache/src/ReactCacheOld.js
+6
-6
@@ -15,20 +15,20 @@ import {createLRU} from './LRU';
15
16
type Suspender = {then(resolve: () => mixed, reject: () => mixed): mixed, ...};
17
18
-type PendingResult = {|
18
+type PendingResult = {
19
status: 0,
20
value: Suspender,
21
-|};
21
+};
22
23
-type ResolvedResult<V> = {|
23
+type ResolvedResult<V> = {
24
status: 1,
25
value: V,
26
-|};
26
+};
27
28
-type RejectedResult = {|
28
+type RejectedResult = {
29
status: 2,
30
value: mixed,
31
-|};
31
+};
32
33
type Result<V> = PendingResult | ResolvedResult<V> | RejectedResult;
34
packages/react-client/src/ReactFlightClient.js
+12
-12
@@ -34,7 +34,7 @@ export type JSONValue =
34
| null
35
| boolean
36
| string
37
- | {|+[key: string]: JSONValue|}
37
+ | {+[key: string]: JSONValue}
38
| $ReadOnlyArray<JSONValue>;
39
40
const PENDING = 0;
@@ -43,36 +43,36 @@ const RESOLVED_MODULE = 2;
43
const INITIALIZED = 3;
44
const ERRORED = 4;
45
46
-type PendingChunk = {|
46
+type PendingChunk = {
47
_status: 0,
48
_value: null | Array<() => mixed>,
49
_response: Response,
50
then(resolve: () => mixed): void,
51
-|};
52
-type ResolvedModelChunk = {|
51
+};
52
+type ResolvedModelChunk = {
53
_status: 1,
54
_value: UninitializedModel,
55
_response: Response,
56
then(resolve: () => mixed): void,
57
-|};
58
-type ResolvedModuleChunk<T> = {|
57
+};
58
+type ResolvedModuleChunk<T> = {
59
_status: 2,
60
_value: ModuleReference<T>,
61
_response: Response,
62
then(resolve: () => mixed): void,
63
-|};
64
-type InitializedChunk<T> = {|
63
+};
64
+type InitializedChunk<T> = {
65
_status: 3,
66
_value: T,
67
_response: Response,
68
then(resolve: () => mixed): void,
69
-|};
70
-type ErroredChunk = {|
69
+};
70
+type ErroredChunk = {
71
_status: 4,
72
_value: Error,
73
_response: Response,
74
then(resolve: () => mixed): void,
75
-|};
75
+};
76
type SomeChunk<T> =
77
| PendingChunk
78
| ResolvedModelChunk
@@ -338,7 +338,7 @@ export function parseModelString(
338
339
export function parseModelTuple(
340
response: Response,
341
- value: {|+[key: string]: JSONValue|} | $ReadOnlyArray<JSONValue>,
341
+ value: {+[key: string]: JSONValue} | $ReadOnlyArray<JSONValue>,
342
): any {
343
const tuple: [mixed, mixed, mixed, mixed] = (value: any);
344
packages/react-client/src/ReactFlightClientHostConfigStream.js
+2
-2
@@ -10,11 +10,11 @@
10
import type {ResponseBase} from './ReactFlightClient';
11
import type {StringDecoder} from './ReactFlightClientHostConfig';
12
13
-export type Response = ResponseBase & {|
13
+export type Response = ResponseBase & {
14
_partialRow: string,
15
_fromJSON: (key: string, value: JSONValue) => any,
16
_stringDecoder: StringDecoder,
17
-|};
17
+};
18
19
export type UninitializedModel = string;
20
packages/react-debug-tools/src/ReactDebugHooks.js
+6
-6
@@ -51,10 +51,10 @@ type Dispatch<A> = A => void;
51
52
let primitiveStackCache: null | Map<string, Array<any>> = null;
53
54
-type Hook = {|
54
+type Hook = {
55
memoizedState: any,
56
next: Hook | null,
57
-|};
57
+};
58
59
function getPrimitiveStackCache(): Map<string, Array<any>> {
60
// This initializes a cache of all primitive hooks so that the top
@@ -154,7 +154,7 @@ function useReducer<S, I, A>(
154
return [state, (action: A) => {}];
155
}
156
157
-function useRef<T>(initialValue: T): {|current: T|} {
157
+function useRef<T>(initialValue: T): {current: T} {
158
const hook = nextHook();
159
const ref = hook !== null ? hook.memoizedState : {current: initialValue};
160
hookLog.push({
@@ -208,7 +208,7 @@ function useEffect(
208
}
209
210
function useImperativeHandle<T>(
211
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
211
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
212
create: () => T,
213
inputs: Array<mixed> | void | null,
214
): void {
@@ -371,12 +371,12 @@ const DispatcherProxy = new Proxy(Dispatcher, DispatcherProxyHandler);
371
372
// Inspect
373
374
-export type HookSource = {|
374
+export type HookSource = {
375
lineNumber: number | null,
376
columnNumber: number | null,
377
fileName: string | null,
378
functionName: string | null,
379
-|};
379
+};
380
381
export type HooksNode = {
382
id: number | null,
packages/react-devtools-core/src/standalone.js
+4
-4
@@ -284,14 +284,14 @@ function connectToSocket(socket: WebSocket) {
284
};
285
}
286
287
-type ServerOptions = {|
287
+type ServerOptions = {
288
key?: string,
289
cert?: string,
290
-|};
290
+};
291
292
-type LoggerOptions = {|
292
+type LoggerOptions = {
293
surface?: ?string,
294
-|};
294
+};
295
296
function startServer(
297
port?: number = 8097,
packages/react-devtools-extensions/flow-typed/jest.js
+5
-5
@@ -206,7 +206,7 @@ type EnzymeMatchersType = {
206
toIncludeText(text: string): void,
207
toMatchElement(
208
element: React$Element<any>,
209
- options?: {|ignoreProps?: boolean, verbose?: boolean|}
209
+ options?: {ignoreProps?: boolean, verbose?: boolean}
210
): void,
211
toMatchSelector(selector: string): void,
212
// 7.x
@@ -1095,7 +1095,7 @@ type JestPrettyFormatPrint = any => string;
1095
// eslint-disable-next-line no-unused-vars
1096
type JestPrettyFormatStringOrNull = string | null;
1097
1098
-type JestPrettyFormatOptions = {|
1098
+type JestPrettyFormatOptions = {
1099
callToJSON: boolean,
1100
edgeSpacing: string,
1101
escapeRegex: boolean,
@@ -1107,14 +1107,14 @@ type JestPrettyFormatOptions = {|
1107
plugins: JestPrettyFormatPlugins,
1108
printFunctionName: boolean,
1109
spacing: string,
1110
- theme: {|
1110
+ theme: {
1111
comment: string,
1112
content: string,
1113
prop: string,
1114
tag: string,
1115
value: string,
1116
- |},
1117
-|};
1116
+ },
1117
+};
1118
1119
type JestPrettyFormatPlugin = {
1120
print: (
packages/react-devtools-inline/src/backend.js
+2
-2
@@ -78,9 +78,9 @@ export function activate(
78
contentWindow: window,
79
{
80
bridge,
81
- }: {|
81
+ }: {
82
bridge?: BackendBridge,
83
- |} = {},
83
+ } = {},
84
): void {
85
if (bridge == null) {
86
bridge = createBridge(contentWindow);
packages/react-devtools-inline/src/frontend.js
+4
-4
@@ -17,11 +17,11 @@ import type {Wall} from 'react-devtools-shared/src/types';
17
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
18
import type {Props} from 'react-devtools-shared/src/devtools/views/DevTools';
19
20
-type Config = {|
20
+type Config = {
21
checkBridgeProtocolCompatibility?: boolean,
22
supportsNativeInspection?: boolean,
23
supportsProfiling?: boolean,
24
-|};
24
+};
25
26
export function createStore(bridge: FrontendBridge, config?: Config): Store {
27
return new Store(bridge, {
@@ -62,10 +62,10 @@ export function initialize(
62
{
63
bridge,
64
store,
65
- }: {|
65
+ }: {
66
bridge?: FrontendBridge,
67
store?: Store,
68
- |} = {},
68
+ } = {},
69
): React.AbstractComponent<Props, mixed> {
70
if (bridge == null) {
71
bridge = createBridge(contentWindow);
packages/react-devtools-shared/src/Logger.js
+26
-26
@@ -10,57 +10,57 @@
10
import {enableLogger} from 'react-devtools-feature-flags';
11
12
export type LoggerEvent =
13
- | {|
13
+ | {
14
+event_name: 'loaded-dev-tools',
15
- |}
16
- | {|
15
+ }
16
+ | {
17
+event_name: 'error',
18
+error_message: string | null,
19
+error_stack: string | null,
20
+error_component_stack: string | null,
21
- |}
22
- | {|
21
+ }
22
+ | {
23
+event_name: 'selected-components-tab',
24
- |}
25
- | {|
24
+ }
25
+ | {
26
+event_name: 'selected-profiler-tab',
27
- |}
28
- | {|
27
+ }
28
+ | {
29
+event_name: 'load-hook-names',
30
+event_status: 'success' | 'error' | 'timeout' | 'unknown',
31
+duration_ms: number,
32
+inspected_element_display_name: string | null,
33
+inspected_element_number_of_hooks: number | null,
34
- |}
35
- | {|
34
+ }
35
+ | {
36
+event_name: 'select-element',
37
- +metadata: {|
37
+ +metadata: {
38
+source: string,
39
- |},
40
- |}
41
- | {|
39
+ },
40
+ }
41
+ | {
42
+event_name: 'inspect-element-button-clicked',
43
- |}
44
- | {|
43
+ }
44
+ | {
45
+event_name: 'profiling-start',
46
- +metadata: {|
46
+ +metadata: {
47
+current_tab: string,
48
- |},
49
- |}
50
- | {|
48
+ },
49
+ }
50
+ | {
51
+event_name: 'profiler-tab-changed',
52
- +metadata: {|
52
+ +metadata: {
53
+tabId: string,
54
- |},
55
- |}
56
- | {|
54
+ },
55
+ }
56
+ | {
57
+event_name: 'settings-changed',
58
+metadata: {
59
+key: string,
60
+value: any,
61
...
62
},
63
- |};
63
+ };
64
65
export type LogFunction = LoggerEvent => void | Promise<void>;
66
packages/react-devtools-shared/src/__tests__/profilingCache-test.js
+1
-4
@@ -202,10 +202,7 @@ describe('ProfilingCache', () => {
202
203
const ModernContext = React.createContext(0);
204
205
- class LegacyContextProvider extends React.Component<
206
- any,
207
- {|count: number|},
208
- > {
205
+ class LegacyContextProvider extends React.Component<any, {count: number}> {
206
static childContextTypes = {
207
count: PropTypes.number,
208
};
packages/react-devtools-shared/src/__tests__/profilingCharts-test.js
+2
-2
@@ -61,7 +61,7 @@ describe('profiling charts', () => {
61
describe('flamegraph chart', () => {
62
// @reactVersion >= 16.9
63
it('should contain valid data', () => {
64
- const Parent = (_: {||}) => {
64
+ const Parent = (_: {}) => {
65
Scheduler.unstable_advanceTime(10);
66
return (
67
<React.Fragment>
@@ -211,7 +211,7 @@ describe('profiling charts', () => {
211
describe('ranked chart', () => {
212
// @reactVersion >= 16.9
213
it('should contain valid data', () => {
214
- const Parent = (_: {||}) => {
214
+ const Parent = (_: {}) => {
215
Scheduler.unstable_advanceTime(10);
216
return (
217
<React.Fragment>
packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js
+1
-1
@@ -51,7 +51,7 @@ describe('Store component filters', () => {
51
52
// @reactVersion >= 16.0
53
it('should support filtering by element type', () => {
54
- class ClassComponent extends React.Component<{|children: React$Node|}> {
54
+ class ClassComponent extends React.Component<{children: React$Node}> {
55
render() {
56
return <div>{this.props.children}</div>;
57
}
packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js
+5
-5
@@ -25,7 +25,7 @@ export default function setupNativeStyleEditor(
25
) {
26
bridge.addListener(
27
'NativeStyleEditor_measure',
28
- ({id, rendererID}: {|id: number, rendererID: RendererID|}) => {
28
+ ({id, rendererID}: {id: number, rendererID: RendererID}) => {
29
measureStyle(agent, bridge, resolveNativeStyle, id, rendererID);
30
},
31
);
@@ -38,13 +38,13 @@ export default function setupNativeStyleEditor(
38
oldName,
39
newName,
40
value,
41
- }: {|
41
+ }: {
42
id: number,
43
rendererID: RendererID,
44
oldName: string,
45
newName: string,
46
value: string,
47
- |}) => {
47
+ }) => {
48
renameStyle(agent, id, rendererID, oldName, newName, value);
49
setTimeout(() =>
50
measureStyle(agent, bridge, resolveNativeStyle, id, rendererID),
@@ -59,12 +59,12 @@ export default function setupNativeStyleEditor(
59
rendererID,
60
name,
61
value,
62
- }: {|
62
+ }: {
63
id: number,
64
rendererID: number,
65
name: string,
66
value: string,
67
- |}) => {
67
+ }) => {
68
setStyle(agent, id, rendererID, name, value);
69
setTimeout(() =>
70
measureStyle(agent, bridge, resolveNativeStyle, id, rendererID),
packages/react-devtools-shared/src/backend/NativeStyleEditor/types.js
+6
-6
@@ -7,14 +7,14 @@
7
* @flow
8
*/
9
10
-export type BoxStyle = $ReadOnly<{|
10
+export type BoxStyle = $ReadOnly<{
11
bottom: number,
12
left: number,
13
right: number,
14
top: number,
15
-|}>;
15
+}>;
16
17
-export type Layout = {|
17
+export type Layout = {
18
x: number,
19
y: number,
20
width: number,
@@ -23,12 +23,12 @@ export type Layout = {|
23
top: number,
24
margin: BoxStyle,
25
padding: BoxStyle,
26
-|};
26
+};
27
28
export type Style = Object;
29
30
-export type StyleAndLayout = {|
30
+export type StyleAndLayout = {
31
id: number,
32
style: Style | null,
33
layout: Layout | null,
34
-|};
34
+};
packages/react-devtools-shared/src/backend/agent.js
+30
-30
@@ -53,102 +53,102 @@ const debug = (methodName, ...args) => {
53
}
54
};
55
56
-type ElementAndRendererID = {|
56
+type ElementAndRendererID = {
57
id: number,
58
rendererID: number,
59
-|};
59
+};
60
61
-type StoreAsGlobalParams = {|
61
+type StoreAsGlobalParams = {
62
count: number,
63
id: number,
64
path: Array<string | number>,
65
rendererID: number,
66
-|};
66
+};
67
68
-type CopyElementParams = {|
68
+type CopyElementParams = {
69
id: number,
70
path: Array<string | number>,
71
rendererID: number,
72
-|};
72
+};
73
74
-type InspectElementParams = {|
74
+type InspectElementParams = {
75
forceFullData: boolean,
76
id: number,
77
path: Array<string | number> | null,
78
rendererID: number,
79
requestID: number,
80
-|};
80
+};
81
82
-type OverrideHookParams = {|
82
+type OverrideHookParams = {
83
id: number,
84
hookID: number,
85
path: Array<string | number>,
86
rendererID: number,
87
wasForwarded?: boolean,
88
value: any,
89
-|};
89
+};
90
91
-type SetInParams = {|
91
+type SetInParams = {
92
id: number,
93
path: Array<string | number>,
94
rendererID: number,
95
wasForwarded?: boolean,
96
value: any,
97
-|};
97
+};
98
99
type PathType = 'props' | 'hooks' | 'state' | 'context';
100
101
-type DeletePathParams = {|
101
+type DeletePathParams = {
102
type: PathType,
103
hookID?: ?number,
104
id: number,
105
path: Array<string | number>,
106
rendererID: number,
107
-|};
107
+};
108
109
-type RenamePathParams = {|
109
+type RenamePathParams = {
110
type: PathType,
111
hookID?: ?number,
112
id: number,
113
oldPath: Array<string | number>,
114
newPath: Array<string | number>,
115
rendererID: number,
116
-|};
116
+};
117
118
-type OverrideValueAtPathParams = {|
118
+type OverrideValueAtPathParams = {
119
type: PathType,
120
hookID?: ?number,
121
id: number,
122
path: Array<string | number>,
123
rendererID: number,
124
value: any,
125
-|};
125
+};
126
127
-type OverrideErrorParams = {|
127
+type OverrideErrorParams = {
128
id: number,
129
rendererID: number,
130
forceError: boolean,
131
-|};
131
+};
132
133
-type OverrideSuspenseParams = {|
133
+type OverrideSuspenseParams = {
134
id: number,
135
rendererID: number,
136
forceFallback: boolean,
137
-|};
137
+};
138
139
-type PersistedSelection = {|
139
+type PersistedSelection = {
140
rendererID: number,
141
path: Array<PathFrame>,
142
-|};
142
+};
143
144
-export default class Agent extends EventEmitter<{|
144
+export default class Agent extends EventEmitter<{
145
hideNativeHighlight: [],
146
showNativeHighlight: [NativeType],
147
startInspectingNative: [],
148
stopInspectingNative: [],
149
shutdown: [],
150
traceUpdates: [Set<NativeType>],
151
-|}> {
151
+}> {
152
_bridge: BackendBridge;
153
_isProfiling: boolean = false;
154
_recordChangeDescriptions: boolean = false;
@@ -254,7 +254,7 @@ export default class Agent extends EventEmitter<{|
254
return this._rendererInterfaces;
255
}
256
257
- clearErrorsAndWarnings = ({rendererID}: {|rendererID: RendererID|}) => {
257
+ clearErrorsAndWarnings = ({rendererID}: {rendererID: RendererID}) => {
258
const renderer = this._rendererInterfaces[rendererID];
259
if (renderer == null) {
260
console.warn(`Invalid renderer id "${rendererID}"`);
@@ -355,7 +355,7 @@ export default class Agent extends EventEmitter<{|
355
this._bridge.send('bridgeProtocol', currentBridgeProtocol);
356
};
357
358
- getProfilingData = ({rendererID}: {|rendererID: RendererID|}) => {
358
+ getProfilingData = ({rendererID}: {rendererID: RendererID}) => {
359
const renderer = this._rendererInterfaces[rendererID];
360
if (renderer == null) {
361
console.warn(`Invalid renderer id "${rendererID}"`);
@@ -676,13 +676,13 @@ export default class Agent extends EventEmitter<{|
676
showInlineWarningsAndErrors,
677
hideConsoleLogsInStrictMode,
678
browserTheme,
679
- }: {|
679
+ }: {
680
appendComponentStack: boolean,
681
breakOnConsoleErrors: boolean,
682
showInlineWarningsAndErrors: boolean,
683
hideConsoleLogsInStrictMode: boolean,
684
browserTheme: BrowserTheme,
685
- |}) => {
685
+ }) => {
686
// If the frontend preference has change,
687
// or in the case of React Native- if the backend is just finding out the preference-
688
// then reinstall the console overrides.
packages/react-devtools-shared/src/backend/console.js
+4
-4
@@ -69,12 +69,12 @@ type OnErrorOrWarning = (
69
70
const injectedRenderers: Map<
71
ReactRenderer,
72
- {|
72
+ {
73
currentDispatcherRef: CurrentDispatcherRef,
74
getCurrentFiber: () => Fiber | null,
75
onErrorOrWarning: ?OnErrorOrWarning,
76
workTagMap: WorkTagMap,
77
- |},
77
+ },
78
> = new Map();
79
80
let targetConsole: Object = console;
@@ -151,13 +151,13 @@ export function patch({
151
showInlineWarningsAndErrors,
152
hideConsoleLogsInStrictMode,
153
browserTheme,
154
-}: {|
154
+}: {
155
appendComponentStack: boolean,
156
breakOnConsoleErrors: boolean,
157
showInlineWarningsAndErrors: boolean,
158
hideConsoleLogsInStrictMode: boolean,
159
browserTheme: BrowserTheme,
160
-|}): void {
160
+}): void {
161
// Settings may change after we've patched the console.
162
// Using a shared ref allows the patch function to read the latest values.
163
consoleSettingsRef.appendComponentStack = appendComponentStack;
packages/react-devtools-shared/src/backend/profilingHooks.js
+4
-4
@@ -93,11 +93,11 @@ export function setPerformanceMock_ONLY_FOR_TESTING(
93
export type GetTimelineData = () => TimelineData | null;
94
export type ToggleProfilingStatus = (value: boolean) => void;
95
96
-type Response = {|
96
+type Response = {
97
getTimelineData: GetTimelineData,
98
profilingHooks: DevToolsProfilingHooks,
99
toggleProfilingStatus: ToggleProfilingStatus,
100
-|};
100
+};
101
102
export function createProfilingHooks({
103
getDisplayNameForFiber,
@@ -106,14 +106,14 @@ export function createProfilingHooks({
106
workTagMap,
107
currentDispatcherRef,
108
reactVersion,
109
-}: {|
109
+}: {
110
getDisplayNameForFiber: (fiber: Fiber) => string | null,
111
getIsProfiling: () => boolean,
112
getLaneLabelMap?: () => Map<Lane, string> | null,
113
currentDispatcherRef?: CurrentDispatcherRef,
114
workTagMap: WorkTagMap,
115
reactVersion: string,
116
-|}): Response {
116
+}): Response {
117
let currentBatchUID: BatchUID = 0;
118
let currentReactComponentMeasure: ReactComponentMeasure | null = null;
119
let currentReactMeasuresStack: Array<ReactMeasure> = [];
packages/react-devtools-shared/src/backend/renderer.js
+10
-10
@@ -126,23 +126,23 @@ import type {
126
type getDisplayNameForFiberType = (fiber: Fiber) => string | null;
127
type getTypeSymbolType = (type: any) => symbol | number;
128
129
-type ReactPriorityLevelsType = {|
129
+type ReactPriorityLevelsType = {
130
ImmediatePriority: number,
131
UserBlockingPriority: number,
132
NormalPriority: number,
133
LowPriority: number,
134
IdlePriority: number,
135
NoPriority: number,
136
-|};
136
+};
137
138
-type ReactTypeOfSideEffectType = {|
138
+type ReactTypeOfSideEffectType = {
139
DidCapture: number,
140
NoFlags: number,
141
PerformedWork: number,
142
Placement: number,
143
Incomplete: number,
144
Hydrating: number,
145
-|};
145
+};
146
147
function getFiberFlags(fiber: Fiber): number {
148
// The name of this field changed from "effectTag" to "flags"
@@ -157,14 +157,14 @@ const getCurrentTime =
157
158
export function getInternalReactConstants(
159
version: string,
160
-): {|
160
+): {
161
getDisplayNameForFiber: getDisplayNameForFiberType,
162
getTypeSymbol: getTypeSymbolType,
163
ReactPriorityLevels: ReactPriorityLevelsType,
164
ReactTypeOfSideEffect: ReactTypeOfSideEffectType,
165
ReactTypeOfWork: WorkTagMap,
166
StrictModeBits: number,
167
-|} {
167
+} {
168
const ReactTypeOfSideEffect: ReactTypeOfSideEffectType = {
169
DidCapture: 0b10000000,
170
NoFlags: 0b00,
@@ -1595,10 +1595,10 @@ export function attach(
1595
1596
type OperationsArray = Array<number>;
1597
1598
- type StringTableEntry = {|
1598
+ type StringTableEntry = {
1599
encodedString: Array<number>,
1600
id: number,
1601
- |};
1601
+ };
1602
1603
const pendingOperations: OperationsArray = [];
1604
const pendingRealUnmountedIDs: Array<number> = [];
@@ -3950,7 +3950,7 @@ export function attach(
3950
}
3951
}
3952
3953
- type CommitProfilingData = {|
3953
+ type CommitProfilingData = {
3954
changeDescriptions: Map<number, ChangeDescription> | null,
3955
commitTime: number,
3956
durations: Array<number>,
@@ -3959,7 +3959,7 @@ export function attach(
3959
passiveEffectDuration: number | null,
3960
priorityLevel: string | null,
3961
updaters: Array<SerializedElement> | null,
3962
- |};
3962
+ };
3963
3964
type CommitProfilingMetadataMap = Map<number, Array<CommitProfilingData>>;
3965
type DisplayNamesByRootID = Map<number, string>;
packages/react-devtools-shared/src/backend/types.js
+37
-37
@@ -26,7 +26,7 @@ export type WorkTag = number;
26
export type WorkFlags = number;
27
export type ExpirationTime = number;
28
29
-export type WorkTagMap = {|
29
+export type WorkTagMap = {
30
CacheComponent: WorkTag,
31
ClassComponent: WorkTag,
32
ContextConsumer: WorkTag,
@@ -55,22 +55,22 @@ export type WorkTagMap = {|
55
SuspenseListComponent: WorkTag,
56
TracingMarkerComponent: WorkTag,
57
YieldComponent: WorkTag,
58
-|};
58
+};
59
60
// TODO: If it's useful for the frontend to know which types of data an Element has
61
// (e.g. props, state, context, hooks) then we could add a bitmask field for this
62
// to keep the number of attributes small.
63
-export type FiberData = {|
63
+export type FiberData = {
64
key: string | null,
65
displayName: string | null,
66
type: ElementType,
67
-|};
67
+};
68
69
export type NativeType = Object;
70
export type RendererID = number;
71
72
type Dispatcher = any;
73
-export type CurrentDispatcherRef = {|current: null | Dispatcher|};
73
+export type CurrentDispatcherRef = {current: null | Dispatcher};
74
75
export type GetDisplayNameForFiberID = (
76
id: number,
@@ -158,16 +158,16 @@ export type ReactRenderer = {
158
...
159
};
160
161
-export type ChangeDescription = {|
161
+export type ChangeDescription = {
162
context: Array<string> | boolean | null,
163
didHooksChange: boolean,
164
isFirstMount: boolean,
165
props: Array<string> | null,
166
state: Array<string> | null,
167
hooks?: Array<number> | null,
168
-|};
168
+};
169
170
-export type CommitDataBackend = {|
170
+export type CommitDataBackend = {
171
// Tuple of fiber ID and change description
172
changeDescriptions: Array<[number, ChangeDescription]> | null,
173
duration: number,
@@ -182,48 +182,48 @@ export type CommitDataBackend = {|
182
priorityLevel: string | null,
183
timestamp: number,
184
updaters: Array<SerializedElement> | null,
185
-|};
185
+};
186
187
-export type ProfilingDataForRootBackend = {|
187
+export type ProfilingDataForRootBackend = {
188
commitData: Array<CommitDataBackend>,
189
displayName: string,
190
// Tuple of Fiber ID and base duration
191
initialTreeBaseDurations: Array<[number, number]>,
192
rootID: number,
193
-|};
193
+};
194
195
// Profiling data collected by the renderer interface.
196
// This information will be passed to the frontend and combined with info it collects.
197
-export type ProfilingDataBackend = {|
197
+export type ProfilingDataBackend = {
198
dataForRoots: Array<ProfilingDataForRootBackend>,
199
rendererID: number,
200
timelineData: TimelineDataExport | null,
201
-|};
201
+};
202
203
-export type PathFrame = {|
203
+export type PathFrame = {
204
key: string | null,
205
index: number,
206
displayName: string | null,
207
-|};
207
+};
208
209
-export type PathMatch = {|
209
+export type PathMatch = {
210
id: number,
211
isFullMatch: boolean,
212
-|};
212
+};
213
214
-export type SerializedElement = {|
214
+export type SerializedElement = {
215
displayName: string | null,
216
id: number,
217
key: number | string | null,
218
type: ElementType,
219
-|};
219
+};
220
221
-export type OwnersList = {|
221
+export type OwnersList = {
222
id: number,
223
owners: Array<SerializedElement> | null,
224
-|};
224
+};
225
226
-export type InspectedElement = {|
226
+export type InspectedElement = {
227
id: number,
228
229
displayName: string | null,
@@ -278,48 +278,48 @@ export type InspectedElement = {|
278
279
// UI plugins/visualizations for the inspected element.
280
plugins: Plugins,
281
-|};
281
+};
282
283
export const InspectElementErrorType = 'error';
284
export const InspectElementFullDataType = 'full-data';
285
export const InspectElementNoChangeType = 'no-change';
286
export const InspectElementNotFoundType = 'not-found';
287
288
-export type InspectElementError = {|
288
+export type InspectElementError = {
289
id: number,
290
responseID: number,
291
type: 'error',
292
errorType: 'user' | 'unknown-hook' | 'uncaught',
293
message: string,
294
stack?: string,
295
-|};
295
+};
296
297
-export type InspectElementFullData = {|
297
+export type InspectElementFullData = {
298
id: number,
299
responseID: number,
300
type: 'full-data',
301
value: InspectedElement,
302
-|};
302
+};
303
304
-export type InspectElementHydratedPath = {|
304
+export type InspectElementHydratedPath = {
305
id: number,
306
responseID: number,
307
type: 'hydrated-path',
308
path: Array<string | number>,
309
value: any,
310
-|};
310
+};
311
312
-export type InspectElementNoChange = {|
312
+export type InspectElementNoChange = {
313
id: number,
314
responseID: number,
315
type: 'no-change',
316
-|};
316
+};
317
318
-export type InspectElementNotFound = {|
318
+export type InspectElementNotFound = {
319
id: number,
320
responseID: number,
321
type: 'not-found',
322
-|};
322
+};
323
324
export type InspectedElementPayload =
325
| InspectElementError
@@ -328,10 +328,10 @@ export type InspectedElementPayload =
328
| InspectElementNoChange
329
| InspectElementNotFound;
330
331
-export type InstanceAndStyle = {|
331
+export type InstanceAndStyle = {
332
instance: Object | null,
333
style: Object | null,
334
-|};
334
+};
335
336
type Type = 'props' | 'hooks' | 'state' | 'context';
337
@@ -411,7 +411,7 @@ export type Handler = (data: any) => void;
411
412
// Renderers use these APIs to report profiling data to DevTools at runtime.
413
// They get passed from the DevTools backend to the reconciler during injection.
414
-export type DevToolsProfilingHooks = {|
414
+export type DevToolsProfilingHooks = {
415
// Scheduling methods:
416
markRenderScheduled: (lane: Lane) => void,
417
markStateUpdateScheduled: (fiber: Fiber, lane: Lane) => void,
@@ -449,7 +449,7 @@ export type DevToolsProfilingHooks = {|
449
markComponentPassiveEffectMountStopped: () => void,
450
markComponentPassiveEffectUnmountStarted: (fiber: Fiber) => void,
451
markComponentPassiveEffectUnmountStopped: () => void,
452
-|};
452
+};
453
454
export type DevToolsHook = {
455
listeners: {[key: string]: Array<Handler>, ...},
packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
+1
-1
@@ -12,7 +12,7 @@ import {getElementDimensions, getNestedBoundingClientRect} from '../utils';
12
import type {Rect} from '../utils';
13
import type Agent from 'react-devtools-shared/src/backend/agent';
14
15
-type Box = {|top: number, left: number, width: number, height: number|};
15
+type Box = {top: number, left: number, width: number, height: number};
16
17
const assign = Object.assign;
18
packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js
+2
-2
@@ -30,12 +30,12 @@ const getCurrentTime =
30
? () => performance.now()
31
: () => Date.now();
32
33
-export type Data = {|
33
+export type Data = {
34
count: number,
35
expirationTime: number,
36
lastMeasuredAt: number,
37
rect: Rect | null,
38
-|};
38
+};
39
40
const nodeToData: Map<NativeType, Data> = new Map();
41
packages/react-devtools-shared/src/backendAPI.js
+12
-12
@@ -28,10 +28,10 @@ import type {
28
export function clearErrorsAndWarnings({
29
bridge,
30
store,
31
-}: {|
31
+}: {
32
bridge: FrontendBridge,
33
store: Store,
34
-|}): void {
34
+}): void {
35
store.rootIDToRendererID.forEach(rendererID => {
36
bridge.send('clearErrorsAndWarnings', {rendererID});
37
});
@@ -41,11 +41,11 @@ export function clearErrorsForElement({
41
bridge,
42
id,
43
rendererID,
44
-}: {|
44
+}: {
45
bridge: FrontendBridge,
46
id: number,
47
rendererID: number,
48
-|}): void {
48
+}): void {
49
bridge.send('clearErrorsForFiberID', {
50
rendererID,
51
id,
@@ -56,11 +56,11 @@ export function clearWarningsForElement({
56
bridge,
57
id,
58
rendererID,
59
-}: {|
59
+}: {
60
bridge: FrontendBridge,
61
id: number,
62
rendererID: number,
63
-|}): void {
63
+}): void {
64
bridge.send('clearWarningsForFiberID', {
65
rendererID,
66
id,
@@ -72,12 +72,12 @@ export function copyInspectedElementPath({
72
id,
73
path,
74
rendererID,
75
-}: {|
75
+}: {
76
bridge: FrontendBridge,
77
id: number,
78
path: Array<string | number>,
79
rendererID: number,
80
-|}): void {
80
+}): void {
81
bridge.send('copyElementPath', {
82
id,
83
path,
@@ -91,13 +91,13 @@ export function inspectElement({
91
id,
92
path,
93
rendererID,
94
-}: {|
94
+}: {
95
bridge: FrontendBridge,
96
forceFullData: boolean,
97
id: number,
98
path: Array<string | number> | null,
99
rendererID: number,
100
-|}): Promise<InspectedElementPayload> {
100
+}): Promise<InspectedElementPayload> {
101
const requestID = requestCounter++;
102
const promise = getPromiseForRequestID<InspectedElementPayload>(
103
requestID,
@@ -124,12 +124,12 @@ export function storeAsGlobal({
124
id,
125
path,
126
rendererID,
127
-}: {|
127
+}: {
128
bridge: FrontendBridge,
129
id: number,
130
path: Array<string | number>,
131
rendererID: number,
132
-|}): void {
132
+}): void {
133
bridge.send('storeAsGlobal', {
134
count: storeAsGlobalCount++,
135
id,
packages/react-devtools-shared/src/bridge.js
+46
-46
@@ -24,7 +24,7 @@ const BATCH_DURATION = 100;
24
// This message specifies the version of the DevTools protocol currently supported by the backend,
25
// as well as the earliest NPM version (e.g. "4.13.0") that protocol is supported by on the frontend.
26
// This enables an older frontend to display an upgrade message to users for a newer, unsupported backend.
27
-export type BridgeProtocol = {|
27
+export type BridgeProtocol = {
28
// Version supported by the current frontend/backend.
29
version: number,
30
@@ -32,7 +32,7 @@ export type BridgeProtocol = {|
32
// Note that 'maxNpmVersion' is only set when the version is bumped.
33
minNpmVersion: string,
34
maxNpmVersion: string | null,
35
-|};
35
+};
36
37
// Bump protocol version whenever a backwards breaking change is made
38
// in the messages sent between BackendBridge and FrontendBridge.
@@ -73,121 +73,121 @@ export const BRIDGE_PROTOCOL: Array<BridgeProtocol> = [
73
export const currentBridgeProtocol: BridgeProtocol =
74
BRIDGE_PROTOCOL[BRIDGE_PROTOCOL.length - 1];
75
76
-type ElementAndRendererID = {|id: number, rendererID: RendererID|};
76
+type ElementAndRendererID = {id: number, rendererID: RendererID};
77
78
-type Message = {|
78
+type Message = {
79
event: string,
80
payload: any,
81
-|};
81
+};
82
83
-type HighlightElementInDOM = {|
83
+type HighlightElementInDOM = {
84
...ElementAndRendererID,
85
displayName: string | null,
86
hideAfterTimeout: boolean,
87
openNativeElementsPanel: boolean,
88
scrollIntoView: boolean,
89
-|};
89
+};
90
91
-type OverrideValue = {|
91
+type OverrideValue = {
92
...ElementAndRendererID,
93
path: Array<string | number>,
94
wasForwarded?: boolean,
95
value: any,
96
-|};
96
+};
97
98
-type OverrideHookState = {|
98
+type OverrideHookState = {
99
...OverrideValue,
100
hookID: number,
101
-|};
101
+};
102
103
type PathType = 'props' | 'hooks' | 'state' | 'context';
104
105
-type DeletePath = {|
105
+type DeletePath = {
106
...ElementAndRendererID,
107
type: PathType,
108
hookID?: ?number,
109
path: Array<string | number>,
110
-|};
110
+};
111
112
-type RenamePath = {|
112
+type RenamePath = {
113
...ElementAndRendererID,
114
type: PathType,
115
hookID?: ?number,
116
oldPath: Array<string | number>,
117
newPath: Array<string | number>,
118
-|};
118
+};
119
120
-type OverrideValueAtPath = {|
120
+type OverrideValueAtPath = {
121
...ElementAndRendererID,
122
type: PathType,
123
hookID?: ?number,
124
path: Array<string | number>,
125
value: any,
126
-|};
126
+};
127
128
-type OverrideError = {|
128
+type OverrideError = {
129
...ElementAndRendererID,
130
forceError: boolean,
131
-|};
131
+};
132
133
-type OverrideSuspense = {|
133
+type OverrideSuspense = {
134
...ElementAndRendererID,
135
forceFallback: boolean,
136
-|};
136
+};
137
138
-type CopyElementPathParams = {|
138
+type CopyElementPathParams = {
139
...ElementAndRendererID,
140
path: Array<string | number>,
141
-|};
141
+};
142
143
-type ViewAttributeSourceParams = {|
143
+type ViewAttributeSourceParams = {
144
...ElementAndRendererID,
145
path: Array<string | number>,
146
-|};
146
+};
147
148
-type InspectElementParams = {|
148
+type InspectElementParams = {
149
...ElementAndRendererID,
150
forceFullData: boolean,
151
path: Array<number | string> | null,
152
requestID: number,
153
-|};
153
+};
154
155
-type StoreAsGlobalParams = {|
155
+type StoreAsGlobalParams = {
156
...ElementAndRendererID,
157
count: number,
158
path: Array<string | number>,
159
-|};
159
+};
160
161
-type NativeStyleEditor_RenameAttributeParams = {|
161
+type NativeStyleEditor_RenameAttributeParams = {
162
...ElementAndRendererID,
163
oldName: string,
164
newName: string,
165
value: string,
166
-|};
166
+};
167
168
-type NativeStyleEditor_SetValueParams = {|
168
+type NativeStyleEditor_SetValueParams = {
169
...ElementAndRendererID,
170
name: string,
171
value: string,
172
-|};
172
+};
173
174
-type UpdateConsolePatchSettingsParams = {|
174
+type UpdateConsolePatchSettingsParams = {
175
appendComponentStack: boolean,
176
breakOnConsoleErrors: boolean,
177
showInlineWarningsAndErrors: boolean,
178
hideConsoleLogsInStrictMode: boolean,
179
browserTheme: BrowserTheme,
180
-|};
180
+};
181
182
-type SavedPreferencesParams = {|
182
+type SavedPreferencesParams = {
183
appendComponentStack: boolean,
184
breakOnConsoleErrors: boolean,
185
componentFilters: Array<ComponentFilter>,
186
showInlineWarningsAndErrors: boolean,
187
hideConsoleLogsInStrictMode: boolean,
188
-|};
188
+};
189
190
-export type BackendEvents = {|
190
+export type BackendEvents = {
191
backendVersion: [string],
192
bridgeProtocol: [BridgeProtocol],
193
extensionBackendInitialized: [],
@@ -211,13 +211,13 @@ export type BackendEvents = {|
211
212
// React Native style editor plug-in.
213
isNativeStyleEditorSupported: [
214
- {|isSupported: boolean, validAttributes: ?$ReadOnlyArray<string>|},
214
+ {isSupported: boolean, validAttributes: ?$ReadOnlyArray<string>},
215
],
216
NativeStyleEditor_styleAndLayout: [StyleAndLayoutPayload],
217
-|};
217
+};
218
219
-type FrontendEvents = {|
220
- clearErrorsAndWarnings: [{|rendererID: RendererID|}],
219
+type FrontendEvents = {
220
+ clearErrorsAndWarnings: [{rendererID: RendererID}],
221
clearErrorsForFiberID: [ElementAndRendererID],
222
clearNativeElementHighlight: [],
223
clearWarningsForFiberID: [ElementAndRendererID],
@@ -226,7 +226,7 @@ type FrontendEvents = {|
226
getBackendVersion: [],
227
getBridgeProtocol: [],
228
getOwnersList: [ElementAndRendererID],
229
- getProfilingData: [{|rendererID: RendererID|}],
229
+ getProfilingData: [{rendererID: RendererID}],
230
getProfilingStatus: [],
231
highlightNativeElement: [HighlightElementInDOM],
232
inspectElement: [InspectElementParams],
@@ -270,15 +270,15 @@ type FrontendEvents = {|
270
overrideHookState: [OverrideHookState],
271
overrideProps: [OverrideValue],
272
overrideState: [OverrideValue],
273
-|};
273
+};
274
275
class Bridge<
276
OutgoingEvents: Object,
277
IncomingEvents: Object,
278
-> extends EventEmitter<{|
278
+> extends EventEmitter<{
279
...IncomingEvents,
280
...OutgoingEvents,
281
-|}> {
281
+}> {
282
_isShutdown: boolean = false;
283
_messageQueue: Array<any> = [];
284
_timeoutID: TimeoutID | null = null;
packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js
+2
-2
@@ -48,10 +48,10 @@ const HIDDEN_STATE = {
48
pageY: 0,
49
};
50
51
-type Props = {|
51
+type Props = {
52
children: (data: Object) => React$Node,
53
id: string,
54
-|};
54
+};
55
56
export default function ContextMenu({children, id}: Props) {
57
const {hideMenu, registerMenu} = useContext<RegistryContextType>(
packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenuItem.js
+2
-2
@@ -15,11 +15,11 @@ import styles from './ContextMenuItem.css';
15
16
import type {RegistryContextType} from './Contexts';
17
18
-type Props = {|
18
+type Props = {
19
children: React$Node,
20
onClick: () => void,
21
title: string,
22
-|};
22
+};
23
24
export default function ContextMenuItem({children, onClick, title}: Props) {
25
const {hideMenu} = useContext<RegistryContextType>(RegistryContext);
packages/react-devtools-shared/src/devtools/ContextMenu/Contexts.js
+5
-5
@@ -9,7 +9,7 @@
9
10
import {createContext} from 'react';
11
12
-export type ShowFn = ({|data: Object, pageX: number, pageY: number|}) => void;
12
+export type ShowFn = ({data: Object, pageX: number, pageY: number}) => void;
13
export type HideFn = () => void;
14
export type OnChangeFn = boolean => void;
15
@@ -38,13 +38,13 @@ function showMenu({
38
onChange,
39
pageX,
40
pageY,
41
-}: {|
41
+}: {
42
data: Object,
43
id: string,
44
onChange?: OnChangeFn,
45
pageX: number,
46
pageY: number,
47
-|}) {
47
+}) {
48
const showFn = idToShowFnMap.get(id);
49
if (typeof showFn === 'function') {
50
// Prevent open menus from being left hanging.
@@ -75,11 +75,11 @@ function registerMenu(id: string, showFn: ShowFn, hideFn: HideFn) {
75
};
76
}
77
78
-export type RegistryContextType = {|
78
+export type RegistryContextType = {
79
hideMenu: typeof hideMenu,
80
showMenu: typeof showMenu,
81
registerMenu: typeof registerMenu,
82
-|};
82
+};
83
84
export const RegistryContext = createContext<RegistryContextType>({
85
hideMenu,
packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js
+3
-3
@@ -18,12 +18,12 @@ export default function useContextMenu({
18
id,
19
onChange,
20
ref,
21
-}: {|
21
+}: {
22
data: Object,
23
id: string,
24
onChange?: OnChangeFn,
25
- ref: {|current: ElementRef<*> | null|},
26
-|}) {
25
+ ref: {current: ElementRef<*> | null},
26
+}) {
27
const {showMenu} = useContext<RegistryContextType>(RegistryContext);
28
29
useEffect(() => {
packages/react-devtools-shared/src/devtools/ProfilerStore.js
+2
-2
@@ -21,11 +21,11 @@ import type {
21
SnapshotNode,
22
} from './views/Profiler/types';
23
24
-export default class ProfilerStore extends EventEmitter<{|
24
+export default class ProfilerStore extends EventEmitter<{
25
isProcessingData: [],
26
isProfiling: [],
27
profilingData: [],
28
-|}> {
28
+}> {
29
_bridge: FrontendBridge;
30
31
// Suspense cache for lazily calculating derived profiling data.
packages/react-devtools-shared/src/devtools/ProfilingCache.js
+8
-8
@@ -36,10 +36,10 @@ export default class ProfilingCache {
36
getCommitTree = ({
37
commitIndex,
38
rootID,
39
- }: {|
39
+ }: {
40
commitIndex: number,
41
rootID: number,
42
- |}) =>
42
+ }) =>
43
getCommitTree({
44
commitIndex,
45
profilerStore: this._profilerStore,
@@ -49,10 +49,10 @@ export default class ProfilingCache {
49
getFiberCommits = ({
50
fiberID,
51
rootID,
52
- }: {|
52
+ }: {
53
fiberID: number,
54
rootID: number,
55
- |}): Array<number> => {
55
+ }): Array<number> => {
56
const cachedFiberCommits = this._fiberCommits.get(fiberID);
57
if (cachedFiberCommits != null) {
58
return cachedFiberCommits;
@@ -75,11 +75,11 @@ export default class ProfilingCache {
75
commitIndex,
76
commitTree,
77
rootID,
78
- }: {|
78
+ }: {
79
commitIndex: number,
80
commitTree: CommitTree,
81
rootID: number,
82
- |}): FlamegraphChartData =>
82
+ }): FlamegraphChartData =>
83
getFlamegraphChartData({
84
commitIndex,
85
commitTree,
@@ -91,11 +91,11 @@ export default class ProfilingCache {
91
commitIndex,
92
commitTree,
93
rootID,
94
- }: {|
94
+ }: {
95
commitIndex: number,
96
commitTree: CommitTree,
97
rootID: number,
98
- |}): RankedChartData =>
98
+ }): RankedChartData =>
99
getRankedChartData({
100
commitIndex,
101
commitTree,
packages/react-devtools-shared/src/devtools/cache.js
+6
-6
@@ -28,20 +28,20 @@ export type {Thenable};
28
29
type Suspender = {then(resolve: () => mixed, reject: () => mixed): mixed, ...};
30
31
-type PendingResult = {|
31
+type PendingResult = {
32
status: 0,
33
value: Suspender,
34
-|};
34
+};
35
36
-type ResolvedResult<Value> = {|
36
+type ResolvedResult<Value> = {
37
status: 1,
38
value: Value,
39
-|};
39
+};
40
41
-type RejectedResult = {|
41
+type RejectedResult = {
42
status: 2,
43
value: mixed,
44
-|};
44
+};
45
46
type Result<Value> = PendingResult | ResolvedResult<Value> | RejectedResult;
47
packages/react-devtools-shared/src/devtools/index.js
+2
-2
@@ -9,10 +9,10 @@
9
10
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
11
12
-type Shell = {|
12
+type Shell = {
13
connect: (callback: Function) => void,
14
onReload: (reloadFn: Function) => void,
15
-|};
15
+};
16
17
export function initDevTools(shell: Shell) {
18
shell.connect((bridge: FrontendBridge) => {
packages/react-devtools-shared/src/devtools/store.js
+12
-12
@@ -62,9 +62,9 @@ const LOCAL_STORAGE_COLLAPSE_ROOTS_BY_DEFAULT_KEY =
62
const LOCAL_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY =
63
'React::DevTools::recordChangeDescriptions';
64
65
-type ErrorAndWarningTuples = Array<{|id: number, index: number|}>;
65
+type ErrorAndWarningTuples = Array<{id: number, index: number}>;
66
67
-type Config = {|
67
+type Config = {
68
checkBridgeProtocolCompatibility?: boolean,
69
isProfiling?: boolean,
70
supportsNativeInspection?: boolean,
@@ -72,20 +72,20 @@ type Config = {|
72
supportsReloadAndProfile?: boolean,
73
supportsTimeline?: boolean,
74
supportsTraceUpdates?: boolean,
75
-|};
75
+};
76
77
-export type Capabilities = {|
77
+export type Capabilities = {
78
supportsBasicProfiling: boolean,
79
hasOwnerMetadata: boolean,
80
supportsStrictMode: boolean,
81
supportsTimeline: boolean,
82
-|};
82
+};
83
84
/**
85
* The store is the single source of truth for updates from the backend.
86
* ContextProviders can subscribe to the Store for specific things they want to provide.
87
*/
88
-export default class Store extends EventEmitter<{|
88
+export default class Store extends EventEmitter<{
89
backendVersion: [],
90
collapseNodesByDefault: [],
91
componentFilters: [],
@@ -99,7 +99,7 @@ export default class Store extends EventEmitter<{|
99
supportsReloadAndProfile: [],
100
unsupportedBridgeProtocolDetected: [],
101
unsupportedRendererVersionDetected: [],
102
-|}> {
102
+}> {
103
// If the backend version is new enough to report its (NPM) version, this is it.
104
// This version may be displayed by the frontend for debugging purposes.
105
_backendVersion: string | null = null;
@@ -119,7 +119,7 @@ export default class Store extends EventEmitter<{|
119
// Map of ID to number of recorded error and warning message IDs.
120
_errorsAndWarnings: Map<
121
number,
122
- {|errorCount: number, warningCount: number|},
122
+ {errorCount: number, warningCount: number},
123
> = new Map();
124
125
// At least one of the injected renderers contains (DEV only) owner metadata.
@@ -553,7 +553,7 @@ export default class Store extends EventEmitter<{|
553
}
554
555
// Returns a tuple of [id, index]
556
- getElementsWithErrorsAndWarnings(): Array<{|id: number, index: number|}> {
556
+ getElementsWithErrorsAndWarnings(): Array<{id: number, index: number}> {
557
if (this._cachedErrorAndWarningTuples !== null) {
558
return this._cachedErrorAndWarningTuples;
559
} else {
@@ -586,7 +586,7 @@ export default class Store extends EventEmitter<{|
586
587
getErrorAndWarningCountForElementID(
588
id: number,
589
- ): {|errorCount: number, warningCount: number|} {
589
+ ): {errorCount: number, warningCount: number} {
590
return this._errorsAndWarnings.get(id) || {errorCount: 0, warningCount: 0};
591
}
592
@@ -871,10 +871,10 @@ export default class Store extends EventEmitter<{|
871
onBridgeNativeStyleEditorSupported = ({
872
isSupported,
873
validAttributes,
874
- }: {|
874
+ }: {
875
isSupported: boolean,
876
validAttributes: ?$ReadOnlyArray<string>,
877
- |}) => {
877
+ }) => {
878
this._isNativeStyleEditorSupported = isSupported;
879
this._nativeStyleEditorValidAttributes = validAttributes || null;
880
packages/react-devtools-shared/src/devtools/views/ButtonIcon.js
+2
-2
@@ -41,10 +41,10 @@ export type IconType =
41
| 'view-dom'
42
| 'view-source';
43
44
-type Props = {|
44
+type Props = {
45
className?: string,
46
type: IconType,
47
-|};
47
+};
48
49
export default function ButtonIcon({className = '', type}: Props) {
50
let pathData = null;
packages/react-devtools-shared/src/devtools/views/Components/Badge.js
+2
-2
@@ -13,12 +13,12 @@ import styles from './Badge.css';
13
14
import type {ElementType} from 'react-devtools-shared/src/types';
15
16
-type Props = {|
16
+type Props = {
17
className?: string,
18
hocDisplayNames: Array<string> | null,
19
type: ElementType,
20
children: React$Node,
21
-|};
21
+};
22
23
export default function Badge({
24
className,
packages/react-devtools-shared/src/devtools/views/Components/ComponentSearchInput.js
+1
-1
@@ -13,7 +13,7 @@ import {TreeDispatcherContext, TreeStateContext} from './TreeContext';
13
14
import SearchInput from '../SearchInput';
15
16
-type Props = {||};
16
+type Props = {};
17
18
export default function ComponentSearchInput(props: Props) {
19
const {searchIndex, searchResults, searchText} = useContext(TreeStateContext);
packages/react-devtools-shared/src/devtools/views/Components/Components.js
+5
-5
@@ -41,18 +41,18 @@ type ResizeActionType =
41
| 'ACTION_SET_HORIZONTAL_PERCENTAGE'
42
| 'ACTION_SET_VERTICAL_PERCENTAGE';
43
44
-type ResizeAction = {|
44
+type ResizeAction = {
45
type: ResizeActionType,
46
payload: any,
47
-|};
47
+};
48
49
-type ResizeState = {|
49
+type ResizeState = {
50
horizontalPercentage: number,
51
isResizing: boolean,
52
verticalPercentage: number,
53
-|};
53
+};
54
55
-function Components(_: {||}) {
55
+function Components(_: {}) {
56
const wrapperElementRef = useRef<null | HTMLElement>(null);
57
const resizeElementRef = useRef<null | HTMLElement>(null);
58
packages/react-devtools-shared/src/devtools/views/Components/EditableName.js
+2
-2
@@ -18,7 +18,7 @@ type OverrideNameFn = (
18
newName: Array<string | number>,
19
) => void;
20
21
-type EditableNameProps = {|
21
+type EditableNameProps = {
22
allowEmpty?: boolean,
23
allowWhiteSpace?: boolean,
24
autoFocus?: boolean,
@@ -27,7 +27,7 @@ type EditableNameProps = {|
27
overrideName: OverrideNameFn,
28
path: Array<string | number>,
29
type: Type,
30
-|};
30
+};
31
32
export default function EditableName({
33
allowEmpty = false,
packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js
+2
-2
@@ -14,12 +14,12 @@ import {useEditableValue} from '../hooks';
14
15
type OverrideValueFn = (path: Array<string | number>, value: any) => void;
16
17
-type EditableValueProps = {|
17
+type EditableValueProps = {
18
className?: string,
19
overrideValue: OverrideValueFn,
20
path: Array<string | number>,
21
value: any,
22
-|};
22
+};
23
24
export default function EditableValue({
25
className = '',
packages/react-devtools-shared/src/devtools/views/Components/Element.js
+6
-6
@@ -64,10 +64,10 @@ export default function Element({data, index, style}: Props) {
64
}),
65
[store, element],
66
);
67
- const {errorCount, warningCount} = useSubscription<{|
67
+ const {errorCount, warningCount} = useSubscription<{
68
errorCount: number,
69
warningCount: number,
70
- |}>(errorsAndWarningsSubscription);
70
+ }>(errorsAndWarningsSubscription);
71
72
const handleDoubleClick = () => {
73
if (id !== null) {
@@ -225,10 +225,10 @@ const swallowDoubleClick = event => {
225
event.stopPropagation();
226
};
227
228
-type ExpandCollapseToggleProps = {|
228
+type ExpandCollapseToggleProps = {
229
element: ElementType,
230
store: Store,
231
-|};
231
+};
232
233
function ExpandCollapseToggle({element, store}: ExpandCollapseToggleProps) {
234
const {children, id, isCollapsed} = element;
@@ -260,10 +260,10 @@ function ExpandCollapseToggle({element, store}: ExpandCollapseToggleProps) {
260
);
261
}
262
263
-type DisplayNameProps = {|
263
+type DisplayNameProps = {
264
displayName: string | null,
265
id: number,
266
-|};
266
+};
267
268
function DisplayName({displayName, id}: DisplayNameProps) {
269
const {searchIndex, searchResults, searchText} = useContext(TreeStateContext);
packages/react-devtools-shared/src/devtools/views/Components/ExpandCollapseToggle.js
+2
-2
@@ -13,11 +13,11 @@ import ButtonIcon from '../ButtonIcon';
13
14
import styles from './ExpandCollapseToggle.css';
15
16
-type ExpandCollapseToggleProps = {|
16
+type ExpandCollapseToggleProps = {
17
disabled: boolean,
18
isOpen: boolean,
19
setIsOpen: Function,
20
-|};
20
+};
21
22
export default function ExpandCollapseToggle({
23
disabled,
packages/react-devtools-shared/src/devtools/views/Components/HocBadges.js
+2
-2
@@ -12,9 +12,9 @@ import styles from './HocBadges.css';
12
13
import type {Element} from './types';
14
15
-type Props = {|
15
+type Props = {
16
element: Element,
17
-|};
17
+};
18
19
export default function HocBadges({element}: Props) {
20
const {hocDisplayNames} = ((element: any): Element);
packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js
+1
-1
@@ -28,7 +28,7 @@ import styles from './InspectedElement.css';
28
29
import type {InspectedElement} from './types';
30
31
-export type Props = {||};
31
+export type Props = {};
32
33
// TODO Make edits and deletes also use transition API!
34
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js
+6
-6
@@ -47,13 +47,13 @@ type Path = Array<string | number>;
47
type InspectPathFunction = (path: Path) => void;
48
export type ToggleParseHookNames = () => void;
49
50
-type Context = {|
50
+type Context = {
51
hookNames: HookNames | null,
52
inspectedElement: InspectedElement | null,
53
inspectPaths: InspectPathFunction,
54
parseHookNames: boolean,
55
toggleParseHookNames: ToggleParseHookNames,
56
-|};
56
+};
57
58
export const InspectedElementContext = createContext<Context>(
59
((null: any): Context),
@@ -61,9 +61,9 @@ export const InspectedElementContext = createContext<Context>(
61
62
const POLL_INTERVAL = 1000;
63
64
-export type Props = {|
64
+export type Props = {
65
children: ReactNodeList,
66
-|};
66
+};
67
68
export function InspectedElementContextController({children}: Props) {
69
const {selectedElementID} = useContext(TreeStateContext);
@@ -84,10 +84,10 @@ export function InspectedElementContextController({children}: Props) {
84
// The transition that updates this causes the component to re-render and ask the cache->backend for the new path.
85
// When a path is sent along with an "inspectElement" request,
86
// the backend knows to send its dehydrated data even if the element hasn't updated since the last request.
87
- const [state, setState] = useState<{|
87
+ const [state, setState] = useState<{
88
element: Element | null,
89
path: Array<number | string> | null,
90
- |}>({
90
+ }>({
91
element: null,
92
path: null,
93
});
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js
+2
-2
@@ -24,12 +24,12 @@ import type {InspectedElement} from './types';
24
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
25
import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types';
26
27
-type Props = {|
27
+type Props = {
28
bridge: FrontendBridge,
29
element: Element,
30
inspectedElement: InspectedElement,
31
store: Store,
32
-|};
32
+};
33
34
export default function InspectedElementContextTree({
35
bridge,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorBoundary.js
+2
-2
@@ -18,9 +18,9 @@ import {TreeStateContext} from './TreeContext';
18
import {clearCacheBecauseOfError} from '../../../inspectedElementCache';
19
import styles from './InspectedElementErrorBoundary.css';
20
21
-type WrapperProps = {|
21
+type WrapperProps = {
22
children: React$Node,
23
-|};
23
+};
24
25
export default function InspectedElementErrorBoundaryWrapper({
26
children,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js
+6
-6
@@ -27,11 +27,11 @@ import {
27
import type {InspectedElement} from './types';
28
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
29
30
-type Props = {|
30
+type Props = {
31
bridge: FrontendBridge,
32
inspectedElement: InspectedElement,
33
store: Store,
34
-|};
34
+};
35
36
export default function InspectedElementErrorsAndWarningsTree({
37
bridge,
@@ -115,7 +115,7 @@ export default function InspectedElementErrorsAndWarningsTree({
115
);
116
}
117
118
-type TreeProps = {|
118
+type TreeProps = {
119
badgeClassName: string,
120
actions: React$Node,
121
className: string,
@@ -124,7 +124,7 @@ type TreeProps = {|
124
isTransitionPending: boolean,
125
label: string,
126
messageClassName: string,
127
-|};
127
+};
128
129
function Tree({
130
badgeClassName,
@@ -163,12 +163,12 @@ function Tree({
163
);
164
}
165
166
-type ErrorOrWarningViewProps = {|
166
+type ErrorOrWarningViewProps = {
167
badgeClassName: string,
168
className: string,
169
count: number,
170
message: string,
171
-|};
171
+};
172
173
function ErrorOrWarningView({
174
className,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementHooksTree.js
+6
-6
@@ -36,7 +36,7 @@ import type {HookNames} from 'react-devtools-shared/src/types';
36
import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types';
37
import type {ToggleParseHookNames} from './InspectedElementContext';
38
39
-type HooksTreeViewProps = {|
39
+type HooksTreeViewProps = {
40
bridge: FrontendBridge,
41
element: Element,
42
hookNames: HookNames | null,
@@ -44,7 +44,7 @@ type HooksTreeViewProps = {|
44
parseHookNames: boolean,
45
store: Store,
46
toggleParseHookNames: ToggleParseHookNames,
47
-|};
47
+};
48
49
export function InspectedElementHooksTree({
50
bridge,
@@ -121,14 +121,14 @@ export function InspectedElementHooksTree({
121
}
122
}
123
124
-type InnerHooksTreeViewProps = {|
124
+type InnerHooksTreeViewProps = {
125
element: Element,
126
hookNames: HookNames | null,
127
hooks: HooksTree,
128
id: number,
129
inspectedElement: InspectedElement,
130
path: Array<string | number>,
131
-|};
131
+};
132
133
export function InnerHooksTreeView({
134
element,
@@ -152,14 +152,14 @@ export function InnerHooksTreeView({
152
));
153
}
154
155
-type HookViewProps = {|
155
+type HookViewProps = {
156
element: Element,
157
hook: HooksNode,
158
hookNames: HookNames | null,
159
id: number,
160
inspectedElement: InspectedElement,
161
path: Array<string | number>,
162
-|};
162
+};
163
164
function HookView({
165
element,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js
+2
-2
@@ -23,12 +23,12 @@ import type {InspectedElement} from './types';
23
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
24
import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types';
25
26
-type Props = {|
26
+type Props = {
27
bridge: FrontendBridge,
28
element: Element,
29
inspectedElement: InspectedElement,
30
store: Store,
31
-|};
31
+};
32
33
export default function InspectedElementPropsTree({
34
bridge,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStateTree.js
+2
-2
@@ -20,12 +20,12 @@ import type {InspectedElement} from './types';
20
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
21
import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types';
22
23
-type Props = {|
23
+type Props = {
24
bridge: FrontendBridge,
25
element: Element,
26
inspectedElement: InspectedElement,
27
store: Store,
28
-|};
28
+};
29
30
export default function InspectedElementStateTree({
31
bridge,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStyleXPlugin.js
+2
-2
@@ -18,12 +18,12 @@ import type {InspectedElement} from './types';
18
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
19
import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types';
20
21
-type Props = {|
21
+type Props = {
22
bridge: FrontendBridge,
23
element: Element,
24
inspectedElement: InspectedElement,
25
store: Store,
26
-|};
26
+};
27
28
export default function InspectedElementStyleXPlugin({
29
bridge,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspenseToggle.js
+2
-2
@@ -17,11 +17,11 @@ import styles from './InspectedElementSharedStyles.css';
17
import type {InspectedElement} from './types';
18
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
19
20
-type Props = {|
20
+type Props = {
21
bridge: FrontendBridge,
22
inspectedElement: InspectedElement,
23
store: Store,
24
-|};
24
+};
25
26
export default function InspectedElementSuspenseToggle({
27
bridge,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
+6
-6
@@ -45,13 +45,13 @@ import type {ToggleParseHookNames} from './InspectedElementContext';
45
export type CopyPath = (path: Array<string | number>) => void;
46
export type InspectPath = (path: Array<string | number>) => void;
47
48
-type Props = {|
48
+type Props = {
49
element: Element,
50
hookNames: HookNames | null,
51
inspectedElement: InspectedElement,
52
parseHookNames: boolean,
53
toggleParseHookNames: ToggleParseHookNames,
54
-|};
54
+};
55
56
export default function InspectedElementView({
57
element,
@@ -259,10 +259,10 @@ function formatSourceForDisplay(fileName: string, lineNumber: string) {
259
return `${nameOnly}:${lineNumber}`;
260
}
261
262
-type SourceProps = {|
262
+type SourceProps = {
263
fileName: string,
264
lineNumber: string,
265
-|};
265
+};
266
267
function Source({fileName, lineNumber}: SourceProps) {
268
const handleCopy = () => copy(`${fileName}:${lineNumber}`);
@@ -281,13 +281,13 @@ function Source({fileName, lineNumber}: SourceProps) {
281
);
282
}
283
284
-type OwnerViewProps = {|
284
+type OwnerViewProps = {
285
displayName: string,
286
hocDisplayNames: Array<string> | null,
287
id: number,
288
isInStore: boolean,
289
type: ElementType,
290
-|};
290
+};
291
292
function OwnerView({
293
displayName,
packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js
+2
-2
@@ -35,7 +35,7 @@ import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
35
36
type Type = 'props' | 'state' | 'context' | 'hooks';
37
38
-type KeyValueProps = {|
38
+type KeyValueProps = {
39
alphaSort: boolean,
40
bridge: FrontendBridge,
41
canDeletePaths: boolean,
@@ -54,7 +54,7 @@ type KeyValueProps = {|
54
pathRoot: Type,
55
store: Store,
56
value: any,
57
-|};
57
+};
58
59
export default function KeyValue({
60
alphaSort,
packages/react-devtools-shared/src/devtools/views/Components/LoadingAnimation.js
+2
-2
@@ -10,9 +10,9 @@
10
import * as React from 'react';
11
import styles from './LoadingAnimation.css';
12
13
-type Props = {|
13
+type Props = {
14
className?: string,
15
-|};
15
+};
16
17
export default function LoadingAnimation({className = ''}: Props) {
18
return (
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/LayoutViewer.js
+2
-2
@@ -12,10 +12,10 @@ import styles from './LayoutViewer.css';
12
13
import type {Layout} from './types';
14
15
-type Props = {|
15
+type Props = {
16
id: number,
17
layout: Layout,
18
-|};
18
+};
19
20
export default function LayoutViewer({id, layout}: Props) {
21
const {height, margin, padding, y, width, x} = layout;
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/StyleEditor.js
+8
-8
@@ -24,10 +24,10 @@ import {sanitizeForParse} from '../../../utils';
24
25
import type {Style} from './types';
26
27
-type Props = {|
27
+type Props = {
28
id: number,
29
style: Style,
30
-|};
30
+};
31
32
type ChangeAttributeFn = (oldName: string, newName: string, value: any) => void;
33
type ChangeValueFn = (name: string, value: any) => void;
@@ -96,11 +96,11 @@ export default function StyleEditor({id, style}: Props) {
96
);
97
}
98
99
-type NewRowProps = {|
99
+type NewRowProps = {
100
changeAttribute: ChangeAttributeFn,
101
changeValue: ChangeValueFn,
102
validAttributes: $ReadOnlyArray<string> | null,
103
-|};
103
+};
104
105
function NewRow({changeAttribute, changeValue, validAttributes}: NewRowProps) {
106
const [key, setKey] = useState<number>(0);
@@ -141,7 +141,7 @@ function NewRow({changeAttribute, changeValue, validAttributes}: NewRowProps) {
141
);
142
}
143
144
-type RowProps = {|
144
+type RowProps = {
145
attribute: string,
146
attributePlaceholder?: string,
147
changeAttribute: ChangeAttributeFn,
@@ -149,7 +149,7 @@ type RowProps = {|
149
validAttributes: $ReadOnlyArray<string> | null,
150
value: any,
151
valuePlaceholder?: string,
152
-|};
152
+};
153
154
function Row({
155
attribute,
@@ -245,14 +245,14 @@ function Row({
245
);
246
}
247
248
-type FieldProps = {|
248
+type FieldProps = {
249
className: string,
250
onChange: (value: any) => void,
251
onReset: () => void,
252
onSubmit: () => void,
253
placeholder?: string,
254
value: any,
255
-|};
255
+};
256
257
function Field({
258
className,
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/context.js
+6
-6
@@ -37,18 +37,18 @@ import type {
37
38
export type GetStyleAndLayout = (id: number) => StyleAndLayoutFrontend | null;
39
40
-type Context = {|
40
+type Context = {
41
getStyleAndLayout: GetStyleAndLayout,
42
-|};
42
+};
43
44
const NativeStyleContext = createContext<Context>(((null: any): Context));
45
NativeStyleContext.displayName = 'NativeStyleContext';
46
47
type ResolveFn = (styleAndLayout: StyleAndLayoutFrontend) => void;
48
-type InProgressRequest = {|
48
+type InProgressRequest = {
49
promise: Thenable<StyleAndLayoutFrontend>,
50
resolveFn: ResolveFn,
51
-|};
51
+};
52
53
const inProgressRequests: WeakMap<Element, InProgressRequest> = new WeakMap();
54
const resource: Resource<
@@ -75,9 +75,9 @@ const resource: Resource<
75
{useWeakMap: true},
76
);
77
78
-type Props = {|
78
+type Props = {
79
children: React$Node,
80
-|};
80
+};
81
82
function NativeStyleContextController({children}: Props) {
83
const bridge = useContext<FrontendBridge>(BridgeContext);
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/index.js
+1
-1
@@ -16,7 +16,7 @@ import LayoutViewer from './LayoutViewer';
16
import StyleEditor from './StyleEditor';
17
import {TreeStateContext} from '../TreeContext';
18
19
-type Props = {||};
19
+type Props = {};
20
21
export default function NativeStyleEditorWrapper(_: Props) {
22
const store = useContext(StoreContext);
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/types.js
+2
-2
@@ -14,7 +14,7 @@ import type {
14
15
export type Layout = LayoutBackend;
16
export type Style = StyleBackend;
17
-export type StyleAndLayout = {|
17
+export type StyleAndLayout = {
18
layout: LayoutBackend | null,
19
style: StyleBackend | null,
20
-|};
20
+};
packages/react-devtools-shared/src/devtools/views/Components/NewArrayValue.js
+2
-2
@@ -18,7 +18,7 @@ import styles from './NewArrayValue.css';
18
import type {InspectedElement} from './types';
19
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
20
21
-type Props = {|
21
+type Props = {
22
bridge: FrontendBridge,
23
depth: number,
24
hidden: boolean,
@@ -28,7 +28,7 @@ type Props = {|
28
path: Array<string | number>,
29
store: Store,
30
type: 'props' | 'context' | 'hooks' | 'state',
31
-|};
31
+};
32
33
export default function NewArrayValue({
34
bridge,
packages/react-devtools-shared/src/devtools/views/Components/NewKeyValue.js
+2
-2
@@ -18,7 +18,7 @@ import styles from './NewKeyValue.css';
18
import type {InspectedElement} from './types';
19
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
20
21
-type Props = {|
21
+type Props = {
22
bridge: FrontendBridge,
23
depth: number,
24
hidden: boolean,
@@ -27,7 +27,7 @@ type Props = {|
27
path: Array<string | number>,
28
store: Store,
29
type: 'props' | 'state' | 'hooks' | 'context',
30
-|};
30
+};
31
32
export default function NewKeyValue({
33
bridge,
packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js
+4
-4
@@ -27,10 +27,10 @@ const OwnersListContext = createContext<Context>(((null: any): Context));
27
OwnersListContext.displayName = 'OwnersListContext';
28
29
type ResolveFn = (ownersList: Array<SerializedElement> | null) => void;
30
-type InProgressRequest = {|
30
+type InProgressRequest = {
31
promise: Thenable<Array<SerializedElement>>,
32
resolveFn: ResolveFn,
33
-|};
33
+};
34
35
const inProgressRequests: WeakMap<Element, InProgressRequest> = new WeakMap();
36
const resource: Resource<
@@ -57,9 +57,9 @@ const resource: Resource<
57
{useWeakMap: true},
58
);
59
60
-type Props = {|
60
+type Props = {
61
children: React$Node,
62
-|};
62
+};
63
64
function OwnersListContextController({children}: Props) {
65
const bridge = useContext(BridgeContext);
packages/react-devtools-shared/src/devtools/views/Components/OwnersStack.js
+8
-8
@@ -38,23 +38,23 @@ import styles from './OwnersStack.css';
38
39
type SelectOwner = (owner: SerializedElement | null) => void;
40
41
-type ACTION_UPDATE_OWNER_ID = {|
41
+type ACTION_UPDATE_OWNER_ID = {
42
type: 'UPDATE_OWNER_ID',
43
ownerID: number | null,
44
owners: Array<SerializedElement>,
45
-|};
46
-type ACTION_UPDATE_SELECTED_INDEX = {|
45
+};
46
+type ACTION_UPDATE_SELECTED_INDEX = {
47
type: 'UPDATE_SELECTED_INDEX',
48
selectedIndex: number,
49
-|};
49
+};
50
51
type Action = ACTION_UPDATE_OWNER_ID | ACTION_UPDATE_SELECTED_INDEX;
52
53
-type State = {|
53
+type State = {
54
ownerID: number | null,
55
owners: Array<SerializedElement>,
56
selectedIndex: number,
57
-|};
57
+};
58
59
function dialogReducer(state, action) {
60
switch (action.type) {
@@ -282,11 +282,11 @@ function ElementView({isSelected, owner, selectOwner}: ElementViewProps) {
282
);
283
}
284
285
-type BackToOwnerButtonProps = {|
285
+type BackToOwnerButtonProps = {
286
owners: Array<SerializedElement>,
287
selectedIndex: number,
288
selectOwner: SelectOwner,
289
-|};
289
+};
290
function BackToOwnerButton({
291
owners,
292
selectedIndex,
packages/react-devtools-shared/src/devtools/views/Components/SelectedTreeHighlight.js
+3
-3
@@ -17,12 +17,12 @@ import {useSubscription} from '../hooks';
17
18
import styles from './SelectedTreeHighlight.css';
19
20
-type Data = {|
20
+type Data = {
21
startIndex: number,
22
stopIndex: number,
23
-|};
23
+};
24
25
-export default function SelectedTreeHighlight(_: {||}) {
25
+export default function SelectedTreeHighlight(_: {}) {
26
const {lineHeight} = useContext(SettingsContext);
27
const store = useContext(StoreContext);
28
const treeFocused = useContext(TreeFocusedContext);
packages/react-devtools-shared/src/devtools/views/Components/Tree.js
+5
-5
@@ -41,15 +41,15 @@ import {logEvent} from 'react-devtools-shared/src/Logger';
41
// Never indent more than this number of pixels (even if we have the room).
42
const DEFAULT_INDENTATION_SIZE = 12;
43
44
-export type ItemData = {|
44
+export type ItemData = {
45
numElements: number,
46
isNavigatingWithKeyboard: boolean,
47
lastScrolledIDRef: {current: number | null, ...},
48
onElementMouseEnter: (id: number) => void,
49
treeFocused: boolean,
50
-|};
50
+};
51
52
-type Props = {||};
52
+type Props = {};
53
54
export default function Tree(props: Props) {
55
const dispatch = useContext(TreeDispatcherContext);
@@ -473,8 +473,8 @@ export default function Tree(props: Props) {
473
function updateIndentationSizeVar(
474
innerDiv: HTMLDivElement,
475
cachedChildWidths: WeakMap<HTMLElement, number>,
476
- indentationSizeRef: {|current: number|},
477
- prevListWidthRef: {|current: number|},
476
+ indentationSizeRef: {current: number},
477
+ prevListWidthRef: {current: number},
478
): void {
479
const list = ((innerDiv.parentElement: any): HTMLDivElement);
480
const listWidth = list.clientWidth;
packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js
+44
-44
@@ -42,7 +42,7 @@ import Store from '../../store';
42
43
import type {Element} from './types';
44
45
-export type StateContext = {|
45
+export type StateContext = {
46
// Tree
47
numElements: number,
48
ownerSubtreeLeafElementID: number | null,
@@ -60,70 +60,70 @@ export type StateContext = {|
60
61
// Inspection element panel
62
inspectedElementID: number | null,
63
-|};
63
+};
64
65
-type ACTION_GO_TO_NEXT_SEARCH_RESULT = {|
65
+type ACTION_GO_TO_NEXT_SEARCH_RESULT = {
66
type: 'GO_TO_NEXT_SEARCH_RESULT',
67
-|};
68
-type ACTION_GO_TO_PREVIOUS_SEARCH_RESULT = {|
67
+};
68
+type ACTION_GO_TO_PREVIOUS_SEARCH_RESULT = {
69
type: 'GO_TO_PREVIOUS_SEARCH_RESULT',
70
-|};
71
-type ACTION_HANDLE_STORE_MUTATION = {|
70
+};
71
+type ACTION_HANDLE_STORE_MUTATION = {
72
type: 'HANDLE_STORE_MUTATION',
73
payload: [Array<number>, Map<number, number>],
74
-|};
75
-type ACTION_RESET_OWNER_STACK = {|
74
+};
75
+type ACTION_RESET_OWNER_STACK = {
76
type: 'RESET_OWNER_STACK',
77
-|};
78
-type ACTION_SELECT_CHILD_ELEMENT_IN_TREE = {|
77
+};
78
+type ACTION_SELECT_CHILD_ELEMENT_IN_TREE = {
79
type: 'SELECT_CHILD_ELEMENT_IN_TREE',
80
-|};
81
-type ACTION_SELECT_ELEMENT_AT_INDEX = {|
80
+};
81
+type ACTION_SELECT_ELEMENT_AT_INDEX = {
82
type: 'SELECT_ELEMENT_AT_INDEX',
83
payload: number | null,
84
-|};
85
-type ACTION_SELECT_ELEMENT_BY_ID = {|
84
+};
85
+type ACTION_SELECT_ELEMENT_BY_ID = {
86
type: 'SELECT_ELEMENT_BY_ID',
87
payload: number | null,
88
-|};
89
-type ACTION_SELECT_NEXT_ELEMENT_IN_TREE = {|
88
+};
89
+type ACTION_SELECT_NEXT_ELEMENT_IN_TREE = {
90
type: 'SELECT_NEXT_ELEMENT_IN_TREE',
91
-|};
92
-type ACTION_SELECT_NEXT_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE = {|
91
+};
92
+type ACTION_SELECT_NEXT_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE = {
93
type: 'SELECT_NEXT_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE',
94
-|};
95
-type ACTION_SELECT_NEXT_SIBLING_IN_TREE = {|
94
+};
95
+type ACTION_SELECT_NEXT_SIBLING_IN_TREE = {
96
type: 'SELECT_NEXT_SIBLING_IN_TREE',
97
-|};
98
-type ACTION_SELECT_OWNER = {|
97
+};
98
+type ACTION_SELECT_OWNER = {
99
type: 'SELECT_OWNER',
100
payload: number,
101
-|};
102
-type ACTION_SELECT_PARENT_ELEMENT_IN_TREE = {|
101
+};
102
+type ACTION_SELECT_PARENT_ELEMENT_IN_TREE = {
103
type: 'SELECT_PARENT_ELEMENT_IN_TREE',
104
-|};
105
-type ACTION_SELECT_PREVIOUS_ELEMENT_IN_TREE = {|
104
+};
105
+type ACTION_SELECT_PREVIOUS_ELEMENT_IN_TREE = {
106
type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE',
107
-|};
108
-type ACTION_SELECT_PREVIOUS_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE = {|
107
+};
108
+type ACTION_SELECT_PREVIOUS_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE = {
109
type: 'SELECT_PREVIOUS_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE',
110
-|};
111
-type ACTION_SELECT_PREVIOUS_SIBLING_IN_TREE = {|
110
+};
111
+type ACTION_SELECT_PREVIOUS_SIBLING_IN_TREE = {
112
type: 'SELECT_PREVIOUS_SIBLING_IN_TREE',
113
-|};
114
-type ACTION_SELECT_OWNER_LIST_NEXT_ELEMENT_IN_TREE = {|
113
+};
114
+type ACTION_SELECT_OWNER_LIST_NEXT_ELEMENT_IN_TREE = {
115
type: 'SELECT_OWNER_LIST_NEXT_ELEMENT_IN_TREE',
116
-|};
117
-type ACTION_SELECT_OWNER_LIST_PREVIOUS_ELEMENT_IN_TREE = {|
116
+};
117
+type ACTION_SELECT_OWNER_LIST_PREVIOUS_ELEMENT_IN_TREE = {
118
type: 'SELECT_OWNER_LIST_PREVIOUS_ELEMENT_IN_TREE',
119
-|};
120
-type ACTION_SET_SEARCH_TEXT = {|
119
+};
120
+type ACTION_SET_SEARCH_TEXT = {
121
type: 'SET_SEARCH_TEXT',
122
payload: string,
123
-|};
124
-type ACTION_UPDATE_INSPECTED_ELEMENT_ID = {|
123
+};
124
+type ACTION_UPDATE_INSPECTED_ELEMENT_ID = {
125
type: 'UPDATE_INSPECTED_ELEMENT_ID',
126
-|};
126
+};
127
128
type Action =
129
| ACTION_GO_TO_NEXT_SEARCH_RESULT
@@ -158,7 +158,7 @@ const TreeDispatcherContext = createContext<DispatcherContext>(
158
);
159
TreeDispatcherContext.displayName = 'TreeDispatcherContext';
160
161
-type State = {|
161
+type State = {
162
// Tree
163
numElements: number,
164
ownerSubtreeLeafElementID: number | null,
@@ -176,7 +176,7 @@ type State = {|
176
177
// Inspection element panel
178
inspectedElementID: number | null,
179
-|};
179
+};
180
181
function reduceTreeState(store: Store, state: State, action: Action): State {
182
let {
@@ -817,7 +817,7 @@ function reduceSuspenseState(
817
return state;
818
}
819
820
-type Props = {|
820
+type Props = {
821
children: React$Node,
822
823
// Used for automated testing
@@ -825,7 +825,7 @@ type Props = {|
825
defaultOwnerID?: ?number,
826
defaultSelectedElementID?: ?number,
827
defaultSelectedElementIndex?: ?number,
828
-|};
828
+};
829
830
// TODO Remove TreeContextController wrapper element once global Context.write API exists.
831
function TreeContextController({
packages/react-devtools-shared/src/devtools/views/Components/ViewElementSourceContext.js
+2
-2
@@ -14,10 +14,10 @@ import type {
14
ViewElementSource,
15
} from 'react-devtools-shared/src/devtools/views/DevTools';
16
17
-export type Context = {|
17
+export type Context = {
18
canViewElementSourceFunction: CanViewElementSource | null,
19
viewElementSourceFunction: ViewElementSource | null,
20
-|};
20
+};
21
22
const ViewElementSourceContext = createContext<Context>(((null: any): Context));
23
ViewElementSourceContext.displayName = 'ViewElementSourceContext';
packages/react-devtools-shared/src/devtools/views/Components/ViewSourceContext.js
+2
-2
@@ -11,9 +11,9 @@ import {createContext} from 'react';
11
12
import type {ViewUrlSource} from 'react-devtools-shared/src/devtools/views/DevTools';
13
14
-export type Context = {|
14
+export type Context = {
15
viewUrlSourceFunction: ViewUrlSource | null,
16
-|};
16
+};
17
18
const ViewSourceContext = createContext<Context>(((null: any): Context));
19
ViewSourceContext.displayName = 'ViewSourceContext';
packages/react-devtools-shared/src/devtools/views/Components/types.js
+10
-10
@@ -18,7 +18,7 @@ import type {ElementType, Plugins} from 'react-devtools-shared/src/types';
18
// Some of its information (e.g. id, type, displayName) come from the backend.
19
// Other bits (e.g. weight and depth) are computed on the frontend for windowing and display purposes.
20
// Elements are updated on a push basis– meaning the backend pushes updates to the frontend when needed.
21
-export type Element = {|
21
+export type Element = {
22
id: number,
23
parentID: number,
24
children: Array<number>,
@@ -46,20 +46,20 @@ export type Element = {|
46
// This element is not in a StrictMode compliant subtree.
47
// Only true for React versions supporting StrictMode.
48
isStrictModeNonCompliant: boolean,
49
-|};
49
+};
50
51
-export type SerializedElement = {|
51
+export type SerializedElement = {
52
displayName: string | null,
53
id: number,
54
key: number | string | null,
55
hocDisplayNames: Array<string> | null,
56
type: ElementType,
57
-|};
57
+};
58
59
-export type OwnersList = {|
59
+export type OwnersList = {
60
id: number,
61
owners: Array<SerializedElement> | null,
62
-|};
62
+};
63
64
export type InspectedElementResponseType =
65
| 'error'
@@ -68,7 +68,7 @@ export type InspectedElementResponseType =
68
| 'no-change'
69
| 'not-found';
70
71
-export type InspectedElement = {|
71
+export type InspectedElement = {
72
id: number,
73
74
// Does the current renderer support editable hooks and function props?
@@ -121,11 +121,11 @@ export type InspectedElement = {|
121
122
// UI plugins/visualizations for the inspected element.
123
plugins: Plugins,
124
-|};
124
+};
125
126
// TODO: Add profiling type
127
128
-export type DehydratedData = {|
128
+export type DehydratedData = {
129
cleaned: Array<Array<string | number>>,
130
data:
131
| string
@@ -135,4 +135,4 @@ export type DehydratedData = {|
135
| Array<Unserializable>
136
| {[key: string]: string | Dehydrated | Unserializable, ...},
137
unserializable: Array<Array<string | number>>,
138
-|};
138
+};
packages/react-devtools-shared/src/devtools/views/DevTools.js
+2
-2
@@ -67,7 +67,7 @@ export type CanViewElementSource = (
67
inspectedElement: InspectedElement,
68
) => boolean;
69
70
-export type Props = {|
70
+export type Props = {
71
bridge: FrontendBridge,
72
browserTheme?: BrowserTheme,
73
canViewElementSourceFunction?: ?CanViewElementSource,
@@ -105,7 +105,7 @@ export type Props = {|
105
fetchFileWithCaching?: ?FetchFileWithCaching,
106
// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
107
hookNamesModuleLoaderFunction?: ?HookNamesModuleLoaderFunction,
108
-|};
108
+};
109
110
const componentsTab = {
111
id: ('components': TabID),
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/CaughtErrorView.js
+2
-2
@@ -10,13 +10,13 @@
10
import * as React from 'react';
11
import styles from './shared.css';
12
13
-type Props = {|
13
+type Props = {
14
callStack: string | null,
15
children: React$Node,
16
info: React$Node | null,
17
componentStack: string | null,
18
errorMessage: string,
19
-|};
19
+};
20
21
export default function CaughtErrorView({
22
callStack,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js
+4
-4
@@ -22,14 +22,14 @@ import UserError from 'react-devtools-shared/src/errors/UserError';
22
import UnknownHookError from 'react-devtools-shared/src/errors/UnknownHookError';
23
import {logEvent} from 'react-devtools-shared/src/Logger';
24
25
-type Props = {|
25
+type Props = {
26
children: React$Node,
27
canDismiss?: boolean,
28
onBeforeDismissCallback?: () => void,
29
store?: Store,
30
-|};
30
+};
31
32
-type State = {|
32
+type State = {
33
callStack: string | null,
34
canDismiss: boolean,
35
componentStack: string | null,
@@ -39,7 +39,7 @@ type State = {|
39
isTimeout: boolean,
40
isUserError: boolean,
41
isUnknownHookError: boolean,
42
-|};
42
+};
43
44
const InitialState: State = {
45
callStack: null,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorView.js
+2
-2
@@ -12,13 +12,13 @@ import Button from '../Button';
12
import ButtonIcon from '../ButtonIcon';
13
import styles from './shared.css';
14
15
-type Props = {|
15
+type Props = {
16
callStack: string | null,
17
children: React$Node,
18
componentStack: string | null,
19
dismissError: Function | null,
20
errorMessage: string | null,
21
-|};
21
+};
22
23
export default function ErrorView({
24
callStack,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ReportNewIssue.js
+2
-2
@@ -21,11 +21,11 @@ const LABELS = [
21
// This must match the filename in ".github/ISSUE_TEMPLATE/"
22
const TEMPLATE = 'devtools_bug_report.yml';
23
24
-type Props = {|
24
+type Props = {
25
callStack: string | null,
26
componentStack: string | null,
27
errorMessage: string | null,
28
-|};
28
+};
29
30
export default function ReportNewIssue({
31
callStack,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/SuspendingErrorView.js
+2
-2
@@ -13,11 +13,11 @@ import UpdateExistingIssue from './UpdateExistingIssue';
13
import ReportNewIssue from './ReportNewIssue';
14
import WorkplaceGroup from './WorkplaceGroup';
15
16
-type Props = {|
16
+type Props = {
17
callStack: string | null,
18
componentStack: string | null,
19
errorMessage: string | null,
20
-|};
20
+};
21
22
export default function SuspendingErrorView({
23
callStack,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/TimeoutView.js
+2
-2
@@ -12,13 +12,13 @@ import Button from '../Button';
12
import ButtonIcon from '../ButtonIcon';
13
import styles from './shared.css';
14
15
-type Props = {|
15
+type Props = {
16
callStack: string | null,
17
children: React$Node,
18
componentStack: string | null,
19
dismissError: Function,
20
errorMessage: string | null,
21
-|};
21
+};
22
23
export default function TimeoutView({
24
callStack,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/UnsupportedBridgeOperationView.js
+2
-2
@@ -10,12 +10,12 @@
10
import * as React from 'react';
11
import styles from './shared.css';
12
13
-type Props = {|
13
+type Props = {
14
callStack: string | null,
15
children: React$Node,
16
componentStack: string | null,
17
errorMessage: string | null,
18
-|};
18
+};
19
20
export default function UnsupportedBridgeOperationView({
21
callStack,
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/UpdateExistingIssue.js
+2
-2
@@ -15,9 +15,9 @@ import styles from './shared.css';
15
16
export default function UpdateExistingIssue({
17
gitHubIssue,
18
-}: {|
18
+}: {
19
gitHubIssue: GitHubIssue,
20
-|}) {
20
+}) {
21
const {title, url} = gitHubIssue;
22
return (
23
<div className={styles.GitHubLinkRow}>
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js
+6
-6
@@ -19,20 +19,20 @@ const Pending = 0;
19
const Resolved = 1;
20
const Rejected = 2;
21
22
-type PendingRecord = {|
22
+type PendingRecord = {
23
status: 0,
24
value: Wakeable,
25
-|};
25
+};
26
27
-type ResolvedRecord<T> = {|
27
+type ResolvedRecord<T> = {
28
status: 1,
29
value: T,
30
-|};
30
+};
31
32
-type RejectedRecord = {|
32
+type RejectedRecord = {
33
status: 2,
34
value: null,
35
-|};
35
+};
36
37
type Record<T> = PendingRecord | ResolvedRecord<T> | RejectedRecord;
38
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/githubAPI.js
+2
-2
@@ -7,10 +7,10 @@
7
* @flow
8
*/
9
10
-export type GitHubIssue = {|
10
+export type GitHubIssue = {
11
title: string,
12
url: string,
13
-|};
13
+};
14
15
const GITHUB_ISSUES_API = 'https://api.github.com/search/issues';
16
packages/react-devtools-shared/src/devtools/views/Icon.js
+2
-2
@@ -28,11 +28,11 @@ export type IconType =
28
| 'strict-mode-non-compliant'
29
| 'warning';
30
31
-type Props = {|
31
+type Props = {
32
className?: string,
33
title?: string,
34
type: IconType,
35
-|};
35
+};
36
37
export default function Icon({className = '', title = '', type}: Props) {
38
let pathData = null;
packages/react-devtools-shared/src/devtools/views/ModalDialog.js
+15
-15
@@ -23,37 +23,37 @@ import styles from './ModalDialog.css';
23
24
type ID = any;
25
26
-type DIALOG_ACTION_HIDE = {|
26
+type DIALOG_ACTION_HIDE = {
27
type: 'HIDE',
28
id: ID,
29
-|};
30
-type DIALOG_ACTION_SHOW = {|
29
+};
30
+type DIALOG_ACTION_SHOW = {
31
type: 'SHOW',
32
canBeDismissed?: boolean,
33
content: React$Node,
34
id: ID,
35
title?: React$Node | null,
36
-|};
36
+};
37
38
type Action = DIALOG_ACTION_HIDE | DIALOG_ACTION_SHOW;
39
40
type Dispatch = (action: Action) => void;
41
42
-type Dialog = {|
42
+type Dialog = {
43
canBeDismissed: boolean,
44
content: React$Node | null,
45
id: ID,
46
title: React$Node | null,
47
-|};
47
+};
48
49
-type State = {|
49
+type State = {
50
dialogs: Array<Dialog>,
51
-|};
51
+};
52
53
-type ModalDialogContextType = {|
53
+type ModalDialogContextType = {
54
...State,
55
dispatch: Dispatch,
56
-|};
56
+};
57
58
const ModalDialogContext = createContext<ModalDialogContextType>(
59
((null: any): ModalDialogContextType),
@@ -83,9 +83,9 @@ function dialogReducer(state, action) {
83
}
84
}
85
86
-type Props = {|
86
+type Props = {
87
children: React$Node,
88
-|};
88
+};
89
90
function ModalDialogContextController({children}: Props) {
91
const [state, dispatch] = useReducer<State, State, Action>(dialogReducer, {
@@ -107,7 +107,7 @@ function ModalDialogContextController({children}: Props) {
107
);
108
}
109
110
-function ModalDialog(_: {||}) {
110
+function ModalDialog(_: {}) {
111
const {dialogs, dispatch} = useContext(ModalDialogContext);
112
113
if (dialogs.length === 0) {
@@ -136,13 +136,13 @@ function ModalDialogImpl({
136
dispatch,
137
id,
138
title,
139
-}: {|
139
+}: {
140
canBeDismissed: boolean,
141
content: React$Node | null,
142
dispatch: Dispatch,
143
id: ID,
144
title: React$Node | null,
145
-|}) {
145
+}) {
146
const dismissModal = useCallback(() => {
147
if (canBeDismissed) {
148
dispatch({type: 'HIDE', id});
packages/react-devtools-shared/src/devtools/views/Profiler/ChartNode.js
+2
-2
@@ -11,7 +11,7 @@ import * as React from 'react';
11
12
import styles from './ChartNode.css';
13
14
-type Props = {|
14
+type Props = {
15
color: string,
16
height: number,
17
isDimmed?: boolean,
@@ -25,7 +25,7 @@ type Props = {|
25
width: number,
26
x: number,
27
y: number,
28
-|};
28
+};
29
30
const minWidthToDisplay = 35;
31
packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraph.js
+5
-5
@@ -27,7 +27,7 @@ import type {TooltipFiberData} from './HoveredFiberInfo';
27
import type {ChartData, ChartNode} from './FlamegraphChartBuilder';
28
import type {CommitTree} from './types';
29
30
-export type ItemData = {|
30
+export type ItemData = {
31
chartData: ChartData,
32
onElementMouseEnter: (fiberData: TooltipFiberData) => void,
33
onElementMouseLeave: () => void,
@@ -36,9 +36,9 @@ export type ItemData = {|
36
selectedChartNodeIndex: number,
37
selectFiber: (id: number | null, name: string | null) => void,
38
width: number,
39
-|};
39
+};
40
41
-export default function CommitFlamegraphAutoSizer(_: {||}) {
41
+export default function CommitFlamegraphAutoSizer(_: {}) {
42
const {profilerStore} = useContext(StoreContext);
43
const {rootID, selectedCommitIndex, selectFiber} = useContext(
44
ProfilerContext,
@@ -90,12 +90,12 @@ export default function CommitFlamegraphAutoSizer(_: {||}) {
90
}
91
}
92
93
-type Props = {|
93
+type Props = {
94
chartData: ChartData,
95
commitTree: CommitTree,
96
height: number,
97
width: number,
98
-|};
98
+};
99
100
function CommitFlamegraph({chartData, commitTree, height, width}: Props) {
101
const [
packages/react-devtools-shared/src/devtools/views/Profiler/CommitRanked.js
+5
-5
@@ -27,7 +27,7 @@ import type {TooltipFiberData} from './HoveredFiberInfo';
27
import type {ChartData} from './RankedChartBuilder';
28
import type {CommitTree} from './types';
29
30
-export type ItemData = {|
30
+export type ItemData = {
31
chartData: ChartData,
32
onElementMouseEnter: (fiberData: TooltipFiberData) => void,
33
onElementMouseLeave: () => void,
@@ -36,9 +36,9 @@ export type ItemData = {|
36
selectedFiberIndex: number,
37
selectFiber: (id: number | null, name: string | null) => void,
38
width: number,
39
-|};
39
+};
40
41
-export default function CommitRankedAutoSizer(_: {||}) {
41
+export default function CommitRankedAutoSizer(_: {}) {
42
const {profilerStore} = useContext(StoreContext);
43
const {rootID, selectedCommitIndex, selectFiber} = useContext(
44
ProfilerContext,
@@ -88,12 +88,12 @@ export default function CommitRankedAutoSizer(_: {||}) {
88
}
89
}
90
91
-type Props = {|
91
+type Props = {
92
chartData: ChartData,
93
commitTree: CommitTree,
94
height: number,
95
width: number,
96
-|};
96
+};
97
98
function CommitRanked({chartData, commitTree, height, width}: Props) {
99
const [
packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js
+2
-2
@@ -45,11 +45,11 @@ export function getCommitTree({
45
commitIndex,
46
profilerStore,
47
rootID,
48
-}: {|
48
+}: {
49
commitIndex: number,
50
profilerStore: ProfilerStore,
51
rootID: number,
52
-|}): CommitTree {
52
+}): CommitTree {
53
if (!rootToCommitTreeMap.has(rootID)) {
54
rootToCommitTreeMap.set(rootID, []);
55
}
packages/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.js
+6
-6
@@ -12,7 +12,7 @@ import ProfilerStore from 'react-devtools-shared/src/devtools/ProfilerStore';
12
13
import type {CommitTree} from './types';
14
15
-export type ChartNode = {|
15
+export type ChartNode = {
16
actualDuration: number,
17
didRender: boolean,
18
id: number,
@@ -21,16 +21,16 @@ export type ChartNode = {|
21
offset: number,
22
selfDuration: number,
23
treeBaseDuration: number,
24
-|};
24
+};
25
26
-export type ChartData = {|
26
+export type ChartData = {
27
baseDuration: number,
28
depth: number,
29
idToDepthMap: Map<number, number>,
30
maxSelfDuration: number,
31
renderPathNodes: Set<number>,
32
rows: Array<Array<ChartNode>>,
33
-|};
33
+};
34
35
const cachedChartData: Map<string, ChartData> = new Map();
36
@@ -39,12 +39,12 @@ export function getChartData({
39
commitTree,
40
profilerStore,
41
rootID,
42
-}: {|
42
+}: {
43
commitIndex: number,
44
commitTree: CommitTree,
45
profilerStore: ProfilerStore,
46
rootID: number,
47
-|}): ChartData {
47
+}): ChartData {
48
const commitDatum = profilerStore.getCommitData(rootID, commitIndex);
49
50
const {fiberActualDurations, fiberSelfDurations} = commitDatum;
packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js
+4
-4
@@ -18,14 +18,14 @@ import styles from './HoveredFiberInfo.css';
18
19
import type {ChartNode} from './FlamegraphChartBuilder';
20
21
-export type TooltipFiberData = {|
21
+export type TooltipFiberData = {
22
id: number,
23
name: string,
24
-|};
24
+};
25
26
-export type Props = {|
26
+export type Props = {
27
fiberData: ChartNode,
28
-|};
28
+};
29
30
export default function HoveredFiberInfo({fiberData}: Props) {
31
const {profilerStore} = useContext(StoreContext);
packages/react-devtools-shared/src/devtools/views/Profiler/NoCommitData.js
+1
-1
@@ -11,7 +11,7 @@ import * as React from 'react';
11
12
import styles from './NoCommitData.css';
13
14
-export default function NoCommitData(_: {||}) {
14
+export default function NoCommitData(_: {}) {
15
return (
16
<div className={styles.NoCommitData}>
17
<div className={styles.Header}>
packages/react-devtools-shared/src/devtools/views/Profiler/Profiler.js
+1
-1
@@ -38,7 +38,7 @@ import {enableProfilerComponentTree} from 'react-devtools-feature-flags';
38
39
import styles from './Profiler.css';
40
41
-function Profiler(_: {||}) {
41
+function Profiler(_: {}) {
42
const {
43
didRecordCommits,
44
isProcessingData,
packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js
+6
-6
@@ -22,7 +22,7 @@ import type {ProfilingDataFrontend} from './types';
22
23
export type TabID = 'flame-chart' | 'ranked-chart' | 'timeline';
24
25
-export type Context = {|
25
+export type Context = {
26
// Which tab is selected in the Profiler UI?
27
selectedTabID: TabID,
28
selectTab(id: TabID): void,
@@ -65,22 +65,22 @@ export type Context = {|
65
selectedFiberID: number | null,
66
selectedFiberName: string | null,
67
selectFiber: (id: number | null, name: string | null) => void,
68
-|};
68
+};
69
70
const ProfilerContext = createContext<Context>(((null: any): Context));
71
ProfilerContext.displayName = 'ProfilerContext';
72
73
-type StoreProfilingState = {|
73
+type StoreProfilingState = {
74
didRecordCommits: boolean,
75
isProcessingData: boolean,
76
isProfiling: boolean,
77
profilingData: ProfilingDataFrontend | null,
78
supportsProfiling: boolean,
79
-|};
79
+};
80
81
-type Props = {|
81
+type Props = {
82
children: React$Node,
83
-|};
83
+};
84
85
function ProfilerContextController({children}: Props) {
86
const store = useContext(StoreContext);
packages/react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder.js
+6
-6
@@ -16,17 +16,17 @@ import ProfilerStore from 'react-devtools-shared/src/devtools/ProfilerStore';
16
17
import type {CommitTree} from './types';
18
19
-export type ChartNode = {|
19
+export type ChartNode = {
20
id: number,
21
label: string,
22
name: string,
23
value: number,
24
-|};
24
+};
25
26
-export type ChartData = {|
26
+export type ChartData = {
27
maxValue: number,
28
nodes: Array<ChartNode>,
29
-|};
29
+};
30
31
const cachedChartData: Map<string, ChartData> = new Map();
32
@@ -35,12 +35,12 @@ export function getChartData({
35
commitTree,
36
profilerStore,
37
rootID,
38
-}: {|
38
+}: {
39
commitIndex: number,
40
commitTree: CommitTree,
41
profilerStore: ProfilerStore,
42
rootID: number,
43
-|}): ChartData {
43
+}): ChartData {
44
const commitDatum = profilerStore.getCommitData(rootID, commitIndex);
45
46
const {fiberActualDurations, fiberSelfDurations} = commitDatum;
packages/react-devtools-shared/src/devtools/views/Profiler/RecordToggle.js
+2
-2
@@ -15,9 +15,9 @@ import {ProfilerContext} from './ProfilerContext';
15
16
import styles from './RecordToggle.css';
17
18
-export type Props = {|
18
+export type Props = {
19
disabled?: boolean,
20
-|};
20
+};
21
22
export default function RecordToggle({disabled}: Props) {
23
const {isProfiling, startProfiling, stopProfiling} = useContext(
packages/react-devtools-shared/src/devtools/views/Profiler/ReloadAndProfileButton.js
+4
-4
@@ -14,16 +14,16 @@ import ButtonIcon from '../ButtonIcon';
14
import {BridgeContext, StoreContext} from '../context';
15
import {useSubscription} from '../hooks';
16
17
-type SubscriptionData = {|
17
+type SubscriptionData = {
18
recordChangeDescriptions: boolean,
19
supportsReloadAndProfile: boolean,
20
-|};
20
+};
21
22
export default function ReloadAndProfileButton({
23
disabled,
24
-}: {|
24
+}: {
25
disabled: boolean,
26
-|}) {
26
+}) {
27
const bridge = useContext(BridgeContext);
28
const store = useContext(StoreContext);
29
packages/react-devtools-shared/src/devtools/views/Profiler/RootSelector.js
+1
-1
@@ -13,7 +13,7 @@ import {ProfilerContext} from './ProfilerContext';
13
14
import styles from './RootSelector.css';
15
16
-export default function RootSelector(_: {||}) {
16
+export default function RootSelector(_: {}) {
17
const {profilingData, rootID, setRootID} = useContext(ProfilerContext);
18
19
const options = [];
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarCommitInfo.js
+1
-1
@@ -17,7 +17,7 @@ import {getCommitTree} from './CommitTreeBuilder';
17
18
import styles from './SidebarCommitInfo.css';
19
20
-export type Props = {||};
20
+export type Props = {};
21
22
export default function SidebarCommitInfo(_: Props) {
23
const {selectedCommitIndex, rootID} = useContext(ProfilerContext);
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js
+3
-3
@@ -24,11 +24,11 @@ import {copy} from 'clipboard-js';
24
25
import styles from './SidebarEventInfo.css';
26
27
-export type Props = {||};
27
+export type Props = {};
28
29
-type SchedulingEventProps = {|
29
+type SchedulingEventProps = {
30
eventInfo: SchedulingEvent,
31
-|};
31
+};
32
33
function SchedulingEventInfo({eventInfo}: SchedulingEventProps) {
34
const {viewUrlSourceFunction} = useContext(ViewSourceContext);
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js
+1
-1
@@ -18,7 +18,7 @@ import ButtonIcon from '../ButtonIcon';
18
19
import styles from './SidebarSelectedFiberInfo.css';
20
21
-export type Props = {||};
21
+export type Props = {};
22
23
export default function SidebarSelectedFiberInfo(_: Props) {
24
const {profilerStore} = useContext(StoreContext);
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js
+8
-8
@@ -20,7 +20,7 @@ import Tooltip from './Tooltip';
20
21
import styles from './SnapshotCommitList.css';
22
23
-export type ItemData = {|
23
+export type ItemData = {
24
commitTimes: Array<number>,
25
filteredCommitIndices: Array<number>,
26
maxDuration: number,
@@ -30,9 +30,9 @@ export type ItemData = {|
30
setHoveredCommitIndex: (index: number) => void,
31
startCommitDrag: (newDragState: DragState) => void,
32
totalDurations: Array<number>,
33
-|};
33
+};
34
35
-type Props = {|
35
+type Props = {
36
commitData: CommitDataFrontend,
37
commitTimes: Array<number>,
38
filteredCommitIndices: Array<number>,
@@ -40,7 +40,7 @@ type Props = {|
40
selectedFilteredCommitIndex: number | null,
41
selectCommitIndex: (index: number) => void,
42
totalDurations: Array<number>,
43
-|};
43
+};
44
45
export default function SnapshotCommitList({
46
commitData,
@@ -70,7 +70,7 @@ export default function SnapshotCommitList({
70
);
71
}
72
73
-type ListProps = {|
73
+type ListProps = {
74
commitData: CommitDataFrontend,
75
commitTimes: Array<number>,
76
height: number,
@@ -80,13 +80,13 @@ type ListProps = {|
80
selectCommitIndex: (index: number) => void,
81
totalDurations: Array<number>,
82
width: number,
83
-|};
83
+};
84
85
-type DragState = {|
85
+type DragState = {
86
commitIndex: number,
87
left: number,
88
sizeIncrement: number,
89
-|};
89
+};
90
91
function List({
92
commitData,
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
+1
-1
@@ -18,7 +18,7 @@ import {StoreContext} from '../context';
18
19
import styles from './SnapshotSelector.css';
20
21
-export type Props = {||};
21
+export type Props = {};
22
23
export default function SnapshotSelector(_: Props) {
24
const {
packages/react-devtools-shared/src/devtools/views/Profiler/Updaters.js
+2
-2
@@ -16,10 +16,10 @@ import {ProfilerContext} from './ProfilerContext';
16
import styles from './Updaters.css';
17
import {ElementTypeRoot} from '../../../types';
18
19
-export type Props = {|
19
+export type Props = {
20
commitTree: CommitTree,
21
updaters: Array<SerializedElement>,
22
-|};
22
+};
23
24
export default function Updaters({commitTree, updaters}: Props) {
25
const {selectFiber} = useContext(ProfilerContext);
packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js
+2
-2
@@ -33,9 +33,9 @@ function hookIndicesToString(indices: Array<number>): string {
33
}
34
}
35
36
-type Props = {|
36
+type Props = {
37
fiberID: number,
38
-|};
38
+};
39
40
export default function WhatChanged({fiberID}: Props) {
41
const {profilerStore} = useContext(StoreContext);
packages/react-devtools-shared/src/devtools/views/Profiler/types.js
+20
-20
@@ -14,7 +14,7 @@ import type {
14
TimelineDataExport,
15
} from 'react-devtools-timeline/src/types';
16
17
-export type CommitTreeNode = {|
17
+export type CommitTreeNode = {
18
id: number,
19
children: Array<number>,
20
displayName: string | null,
@@ -23,32 +23,32 @@ export type CommitTreeNode = {|
23
parentID: number,
24
treeBaseDuration: number,
25
type: ElementType,
26
-|};
26
+};
27
28
-export type CommitTree = {|
28
+export type CommitTree = {
29
nodes: Map<number, CommitTreeNode>,
30
rootID: number,
31
-|};
31
+};
32
33
-export type SnapshotNode = {|
33
+export type SnapshotNode = {
34
id: number,
35
children: Array<number>,
36
displayName: string | null,
37
hocDisplayNames: Array<string> | null,
38
key: number | string | null,
39
type: ElementType,
40
-|};
40
+};
41
42
-export type ChangeDescription = {|
42
+export type ChangeDescription = {
43
context: Array<string> | boolean | null,
44
didHooksChange: boolean,
45
isFirstMount: boolean,
46
props: Array<string> | null,
47
state: Array<string> | null,
48
hooks?: Array<number> | null,
49
-|};
49
+};
50
51
-export type CommitDataFrontend = {|
51
+export type CommitDataFrontend = {
52
// Map of Fiber (ID) to a description of what changed in this commit.
53
changeDescriptions: Map<number, ChangeDescription> | null,
54
@@ -79,9 +79,9 @@ export type CommitDataFrontend = {|
79
80
// Fiber(s) responsible for scheduling this update.
81
updaters: Array<SerializedElement> | null,
82
-|};
82
+};
83
84
-export type ProfilingDataForRootFrontend = {|
84
+export type ProfilingDataForRootFrontend = {
85
// Timing, duration, and other metadata about each commit.
86
commitData: Array<CommitDataFrontend>,
87
@@ -103,10 +103,10 @@ export type ProfilingDataForRootFrontend = {|
103
// Map of fiber id to node when the Profiling session was started.
104
// This info can be used along with commitOperations to reconstruct the tree for any commit.
105
snapshots: Map<number, SnapshotNode>,
106
-|};
106
+};
107
108
// Combination of profiling data collected by the renderer interface (backend) and Store (frontend).
109
-export type ProfilingDataFrontend = {|
109
+export type ProfilingDataFrontend = {
110
// Legacy profiling data is per renderer + root.
111
dataForRoots: Map<number, ProfilingDataForRootFrontend>,
112
@@ -117,9 +117,9 @@ export type ProfilingDataFrontend = {|
117
// e.g. DevTools should not try to sync selection between Components and Profiler tabs,
118
// even if there are Fibers with the same IDs.
119
imported: boolean,
120
-|};
120
+};
121
122
-export type CommitDataExport = {|
122
+export type CommitDataExport = {
123
changeDescriptions: Array<[number, ChangeDescription]> | null,
124
duration: number,
125
effectDuration: number | null,
@@ -131,9 +131,9 @@ export type CommitDataExport = {|
131
priorityLevel: string | null,
132
timestamp: number,
133
updaters: Array<SerializedElement> | null,
134
-|};
134
+};
135
136
-export type ProfilingDataForRootExport = {|
136
+export type ProfilingDataForRootExport = {
137
commitData: Array<CommitDataExport>,
138
displayName: string,
139
// Tuple of Fiber ID and base duration
@@ -141,10 +141,10 @@ export type ProfilingDataForRootExport = {|
141
operations: Array<Array<number>>,
142
rootID: number,
143
snapshots: Array<[number, SnapshotNode]>,
144
-|};
144
+};
145
146
// Serializable version of ProfilingDataFrontend data.
147
-export type ProfilingDataExport = {|
147
+export type ProfilingDataExport = {
148
version: 5,
149
150
// Legacy profiling data is per renderer + root.
@@ -153,4 +153,4 @@ export type ProfilingDataExport = {|
153
// Timeline data is per rederer.
154
// Note that old exported profiles won't contain this key.
155
timelineData?: Array<TimelineDataExport>,
156
-|};
156
+};
packages/react-devtools-shared/src/devtools/views/ReactLogo.js
+2
-2
@@ -11,9 +11,9 @@ import * as React from 'react';
11
12
import styles from './ReactLogo.css';
13
14
-type Props = {|
14
+type Props = {
15
className?: string,
16
-|};
16
+};
17
18
export default function ReactLogo({className}: Props) {
19
return (
packages/react-devtools-shared/src/devtools/views/SearchInput.js
+2
-2
@@ -15,7 +15,7 @@ import Icon from './Icon';
15
16
import styles from './SearchInput.css';
17
18
-type Props = {|
18
+type Props = {
19
goToNextResult: () => void,
20
goToPreviousResult: () => void,
21
placeholder: string,
@@ -24,7 +24,7 @@ type Props = {|
24
searchResultsCount: number,
25
searchText: string,
26
testName?: ?string,
27
-|};
27
+};
28
29
export default function SearchInput({
30
goToNextResult,
packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js
+3
-3
@@ -51,7 +51,7 @@ import type {
51
RegExpComponentFilter,
52
} from 'react-devtools-shared/src/types';
53
54
-export default function ComponentsSettings(_: {||}) {
54
+export default function ComponentsSettings(_: {}) {
55
const store = useContext(StoreContext);
56
const {parseHookNames, setParseHookNames} = useContext(SettingsContext);
57
@@ -417,10 +417,10 @@ export default function ComponentsSettings(_: {||}) {
417
);
418
}
419
420
-type ToggleIconProps = {|
420
+type ToggleIconProps = {
421
isEnabled: boolean,
422
isValid: boolean,
423
-|};
423
+};
424
function ToggleIcon({isEnabled, isValid}: ToggleIconProps) {
425
let className;
426
if (isValid) {
packages/react-devtools-shared/src/devtools/views/Settings/DebuggingSettings.js
+1
-1
@@ -13,7 +13,7 @@ import {SettingsContext} from './SettingsContext';
13
14
import styles from './SettingsShared.css';
15
16
-export default function DebuggingSettings(_: {||}) {
16
+export default function DebuggingSettings(_: {}) {
17
const {
18
appendComponentStack,
19
breakOnConsoleErrors,
packages/react-devtools-shared/src/devtools/views/Settings/GeneralSettings.js
+2
-2
@@ -28,7 +28,7 @@ function getChangeLogUrl(version: ?string): string | null {
28
return `${CHANGE_LOG_URL}#${versionAnchor}`;
29
}
30
31
-export default function GeneralSettings(_: {||}) {
31
+export default function GeneralSettings(_: {}) {
32
const {
33
displayDensity,
34
setDisplayDensity,
@@ -113,7 +113,7 @@ export default function GeneralSettings(_: {||}) {
113
);
114
}
115
116
-function Version({label, version}: {|label: string, version: ?string|}) {
116
+function Version({label, version}: {label: string, version: ?string}) {
117
const changelogLink = useMemo(() => {
118
return getChangeLogUrl(version);
119
}, [version]);
packages/react-devtools-shared/src/devtools/views/Settings/ProfilerSettings.js
+1
-1
@@ -15,7 +15,7 @@ import {ProfilerContext} from 'react-devtools-shared/src/devtools/views/Profiler
15
16
import styles from './SettingsShared.css';
17
18
-export default function ProfilerSettings(_: {||}) {
18
+export default function ProfilerSettings(_: {}) {
19
const {
20
isCommitFilterEnabled,
21
minCommitDuration,
packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js
+4
-4
@@ -35,7 +35,7 @@ import type {BrowserTheme} from '../DevTools';
35
export type DisplayDensity = 'comfortable' | 'compact';
36
export type Theme = 'auto' | 'light' | 'dark';
37
38
-type Context = {|
38
+type Context = {
39
displayDensity: DisplayDensity,
40
setDisplayDensity(value: DisplayDensity): void,
41
@@ -65,7 +65,7 @@ type Context = {|
65
66
traceUpdatesEnabled: boolean,
67
setTraceUpdatesEnabled: (value: boolean) => void,
68
-|};
68
+};
69
70
const SettingsContext = createContext<Context>(((null: any): Context));
71
SettingsContext.displayName = 'SettingsContext';
@@ -88,12 +88,12 @@ function useLocalStorageWithLog<T>(
88
89
type DocumentElements = Array<HTMLElement>;
90
91
-type Props = {|
91
+type Props = {
92
browserTheme: BrowserTheme,
93
children: React$Node,
94
componentsPortalContainer?: Element,
95
profilerPortalContainer?: Element,
96
-|};
96
+};
97
98
function SettingsContextController({
99
browserTheme,
packages/react-devtools-shared/src/devtools/views/Settings/SettingsModal.js
+2
-2
@@ -28,7 +28,7 @@ import styles from './SettingsModal.css';
28
29
type TabID = 'general' | 'components' | 'profiler';
30
31
-export default function SettingsModal(_: {||}) {
31
+export default function SettingsModal(_: {}) {
32
const {isModalShowing, setIsModalShowing} = useContext(SettingsModalContext);
33
const store = useContext(StoreContext);
34
const {profilerStore} = store;
@@ -57,7 +57,7 @@ export default function SettingsModal(_: {||}) {
57
return <SettingsModalImpl />;
58
}
59
60
-function SettingsModalImpl(_: {||}) {
60
+function SettingsModalImpl(_: {}) {
61
const {setIsModalShowing} = useContext(SettingsModalContext);
62
const dismissModal = useCallback(() => setIsModalShowing(false), [
63
setIsModalShowing,
packages/react-devtools-shared/src/devtools/views/Settings/SettingsModalContext.js
+1
-1
@@ -22,7 +22,7 @@ type Context = {
22
const SettingsModalContext = createContext<Context>(((null: any): Context));
23
SettingsModalContext.displayName = 'SettingsModalContext';
24
25
-function SettingsModalContextController({children}: {|children: React$Node|}) {
25
+function SettingsModalContextController({children}: {children: React$Node}) {
26
const [isModalShowing, setIsModalShowing] = useState<boolean>(false);
27
28
const value = useMemo(() => ({isModalShowing, setIsModalShowing}), [
packages/react-devtools-shared/src/devtools/views/TabBar.js
+4
-4
@@ -16,21 +16,21 @@ import Tooltip from './Components/reach-ui/tooltip';
16
17
import type {IconType} from './Icon';
18
19
-type TabInfo = {|
19
+type TabInfo = {
20
icon: IconType,
21
id: string,
22
label: string,
23
title?: string,
24
-|};
24
+};
25
26
-export type Props = {|
26
+export type Props = {
27
currentTab: any,
28
disabled?: boolean,
29
id: string,
30
selectTab: (tabID: any) => void,
31
tabs: Array<TabInfo | null>,
32
type: 'navigation' | 'profiler' | 'settings',
33
-|};
33
+};
34
35
export default function TabBar({
36
currentTab,
packages/react-devtools-shared/src/devtools/views/ThemeProvider.js
+1
-1
@@ -10,7 +10,7 @@
10
import * as React from 'react';
11
import useThemeStyles from './useThemeStyles';
12
13
-export default function ThemeProvider({children}: {|children: React$Node|}) {
13
+export default function ThemeProvider({children}: {children: React$Node}) {
14
const themeStyle = useThemeStyles();
15
16
const style = React.useMemo(() => {
packages/react-devtools-shared/src/devtools/views/UnsupportedBridgeProtocolDialog.js
+3
-3
@@ -24,7 +24,7 @@ const INSTRUCTIONS_FB_URL =
24
'https://fb.me/devtools-unsupported-bridge-protocol';
25
const MODAL_DIALOG_ID = 'UnsupportedBridgeProtocolDialog';
26
27
-export default function UnsupportedBridgeProtocolDialog(_: {||}) {
27
+export default function UnsupportedBridgeProtocolDialog(_: {}) {
28
const {dialogs, dispatch} = useContext(ModalDialogContext);
29
const store = useContext(StoreContext);
30
@@ -66,9 +66,9 @@ export default function UnsupportedBridgeProtocolDialog(_: {||}) {
66
67
function DialogContent({
68
unsupportedBridgeProtocol,
69
-}: {|
69
+}: {
70
unsupportedBridgeProtocol: BridgeProtocol,
71
-|}) {
71
+}) {
72
const {version, minNpmVersion, maxNpmVersion} = unsupportedBridgeProtocol;
73
74
let instructions;
packages/react-devtools-shared/src/devtools/views/UnsupportedVersionDialog.js
+2
-2
@@ -18,7 +18,7 @@ import styles from './UnsupportedVersionDialog.css';
18
19
type DAILOG_STATE = 'dialog-not-shown' | 'show-dialog' | 'dialog-shown';
20
21
-export default function UnsupportedVersionDialog(_: {||}) {
21
+export default function UnsupportedVersionDialog(_: {}) {
22
const {dispatch} = useContext(ModalDialogContext);
23
const store = useContext(StoreContext);
24
const [state, setState] = useState<DAILOG_STATE>('dialog-not-shown');
@@ -54,7 +54,7 @@ export default function UnsupportedVersionDialog(_: {||}) {
54
return null;
55
}
56
57
-function DialogContent(_: {||}) {
57
+function DialogContent(_: {}) {
58
return (
59
<Fragment>
60
<div className={styles.Row}>
packages/react-devtools-shared/src/devtools/views/WarnIfLegacyBackendDetected.js
+2
-2
@@ -14,7 +14,7 @@ import {ModalDialogContext} from './ModalDialog';
14
15
import styles from './WarnIfLegacyBackendDetected.css';
16
17
-export default function WarnIfLegacyBackendDetected(_: {||}) {
17
+export default function WarnIfLegacyBackendDetected(_: {}) {
18
const bridge = useContext(BridgeContext);
19
const {dispatch} = useContext(ModalDialogContext);
20
@@ -75,7 +75,7 @@ export default function WarnIfLegacyBackendDetected(_: {||}) {
75
return null;
76
}
77
78
-function InvalidBackendDetected(_: {||}) {
78
+function InvalidBackendDetected(_: {}) {
79
return (
80
<Fragment>
81
<p>Either upgrade React or install React DevTools v3:</p>
packages/react-devtools-shared/src/devtools/views/context.js
+4
-4
@@ -21,10 +21,10 @@ BridgeContext.displayName = 'BridgeContext';
21
export const StoreContext = createContext<Store>(((null: any): Store));
22
StoreContext.displayName = 'StoreContext';
23
24
-export type ContextMenuContextType = {|
24
+export type ContextMenuContextType = {
25
isEnabledForInspectedElement: boolean,
26
viewAttributeSourceFunction: ViewAttributeSource | null,
27
-|};
27
+};
28
29
export const ContextMenuContext = createContext<ContextMenuContextType>({
30
isEnabledForInspectedElement: false,
@@ -32,14 +32,14 @@ export const ContextMenuContext = createContext<ContextMenuContextType>({
32
});
33
ContextMenuContext.displayName = 'ContextMenuContext';
34
35
-export type OptionsContextType = {|
35
+export type OptionsContextType = {
36
readOnly: boolean,
37
hideSettings: boolean,
38
hideToggleErrorAction: boolean,
39
hideToggleSuspenseAction: boolean,
40
hideLogAction: boolean,
41
hideViewSourceAction: boolean,
42
-|};
42
+};
43
44
export const OptionsContext = createContext<OptionsContextType>({
45
readOnly: false,
packages/react-devtools-shared/src/devtools/views/hooks.js
+8
-8
@@ -23,25 +23,25 @@ import {
23
import {StoreContext, BridgeContext} from './context';
24
import {sanitizeForParse, smartParse, smartStringify} from '../utils';
25
26
-type ACTION_RESET = {|
26
+type ACTION_RESET = {
27
type: 'RESET',
28
externalValue: any,
29
-|};
30
-type ACTION_UPDATE = {|
29
+};
30
+type ACTION_UPDATE = {
31
type: 'UPDATE',
32
editableValue: any,
33
externalValue: any,
34
-|};
34
+};
35
36
type UseEditableValueAction = ACTION_RESET | ACTION_UPDATE;
37
type UseEditableValueDispatch = (action: UseEditableValueAction) => void;
38
-type UseEditableValueState = {|
38
+type UseEditableValueState = {
39
editableValue: any,
40
externalValue: any,
41
hasPendingChanges: boolean,
42
isValid: boolean,
43
parsedValue: any,
44
-|};
44
+};
45
46
function useEditableValueReducer(state, action) {
47
switch (action.type) {
@@ -271,10 +271,10 @@ export function useModalDismissSignal(
271
export function useSubscription<Value>({
272
getCurrentValue,
273
subscribe,
274
-}: {|
274
+}: {
275
getCurrentValue: () => Value,
276
subscribe: (callback: Function) => () => void,
277
-|}): Value {
277
+}): Value {
278
const [state, setState] = useState(() => ({
279
getCurrentValue,
280
subscribe,
packages/react-devtools-shared/src/dynamicImportCache.js
+6
-6
@@ -17,20 +17,20 @@ const Pending = 0;
17
const Resolved = 1;
18
const Rejected = 2;
19
20
-type PendingRecord = {|
20
+type PendingRecord = {
21
status: 0,
22
value: Wakeable,
23
-|};
23
+};
24
25
-type ResolvedRecord<T> = {|
25
+type ResolvedRecord<T> = {
26
status: 1,
27
value: T,
28
-|};
28
+};
29
30
-type RejectedRecord = {|
30
+type RejectedRecord = {
31
status: 2,
32
value: null,
33
-|};
33
+};
34
35
type Record<T> = PendingRecord | ResolvedRecord<T> | RejectedRecord;
36
packages/react-devtools-shared/src/hook.js
+2
-2
@@ -224,10 +224,10 @@ export function installHook(target: any): DevToolsHook | null {
224
function patchConsoleForInitialRenderInStrictMode({
225
hideConsoleLogsInStrictMode,
226
browserTheme,
227
- }: {|
227
+ }: {
228
hideConsoleLogsInStrictMode: boolean,
229
browserTheme: BrowserTheme,
230
- |}) {
230
+ }) {
231
const overrideConsoleMethods = [
232
'error',
233
'group',
packages/react-devtools-shared/src/hookNamesCache.js
+6
-6
@@ -27,20 +27,20 @@ const Pending = 0;
27
const Resolved = 1;
28
const Rejected = 2;
29
30
-type PendingRecord = {|
30
+type PendingRecord = {
31
status: 0,
32
value: Wakeable,
33
-|};
33
+};
34
35
-type ResolvedRecord<T> = {|
35
+type ResolvedRecord<T> = {
36
status: 1,
37
value: T,
38
-|};
38
+};
39
40
-type RejectedRecord = {|
40
+type RejectedRecord = {
41
status: 2,
42
value: null,
43
-|};
43
+};
44
45
type Record<T> = PendingRecord | ResolvedRecord<T> | RejectedRecord;
46
packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
+8
-8
@@ -16,21 +16,21 @@ import type {
16
MixedSourceMap,
17
} from './SourceMapTypes';
18
19
-type SearchPosition = {|
19
+type SearchPosition = {
20
columnNumber: number,
21
lineNumber: number,
22
-|};
22
+};
23
24
-type ResultPosition = {|
24
+type ResultPosition = {
25
column: number,
26
line: number,
27
sourceContent: string,
28
sourceURL: string,
29
-|};
29
+};
30
31
-export type SourceMapConsumerType = {|
31
+export type SourceMapConsumerType = {
32
originalPositionFor: SearchPosition => ResultPosition,
33
-|};
33
+};
34
35
type Mappings = Array<Array<Array<number>>>;
36
@@ -138,14 +138,14 @@ function BasicSourceMapConsumer(sourceMapJSON: BasicSourceMap) {
138
}: any): SourceMapConsumerType);
139
}
140
141
-type Section = {|
141
+type Section = {
142
+generatedColumn: number,
143
+generatedLine: number,
144
+map: MixedSourceMap,
145
146
// Lazily parsed only when/as the section is needed.
147
sourceMapConsumer: SourceMapConsumerType | null,
148
-|};
148
+};
149
150
function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) {
151
let lastOffset = {
packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js
+2
-2
@@ -83,10 +83,10 @@ export class SourceMapMetadataConsumer {
83
line,
84
column,
85
source,
86
- }: {|
86
+ }: {
87
...Position,
88
+source: ?string,
89
- |}): ?string {
89
+ }): ?string {
90
if (source == null) {
91
return null;
92
}
packages/react-devtools-shared/src/hooks/SourceMapTypes.js
+4
-4
@@ -15,7 +15,7 @@ export type ReactSourcesArray = $ReadOnlyArray<?ReactSourceMetadata>;
15
export type FBSourceMetadata = [?{...}, ?ReactSourceMetadata];
16
export type FBSourcesArray = $ReadOnlyArray<?FBSourceMetadata>;
17
18
-export type BasicSourceMap = {|
18
+export type BasicSourceMap = {
19
+file?: string,
20
+mappings: string,
21
+names: Array<string>,
@@ -25,7 +25,7 @@ export type BasicSourceMap = {|
25
+version: number,
26
+x_facebook_sources?: FBSourcesArray,
27
+x_react_sources?: ReactSourcesArray,
28
-|};
28
+};
29
30
export type IndexSourceMapSection = {
31
map: IndexSourceMap | BasicSourceMap,
@@ -37,7 +37,7 @@ export type IndexSourceMapSection = {
37
...
38
};
39
40
-export type IndexSourceMap = {|
40
+export type IndexSourceMap = {
41
+file?: string,
42
+mappings?: void, // avoids SourceMap being a disjoint union
43
+sourcesContent?: void,
@@ -45,6 +45,6 @@ export type IndexSourceMap = {|
45
+version: number,
46
+x_facebook_sources?: FBSourcesArray,
47
+x_react_sources?: ReactSourcesArray,
48
-|};
48
+};
49
50
export type MixedSourceMap = IndexSourceMap | BasicSourceMap;
packages/react-devtools-shared/src/hooks/astUtils.js
+5
-5
@@ -13,16 +13,16 @@ import {File} from '@babel/types';
13
14
import type {HooksNode} from 'react-debug-tools/src/ReactDebugHooks';
15
16
-export type Position = {|
16
+export type Position = {
17
line: number,
18
column: number,
19
-|};
19
+};
20
21
-export type SourceFileASTWithHookDetails = {|
21
+export type SourceFileASTWithHookDetails = {
22
sourceFileAST: File,
23
line: number,
24
source: string,
25
-|};
25
+};
26
27
export const NO_HOOK_NAME = '<no-hook>';
28
@@ -356,7 +356,7 @@ function getPotentialHookDeclarationsFromAST(sourceAST: File): NodePath[] {
356
*/
357
export function getHookNamesMappingFromAST(
358
sourceAST: File,
359
-): $ReadOnlyArray<{|name: string, start: Position|}> {
359
+): $ReadOnlyArray<{name: string, start: Position}> {
360
const hookStack = [];
361
const hookNames = [];
362
const pushFrame = (name: string, node: Node) => {
packages/react-devtools-shared/src/hooks/generateHookMap.js
+4
-4
@@ -11,15 +11,15 @@ import {getHookNamesMappingFromAST} from './astUtils';
11
import {encode, decode} from 'sourcemap-codec';
12
import {File} from '@babel/types';
13
14
-export type HookMap = {|
14
+export type HookMap = {
15
names: $ReadOnlyArray<string>,
16
mappings: HookMapMappings,
17
-|};
17
+};
18
19
-export type EncodedHookMap = {|
19
+export type EncodedHookMap = {
20
names: $ReadOnlyArray<string>,
21
mappings: string,
22
-|};
22
+};
23
24
// See generateHookMap below for more details on formatting
25
export type HookMapEntry = [
packages/react-devtools-shared/src/hooks/getHookNameForLocation.js
+3
-3
@@ -91,7 +91,7 @@ function binSearch<T>(
91
location: Position,
92
items: T[],
93
index: number,
94
- ) => {|index: number | null, direction: number|},
94
+ ) => {index: number | null, direction: number},
95
): T | null {
96
let count = items.length;
97
let index = 0;
@@ -141,7 +141,7 @@ function compareLinePositions(
141
location: Position,
142
mappings: HookMapMappings,
143
index: number,
144
-): {|index: number | null, direction: number|} {
144
+): {index: number | null, direction: number} {
145
const startIndex = index;
146
const start = mappings[startIndex];
147
if (start == null) {
@@ -200,7 +200,7 @@ function compareColumnPositions(
200
location: Position,
201
line: HookMapLine,
202
index: number,
203
-): {|index: number | null, direction: number|} {
203
+): {index: number | null, direction: number} {
204
const startIndex = index;
205
const start = line[index];
206
if (start == null) {
packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js
+2
-2
@@ -68,7 +68,7 @@ const FETCH_OPTIONS = {cache: 'force-cache'};
68
69
const MAX_SOURCE_LENGTH = 100_000_000;
70
71
-export type HookSourceAndMetadata = {|
71
+export type HookSourceAndMetadata = {
72
// Generated by react-debug-tools.
73
hookSource: HookSource,
74
@@ -86,7 +86,7 @@ export type HookSourceAndMetadata = {|
86
// External URL of source map.
87
// Sources without source maps (or with inline source maps) won't have this.
88
sourceMapURL: string | null,
89
-|};
89
+};
90
91
export type LocationKeyToHookSourceAndMetadata = Map<
92
string,
packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
+6
-6
@@ -33,7 +33,7 @@ import type {HookNames, LRUCache} from 'react-devtools-shared/src/types';
33
34
type AST = mixed;
35
36
-type HookParsedMetadata = {|
36
+type HookParsedMetadata = {
37
// API for consuming metadfata present in extended source map.
38
metadataConsumer: SourceMapMetadataConsumer | null,
39
@@ -55,24 +55,24 @@ type HookParsedMetadata = {|
55
56
// Alternate APIs from source-map for parsing source maps (if detected).
57
sourceMapConsumer: SourceMapConsumerType | null,
58
-|};
58
+};
59
60
type LocationKeyToHookParsedMetadata = Map<string, HookParsedMetadata>;
61
62
-type CachedRuntimeCodeMetadata = {|
62
+type CachedRuntimeCodeMetadata = {
63
metadataConsumer: SourceMapMetadataConsumer | null,
64
sourceMapConsumer: SourceMapConsumerType | null,
65
-|};
65
+};
66
67
const runtimeURLToMetadataCache: LRUCache<
68
string,
69
CachedRuntimeCodeMetadata,
70
> = new LRU({max: 50});
71
72
-type CachedSourceCodeMetadata = {|
72
+type CachedSourceCodeMetadata = {
73
originalSourceAST: AST,
74
originalSourceCode: string,
75
-|};
75
+};
76
77
const originalURLToMetadataCache: LRUCache<
78
string,
packages/react-devtools-shared/src/hydration.js
+2
-2
@@ -30,7 +30,7 @@ export const meta = {
30
unserializable: Symbol('unserializable'),
31
};
32
33
-export type Dehydrated = {|
33
+export type Dehydrated = {
34
inspectable: boolean,
35
name: string | null,
36
preview_long: string | null,
@@ -38,7 +38,7 @@ export type Dehydrated = {|
38
readonly?: boolean,
39
size?: number,
40
type: string,
41
-|};
41
+};
42
43
// Typed arrays and other complex iteratable objects (e.g. Map, Set, ImmutableJS) need special handling.
44
// These objects can't be serialized without losing type information,
packages/react-devtools-shared/src/inspectedElementCache.js
+8
-8
@@ -26,20 +26,20 @@ const Pending = 0;
26
const Resolved = 1;
27
const Rejected = 2;
28
29
-type PendingRecord = {|
29
+type PendingRecord = {
30
status: 0,
31
value: Wakeable,
32
-|};
32
+};
33
34
-type ResolvedRecord<T> = {|
34
+type ResolvedRecord<T> = {
35
status: 1,
36
value: T,
37
-|};
37
+};
38
39
-type RejectedRecord = {|
39
+type RejectedRecord = {
40
status: 2,
41
value: Error | string,
42
-|};
42
+};
43
44
type Record<T> = PendingRecord | ResolvedRecord<T> | RejectedRecord;
45
@@ -168,12 +168,12 @@ export function checkForUpdate({
168
element,
169
refresh,
170
store,
171
-}: {|
171
+}: {
172
bridge: FrontendBridge,
173
element: Element,
174
refresh: RefreshFunction,
175
store: Store,
176
-|}): void {
176
+}): void {
177
const {id} = element;
178
const rendererID = store.getRendererIDForElement(id);
179
if (rendererID != null) {
packages/react-devtools-shared/src/inspectedElementMutableSource.js
+2
-2
@@ -58,12 +58,12 @@ export function inspectElement({
58
element,
59
path,
60
rendererID,
61
-}: {|
61
+}: {
62
bridge: FrontendBridge,
63
element: Element,
64
path: Path | null,
65
rendererID: number,
66
-|}): Promise<InspectElementReturnType> {
66
+}): Promise<InspectElementReturnType> {
67
const {id} = element;
68
69
// This could indicate that the DevTools UI has been closed and reopened.
packages/react-devtools-shared/src/registerDevToolsEventLogger.js
+2
-2
@@ -15,9 +15,9 @@ import {enableLogger} from 'react-devtools-feature-flags';
15
let loggingIFrame = null;
16
let missedEvents = [];
17
18
-type LoggerContext = {|
18
+type LoggerContext = {
19
page_url: ?string,
20
-|};
20
+};
21
22
export function registerDevToolsEventLogger(
23
surface: string,
packages/react-devtools-shared/src/types.js
+14
-14
@@ -7,11 +7,11 @@
7
* @flow
8
*/
9
10
-export type Wall = {|
10
+export type Wall = {
11
// `listen` returns the "unlisten" function.
12
listen: (fn: Function) => Function,
13
send: (event: string, payload: any, transferable?: Array<any>) => void,
14
-|};
14
+};
15
16
// WARNING
17
// The values below are referenced by ComponentFilters (which are saved via localStorage).
@@ -52,26 +52,26 @@ export type ComponentFilterType = 1 | 2 | 3 | 4;
52
53
// Hide all elements of types in this Set.
54
// We hide host components only by default.
55
-export type ElementTypeComponentFilter = {|
55
+export type ElementTypeComponentFilter = {
56
isEnabled: boolean,
57
type: 1,
58
value: ElementType,
59
-|};
59
+};
60
61
// Hide all elements with displayNames or paths matching one or more of the RegExps in this Set.
62
// Path filters are only used when elements include debug source location.
63
-export type RegExpComponentFilter = {|
63
+export type RegExpComponentFilter = {
64
isEnabled: boolean,
65
isValid: boolean,
66
type: 2 | 3,
67
value: string,
68
-|};
68
+};
69
70
-export type BooleanComponentFilter = {|
70
+export type BooleanComponentFilter = {
71
isEnabled: boolean,
72
isValid: boolean,
73
type: 4,
74
-|};
74
+};
75
76
export type ComponentFilter =
77
| BooleanComponentFilter
@@ -85,21 +85,21 @@ export type HookName = string | null;
85
export type HookSourceLocationKey = string;
86
export type HookNames = Map<HookSourceLocationKey, HookName>;
87
88
-export type LRUCache<K, V> = {|
88
+export type LRUCache<K, V> = {
89
del: (key: K) => void,
90
get: (key: K) => V,
91
has: (key: K) => boolean,
92
reset: () => void,
93
set: (key: K, value: V) => void,
94
-|};
94
+};
95
96
-export type StyleXPlugin = {|
96
+export type StyleXPlugin = {
97
sources: Array<string>,
98
resolvedStyles: Object,
99
-|};
99
+};
100
101
-export type Plugins = {|
101
+export type Plugins = {
102
stylex: StyleXPlugin | null,
103
-|};
103
+};
104
105
export const StrictMode = 1;
packages/react-devtools-shell/src/app/EditableProps/index.js
+4
-4
@@ -32,7 +32,7 @@ function reducer(state, action) {
32
}
33
}
34
35
-type StatefulFunctionProps = {|name: string|};
35
+type StatefulFunctionProps = {name: string};
36
37
function StatefulFunction({name}: StatefulFunctionProps) {
38
const [count, updateCount] = useState(0);
@@ -68,8 +68,8 @@ function StatefulFunction({name}: StatefulFunctionProps) {
68
const BoolContext = createContext(true);
69
BoolContext.displayName = 'BoolContext';
70
71
-type Props = {|name: string, toggle: boolean|};
72
-type State = {|cities: Array<string>, state: string|};
71
+type Props = {name: string, toggle: boolean};
72
+type State = {cities: Array<string>, state: string};
73
74
class StatefulClass extends Component<Props, State> {
75
static contextType = BoolContext;
@@ -102,7 +102,7 @@ class StatefulClass extends Component<Props, State> {
102
const MemoizedStatefulClass = memo(StatefulClass);
103
const MemoizedStatefulFunction = memo(StatefulFunction);
104
105
-const ForwardRef = forwardRef<{|name: string|}, HTMLUListElement>(
105
+const ForwardRef = forwardRef<{name: string}, HTMLUListElement>(
106
({name}, ref) => {
107
const [count, updateCount] = useState(0);
108
const debouncedCount = useDebounce(count, 1000);
packages/react-devtools-shell/src/app/ToDoList/List.js
+3
-3
@@ -12,13 +12,13 @@ import {Fragment, useCallback, useState} from 'react';
12
import ListItem from './ListItem';
13
import styles from './List.css';
14
15
-export type Item = {|
15
+export type Item = {
16
id: number,
17
isComplete: boolean,
18
text: string,
19
-|};
19
+};
20
21
-type Props = {||};
21
+type Props = {};
22
23
export default function List(props: Props) {
24
const [newItemText, setNewItemText] = useState<string>('');
packages/react-devtools-shell/src/app/ToDoList/ListItem.js
+2
-2
@@ -13,11 +13,11 @@ import styles from './ListItem.css';
13
14
import type {Item} from './List';
15
16
-type Props = {|
16
+type Props = {
17
item: Item,
18
removeItem: (item: Item) => void,
19
toggleItem: (item: Item) => void,
20
-|};
20
+};
21
22
function ListItem({item, removeItem, toggleItem}: Props) {
23
const handleDelete = useCallback(() => {
packages/react-devtools-timeline/src/CanvasPage.js
+5
-5
@@ -69,10 +69,10 @@ import styles from './CanvasPage.css';
69
70
const CONTEXT_MENU_ID = 'canvas';
71
72
-type Props = {|
72
+type Props = {
73
profilerData: TimelineData,
74
viewState: ViewState,
75
-|};
75
+};
76
77
function CanvasPage({profilerData, viewState}: Props) {
78
return (
@@ -80,7 +80,7 @@ function CanvasPage({profilerData, viewState}: Props) {
80
className={styles.CanvasPage}
81
style={{backgroundColor: COLORS.BACKGROUND}}>
82
<AutoSizer>
83
- {({height, width}: {|height: number, width: number|}) => (
83
+ {({height, width}: {height: number, width: number}) => (
84
<AutoSizedCanvas
85
data={profilerData}
86
height={height}
@@ -145,12 +145,12 @@ const EMPTY_CONTEXT_INFO: ReactEventInfo = {
145
userTimingMark: null,
146
};
147
148
-type AutoSizedCanvasProps = {|
148
+type AutoSizedCanvasProps = {
149
data: TimelineData,
150
height: number,
151
viewState: ViewState,
152
width: number,
153
-|};
153
+};
154
155
function AutoSizedCanvas({
156
data,
packages/react-devtools-timeline/src/EventTooltip.js
+20
-20
@@ -36,14 +36,14 @@ import styles from './EventTooltip.css';
36
37
const MAX_TOOLTIP_TEXT_LENGTH = 60;
38
39
-type Props = {|
40
- canvasRef: {|current: HTMLCanvasElement | null|},
39
+type Props = {
40
+ canvasRef: {current: HTMLCanvasElement | null},
41
data: TimelineData,
42
height: number,
43
hoveredEvent: ReactEventInfo | null,
44
origin: Point,
45
width: number,
46
-|};
46
+};
47
48
function getReactMeasureLabel(type): string | null {
49
switch (type) {
@@ -135,9 +135,9 @@ export default function EventTooltip({
135
136
const TooltipReactComponentMeasure = ({
137
componentMeasure,
138
-}: {|
138
+}: {
139
componentMeasure: ReactComponentMeasure,
140
-|}) => {
140
+}) => {
141
const {componentName, duration, timestamp, type, warning} = componentMeasure;
142
143
let label = componentName;
@@ -182,9 +182,9 @@ const TooltipReactComponentMeasure = ({
182
183
const TooltipFlamechartNode = ({
184
stackFrame,
185
-}: {|
185
+}: {
186
stackFrame: FlamechartStackFrame,
187
-|}) => {
187
+}) => {
188
const {name, timestamp, duration, locationLine, locationColumn} = stackFrame;
189
return (
190
<div className={styles.TooltipSection}>
@@ -207,7 +207,7 @@ const TooltipFlamechartNode = ({
207
);
208
};
209
210
-const TooltipNativeEvent = ({nativeEvent}: {|nativeEvent: NativeEvent|}) => {
210
+const TooltipNativeEvent = ({nativeEvent}: {nativeEvent: NativeEvent}) => {
211
const {duration, timestamp, type, warning} = nativeEvent;
212
213
return (
@@ -234,9 +234,9 @@ const TooltipNativeEvent = ({nativeEvent}: {|nativeEvent: NativeEvent|}) => {
234
235
const TooltipNetworkMeasure = ({
236
networkMeasure,
237
-}: {|
237
+}: {
238
networkMeasure: NetworkMeasure,
239
-|}) => {
239
+}) => {
240
const {
241
finishTimestamp,
242
lastReceivedDataTimestamp,
@@ -269,10 +269,10 @@ const TooltipNetworkMeasure = ({
269
const TooltipSchedulingEvent = ({
270
data,
271
schedulingEvent,
272
-}: {|
272
+}: {
273
data: TimelineData,
274
schedulingEvent: SchedulingEvent,
275
-|}) => {
275
+}) => {
276
const label = getSchedulingEventLabel(schedulingEvent);
277
if (!label) {
278
if (__DEV__) {
@@ -335,11 +335,11 @@ const TooltipSnapshot = ({
335
height,
336
snapshot,
337
width,
338
-}: {|
338
+}: {
339
height: number,
340
snapshot: Snapshot,
341
width: number,
342
-|}) => {
342
+}) => {
343
const aspectRatio = snapshot.width / snapshot.height;
344
345
// Zoomed in view should not be any bigger than the DevTools viewport.
@@ -365,9 +365,9 @@ const TooltipSnapshot = ({
365
366
const TooltipSuspenseEvent = ({
367
suspenseEvent,
368
-}: {|
368
+}: {
369
suspenseEvent: SuspenseEvent,
370
-|}) => {
370
+}) => {
371
const {
372
componentName,
373
duration,
@@ -424,10 +424,10 @@ const TooltipSuspenseEvent = ({
424
const TooltipReactMeasure = ({
425
data,
426
measure,
427
-}: {|
427
+}: {
428
data: TimelineData,
429
measure: ReactMeasure,
430
-|}) => {
430
+}) => {
431
const label = getReactMeasureLabel(measure.type);
432
if (!label) {
433
if (__DEV__) {
@@ -471,7 +471,7 @@ const TooltipReactMeasure = ({
471
);
472
};
473
474
-const TooltipUserTimingMark = ({mark}: {|mark: UserTimingMark|}) => {
474
+const TooltipUserTimingMark = ({mark}: {mark: UserTimingMark}) => {
475
const {name, timestamp} = mark;
476
return (
477
<div className={styles.TooltipSection}>
@@ -485,7 +485,7 @@ const TooltipUserTimingMark = ({mark}: {|mark: UserTimingMark|}) => {
485
);
486
};
487
488
-const TooltipThrownError = ({thrownError}: {|thrownError: ThrownError|}) => {
488
+const TooltipThrownError = ({thrownError}: {thrownError: ThrownError}) => {
489
const {componentName, message, phase, timestamp} = thrownError;
490
const label = `threw an error during ${phase}`;
491
return (
packages/react-devtools-timeline/src/Timeline.js
+3
-3
@@ -32,7 +32,7 @@ import {TimelineSearchContextController} from './TimelineSearchContext';
32
33
import styles from './Timeline.css';
34
35
-export function Timeline(_: {||}) {
35
+export function Timeline(_: {}) {
36
const {
37
file,
38
inMemoryTimelineData,
@@ -143,11 +143,11 @@ const FileLoader = ({
143
file,
144
onFileSelect,
145
viewState,
146
-}: {|
146
+}: {
147
file: File | null,
148
onFileSelect: (file: File) => void,
149
viewState: ViewState,
150
-|}) => {
150
+}) => {
151
if (file === null) {
152
return null;
153
}
packages/react-devtools-timeline/src/TimelineContext.js
+4
-4
@@ -27,7 +27,7 @@ import type {
27
} from './types';
28
import type {RefObject} from 'shared/ReactTypes';
29
30
-export type Context = {|
30
+export type Context = {
31
file: File | null,
32
inMemoryTimelineData: Array<TimelineData> | null,
33
isTimelineSupported: boolean,
@@ -36,14 +36,14 @@ export type Context = {|
36
viewState: ViewState,
37
selectEvent: ReactEventInfo => void,
38
selectedEvent: ReactEventInfo,
39
-|};
39
+};
40
41
const TimelineContext = createContext<Context>(((null: any): Context));
42
TimelineContext.displayName = 'TimelineContext';
43
44
-type Props = {|
44
+type Props = {
45
children: React$Node,
46
-|};
46
+};
47
48
function TimelineContextController({children}: Props) {
49
const searchInputContainerRef = useRef(null);
packages/react-devtools-timeline/src/TimelineSearchContext.js
+12
-12
@@ -12,24 +12,24 @@ import {createContext, useMemo, useReducer} from 'react';
12
13
import type {ReactComponentMeasure, TimelineData, ViewState} from './types';
14
15
-type State = {|
15
+type State = {
16
profilerData: TimelineData,
17
searchIndex: number,
18
searchRegExp: RegExp | null,
19
searchResults: Array<ReactComponentMeasure>,
20
searchText: string,
21
-|};
21
+};
22
23
-type ACTION_GO_TO_NEXT_SEARCH_RESULT = {|
23
+type ACTION_GO_TO_NEXT_SEARCH_RESULT = {
24
type: 'GO_TO_NEXT_SEARCH_RESULT',
25
-|};
26
-type ACTION_GO_TO_PREVIOUS_SEARCH_RESULT = {|
25
+};
26
+type ACTION_GO_TO_PREVIOUS_SEARCH_RESULT = {
27
type: 'GO_TO_PREVIOUS_SEARCH_RESULT',
28
-|};
29
-type ACTION_SET_SEARCH_TEXT = {|
28
+};
29
+type ACTION_SET_SEARCH_TEXT = {
30
type: 'SET_SEARCH_TEXT',
31
payload: string,
32
-|};
32
+};
33
34
type Action =
35
| ACTION_GO_TO_NEXT_SEARCH_RESULT
@@ -111,7 +111,7 @@ function reducer(state: State, action: Action): State {
111
};
112
}
113
114
-export type Context = {|
114
+export type Context = {
115
profilerData: TimelineData,
116
117
// Search state
@@ -120,16 +120,16 @@ export type Context = {|
120
searchRegExp: null,
121
searchResults: Array<ReactComponentMeasure>,
122
searchText: string,
123
-|};
123
+};
124
125
const TimelineSearchContext = createContext<Context>(((null: any): Context));
126
TimelineSearchContext.displayName = 'TimelineSearchContext';
127
128
-type Props = {|
128
+type Props = {
129
children: React$Node,
130
profilerData: TimelineData,
131
viewState: ViewState,
132
-|};
132
+};
133
134
function TimelineSearchContextController({
135
children,
packages/react-devtools-timeline/src/TimelineSearchInput.js
+1
-1
@@ -14,7 +14,7 @@ import SearchInput from 'react-devtools-shared/src/devtools/views/SearchInput';
14
import {TimelineContext} from './TimelineContext';
15
import {TimelineSearchContext} from './TimelineSearchContext';
16
17
-type Props = {||};
17
+type Props = {};
18
19
export default function TimelineSearchInput(props: Props) {
20
const {searchInputContainerRef} = useContext(TimelineContext);
packages/react-devtools-timeline/src/content-views/utils/colors.js
+3
-3
@@ -7,10 +7,10 @@
7
* @flow
8
*/
9
10
-type ColorSpace = number | {|min: number, max: number, count?: number|};
10
+type ColorSpace = number | {min: number, max: number, count?: number};
11
12
// Docstrings from https://www.w3schools.com/css/css_colors_hsl.asp
13
-type HslaColor = $ReadOnly<{|
13
+type HslaColor = $ReadOnly<{
14
/** Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. */
15
h: number,
16
/** Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color. */
@@ -19,7 +19,7 @@ type HslaColor = $ReadOnly<{|
19
l: number,
20
/** Alpha is a percentage, 0% is fully transparent, and 100 is not transparent at all. */
21
a: number,
22
-|}>;
22
+}>;
23
24
export function hslaColorToString({h, s, l, a}: HslaColor): string {
25
return `hsl(${h}deg ${s}% ${l}% / ${a})`;
packages/react-devtools-timeline/src/content-views/utils/text.js
+2
-2
@@ -62,11 +62,11 @@ export function trimText(
62
return longestValidText;
63
}
64
65
-type TextConfig = {|
65
+type TextConfig = {
66
fillStyle?: string,
67
fontSize?: number,
68
textAlign?: 'left' | 'center',
69
-|};
69
+};
70
71
export function drawText(
72
text: string,
packages/react-devtools-timeline/src/import-worker/index.js
+3
-3
@@ -22,9 +22,9 @@ const workerizedImportFile: ImportFileModule = window.Worker
22
: importFileModule;
23
24
export type ImportWorkerOutputData =
25
- | {|status: 'SUCCESS', processedData: TimelineData|}
26
- | {|status: 'INVALID_PROFILE_ERROR', error: Error|}
27
- | {|status: 'UNEXPECTED_ERROR', error: Error|};
25
+ | {status: 'SUCCESS', processedData: TimelineData}
26
+ | {status: 'INVALID_PROFILE_ERROR', error: Error}
27
+ | {status: 'UNEXPECTED_ERROR', error: Error};
28
29
export type importFileFunction = (file: File) => ImportWorkerOutputData;
30
packages/react-devtools-timeline/src/import-worker/preprocessData.js
+4
-4
@@ -38,15 +38,15 @@ import InvalidProfileError from './InvalidProfileError';
38
import {getBatchRange} from '../utils/getBatchRange';
39
import ErrorStackParser from 'error-stack-parser';
40
41
-type MeasureStackElement = {|
41
+type MeasureStackElement = {
42
type: ReactMeasureType,
43
depth: number,
44
measure: ReactMeasure,
45
startTime: Milliseconds,
46
stopTime?: Milliseconds,
47
-|};
47
+};
48
49
-type ProcessorState = {|
49
+type ProcessorState = {
50
asyncProcessingPromises: Promise<any>[],
51
batchUID: BatchUID,
52
currentReactComponentMeasure: ReactComponentMeasure | null,
@@ -64,7 +64,7 @@ type ProcessorState = {|
64
requestIdToNetworkMeasureMap: Map<string, NetworkMeasure>,
65
uidCounter: BatchUID,
66
unresolvedSuspenseEvents: Map<string, SuspenseEvent>,
67
-|};
67
+};
68
69
const NATIVE_EVENT_DURATION_THRESHOLD = 20;
70
const NESTED_UPDATE_DURATION_THRESHOLD = 20;
packages/react-devtools-timeline/src/timelineCache.js
+6
-6
@@ -16,20 +16,20 @@ const Pending = 0;
16
const Resolved = 1;
17
const Rejected = 2;
18
19
-type PendingRecord = {|
19
+type PendingRecord = {
20
status: 0,
21
value: Wakeable,
22
-|};
22
+};
23
24
-type ResolvedRecord<T> = {|
24
+type ResolvedRecord<T> = {
25
status: 1,
26
value: T,
27
-|};
27
+};
28
29
-type RejectedRecord = {|
29
+type RejectedRecord = {
30
status: 2,
31
value: Error,
32
-|};
32
+};
33
34
type Record<T> = PendingRecord | ResolvedRecord<T> | RejectedRecord;
35
packages/react-devtools-timeline/src/types.js
+38
-38
@@ -17,51 +17,51 @@ export type Return<T> = Return_<*, T>;
17
18
// Project types
19
20
-export type ErrorStackFrame = {|
20
+export type ErrorStackFrame = {
21
fileName: string,
22
lineNumber: number,
23
columnNumber: number,
24
-|};
24
+};
25
26
export type Milliseconds = number;
27
28
export type ReactLane = number;
29
30
-export type NativeEvent = {|
30
+export type NativeEvent = {
31
+depth: number,
32
+duration: Milliseconds,
33
+timestamp: Milliseconds,
34
+type: string,
35
warning: string | null,
36
-|};
36
+};
37
38
-type BaseReactEvent = {|
38
+type BaseReactEvent = {
39
+componentName?: string,
40
+timestamp: Milliseconds,
41
warning: string | null,
42
-|};
42
+};
43
44
-type BaseReactScheduleEvent = {|
44
+type BaseReactScheduleEvent = {
45
...BaseReactEvent,
46
+lanes: ReactLane[],
47
-|};
48
-export type ReactScheduleRenderEvent = {|
47
+};
48
+export type ReactScheduleRenderEvent = {
49
...BaseReactScheduleEvent,
50
+type: 'schedule-render',
51
-|};
52
-export type ReactScheduleStateUpdateEvent = {|
51
+};
52
+export type ReactScheduleStateUpdateEvent = {
53
...BaseReactScheduleEvent,
54
+componentStack?: string,
55
+type: 'schedule-state-update',
56
-|};
57
-export type ReactScheduleForceUpdateEvent = {|
56
+};
57
+export type ReactScheduleForceUpdateEvent = {
58
...BaseReactScheduleEvent,
59
+type: 'schedule-force-update',
60
-|};
60
+};
61
62
export type Phase = 'mount' | 'update';
63
64
-export type SuspenseEvent = {|
64
+export type SuspenseEvent = {
65
...BaseReactEvent,
66
depth: number,
67
duration: number | null,
@@ -70,15 +70,15 @@ export type SuspenseEvent = {|
70
promiseName: string | null,
71
resolution: 'rejected' | 'resolved' | 'unresolved',
72
+type: 'suspense',
73
-|};
73
+};
74
75
-export type ThrownError = {|
75
+export type ThrownError = {
76
+componentName?: string,
77
+message: string,
78
+phase: Phase,
79
+timestamp: Milliseconds,
80
+type: 'thrown-error',
81
-|};
81
+};
82
83
export type SchedulingEvent =
84
| ReactScheduleRenderEvent
@@ -97,16 +97,16 @@ export type ReactMeasureType =
97
98
export type BatchUID = number;
99
100
-export type ReactMeasure = {|
100
+export type ReactMeasure = {
101
+type: ReactMeasureType,
102
+lanes: ReactLane[],
103
+timestamp: Milliseconds,
104
+duration: Milliseconds,
105
+batchUID: BatchUID,
106
+depth: number,
107
-|};
107
+};
108
109
-export type NetworkMeasure = {|
109
+export type NetworkMeasure = {
110
+depth: number,
111
finishTimestamp: Milliseconds,
112
firstReceivedDataTimestamp: Milliseconds,
@@ -117,7 +117,7 @@ export type NetworkMeasure = {|
117
requestMethod: string,
118
sendRequestTimestamp: Milliseconds,
119
url: string,
120
-|};
120
+};
121
122
export type ReactComponentMeasureType =
123
| 'render'
@@ -126,38 +126,38 @@ export type ReactComponentMeasureType =
126
| 'passive-effect-mount'
127
| 'passive-effect-unmount';
128
129
-export type ReactComponentMeasure = {|
129
+export type ReactComponentMeasure = {
130
+componentName: string,
131
duration: Milliseconds,
132
+timestamp: Milliseconds,
133
+type: ReactComponentMeasureType,
134
warning: string | null,
135
-|};
135
+};
136
137
/**
138
* A flamechart stack frame belonging to a stack trace.
139
*/
140
-export type FlamechartStackFrame = {|
140
+export type FlamechartStackFrame = {
141
name: string,
142
timestamp: Milliseconds,
143
duration: Milliseconds,
144
scriptUrl?: string,
145
locationLine?: number,
146
locationColumn?: number,
147
-|};
147
+};
148
149
-export type UserTimingMark = {|
149
+export type UserTimingMark = {
150
name: string,
151
timestamp: Milliseconds,
152
-|};
152
+};
153
154
-export type Snapshot = {|
154
+export type Snapshot = {
155
height: number,
156
image: Image | null,
157
+imageSource: string,
158
+timestamp: Milliseconds,
159
width: number,
160
-|};
160
+};
161
162
/**
163
* A "layer" of stack frames in the profiler UI, i.e. all stack frames of the
@@ -177,7 +177,7 @@ export type SearchRegExpStateChangeCallback = (
177
// Imperative view state that corresponds to profiler data.
178
// This state lives outside of React's lifecycle
179
// and should be erased/reset whenever new profiler data is loaded.
180
-export type ViewState = {|
180
+export type ViewState = {
181
horizontalScrollState: ScrollState,
182
onHorizontalScrollStateChange: (
183
callback: HorizontalScrollStateChangeCallback,
@@ -189,7 +189,7 @@ export type ViewState = {|
189
updateHorizontalScrollState: (scrollState: ScrollState) => void,
190
updateSearchRegExpState: (searchRegExp: RegExp | null) => void,
191
viewToMutableViewStateMap: Map<string, mixed>,
192
-|};
192
+};
193
194
export type InternalModuleSourceToRanges = Map<
195
string,
@@ -198,7 +198,7 @@ export type InternalModuleSourceToRanges = Map<
198
199
export type LaneToLabelMap = Map<ReactLane, string>;
200
201
-export type TimelineData = {|
201
+export type TimelineData = {
202
batchUIDToMeasuresMap: Map<BatchUID, ReactMeasure[]>,
203
componentMeasures: ReactComponentMeasure[],
204
duration: number,
@@ -216,9 +216,9 @@ export type TimelineData = {|
216
startTime: number,
217
suspenseEvents: SuspenseEvent[],
218
thrownErrors: ThrownError[],
219
-|};
219
+};
220
221
-export type TimelineDataExport = {|
221
+export type TimelineDataExport = {
222
batchUIDToMeasuresKeyValueArray: Array<[BatchUID, ReactMeasure[]]>,
223
componentMeasures: ReactComponentMeasure[],
224
duration: number,
@@ -238,9 +238,9 @@ export type TimelineDataExport = {|
238
startTime: number,
239
suspenseEvents: SuspenseEvent[],
240
thrownErrors: ThrownError[],
241
-|};
241
+};
242
243
-export type ReactEventInfo = {|
243
+export type ReactEventInfo = {
244
componentMeasure: ReactComponentMeasure | null,
245
flamechartStackFrame: FlamechartStackFrame | null,
246
measure: ReactMeasure | null,
@@ -251,4 +251,4 @@ export type ReactEventInfo = {|
251
snapshot: Snapshot | null,
252
thrownError: ThrownError | null,
253
userTimingMark: UserTimingMark | null,
254
-|};
254
+};
packages/react-devtools-timeline/src/utils/useSmartTooltip.js
+3
-3
@@ -16,11 +16,11 @@ export default function useSmartTooltip({
16
canvasRef,
17
mouseX,
18
mouseY,
19
-}: {|
20
- canvasRef: {|current: HTMLCanvasElement | null|},
19
+}: {
20
+ canvasRef: {current: HTMLCanvasElement | null},
21
mouseX: number,
22
mouseY: number,
23
-|}) {
23
+}) {
24
const ref = useRef<HTMLElement | null>(null);
25
26
// HACK: Browser extension reports window.innerHeight of 0,
packages/react-devtools-timeline/src/view-base/Surface.js
+2
-2
@@ -16,10 +16,10 @@ import {View} from './View';
16
import {zeroPoint} from './geometry';
17
import {DPR} from '../content-views/constants';
18
19
-export type ViewRefs = {|
19
+export type ViewRefs = {
20
activeView: View | null,
21
hoveredView: View | null,
22
-|};
22
+};
23
24
// hidpi canvas: https://www.html5rocks.com/en/tutorials/canvas/hidpi/
25
function configureRetinaCanvas(canvas, height, width) {
packages/react-devtools-timeline/src/view-base/geometry.js
+5
-5
@@ -7,9 +7,9 @@
7
* @flow
8
*/
9
10
-export type Point = $ReadOnly<{|x: number, y: number|}>;
11
-export type Size = $ReadOnly<{|width: number, height: number|}>;
12
-export type IntrinsicSize = {|
10
+export type Point = $ReadOnly<{x: number, y: number}>;
11
+export type Size = $ReadOnly<{width: number, height: number}>;
12
+export type IntrinsicSize = {
13
...Size,
14
15
// If content is this height or less, hide the scrollbar entirely,
@@ -18,8 +18,8 @@ export type IntrinsicSize = {|
18
19
// The initial height should be the height of the content, or this, whichever is less.
20
maxInitialHeight?: number,
21
-|};
22
-export type Rect = $ReadOnly<{|origin: Point, size: Size|}>;
21
+};
22
+export type Rect = $ReadOnly<{origin: Point, size: Size}>;
23
24
/**
25
* Alternative representation of `Rect`.
packages/react-devtools-timeline/src/view-base/layouter.js
+1
-1
@@ -10,7 +10,7 @@
10
import type {Rect} from './geometry';
11
import type {View} from './View';
12
13
-export type LayoutInfo = {|view: View, frame: Rect|};
13
+export type LayoutInfo = {view: View, frame: Rect};
14
export type Layout = LayoutInfo[];
15
16
/**
packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js
+6
-6
@@ -26,17 +26,17 @@ import {rectContainsPoint} from '../geometry';
26
import {noopLayout} from '../layouter';
27
import {clamp} from '../utils/clamp';
28
29
-type ResizingState = $ReadOnly<{|
29
+type ResizingState = $ReadOnly<{
30
/** Distance between top of resize bar and mouseY */
31
cursorOffsetInBarFrame: number,
32
/** Mouse's vertical coordinates relative to canvas */
33
mouseY: number,
34
-|}>;
34
+}>;
35
36
-type LayoutState = {|
36
+type LayoutState = {
37
/** Resize bar's vertical position relative to resize view's frame.origin.y */
38
barOffsetY: number,
39
-|};
39
+};
40
41
const RESIZE_BAR_HEIGHT = 8;
42
const RESIZE_BAR_WITH_LABEL_HEIGHT = 16;
@@ -47,7 +47,7 @@ const HIDDEN_RECT = {
47
};
48
49
export class ResizableView extends View {
50
- _canvasRef: {|current: HTMLCanvasElement | null|};
50
+ _canvasRef: {current: HTMLCanvasElement | null};
51
_layoutState: LayoutState;
52
_mutableViewStateKey: string;
53
_resizeBar: ResizeBarView;
@@ -60,7 +60,7 @@ export class ResizableView extends View {
60
frame: Rect,
61
subview: View,
62
viewState: ViewState,
63
- canvasRef: {|current: HTMLCanvasElement | null|},
63
+ canvasRef: {current: HTMLCanvasElement | null},
64
label: string,
65
) {
66
super(surface, frame, noopLayout);
packages/react-devtools-timeline/src/view-base/useCanvasInteraction.js
+37
-37
@@ -13,73 +13,73 @@ import type {Point} from './geometry';
13
import {useEffect, useRef} from 'react';
14
import {normalizeWheel} from './utils/normalizeWheel';
15
16
-export type ClickInteraction = {|
16
+export type ClickInteraction = {
17
type: 'click',
18
- payload: {|
18
+ payload: {
19
event: MouseEvent,
20
location: Point,
21
- |},
22
-|};
23
-export type DoubleClickInteraction = {|
21
+ },
22
+};
23
+export type DoubleClickInteraction = {
24
type: 'double-click',
25
- payload: {|
25
+ payload: {
26
event: MouseEvent,
27
location: Point,
28
- |},
29
-|};
30
-export type MouseDownInteraction = {|
28
+ },
29
+};
30
+export type MouseDownInteraction = {
31
type: 'mousedown',
32
- payload: {|
32
+ payload: {
33
event: MouseEvent,
34
location: Point,
35
- |},
36
-|};
37
-export type MouseMoveInteraction = {|
35
+ },
36
+};
37
+export type MouseMoveInteraction = {
38
type: 'mousemove',
39
- payload: {|
39
+ payload: {
40
event: MouseEvent,
41
location: Point,
42
- |},
43
-|};
44
-export type MouseUpInteraction = {|
42
+ },
43
+};
44
+export type MouseUpInteraction = {
45
type: 'mouseup',
46
- payload: {|
46
+ payload: {
47
event: MouseEvent,
48
location: Point,
49
- |},
50
-|};
51
-export type WheelPlainInteraction = {|
49
+ },
50
+};
51
+export type WheelPlainInteraction = {
52
type: 'wheel-plain',
53
- payload: {|
53
+ payload: {
54
event: WheelEvent,
55
location: Point,
56
delta: NormalizedWheelDelta,
57
- |},
58
-|};
59
-export type WheelWithShiftInteraction = {|
57
+ },
58
+};
59
+export type WheelWithShiftInteraction = {
60
type: 'wheel-shift',
61
- payload: {|
61
+ payload: {
62
event: WheelEvent,
63
location: Point,
64
delta: NormalizedWheelDelta,
65
- |},
66
-|};
67
-export type WheelWithControlInteraction = {|
65
+ },
66
+};
67
+export type WheelWithControlInteraction = {
68
type: 'wheel-control',
69
- payload: {|
69
+ payload: {
70
event: WheelEvent,
71
location: Point,
72
delta: NormalizedWheelDelta,
73
- |},
74
-|};
75
-export type WheelWithMetaInteraction = {|
73
+ },
74
+};
75
+export type WheelWithMetaInteraction = {
76
type: 'wheel-meta',
77
- payload: {|
77
+ payload: {
78
event: WheelEvent,
79
location: Point,
80
delta: NormalizedWheelDelta,
81
- |},
82
-|};
81
+ },
82
+};
83
84
export type Interaction =
85
| ClickInteraction
@@ -112,7 +112,7 @@ function cacheFirstGetCanvasBoundingRect(
112
}
113
114
export function useCanvasInteraction(
115
- canvasRef: {|current: HTMLCanvasElement | null|},
115
+ canvasRef: {current: HTMLCanvasElement | null},
116
interactor: (interaction: Interaction) => void,
117
) {
118
const isMouseDownRef = useRef<boolean>(false);
packages/react-devtools-timeline/src/view-base/utils/normalizeWheel.js
+2
-2
@@ -9,10 +9,10 @@
9
10
// Adapted from: https://github.com/facebookarchive/fixed-data-table/blob/main/src/vendor_upstream/dom/normalizeWheel.js
11
12
-export type NormalizedWheelDelta = {|
12
+export type NormalizedWheelDelta = {
13
deltaX: number,
14
deltaY: number,
15
-|};
15
+};
16
17
// Reasonable defaults
18
const LINE_HEIGHT = 40;
packages/react-devtools-timeline/src/view-base/utils/scrollState.js
+12
-12
@@ -18,10 +18,10 @@ import {clamp} from './clamp';
18
* |<-------------------length------------------->|
19
* ```
20
*/
21
-export type ScrollState = {|
21
+export type ScrollState = {
22
offset: number,
23
length: number,
24
-|};
24
+};
25
26
function clampOffset(state: ScrollState, containerLength: number): ScrollState {
27
return {
@@ -35,12 +35,12 @@ function clampLength({
35
minContentLength,
36
maxContentLength,
37
containerLength,
38
-}: {|
38
+}: {
39
state: ScrollState,
40
minContentLength: number,
41
maxContentLength: number,
42
containerLength: number,
43
-|}): ScrollState {
43
+}): ScrollState {
44
return {
45
offset: state.offset,
46
length: clamp(
@@ -62,12 +62,12 @@ export function clampState({
62
minContentLength,
63
maxContentLength,
64
containerLength,
65
-}: {|
65
+}: {
66
state: ScrollState,
67
minContentLength: number,
68
maxContentLength: number,
69
containerLength: number,
70
-|}): ScrollState {
70
+}): ScrollState {
71
return clampOffset(
72
clampLength({
73
state,
@@ -83,11 +83,11 @@ export function translateState({
83
state,
84
delta,
85
containerLength,
86
-}: {|
86
+}: {
87
state: ScrollState,
88
delta: number,
89
containerLength: number,
90
-|}): ScrollState {
90
+}): ScrollState {
91
return clampOffset(
92
{
93
offset: state.offset + delta,
@@ -119,7 +119,7 @@ export function zoomState({
119
minContentLength,
120
maxContentLength,
121
containerLength,
122
-}: {|
122
+}: {
123
state: ScrollState,
124
multiplier: number,
125
fixedPoint: number,
@@ -127,7 +127,7 @@ export function zoomState({
127
minContentLength: number,
128
maxContentLength: number,
129
containerLength: number,
130
-|}): ScrollState {
130
+}): ScrollState {
131
// Length and offset must be computed separately, so that if the length is
132
// clamped the offset will still be correct (unless it gets clamped too).
133
@@ -164,7 +164,7 @@ export function moveStateToRange({
164
minContentLength,
165
maxContentLength,
166
containerLength,
167
-}: {|
167
+}: {
168
state: ScrollState,
169
rangeStart: number,
170
rangeEnd: number,
@@ -173,7 +173,7 @@ export function moveStateToRange({
173
minContentLength: number,
174
maxContentLength: number,
175
containerLength: number,
176
-|}): ScrollState {
176
+}): ScrollState {
177
// Length and offset must be computed separately, so that if the length is
178
// clamped the offset will still be correct (unless it gets clamped too).
179
packages/react-dom/src/client/ReactDOMEventHandle.js
+2
-2
@@ -29,9 +29,9 @@ import {
29
enableCreateEventHandleAPI,
30
} from 'shared/ReactFeatureFlags';
31
32
-type EventHandleOptions = {|
32
+type EventHandleOptions = {
33
capture?: boolean,
34
-|};
34
+};
35
36
function isValidEventTarget(target: EventTarget | ReactScopeInstance): boolean {
37
return typeof (target: Object).addEventListener === 'function';
packages/react-dom/src/client/ReactDOMHostConfig.js
+8
-8
@@ -126,12 +126,12 @@ export type UpdatePayload = Array<mixed>;
126
export type ChildSet = void; // Unused
127
export type TimeoutHandle = TimeoutID;
128
export type NoTimeout = -1;
129
-export type RendererInspectionConfig = $ReadOnly<{||}>;
129
+export type RendererInspectionConfig = $ReadOnly<{}>;
130
131
-type SelectionInformation = {|
131
+type SelectionInformation = {
132
focusedElem: null | HTMLElement,
133
selectionRange: mixed,
134
-|};
134
+};
135
136
const SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
137
@@ -733,7 +733,7 @@ export function isSuspenseInstanceFallback(instance: SuspenseInstance) {
733
734
export function getSuspenseInstanceFallbackErrorDetails(
735
instance: SuspenseInstance,
736
-): {|digest: ?string, message?: string, stack?: string|} {
736
+): {digest: ?string, message?: string, stack?: string} {
737
const dataset =
738
instance.nextSibling && ((instance.nextSibling: any): HTMLElement).dataset;
739
let digest, message, stack;
@@ -1320,20 +1320,20 @@ export function setFocusIfFocusable(node: Instance): boolean {
1320
return didFocus;
1321
}
1322
1323
-type RectRatio = {|
1323
+type RectRatio = {
1324
ratio: number,
1325
rect: BoundingRect,
1326
-|};
1326
+};
1327
1328
export function setupIntersectionObserver(
1329
targets: Array<Instance>,
1330
callback: ObserveVisibleRectsCallback,
1331
options?: IntersectionObserverOptions,
1332
-): {|
1332
+): {
1333
disconnect: () => void,
1334
observe: (instance: Instance) => void,
1335
unobserve: (instance: Instance) => void,
1336
-|} {
1336
+} {
1337
const rectRatioCache: Map<Instance, RectRatio> = new Map();
1338
targets.forEach(target => {
1339
rectRatioCache.set(target, {
packages/react-dom/src/client/ReactDOMSelect.js
+3
-3
@@ -21,9 +21,9 @@ if (__DEV__) {
21
didWarnValueDefaultValue = false;
22
}
23
24
-type SelectWithWrapperState = HTMLSelectElement & {|
25
- _wrapperState: {|wasMultiple: boolean|},
26
-|};
24
+type SelectWithWrapperState = HTMLSelectElement & {
25
+ _wrapperState: {wasMultiple: boolean},
26
+};
27
28
function getDeclarationErrorAddendum() {
29
const ownerName = getCurrentFiberOwnerNameInDevOrNull();
packages/react-dom/src/client/ReactDOMTextarea.js
+3
-3
@@ -17,9 +17,9 @@ import {disableTextareaChildren} from 'shared/ReactFeatureFlags';
17
18
let didWarnValDefaultVal = false;
19
20
-type TextAreaWithWrapperState = HTMLTextAreaElement & {|
21
- _wrapperState: {|initialValue: ToStringValue|},
22
-|};
20
+type TextAreaWithWrapperState = HTMLTextAreaElement & {
21
+ _wrapperState: {initialValue: ToStringValue},
22
+};
23
24
/**
25
* Implements a <textarea> host component that allows setting `value`, and
packages/react-dom/src/client/inputValueTracking.js
+2
-2
@@ -9,11 +9,11 @@
9
10
import {checkFormFieldValueStringCoercion} from 'shared/CheckStringCoercion';
11
12
-type ValueTracker = {|
12
+type ValueTracker = {
13
getValue(): string,
14
setValue(value: string): void,
15
stopTracking(): void,
16
-|};
16
+};
17
type WrapperState = {_valueTracker?: ?ValueTracker, ...};
18
type ElementWithValueTracker = HTMLInputElement & WrapperState;
19
packages/react-dom/src/events/DOMPluginEventSystem.js
+4
-4
@@ -72,16 +72,16 @@ import * as EnterLeaveEventPlugin from './plugins/EnterLeaveEventPlugin';
72
import * as SelectEventPlugin from './plugins/SelectEventPlugin';
73
import * as SimpleEventPlugin from './plugins/SimpleEventPlugin';
74
75
-type DispatchListener = {|
75
+type DispatchListener = {
76
instance: null | Fiber,
77
listener: Function,
78
currentTarget: EventTarget,
79
-|};
79
+};
80
81
-type DispatchEntry = {|
81
+type DispatchEntry = {
82
event: ReactSyntheticEvent,
83
listeners: Array<DispatchListener>,
84
-|};
84
+};
85
86
export type DispatchQueue = Array<DispatchEntry>;
87
packages/react-dom/src/events/ReactDOMEventReplaying.js
+4
-4
@@ -90,13 +90,13 @@ type PointerEvent = Event & {
90
...
91
};
92
93
-type QueuedReplayableEvent = {|
93
+type QueuedReplayableEvent = {
94
blockedOn: null | Container | SuspenseInstance,
95
domEventName: DOMEventName,
96
eventSystemFlags: EventSystemFlags,
97
nativeEvent: AnyNativeEvent,
98
targetContainers: Array<EventTarget>,
99
-|};
99
+};
100
101
let hasScheduledReplayAttempt = false;
102
@@ -115,11 +115,11 @@ const queuedPointers: Map<number, QueuedReplayableEvent> = new Map();
115
const queuedPointerCaptures: Map<number, QueuedReplayableEvent> = new Map();
116
// We could consider replaying selectionchange and touchmoves too.
117
118
-type QueuedHydrationTarget = {|
118
+type QueuedHydrationTarget = {
119
blockedOn: null | Container | SuspenseInstance,
120
target: Node,
121
priority: EventPriority,
122
-|};
122
+};
123
const queuedExplicitHydrationTargets: Array<QueuedHydrationTarget> = [];
124
125
export function hasQueuedDiscreteEvents(): boolean {
packages/react-dom/src/events/ReactSyntheticEventType.js
+10
-10
@@ -11,16 +11,16 @@
11
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
12
import type {DOMEventName} from './DOMEventNames';
13
14
-export type DispatchConfig = {|
14
+export type DispatchConfig = {
15
dependencies?: Array<DOMEventName>,
16
- phasedRegistrationNames: {|
16
+ phasedRegistrationNames: {
17
bubbled: null | string,
18
captured: null | string,
19
- |},
19
+ },
20
registrationName?: string,
21
-|};
21
+};
22
23
-type BaseSyntheticEvent = {|
23
+type BaseSyntheticEvent = {
24
isPersistent: () => boolean,
25
isPropagationStopped: () => boolean,
26
_dispatchInstances?: null | Array<Fiber | null> | Fiber,
@@ -31,14 +31,14 @@ type BaseSyntheticEvent = {|
31
relatedTarget?: mixed,
32
type: string,
33
currentTarget: null | EventTarget,
34
-|};
34
+};
35
36
-export type KnownReactSyntheticEvent = BaseSyntheticEvent & {|
36
+export type KnownReactSyntheticEvent = BaseSyntheticEvent & {
37
_reactName: string,
38
-|};
39
-export type UnknownReactSyntheticEvent = BaseSyntheticEvent & {|
38
+};
39
+export type UnknownReactSyntheticEvent = BaseSyntheticEvent & {
40
_reactName: null,
41
-|};
41
+};
42
43
export type ReactSyntheticEvent =
44
| KnownReactSyntheticEvent
packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
+4
-4
@@ -24,7 +24,7 @@ import {
24
createRootFormatContext,
25
} from './ReactDOMServerFormatConfig';
26
27
-type Options = {|
27
+type Options = {
28
identifierPrefix?: string,
29
namespaceURI?: string,
30
nonce?: string,
@@ -34,12 +34,12 @@ type Options = {|
34
progressiveChunkSize?: number,
35
signal?: AbortSignal,
36
onError?: (error: mixed) => ?string,
37
-|};
37
+};
38
39
// TODO: Move to sub-classing ReadableStream.
40
-type ReactDOMServerReadableStream = ReadableStream & {|
40
+type ReactDOMServerReadableStream = ReadableStream & {
41
allReady: Promise<void>,
42
-|};
42
+};
43
44
function renderToReadableStream(
45
children: ReactNodeList,
packages/react-dom/src/server/ReactDOMFizzServerNode.js
+4
-4
@@ -34,7 +34,7 @@ function createAbortHandler(request, reason) {
34
return () => abort(request, new Error(reason));
35
}
36
37
-type Options = {|
37
+type Options = {
38
identifierPrefix?: string,
39
namespaceURI?: string,
40
nonce?: string,
@@ -46,14 +46,14 @@ type Options = {|
46
onShellError?: (error: mixed) => void,
47
onAllReady?: () => void,
48
onError?: (error: mixed) => ?string,
49
-|};
49
+};
50
51
-type PipeableStream = {|
51
+type PipeableStream = {
52
// Cancel any pending I/O and put anything remaining into
53
// client rendered mode.
54
abort(reason: mixed): void,
55
pipe<T: Writable>(destination: T): T,
56
-|};
56
+};
57
58
function createRequestImpl(children: ReactNodeList, options: void | Options) {
59
return createRequest(
packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js
+4
-4
@@ -24,7 +24,7 @@ import {
24
createRootFormatContext,
25
} from './ReactDOMServerFormatConfig';
26
27
-type Options = {|
27
+type Options = {
28
identifierPrefix?: string,
29
namespaceURI?: string,
30
bootstrapScriptContent?: string,
@@ -33,11 +33,11 @@ type Options = {|
33
progressiveChunkSize?: number,
34
signal?: AbortSignal,
35
onError?: (error: mixed) => ?string,
36
-|};
36
+};
37
38
-type StaticResult = {|
38
+type StaticResult = {
39
prelude: ReadableStream,
40
-|};
40
+};
41
42
function prerender(
43
children: ReactNodeList,
packages/react-dom/src/server/ReactDOMFizzStaticNode.js
+4
-4
@@ -26,7 +26,7 @@ import {
26
createRootFormatContext,
27
} from './ReactDOMServerFormatConfig';
28
29
-type Options = {|
29
+type Options = {
30
identifierPrefix?: string,
31
namespaceURI?: string,
32
bootstrapScriptContent?: string,
@@ -35,11 +35,11 @@ type Options = {|
35
progressiveChunkSize?: number,
36
signal?: AbortSignal,
37
onError?: (error: mixed) => ?string,
38
-|};
38
+};
39
40
-type StaticResult = {|
40
+type StaticResult = {
41
prelude: Readable,
42
-|};
42
+};
43
44
function createFakeWritable(readable): Writable {
45
// The current host config expects a Writable so we create
packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js
+2
-2
@@ -11,9 +11,9 @@ import type {ReactNodeList} from 'shared/ReactTypes';
11
12
import {version, renderToStringImpl} from './ReactDOMLegacyServerImpl';
13
14
-type ServerOptions = {|
14
+type ServerOptions = {
15
identifierPrefix?: string,
16
-|};
16
+};
17
18
function renderToString(
19
children: ReactNodeList,
packages/react-dom/src/server/ReactDOMLegacyServerImpl.js
+2
-2
@@ -23,9 +23,9 @@ import {
23
createRootFormatContext,
24
} from './ReactDOMServerLegacyFormatConfig';
25
26
-type ServerOptions = {|
26
+type ServerOptions = {
27
identifierPrefix?: string,
28
-|};
28
+};
29
30
function onError() {
31
// Non-fatal errors are ignored.
packages/react-dom/src/server/ReactDOMLegacyServerNode.js
+2
-2
@@ -15,9 +15,9 @@ import {
15
renderToStaticNodeStream,
16
} from './ReactDOMLegacyServerNodeStream';
17
18
-type ServerOptions = {|
18
+type ServerOptions = {
19
identifierPrefix?: string,
20
-|};
20
+};
21
22
function renderToString(
23
children: ReactNodeList,
packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js
+2
-2
@@ -25,9 +25,9 @@ import {
25
26
import {Readable} from 'stream';
27
28
-type ServerOptions = {|
28
+type ServerOptions = {
29
identifierPrefix?: string,
30
-|};
30
+};
31
32
class ReactMarkupReadableStream extends Readable {
33
request: Request;
packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+4
-4
@@ -105,10 +105,10 @@ const scriptRegex = /(<\/|<)(s)(cript)/gi;
105
const scriptReplacer = (match, prefix, s, suffix) =>
106
`${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`;
107
108
-export type BootstrapScriptDescriptor = {|
108
+export type BootstrapScriptDescriptor = {
109
src: string,
110
integrity?: string,
111
-|};
111
+};
112
// Allows us to keep track of what we've already written so we can refer back to it.
113
export function createResponseState(
114
identifierPrefix: string | void,
@@ -203,10 +203,10 @@ const HTML_COLGROUP_MODE = 7;
203
type InsertionMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
204
205
// Lets us keep track of contextual state and pick it back up after suspending.
206
-export type FormatContext = {|
206
+export type FormatContext = {
207
insertionMode: InsertionMode, // root/svg/html/mathml/table
208
selectedValue: null | string | Array<string>, // the selected value(s) inside a <select>, or null outside <select>
209
-|};
209
+};
210
211
function createFormatContext(
212
insertionMode: InsertionMode,
packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js
+2
-2
@@ -28,7 +28,7 @@ import type {
28
29
export const isPrimaryRenderer = false;
30
31
-export type ResponseState = {|
31
+export type ResponseState = {
32
// Keep this in sync with ReactDOMServerFormatConfig
33
bootstrapChunks: Array<Chunk | PrecomputedChunk>,
34
startInlineScript: PrecomputedChunk,
@@ -42,7 +42,7 @@ export type ResponseState = {|
42
sentClientRenderFunction: boolean,
43
// This is an extra field for the legacy renderer
44
generateStaticMarkup: boolean,
45
-|};
45
+};
46
47
export function createResponseState(
48
generateStaticMarkup: boolean,
packages/react-dom/src/shared/DOMProperty.js
+2
-2
@@ -48,7 +48,7 @@ export const NUMERIC = 5;
48
// When falsy, it should be removed.
49
export const POSITIVE_NUMERIC = 6;
50
51
-export type PropertyInfo = {|
51
+export type PropertyInfo = {
52
+acceptsBooleans: boolean,
53
+attributeName: string,
54
+attributeNamespace: string | null,
@@ -57,7 +57,7 @@ export type PropertyInfo = {|
57
+type: PropertyType,
58
+sanitizeURL: boolean,
59
+removeEmptyString: boolean,
60
-|};
60
+};
61
62
/* eslint-disable max-len */
63
export const ATTRIBUTE_NAME_START_CHAR =
packages/react-dom/src/shared/ReactDOMTypes.js
+2
-2
@@ -15,8 +15,8 @@ export type ReactDOMEventHandle = (
15
callback: (SyntheticEvent<EventTarget>) => void,
16
) => () => void;
17
18
-export type ReactDOMEventHandleListener = {|
18
+export type ReactDOMEventHandleListener = {
19
callback: (SyntheticEvent<EventTarget>) => void,
20
capture: boolean,
21
type: DOMEventName,
22
-|};
22
+};
packages/react-fetch/src/ReactFetchBrowser.js
+6
-6
@@ -15,20 +15,20 @@ const Pending = 0;
15
const Resolved = 1;
16
const Rejected = 2;
17
18
-type PendingRecord = {|
18
+type PendingRecord = {
19
status: 0,
20
value: Wakeable,
21
-|};
21
+};
22
23
-type ResolvedRecord = {|
23
+type ResolvedRecord = {
24
status: 1,
25
value: mixed,
26
-|};
26
+};
27
28
-type RejectedRecord = {|
28
+type RejectedRecord = {
29
status: 2,
30
value: mixed,
31
-|};
31
+};
32
33
type Record = PendingRecord | ResolvedRecord | RejectedRecord;
34
packages/react-fetch/src/ReactFetchNode.js
+8
-8
@@ -13,7 +13,7 @@ import * as http from 'http';
13
import * as https from 'https';
14
import {unstable_getCacheForType} from 'react';
15
16
-type FetchResponse = {|
16
+type FetchResponse = {
17
// Properties
18
headers: any,
19
ok: boolean,
@@ -27,7 +27,7 @@ type FetchResponse = {|
27
blob(): any,
28
json(): any,
29
text(): string,
30
-|};
30
+};
31
32
function nodeFetch(
33
url: string,
@@ -58,20 +58,20 @@ const Pending = 0;
58
const Resolved = 1;
59
const Rejected = 2;
60
61
-type PendingRecord = {|
61
+type PendingRecord = {
62
status: 0,
63
value: Wakeable,
64
-|};
64
+};
65
66
-type ResolvedRecord<V> = {|
66
+type ResolvedRecord<V> = {
67
status: 1,
68
value: V,
69
-|};
69
+};
70
71
-type RejectedRecord = {|
71
+type RejectedRecord = {
72
status: 2,
73
value: mixed,
74
-|};
74
+};
75
76
type Record<V> = PendingRecord | ResolvedRecord<V> | RejectedRecord;
77
packages/react-fs/src/ReactFilesystem.js
+13
-13
@@ -17,23 +17,23 @@ const Pending = 0;
17
const Resolved = 1;
18
const Rejected = 2;
19
20
-type PendingRecord = {|
20
+type PendingRecord = {
21
status: 0,
22
value: Wakeable,
23
cache: null,
24
-|};
24
+};
25
26
-type ResolvedRecord<T> = {|
26
+type ResolvedRecord<T> = {
27
status: 1,
28
value: T,
29
cache: null | Array<mixed>,
30
-|};
30
+};
31
32
-type RejectedRecord = {|
32
+type RejectedRecord = {
33
status: 2,
34
value: mixed,
35
cache: null,
36
-|};
36
+};
37
38
type Record<T> = PendingRecord | ResolvedRecord<T> | RejectedRecord;
39
@@ -128,7 +128,7 @@ function createLstatMap(): Map<string, Array<boolean | Record<mixed>>> {
128
return new Map();
129
}
130
131
-export function lstat(path: string, options?: {|bigint?: boolean|}): mixed {
131
+export function lstat(path: string, options?: {bigint?: boolean}): mixed {
132
checkPathInDev(path);
133
let bigint = false;
134
if (options && options.bigint) {
@@ -167,7 +167,7 @@ function createReaddirMap(): Map<
167
168
export function readdir(
169
path: string,
170
- options?: string | {|encoding?: string, withFileTypes?: boolean|},
170
+ options?: string | {encoding?: string, withFileTypes?: boolean},
171
): mixed {
172
checkPathInDev(path);
173
let encoding = 'utf8';
@@ -215,12 +215,12 @@ export function readFile(
215
path: string,
216
options:
217
| string
218
- | {|
218
+ | {
219
encoding?: string | null,
220
// Unsupported:
221
flag?: string, // Doesn't make sense except "r"
222
signal?: mixed, // We'll have our own signal
223
- |},
223
+ },
224
): string | Buffer {
225
checkPathInDev(path);
226
const map = unstable_getCacheForType(createReadFileMap);
@@ -270,7 +270,7 @@ function createReadlinkMap(): Map<string, Array<string | Record<mixed>>> {
270
271
export function readlink(
272
path: string,
273
- options?: string | {|encoding?: string|},
273
+ options?: string | {encoding?: string},
274
): mixed {
275
checkPathInDev(path);
276
let encoding = 'utf8';
@@ -311,7 +311,7 @@ function createRealpathMap(): Map<string, Array<string | Record<mixed>>> {
311
312
export function realpath(
313
path: string,
314
- options?: string | {|encoding?: string|},
314
+ options?: string | {encoding?: string},
315
): mixed {
316
checkPathInDev(path);
317
let encoding = 'utf8';
@@ -350,7 +350,7 @@ function createStatMap(): Map<string, Array<boolean | Record<mixed>>> {
350
return new Map();
351
}
352
353
-export function stat(path: string, options?: {|bigint?: boolean|}): mixed {
353
+export function stat(path: string, options?: {bigint?: boolean}): mixed {
354
checkPathInDev(path);
355
let bigint = false;
356
if (options && options.bigint) {
packages/react-interactions/events/src/dom/create-event-handle/Focus.js
+10
-10
@@ -14,15 +14,15 @@ const {useCallback, useEffect, useLayoutEffect, useRef} = React;
14
15
type FocusEvent = SyntheticEvent<EventTarget>;
16
17
-type UseFocusOptions = {|
17
+type UseFocusOptions = {
18
disabled?: boolean,
19
onBlur?: ?(FocusEvent) => void,
20
onFocus?: ?(FocusEvent) => void,
21
onFocusChange?: ?(boolean) => void,
22
onFocusVisibleChange?: ?(boolean) => void,
23
-|};
23
+};
24
25
-type UseFocusWithinOptions = {|
25
+type UseFocusWithinOptions = {
26
disabled?: boolean,
27
onAfterBlurWithin?: FocusEvent => void,
28
onBeforeBlurWithin?: FocusEvent => void,
@@ -30,7 +30,7 @@ type UseFocusWithinOptions = {|
30
onFocusWithin?: FocusEvent => void,
31
onFocusWithinChange?: boolean => void,
32
onFocusWithinVisibleChange?: boolean => void,
33
-|};
33
+};
34
35
const isMac =
36
typeof window !== 'undefined' && window.navigator != null
@@ -154,7 +154,7 @@ function useFocusLifecycles() {
154
}
155
156
export function useFocus(
157
- focusTargetRef: {|current: null | Node|},
157
+ focusTargetRef: {current: null | Node},
158
{
159
disabled,
160
onBlur,
@@ -164,10 +164,10 @@ export function useFocus(
164
}: UseFocusOptions,
165
): void {
166
// Setup controlled state for this useFocus hook
167
- const stateRef = useRef<null | {|
167
+ const stateRef = useRef<null | {
168
isFocused: boolean,
169
isFocusVisible: boolean,
170
- |}>({isFocused: false, isFocusVisible: false});
170
+ }>({isFocused: false, isFocusVisible: false});
171
const focusHandle = useEvent('focusin');
172
const blurHandle = useEvent('focusout');
173
const focusVisibleHandles = useFocusVisibleInputHandles();
@@ -249,7 +249,7 @@ export function useFocus(
249
250
export function useFocusWithin<T>(
251
focusWithinTargetRef:
252
- | {|current: null | T|}
252
+ | {current: null | T}
253
| ((focusWithinTarget: null | T) => void),
254
{
255
disabled,
@@ -262,10 +262,10 @@ export function useFocusWithin<T>(
262
}: UseFocusWithinOptions,
263
): (focusWithinTarget: null | T) => void {
264
// Setup controlled state for this useFocus hook
265
- const stateRef = useRef<null | {|
265
+ const stateRef = useRef<null | {
266
isFocused: boolean,
267
isFocusVisible: boolean,
268
- |}>({isFocused: false, isFocusVisible: false});
268
+ }>({isFocused: false, isFocusVisible: false});
269
const focusHandle = useEvent('focusin');
270
const blurHandle = useEvent('focusout');
271
const afterBlurHandle = useEvent('afterblur');
packages/react-interactions/events/src/dom/create-event-handle/useEvent.js
+4
-4
@@ -13,19 +13,19 @@ import * as ReactDOM from 'react-dom';
13
const {useLayoutEffect, useRef} = React;
14
const {unstable_createEventHandle} = ReactDOM;
15
16
-type UseEventHandle = {|
16
+type UseEventHandle = {
17
setListener: (
18
target: EventTarget,
19
null | ((SyntheticEvent<EventTarget>) => void),
20
) => void,
21
clear: () => void,
22
-|};
22
+};
23
24
export default function useEvent(
25
event: string,
26
- options?: {|
26
+ options?: {
27
capture?: boolean,
28
- |},
28
+ },
29
): UseEventHandle {
30
const handleRef = useRef<UseEventHandle | null>(null);
31
let useEventHandle = handleRef.current;
packages/react-native-renderer/src/ReactFabricHostConfig.js
+12
-12
@@ -75,15 +75,15 @@ export type HydratableInstance = Instance | TextInstance;
75
export type PublicInstance = ReactFabricHostComponent;
76
export type Container = number;
77
export type ChildSet = Object;
78
-export type HostContext = $ReadOnly<{|
78
+export type HostContext = $ReadOnly<{
79
isInAParentText: boolean,
80
-|}>;
80
+}>;
81
export type UpdatePayload = Object;
82
83
export type TimeoutHandle = TimeoutID;
84
export type NoTimeout = -1;
85
86
-export type RendererInspectionConfig = $ReadOnly<{|
86
+export type RendererInspectionConfig = $ReadOnly<{
87
// Deprecated. Replaced with getInspectorDataForViewAtPoint.
88
getInspectorDataForViewTag?: (tag: number) => Object,
89
getInspectorDataForViewAtPoint?: (
@@ -92,29 +92,29 @@ export type RendererInspectionConfig = $ReadOnly<{|
92
locationY: number,
93
callback: (viewData: TouchedViewDataAtPoint) => mixed,
94
) => void,
95
-|}>;
95
+}>;
96
97
// TODO?: find a better place for this type to live
98
-export type EventListenerOptions = $ReadOnly<{|
98
+export type EventListenerOptions = $ReadOnly<{
99
capture?: boolean,
100
once?: boolean,
101
passive?: boolean,
102
signal: mixed, // not yet implemented
103
-|}>;
104
-export type EventListenerRemoveOptions = $ReadOnly<{|
103
+}>;
104
+export type EventListenerRemoveOptions = $ReadOnly<{
105
capture?: boolean,
106
-|}>;
106
+}>;
107
108
// TODO?: this will be changed in the future to be w3c-compatible and allow "EventListener" objects as well as functions.
109
export type EventListener = Function;
110
111
-type InternalEventListeners = {|
112
- [string]: {|
111
+type InternalEventListeners = {
112
+ [string]: {
113
listener: EventListener,
114
options: EventListenerOptions,
115
invalidated: boolean,
116
- |}[],
117
-|};
116
+ }[],
117
+};
118
119
// TODO: Remove this conditional once all changes have propagated.
120
if (registerEventHandler) {
packages/react-native-renderer/src/ReactNativeHostConfig.js
+4
-4
@@ -35,16 +35,16 @@ export type Instance = ReactNativeFiberHostComponent;
35
export type TextInstance = number;
36
export type HydratableInstance = Instance | TextInstance;
37
export type PublicInstance = Instance;
38
-export type HostContext = $ReadOnly<{|
38
+export type HostContext = $ReadOnly<{
39
isInAParentText: boolean,
40
-|}>;
40
+}>;
41
export type UpdatePayload = Object; // Unused
42
export type ChildSet = void; // Unused
43
44
export type TimeoutHandle = TimeoutID;
45
export type NoTimeout = -1;
46
47
-export type RendererInspectionConfig = $ReadOnly<{|
47
+export type RendererInspectionConfig = $ReadOnly<{
48
// Deprecated. Replaced with getInspectorDataForViewAtPoint.
49
getInspectorDataForViewTag?: (tag: number) => Object,
50
getInspectorDataForViewAtPoint?: (
@@ -53,7 +53,7 @@ export type RendererInspectionConfig = $ReadOnly<{|
53
locationY: number,
54
callback: (viewData: TouchedViewDataAtPoint) => mixed,
55
) => void,
56
-|}>;
56
+}>;
57
58
const UPDATE_SIGNAL = {};
59
if (__DEV__) {
packages/react-native-renderer/src/ReactNativeTypes.js
+30
-30
@@ -35,10 +35,10 @@ export type MeasureLayoutOnSuccessCallback = (
35
36
export type AttributeType<T, V> =
37
| true
38
- | $ReadOnly<{|
38
+ | $ReadOnly<{
39
diff?: (arg1: T, arg2: T) => boolean,
40
process?: (arg1: V) => T,
41
- |}>;
41
+ }>;
42
43
// We either force that `diff` and `process` always use mixed,
44
// or we allow them to define specific types and use this hack
@@ -62,40 +62,40 @@ export type PartialAttributeConfiguration = $ReadOnly<{
62
...
63
}>;
64
65
-export type ViewConfig = $ReadOnly<{|
65
+export type ViewConfig = $ReadOnly<{
66
Commands?: $ReadOnly<{[commandName: string]: number, ...}>,
67
Constants?: $ReadOnly<{[name: string]: mixed, ...}>,
68
Manager?: string,
69
NativeProps?: $ReadOnly<{[propName: string]: string, ...}>,
70
baseModuleName?: ?string,
71
bubblingEventTypes?: $ReadOnly<{
72
- [eventName: string]: $ReadOnly<{|
73
- phasedRegistrationNames: $ReadOnly<{|
72
+ [eventName: string]: $ReadOnly<{
73
+ phasedRegistrationNames: $ReadOnly<{
74
captured: string,
75
bubbled: string,
76
skipBubbling?: ?boolean,
77
- |}>,
78
- |}>,
77
+ }>,
78
+ }>,
79
...,
80
}>,
81
directEventTypes?: $ReadOnly<{
82
- [eventName: string]: $ReadOnly<{|
82
+ [eventName: string]: $ReadOnly<{
83
registrationName: string,
84
- |}>,
84
+ }>,
85
...,
86
}>,
87
uiViewClassName: string,
88
validAttributes: AttributeConfiguration,
89
-|}>;
89
+}>;
90
91
-export type PartialViewConfig = $ReadOnly<{|
91
+export type PartialViewConfig = $ReadOnly<{
92
bubblingEventTypes?: $PropertyType<ViewConfig, 'bubblingEventTypes'>,
93
directEventTypes?: $PropertyType<ViewConfig, 'directEventTypes'>,
94
uiViewClassName: string,
95
validAttributes?: PartialAttributeConfiguration,
96
-|}>;
96
+}>;
97
98
-export type NativeMethods = $ReadOnly<{|
98
+export type NativeMethods = $ReadOnly<{
99
blur(): void,
100
focus(): void,
101
measure(callback: MeasureOnSuccessCallback): void,
@@ -106,7 +106,7 @@ export type NativeMethods = $ReadOnly<{|
106
onFail?: () => void,
107
): void,
108
setNativeProps(nativeProps: {...}): void,
109
-|}>;
109
+}>;
110
111
export type HostComponent<T> = AbstractComponent<T, $ReadOnly<NativeMethods>>;
112
@@ -122,43 +122,43 @@ type InspectorDataProps = $ReadOnly<{
122
...,
123
}>;
124
125
-type InspectorDataSource = $ReadOnly<{|
125
+type InspectorDataSource = $ReadOnly<{
126
fileName?: string,
127
lineNumber?: number,
128
-|}>;
128
+}>;
129
130
type InspectorDataGetter = (
131
<TElementType: ElementType>(
132
componentOrHandle: ElementRef<TElementType> | number,
133
) => ?number,
134
-) => $ReadOnly<{|
134
+) => $ReadOnly<{
135
measure: (callback: MeasureOnSuccessCallback) => void,
136
props: InspectorDataProps,
137
source: InspectorDataSource,
138
-|}>;
138
+}>;
139
140
-export type InspectorData = $ReadOnly<{|
141
- hierarchy: Array<{|
140
+export type InspectorData = $ReadOnly<{
141
+ hierarchy: Array<{
142
name: ?string,
143
getInspectorData: InspectorDataGetter,
144
- |}>,
144
+ }>,
145
selectedIndex: ?number,
146
props: InspectorDataProps,
147
source: ?InspectorDataSource,
148
-|}>;
148
+}>;
149
150
-export type TouchedViewDataAtPoint = $ReadOnly<{|
150
+export type TouchedViewDataAtPoint = $ReadOnly<{
151
pointerY: number,
152
touchedViewTag?: number,
153
closestInstance?: mixed,
154
- frame: $ReadOnly<{|
154
+ frame: $ReadOnly<{
155
top: number,
156
left: number,
157
width: number,
158
height: number,
159
- |}>,
159
+ }>,
160
...InspectorData,
161
-|}>;
161
+}>;
162
163
/**
164
* Flat ReactNative renderer bundles are too big for Flow to parse efficiently.
@@ -268,18 +268,18 @@ export type LayoutAnimationProperty =
268
| 'scaleY'
269
| 'scaleXY';
270
271
-export type LayoutAnimationAnimationConfig = $ReadOnly<{|
271
+export type LayoutAnimationAnimationConfig = $ReadOnly<{
272
duration?: number,
273
delay?: number,
274
springDamping?: number,
275
initialVelocity?: number,
276
type?: LayoutAnimationType,
277
property?: LayoutAnimationProperty,
278
-|}>;
278
+}>;
279
280
-export type LayoutAnimationConfig = $ReadOnly<{|
280
+export type LayoutAnimationConfig = $ReadOnly<{
281
duration: number,
282
create?: LayoutAnimationAnimationConfig,
283
update?: LayoutAnimationAnimationConfig,
284
delete?: LayoutAnimationAnimationConfig,
285
-|}>;
285
+}>;
packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/deepDiffer.js
+1
-1
@@ -10,7 +10,7 @@
10
11
'use strict';
12
13
-type Options = {|+unsafelyIgnoreFunctions?: boolean|};
13
+type Options = {+unsafelyIgnoreFunctions?: boolean};
14
15
/*
16
* @returns {bool} true if different, false if equal
packages/react-native-renderer/src/legacy-events/PluginModuleType.js
+2
-2
@@ -22,7 +22,7 @@ export type PluginName = string;
22
23
export type EventSystemFlags = number;
24
25
-export type LegacyPluginModule<NativeEvent> = {|
25
+export type LegacyPluginModule<NativeEvent> = {
26
eventTypes: EventTypes,
27
extractEvents: (
28
topLevelType: TopLevelType,
@@ -33,4 +33,4 @@ export type LegacyPluginModule<NativeEvent> = {|
33
container?: null | EventTarget,
34
) => ?ReactSyntheticEvent,
35
tapMoveThreshold?: number,
36
-|};
36
+};
packages/react-native-renderer/src/legacy-events/ReactSyntheticEventType.js
+10
-10
@@ -11,27 +11,27 @@
11
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
12
import type {TopLevelType} from './TopLevelEventTypes';
13
14
-export type DispatchConfig = {|
14
+export type DispatchConfig = {
15
dependencies?: Array<TopLevelType>,
16
- phasedRegistrationNames: {|
16
+ phasedRegistrationNames: {
17
bubbled: null | string,
18
captured: null | string,
19
skipBubbling?: ?boolean,
20
- |},
20
+ },
21
registrationName?: string,
22
-|};
22
+};
23
24
-export type CustomDispatchConfig = {|
25
- phasedRegistrationNames: {|
24
+export type CustomDispatchConfig = {
25
+ phasedRegistrationNames: {
26
bubbled: null,
27
captured: null,
28
skipBubbling?: ?boolean,
29
- |},
29
+ },
30
registrationName?: string,
31
customEvent: true,
32
-|};
32
+};
33
34
-export type ReactSyntheticEvent = {|
34
+export type ReactSyntheticEvent = {
35
dispatchConfig: DispatchConfig | CustomDispatchConfig,
36
getPooled: (
37
dispatchConfig: DispatchConfig | CustomDispatchConfig,
@@ -46,4 +46,4 @@ export type ReactSyntheticEvent = {|
46
_targetInst: Fiber,
47
type: string,
48
currentTarget: null | EventTarget,
49
-|};
49
+};
packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js
+2
-2
@@ -14,7 +14,7 @@ import {isStartish, isMoveish, isEndish} from './ResponderTopLevelEventTypes';
14
* should typically only see IDs in the range of 1-20 because IDs get recycled
15
* when touches end and start again.
16
*/
17
-type TouchRecord = {|
17
+type TouchRecord = {
18
touchActive: boolean,
19
startPageX: number,
20
startPageY: number,
@@ -25,7 +25,7 @@ type TouchRecord = {|
25
previousPageX: number,
26
previousPageY: number,
27
previousTimeStamp: number,
28
-|};
28
+};
29
30
const MAX_TOUCH_BANK = 20;
31
const touchBank: Array<TouchRecord> = [];
packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js
+2
-2
@@ -58,9 +58,9 @@ const SUSPENSE_UPDATE_TO_CLIENT_RENDER = new Uint8Array(1);
58
SUSPENSE_UPDATE_TO_CLIENT_RENDER[0] = SUSPENSE_UPDATE_TO_CLIENT_RENDER_TAG;
59
60
// Per response,
61
-export type ResponseState = {|
61
+export type ResponseState = {
62
nextSuspenseID: number,
63
-|};
63
+};
64
65
// Allows us to keep track of what we've already written so we can refer back to it.
66
export function createResponseState(): ResponseState {
packages/react-noop-renderer/src/ReactNoopServer.js
+6
-6
@@ -18,22 +18,22 @@ import type {ReactNodeList} from 'shared/ReactTypes';
18
19
import ReactFizzServer from 'react-server';
20
21
-type Instance = {|
21
+type Instance = {
22
type: string,
23
children: Array<Instance | TextInstance | SuspenseInstance>,
24
prop: any,
25
hidden: boolean,
26
-|};
26
+};
27
28
-type TextInstance = {|
28
+type TextInstance = {
29
text: string,
30
hidden: boolean,
31
-|};
31
+};
32
33
-type SuspenseInstance = {|
33
+type SuspenseInstance = {
34
state: 'pending' | 'complete' | 'client-render',
35
children: Array<Instance | TextInstance | SuspenseInstance>,
36
-|};
36
+};
37
38
type Placeholder = {
39
parent: Instance | SuspenseInstance,
packages/react-noop-renderer/src/createReactNoop.js
+8
-8
@@ -49,7 +49,7 @@ type Props = {
49
top?: null | number,
50
...
51
};
52
-type Instance = {|
52
+type Instance = {
53
type: string,
54
id: number,
55
parent: number,
@@ -58,14 +58,14 @@ type Instance = {|
58
prop: any,
59
hidden: boolean,
60
context: HostContext,
61
-|};
62
-type TextInstance = {|
61
+};
62
+type TextInstance = {
63
text: string,
64
id: number,
65
parent: number,
66
hidden: boolean,
67
context: HostContext,
68
-|};
68
+};
69
type HostContext = Object;
70
type CreateRootOptions = {
71
unstable_transitionCallbacks?: TransitionTracingCallbacks,
@@ -953,14 +953,14 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
953
flushWithHostCounters(
954
fn: () => void,
955
):
956
- | {|
956
+ | {
957
hostDiffCounter: number,
958
hostUpdateCounter: number,
959
- |}
960
- | {|
959
+ }
960
+ | {
961
hostDiffCounter: number,
962
hostCloneCounter: number,
963
- |} {
963
+ } {
964
hostDiffCounter = 0;
965
hostUpdateCounter = 0;
966
hostCloneCounter = 0;
packages/react-pg/src/ReactPostgres.js
+6
-6
@@ -17,20 +17,20 @@ const Pending = 0;
17
const Resolved = 1;
18
const Rejected = 2;
19
20
-type PendingRecord = {|
20
+type PendingRecord = {
21
status: 0,
22
value: Wakeable,
23
-|};
23
+};
24
25
-type ResolvedRecord = {|
25
+type ResolvedRecord = {
26
status: 1,
27
value: mixed,
28
-|};
28
+};
29
30
-type RejectedRecord = {|
30
+type RejectedRecord = {
31
status: 2,
32
value: mixed,
33
-|};
33
+};
34
35
type Record = PendingRecord | ResolvedRecord | RejectedRecord;
36
packages/react-reconciler/src/ReactCapturedValue.js
+2
-2
@@ -11,12 +11,12 @@ import type {Fiber} from './ReactInternalTypes';
11
12
import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack';
13
14
-export type CapturedValue<T> = {|
14
+export type CapturedValue<T> = {
15
value: T,
16
source: Fiber | null,
17
stack: string | null,
18
digest: string | null,
19
-|};
19
+};
20
21
export function createCapturedValueAtFiber<T>(
22
value: T,
packages/react-reconciler/src/ReactFiberCacheComponent.new.js
+6
-6
@@ -36,21 +36,21 @@ const AbortControllerLocal = enableCache
36
}: AbortController)
37
: (null: any);
38
39
-export type Cache = {|
39
+export type Cache = {
40
controller: AbortControllerLocal,
41
data: Map<() => mixed, mixed>,
42
refCount: number,
43
-|};
43
+};
44
45
-export type CacheComponentState = {|
45
+export type CacheComponentState = {
46
+parent: Cache,
47
+cache: Cache,
48
-|};
48
+};
49
50
-export type SpawnedCachePool = {|
50
+export type SpawnedCachePool = {
51
+parent: Cache,
52
+pool: Cache,
53
-|};
53
+};
54
55
// Intentionally not named imports because Rollup would
56
// use dynamic dispatch for CommonJS interop named imports.
packages/react-reconciler/src/ReactFiberCacheComponent.old.js
+6
-6
@@ -36,21 +36,21 @@ const AbortControllerLocal = enableCache
36
}: AbortController)
37
: (null: any);
38
39
-export type Cache = {|
39
+export type Cache = {
40
controller: AbortControllerLocal,
41
data: Map<() => mixed, mixed>,
42
refCount: number,
43
-|};
43
+};
44
45
-export type CacheComponentState = {|
45
+export type CacheComponentState = {
46
+parent: Cache,
47
+cache: Cache,
48
-|};
48
+};
49
50
-export type SpawnedCachePool = {|
50
+export type SpawnedCachePool = {
51
+parent: Cache,
52
+pool: Cache,
53
-|};
53
+};
54
55
// Intentionally not named imports because Rollup would
56
// use dynamic dispatch for CommonJS interop named imports.
packages/react-reconciler/src/ReactFiberClassUpdateQueue.new.js
+6
-6
@@ -125,7 +125,7 @@ import {setIsStrictModeForDevtools} from './ReactFiberDevToolsHook.new';
125
126
import assign from 'shared/assign';
127
128
-export type Update<State> = {|
128
+export type Update<State> = {
129
// TODO: Temporary field. Will remove this by storing a map of
130
// transition -> event time on the root.
131
eventTime: number,
@@ -136,21 +136,21 @@ export type Update<State> = {|
136
callback: (() => mixed) | null,
137
138
next: Update<State> | null,
139
-|};
139
+};
140
141
-export type SharedQueue<State> = {|
141
+export type SharedQueue<State> = {
142
pending: Update<State> | null,
143
lanes: Lanes,
144
hiddenCallbacks: Array<() => mixed> | null,
145
-|};
145
+};
146
147
-export type UpdateQueue<State> = {|
147
+export type UpdateQueue<State> = {
148
baseState: State,
149
firstBaseUpdate: Update<State> | null,
150
lastBaseUpdate: Update<State> | null,
151
shared: SharedQueue<State>,
152
callbacks: Array<() => mixed> | null,
153
-|};
153
+};
154
155
export const UpdateState = 0;
156
export const ReplaceState = 1;
packages/react-reconciler/src/ReactFiberClassUpdateQueue.old.js
+6
-6
@@ -125,7 +125,7 @@ import {setIsStrictModeForDevtools} from './ReactFiberDevToolsHook.old';
125
126
import assign from 'shared/assign';
127
128
-export type Update<State> = {|
128
+export type Update<State> = {
129
// TODO: Temporary field. Will remove this by storing a map of
130
// transition -> event time on the root.
131
eventTime: number,
@@ -136,21 +136,21 @@ export type Update<State> = {|
136
callback: (() => mixed) | null,
137
138
next: Update<State> | null,
139
-|};
139
+};
140
141
-export type SharedQueue<State> = {|
141
+export type SharedQueue<State> = {
142
pending: Update<State> | null,
143
lanes: Lanes,
144
hiddenCallbacks: Array<() => mixed> | null,
145
-|};
145
+};
146
147
-export type UpdateQueue<State> = {|
147
+export type UpdateQueue<State> = {
148
baseState: State,
149
firstBaseUpdate: Update<State> | null,
150
lastBaseUpdate: Update<State> | null,
151
shared: SharedQueue<State>,
152
callbacks: Array<() => mixed> | null,
153
-|};
153
+};
154
155
export const UpdateState = 0;
156
export const ReplaceState = 1;
packages/react-reconciler/src/ReactFiberConcurrentUpdates.new.js
+4
-4
@@ -33,14 +33,14 @@ import {NoFlags, Placement, Hydrating} from './ReactFiberFlags';
33
import {HostRoot, OffscreenComponent} from './ReactWorkTags';
34
import {OffscreenVisible} from './ReactFiberOffscreenComponent';
35
36
-export type ConcurrentUpdate = {|
36
+export type ConcurrentUpdate = {
37
next: ConcurrentUpdate,
38
lane: Lane,
39
-|};
39
+};
40
41
-type ConcurrentQueue = {|
41
+type ConcurrentQueue = {
42
pending: ConcurrentUpdate | null,
43
-|};
43
+};
44
45
// If a render is in progress, and we receive an update from a concurrent event,
46
// we wait until the current render is over (either finished or interrupted)
packages/react-reconciler/src/ReactFiberConcurrentUpdates.old.js
+4
-4
@@ -33,14 +33,14 @@ import {NoFlags, Placement, Hydrating} from './ReactFiberFlags';
33
import {HostRoot, OffscreenComponent} from './ReactWorkTags';
34
import {OffscreenVisible} from './ReactFiberOffscreenComponent';
35
36
-export type ConcurrentUpdate = {|
36
+export type ConcurrentUpdate = {
37
next: ConcurrentUpdate,
38
lane: Lane,
39
-|};
39
+};
40
41
-type ConcurrentQueue = {|
41
+type ConcurrentQueue = {
42
pending: ConcurrentUpdate | null,
43
-|};
43
+};
44
45
// If a render is in progress, and we receive an update from a concurrent event,
46
// we wait until the current render is over (either finished or interrupted)
packages/react-reconciler/src/ReactFiberHooks.new.js
+37
-37
@@ -123,21 +123,21 @@ import {
123
124
const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;
125
126
-export type Update<S, A> = {|
126
+export type Update<S, A> = {
127
lane: Lane,
128
action: A,
129
hasEagerState: boolean,
130
eagerState: S | null,
131
next: Update<S, A>,
132
-|};
132
+};
133
134
-export type UpdateQueue<S, A> = {|
134
+export type UpdateQueue<S, A> = {
135
pending: Update<S, A> | null,
136
lanes: Lanes,
137
dispatch: (A => mixed) | null,
138
lastRenderedReducer: ((S, A) => S) | null,
139
lastRenderedState: S | null,
140
-|};
140
+};
141
142
let didWarnAboutMismatchedHooksForComponent;
143
let didWarnUncachedGetSnapshot;
@@ -145,36 +145,36 @@ if (__DEV__) {
145
didWarnAboutMismatchedHooksForComponent = new Set();
146
}
147
148
-export type Hook = {|
148
+export type Hook = {
149
memoizedState: any,
150
baseState: any,
151
baseQueue: Update<any, any> | null,
152
queue: any,
153
next: Hook | null,
154
-|};
154
+};
155
156
-export type Effect = {|
156
+export type Effect = {
157
tag: HookFlags,
158
create: () => (() => void) | void,
159
destroy: (() => void) | void,
160
deps: Array<mixed> | null,
161
next: Effect,
162
-|};
162
+};
163
164
-type StoreInstance<T> = {|
164
+type StoreInstance<T> = {
165
value: T,
166
getSnapshot: () => T,
167
-|};
167
+};
168
169
-type StoreConsistencyCheck<T> = {|
169
+type StoreConsistencyCheck<T> = {
170
value: T,
171
getSnapshot: () => T,
172
-|};
172
+};
173
174
-export type FunctionComponentUpdateQueue = {|
174
+export type FunctionComponentUpdateQueue = {
175
lastEffect: Effect | null,
176
stores: Array<StoreConsistencyCheck<any>> | null,
177
-|};
177
+};
178
179
type BasicStateAction<S> = (S => S) | S;
180
@@ -1031,14 +1031,14 @@ function rerenderReducer<S, I, A>(
1031
return [newState, dispatch];
1032
}
1033
1034
-type MutableSourceMemoizedState<Source, Snapshot> = {|
1035
- refs: {|
1034
+type MutableSourceMemoizedState<Source, Snapshot> = {
1035
+ refs: {
1036
getSnapshot: MutableSourceGetSnapshotFn<Source, Snapshot>,
1037
setSnapshot: Snapshot => void,
1038
- |},
1038
+ },
1039
source: MutableSource<any>,
1040
subscribe: MutableSourceSubscribeFn<Source, Snapshot>,
1041
-|};
1041
+};
1042
1043
function readFromUnsubscribedMutableSource<Source, Snapshot>(
1044
root: FiberRoot,
@@ -1651,7 +1651,7 @@ function getCallerStackFrame(): string {
1651
: stackFrames.slice(2, 3).join('\n');
1652
}
1653
1654
-function mountRef<T>(initialValue: T): {|current: T|} {
1654
+function mountRef<T>(initialValue: T): {current: T} {
1655
const hook = mountWorkInProgressHook();
1656
if (enableUseRefAccessWarning) {
1657
if (__DEV__) {
@@ -1720,7 +1720,7 @@ function mountRef<T>(initialValue: T): {|current: T|} {
1720
}
1721
}
1722
1723
-function updateRef<T>(initialValue: T): {|current: T|} {
1723
+function updateRef<T>(initialValue: T): {current: T} {
1724
const hook = updateWorkInProgressHook();
1725
return hook.memoizedState;
1726
}
@@ -1814,7 +1814,7 @@ function updateLayoutEffect(
1814
1815
function imperativeHandleEffect<T>(
1816
create: () => T,
1817
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
1817
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
1818
) {
1819
if (typeof ref === 'function') {
1820
const refCallback = ref;
@@ -1843,7 +1843,7 @@ function imperativeHandleEffect<T>(
1843
}
1844
1845
function mountImperativeHandle<T>(
1846
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
1846
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
1847
create: () => T,
1848
deps: Array<mixed> | void | null,
1849
): void {
@@ -1871,7 +1871,7 @@ function mountImperativeHandle<T>(
1871
}
1872
1873
function updateImperativeHandle<T>(
1874
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
1874
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
1875
create: () => T,
1876
deps: Array<mixed> | void | null,
1877
): void {
@@ -2615,7 +2615,7 @@ if (__DEV__) {
2615
return mountEffect(create, deps);
2616
},
2617
useImperativeHandle<T>(
2618
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
2618
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
2619
create: () => T,
2620
deps: Array<mixed> | void | null,
2621
): void {
@@ -2669,7 +2669,7 @@ if (__DEV__) {
2669
ReactCurrentDispatcher.current = prevDispatcher;
2670
}
2671
},
2672
- useRef<T>(initialValue: T): {|current: T|} {
2672
+ useRef<T>(initialValue: T): {current: T} {
2673
currentHookNameInDev = 'useRef';
2674
mountHookTypesDev();
2675
return mountRef(initialValue);
@@ -2767,7 +2767,7 @@ if (__DEV__) {
2767
return mountEffect(create, deps);
2768
},
2769
useImperativeHandle<T>(
2770
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
2770
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
2771
create: () => T,
2772
deps: Array<mixed> | void | null,
2773
): void {
@@ -2817,7 +2817,7 @@ if (__DEV__) {
2817
ReactCurrentDispatcher.current = prevDispatcher;
2818
}
2819
},
2820
- useRef<T>(initialValue: T): {|current: T|} {
2820
+ useRef<T>(initialValue: T): {current: T} {
2821
currentHookNameInDev = 'useRef';
2822
updateHookTypesDev();
2823
return mountRef(initialValue);
@@ -2915,7 +2915,7 @@ if (__DEV__) {
2915
return updateEffect(create, deps);
2916
},
2917
useImperativeHandle<T>(
2918
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
2918
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
2919
create: () => T,
2920
deps: Array<mixed> | void | null,
2921
): void {
@@ -2965,7 +2965,7 @@ if (__DEV__) {
2965
ReactCurrentDispatcher.current = prevDispatcher;
2966
}
2967
},
2968
- useRef<T>(initialValue: T): {|current: T|} {
2968
+ useRef<T>(initialValue: T): {current: T} {
2969
currentHookNameInDev = 'useRef';
2970
updateHookTypesDev();
2971
return updateRef(initialValue);
@@ -3064,7 +3064,7 @@ if (__DEV__) {
3064
return updateEffect(create, deps);
3065
},
3066
useImperativeHandle<T>(
3067
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3067
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3068
create: () => T,
3069
deps: Array<mixed> | void | null,
3070
): void {
@@ -3114,7 +3114,7 @@ if (__DEV__) {
3114
ReactCurrentDispatcher.current = prevDispatcher;
3115
}
3116
},
3117
- useRef<T>(initialValue: T): {|current: T|} {
3117
+ useRef<T>(initialValue: T): {current: T} {
3118
currentHookNameInDev = 'useRef';
3119
updateHookTypesDev();
3120
return updateRef(initialValue);
@@ -3216,7 +3216,7 @@ if (__DEV__) {
3216
return mountEffect(create, deps);
3217
},
3218
useImperativeHandle<T>(
3219
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3219
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3220
create: () => T,
3221
deps: Array<mixed> | void | null,
3222
): void {
@@ -3271,7 +3271,7 @@ if (__DEV__) {
3271
ReactCurrentDispatcher.current = prevDispatcher;
3272
}
3273
},
3274
- useRef<T>(initialValue: T): {|current: T|} {
3274
+ useRef<T>(initialValue: T): {current: T} {
3275
currentHookNameInDev = 'useRef';
3276
warnInvalidHookAccess();
3277
mountHookTypesDev();
@@ -3391,7 +3391,7 @@ if (__DEV__) {
3391
return updateEffect(create, deps);
3392
},
3393
useImperativeHandle<T>(
3394
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3394
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3395
create: () => T,
3396
deps: Array<mixed> | void | null,
3397
): void {
@@ -3446,7 +3446,7 @@ if (__DEV__) {
3446
ReactCurrentDispatcher.current = prevDispatcher;
3447
}
3448
},
3449
- useRef<T>(initialValue: T): {|current: T|} {
3449
+ useRef<T>(initialValue: T): {current: T} {
3450
currentHookNameInDev = 'useRef';
3451
warnInvalidHookAccess();
3452
updateHookTypesDev();
@@ -3567,7 +3567,7 @@ if (__DEV__) {
3567
return updateEffect(create, deps);
3568
},
3569
useImperativeHandle<T>(
3570
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3570
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3571
create: () => T,
3572
deps: Array<mixed> | void | null,
3573
): void {
@@ -3622,7 +3622,7 @@ if (__DEV__) {
3622
ReactCurrentDispatcher.current = prevDispatcher;
3623
}
3624
},
3625
- useRef<T>(initialValue: T): {|current: T|} {
3625
+ useRef<T>(initialValue: T): {current: T} {
3626
currentHookNameInDev = 'useRef';
3627
warnInvalidHookAccess();
3628
updateHookTypesDev();
packages/react-reconciler/src/ReactFiberHooks.old.js
+37
-37
@@ -123,21 +123,21 @@ import {
123
124
const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;
125
126
-export type Update<S, A> = {|
126
+export type Update<S, A> = {
127
lane: Lane,
128
action: A,
129
hasEagerState: boolean,
130
eagerState: S | null,
131
next: Update<S, A>,
132
-|};
132
+};
133
134
-export type UpdateQueue<S, A> = {|
134
+export type UpdateQueue<S, A> = {
135
pending: Update<S, A> | null,
136
lanes: Lanes,
137
dispatch: (A => mixed) | null,
138
lastRenderedReducer: ((S, A) => S) | null,
139
lastRenderedState: S | null,
140
-|};
140
+};
141
142
let didWarnAboutMismatchedHooksForComponent;
143
let didWarnUncachedGetSnapshot;
@@ -145,36 +145,36 @@ if (__DEV__) {
145
didWarnAboutMismatchedHooksForComponent = new Set();
146
}
147
148
-export type Hook = {|
148
+export type Hook = {
149
memoizedState: any,
150
baseState: any,
151
baseQueue: Update<any, any> | null,
152
queue: any,
153
next: Hook | null,
154
-|};
154
+};
155
156
-export type Effect = {|
156
+export type Effect = {
157
tag: HookFlags,
158
create: () => (() => void) | void,
159
destroy: (() => void) | void,
160
deps: Array<mixed> | null,
161
next: Effect,
162
-|};
162
+};
163
164
-type StoreInstance<T> = {|
164
+type StoreInstance<T> = {
165
value: T,
166
getSnapshot: () => T,
167
-|};
167
+};
168
169
-type StoreConsistencyCheck<T> = {|
169
+type StoreConsistencyCheck<T> = {
170
value: T,
171
getSnapshot: () => T,
172
-|};
172
+};
173
174
-export type FunctionComponentUpdateQueue = {|
174
+export type FunctionComponentUpdateQueue = {
175
lastEffect: Effect | null,
176
stores: Array<StoreConsistencyCheck<any>> | null,
177
-|};
177
+};
178
179
type BasicStateAction<S> = (S => S) | S;
180
@@ -1031,14 +1031,14 @@ function rerenderReducer<S, I, A>(
1031
return [newState, dispatch];
1032
}
1033
1034
-type MutableSourceMemoizedState<Source, Snapshot> = {|
1035
- refs: {|
1034
+type MutableSourceMemoizedState<Source, Snapshot> = {
1035
+ refs: {
1036
getSnapshot: MutableSourceGetSnapshotFn<Source, Snapshot>,
1037
setSnapshot: Snapshot => void,
1038
- |},
1038
+ },
1039
source: MutableSource<any>,
1040
subscribe: MutableSourceSubscribeFn<Source, Snapshot>,
1041
-|};
1041
+};
1042
1043
function readFromUnsubscribedMutableSource<Source, Snapshot>(
1044
root: FiberRoot,
@@ -1651,7 +1651,7 @@ function getCallerStackFrame(): string {
1651
: stackFrames.slice(2, 3).join('\n');
1652
}
1653
1654
-function mountRef<T>(initialValue: T): {|current: T|} {
1654
+function mountRef<T>(initialValue: T): {current: T} {
1655
const hook = mountWorkInProgressHook();
1656
if (enableUseRefAccessWarning) {
1657
if (__DEV__) {
@@ -1720,7 +1720,7 @@ function mountRef<T>(initialValue: T): {|current: T|} {
1720
}
1721
}
1722
1723
-function updateRef<T>(initialValue: T): {|current: T|} {
1723
+function updateRef<T>(initialValue: T): {current: T} {
1724
const hook = updateWorkInProgressHook();
1725
return hook.memoizedState;
1726
}
@@ -1814,7 +1814,7 @@ function updateLayoutEffect(
1814
1815
function imperativeHandleEffect<T>(
1816
create: () => T,
1817
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
1817
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
1818
) {
1819
if (typeof ref === 'function') {
1820
const refCallback = ref;
@@ -1843,7 +1843,7 @@ function imperativeHandleEffect<T>(
1843
}
1844
1845
function mountImperativeHandle<T>(
1846
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
1846
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
1847
create: () => T,
1848
deps: Array<mixed> | void | null,
1849
): void {
@@ -1871,7 +1871,7 @@ function mountImperativeHandle<T>(
1871
}
1872
1873
function updateImperativeHandle<T>(
1874
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
1874
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
1875
create: () => T,
1876
deps: Array<mixed> | void | null,
1877
): void {
@@ -2615,7 +2615,7 @@ if (__DEV__) {
2615
return mountEffect(create, deps);
2616
},
2617
useImperativeHandle<T>(
2618
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
2618
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
2619
create: () => T,
2620
deps: Array<mixed> | void | null,
2621
): void {
@@ -2669,7 +2669,7 @@ if (__DEV__) {
2669
ReactCurrentDispatcher.current = prevDispatcher;
2670
}
2671
},
2672
- useRef<T>(initialValue: T): {|current: T|} {
2672
+ useRef<T>(initialValue: T): {current: T} {
2673
currentHookNameInDev = 'useRef';
2674
mountHookTypesDev();
2675
return mountRef(initialValue);
@@ -2767,7 +2767,7 @@ if (__DEV__) {
2767
return mountEffect(create, deps);
2768
},
2769
useImperativeHandle<T>(
2770
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
2770
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
2771
create: () => T,
2772
deps: Array<mixed> | void | null,
2773
): void {
@@ -2817,7 +2817,7 @@ if (__DEV__) {
2817
ReactCurrentDispatcher.current = prevDispatcher;
2818
}
2819
},
2820
- useRef<T>(initialValue: T): {|current: T|} {
2820
+ useRef<T>(initialValue: T): {current: T} {
2821
currentHookNameInDev = 'useRef';
2822
updateHookTypesDev();
2823
return mountRef(initialValue);
@@ -2915,7 +2915,7 @@ if (__DEV__) {
2915
return updateEffect(create, deps);
2916
},
2917
useImperativeHandle<T>(
2918
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
2918
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
2919
create: () => T,
2920
deps: Array<mixed> | void | null,
2921
): void {
@@ -2965,7 +2965,7 @@ if (__DEV__) {
2965
ReactCurrentDispatcher.current = prevDispatcher;
2966
}
2967
},
2968
- useRef<T>(initialValue: T): {|current: T|} {
2968
+ useRef<T>(initialValue: T): {current: T} {
2969
currentHookNameInDev = 'useRef';
2970
updateHookTypesDev();
2971
return updateRef(initialValue);
@@ -3064,7 +3064,7 @@ if (__DEV__) {
3064
return updateEffect(create, deps);
3065
},
3066
useImperativeHandle<T>(
3067
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3067
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3068
create: () => T,
3069
deps: Array<mixed> | void | null,
3070
): void {
@@ -3114,7 +3114,7 @@ if (__DEV__) {
3114
ReactCurrentDispatcher.current = prevDispatcher;
3115
}
3116
},
3117
- useRef<T>(initialValue: T): {|current: T|} {
3117
+ useRef<T>(initialValue: T): {current: T} {
3118
currentHookNameInDev = 'useRef';
3119
updateHookTypesDev();
3120
return updateRef(initialValue);
@@ -3216,7 +3216,7 @@ if (__DEV__) {
3216
return mountEffect(create, deps);
3217
},
3218
useImperativeHandle<T>(
3219
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3219
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3220
create: () => T,
3221
deps: Array<mixed> | void | null,
3222
): void {
@@ -3271,7 +3271,7 @@ if (__DEV__) {
3271
ReactCurrentDispatcher.current = prevDispatcher;
3272
}
3273
},
3274
- useRef<T>(initialValue: T): {|current: T|} {
3274
+ useRef<T>(initialValue: T): {current: T} {
3275
currentHookNameInDev = 'useRef';
3276
warnInvalidHookAccess();
3277
mountHookTypesDev();
@@ -3391,7 +3391,7 @@ if (__DEV__) {
3391
return updateEffect(create, deps);
3392
},
3393
useImperativeHandle<T>(
3394
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3394
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3395
create: () => T,
3396
deps: Array<mixed> | void | null,
3397
): void {
@@ -3446,7 +3446,7 @@ if (__DEV__) {
3446
ReactCurrentDispatcher.current = prevDispatcher;
3447
}
3448
},
3449
- useRef<T>(initialValue: T): {|current: T|} {
3449
+ useRef<T>(initialValue: T): {current: T} {
3450
currentHookNameInDev = 'useRef';
3451
warnInvalidHookAccess();
3452
updateHookTypesDev();
@@ -3567,7 +3567,7 @@ if (__DEV__) {
3567
return updateEffect(create, deps);
3568
},
3569
useImperativeHandle<T>(
3570
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
3570
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
3571
create: () => T,
3572
deps: Array<mixed> | void | null,
3573
): void {
@@ -3622,7 +3622,7 @@ if (__DEV__) {
3622
ReactCurrentDispatcher.current = prevDispatcher;
3623
}
3624
},
3625
- useRef<T>(initialValue: T): {|current: T|} {
3625
+ useRef<T>(initialValue: T): {current: T} {
3626
currentHookNameInDev = 'useRef';
3627
warnInvalidHookAccess();
3628
updateHookTypesDev();
packages/react-reconciler/src/ReactFiberHotReloading.new.js
+4
-4
@@ -40,14 +40,14 @@ import {
40
REACT_LAZY_TYPE,
41
} from 'shared/ReactSymbols';
42
43
-export type Family = {|
43
+export type Family = {
44
current: any,
45
-|};
45
+};
46
47
-export type RefreshUpdate = {|
47
+export type RefreshUpdate = {
48
staleFamilies: Set<Family>,
49
updatedFamilies: Set<Family>,
50
-|};
50
+};
51
52
// Resolves type to a family.
53
type RefreshHandler = any => Family | void;
packages/react-reconciler/src/ReactFiberHotReloading.old.js
+4
-4
@@ -40,14 +40,14 @@ import {
40
REACT_LAZY_TYPE,
41
} from 'shared/ReactSymbols';
42
43
-export type Family = {|
43
+export type Family = {
44
current: any,
45
-|};
45
+};
46
47
-export type RefreshUpdate = {|
47
+export type RefreshUpdate = {
48
staleFamilies: Set<Family>,
49
updatedFamilies: Set<Family>,
50
-|};
50
+};
51
52
// Resolves type to a family.
53
type RefreshHandler = any => Family | void;
packages/react-reconciler/src/ReactFiberOffscreenComponent.js
+8
-8
@@ -15,7 +15,7 @@ import type {
15
TracingMarkerInstance,
16
} from './ReactFiberTracingMarkerComponent.new';
17
18
-export type OffscreenProps = {|
18
+export type OffscreenProps = {
19
// TODO: Pick an API before exposing the Offscreen type. I've chosen an enum
20
// for now, since we might have multiple variants. For example, hiding the
21
// content without changing the layout.
@@ -24,32 +24,32 @@ export type OffscreenProps = {|
24
// called "Offscreen." Possible alt: <Visibility />?
25
mode?: OffscreenMode | null | void,
26
children?: ReactNodeList,
27
-|};
27
+};
28
29
// We use the existence of the state object as an indicator that the component
30
// is hidden.
31
-export type OffscreenState = {|
31
+export type OffscreenState = {
32
// TODO: This doesn't do anything, yet. It's always NoLanes. But eventually it
33
// will represent the pending work that must be included in the render in
34
// order to unhide the component.
35
baseLanes: Lanes,
36
cachePool: SpawnedCachePool | null,
37
-|};
37
+};
38
39
-export type OffscreenQueue = {|
39
+export type OffscreenQueue = {
40
transitions: Array<Transition> | null,
41
markerInstances: Array<TracingMarkerInstance> | null,
42
wakeables: Set<Wakeable> | null,
43
-|};
43
+};
44
45
type OffscreenVisibility = number;
46
47
export const OffscreenVisible = /* */ 0b01;
48
export const OffscreenPassiveEffectsConnected = /* */ 0b10;
49
50
-export type OffscreenInstance = {|
50
+export type OffscreenInstance = {
51
visibility: OffscreenVisibility,
52
pendingMarkers: Set<TracingMarkerInstance> | null,
53
transitions: Set<Transition> | null,
54
retryCache: WeakSet<Wakeable> | Set<Wakeable> | null,
55
-|};
55
+};
packages/react-reconciler/src/ReactFiberReconciler.new.js
+2
-2
@@ -120,7 +120,7 @@ type OpaqueRoot = FiberRoot;
120
// Might add PROFILE later.
121
type BundleType = 0 | 1;
122
123
-type DevToolsConfig = {|
123
+type DevToolsConfig = {
124
bundleType: BundleType,
125
version: string,
126
rendererPackageName: string,
@@ -128,7 +128,7 @@ type DevToolsConfig = {|
128
// Used by "inspect clicked DOM element" in React DevTools.
129
findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null,
130
rendererConfig?: RendererInspectionConfig,
131
-|};
131
+};
132
133
let didWarnAboutNestedUpdates;
134
let didWarnAboutFindNodeInStrictMode;
packages/react-reconciler/src/ReactFiberReconciler.old.js
+2
-2
@@ -120,7 +120,7 @@ type OpaqueRoot = FiberRoot;
120
// Might add PROFILE later.
121
type BundleType = 0 | 1;
122
123
-type DevToolsConfig = {|
123
+type DevToolsConfig = {
124
bundleType: BundleType,
125
version: string,
126
rendererPackageName: string,
@@ -128,7 +128,7 @@ type DevToolsConfig = {|
128
// Used by "inspect clicked DOM element" in React DevTools.
129
findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null,
130
rendererConfig?: RendererInspectionConfig,
131
-|};
131
+};
132
133
let didWarnAboutNestedUpdates;
134
let didWarnAboutFindNodeInStrictMode;
packages/react-reconciler/src/ReactFiberRoot.new.js
+2
-2
@@ -38,11 +38,11 @@ import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue.new';
38
import {LegacyRoot, ConcurrentRoot} from './ReactRootTags';
39
import {createCache, retainCache} from './ReactFiberCacheComponent.new';
40
41
-export type RootState = {|
41
+export type RootState = {
42
element: any,
43
isDehydrated: boolean,
44
cache: Cache,
45
-|};
45
+};
46
47
function FiberRootNode(
48
containerInfo,
packages/react-reconciler/src/ReactFiberRoot.old.js
+2
-2
@@ -38,11 +38,11 @@ import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue.old';
38
import {LegacyRoot, ConcurrentRoot} from './ReactRootTags';
39
import {createCache, retainCache} from './ReactFiberCacheComponent.old';
40
41
-export type RootState = {|
41
+export type RootState = {
42
element: any,
43
isDehydrated: boolean,
44
cache: Cache,
45
-|};
45
+};
46
47
function FiberRootNode(
48
containerInfo,
packages/react-reconciler/src/ReactFiberStack.new.js
+1
-1
@@ -9,7 +9,7 @@
9
10
import type {Fiber} from './ReactInternalTypes';
11
12
-export type StackCursor<T> = {|current: T|};
12
+export type StackCursor<T> = {current: T};
13
14
const valueStack: Array<any> = [];
15
packages/react-reconciler/src/ReactFiberStack.old.js
+1
-1
@@ -9,7 +9,7 @@
9
10
import type {Fiber} from './ReactInternalTypes';
11
12
-export type StackCursor<T> = {|current: T|};
12
+export type StackCursor<T> = {current: T};
13
14
const valueStack: Array<any> = [];
15
packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js
+6
-6
@@ -20,7 +20,7 @@ import {
20
isSuspenseInstanceFallback,
21
} from './ReactFiberHostConfig';
22
23
-export type SuspenseProps = {|
23
+export type SuspenseProps = {
24
children?: ReactNodeList,
25
fallback?: ReactNodeList,
26
@@ -29,7 +29,7 @@ export type SuspenseProps = {|
29
30
unstable_expectedLoadTime?: number,
31
unstable_name?: string,
32
-|};
32
+};
33
34
// A null SuspenseState represents an unsuspended normal Suspense boundary.
35
// A non-null SuspenseState means that it is blocked for one reason or another.
@@ -38,7 +38,7 @@ export type SuspenseProps = {|
38
// isSuspenseInstanceFallback to query the reason for being dehydrated.
39
// - A null dehydrated field means it's blocked by something suspending and
40
// we're currently showing a fallback instead.
41
-export type SuspenseState = {|
41
+export type SuspenseState = {
42
// If this boundary is still dehydrated, we store the SuspenseInstance
43
// here to indicate that it is dehydrated (flag) and for quick access
44
// to check things like isSuspenseInstancePending.
@@ -48,11 +48,11 @@ export type SuspenseState = {|
48
// OffscreenLane is the default for dehydrated boundaries.
49
// NoLane is the default for normal boundaries, which turns into "normal" pri.
50
retryLane: Lane,
51
-|};
51
+};
52
53
export type SuspenseListTailMode = 'collapsed' | 'hidden' | void;
54
55
-export type SuspenseListRenderState = {|
55
+export type SuspenseListRenderState = {
56
isBackwards: boolean,
57
// The currently rendering tail row.
58
rendering: null | Fiber,
@@ -64,7 +64,7 @@ export type SuspenseListRenderState = {|
64
tail: null | Fiber,
65
// Tail insertions setting.
66
tailMode: SuspenseListTailMode,
67
-|};
67
+};
68
69
export function findFirstSuspended(row: Fiber): null | Fiber {
70
let node = row;
packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js
+6
-6
@@ -20,7 +20,7 @@ import {
20
isSuspenseInstanceFallback,
21
} from './ReactFiberHostConfig';
22
23
-export type SuspenseProps = {|
23
+export type SuspenseProps = {
24
children?: ReactNodeList,
25
fallback?: ReactNodeList,
26
@@ -29,7 +29,7 @@ export type SuspenseProps = {|
29
30
unstable_expectedLoadTime?: number,
31
unstable_name?: string,
32
-|};
32
+};
33
34
// A null SuspenseState represents an unsuspended normal Suspense boundary.
35
// A non-null SuspenseState means that it is blocked for one reason or another.
@@ -38,7 +38,7 @@ export type SuspenseProps = {|
38
// isSuspenseInstanceFallback to query the reason for being dehydrated.
39
// - A null dehydrated field means it's blocked by something suspending and
40
// we're currently showing a fallback instead.
41
-export type SuspenseState = {|
41
+export type SuspenseState = {
42
// If this boundary is still dehydrated, we store the SuspenseInstance
43
// here to indicate that it is dehydrated (flag) and for quick access
44
// to check things like isSuspenseInstancePending.
@@ -48,11 +48,11 @@ export type SuspenseState = {|
48
// OffscreenLane is the default for dehydrated boundaries.
49
// NoLane is the default for normal boundaries, which turns into "normal" pri.
50
retryLane: Lane,
51
-|};
51
+};
52
53
export type SuspenseListTailMode = 'collapsed' | 'hidden' | void;
54
55
-export type SuspenseListRenderState = {|
55
+export type SuspenseListRenderState = {
56
isBackwards: boolean,
57
// The currently rendering tail row.
58
rendering: null | Fiber,
@@ -64,7 +64,7 @@ export type SuspenseListRenderState = {|
64
tail: null | Fiber,
65
// Tail insertions setting.
66
tailMode: SuspenseListTailMode,
67
-|};
67
+};
68
69
export function findFirstSuspended(row: Fiber): null | Fiber {
70
let node = row;
packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js
+13
-13
@@ -19,47 +19,47 @@ import {enableTransitionTracing} from 'shared/ReactFeatureFlags';
19
import {createCursor, push, pop} from './ReactFiberStack.new';
20
import {getWorkInProgressTransitions} from './ReactFiberWorkLoop.new';
21
22
-export type SuspenseInfo = {|name: string | null|};
22
+export type SuspenseInfo = {name: string | null};
23
24
-export type PendingTransitionCallbacks = {|
24
+export type PendingTransitionCallbacks = {
25
transitionStart: Array<Transition> | null,
26
transitionProgress: Map<Transition, PendingBoundaries> | null,
27
transitionComplete: Array<Transition> | null,
28
markerProgress: Map<
29
string,
30
- {|pendingBoundaries: PendingBoundaries, transitions: Set<Transition>|},
30
+ {pendingBoundaries: PendingBoundaries, transitions: Set<Transition>},
31
> | null,
32
markerIncomplete: Map<
33
string,
34
- {|aborts: Array<TransitionAbort>, transitions: Set<Transition>|},
34
+ {aborts: Array<TransitionAbort>, transitions: Set<Transition>},
35
> | null,
36
markerComplete: Map<string, Set<Transition>> | null,
37
-|};
37
+};
38
39
-export type Transition = {|
39
+export type Transition = {
40
name: string,
41
startTime: number,
42
-|};
42
+};
43
44
-export type BatchConfigTransition = {|
44
+export type BatchConfigTransition = {
45
name?: string,
46
startTime?: number,
47
_updatedFibers?: Set<Fiber>,
48
-|};
48
+};
49
50
// TODO: Is there a way to not include the tag or name here?
51
-export type TracingMarkerInstance = {|
51
+export type TracingMarkerInstance = {
52
tag?: TracingMarkerTag,
53
transitions: Set<Transition> | null,
54
pendingBoundaries: PendingBoundaries | null,
55
aborts: Array<TransitionAbort> | null,
56
name: string | null,
57
-|};
57
+};
58
59
-export type TransitionAbort = {|
59
+export type TransitionAbort = {
60
reason: 'error' | 'unknown' | 'marker' | 'suspense',
61
name?: string | null,
62
-|};
62
+};
63
64
export const TransitionRoot = 0;
65
export const TransitionTracingMarker = 1;
packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js
+13
-13
@@ -19,47 +19,47 @@ import {enableTransitionTracing} from 'shared/ReactFeatureFlags';
19
import {createCursor, push, pop} from './ReactFiberStack.old';
20
import {getWorkInProgressTransitions} from './ReactFiberWorkLoop.old';
21
22
-export type SuspenseInfo = {|name: string | null|};
22
+export type SuspenseInfo = {name: string | null};
23
24
-export type PendingTransitionCallbacks = {|
24
+export type PendingTransitionCallbacks = {
25
transitionStart: Array<Transition> | null,
26
transitionProgress: Map<Transition, PendingBoundaries> | null,
27
transitionComplete: Array<Transition> | null,
28
markerProgress: Map<
29
string,
30
- {|pendingBoundaries: PendingBoundaries, transitions: Set<Transition>|},
30
+ {pendingBoundaries: PendingBoundaries, transitions: Set<Transition>},
31
> | null,
32
markerIncomplete: Map<
33
string,
34
- {|aborts: Array<TransitionAbort>, transitions: Set<Transition>|},
34
+ {aborts: Array<TransitionAbort>, transitions: Set<Transition>},
35
> | null,
36
markerComplete: Map<string, Set<Transition>> | null,
37
-|};
37
+};
38
39
-export type Transition = {|
39
+export type Transition = {
40
name: string,
41
startTime: number,
42
-|};
42
+};
43
44
-export type BatchConfigTransition = {|
44
+export type BatchConfigTransition = {
45
name?: string,
46
startTime?: number,
47
_updatedFibers?: Set<Fiber>,
48
-|};
48
+};
49
50
// TODO: Is there a way to not include the tag or name here?
51
-export type TracingMarkerInstance = {|
51
+export type TracingMarkerInstance = {
52
tag?: TracingMarkerTag,
53
transitions: Set<Transition> | null,
54
pendingBoundaries: PendingBoundaries | null,
55
aborts: Array<TransitionAbort> | null,
56
name: string | null,
57
-|};
57
+};
58
59
-export type TransitionAbort = {|
59
+export type TransitionAbort = {
60
reason: 'error' | 'unknown' | 'marker' | 'suspense',
61
name?: string | null,
62
-|};
62
+};
63
64
export const TransitionRoot = 0;
65
export const TransitionTracingMarker = 1;
packages/react-reconciler/src/ReactFiberTreeContext.new.js
+2
-2
@@ -64,10 +64,10 @@ import {getIsHydrating} from './ReactFiberHydrationContext.new';
64
import {clz32} from './clz32';
65
import {Forked, NoFlags} from './ReactFiberFlags';
66
67
-export type TreeContext = {|
67
+export type TreeContext = {
68
id: number,
69
overflow: string,
70
-|};
70
+};
71
72
// TODO: Use the unified fiber stack module instead of this local one?
73
// Intentionally not using it yet to derisk the initial implementation, because
packages/react-reconciler/src/ReactFiberTreeContext.old.js
+2
-2
@@ -64,10 +64,10 @@ import {getIsHydrating} from './ReactFiberHydrationContext.old';
64
import {clz32} from './clz32';
65
import {Forked, NoFlags} from './ReactFiberFlags';
66
67
-export type TreeContext = {|
67
+export type TreeContext = {
68
id: number,
69
overflow: string,
70
-|};
70
+};
71
72
// TODO: Use the unified fiber stack module instead of this local one?
73
// Intentionally not using it yet to derisk the initial implementation, because
packages/react-reconciler/src/ReactInternalTypes.js
+23
-23
@@ -70,7 +70,7 @@ export type Dependencies = {
70
71
// A Fiber is work on a Component that needs to be done or was done. There can
72
// be more than one per component.
73
-export type Fiber = {|
73
+export type Fiber = {
74
// These first fields are conceptually members of an Instance. This used to
75
// be split into a separate type and intersected with the other Fiber fields,
76
// but until Flow fixes its intersection bugs, we've merged them into a
@@ -197,9 +197,9 @@ export type Fiber = {|
197
198
// Used to verify that the order of hooks does not change between renders.
199
_debugHookTypes?: Array<HookType> | null,
200
-|};
200
+};
201
202
-type BaseFiberRootProperties = {|
202
+type BaseFiberRootProperties = {
203
// The type of root (legacy, batched, concurrent, etc.)
204
tag: RootTag,
205
@@ -258,16 +258,16 @@ type BaseFiberRootProperties = {|
258
259
onRecoverableError: (
260
error: mixed,
261
- errorInfo: {|digest?: ?string, componentStack?: ?string|},
261
+ errorInfo: {digest?: ?string, componentStack?: ?string},
262
) => void,
263
-|};
263
+};
264
265
// The following attributes are only used by DevTools and are only present in DEV builds.
266
// They enable DevTools Profiler UI to show which Fiber(s) scheduled a given commit.
267
-type UpdaterTrackingOnlyFiberRootProperties = {|
267
+type UpdaterTrackingOnlyFiberRootProperties = {
268
memoizedUpdaters: Set<Fiber>,
269
pendingUpdatersLaneMap: LaneMap<Set<Fiber>>,
270
-|};
270
+};
271
272
export type SuspenseHydrationCallbacks = {
273
onHydrated?: (suspenseInstance: SuspenseInstance) => void,
@@ -276,26 +276,26 @@ export type SuspenseHydrationCallbacks = {
276
};
277
278
// The follow fields are only used by enableSuspenseCallback for hydration.
279
-type SuspenseCallbackOnlyFiberRootProperties = {|
279
+type SuspenseCallbackOnlyFiberRootProperties = {
280
hydrationCallbacks: null | SuspenseHydrationCallbacks,
281
-|};
281
+};
282
283
-export type TransitionTracingCallbacks = {|
283
+export type TransitionTracingCallbacks = {
284
onTransitionStart?: (transitionName: string, startTime: number) => void,
285
onTransitionProgress?: (
286
transitionName: string,
287
startTime: number,
288
currentTime: number,
289
- pending: Array<{|name: null | string|}>,
289
+ pending: Array<{name: null | string}>,
290
) => void,
291
onTransitionIncomplete?: (
292
transitionName: string,
293
startTime: number,
294
- deletions: Array<{|
294
+ deletions: Array<{
295
type: string,
296
name?: string | null,
297
endTime: number,
298
- |}>,
298
+ }>,
299
) => void,
300
onTransitionComplete?: (
301
transitionName: string,
@@ -307,17 +307,17 @@ export type TransitionTracingCallbacks = {|
307
marker: string,
308
startTime: number,
309
currentTime: number,
310
- pending: Array<{|name: null | string|}>,
310
+ pending: Array<{name: null | string}>,
311
) => void,
312
onMarkerIncomplete?: (
313
transitionName: string,
314
marker: string,
315
startTime: number,
316
- deletions: Array<{|
316
+ deletions: Array<{
317
type: string,
318
name?: string | null,
319
endTime: number,
320
- |}>,
320
+ }>,
321
) => void,
322
onMarkerComplete?: (
323
transitionName: string,
@@ -325,10 +325,10 @@ export type TransitionTracingCallbacks = {|
325
startTime: number,
326
endTime: number,
327
) => void,
328
-|};
328
+};
329
330
// The following fields are only used in transition tracing in Profile builds
331
-type TransitionTracingOnlyFiberRootProperties = {|
331
+type TransitionTracingOnlyFiberRootProperties = {
332
transitionCallbacks: null | TransitionTracingCallbacks,
333
transitionLanes: Array<Set<Transition> | null>,
334
// Transitions on the root can be represented as a bunch of tracing markers.
@@ -338,7 +338,7 @@ type TransitionTracingOnlyFiberRootProperties = {|
338
// empty. We can represent this as a Map of transitions to suspense
339
// boundary sets
340
incompleteTransitions: Map<Transition, TracingMarkerInstance>,
341
-|};
341
+};
342
343
// Exported FiberRoot type includes all properties,
344
// To avoid requiring potentially error-prone :any casts throughout the project.
@@ -354,7 +354,7 @@ export type FiberRoot = {
354
type BasicStateAction<S> = (S => S) | S;
355
type Dispatch<A> = A => void;
356
357
-export type Dispatcher = {|
357
+export type Dispatcher = {
358
use?: <T>(Usable<T>) => T,
359
getCacheSignal?: () => AbortSignal,
360
getCacheForType?: <T>(resourceType: () => T) => T,
@@ -366,7 +366,7 @@ export type Dispatcher = {|
366
init?: (I) => S,
367
): [S, Dispatch<A>],
368
useContext<T>(context: ReactContext<T>): T,
369
- useRef<T>(initialValue: T): {|current: T|},
369
+ useRef<T>(initialValue: T): {current: T},
370
useEffect(
371
create: () => (() => void) | void,
372
deps: Array<mixed> | void | null,
@@ -382,7 +382,7 @@ export type Dispatcher = {|
382
useCallback<T>(callback: T, deps: Array<mixed> | void | null): T,
383
useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T,
384
useImperativeHandle<T>(
385
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
385
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
386
create: () => T,
387
deps: Array<mixed> | void | null,
388
): void,
@@ -407,4 +407,4 @@ export type Dispatcher = {|
407
useMemoCache?: (size: number) => Array<any>,
408
409
unstable_isNewReconciler?: boolean,
410
-|};
410
+};
packages/react-reconciler/src/ReactTestSelectors.js
+15
-17
@@ -41,30 +41,30 @@ if (typeof Symbol === 'function' && Symbol.for) {
41
42
type Type = symbol | number;
43
44
-type ComponentSelector = {|
44
+type ComponentSelector = {
45
$$typeof: Type,
46
value: React$AbstractComponent<empty, mixed>,
47
-|};
47
+};
48
49
-type HasPseudoClassSelector = {|
49
+type HasPseudoClassSelector = {
50
$$typeof: Type,
51
value: Array<Selector>,
52
-|};
52
+};
53
54
-type RoleSelector = {|
54
+type RoleSelector = {
55
$$typeof: Type,
56
value: string,
57
-|};
57
+};
58
59
-type TextSelector = {|
59
+type TextSelector = {
60
$$typeof: Type,
61
value: string,
62
-|};
62
+};
63
64
-type TestNameSelector = {|
64
+type TestNameSelector = {
65
$$typeof: Type,
66
value: string,
67
-|};
67
+};
68
69
type Selector =
70
| ComponentSelector
@@ -364,12 +364,12 @@ export function getFindAllNodesFailureDescription(
364
return null;
365
}
366
367
-export type BoundingRect = {|
367
+export type BoundingRect = {
368
x: number,
369
y: number,
370
width: number,
371
height: number,
372
-|};
372
+};
373
374
export function findBoundingRects(
375
hostRoot: Instance,
@@ -506,17 +506,15 @@ export function onCommitRoot(): void {
506
export type IntersectionObserverOptions = Object;
507
508
export type ObserveVisibleRectsCallback = (
509
- intersections: Array<{|ratio: number, rect: BoundingRect|}>,
509
+ intersections: Array<{ratio: number, rect: BoundingRect}>,
510
) => void;
511
512
export function observeVisibleRects(
513
hostRoot: Instance,
514
selectors: Array<Selector>,
515
- callback: (
516
- intersections: Array<{|ratio: number, rect: BoundingRect|}>,
517
- ) => void,
515
+ callback: (intersections: Array<{ratio: number, rect: BoundingRect}>) => void,
516
options?: IntersectionObserverOptions,
519
-): {|disconnect: () => void|} {
517
+): {disconnect: () => void} {
518
if (!supportsTestSelectors) {
519
throw new Error('Test selector API is not supported by this renderer.');
520
}
packages/react-refresh/src/ReactFreshRuntime.js
+4
-4
@@ -21,19 +21,19 @@ import type {ReactNodeList} from 'shared/ReactTypes';
21
22
import {REACT_MEMO_TYPE, REACT_FORWARD_REF_TYPE} from 'shared/ReactSymbols';
23
24
-type Signature = {|
24
+type Signature = {
25
ownKey: string,
26
forceReset: boolean,
27
fullKey: string | null, // Contains keys of nested Hooks. Computed lazily.
28
getCustomHooks: () => Array<Function>,
29
-|};
29
+};
30
31
-type RendererHelpers = {|
31
+type RendererHelpers = {
32
findHostInstancesForRefresh: FindHostInstancesForRefresh,
33
scheduleRefresh: ScheduleRefresh,
34
scheduleRoot: ScheduleRoot,
35
setRefreshHandler: SetRefreshHandler,
36
-|};
36
+};
37
38
if (!__DEV__) {
39
throw new Error(
packages/react-server-dom-relay/src/ReactDOMServerFB.js
+4
-4
@@ -26,19 +26,19 @@ import {
26
createRootFormatContext,
27
} from 'react-server/src/ReactServerFormatConfig';
28
29
-type Options = {|
29
+type Options = {
30
identifierPrefix?: string,
31
bootstrapScriptContent?: string,
32
bootstrapScripts: Array<string>,
33
bootstrapModules: Array<string>,
34
progressiveChunkSize?: number,
35
onError: (error: mixed) => void,
36
-|};
36
+};
37
38
-opaque type Stream = {|
38
+opaque type Stream = {
39
destination: Destination,
40
request: Request,
41
-|};
41
+};
42
43
function renderToStream(children: ReactNodeList, options: Options): Stream {
44
const destination = {
packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js
+1
-1
@@ -14,7 +14,7 @@ export type JSONValue =
14
| number
15
| boolean
16
| null
17
- | {|+[key: string]: JSONValue|}
17
+ | {+[key: string]: JSONValue}
18
| $ReadOnlyArray<JSONValue>;
19
20
export type RowEncoding =
packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js
+2
-2
@@ -19,10 +19,10 @@ import {
19
startFlowing,
20
} from 'react-server/src/ReactFlightServer';
21
22
-type Options = {|
22
+type Options = {
23
onError?: (error: mixed) => void,
24
identifierPrefix?: string,
25
-|};
25
+};
26
27
function render(
28
model: ReactModel,
packages/react-server-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js
+2
-2
@@ -78,7 +78,7 @@ export function processErrorChunk(
78
79
function convertModelToJSON(
80
request: Request,
81
- parent: {|+[key: string]: ReactModel|} | $ReadOnlyArray<ReactModel>,
81
+ parent: {+[key: string]: ReactModel} | $ReadOnlyArray<ReactModel>,
82
key: string,
83
model: ReactModel,
84
): JSONValue {
@@ -93,7 +93,7 @@ function convertModelToJSON(
93
} else {
94
/* $FlowFixMe the old version of Flow doesn't have a good way to define
95
* an empty exact object. */
96
- const jsonObj: {|[key: string]: JSONValue|} = {};
96
+ const jsonObj: {[key: string]: JSONValue} = {};
97
for (const nextKey in json) {
98
if (hasOwnProperty.call(json, nextKey)) {
99
jsonObj[nextKey] = convertModelToJSON(
packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js
+2
-2
@@ -7,12 +7,12 @@
7
* @flow
8
*/
9
10
-export type Destination = {|
10
+export type Destination = {
11
buffer: string,
12
done: boolean,
13
fatal: boolean,
14
error: mixed,
15
-|};
15
+};
16
17
export type PrecomputedChunk = string;
18
export type Chunk = string;
packages/react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js
+6
-6
@@ -9,20 +9,20 @@
9
10
import type {Thenable} from 'shared/ReactTypes';
11
12
-export type WebpackSSRMap = {|
13
- [clientId: string]: {|
12
+export type WebpackSSRMap = {
13
+ [clientId: string]: {
14
[clientExportName: string]: ModuleMetaData,
15
- |},
16
-|};
15
+ },
16
+};
17
18
export type BundlerConfig = null | WebpackSSRMap;
19
20
-export opaque type ModuleMetaData = {|
20
+export opaque type ModuleMetaData = {
21
id: string,
22
chunks: Array<string>,
23
name: string,
24
async: boolean,
25
-|};
25
+};
26
27
// eslint-disable-next-line no-unused-vars
28
export opaque type ModuleReference<T> = ModuleMetaData;
packages/react-server-dom-webpack/src/ReactFlightDOMClient.js
+2
-2
@@ -19,9 +19,9 @@ import {
19
close,
20
} from 'react-client/src/ReactFlightClientStream';
21
22
-export type Options = {|
22
+export type Options = {
23
moduleMap?: BundlerConfig,
24
-|};
24
+};
25
26
function startReadingFromStream(
27
response: FlightResponse,
packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js
+2
-2
@@ -18,12 +18,12 @@ import {
18
abort,
19
} from 'react-server/src/ReactFlightServer';
20
21
-type Options = {|
21
+type Options = {
22
identifierPrefix?: string,
23
signal?: AbortSignal,
24
context?: Array<[string, ServerContextJSONValue]>,
25
onError?: (error: mixed) => void,
26
-|};
26
+};
27
28
function renderToReadableStream(
29
model: ReactModel,
packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js
+4
-4
@@ -23,16 +23,16 @@ function createDrainHandler(destination, request) {
23
return () => startFlowing(request, destination);
24
}
25
26
-type Options = {|
26
+type Options = {
27
onError?: (error: mixed) => void,
28
context?: Array<[string, ServerContextJSONValue]>,
29
identifierPrefix?: string,
30
-|};
30
+};
31
32
-type PipeableStream = {|
32
+type PipeableStream = {
33
abort(reason: mixed): void,
34
pipe<T: Writable>(destination: T): T,
35
-|};
35
+};
36
37
function renderToPipeableStream(
38
model: ReactModel,
packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js
+8
-8
@@ -7,28 +7,28 @@
7
* @flow
8
*/
9
10
-type WebpackMap = {|
11
- [filepath: string]: {|
10
+type WebpackMap = {
11
+ [filepath: string]: {
12
[name: string]: ModuleMetaData,
13
- |},
14
-|};
13
+ },
14
+};
15
16
export type BundlerConfig = WebpackMap;
17
18
// eslint-disable-next-line no-unused-vars
19
-export type ModuleReference<T> = {|
19
+export type ModuleReference<T> = {
20
$$typeof: symbol,
21
filepath: string,
22
name: string,
23
async: boolean,
24
-|};
24
+};
25
26
-export type ModuleMetaData = {|
26
+export type ModuleMetaData = {
27
id: string,
28
chunks: Array<string>,
29
name: string,
30
async: boolean,
31
-|};
31
+};
32
33
export type ModuleKey = string;
34
packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js
+13
-13
@@ -9,37 +9,37 @@
9
10
import {acorn} from 'acorn';
11
12
-type ResolveContext = {|
12
+type ResolveContext = {
13
conditions: Array<string>,
14
parentURL: string | void,
15
-|};
15
+};
16
17
type ResolveFunction = (
18
string,
19
ResolveContext,
20
ResolveFunction,
21
-) => {|url: string|} | Promise<{|url: string|}>;
21
+) => {url: string} | Promise<{url: string}>;
22
23
-type GetSourceContext = {|
23
+type GetSourceContext = {
24
format: string,
25
-|};
25
+};
26
27
type GetSourceFunction = (
28
string,
29
GetSourceContext,
30
GetSourceFunction,
31
-) => Promise<{|source: Source|}>;
31
+) => Promise<{source: Source}>;
32
33
-type TransformSourceContext = {|
33
+type TransformSourceContext = {
34
format: string,
35
url: string,
36
-|};
36
+};
37
38
type TransformSourceFunction = (
39
Source,
40
TransformSourceContext,
41
TransformSourceFunction,
42
-) => Promise<{|source: Source|}>;
42
+) => Promise<{source: Source}>;
43
44
type Source = string | ArrayBuffer | Uint8Array;
45
@@ -52,7 +52,7 @@ export async function resolve(
52
specifier: string,
53
context: ResolveContext,
54
defaultResolve: ResolveFunction,
55
-): Promise<{|url: string|}> {
55
+): Promise<{url: string}> {
56
// We stash this in case we end up needing to resolve export * statements later.
57
stashedResolve = defaultResolve;
58
@@ -133,7 +133,7 @@ function addExportNames(names, node) {
133
function resolveClientImport(
134
specifier: string,
135
parentURL: string,
136
-): {|url: string|} | Promise<{|url: string|}> {
136
+): {url: string} | Promise<{url: string}> {
137
// Resolve an import specifier as if it was loaded by the client. This doesn't use
138
// the overrides that this loader does but instead reverts to the default.
139
// This resolution algorithm will not necessarily have the same configuration
@@ -151,7 +151,7 @@ function resolveClientImport(
151
async function loadClientImport(
152
url: string,
153
defaultTransformSource: TransformSourceFunction,
154
-): Promise<{|source: Source|}> {
154
+): Promise<{source: Source}> {
155
if (stashedGetSource === null) {
156
throw new Error(
157
'Expected getSource to have been called before transformSource',
@@ -225,7 +225,7 @@ export async function transformSource(
225
source: Source,
226
context: TransformSourceContext,
227
defaultTransformSource: TransformSourceFunction,
228
-): Promise<{|source: Source|}> {
228
+): Promise<{source: Source}> {
229
const transformed = await defaultTransformSource(
230
source,
231
context,
packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js
+4
-4
@@ -42,21 +42,21 @@ class ClientReferenceDependency extends ModuleDependency {
42
const clientImportName = 'react-server-dom-webpack';
43
const clientFileName = require.resolve('../');
44
45
-type ClientReferenceSearchPath = {|
45
+type ClientReferenceSearchPath = {
46
directory: string,
47
recursive?: boolean,
48
include: RegExp,
49
exclude?: RegExp,
50
-|};
50
+};
51
52
type ClientReferencePath = string | ClientReferenceSearchPath;
53
54
-type Options = {|
54
+type Options = {
55
isServer: boolean,
56
clientReferences?: ClientReferencePath | $ReadOnlyArray<ClientReferencePath>,
57
chunkName?: string,
58
manifestFilename?: string,
59
-|};
59
+};
60
61
const PLUGIN_NAME = 'React Server Plugin';
62
packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js
+1
-1
@@ -14,7 +14,7 @@ export type JSONValue =
14
| number
15
| boolean
16
| null
17
- | {|+[key: string]: JSONValue|}
17
+ | {+[key: string]: JSONValue}
18
| Array<JSONValue>;
19
20
export type RowEncoding =
packages/react-server-native-relay/src/ReactFlightNativeRelayServerHostConfig.js
+2
-2
@@ -75,7 +75,7 @@ export function processErrorChunk(
75
76
function convertModelToJSON(
77
request: Request,
78
- parent: {|+[key: string]: ReactModel|} | $ReadOnlyArray<ReactModel>,
78
+ parent: {+[key: string]: ReactModel} | $ReadOnlyArray<ReactModel>,
79
key: string,
80
model: ReactModel,
81
): JSONValue {
@@ -89,7 +89,7 @@ function convertModelToJSON(
89
return jsonArray;
90
} else {
91
// $FlowFixMe no good way to define an empty exact object
92
- const jsonObj: {|[key: string]: JSONValue|} = {};
92
+ const jsonObj: {[key: string]: JSONValue} = {};
93
for (const nextKey in json) {
94
if (hasOwnProperty.call(json, nextKey)) {
95
jsonObj[nextKey] = convertModelToJSON(
packages/react-server/src/ReactFizzClassComponent.js
+2
-2
@@ -100,10 +100,10 @@ function warnNoop(
100
}
101
}
102
103
-type InternalInstance = {|
103
+type InternalInstance = {
104
queue: null | Array<Object>,
105
replace: boolean,
106
-|};
106
+};
107
108
const classComponentUpdater = {
109
isMounted(inst) {
packages/react-server/src/ReactFizzComponentStack.js
+6
-6
@@ -14,21 +14,21 @@ import {
14
} from 'shared/ReactComponentStackFrame';
15
16
// DEV-only reverse linked list representing the current component stack
17
-type BuiltInComponentStackNode = {|
17
+type BuiltInComponentStackNode = {
18
tag: 0,
19
parent: null | ComponentStackNode,
20
type: string,
21
-|};
22
-type FunctionComponentStackNode = {|
21
+};
22
+type FunctionComponentStackNode = {
23
tag: 1,
24
parent: null | ComponentStackNode,
25
type: Function,
26
-|};
27
-type ClassComponentStackNode = {|
26
+};
27
+type ClassComponentStackNode = {
28
tag: 2,
29
parent: null | ComponentStackNode,
30
type: Function,
31
-|};
31
+};
32
export type ComponentStackNode =
33
| BuiltInComponentStackNode
34
| FunctionComponentStackNode
packages/react-server/src/ReactFizzHooks.js
+7
-7
@@ -43,21 +43,21 @@ import is from 'shared/objectIs';
43
type BasicStateAction<S> = (S => S) | S;
44
type Dispatch<A> = A => void;
45
46
-type Update<A> = {|
46
+type Update<A> = {
47
action: A,
48
next: Update<A> | null,
49
-|};
49
+};
50
51
-type UpdateQueue<A> = {|
51
+type UpdateQueue<A> = {
52
last: Update<A> | null,
53
dispatch: any,
54
-|};
54
+};
55
56
-type Hook = {|
56
+type Hook = {
57
memoizedState: any,
58
queue: UpdateQueue<any> | null,
59
next: Hook | null,
60
-|};
60
+};
61
62
let currentlyRenderingComponent: Object | null = null;
63
let currentlyRenderingTask: Task | null = null;
@@ -416,7 +416,7 @@ function useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T {
416
return nextValue;
417
}
418
419
-function useRef<T>(initialValue: T): {|current: T|} {
419
+function useRef<T>(initialValue: T): {current: T} {
420
currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
421
workInProgressHook = createWorkInProgressHook();
422
const previousRef = workInProgressHook.memoizedState;
packages/react-server/src/ReactFizzNewContext.js
+2
-2
@@ -20,13 +20,13 @@ if (__DEV__) {
20
21
// Used to store the parent path of all context overrides in a shared linked list.
22
// Forming a reverse tree.
23
-type ContextNode<T> = {|
23
+type ContextNode<T> = {
24
parent: null | ContextNode<any>,
25
depth: number, // Short hand to compute the depth of the tree at this node.
26
context: ReactContext<T>,
27
parentValue: T,
28
value: T,
29
-|};
29
+};
30
31
// The structure of a context snapshot is an implementation of this file.
32
// Currently, it's implemented as tracking the current active node.
packages/react-server/src/ReactFizzServer.js
+10
-10
@@ -131,11 +131,11 @@ import {trackSuspendedWakeable} from './ReactFizzWakeable';
131
const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
132
const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
133
134
-type LegacyContext = {|
134
+type LegacyContext = {
135
[key: string]: any,
136
-|};
136
+};
137
138
-type SuspenseBoundary = {|
138
+type SuspenseBoundary = {
139
id: SuspenseBoundaryID,
140
rootSegmentID: number,
141
errorDigest: ?string, // the error hash if it errors
@@ -147,9 +147,9 @@ type SuspenseBoundary = {|
147
completedSegments: Array<Segment>, // completed but not yet flushed segments.
148
byteSize: number, // used to determine whether to inline children boundaries.
149
fallbackAbortableTasks: Set<Task>, // used to cancel task on the fallback if the boundary completes or gets canceled.
150
-|};
150
+};
151
152
-export type Task = {|
152
+export type Task = {
153
node: ReactNodeList,
154
ping: () => void,
155
blockedBoundary: Root | SuspenseBoundary,
@@ -160,7 +160,7 @@ export type Task = {|
160
treeContext: TreeContext, // the current tree context that this task is executing in
161
componentStack: null | ComponentStackNode, // DEV-only component stack
162
thenableState: null | ThenableState,
163
-|};
163
+};
164
165
const PENDING = 0;
166
const COMPLETED = 1;
@@ -170,7 +170,7 @@ const ERRORED = 4;
170
171
type Root = null;
172
173
-type Segment = {|
173
+type Segment = {
174
status: 0 | 1 | 2 | 3 | 4,
175
parentFlushed: boolean, // typically a segment will be flushed by its parent, except if its parent was already flushed
176
id: number, // starts as 0 and is lazily assigned if the parent flushes early
@@ -184,13 +184,13 @@ type Segment = {|
184
// used to discern when text separator boundaries are needed
185
lastPushedText: boolean,
186
textEmbedded: boolean,
187
-|};
187
+};
188
189
const OPEN = 0;
190
const CLOSING = 1;
191
const CLOSED = 2;
192
193
-export opaque type Request = {|
193
+export opaque type Request = {
194
destination: null | Destination,
195
+responseState: ResponseState,
196
+progressiveChunkSize: number,
@@ -223,7 +223,7 @@ export opaque type Request = {|
223
// emit a different response to the stream instead.
224
onShellError: (error: mixed) => void,
225
onFatalError: (error: mixed) => void,
226
-|};
226
+};
227
228
// This is a default heuristic for how to split up the HTML content into progressive
229
// loading. Our goal is to be able to display additional new content about every 500ms.
packages/react-server/src/ReactFizzTreeContext.js
+2
-2
@@ -60,10 +60,10 @@
60
// log2(32) = 5 bits. That means we can lop bits off the end 5 at a time without
61
// affecting the final result.
62
63
-export type TreeContext = {|
63
+export type TreeContext = {
64
+id: number,
65
+overflow: string,
66
-|};
66
+};
67
68
export const emptyTreeContext = {
69
id: 1,
packages/react-server/src/ReactFlightNewContext.js
+2
-2
@@ -23,13 +23,13 @@ if (__DEV__) {
23
24
// Used to store the parent path of all context overrides in a shared linked list.
25
// Forming a reverse tree.
26
-type ContextNode<T: ServerContextJSONValue> = {|
26
+type ContextNode<T: ServerContextJSONValue> = {
27
parent: null | ContextNode<any>,
28
depth: number, // Short hand to compute the depth of the tree at this node.
29
context: ReactServerContext<T>,
30
parentValue: T,
31
value: T,
32
-|};
32
+};
33
34
// The structure of a context snapshot is an implementation of this file.
35
// Currently, it's implemented as tracking the current active node.
packages/react-server/src/ReactFlightServer.js
+7
-7
@@ -91,23 +91,23 @@ export type ReactModel =
91
| Iterable<ReactModel>
92
| ReactModelObject;
93
94
-type ReactModelObject = {|+[key: string]: ReactModel|};
94
+type ReactModelObject = {+[key: string]: ReactModel};
95
96
const PENDING = 0;
97
const COMPLETED = 1;
98
const ABORTED = 3;
99
const ERRORED = 4;
100
101
-type Task = {|
101
+type Task = {
102
id: number,
103
status: 0 | 1 | 3 | 4,
104
model: ReactModel,
105
ping: () => void,
106
context: ContextSnapshot,
107
thenableState: ThenableState | null,
108
-|};
108
+};
109
110
-export type Request = {|
110
+export type Request = {
111
status: 0 | 1 | 2,
112
fatalError: mixed,
113
destination: null | Destination,
@@ -127,7 +127,7 @@ export type Request = {|
127
identifierCount: number,
128
onError: (error: mixed) => void,
129
toJSON: (key: string, value: ReactModel) => ReactJSONValue,
130
-|};
130
+};
131
132
const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
133
@@ -325,7 +325,7 @@ function serializeByRefID(id: number): string {
325
326
function serializeModuleReference(
327
request: Request,
328
- parent: {|+[key: string | number]: ReactModel|} | $ReadOnlyArray<ReactModel>,
328
+ parent: {+[key: string | number]: ReactModel} | $ReadOnlyArray<ReactModel>,
329
key: string,
330
moduleReference: ModuleReference<any>,
331
): string {
@@ -529,7 +529,7 @@ let isInsideContextValue = false;
529
530
export function resolveModelToJSON(
531
request: Request,
532
- parent: {|+[key: string | number]: ReactModel|} | $ReadOnlyArray<ReactModel>,
532
+ parent: {+[key: string | number]: ReactModel} | $ReadOnlyArray<ReactModel>,
533
key: string,
534
value: ReactModel,
535
): ReactJSONValue {
packages/react-test-renderer/src/ReactTestHostConfig.js
+7
-7
@@ -12,12 +12,12 @@ import {DefaultEventPriority} from 'react-reconciler/src/ReactEventPriorities';
12
13
export type Type = string;
14
export type Props = Object;
15
-export type Container = {|
15
+export type Container = {
16
children: Array<Instance | TextInstance>,
17
createNodeMock: Function,
18
tag: 'CONTAINER',
19
-|};
20
-export type Instance = {|
19
+};
20
+export type Instance = {
21
type: string,
22
props: Object,
23
isHidden: boolean,
@@ -25,12 +25,12 @@ export type Instance = {|
25
internalInstanceHandle: Object,
26
rootContainerInstance: Container,
27
tag: 'INSTANCE',
28
-|};
29
-export type TextInstance = {|
28
+};
29
+export type TextInstance = {
30
text: string,
31
isHidden: boolean,
32
tag: 'TEXT',
33
-|};
33
+};
34
export type HydratableInstance = Instance | TextInstance;
35
export type PublicInstance = Instance | TextInstance;
36
export type HostContext = Object;
@@ -40,7 +40,7 @@ export type TimeoutHandle = TimeoutID;
40
export type NoTimeout = -1;
41
export type EventResponder = any;
42
43
-export type RendererInspectionConfig = $ReadOnly<{||}>;
43
+export type RendererInspectionConfig = $ReadOnly<{}>;
44
45
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoPersistence';
46
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoHydration';
packages/react-test-renderer/src/ReactTestRenderer.js
+2
-2
@@ -61,12 +61,12 @@ type TestRendererOptions = {
61
...
62
};
63
64
-type ReactTestRendererJSON = {|
64
+type ReactTestRendererJSON = {
65
type: string,
66
props: {[propName: string]: any, ...},
67
children: null | Array<ReactTestRendererNode>,
68
$$typeof?: symbol, // Optional because we add it with defineProperty().
69
-|};
69
+};
70
type ReactTestRendererNode = ReactTestRendererJSON | string;
71
72
type FindOptions = $Shape<{
packages/react/src/ReactChildren.js
+2
-2
@@ -173,9 +173,9 @@ function mapIntoArray(
173
} else {
174
const iteratorFn = getIteratorFn(children);
175
if (typeof iteratorFn === 'function') {
176
- const iterableChildren: Iterable<React$Node> & {|
176
+ const iterableChildren: Iterable<React$Node> & {
177
entries: any,
178
- |} = (children: any);
178
+ } = (children: any);
179
180
if (__DEV__) {
181
// Warn about using Maps as children
packages/react/src/ReactCurrentBatchConfig.js
+2
-2
@@ -9,9 +9,9 @@
9
10
import type {BatchConfigTransition} from 'react-reconciler/src/ReactFiberTracingMarkerComponent.new';
11
12
-type BatchConfig = {|
12
+type BatchConfig = {
13
transition: BatchConfigTransition | null,
14
-|};
14
+};
15
/**
16
* Keeps track of the current batch's configuration such as how long an update
17
* should suspend for if it needs to.
packages/react/src/ReactHooks.js
+2
-2
@@ -94,7 +94,7 @@ export function useReducer<S, I, A>(
94
return dispatcher.useReducer(reducer, initialArg, init);
95
}
96
97
-export function useRef<T>(initialValue: T): {|current: T|} {
97
+export function useRef<T>(initialValue: T): {current: T} {
98
const dispatcher = resolveDispatcher();
99
return dispatcher.useRef(initialValue);
100
}
@@ -140,7 +140,7 @@ export function useMemo<T>(
140
}
141
142
export function useImperativeHandle<T>(
143
- ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
143
+ ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
144
create: () => T,
145
deps: Array<mixed> | void | null,
146
): void {
packages/react/src/ReactLazy.js
+10
-10
@@ -16,25 +16,25 @@ const Pending = 0;
16
const Resolved = 1;
17
const Rejected = 2;
18
19
-type UninitializedPayload<T> = {|
19
+type UninitializedPayload<T> = {
20
_status: -1,
21
_result: () => Thenable<{default: T, ...}>,
22
-|};
22
+};
23
24
-type PendingPayload = {|
24
+type PendingPayload = {
25
_status: 0,
26
_result: Wakeable,
27
-|};
27
+};
28
29
-type ResolvedPayload<T> = {|
29
+type ResolvedPayload<T> = {
30
_status: 1,
31
_result: {default: T, ...},
32
-|};
32
+};
33
34
-type RejectedPayload = {|
34
+type RejectedPayload = {
35
_status: 2,
36
_result: mixed,
37
-|};
37
+};
38
39
type Payload<T> =
40
| UninitializedPayload<T>
@@ -42,11 +42,11 @@ type Payload<T> =
42
| ResolvedPayload<T>
43
| RejectedPayload;
44
45
-export type LazyComponent<T, P> = {|
45
+export type LazyComponent<T, P> = {
46
$$typeof: symbol | number,
47
_payload: P,
48
_init: (payload: P) => T,
49
-|};
49
+};
50
51
function lazyInitializer<T>(payload: Payload<T>): T {
52
if (payload._status === Uninitialized) {
packages/scheduler/src/SchedulerMinHeap.js
+2
-2
@@ -8,10 +8,10 @@
8
*/
9
10
type Heap = Array<Node>;
11
-type Node = {|
11
+type Node = {
12
id: number,
13
sortIndex: number,
14
-|};
14
+};
15
16
export function push(heap: Heap, node: Node): void {
17
const index = heap.length;
packages/scheduler/src/forks/SchedulerPostTask.js
+3
-3
@@ -17,9 +17,9 @@ declare class TaskController {
17
18
type PostTaskPriorityLevel = 'user-blocking' | 'user-visible' | 'background';
19
20
-type CallbackNode = {|
20
+type CallbackNode = {
21
_controller: TaskController,
22
-|};
22
+};
23
24
import {
25
ImmediatePriority,
@@ -77,7 +77,7 @@ type SchedulerCallback<T> = (
77
export function unstable_scheduleCallback<T>(
78
priorityLevel: PriorityLevel,
79
callback: SchedulerCallback<T>,
80
- options?: {|delay?: number|},
80
+ options?: {delay?: number},
81
): CallbackNode {
82
let postTaskPriority;
83
switch (priorityLevel) {
packages/shared/ReactElementType.js
+4
-4
@@ -7,12 +7,12 @@
7
* @flow
8
*/
9
10
-export type Source = {|
10
+export type Source = {
11
fileName: string,
12
lineNumber: number,
13
-|};
13
+};
14
15
-export type ReactElement = {|
15
+export type ReactElement = {
16
$$typeof: any,
17
type: any,
18
key: any,
@@ -26,4 +26,4 @@ export type ReactElement = {|
26
_self: React$Element<any>,
27
_shadowChildren: any,
28
_source: Source,
29
-|};
29
+};
packages/shared/ReactTypes.js
+11
-11
@@ -80,7 +80,7 @@ export type ServerContextJSONValue =
80
| number
81
| null
82
| $ReadOnlyArray<ServerContextJSONValue>
83
- | {|+[key: string]: ServerContextJSONValue|};
83
+ | {+[key: string]: ServerContextJSONValue};
84
85
export type ReactServerContext<T: any> = ReactContext<T>;
86
@@ -94,13 +94,13 @@ export type ReactPortal = {
94
...
95
};
96
97
-export type RefObject = {|
97
+export type RefObject = {
98
current: any,
99
-|};
99
+};
100
101
-export type ReactScope = {|
101
+export type ReactScope = {
102
$$typeof: symbol | number,
103
-|};
103
+};
104
105
export type ReactScopeQuery = (
106
type: string,
@@ -108,12 +108,12 @@ export type ReactScopeQuery = (
108
instance: mixed,
109
) => boolean;
110
111
-export type ReactScopeInstance = {|
111
+export type ReactScopeInstance = {
112
DO_NOT_USE_queryAllNodes(ReactScopeQuery): null | Array<Object>,
113
DO_NOT_USE_queryFirstNode(ReactScopeQuery): null | Object,
114
containsNode(Object): boolean,
115
getChildContextValues: <T>(context: ReactContext<T>) => Array<T>,
116
-|};
116
+};
117
118
// Mutable source version can be anything (e.g. number, string, immutable data structure)
119
// so long as it changes every time any part of the source changes.
@@ -133,7 +133,7 @@ export type MutableSourceGetVersionFn = (
133
source: $NonMaybeType<mixed>,
134
) => MutableSourceVersion;
135
136
-export type MutableSource<Source: $NonMaybeType<mixed>> = {|
136
+export type MutableSource<Source: $NonMaybeType<mixed>> = {
137
_source: Source,
138
139
_getVersion: MutableSourceGetVersionFn,
@@ -163,7 +163,7 @@ export type MutableSource<Source: $NonMaybeType<mixed>> = {|
163
// See https://github.com/facebook/react/issues/19948
164
_currentlyRenderingFiber?: Fiber | null,
165
_initialVersionAsOfFirstRender?: MutableSourceVersion | null,
166
-|};
166
+};
167
168
// The subset of a Thenable required by things thrown by Suspense.
169
// This doesn't require a value to be passed to either handler.
@@ -209,9 +209,9 @@ export type OffscreenMode =
209
| 'unstable-defer-without-hiding'
210
| 'visible';
211
212
-export type StartTransitionOptions = {|
212
+export type StartTransitionOptions = {
213
name?: string,
214
-|};
214
+};
215
216
// TODO: Add Context support
217
export type Usable<T> = Thenable<T> | ReactContext<T>;
packages/use-subscription/src/useSubscription.js
+2
-2
@@ -22,9 +22,9 @@ export function useSubscription<Value>({
22
// This function is passed an event handler to attach to the subscription.
23
// It should return an unsubscribe function that removes the handler.
24
subscribe,
25
-}: {|
25
+}: {
26
getCurrentValue: () => Value,
27
subscribe: (callback: Function) => () => void,
28
-|}): Value {
28
+}): Value {
29
return useSyncExternalStore(subscribe, getCurrentValue);
30
}
scripts/flow/environment.js
+17
-17
@@ -25,13 +25,13 @@ declare module 'create-react-class' {
25
declare var exports: React$CreateClass;
26
}
27
28
-declare var trustedTypes: {|
28
+declare var trustedTypes: {
29
isHTML: (value: any) => boolean,
30
isScript: (value: any) => boolean,
31
isScriptURL: (value: any) => boolean,
32
// TrustedURLs are deprecated and will be removed soon: https://github.com/WICG/trusted-types/pull/204
33
isURL?: (value: any) => boolean,
34
-|};
34
+};
35
36
// ReactFeatureFlags www fork
37
declare module 'ReactFeatureFlags' {
@@ -77,52 +77,52 @@ declare module 'fs/promises' {
77
declare var access: (path: string, mode?: number) => Promise<void>;
78
declare var lstat: (
79
path: string,
80
- options?: ?{|bigint?: boolean|},
80
+ options?: ?{bigint?: boolean},
81
) => Promise<mixed>;
82
declare var readdir: (
83
path: string,
84
options?:
85
| ?string
86
- | {|
86
+ | {
87
encoding?: ?string,
88
withFileTypes?: ?boolean,
89
- |},
89
+ },
90
) => Promise<Buffer>;
91
declare var readFile: (
92
path: string,
93
options?:
94
| ?string
95
- | {|
95
+ | {
96
encoding?: ?string,
97
- |},
97
+ },
98
) => Promise<Buffer>;
99
declare var readlink: (
100
path: string,
101
options?:
102
| ?string
103
- | {|
103
+ | {
104
encoding?: ?string,
105
- |},
105
+ },
106
) => Promise<mixed>;
107
declare var realpath: (
108
path: string,
109
options?:
110
| ?string
111
- | {|
111
+ | {
112
encoding?: ?string,
113
- |},
113
+ },
114
) => Promise<mixed>;
115
declare var stat: (
116
path: string,
117
- options?: ?{|bigint?: boolean|},
117
+ options?: ?{bigint?: boolean},
118
) => Promise<mixed>;
119
}
120
declare module 'pg' {
121
declare var Pool: (
122
options: mixed,
123
- ) => {|
123
+ ) => {
124
query: (query: string, values?: Array<mixed>) => void,
125
- |};
125
+ };
126
}
127
128
declare module 'util' {
@@ -147,13 +147,13 @@ declare module 'util' {
147
encodeInto(
148
buffer: string,
149
dest: Uint8Array,
150
- ): {|read: number, written: number|};
150
+ ): {read: number, written: number};
151
encoding: string;
152
}
153
}
154
155
declare module 'pg/lib/utils' {
156
- declare module.exports: {|
156
+ declare module.exports: {
157
prepareValue(val: any): mixed,
158
- |};
158
+ };
159
}
scripts/flow/react-native-host-hooks.js
+3
-3
@@ -20,14 +20,14 @@ import type {RNTopLevelEventType} from 'react-native-renderer/src/legacy-events/
20
import type {CapturedError} from 'react-reconciler/src/ReactCapturedValue';
21
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
22
23
-type DeepDifferOptions = {|+unsafelyIgnoreFunctions?: boolean|};
24
-type RawEventEmitterEvent = $ReadOnly<{|
23
+type DeepDifferOptions = {+unsafelyIgnoreFunctions?: boolean};
24
+type RawEventEmitterEvent = $ReadOnly<{
25
eventName: string,
26
// We expect, but do not/cannot require, that nativeEvent is an object
27
// with the properties: key, elementType (string), type (string), tag (numeric),
28
// and a stateNode of the native element/Fiber the event was emitted to.
29
nativeEvent: {[string]: mixed, ...},
30
-|}>;
30
+}>;
31
32
declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' {
33
declare export function deepDiffer(
scripts/flow/react-relay-hooks.js
+1
-1
@@ -12,7 +12,7 @@ type JSONValue =
12
| boolean
13
| number
14
| null
15
- | {|+[key: string]: JSONValue|}
15
+ | {+[key: string]: JSONValue}
16
| $ReadOnlyArray<JSONValue>;
17
18
declare module 'JSResourceReference' {
scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js
+6
-6
@@ -15,19 +15,19 @@ import invariant from 'invariant';
15
16
// Event configs
17
const customBubblingEventTypes: {
18
- [eventName: string]: $ReadOnly<{|
19
- phasedRegistrationNames: $ReadOnly<{|
18
+ [eventName: string]: $ReadOnly<{
19
+ phasedRegistrationNames: $ReadOnly<{
20
captured: string,
21
bubbled: string,
22
skipBubbling?: ?boolean,
23
- |}>,
24
- |}>,
23
+ }>,
24
+ }>,
25
...,
26
} = {};
27
const customDirectEventTypes: {
28
- [eventName: string]: $ReadOnly<{|
28
+ [eventName: string]: $ReadOnly<{
29
registrationName: string,
30
- |}>,
30
+ }>,
31
...,
32
} = {};
33