Skip to content

Commit 2bf29ce

Browse files
committed
refactor[react-devtools]: remove browserTheme from ConsolePatchSettings
1 parent 09a7a6a commit 2bf29ce

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
@@ -22,7 +22,7 @@ import {
2222
ANSI_STYLE_DIMMING_TEMPLATE,
2323
ANSI_STYLE_DIMMING_TEMPLATE_WITH_COMPONENT_STACK,
2424
} from 'react-devtools-shared/src/constants';
25-
import {castBool, castBrowserTheme} from '../utils';
25+
import {castBool} from '../utils';
2626

2727
const OVERRIDE_CONSOLE_METHODS = ['error', 'trace', 'warn'];
2828

@@ -124,7 +124,6 @@ const consoleSettingsRef: ConsolePatchSettings = {
124124
breakOnConsoleErrors: false,
125125
showInlineWarningsAndErrors: false,
126126
hideConsoleLogsInStrictMode: false,
127-
browserTheme: 'dark',
128127
};
129128

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

147144
if (
148145
appendComponentStack ||
@@ -402,15 +399,12 @@ export function patchConsoleUsingWindowValues() {
402399
const hideConsoleLogsInStrictMode =
403400
castBool(window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__) ??
404401
false;
405-
const browserTheme =
406-
castBrowserTheme(window.__REACT_DEVTOOLS_BROWSER_THEME__) ?? 'dark';
407402

408403
patch({
409404
appendComponentStack,
410405
breakOnConsoleErrors,
411406
showInlineWarningsAndErrors,
412407
hideConsoleLogsInStrictMode,
413-
browserTheme,
414408
});
415409
}
416410

@@ -428,7 +422,6 @@ export function writeConsolePatchSettingsToWindow(
428422
settings.showInlineWarningsAndErrors;
429423
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
430424
settings.hideConsoleLogsInStrictMode;
431-
window.__REACT_DEVTOOLS_BROWSER_THEME__ = settings.browserTheme;
432425
}
433426

434427
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';
@@ -532,17 +531,12 @@ export type DevToolsHook = {
532531
...
533532
};
534533

535-
export type ConsolePatchSettings = {
536-
appendComponentStack: boolean,
537-
breakOnConsoleErrors: boolean,
538-
showInlineWarningsAndErrors: boolean,
539-
hideConsoleLogsInStrictMode: boolean,
540-
browserTheme: BrowserTheme,
541-
};
542-
543534
export type DevToolsHookSettings = {
544535
appendComponentStack: boolean,
545536
breakOnConsoleErrors: boolean,
546537
showInlineWarningsAndErrors: boolean,
547538
hideConsoleLogsInStrictMode: boolean,
548539
};
540+
541+
// Will be removed together with console patching from backend/console.js to hook.js
542+
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)