Skip to content

Commit b521ef8

Browse files
authored
refactor[react-devtools]: remove browserTheme from ConsolePatchSettings (#30566)
Stacked on #30564. We are no longer using browser theme in our console patching, this was removed in unification of console patching for strict mode, we started using ansi escape symbols and forking based on browser theme is no longer required - #29869 The real browser theme initialization for frontend is happening at the other place and is not affected: https://github.com/facebook/react/blob/40be968257a7a10a267210670103f20dd0429ef3/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js#L117-L120
1 parent 5e83d9a commit b521ef8

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 ||
@@ -412,15 +409,12 @@ export function patchConsoleUsingWindowValues() {
412409
const hideConsoleLogsInStrictMode =
413410
castBool(window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__) ??
414411
false;
415-
const browserTheme =
416-
castBrowserTheme(window.__REACT_DEVTOOLS_BROWSER_THEME__) ?? 'dark';
417412

418413
patch({
419414
appendComponentStack,
420415
breakOnConsoleErrors,
421416
showInlineWarningsAndErrors,
422417
hideConsoleLogsInStrictMode,
423-
browserTheme,
424418
});
425419
}
426420

@@ -438,7 +432,6 @@ export function writeConsolePatchSettingsToWindow(
438432
settings.showInlineWarningsAndErrors;
439433
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
440434
settings.hideConsoleLogsInStrictMode;
441-
window.__REACT_DEVTOOLS_BROWSER_THEME__ = settings.browserTheme;
442435
}
443436

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

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