Skip to content

Commit 1cd3fec

Browse files
committed
refactor[react-devtools]: remove browserTheme from ConsolePatchSettings
1 parent 2c3f705 commit 1cd3fec

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import type {ConsolePatchSettings} from 'react-devtools-shared/src/backend/types';
1111
import {writeConsolePatchSettingsToWindow} from 'react-devtools-shared/src/backend/console';
12-
import {castBool, castBrowserTheme} from 'react-devtools-shared/src/utils';
12+
import {castBool} from 'react-devtools-shared/src/utils';
1313

1414
// Note: all keys should be optional in this type, because users can use newer
1515
// versions of React DevTools with older versions of React Native, and the object
@@ -54,14 +54,13 @@ function parseConsolePatchSettings(
5454
breakOnConsoleErrors,
5555
showInlineWarningsAndErrors,
5656
hideConsoleLogsInStrictMode,
57-
browserTheme,
5857
} = parsedValue;
58+
5959
return {
6060
appendComponentStack: castBool(appendComponentStack) ?? true,
6161
breakOnConsoleErrors: castBool(breakOnConsoleErrors) ?? false,
6262
showInlineWarningsAndErrors: castBool(showInlineWarningsAndErrors) ?? true,
6363
hideConsoleLogsInStrictMode: castBool(hideConsoleLogsInStrictMode) ?? false,
64-
browserTheme: castBrowserTheme(browserTheme) ?? 'dark',
6564
};
6665
}
6766

packages/react-devtools-extensions/src/main/syncSavedPreferences.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
getShowInlineWarningsAndErrors,
88
getHideConsoleLogsInStrictMode,
99
} from 'react-devtools-shared/src/utils';
10-
import {getBrowserTheme} from 'react-devtools-extensions/src/utils';
1110

1211
// The renderer interface can't read saved component filters directly,
1312
// because they are stored in localStorage within the context of the extension.
@@ -28,9 +27,6 @@ function syncSavedPreferences() {
2827
)};
2928
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ = ${JSON.stringify(
3029
getHideConsoleLogsInStrictMode(),
31-
)};
32-
window.__REACT_DEVTOOLS_BROWSER_THEME__ = ${JSON.stringify(
33-
getBrowserTheme(),
3430
)};`,
3531
);
3632
}

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
ANSI_STYLE_DIMMING_TEMPLATE,
1919
ANSI_STYLE_DIMMING_TEMPLATE_WITH_COMPONENT_STACK,
2020
} from 'react-devtools-shared/src/constants';
21-
import {castBool, castBrowserTheme} from '../utils';
21+
import {castBool} from '../utils';
2222

2323
const OVERRIDE_CONSOLE_METHODS = ['error', 'trace', 'warn'];
2424

@@ -125,7 +125,6 @@ const consoleSettingsRef: ConsolePatchSettings = {
125125
breakOnConsoleErrors: false,
126126
showInlineWarningsAndErrors: false,
127127
hideConsoleLogsInStrictMode: false,
128-
browserTheme: 'dark',
129128
};
130129

131130
// Patches console methods to append component stack for the current fiber.
@@ -135,15 +134,13 @@ export function patch({
135134
breakOnConsoleErrors,
136135
showInlineWarningsAndErrors,
137136
hideConsoleLogsInStrictMode,
138-
browserTheme,
139137
}: $ReadOnly<ConsolePatchSettings>): void {
140138
// Settings may change after we've patched the console.
141139
// Using a shared ref allows the patch function to read the latest values.
142140
consoleSettingsRef.appendComponentStack = appendComponentStack;
143141
consoleSettingsRef.breakOnConsoleErrors = breakOnConsoleErrors;
144142
consoleSettingsRef.showInlineWarningsAndErrors = showInlineWarningsAndErrors;
145143
consoleSettingsRef.hideConsoleLogsInStrictMode = hideConsoleLogsInStrictMode;
146-
consoleSettingsRef.browserTheme = browserTheme;
147144

148145
if (
149146
appendComponentStack ||
@@ -403,15 +400,12 @@ export function patchConsoleUsingWindowValues() {
403400
const hideConsoleLogsInStrictMode =
404401
castBool(window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__) ??
405402
false;
406-
const browserTheme =
407-
castBrowserTheme(window.__REACT_DEVTOOLS_BROWSER_THEME__) ?? 'dark';
408403

409404
patch({
410405
appendComponentStack,
411406
breakOnConsoleErrors,
412407
showInlineWarningsAndErrors,
413408
hideConsoleLogsInStrictMode,
414-
browserTheme,
415409
});
416410
}
417411

@@ -429,7 +423,6 @@ export function writeConsolePatchSettingsToWindow(
429423
settings.showInlineWarningsAndErrors;
430424
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
431425
settings.hideConsoleLogsInStrictMode;
432-
window.__REACT_DEVTOOLS_BROWSER_THEME__ = settings.browserTheme;
433426
}
434427

435428
export function installConsoleFunctionsToWindow(): void {

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import type {
3131
} from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
3232
import type {InitBackend} from 'react-devtools-shared/src/backend';
3333
import type {TimelineDataExport} from 'react-devtools-timeline/src/types';
34-
import type {BrowserTheme} from 'react-devtools-shared/src/frontend/types';
3534
import type {BackendBridge} from 'react-devtools-shared/src/bridge';
3635
import type {Source} from 'react-devtools-shared/src/shared/types';
3736
import type Agent from './agent';
@@ -522,17 +521,12 @@ export type DevToolsHook = {
522521
...
523522
};
524523

525-
export type ConsolePatchSettings = {
526-
appendComponentStack: boolean,
527-
breakOnConsoleErrors: boolean,
528-
showInlineWarningsAndErrors: boolean,
529-
hideConsoleLogsInStrictMode: boolean,
530-
browserTheme: BrowserTheme,
531-
};
532-
533524
export type DevToolsHookSettings = {
534525
appendComponentStack: boolean,
535526
breakOnConsoleErrors: boolean,
536527
showInlineWarningsAndErrors: boolean,
537528
hideConsoleLogsInStrictMode: boolean,
538529
};
530+
531+
// Will be removed together with console patching from backend/console.js to hook.js
532+
export type ConsolePatchSettings = DevToolsHookSettings;

packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,13 @@ function SettingsContextController({
202202
breakOnConsoleErrors,
203203
showInlineWarningsAndErrors,
204204
hideConsoleLogsInStrictMode,
205-
browserTheme,
206205
});
207206
}, [
208207
bridge,
209208
appendComponentStack,
210209
breakOnConsoleErrors,
211210
showInlineWarningsAndErrors,
212211
hideConsoleLogsInStrictMode,
213-
browserTheme,
214212
]);
215213

216214
useEffect(() => {

0 commit comments

Comments
 (0)