26
import type {
27
DevToolsHook,
28
DevToolsHookSettings,
29
- ReloadAndProfileConfig,
30
- ReloadAndProfileConfigPersistence,
29
+ ProfilingSettings,
30
} from 'react-devtools-shared/src/backend/types';
31
import type {ResolveNativeStyle} from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
32
41
websocket?: ?WebSocket,
42
onSettingsUpdated?: (settings: $ReadOnly<DevToolsHookSettings>) => void,
43
isReloadAndProfileSupported?: boolean,
45
- reloadAndProfileConfigPersistence?: ReloadAndProfileConfigPersistence,
44
+ isProfiling?: boolean,
45
+ onReloadAndProfile?: (recordChangeDescriptions: boolean) => void,
46
+ onReloadAndProfileFlagsReset?: () => void,
47
};
48
49
let savedComponentFilters: Array<ComponentFilter> =
64
maybeSettingsOrSettingsPromise?:
65
| DevToolsHookSettings
66
| Promise<DevToolsHookSettings>,
66
- reloadAndProfileConfig?: ReloadAndProfileConfig,
67
+ shouldStartProfilingNow: boolean = false,
68
+ profilingSettings?: ProfilingSettings,
69
) {
68
- installHook(window, maybeSettingsOrSettingsPromise, reloadAndProfileConfig);
70
+ installHook(
71
+ window,
72
+ maybeSettingsOrSettingsPromise,
73
+ shouldStartProfilingNow,
74
+ profilingSettings,
75
+ );
76
}
77
78
export function connectToDevTools(options: ?ConnectOptions) {
93
isAppActive = () => true,
94
onSettingsUpdated,
95
isReloadAndProfileSupported = getIsReloadAndProfileSupported(),
89
- reloadAndProfileConfigPersistence,
96
+ isProfiling,
97
+ onReloadAndProfile,
98
+ onReloadAndProfileFlagsReset,
99
} = options || {};
100
101
const protocol = useHttps ? 'wss' : 'ws';
189
190
// TODO (npm-packages) Warn if "isBackendStorageAPISupported"
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
+
197
if (onSettingsUpdated != null) {
198
agent.addListener('updateHookSettings', onSettingsUpdated);
199
}
333
resolveRNStyle?: ResolveNativeStyle,
334
onSettingsUpdated?: (settings: $ReadOnly<DevToolsHookSettings>) => void,
335
isReloadAndProfileSupported?: boolean,
323
- reloadAndProfileConfigPersistence?: ReloadAndProfileConfigPersistence,
336
+ isProfiling?: boolean,
337
+ onReloadAndProfile?: (recordChangeDescriptions: boolean) => void,
338
+ onReloadAndProfileFlagsReset?: () => void,
339
};
340
341
export function connectWithCustomMessagingProtocol({
346
resolveRNStyle,
347
onSettingsUpdated,
348
isReloadAndProfileSupported = getIsReloadAndProfileSupported(),
334
- reloadAndProfileConfigPersistence,
349
+ isProfiling,
350
+ onReloadAndProfile,
351
+ onReloadAndProfileFlagsReset,
352
}: ConnectWithCustomMessagingOptions): Function {
353
const hook: ?DevToolsHook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
354
if (hook == null) {
385
bridge.send('overrideComponentFilters', savedComponentFilters);
386
}
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
+
393
if (onSettingsUpdated != null) {
394
agent.addListener('updateHookSettings', onSettingsUpdated);
395
}