@samitouri / QOS-React / commits / 74cd1a5d29

Misc cleanup of comments and localStorage key names

Brian Vaughn committed Apr 1, 2019 at 09:05 UTC 74cd1a5d29dc670788ac2955495150f57d911db7
6 files changed +17 -17
shells/browser/shared/src/renderer.js
+5 -4
@@ -1,8 +1,9 @@
1 /**
2 - * Install the hook on window, which is an event emitter.
3 - * Note because Chrome content scripts cannot directly modify the window object,
4 - * we are evaling this function by inserting a script tag.
5 - * That's why we have to inline the whole event emitter implementation here.
2 + * In order to support reload-and-profile functionality, the renderer needs to be injected before any other scripts.
3 + * Since it is a complex file (with imports) we can't just toString() it like we do with the hook itself,
4 + * So this entry point (one of the web_accessible_resources) provcides a way to eagerly inject it.
5 + * The hook will look for the presence of a global __REACT_DEVTOOLS_ATTACH__ and attach an injected renderer early.
6 + * The normal case (not a reload-and-profile) will not make use of this entry point though.
7 *
8 * @flow
9 */
src/backend/index.js
+2 -1
@@ -42,7 +42,8 @@ export function initBackend(
42 hook.rendererInterfaces.set(id, rendererInterface);
43 }
44
45 - // Notify the DevTools frontend about any renderers that were attached early.
45 + // Notify the DevTools frontend about new renderers.
46 + // This includes any that were attached early (via __REACT_DEVTOOLS_ATTACH__).
47 hook.emit('renderer-attached', {
48 id,
49 renderer,
src/backend/renderer.js
+2 -1
@@ -18,6 +18,7 @@ import { getDisplayName, utfEncodeString } from '../utils';
18 import { cleanForBridge, copyWithSet, setInObject } from './utils';
19 import {
20 __DEBUG__,
21 + RELOAD_AND_PROFILE_KEY,
22 TREE_OPERATION_ADD,
23 TREE_OPERATION_REMOVE,
24 TREE_OPERATION_RESET_CHILDREN,
@@ -1616,7 +1617,7 @@ export function attach(
1617 }
1618
1619 // Automatically start profiling so that we don't miss timing info from initial "mount".
1619 - if (localStorage.getItem('React::DevTools::reloadAndProfile') === 'true') {
1620 + if (localStorage.getItem(RELOAD_AND_PROFILE_KEY) === 'true') {
1621 startProfiling();
1622 }
1623
src/devtools/views/Profiler/ProfilerContext.js
+1 -1
@@ -130,7 +130,7 @@ function ProfilerContextController({ children }: Props) {
130 const [
131 isCommitFilterEnabled,
132 setIsCommitFilterEnabled,
133 - ] = useLocalStorage<boolean>('isCommitFilterEnabled', false);
133 + ] = useLocalStorage<boolean>('React::DevTools::isCommitFilterEnabled', false);
134 const [minCommitDuration, setMinCommitDuration] = useLocalStorage<number>(
135 'minCommitDuration',
136 0
src/devtools/views/Settings/SettingsContext.js
+5 -2
@@ -41,10 +41,13 @@ function SettingsContextController({
41 settingsPortalContainer,
42 }: Props) {
43 const [displayDensity, setDisplayDensity] = useLocalStorage<DisplayDensity>(
44 - 'displayDensity',
44 + 'React::DevTools::displayDensity',
45 'compact'
46 );
47 - const [theme, setTheme] = useLocalStorage<Theme>('theme', 'auto');
47 + const [theme, setTheme] = useLocalStorage<Theme>(
48 + 'React::DevTools::theme',
49 + 'auto'
50 + );
51
52 const documentElements = useMemo<DocumentElements>(() => {
53 const array: Array<HTMLElement> = [
src/hook.js
+2 -8
@@ -77,22 +77,16 @@ export function installHook(target: any): DevToolsHook | null {
77 ? 'deadcode'
78 : detectReactBuildType(renderer);
79
80 - hook.emit('renderer', { id, renderer, reactBuildType });
81 -
80 // If we have just reloaded to profile, we need to inject the renderer interface before the app loads.
81 // Otherwise the renderer won't yet exist and we can skip this step.
82 const attach = target.__REACT_DEVTOOLS_ATTACH__;
83 if (typeof attach === 'function') {
84 const rendererInterface = attach(hook, id, renderer, target);
85 hook.rendererInterfaces.set(id, rendererInterface);
88 -
89 - /*hook.emit('renderer-attached', {
90 - id,
91 - renderer,
92 - rendererInterface,
93 - });*/
86 }
87
88 + hook.emit('renderer', { id, renderer, reactBuildType });
89 +
90 return id;
91 }
92