Skip to content

Commit db43837

Browse files
committed
refactor[react-devtools]: remove browserTheme from ConsolePatchSettings
1 parent 24e529b commit db43837

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
@@ -33,7 +33,7 @@ import {
3333
supportsConsoleTasks,
3434
} from './fiber/DevToolsFiberComponentStack';
3535
import {formatOwnerStack} from './shared/DevToolsOwnerStack';
36-
import {castBool, castBrowserTheme} from '../utils';
36+
import {castBool} from '../utils';
3737

3838
const OVERRIDE_CONSOLE_METHODS = ['error', 'trace', 'warn'];
3939

@@ -166,7 +166,6 @@ const consoleSettingsRef: ConsolePatchSettings = {
166166
breakOnConsoleErrors: false,
167167
showInlineWarningsAndErrors: false,
168168
hideConsoleLogsInStrictMode: false,
169-
browserTheme: 'dark',
170169
};
171170

172171
// Patches console methods to append component stack for the current fiber.
@@ -176,15 +175,13 @@ export function patch({
176175
breakOnConsoleErrors,
177176
showInlineWarningsAndErrors,
178177
hideConsoleLogsInStrictMode,
179-
browserTheme,
180178
}: $ReadOnly<ConsolePatchSettings>): void {
181179
// Settings may change after we've patched the console.
182180
// Using a shared ref allows the patch function to read the latest values.
183181
consoleSettingsRef.appendComponentStack = appendComponentStack;
184182
consoleSettingsRef.breakOnConsoleErrors = breakOnConsoleErrors;
185183
consoleSettingsRef.showInlineWarningsAndErrors = showInlineWarningsAndErrors;
186184
consoleSettingsRef.hideConsoleLogsInStrictMode = hideConsoleLogsInStrictMode;
187-
consoleSettingsRef.browserTheme = browserTheme;
188185

189186
if (
190187
appendComponentStack ||
@@ -459,15 +456,12 @@ export function patchConsoleUsingWindowValues() {
459456
const hideConsoleLogsInStrictMode =
460457
castBool(window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__) ??
461458
false;
462-
const browserTheme =
463-
castBrowserTheme(window.__REACT_DEVTOOLS_BROWSER_THEME__) ?? 'dark';
464459

465460
patch({
466461
appendComponentStack,
467462
breakOnConsoleErrors,
468463
showInlineWarningsAndErrors,
469464
hideConsoleLogsInStrictMode,
470-
browserTheme,
471465
});
472466
}
473467

@@ -485,7 +479,6 @@ export function writeConsolePatchSettingsToWindow(
485479
settings.showInlineWarningsAndErrors;
486480
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
487481
settings.hideConsoleLogsInStrictMode;
488-
window.__REACT_DEVTOOLS_BROWSER_THEME__ = settings.browserTheme;
489482
}
490483

491484
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
@@ -27,7 +27,6 @@ import type {
2727
} from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
2828
import type {InitBackend} from 'react-devtools-shared/src/backend';
2929
import type {TimelineDataExport} from 'react-devtools-timeline/src/types';
30-
import type {BrowserTheme} from 'react-devtools-shared/src/frontend/types';
3130
import type {BackendBridge} from 'react-devtools-shared/src/bridge';
3231
import type {Source} from 'react-devtools-shared/src/shared/types';
3332
import type Agent from './agent';
@@ -517,17 +516,12 @@ export type DevToolsHook = {
517516
...
518517
};
519518

520-
export type ConsolePatchSettings = {
521-
appendComponentStack: boolean,
522-
breakOnConsoleErrors: boolean,
523-
showInlineWarningsAndErrors: boolean,
524-
hideConsoleLogsInStrictMode: boolean,
525-
browserTheme: BrowserTheme,
526-
};
527-
528519
export type DevToolsHookSettings = {
529520
appendComponentStack: boolean,
530521
breakOnConsoleErrors: boolean,
531522
showInlineWarningsAndErrors: boolean,
532523
hideConsoleLogsInStrictMode: boolean,
533524
};
525+
526+
// Will be removed together with console patching from backend/console.js to hook.js
527+
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)