mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
chore: remove using local storage for persisting console settings on the frontend (#31002)
After https://github.com/facebook/react/pull/30636 and https://github.com/facebook/react/pull/30986 we no longer store settings on the Frontend side via `localStorage`. This PR removes all occurrences of it from `react-devtools-core/standalone` and `react-devtools-inline`.
This commit is contained in:
parent
c21ce4a396
commit
e740d4b14b
20
packages/react-devtools-core/src/standalone.js
vendored
20
packages/react-devtools-core/src/standalone.js
vendored
|
|
@ -12,13 +12,7 @@ import {flushSync} from 'react-dom';
|
|||
import {createRoot} from 'react-dom/client';
|
||||
import Bridge from 'react-devtools-shared/src/bridge';
|
||||
import Store from 'react-devtools-shared/src/devtools/store';
|
||||
import {
|
||||
getAppendComponentStack,
|
||||
getBreakOnConsoleErrors,
|
||||
getSavedComponentFilters,
|
||||
getShowInlineWarningsAndErrors,
|
||||
getHideConsoleLogsInStrictMode,
|
||||
} from 'react-devtools-shared/src/utils';
|
||||
import {getSavedComponentFilters} from 'react-devtools-shared/src/utils';
|
||||
import {registerDevToolsEventLogger} from 'react-devtools-shared/src/registerDevToolsEventLogger';
|
||||
import {Server} from 'ws';
|
||||
import {join} from 'path';
|
||||
|
|
@ -368,20 +362,8 @@ function startServer(
|
|||
// Because of this it relies on the extension to pass filters, so include them wth the response here.
|
||||
// This will ensure that saved filters are shared across different web pages.
|
||||
const savedPreferencesString = `
|
||||
window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = ${JSON.stringify(
|
||||
getAppendComponentStack(),
|
||||
)};
|
||||
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = ${JSON.stringify(
|
||||
getBreakOnConsoleErrors(),
|
||||
)};
|
||||
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = ${JSON.stringify(
|
||||
getSavedComponentFilters(),
|
||||
)};
|
||||
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = ${JSON.stringify(
|
||||
getShowInlineWarningsAndErrors(),
|
||||
)};
|
||||
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ = ${JSON.stringify(
|
||||
getHideConsoleLogsInStrictMode(),
|
||||
)};`;
|
||||
|
||||
response.end(
|
||||
|
|
|
|||
12
packages/react-devtools-inline/src/frontend.js
vendored
12
packages/react-devtools-inline/src/frontend.js
vendored
|
|
@ -5,13 +5,7 @@ import {forwardRef} from 'react';
|
|||
import Bridge from 'react-devtools-shared/src/bridge';
|
||||
import Store from 'react-devtools-shared/src/devtools/store';
|
||||
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';
|
||||
import {
|
||||
getAppendComponentStack,
|
||||
getBreakOnConsoleErrors,
|
||||
getSavedComponentFilters,
|
||||
getShowInlineWarningsAndErrors,
|
||||
getHideConsoleLogsInStrictMode,
|
||||
} from 'react-devtools-shared/src/utils';
|
||||
import {getSavedComponentFilters} from 'react-devtools-shared/src/utils';
|
||||
|
||||
import type {Wall} from 'react-devtools-shared/src/frontend/types';
|
||||
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
|
||||
|
|
@ -76,11 +70,7 @@ export function initialize(
|
|||
frontendBridge.removeListener('getSavedPreferences', onGetSavedPreferences);
|
||||
|
||||
const data = {
|
||||
appendComponentStack: getAppendComponentStack(),
|
||||
breakOnConsoleErrors: getBreakOnConsoleErrors(),
|
||||
componentFilters: getSavedComponentFilters(),
|
||||
showInlineWarningsAndErrors: getShowInlineWarningsAndErrors(),
|
||||
hideConsoleLogsInStrictMode: getHideConsoleLogsInStrictMode(),
|
||||
};
|
||||
|
||||
// The renderer interface can't read saved preferences directly,
|
||||
|
|
|
|||
4
packages/react-devtools-shared/src/bridge.js
vendored
4
packages/react-devtools-shared/src/bridge.js
vendored
|
|
@ -170,11 +170,7 @@ type NativeStyleEditor_SetValueParams = {
|
|||
};
|
||||
|
||||
type SavedPreferencesParams = {
|
||||
appendComponentStack: boolean,
|
||||
breakOnConsoleErrors: boolean,
|
||||
componentFilters: Array<ComponentFilter>,
|
||||
showInlineWarningsAndErrors: boolean,
|
||||
hideConsoleLogsInStrictMode: boolean,
|
||||
};
|
||||
|
||||
export type BackendEvents = {
|
||||
|
|
|
|||
|
|
@ -43,17 +43,9 @@ export const SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY =
|
|||
'React::DevTools::recordChangeDescriptions';
|
||||
export const SESSION_STORAGE_RELOAD_AND_PROFILE_KEY =
|
||||
'React::DevTools::reloadAndProfile';
|
||||
export const LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS =
|
||||
'React::DevTools::breakOnConsoleErrors';
|
||||
export const LOCAL_STORAGE_BROWSER_THEME = 'React::DevTools::theme';
|
||||
export const LOCAL_STORAGE_SHOULD_APPEND_COMPONENT_STACK_KEY =
|
||||
'React::DevTools::appendComponentStack';
|
||||
export const LOCAL_STORAGE_SHOW_INLINE_WARNINGS_AND_ERRORS_KEY =
|
||||
'React::DevTools::showInlineWarningsAndErrors';
|
||||
export const LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY =
|
||||
'React::DevTools::traceUpdatesEnabled';
|
||||
export const LOCAL_STORAGE_HIDE_CONSOLE_LOGS_IN_STRICT_MODE =
|
||||
'React::DevTools::hideConsoleLogsInStrictMode';
|
||||
export const LOCAL_STORAGE_SUPPORTS_PROFILING_KEY =
|
||||
'React::DevTools::supportsProfiling';
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import type {FrontendBridge} from '../../../bridge';
|
|||
import type {DevToolsHookSettings} from '../../../backend/types';
|
||||
import type Store from '../../store';
|
||||
|
||||
export type DisplayDensity = 'comfortable' | 'compact';
|
||||
export type Theme = 'auto' | 'light' | 'dark';
|
||||
|
||||
type Context = {
|
||||
|
|
|
|||
52
packages/react-devtools-shared/src/utils.js
vendored
52
packages/react-devtools-shared/src/utils.js
vendored
|
|
@ -36,10 +36,6 @@ import {
|
|||
TREE_OPERATION_UPDATE_TREE_BASE_DURATION,
|
||||
LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY,
|
||||
LOCAL_STORAGE_OPEN_IN_EDITOR_URL,
|
||||
LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS,
|
||||
LOCAL_STORAGE_SHOULD_APPEND_COMPONENT_STACK_KEY,
|
||||
LOCAL_STORAGE_SHOW_INLINE_WARNINGS_AND_ERRORS_KEY,
|
||||
LOCAL_STORAGE_HIDE_CONSOLE_LOGS_IN_STRICT_MODE,
|
||||
} from './constants';
|
||||
import {
|
||||
ComponentFilterElementType,
|
||||
|
|
@ -61,7 +57,6 @@ import isArray from './isArray';
|
|||
import type {
|
||||
ComponentFilter,
|
||||
ElementType,
|
||||
BrowserTheme,
|
||||
SerializedElement as SerializedElementFrontend,
|
||||
LRUCache,
|
||||
} from 'react-devtools-shared/src/frontend/types';
|
||||
|
|
@ -374,53 +369,6 @@ export function filterOutLocationComponentFilters(
|
|||
return componentFilters.filter(f => f.type !== ComponentFilterLocation);
|
||||
}
|
||||
|
||||
function parseBool(s: ?string): ?boolean {
|
||||
if (s === 'true') {
|
||||
return true;
|
||||
}
|
||||
if (s === 'false') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function castBool(v: any): ?boolean {
|
||||
if (v === true || v === false) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
export function castBrowserTheme(v: any): ?BrowserTheme {
|
||||
if (v === 'light' || v === 'dark' || v === 'auto') {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAppendComponentStack(): boolean {
|
||||
const raw = localStorageGetItem(
|
||||
LOCAL_STORAGE_SHOULD_APPEND_COMPONENT_STACK_KEY,
|
||||
);
|
||||
return parseBool(raw) ?? true;
|
||||
}
|
||||
|
||||
export function getBreakOnConsoleErrors(): boolean {
|
||||
const raw = localStorageGetItem(LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS);
|
||||
return parseBool(raw) ?? false;
|
||||
}
|
||||
|
||||
export function getHideConsoleLogsInStrictMode(): boolean {
|
||||
const raw = localStorageGetItem(
|
||||
LOCAL_STORAGE_HIDE_CONSOLE_LOGS_IN_STRICT_MODE,
|
||||
);
|
||||
return parseBool(raw) ?? false;
|
||||
}
|
||||
|
||||
export function getShowInlineWarningsAndErrors(): boolean {
|
||||
const raw = localStorageGetItem(
|
||||
LOCAL_STORAGE_SHOW_INLINE_WARNINGS_AND_ERRORS_KEY,
|
||||
);
|
||||
return parseBool(raw) ?? true;
|
||||
}
|
||||
|
||||
export function getDefaultOpenInEditorURL(): string {
|
||||
return typeof process.env.EDITOR_URL === 'string'
|
||||
? process.env.EDITOR_URL
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user