@@ -26,8 +26,7 @@ import type {
2626import type {
2727 DevToolsHook ,
2828 DevToolsHookSettings ,
29- ReloadAndProfileConfig ,
30- ReloadAndProfileConfigPersistence ,
29+ ProfilingSettings ,
3130} from 'react-devtools-shared/src/backend/types' ;
3231import type { ResolveNativeStyle } from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor' ;
3332
@@ -42,7 +41,9 @@ type ConnectOptions = {
4241 websocket ?: ?WebSocket ,
4342 onSettingsUpdated ?: ( settings : $ReadOnly < DevToolsHookSettings > ) => void ,
4443 isReloadAndProfileSupported ?: boolean ,
45- reloadAndProfileConfigPersistence ?: ReloadAndProfileConfigPersistence ,
44+ isProfiling ?: boolean ,
45+ onReloadAndProfile ?: ( recordChangeDescriptions : boolean ) => void ,
46+ onReloadAndProfileFlagsReset ?: ( ) => void ,
4647} ;
4748
4849let savedComponentFilters : Array < ComponentFilter > =
@@ -63,9 +64,15 @@ export function initialize(
6364 maybeSettingsOrSettingsPromise ?:
6465 | DevToolsHookSettings
6566 | Promise < DevToolsHookSettings > ,
66- reloadAndProfileConfig ?: ReloadAndProfileConfig ,
67+ shouldStartProfilingNow : boolean = false ,
68+ profilingSettings ?: ProfilingSettings ,
6769) {
68- installHook ( window , maybeSettingsOrSettingsPromise , reloadAndProfileConfig ) ;
70+ installHook (
71+ window ,
72+ maybeSettingsOrSettingsPromise ,
73+ shouldStartProfilingNow ,
74+ profilingSettings ,
75+ ) ;
6976}
7077
7178export function connectToDevTools ( options : ?ConnectOptions ) {
@@ -86,7 +93,9 @@ export function connectToDevTools(options: ?ConnectOptions) {
8693 isAppActive = ( ) => true ,
8794 onSettingsUpdated,
8895 isReloadAndProfileSupported = getIsReloadAndProfileSupported ( ) ,
89- reloadAndProfileConfigPersistence,
96+ isProfiling,
97+ onReloadAndProfile,
98+ onReloadAndProfileFlagsReset,
9099 } = options || { } ;
91100
92101 const protocol = useHttps ? 'wss' : 'ws' ;
@@ -180,7 +189,11 @@ export function connectToDevTools(options: ?ConnectOptions) {
180189
181190 // TODO (npm-packages) Warn if "isBackendStorageAPISupported"
182191 // $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+
184197 if ( onSettingsUpdated != null ) {
185198 agent . addListener ( 'updateHookSettings' , onSettingsUpdated ) ;
186199 }
@@ -320,7 +333,9 @@ type ConnectWithCustomMessagingOptions = {
320333 resolveRNStyle ?: ResolveNativeStyle ,
321334 onSettingsUpdated ?: ( settings : $ReadOnly < DevToolsHookSettings > ) => void ,
322335 isReloadAndProfileSupported ?: boolean ,
323- reloadAndProfileConfigPersistence ?: ReloadAndProfileConfigPersistence ,
336+ isProfiling ?: boolean ,
337+ onReloadAndProfile ?: ( recordChangeDescriptions : boolean ) => void ,
338+ onReloadAndProfileFlagsReset ?: ( ) => void ,
324339} ;
325340
326341export function connectWithCustomMessagingProtocol ( {
@@ -331,7 +346,9 @@ export function connectWithCustomMessagingProtocol({
331346 resolveRNStyle,
332347 onSettingsUpdated,
333348 isReloadAndProfileSupported = getIsReloadAndProfileSupported ( ) ,
334- reloadAndProfileConfigPersistence,
349+ isProfiling,
350+ onReloadAndProfile,
351+ onReloadAndProfileFlagsReset,
335352} : ConnectWithCustomMessagingOptions ) : Function {
336353 const hook : ?DevToolsHook = window . __REACT_DEVTOOLS_GLOBAL_HOOK__ ;
337354 if ( hook == null ) {
@@ -368,7 +385,11 @@ export function connectWithCustomMessagingProtocol({
368385 bridge . send ( 'overrideComponentFilters' , savedComponentFilters ) ;
369386 }
370387
371- const agent = new Agent ( bridge , reloadAndProfileConfigPersistence ) ;
388+ const agent = new Agent ( bridge , isProfiling , onReloadAndProfile ) ;
389+ if ( typeof onReloadAndProfileFlagsReset === 'function' ) {
390+ onReloadAndProfileFlagsReset ( ) ;
391+ }
392+
372393 if ( onSettingsUpdated != null ) {
373394 agent . addListener ( 'updateHookSettings' , onSettingsUpdated ) ;
374395 }
0 commit comments