diff --git a/packages/react-devtools-extensions/src/backend.js b/packages/react-devtools-extensions/src/backend.js index a506c590d2f04..7cf684365f95c 100644 --- a/packages/react-devtools-extensions/src/backend.js +++ b/packages/react-devtools-extensions/src/backend.js @@ -24,9 +24,9 @@ function setup(hook: ?DevToolsHook) { return; } - const bridge = new Bridge({ + const bridge = new Bridge({ listen(fn) { - const listener = event => { + const listener = (event: any) => { if ( event.source !== window || !event.data || @@ -42,7 +42,7 @@ function setup(hook: ?DevToolsHook) { window.removeEventListener('message', listener); }; }, - send(event, payload, transferable) { + send(event: string, payload: any, transferable: any) { window.postMessage( { source: 'react-devtools-bridge', diff --git a/packages/react-devtools-extensions/src/utils.js b/packages/react-devtools-extensions/src/utils.js index 889af3df43454..117d85ebc3f15 100644 --- a/packages/react-devtools-extensions/src/utils.js +++ b/packages/react-devtools-extensions/src/utils.js @@ -1,6 +1,6 @@ -/* global chrome */ +// /* global chrome */ -import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools'; +// import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools'; // REPLAY Our RDT integration is only for Chrome currently export const IS_EDGE = false; // navigator.userAgent.indexOf('Edg') >= 0; diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js index 6383f022624ca..0eadb63cd3271 100644 --- a/packages/react-devtools-shared/src/backend/agent.js +++ b/packages/react-devtools-shared/src/backend/agent.js @@ -206,7 +206,7 @@ export default class Agent extends EventEmitter<{ // Notify the frontend if the backend supports the Storage API (e.g. localStorage). // If not, features like reload-and-profile will not work correctly and must be disabled. - let isBackendStorageAPISupported = false; + const isBackendStorageAPISupported = false; bridge.send('isBackendStorageAPISupported', isBackendStorageAPISupported); bridge.send('isSynchronousXHRSupported', isSynchronousXHRSupported()); @@ -216,11 +216,11 @@ export default class Agent extends EventEmitter<{ inData, ) => { let rv; - this._bridge = { + this._bridge = ({ send(event, data) { rv = {event, data}; }, - }; + }: any); try { this[inEvent](inData); } catch (err) { diff --git a/packages/react-devtools-shared/src/backend/console.js b/packages/react-devtools-shared/src/backend/console.js index e1b98b9190129..c2ce574991abf 100644 --- a/packages/react-devtools-shared/src/backend/console.js +++ b/packages/react-devtools-shared/src/backend/console.js @@ -136,7 +136,11 @@ export function registerRenderer( // currentDispatcherRef gets injected for v16.8+ to support hooks inspection. // getCurrentFiber gets injected for v16.9+. if (currentDispatcherRef != null && typeof getCurrentFiber === 'function') { - const {ReactTypeOfWork} = getInternalReactConstants(version); + const {ReactTypeOfWork} = getInternalReactConstants( + version, + // REPLAY Our fork will never run this code anyway, make Flow happy + () => 0, + ); injectedRenderers.set(renderer, { currentDispatcherRef, diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index c32a968bf9875..bff10da6dfb4a 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -63,7 +63,7 @@ import { TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS, TREE_OPERATION_UPDATE_TREE_BASE_DURATION, } from '../constants'; -import {HooksNode, inspectHooksOfFiber} from 'react-debug-tools'; +import {inspectHooksOfFiber} from 'react-debug-tools'; import { patchConsoleUsingWindowValues, registerRenderer as registerRendererWithConsole, @@ -96,8 +96,7 @@ import is from 'shared/objectIs'; import hasOwnProperty from 'shared/hasOwnProperty'; // REPLAY Not doing any profiling work for the foreseeable future, disable this // import {createProfilingHooks} from './profilingHooks'; - -import type {GetTimelineData, ToggleProfilingStatus} from './profilingHooks'; +import type {ToggleProfilingStatus} from './profilingHooks'; import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import type { ChangeDescription, @@ -736,7 +735,6 @@ export function attach( } = ReactPriorityLevels; const { - getLaneLabelMap, injectProfilingHooks, overrideHookState, overrideHookStateDeletePath, @@ -772,11 +770,12 @@ export function attach( }; } - let getTimelineData: null | GetTimelineData = null; - let toggleProfilingStatus: null | ToggleProfilingStatus = null; - + const toggleProfilingStatus: null | ToggleProfilingStatus = null; // REPLAY Not doing any profiling work for the foreseeable future, disable this /* + let getTimelineData: null | GetTimelineData = null; + + if (typeof injectProfilingHooks === 'function') { const response = createProfilingHooks({ getDisplayNameForFiber, @@ -2485,7 +2484,7 @@ export function attach( if ( mostRecentlyInspectedElement !== null && mostRecentlyInspectedElement.id === id && - fiberRenderered + fiberRendered ) { // If this Fiber has updated, clear cached inspected data. // If it is inspected again, it may need to be re-run to obtain updated hooks values. @@ -3925,6 +3924,7 @@ export function attach( prevFiber.memoizedState, fiber.memoizedState, ); + // eslint-disable-next-line eqeqeq return indices == null || indices.length == 0 ? [] : indices; } return []; @@ -4318,7 +4318,7 @@ export function attach( }, ); - let timelineData: null = null; + const timelineData: null = null; // REPLAY Not doing any profiling work for the foreseeable future, disable this /* @@ -4833,7 +4833,6 @@ export function attach( setTrackedPath, shouldFilterFiber, startProfiling, - shouldFilterFiber, stopProfiling, storeAsGlobal, unpatchConsoleForStrictMode, diff --git a/packages/react-devtools-shared/src/devtools/store.js b/packages/react-devtools-shared/src/devtools/store.js index 410f90a5008d6..8649330e77afd 100644 --- a/packages/react-devtools-shared/src/devtools/store.js +++ b/packages/react-devtools-shared/src/devtools/store.js @@ -60,10 +60,10 @@ const debug = (methodName: string, ...args: Array) => { } }; -const LOCAL_STORAGE_COLLAPSE_ROOTS_BY_DEFAULT_KEY = - 'React::DevTools::collapseNodesByDefault'; -const LOCAL_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY = - 'React::DevTools::recordChangeDescriptions'; +// const LOCAL_STORAGE_COLLAPSE_ROOTS_BY_DEFAULT_KEY = +// 'React::DevTools::collapseNodesByDefault'; +// const LOCAL_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY = +// 'React::DevTools::recordChangeDescriptions'; type ErrorAndWarningTuples = Array<{id: number, index: number}>; diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js index b675a23a45ec4..638cf24f09a6b 100644 --- a/packages/react-devtools-shared/src/utils.js +++ b/packages/react-devtools-shared/src/utils.js @@ -48,12 +48,12 @@ import { TREE_OPERATION_SET_SUBTREE_MODE, TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS, 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, + // 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, @@ -390,14 +390,14 @@ 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; - } -} +// 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) {