Skip to content

Commit 46ec66f

Browse files
committed
refactor[react-devtools]: move console patching to global hook
1 parent 1fcf116 commit 46ec66f

File tree

10 files changed

+266
-587
lines changed

10 files changed

+266
-587
lines changed

packages/react-devtools-core/src/backend.js

-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Agent from 'react-devtools-shared/src/backend/agent';
1111
import Bridge from 'react-devtools-shared/src/bridge';
1212
import {installHook} from 'react-devtools-shared/src/hook';
1313
import {initBackend} from 'react-devtools-shared/src/backend';
14-
import {installConsoleFunctionsToWindow} from 'react-devtools-shared/src/backend/console';
1514
import {__DEBUG__} from 'react-devtools-shared/src/constants';
1615
import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
1716
import {getDefaultComponentFilters} from 'react-devtools-shared/src/utils';
@@ -41,9 +40,6 @@ type ConnectOptions = {
4140
devToolsSettingsManager: ?DevToolsSettingsManager,
4241
};
4342

44-
// Install a global variable to allow patching console early (during injection).
45-
// This provides React Native developers with components stacks even if they don't run DevTools.
46-
installConsoleFunctionsToWindow();
4743
installHook(window);
4844

4945
const hook: ?DevToolsHook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;

packages/react-devtools-inline/src/backend.js

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import Agent from 'react-devtools-shared/src/backend/agent';
44
import Bridge from 'react-devtools-shared/src/bridge';
55
import {initBackend} from 'react-devtools-shared/src/backend';
6-
import {installConsoleFunctionsToWindow} from 'react-devtools-shared/src/backend/console';
76
import {installHook} from 'react-devtools-shared/src/hook';
87
import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
98

@@ -120,8 +119,5 @@ export function createBridge(contentWindow: any, wall?: Wall): BackendBridge {
120119
}
121120

122121
export function initialize(contentWindow: any): void {
123-
// Install a global variable to allow patching console early (during injection).
124-
// This provides React Native developers with components stacks even if they don't run DevTools.
125-
installConsoleFunctionsToWindow();
126122
installHook(contentWindow);
127123
}

packages/react-devtools-shared/src/backend/agent.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
initialize as setupTraceUpdates,
2525
toggleEnabled as setTraceUpdatesEnabled,
2626
} from './views/TraceUpdates';
27-
import {patch as patchConsole} from './console';
2827
import {currentBridgeProtocol} from 'react-devtools-shared/src/bridge';
2928

3029
import type {BackendBridge} from 'react-devtools-shared/src/bridge';
@@ -36,7 +35,6 @@ import type {
3635
PathMatch,
3736
RendererID,
3837
RendererInterface,
39-
ConsolePatchSettings,
4038
DevToolsHookSettings,
4139
} from './types';
4240
import type {ComponentFilter} from 'react-devtools-shared/src/frontend/types';
@@ -805,7 +803,7 @@ export default class Agent extends EventEmitter<{
805803
};
806804

807805
updateConsolePatchSettings: (
808-
settings: $ReadOnly<ConsolePatchSettings>,
806+
settings: $ReadOnly<DevToolsHookSettings>,
809807
) => void = settings => {
810808
// Propagate the settings, so Backend can subscribe to it and modify hook
811809
this.emit('updateHookSettings', {
@@ -814,12 +812,6 @@ export default class Agent extends EventEmitter<{
814812
showInlineWarningsAndErrors: settings.showInlineWarningsAndErrors,
815813
hideConsoleLogsInStrictMode: settings.hideConsoleLogsInStrictMode,
816814
});
817-
818-
// If the frontend preferences have changed,
819-
// or in the case of React Native- if the backend is just finding out the preferences-
820-
// then reinstall the console overrides.
821-
// It's safe to call `patchConsole` multiple times.
822-
patchConsole(settings);
823815
};
824816

825817
updateComponentFilters: (componentFilters: Array<ComponentFilter>) => void =

0 commit comments

Comments
 (0)