@@ -26,8 +26,7 @@ import type {
26
26
import type {
27
27
DevToolsHook ,
28
28
DevToolsHookSettings ,
29
- ReloadAndProfileConfig ,
30
- ReloadAndProfileConfigPersistence ,
29
+ ProfilingSettings ,
31
30
} from 'react-devtools-shared/src/backend/types' ;
32
31
import type { ResolveNativeStyle } from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor' ;
33
32
@@ -42,7 +41,9 @@ type ConnectOptions = {
42
41
websocket ?: ?WebSocket ,
43
42
onSettingsUpdated ?: ( settings : $ReadOnly < DevToolsHookSettings > ) => void ,
44
43
isReloadAndProfileSupported ?: boolean ,
45
- reloadAndProfileConfigPersistence ?: ReloadAndProfileConfigPersistence ,
44
+ isProfiling ?: boolean ,
45
+ onReloadAndProfile ?: ( recordChangeDescriptions : boolean ) => void ,
46
+ onReloadAndProfileFlagsReset ?: ( ) => void ,
46
47
} ;
47
48
48
49
let savedComponentFilters : Array < ComponentFilter > =
@@ -63,9 +64,15 @@ export function initialize(
63
64
maybeSettingsOrSettingsPromise ?:
64
65
| DevToolsHookSettings
65
66
| Promise < DevToolsHookSettings > ,
66
- reloadAndProfileConfig ?: ReloadAndProfileConfig ,
67
+ shouldStartProfilingRightNow : boolean = false ,
68
+ profilingSettings ?: ProfilingSettings ,
67
69
) {
68
- installHook ( window , maybeSettingsOrSettingsPromise , reloadAndProfileConfig ) ;
70
+ installHook (
71
+ window ,
72
+ maybeSettingsOrSettingsPromise ,
73
+ shouldStartProfilingRightNow ,
74
+ profilingSettings ,
75
+ ) ;
69
76
}
70
77
71
78
export function connectToDevTools ( options : ?ConnectOptions ) {
@@ -86,7 +93,9 @@ export function connectToDevTools(options: ?ConnectOptions) {
86
93
isAppActive = ( ) => true ,
87
94
onSettingsUpdated,
88
95
isReloadAndProfileSupported = getIsReloadAndProfileSupported ( ) ,
89
- reloadAndProfileConfigPersistence,
96
+ isProfiling,
97
+ onReloadAndProfile,
98
+ onReloadAndProfileFlagsReset,
90
99
} = options || { } ;
91
100
92
101
const protocol = useHttps ? 'wss' : 'ws' ;
@@ -180,7 +189,11 @@ export function connectToDevTools(options: ?ConnectOptions) {
180
189
181
190
// TODO (npm-packages) Warn if "isBackendStorageAPISupported"
182
191
// $FlowFixMe[incompatible-call] found when upgrading Flow
183
- const agent = new Agent ( bridge , reloadAndProfileConfigPersistence ) ;
192
+ const agent = new Agent ( bridge , isProfiling , onReloadAndProfile ) ;
193
+ if ( typeof onReloadAndProfileFlagsReset === 'function' ) {
194
+ onReloadAndProfileFlagsReset ( ) ;
195
+ }
196
+
184
197
if ( onSettingsUpdated != null ) {
185
198
agent . addListener ( 'updateHookSettings' , onSettingsUpdated ) ;
186
199
}
@@ -320,7 +333,9 @@ type ConnectWithCustomMessagingOptions = {
320
333
resolveRNStyle ?: ResolveNativeStyle ,
321
334
onSettingsUpdated ?: ( settings : $ReadOnly < DevToolsHookSettings > ) => void ,
322
335
isReloadAndProfileSupported ?: boolean ,
323
- reloadAndProfileConfigPersistence ?: ReloadAndProfileConfigPersistence ,
336
+ isProfiling ?: boolean ,
337
+ onReloadAndProfile ?: ( recordChangeDescriptions : boolean ) => void ,
338
+ onReloadAndProfileFlagsReset ?: ( ) => void ,
324
339
} ;
325
340
326
341
export function connectWithCustomMessagingProtocol ( {
@@ -331,7 +346,9 @@ export function connectWithCustomMessagingProtocol({
331
346
resolveRNStyle,
332
347
onSettingsUpdated,
333
348
isReloadAndProfileSupported = getIsReloadAndProfileSupported ( ) ,
334
- reloadAndProfileConfigPersistence,
349
+ isProfiling,
350
+ onReloadAndProfile,
351
+ onReloadAndProfileFlagsReset,
335
352
} : ConnectWithCustomMessagingOptions ) : Function {
336
353
const hook : ?DevToolsHook = window . __REACT_DEVTOOLS_GLOBAL_HOOK__ ;
337
354
if ( hook == null ) {
@@ -368,7 +385,11 @@ export function connectWithCustomMessagingProtocol({
368
385
bridge . send ( 'overrideComponentFilters' , savedComponentFilters ) ;
369
386
}
370
387
371
- const agent = new Agent ( bridge , reloadAndProfileConfigPersistence ) ;
388
+ const agent = new Agent ( bridge , isProfiling , onReloadAndProfile ) ;
389
+ if ( typeof onReloadAndProfileFlagsReset === 'function' ) {
390
+ onReloadAndProfileFlagsReset ( ) ;
391
+ }
392
+
372
393
if ( onSettingsUpdated != null ) {
373
394
agent . addListener ( 'updateHookSettings' , onSettingsUpdated ) ;
374
395
}
0 commit comments