);
- const Parent = ({ flip }) => (
+ const Parent = ({flip}) => (
);
- const Wrapper = ({ children }) => children;
+ const Wrapper = ({children}) => children;
const Leaf = () =>
, document.createElement('div')));
expect(store).toMatchSnapshot('1: mount');
const rootID = store.getElementIDAtIndex(0);
expect(
- printOwnersList(store.getOwnersListForElement(rootID))
+ printOwnersList(store.getOwnersListForElement(rootID)),
).toMatchSnapshot('2: components owned by
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -460,8 +460,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -476,8 +476,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -489,8 +489,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -515,8 +515,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -527,8 +527,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -544,8 +544,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -566,8 +566,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// We get ID from the index in the tree above:
@@ -609,8 +609,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[j]);
@@ -633,8 +633,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Fallback is still forced though.
expect(print(store)).toEqual(snapshots[j]);
@@ -689,7 +689,7 @@ describe('StoreStress (Sync Mode)', () => {
throw new Promise(() => {});
};
- const MaybeSuspend = ({ children, suspend }) => {
+ const MaybeSuspend = ({children, suspend}) => {
if (suspend) {
return (
@@ -707,7 +707,7 @@ describe('StoreStress (Sync Mode)', () => {
);
};
- const Root = ({ children }) => {
+ const Root = ({children}) => {
return children;
};
@@ -725,8 +725,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// We snapshot each step once so it doesn't regress.
expect(store).toMatchSnapshot();
@@ -751,8 +751,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// We snapshot each step once so it doesn't regress.
expect(store).toMatchSnapshot();
@@ -775,8 +775,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -789,8 +789,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -804,8 +804,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -833,8 +833,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Re-render with steps[j].
@@ -852,8 +852,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(fallbackSnapshots[j]);
@@ -872,8 +872,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Clean up after every iteration.
@@ -896,8 +896,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -910,8 +910,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(fallbackSnapshots[j]);
@@ -925,8 +925,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -949,8 +949,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Re-render with steps[j].
@@ -963,8 +963,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -978,8 +978,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Clean up after every iteration.
@@ -1002,8 +1002,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// We get ID from the index in the tree above:
@@ -1043,8 +1043,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[j]);
@@ -1069,8 +1069,8 @@ describe('StoreStress (Sync Mode)', () => {
,
- container
- )
+ container,
+ ),
);
// Fallback is still forced though.
expect(print(store)).toEqual(fallbackSnapshots[j]);
diff --git a/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js b/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js
index d2a834ca98509..f219c7f813c3c 100644
--- a/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js
+++ b/packages/react-devtools-shared/src/__tests__/storeStressTestConcurrent-test.js
@@ -43,7 +43,7 @@ describe('StoreStressConcurrent', () => {
const d =
;
const e =
;
- function Parent({ children }) {
+ function Parent({children}) {
return children;
}
@@ -201,7 +201,7 @@ describe('StoreStressConcurrent', () => {
[c, a],
];
- const Root = ({ children }) => {
+ const Root = ({children}) => {
return children;
};
@@ -246,24 +246,24 @@ describe('StoreStressConcurrent', () => {
root.render(
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toMatch(snapshots[i]);
act(() =>
root.render(
{steps[j]}
-
- )
+ ,
+ ),
);
expect(print(store)).toMatch(snapshots[j]);
act(() =>
root.render(
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toMatch(snapshots[i]);
act(() => root.unmount());
@@ -304,7 +304,7 @@ describe('StoreStressConcurrent', () => {
throw new Promise(() => {});
};
- const Root = ({ children }) => {
+ const Root = ({children}) => {
return children;
};
@@ -321,8 +321,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// We snapshot each step once so it doesn't regress.
expect(store).toMatchSnapshot();
@@ -343,8 +343,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
act(() => root.unmount());
@@ -364,8 +364,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -375,8 +375,8 @@ describe('StoreStressConcurrent', () => {
{steps[j]}
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -387,8 +387,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -414,8 +414,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -429,8 +429,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -445,8 +445,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -468,8 +468,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -483,8 +483,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -495,8 +495,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -522,8 +522,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -533,8 +533,8 @@ describe('StoreStressConcurrent', () => {
{steps[j]}
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -549,8 +549,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -572,8 +572,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// We get ID from the index in the tree above:
@@ -614,8 +614,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[j]);
@@ -637,8 +637,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// Fallback is still forced though.
expect(print(store)).toEqual(snapshots[j]);
@@ -693,7 +693,7 @@ describe('StoreStressConcurrent', () => {
throw new Promise(() => {});
};
- const MaybeSuspend = ({ children, suspend }) => {
+ const MaybeSuspend = ({children, suspend}) => {
if (suspend) {
return (
@@ -711,7 +711,7 @@ describe('StoreStressConcurrent', () => {
);
};
- const Root = ({ children }) => {
+ const Root = ({children}) => {
return children;
};
@@ -730,8 +730,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// We snapshot each step once so it doesn't regress.
expect(store).toMatchSnapshot();
@@ -755,8 +755,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
// We snapshot each step once so it doesn't regress.
expect(store).toMatchSnapshot();
@@ -780,8 +780,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -793,8 +793,8 @@ describe('StoreStressConcurrent', () => {
{steps[j]}
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -807,8 +807,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -837,8 +837,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Re-render with steps[j].
@@ -855,8 +855,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(fallbackSnapshots[j]);
@@ -874,8 +874,8 @@ describe('StoreStressConcurrent', () => {
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Clean up after every iteration.
@@ -899,8 +899,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Re-render with steps[j].
@@ -912,8 +912,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(fallbackSnapshots[j]);
@@ -926,8 +926,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(snapshots[i]);
// Clean up after every iteration.
@@ -951,8 +951,8 @@ describe('StoreStressConcurrent', () => {
{steps[j]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Re-render with steps[j].
@@ -964,8 +964,8 @@ describe('StoreStressConcurrent', () => {
{steps[j]}
-
- )
+ ,
+ ),
);
// Verify the successful transition to steps[j].
expect(print(store)).toEqual(snapshots[j]);
@@ -978,8 +978,8 @@ describe('StoreStressConcurrent', () => {
{steps[j]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[i]);
// Clean up after every iteration.
@@ -1003,8 +1003,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// We get ID from the index in the tree above:
@@ -1043,8 +1043,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
expect(print(store)).toEqual(fallbackSnapshots[j]);
@@ -1068,8 +1068,8 @@ describe('StoreStressConcurrent', () => {
{steps[i]}
-
- )
+ ,
+ ),
);
// Fallback is still forced though.
expect(print(store)).toEqual(fallbackSnapshots[j]);
diff --git a/packages/react-devtools-shared/src/__tests__/treeContext-test.js b/packages/react-devtools-shared/src/__tests__/treeContext-test.js
index e007dcf97cb36..3983b156eec27 100644
--- a/packages/react-devtools-shared/src/__tests__/treeContext-test.js
+++ b/packages/react-devtools-shared/src/__tests__/treeContext-test.js
@@ -1,7 +1,7 @@
// @flow
import typeof ReactTestRenderer from 'react-test-renderer';
-import type { FrontendBridge } from 'react-devtools-shared/src/bridge';
+import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type Store from 'react-devtools-shared/src/devtools/store';
import type {
DispatcherContext,
@@ -35,8 +35,10 @@ describe('TreeListContext', () => {
ReactDOM = require('react-dom');
TestRenderer = utils.requireTestRenderer();
- BridgeContext = require('react-devtools-shared/src/devtools/views/context').BridgeContext;
- StoreContext = require('react-devtools-shared/src/devtools/views/context').StoreContext;
+ BridgeContext = require('react-devtools-shared/src/devtools/views/context')
+ .BridgeContext;
+ StoreContext = require('react-devtools-shared/src/devtools/views/context')
+ .StoreContext;
TreeContext = require('react-devtools-shared/src/devtools/views/Components/TreeContext');
});
@@ -76,7 +78,7 @@ describe('TreeListContext', () => {
const Child = () => null;
utils.act(() =>
- ReactDOM.render(
, document.createElement('div'))
+ ReactDOM.render(
, document.createElement('div')),
);
expect(store).toMatchSnapshot('0: mount');
@@ -85,7 +87,7 @@ describe('TreeListContext', () => {
utils.act(() => (renderer = TestRenderer.create(
)));
expect(state).toMatchSnapshot('1: initial state');
- utils.act(() => dispatch({ type: 'SELECT_NEXT_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: select first element');
@@ -94,7 +96,7 @@ describe('TreeListContext', () => {
state.selectedElementIndex < store.numElements - 1
) {
const index = ((state.selectedElementIndex: any): number);
- utils.act(() => dispatch({ type: 'SELECT_NEXT_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot(`3: select element after (${index})`);
}
@@ -104,16 +106,16 @@ describe('TreeListContext', () => {
state.selectedElementIndex > 0
) {
const index = ((state.selectedElementIndex: any): number);
- utils.act(() => dispatch({ type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot(`4: select element before (${index})`);
}
- utils.act(() => dispatch({ type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('5: select previous wraps around to last');
- utils.act(() => dispatch({ type: 'SELECT_NEXT_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('6: select next wraps around to first');
});
@@ -134,7 +136,7 @@ describe('TreeListContext', () => {
const Child = () => null;
utils.act(() =>
- ReactDOM.render(
, document.createElement('div'))
+ ReactDOM.render(
, document.createElement('div')),
);
expect(store).toMatchSnapshot('0: mount');
@@ -143,24 +145,22 @@ describe('TreeListContext', () => {
utils.act(() => (renderer = TestRenderer.create(
)));
expect(state).toMatchSnapshot('1: initial state');
- utils.act(() =>
- dispatch({ type: 'SELECT_ELEMENT_AT_INDEX', payload: 0 })
- );
+ utils.act(() => dispatch({type: 'SELECT_ELEMENT_AT_INDEX', payload: 0}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: select first element');
- utils.act(() => dispatch({ type: 'SELECT_CHILD_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_CHILD_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: select Parent');
- utils.act(() => dispatch({ type: 'SELECT_CHILD_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_CHILD_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: select Child');
const previousState = state;
// There are no more children to select, so this should be a no-op
- utils.act(() => dispatch({ type: 'SELECT_CHILD_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_CHILD_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toEqual(previousState);
});
@@ -181,7 +181,7 @@ describe('TreeListContext', () => {
const Child = () => null;
utils.act(() =>
- ReactDOM.render(
, document.createElement('div'))
+ ReactDOM.render(
, document.createElement('div')),
);
expect(store).toMatchSnapshot('0: mount');
@@ -193,23 +193,23 @@ describe('TreeListContext', () => {
const lastChildID = store.getElementIDAtIndex(store.numElements - 1);
utils.act(() =>
- dispatch({ type: 'SELECT_ELEMENT_BY_ID', payload: lastChildID })
+ dispatch({type: 'SELECT_ELEMENT_BY_ID', payload: lastChildID}),
);
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: select last child');
- utils.act(() => dispatch({ type: 'SELECT_PARENT_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_PARENT_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: select Parent');
- utils.act(() => dispatch({ type: 'SELECT_PARENT_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_PARENT_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: select Grandparent');
const previousState = state;
// There are no more ancestors to select, so this should be a no-op
- utils.act(() => dispatch({ type: 'SELECT_PARENT_ELEMENT_IN_TREE' }));
+ utils.act(() => dispatch({type: 'SELECT_PARENT_ELEMENT_IN_TREE'}));
utils.act(() => renderer.update(
));
expect(state).toEqual(previousState);
});
@@ -228,8 +228,8 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
expect(store).toMatchSnapshot('0: mount');
@@ -238,9 +238,7 @@ describe('TreeListContext', () => {
utils.act(() => (renderer = TestRenderer.create(
)));
expect(state).toMatchSnapshot('1: initial state');
- utils.act(() =>
- dispatch({ type: 'SELECT_ELEMENT_AT_INDEX', payload: 3 })
- );
+ utils.act(() => dispatch({type: 'SELECT_ELEMENT_AT_INDEX', payload: 3}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: select second child');
@@ -249,16 +247,16 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
expect(state).toMatchSnapshot(
- '3: remove children (parent should now be selected)'
+ '3: remove children (parent should now be selected)',
);
await utils.actAsync(() => ReactDOM.unmountComponentAtNode(container));
expect(state).toMatchSnapshot(
- '4: unmount root (nothing should be selected)'
+ '4: unmount root (nothing should be selected)',
);
done();
@@ -282,8 +280,8 @@ describe('TreeListContext', () => {
,
- document.createElement('div')
- )
+ document.createElement('div'),
+ ),
);
expect(store).toMatchSnapshot('0: mount');
@@ -293,22 +291,22 @@ describe('TreeListContext', () => {
expect(state).toMatchSnapshot('1: initial state');
// NOTE: multi-match
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'ba' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'ba'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: search for "ba"');
// NOTE: single match
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'f' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'f'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: search for "f"');
// NOTE: no match
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'y' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'y'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: search for "y"');
// NOTE: HOC match
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'w' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'w'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('5: search for "w"');
});
@@ -326,8 +324,8 @@ describe('TreeListContext', () => {
,
- document.createElement('div')
- )
+ document.createElement('div'),
+ ),
);
expect(store).toMatchSnapshot('0: mount');
@@ -336,31 +334,31 @@ describe('TreeListContext', () => {
utils.act(() => (renderer = TestRenderer.create(
)));
expect(state).toMatchSnapshot('1: initial state');
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'ba' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'ba'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: search for "ba"');
- utils.act(() => dispatch({ type: 'GO_TO_NEXT_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: go to second result');
- utils.act(() => dispatch({ type: 'GO_TO_NEXT_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: go to third result');
- utils.act(() => dispatch({ type: 'GO_TO_PREVIOUS_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('5: go to second result');
- utils.act(() => dispatch({ type: 'GO_TO_PREVIOUS_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('6: go to first result');
- utils.act(() => dispatch({ type: 'GO_TO_PREVIOUS_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('7: wrap to last result');
- utils.act(() => dispatch({ type: 'GO_TO_NEXT_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('8: wrap to first result');
});
@@ -378,8 +376,8 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
expect(store).toMatchSnapshot('0: mount');
@@ -388,7 +386,7 @@ describe('TreeListContext', () => {
utils.act(() => (renderer = TestRenderer.create(
)));
expect(state).toMatchSnapshot('1: initial state');
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'ba' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'ba'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: search for "ba"');
@@ -399,8 +397,8 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: mount Baz');
@@ -422,8 +420,8 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
expect(store).toMatchSnapshot('0: mount');
@@ -432,11 +430,11 @@ describe('TreeListContext', () => {
utils.act(() => (renderer = TestRenderer.create(
)));
expect(state).toMatchSnapshot('1: initial state');
- utils.act(() => dispatch({ type: 'SET_SEARCH_TEXT', payload: 'ba' }));
+ utils.act(() => dispatch({type: 'SET_SEARCH_TEXT', payload: 'ba'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: search for "ba"');
- utils.act(() => dispatch({ type: 'GO_TO_NEXT_SEARCH_RESULT' }));
+ utils.act(() => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: go to second result');
@@ -446,8 +444,8 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: unmount Baz');
@@ -468,7 +466,7 @@ describe('TreeListContext', () => {
const Child = () => null;
utils.act(() =>
- ReactDOM.render(
, document.createElement('div'))
+ ReactDOM.render(
, document.createElement('div')),
);
expect(store).toMatchSnapshot('0: mount');
@@ -478,18 +476,18 @@ describe('TreeListContext', () => {
expect(state).toMatchSnapshot('1: initial state');
let parentID = ((store.getElementIDAtIndex(1): any): number);
- utils.act(() => dispatch({ type: 'SELECT_OWNER', payload: parentID }));
+ utils.act(() => dispatch({type: 'SELECT_OWNER', payload: parentID}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: parent owners tree');
- utils.act(() => dispatch({ type: 'RESET_OWNER_STACK' }));
+ utils.act(() => dispatch({type: 'RESET_OWNER_STACK'}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: final state');
});
it('should remove an element from the owners list if it is unmounted', async done => {
- const Grandparent = ({ count }) =>
;
- const Parent = ({ count }) =>
+ const Grandparent = ({count}) =>
;
+ const Parent = ({count}) =>
new Array(count).fill(true).map((_, index) =>
);
const Child = () => null;
@@ -503,17 +501,17 @@ describe('TreeListContext', () => {
expect(state).toMatchSnapshot('1: initial state');
let parentID = ((store.getElementIDAtIndex(1): any): number);
- utils.act(() => dispatch({ type: 'SELECT_OWNER', payload: parentID }));
+ utils.act(() => dispatch({type: 'SELECT_OWNER', payload: parentID}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: parent owners tree');
await utils.actAsync(() =>
- ReactDOM.render(
, container)
+ ReactDOM.render(
, container),
);
expect(state).toMatchSnapshot('3: remove second child');
await utils.actAsync(() =>
- ReactDOM.render(
, container)
+ ReactDOM.render(
, container),
);
expect(state).toMatchSnapshot('4: remove first child');
@@ -530,8 +528,8 @@ describe('TreeListContext', () => {
,
- container
- )
+ container,
+ ),
);
expect(store).toMatchSnapshot('0: mount');
@@ -541,7 +539,7 @@ describe('TreeListContext', () => {
expect(state).toMatchSnapshot('1: initial state');
let childID = ((store.getElementIDAtIndex(1): any): number);
- utils.act(() => dispatch({ type: 'SELECT_OWNER', payload: childID }));
+ utils.act(() => dispatch({type: 'SELECT_OWNER', payload: childID}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: child owners tree');
@@ -549,7 +547,7 @@ describe('TreeListContext', () => {
expect(state).toMatchSnapshot('3: remove child');
let parentID = ((store.getElementIDAtIndex(0): any): number);
- utils.act(() => dispatch({ type: 'SELECT_OWNER', payload: parentID }));
+ utils.act(() => dispatch({type: 'SELECT_OWNER', payload: parentID}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: parent owners tree');
@@ -586,20 +584,20 @@ describe('TreeListContext', () => {
const childID = ((store.getElementIDAtIndex(2): any): number);
const innerSuspenseID = ((store.getElementIDAtIndex(3): any): number);
- utils.act(() => dispatch({ type: 'SELECT_OWNER', payload: childID }));
+ utils.act(() => dispatch({type: 'SELECT_OWNER', payload: childID}));
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('2: child owners tree');
// Toggling a Suspense boundary inside of the flat list should update selected index
utils.act(() =>
- dispatch({ type: 'SELECT_ELEMENT_BY_ID', payload: innerSuspenseID })
+ dispatch({type: 'SELECT_ELEMENT_BY_ID', payload: innerSuspenseID}),
);
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('3: child owners tree');
// Toggling a Suspense boundary outside of the flat list should exit owners list and update index
utils.act(() =>
- dispatch({ type: 'SELECT_ELEMENT_BY_ID', payload: outerSuspenseID })
+ dispatch({type: 'SELECT_ELEMENT_BY_ID', payload: outerSuspenseID}),
);
utils.act(() => renderer.update(
));
expect(state).toMatchSnapshot('4: main tree');
diff --git a/packages/react-devtools-shared/src/__tests__/utils.js b/packages/react-devtools-shared/src/__tests__/utils.js
index a1e0274f0d676..1679ab5dcae2a 100644
--- a/packages/react-devtools-shared/src/__tests__/utils.js
+++ b/packages/react-devtools-shared/src/__tests__/utils.js
@@ -2,14 +2,14 @@
import typeof ReactTestRenderer from 'react-test-renderer';
-import type { FrontendBridge } from 'react-devtools-shared/src/bridge';
+import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type Store from 'react-devtools-shared/src/devtools/store';
-import type { ProfilingDataFrontend } from 'react-devtools-shared/src/devtools/views/Profiler/types';
-import type { ElementType } from 'react-devtools-shared/src/types';
+import type {ProfilingDataFrontend} from 'react-devtools-shared/src/devtools/views/Profiler/types';
+import type {ElementType} from 'react-devtools-shared/src/types';
export function act(callback: Function): void {
- const { act: actTestRenderer } = require('react-test-renderer');
- const { act: actDOM } = require('react-dom/test-utils');
+ const {act: actTestRenderer} = require('react-test-renderer');
+ const {act: actDOM} = require('react-dom/test-utils');
actDOM(() => {
actTestRenderer(() => {
@@ -27,10 +27,10 @@ export function act(callback: Function): void {
export async function actAsync(
cb: () => *,
- recursivelyFlush: boolean = true
+ recursivelyFlush: boolean = true,
): Promise
{
- const { act: actTestRenderer } = require('react-test-renderer');
- const { act: actDOM } = require('react-dom/test-utils');
+ const {act: actTestRenderer} = require('react-test-renderer');
+ const {act: actDOM} = require('react-dom/test-utils');
// $FlowFixMe Flow doens't know about "await act()" yet
await actDOM(async () => {
@@ -67,13 +67,13 @@ export function beforeEachProfiling(): void {
jest
.spyOn(performance, 'now')
.mockImplementation(
- jest.requireActual('scheduler/unstable_mock').unstable_now
+ jest.requireActual('scheduler/unstable_mock').unstable_now,
);
}
export function createDisplayNameFilter(
source: string,
- isEnabled: boolean = true
+ isEnabled: boolean = true,
) {
const Types = require('react-devtools-shared/src/types');
let isValid = true;
@@ -101,7 +101,7 @@ export function createHOCFilter(isEnabled: boolean = true) {
export function createElementTypeFilter(
elementType: ElementType,
- isEnabled: boolean = true
+ isEnabled: boolean = true,
) {
const Types = require('react-devtools-shared/src/types');
return {
@@ -113,7 +113,7 @@ export function createElementTypeFilter(
export function createLocationFilter(
source: string,
- isEnabled: boolean = true
+ isEnabled: boolean = true,
) {
const Types = require('react-devtools-shared/src/types');
let isValid = true;
@@ -162,32 +162,32 @@ export function requireTestRenderer(): ReactTestRenderer {
}
export function exportImportHelper(bridge: FrontendBridge, store: Store): void {
- const { act } = require('./utils');
+ const {act} = require('./utils');
const {
prepareProfilingDataExport,
prepareProfilingDataFrontendFromExport,
} = require('react-devtools-shared/src/devtools/views/Profiler/utils');
- const { profilerStore } = store;
+ const {profilerStore} = store;
expect(profilerStore.profilingData).not.toBeNull();
const profilingDataFrontendInitial = ((profilerStore.profilingData: any): ProfilingDataFrontend);
const profilingDataExport = prepareProfilingDataExport(
- profilingDataFrontendInitial
+ profilingDataFrontendInitial,
);
// Simulate writing/reading to disk.
const serializedProfilingDataExport = JSON.stringify(
profilingDataExport,
null,
- 2
+ 2,
);
const parsedProfilingDataExport = JSON.parse(serializedProfilingDataExport);
const profilingDataFrontend = prepareProfilingDataFrontendFromExport(
- (parsedProfilingDataExport: any)
+ (parsedProfilingDataExport: any),
);
// Sanity check that profiling snapshots are serialized correctly.
diff --git a/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js b/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js
index 0609272dc9050..3a25494131520 100644
--- a/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js
+++ b/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js
@@ -1,6 +1,6 @@
// @flow
-import type { BoxStyle } from './types';
+import type {BoxStyle} from './types';
/**
* This mirrors react-native/Libraries/Inspector/resolveBoxStyle.js (but without RTL support).
@@ -12,7 +12,7 @@ import type { BoxStyle } from './types';
*/
export default function resolveBoxStyle(
prefix: string,
- style: Object
+ style: Object,
): BoxStyle | null {
let hasParts = false;
const result = {
diff --git a/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js b/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js
index 7568b6cc45459..7f72b8cbf3865 100644
--- a/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js
+++ b/packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js
@@ -3,9 +3,9 @@
import Agent from 'react-devtools-shared/src/backend/agent';
import resolveBoxStyle from './resolveBoxStyle';
-import type { BackendBridge } from 'react-devtools-shared/src/bridge';
-import type { RendererID } from '../types';
-import type { StyleAndLayout } from './types';
+import type {BackendBridge} from 'react-devtools-shared/src/bridge';
+import type {RendererID} from '../types';
+import type {StyleAndLayout} from './types';
export type ResolveNativeStyle = (stylesheetID: any) => ?Object;
@@ -13,13 +13,13 @@ export default function setupNativeStyleEditor(
bridge: BackendBridge,
agent: Agent,
resolveNativeStyle: ResolveNativeStyle,
- validAttributes?: $ReadOnlyArray | null
+ validAttributes?: $ReadOnlyArray | null,
) {
bridge.addListener(
'NativeStyleEditor_measure',
- ({ id, rendererID }: {| id: number, rendererID: RendererID |}) => {
+ ({id, rendererID}: {|id: number, rendererID: RendererID|}) => {
measureStyle(agent, bridge, resolveNativeStyle, id, rendererID);
- }
+ },
);
bridge.addListener(
@@ -39,9 +39,9 @@ export default function setupNativeStyleEditor(
|}) => {
renameStyle(agent, id, rendererID, oldName, newName, value);
setTimeout(() =>
- measureStyle(agent, bridge, resolveNativeStyle, id, rendererID)
+ measureStyle(agent, bridge, resolveNativeStyle, id, rendererID),
);
- }
+ },
);
bridge.addListener(
@@ -59,9 +59,9 @@ export default function setupNativeStyleEditor(
|}) => {
setStyle(agent, id, rendererID, name, value);
setTimeout(() =>
- measureStyle(agent, bridge, resolveNativeStyle, id, rendererID)
+ measureStyle(agent, bridge, resolveNativeStyle, id, rendererID),
);
- }
+ },
);
bridge.send('isNativeStyleEditorSupported', {
@@ -84,9 +84,9 @@ function measureStyle(
bridge: BackendBridge,
resolveNativeStyle: ResolveNativeStyle,
id: number,
- rendererID: RendererID
+ rendererID: RendererID,
) {
- const data = agent.getInstanceAndStyle({ id, rendererID });
+ const data = agent.getInstanceAndStyle({id, rendererID});
if (!data || !data.style) {
bridge.send(
'NativeStyleEditor_styleAndLayout',
@@ -94,12 +94,12 @@ function measureStyle(
id,
layout: null,
style: null,
- }: StyleAndLayout)
+ }: StyleAndLayout),
);
return;
}
- const { instance, style } = data;
+ const {instance, style} = data;
let resolvedStyle = resolveNativeStyle(style);
@@ -116,7 +116,7 @@ function measureStyle(
id,
layout: null,
style: resolvedStyle || null,
- }: StyleAndLayout)
+ }: StyleAndLayout),
);
return;
}
@@ -132,12 +132,16 @@ function measureStyle(
id,
layout: null,
style: resolvedStyle || null,
- }: StyleAndLayout)
+ }: StyleAndLayout),
);
return;
}
- const margin = resolvedStyle != null && resolveBoxStyle('margin', resolvedStyle) || EMPTY_BOX_STYLE;
- const padding = resolvedStyle != null && resolveBoxStyle('padding', resolvedStyle) || EMPTY_BOX_STYLE;
+ const margin =
+ (resolvedStyle != null && resolveBoxStyle('margin', resolvedStyle)) ||
+ EMPTY_BOX_STYLE;
+ const padding =
+ (resolvedStyle != null && resolveBoxStyle('padding', resolvedStyle)) ||
+ EMPTY_BOX_STYLE;
bridge.send(
'NativeStyleEditor_styleAndLayout',
({
@@ -153,7 +157,7 @@ function measureStyle(
padding,
},
style: resolvedStyle || null,
- }: StyleAndLayout)
+ }: StyleAndLayout),
);
});
}
@@ -172,18 +176,18 @@ function renameStyle(
rendererID: RendererID,
oldName: string,
newName: string,
- value: string
+ value: string,
): void {
- const data = agent.getInstanceAndStyle({ id, rendererID });
+ const data = agent.getInstanceAndStyle({id, rendererID});
if (!data || !data.style) {
return;
}
- const { instance, style } = data;
+ const {instance, style} = data;
const newStyle = newName
- ? { [oldName]: undefined, [newName]: value }
- : { [oldName]: undefined };
+ ? {[oldName]: undefined, [newName]: value}
+ : {[oldName]: undefined};
let customStyle;
@@ -198,7 +202,7 @@ function renameStyle(
Object.assign(styleOverrides, newStyle);
}
// TODO Fabric does not support setNativeProps; chat with Sebastian or Eli
- instance.setNativeProps({ style: newStyle });
+ instance.setNativeProps({style: newStyle});
} else if (Array.isArray(style)) {
const lastIndex = style.length - 1;
if (
@@ -259,15 +263,15 @@ function setStyle(
id: number,
rendererID: RendererID,
name: string,
- value: string
+ value: string,
) {
- const data = agent.getInstanceAndStyle({ id, rendererID });
+ const data = agent.getInstanceAndStyle({id, rendererID});
if (!data || !data.style) {
return;
}
- const { instance, style } = data;
- const newStyle = { [name]: value };
+ const {instance, style} = data;
+ const newStyle = {[name]: value};
// TODO It would be nice if the renderer interface abstracted this away somehow.
if (instance !== null && typeof instance.setNativeProps === 'function') {
@@ -280,7 +284,7 @@ function setStyle(
Object.assign(styleOverrides, newStyle);
}
// TODO Fabric does not support setNativeProps; chat with Sebastian or Eli
- instance.setNativeProps({ style: newStyle });
+ instance.setNativeProps({style: newStyle});
} else if (Array.isArray(style)) {
const lastLength = style.length - 1;
if (
diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js
index eb72e0bfd3e01..fd79433352bbe 100644
--- a/packages/react-devtools-shared/src/backend/agent.js
+++ b/packages/react-devtools-shared/src/backend/agent.js
@@ -14,9 +14,9 @@ import {
sessionStorageSetItem,
} from 'react-devtools-shared/src/storage';
import setupHighlighter from './views/Highlighter';
-import { patch as patchConsole, unpatch as unpatchConsole } from './console';
+import {patch as patchConsole, unpatch as unpatchConsole} from './console';
-import type { BackendBridge } from 'react-devtools-shared/src/bridge';
+import type {BackendBridge} from 'react-devtools-shared/src/bridge';
import type {
InstanceAndStyle,
NativeType,
@@ -26,7 +26,7 @@ import type {
RendererID,
RendererInterface,
} from './types';
-import type { ComponentFilter } from '../types';
+import type {ComponentFilter} from '../types';
const debug = (methodName, ...args) => {
if (__DEBUG__) {
@@ -34,7 +34,7 @@ const debug = (methodName, ...args) => {
`%cAgent %c${methodName}`,
'color: purple; font-weight: bold;',
'font-weight: bold;',
- ...args
+ ...args,
);
}
};
@@ -84,7 +84,7 @@ export default class Agent extends EventEmitter<{|
_bridge: BackendBridge;
_isProfiling: boolean = false;
_recordChangeDescriptions: boolean = false;
- _rendererInterfaces: { [key: RendererID]: RendererInterface } = {};
+ _rendererInterfaces: {[key: RendererID]: RendererInterface} = {};
_persistedSelection: PersistedSelection | null = null;
_persistedSelectionMatch: PathMatch | null = null;
@@ -96,7 +96,7 @@ export default class Agent extends EventEmitter<{|
) {
this._recordChangeDescriptions =
sessionStorageGetItem(
- SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY
+ SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY,
) === 'true';
this._isProfiling = true;
@@ -105,7 +105,7 @@ export default class Agent extends EventEmitter<{|
}
const persistedSelectionString = sessionStorageGetItem(
- SESSION_STORAGE_LAST_SELECTION_KEY
+ SESSION_STORAGE_LAST_SELECTION_KEY,
);
if (persistedSelectionString != null) {
this._persistedSelection = JSON.parse(persistedSelectionString);
@@ -128,12 +128,12 @@ export default class Agent extends EventEmitter<{|
bridge.addListener('stopProfiling', this.stopProfiling);
bridge.addListener(
'syncSelectionFromNativeElementsPanel',
- this.syncSelectionFromNativeElementsPanel
+ this.syncSelectionFromNativeElementsPanel,
);
bridge.addListener('shutdown', this.shutdown);
bridge.addListener(
'updateAppendComponentStack',
- this.updateAppendComponentStack
+ this.updateAppendComponentStack,
);
bridge.addListener('updateComponentFilters', this.updateComponentFilters);
bridge.addListener('viewElementSource', this.viewElementSource);
@@ -154,7 +154,7 @@ export default class Agent extends EventEmitter<{|
setupHighlighter(bridge, this);
}
- get rendererInterfaces(): { [key: RendererID]: RendererInterface } {
+ get rendererInterfaces(): {[key: RendererID]: RendererInterface} {
return this._rendererInterfaces;
}
@@ -189,7 +189,7 @@ export default class Agent extends EventEmitter<{|
return null;
}
- getProfilingData = ({ rendererID }: {| rendererID: RendererID |}) => {
+ getProfilingData = ({rendererID}: {|rendererID: RendererID|}) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}"`);
@@ -202,17 +202,17 @@ export default class Agent extends EventEmitter<{|
this._bridge.send('profilingStatus', this._isProfiling);
};
- getOwnersList = ({ id, rendererID }: ElementAndRendererID) => {
+ getOwnersList = ({id, rendererID}: ElementAndRendererID) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
} else {
const owners = renderer.getOwnersList(id);
- this._bridge.send('ownersList', ({ id, owners }: OwnersList));
+ this._bridge.send('ownersList', ({id, owners}: OwnersList));
}
};
- inspectElement = ({ id, path, rendererID }: InspectElementParams) => {
+ inspectElement = ({id, path, rendererID}: InspectElementParams) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
@@ -239,7 +239,7 @@ export default class Agent extends EventEmitter<{|
}
};
- logElementToConsole = ({ id, rendererID }: ElementAndRendererID) => {
+ logElementToConsole = ({id, rendererID}: ElementAndRendererID) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
@@ -252,7 +252,7 @@ export default class Agent extends EventEmitter<{|
sessionStorageSetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY, 'true');
sessionStorageSetItem(
SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY,
- recordChangeDescriptions ? 'true' : 'false'
+ recordChangeDescriptions ? 'true' : 'false',
);
// This code path should only be hit if the shell has explicitly told the Store that it supports profiling.
@@ -261,7 +261,7 @@ export default class Agent extends EventEmitter<{|
this._bridge.send('reloadAppForProfiling');
};
- overrideContext = ({ id, path, rendererID, value }: SetInParams) => {
+ overrideContext = ({id, path, rendererID, value}: SetInParams) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
@@ -285,7 +285,7 @@ export default class Agent extends EventEmitter<{|
}
};
- overrideProps = ({ id, path, rendererID, value }: SetInParams) => {
+ overrideProps = ({id, path, rendererID, value}: SetInParams) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
@@ -294,7 +294,7 @@ export default class Agent extends EventEmitter<{|
}
};
- overrideState = ({ id, path, rendererID, value }: SetInParams) => {
+ overrideState = ({id, path, rendererID, value}: SetInParams) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
@@ -325,7 +325,7 @@ export default class Agent extends EventEmitter<{|
setRendererInterface(
rendererID: RendererID,
- rendererInterface: RendererInterface
+ rendererInterface: RendererInterface,
) {
this._rendererInterfaces[rendererID] = rendererInterface;
@@ -400,7 +400,7 @@ export default class Agent extends EventEmitter<{|
}
};
- viewElementSource = ({ id, rendererID }: ElementAndRendererID) => {
+ viewElementSource = ({id, rendererID}: ElementAndRendererID) => {
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
@@ -476,7 +476,7 @@ export default class Agent extends EventEmitter<{|
if (path !== null) {
sessionStorageSetItem(
SESSION_STORAGE_LAST_SELECTION_KEY,
- JSON.stringify(({ rendererID, path }: PersistedSelection))
+ JSON.stringify(({rendererID, path}: PersistedSelection)),
);
} else {
sessionStorageRemoveItem(SESSION_STORAGE_LAST_SELECTION_KEY);
diff --git a/packages/react-devtools-shared/src/backend/console.js b/packages/react-devtools-shared/src/backend/console.js
index 22f5db951541c..8bcc242a5848b 100644
--- a/packages/react-devtools-shared/src/backend/console.js
+++ b/packages/react-devtools-shared/src/backend/console.js
@@ -1,9 +1,9 @@
// @flow
-import { getInternalReactConstants } from './renderer';
+import {getInternalReactConstants} from './renderer';
import describeComponentFrame from './describeComponentFrame';
-import type { Fiber, ReactRenderer } from './types';
+import type {Fiber, ReactRenderer} from './types';
const APPEND_STACK_TO_METHODS = ['error', 'trace', 'warn'];
@@ -14,7 +14,7 @@ const injectedRenderers: Map<
{|
getCurrentFiber: () => Fiber | null,
getDisplayNameForFiber: (fiber: Fiber) => string | null,
- |}
+ |},
> = new Map();
let targetConsole: Object = console;
@@ -27,7 +27,7 @@ let unpatchFn: null | (() => void) = null;
// Enables e.g. Jest tests to inject a mock console object.
export function dangerous_setTargetConsoleForTesting(
- targetConsoleForTesting: Object
+ targetConsoleForTesting: Object,
): void {
targetConsole = targetConsoleForTesting;
@@ -41,7 +41,7 @@ export function dangerous_setTargetConsoleForTesting(
// These internals will be used if the console is patched.
// Injecting them separately allows the console to easily be patched or unpacted later (at runtime).
export function registerRenderer(renderer: ReactRenderer): void {
- const { getCurrentFiber, findFiberByHostInstance, version } = renderer;
+ const {getCurrentFiber, findFiberByHostInstance, version} = renderer;
// Ignore React v15 and older because they don't expose a component stack anyway.
if (typeof findFiberByHostInstance !== 'function') {
@@ -49,7 +49,7 @@ export function registerRenderer(renderer: ReactRenderer): void {
}
if (typeof getCurrentFiber === 'function') {
- const { getDisplayNameForFiber } = getInternalReactConstants(version);
+ const {getDisplayNameForFiber} = getInternalReactConstants(version);
injectedRenderers.set(renderer, {
getCurrentFiber,
@@ -107,7 +107,7 @@ export function patch(): void {
ownerStack += describeComponentFrame(
name,
current._debugSource,
- ownerName
+ ownerName,
);
current = owner;
diff --git a/packages/react-devtools-shared/src/backend/describeComponentFrame.js b/packages/react-devtools-shared/src/backend/describeComponentFrame.js
index 5c632471babc1..849e9bc1f4da4 100644
--- a/packages/react-devtools-shared/src/backend/describeComponentFrame.js
+++ b/packages/react-devtools-shared/src/backend/describeComponentFrame.js
@@ -10,7 +10,7 @@ const BEFORE_SLASH_RE = /^(.*)[\\/]/;
export default function describeComponentFrame(
name: null | string,
source: any,
- ownerName: null | string
+ ownerName: null | string,
) {
let sourceInfo = '';
if (source) {
diff --git a/packages/react-devtools-shared/src/backend/index.js b/packages/react-devtools-shared/src/backend/index.js
index feee4c00dedd8..98aece0a856f8 100644
--- a/packages/react-devtools-shared/src/backend/index.js
+++ b/packages/react-devtools-shared/src/backend/index.js
@@ -2,15 +2,15 @@
import Agent from './agent';
-import { attach } from './renderer';
-import { attach as attachLegacy } from './legacy/renderer';
+import {attach} from './renderer';
+import {attach as attachLegacy} from './legacy/renderer';
-import type { DevToolsHook, ReactRenderer, RendererInterface } from './types';
+import type {DevToolsHook, ReactRenderer, RendererInterface} from './types';
export function initBackend(
hook: DevToolsHook,
agent: Agent,
- global: Object
+ global: Object,
): () => void {
const subs = [
hook.sub(
@@ -29,7 +29,7 @@ export function initBackend(
// Now that the Store and the renderer interface are connected,
// it's time to flush the pending operation codes to the frontend.
rendererInterface.flushInitialOperations();
- }
+ },
),
hook.sub('operations', agent.onHookOperations),
@@ -69,10 +69,10 @@ export function initBackend(
subs.push(
hook.sub(
'renderer',
- ({ id, renderer }: { id: number, renderer: ReactRenderer }) => {
+ ({id, renderer}: {id: number, renderer: ReactRenderer}) => {
attachRenderer(id, renderer);
- }
- )
+ },
+ ),
);
hook.emit('react-devtools', agent);
diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js
index 4fff97a5fbf0a..a892bdedcd5de 100644
--- a/packages/react-devtools-shared/src/backend/legacy/renderer.js
+++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js
@@ -7,16 +7,16 @@ import {
ElementTypeHostComponent,
ElementTypeOtherOrUnknown,
} from 'react-devtools-shared/src/types';
-import { getUID, utfEncodeString, printOperationsArray } from '../../utils';
-import { cleanForBridge, copyWithSet } from '../utils';
-import { getDisplayName } from 'react-devtools-shared/src/utils';
+import {getUID, utfEncodeString, printOperationsArray} from '../../utils';
+import {cleanForBridge, copyWithSet} from '../utils';
+import {getDisplayName} from 'react-devtools-shared/src/utils';
import {
__DEBUG__,
TREE_OPERATION_ADD,
TREE_OPERATION_REMOVE,
TREE_OPERATION_REORDER_CHILDREN,
} from '../../constants';
-import { decorateMany, forceUpdate, restoreMany } from './utils';
+import {decorateMany, forceUpdate, restoreMany} from './utils';
import type {
DevToolsHook,
@@ -28,8 +28,11 @@ import type {
PathMatch,
RendererInterface,
} from '../types';
-import type { ComponentFilter, ElementType } from 'react-devtools-shared/src/types';
-import type { Owner, InspectedElement } from '../types';
+import type {
+ ComponentFilter,
+ ElementType,
+} from 'react-devtools-shared/src/types';
+import type {Owner, InspectedElement} from '../types';
export type InternalInstance = Object;
type LegacyRenderer = Object;
@@ -112,16 +115,16 @@ export function attach(
hook: DevToolsHook,
rendererID: number,
renderer: LegacyRenderer,
- global: Object
+ global: Object,
): RendererInterface {
const idToInternalInstanceMap: Map = new Map();
const internalInstanceToIDMap: WeakMap<
InternalInstance,
- number
+ number,
> = new WeakMap();
const internalInstanceToRootIDMap: WeakMap<
InternalInstance,
- number
+ number,
> = new WeakMap();
let getInternalIDForNative: GetFiberIDForNative = ((null: any): GetFiberIDForNative);
@@ -130,7 +133,7 @@ export function attach(
if (renderer.ComponentTree) {
getInternalIDForNative = (node, findNearestUnfilteredAncestor) => {
const internalInstance = renderer.ComponentTree.getClosestInstanceFromNode(
- node
+ node,
);
return internalInstanceToIDMap.get(internalInstance) || null;
};
@@ -203,7 +206,7 @@ export function attach(
// Remember the root.
internalInstanceToRootIDMap.set(
internalInstance,
- getID(hostContainerInfo._topLevelWrapper)
+ getID(hostContainerInfo._topLevelWrapper),
);
try {
@@ -337,7 +340,7 @@ export function attach(
function recordMount(
internalInstance: InternalInstance,
id: number,
- parentID: number
+ parentID: number,
) {
const isRoot = parentID === 0;
@@ -346,7 +349,7 @@ export function attach(
'%crecordMount()',
'color: green; font-weight: bold;',
id,
- getData(internalInstance).displayName
+ getData(internalInstance).displayName,
);
}
@@ -363,7 +366,7 @@ export function attach(
pushOperation(hasOwnerMetadata ? 1 : 0);
} else {
const type = getElementType(internalInstance);
- const { displayName, key } = getData(internalInstance);
+ const {displayName, key} = getData(internalInstance);
const ownerID =
internalInstance._currentElement != null &&
@@ -386,7 +389,7 @@ export function attach(
function recordReorder(
internalInstance: InternalInstance,
id: number,
- nextChildren: Array
+ nextChildren: Array,
) {
pushOperation(TREE_OPERATION_REORDER_CHILDREN);
pushOperation(id);
@@ -405,7 +408,7 @@ export function attach(
function crawlAndRecordInitialMounts(
id: number,
parentID: number,
- rootID: number
+ rootID: number,
) {
if (__DEBUG__) {
console.group('crawlAndRecordInitialMounts() id:', id);
@@ -416,7 +419,7 @@ export function attach(
internalInstanceToRootIDMap.set(internalInstance, rootID);
recordMount(internalInstance, id, parentID);
getChildren(internalInstance).forEach(child =>
- crawlAndRecordInitialMounts(getID(child), id, rootID)
+ crawlAndRecordInitialMounts(getID(child), id, rootID),
);
}
@@ -469,7 +472,7 @@ export function attach(
// [TREE_OPERATION_REMOVE, removedIDLength, ...ids]
(numUnmountIDs > 0 ? 2 + numUnmountIDs : 0) +
// Mount operations
- pendingOperations.length
+ pendingOperations.length,
);
// Identify which renderer this update is coming from.
@@ -532,7 +535,7 @@ export function attach(
if (!Number.isInteger(op)) {
console.error(
'pushOperation() was called but the value is not an integer.',
- op
+ op,
);
}
}
@@ -641,7 +644,7 @@ export function attach(
function inspectElement(
id: number,
- path?: Array
+ path?: Array,
): InspectedElementPayload {
if (currentlyInspectedElementID !== id) {
currentlyInspectedElementID = id;
@@ -667,15 +670,15 @@ export function attach(
inspectedElement.context = cleanForBridge(
inspectedElement.context,
- createIsPathWhitelisted('context')
+ createIsPathWhitelisted('context'),
);
inspectedElement.props = cleanForBridge(
inspectedElement.props,
- createIsPathWhitelisted('props')
+ createIsPathWhitelisted('props'),
);
inspectedElement.state = cleanForBridge(
inspectedElement.state,
- createIsPathWhitelisted('state')
+ createIsPathWhitelisted('state'),
);
return {
@@ -692,7 +695,7 @@ export function attach(
return null;
}
- const { displayName } = getData(internalInstance);
+ const {displayName} = getData(internalInstance);
const type = getElementType(internalInstance);
let context = null;
@@ -773,7 +776,7 @@ export function attach(
console.groupCollapsed(
`[Click to expand] %c<${result.displayName || 'Component'} />`,
// --dom-tag-name-color is the CSS variable Chrome styles HTML elements with in the console.
- 'color: var(--dom-tag-name-color); font-weight: normal;'
+ 'color: var(--dom-tag-name-color); font-weight: normal;',
);
}
if (result.props !== null) {
@@ -791,7 +794,7 @@ export function attach(
}
if (window.chrome || /firefox/i.test(navigator.userAgent)) {
console.log(
- 'Right-click any value to save it as a global variable for further inspection.'
+ 'Right-click any value to save it as a global variable for further inspection.',
);
}
if (supportsGroup) {
@@ -854,7 +857,7 @@ export function attach(
const parent = path.reduce(
// $FlowFixMe
(reduced, attr) => (reduced ? reduced[attr] : null),
- obj
+ obj,
);
if (parent) {
// $FlowFixMe
diff --git a/packages/react-devtools-shared/src/backend/legacy/utils.js b/packages/react-devtools-shared/src/backend/legacy/utils.js
index 9fbe3079355ef..776fa6ae26052 100644
--- a/packages/react-devtools-shared/src/backend/legacy/utils.js
+++ b/packages/react-devtools-shared/src/backend/legacy/utils.js
@@ -1,6 +1,6 @@
// @flow
-import type { InternalInstance } from './renderer';
+import type {InternalInstance} from './renderer';
export function decorate(object: Object, attr: string, fn: Function): Function {
const old = object[attr];
@@ -12,7 +12,7 @@ export function decorate(object: Object, attr: string, fn: Function): Function {
export function decorateMany(
source: Object,
- fns: { [attr: string]: Function }
+ fns: {[attr: string]: Function},
): Object {
const olds = {};
for (const name in fns) {
diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js
index 2effb3344562a..cfedcf883c286 100644
--- a/packages/react-devtools-shared/src/backend/renderer.js
+++ b/packages/react-devtools-shared/src/backend/renderer.js
@@ -1,6 +1,6 @@
// @flow
-import { gte } from 'semver';
+import {gte} from 'semver';
import {
ComponentFilterDisplayName,
ComponentFilterElementType,
@@ -25,8 +25,8 @@ import {
setInObject,
utfEncodeString,
} from 'react-devtools-shared/src/utils';
-import { sessionStorageGetItem } from 'react-devtools-shared/src/storage';
-import { cleanForBridge, copyWithSet } from './utils';
+import {sessionStorageGetItem} from 'react-devtools-shared/src/storage';
+import {cleanForBridge, copyWithSet} from './utils';
import {
__DEBUG__,
SESSION_STORAGE_RELOAD_AND_PROFILE_KEY,
@@ -36,7 +36,7 @@ import {
TREE_OPERATION_REORDER_CHILDREN,
TREE_OPERATION_UPDATE_TREE_BASE_DURATION,
} from '../constants';
-import { inspectHooksOfFiber } from 'react-debug-tools';
+import {inspectHooksOfFiber} from 'react-debug-tools';
import {
patch as patchConsole,
registerRenderer as registerRendererWithConsole,
@@ -58,8 +58,11 @@ import type {
ReactRenderer,
RendererInterface,
} from './types';
-import type { Interaction } from 'react-devtools-shared/src/devtools/views/Profiler/types';
-import type { ComponentFilter, ElementType } from 'react-devtools-shared/src/types';
+import type {Interaction} from 'react-devtools-shared/src/devtools/views/Profiler/types';
+import type {
+ ComponentFilter,
+ ElementType,
+} from 'react-devtools-shared/src/types';
type getDisplayNameForFiberType = (fiber: Fiber) => string | null;
type getTypeSymbolType = (type: any) => Symbol | number;
@@ -138,7 +141,7 @@ const getCurrentTime =
: () => Date.now();
export function getInternalReactConstants(
- version: string
+ version: string,
): {|
getDisplayNameForFiber: getDisplayNameForFiberType,
getTypeSymbol: getTypeSymbolType,
@@ -325,7 +328,7 @@ export function getInternalReactConstants(
// NOTICE Keep in sync with shouldFilterFiber() and other get*ForFiber methods
function getDisplayNameForFiber(fiber: Fiber): string | null {
- const { elementType, type, tag } = fiber;
+ const {elementType, type, tag} = fiber;
// This is to support lazy components with a Promise as the type.
// see https://github.com/facebook/react/pull/13397
@@ -422,7 +425,7 @@ export function attach(
hook: DevToolsHook,
rendererID: number,
renderer: ReactRenderer,
- global: Object
+ global: Object,
): RendererInterface {
const {
getDisplayNameForFiber,
@@ -432,7 +435,7 @@ export function attach(
ReactSymbols,
ReactTypeOfSideEffect,
} = getInternalReactConstants(renderer.version);
- const { NoEffect, PerformedWork, Placement } = ReactTypeOfSideEffect;
+ const {NoEffect, PerformedWork, Placement} = ReactTypeOfSideEffect;
const {
FunctionComponent,
ClassComponent,
@@ -515,7 +518,7 @@ export function attach(
}`,
'color: red; font-weight: bold;',
'color: blue;',
- 'color: purple;'
+ 'color: purple;',
);
}
};
@@ -539,7 +542,7 @@ export function attach(
case ComponentFilterDisplayName:
if (componentFilter.isValid && componentFilter.value !== '') {
hideElementsWithDisplayNames.add(
- new RegExp(componentFilter.value, 'i')
+ new RegExp(componentFilter.value, 'i'),
);
}
break;
@@ -556,7 +559,7 @@ export function attach(
break;
default:
console.warn(
- `Invalid component filter type "${componentFilter.type}"`
+ `Invalid component filter type "${componentFilter.type}"`,
);
break;
}
@@ -614,7 +617,7 @@ export function attach(
// NOTICE Keep in sync with get*ForFiber methods
function shouldFilterFiber(fiber: Fiber): boolean {
- const { _debugSource, tag, type } = fiber;
+ const {_debugSource, tag, type} = fiber;
switch (tag) {
case DehydratedSuspenseComponent:
@@ -663,7 +666,7 @@ export function attach(
}
if (_debugSource != null && hideElementsWithPaths.size > 0) {
- const { fileName } = _debugSource;
+ const {fileName} = _debugSource;
for (let pathRegExp of hideElementsWithPaths) {
if (pathRegExp.test(fileName)) {
return true;
@@ -675,7 +678,7 @@ export function attach(
}
// NOTICE Keep in sync with shouldFilterFiber() and other get*ForFiber methods
function getElementTypeForFiber(fiber: Fiber): ElementType {
- const { type, tag } = fiber;
+ const {type, tag} = fiber;
switch (tag) {
case ClassComponent:
@@ -735,7 +738,7 @@ export function attach(
if (primaryFibers.has(fiber)) {
return fiber;
}
- const { alternate } = fiber;
+ const {alternate} = fiber;
if (alternate != null && primaryFibers.has(alternate)) {
return alternate;
}
@@ -771,7 +774,7 @@ export function attach(
function getChangeDescription(
prevFiber: Fiber | null,
- nextFiber: Fiber
+ nextFiber: Fiber,
): ChangeDescription | null {
switch (getElementTypeForFiber(nextFiber)) {
case ElementTypeClass:
@@ -791,16 +794,16 @@ export function attach(
context: getContextChangedKeys(nextFiber),
didHooksChange: didHooksChange(
prevFiber.memoizedState,
- nextFiber.memoizedState
+ nextFiber.memoizedState,
),
isFirstMount: false,
props: getChangedKeys(
prevFiber.memoizedProps,
- nextFiber.memoizedProps
+ nextFiber.memoizedProps,
),
state: getChangedKeys(
prevFiber.memoizedState,
- nextFiber.memoizedState
+ nextFiber.memoizedState,
),
};
}
@@ -984,7 +987,7 @@ export function attach(
if (!Number.isInteger(op)) {
console.error(
'pushOperation() was called but the value is not an integer.',
- op
+ op,
);
}
}
@@ -1022,7 +1025,7 @@ export function attach(
// [TREE_OPERATION_REMOVE, removedIDLength, ...ids]
(numUnmountIDs > 0 ? 2 + numUnmountIDs : 0) +
// Regular operations
- pendingOperations.length
+ pendingOperations.length,
);
// Identify which renderer this update is coming from.
@@ -1134,10 +1137,10 @@ export function attach(
}
}
} else {
- const { key } = fiber;
+ const {key} = fiber;
const displayName = getDisplayNameForFiber(fiber);
const elementType = getElementTypeForFiber(fiber);
- const { _debugOwner } = fiber;
+ const {_debugOwner} = fiber;
const ownerID =
_debugOwner != null ? getFiberID(getPrimaryFiber(_debugOwner)) : 0;
@@ -1217,7 +1220,7 @@ export function attach(
function mountFiberRecursively(
fiber: Fiber,
parentFiber: Fiber | null,
- traverseSiblings = false
+ traverseSiblings = false,
) {
if (__DEBUG__) {
debug('mountFiberRecursively()', fiber, parentFiber);
@@ -1226,7 +1229,7 @@ export function attach(
// If we have the tree selection from previous reload, try to match this Fiber.
// Also remember whether to do the same for siblings.
const mightSiblingsBeOnTrackedPath = updateTrackedPathStateBeforeMount(
- fiber
+ fiber,
);
const shouldIncludeInTree = !shouldFilterFiber(fiber);
@@ -1253,7 +1256,7 @@ export function attach(
mountFiberRecursively(
fallbackChild,
shouldIncludeInTree ? fiber : parentFiber,
- true
+ true,
);
}
} else {
@@ -1261,7 +1264,7 @@ export function attach(
mountFiberRecursively(
fiber.child,
shouldIncludeInTree ? fiber : parentFiber,
- true
+ true,
);
}
}
@@ -1311,12 +1314,12 @@ export function attach(
function recordProfilingDurations(fiber: Fiber) {
const id = getFiberID(getPrimaryFiber(fiber));
- const { actualDuration, treeBaseDuration } = fiber;
+ const {actualDuration, treeBaseDuration} = fiber;
idToTreeBaseDurationMap.set(id, fiber.treeBaseDuration || 0);
if (isProfiling) {
- const { alternate } = fiber;
+ const {alternate} = fiber;
if (
alternate == null ||
@@ -1325,7 +1328,7 @@ export function attach(
// Tree base duration updates are included in the operations typed array.
// So we have to convert them from milliseconds to microseconds so we can send them as ints.
const treeBaseDuration = Math.floor(
- (fiber.treeBaseDuration || 0) * 1000
+ (fiber.treeBaseDuration || 0) * 1000,
);
pushOperation(TREE_OPERATION_UPDATE_TREE_BASE_DURATION);
pushOperation(id);
@@ -1355,7 +1358,7 @@ export function attach(
metadata.durations.push(id, actualDuration, selfDuration);
metadata.maxActualDuration = Math.max(
metadata.maxActualDuration,
- actualDuration
+ actualDuration,
);
if (recordChangeDescriptions) {
@@ -1402,7 +1405,7 @@ export function attach(
function findReorderedChildrenRecursively(
fiber: Fiber,
- nextChildren: Array
+ nextChildren: Array,
) {
if (!shouldFilterFiber(fiber)) {
nextChildren.push(getFiberID(getPrimaryFiber(fiber)));
@@ -1419,7 +1422,7 @@ export function attach(
function updateFiberRecursively(
nextFiber: Fiber,
prevFiber: Fiber,
- parentFiber: Fiber | null
+ parentFiber: Fiber | null,
): boolean {
if (__DEBUG__) {
debug('updateFiberRecursively()', nextFiber, parentFiber);
@@ -1470,7 +1473,7 @@ export function attach(
updateFiberRecursively(
nextFallbackChildSet,
prevFallbackChildSet,
- nextFiber
+ nextFiber,
)
) {
shouldResetChildren = true;
@@ -1519,7 +1522,7 @@ export function attach(
updateFiberRecursively(
nextChild,
prevChild,
- shouldIncludeInTree ? nextFiber : parentFiber
+ shouldIncludeInTree ? nextFiber : parentFiber,
)
) {
// If a nested tree child order changed but it can't handle its own
@@ -1536,7 +1539,7 @@ export function attach(
} else {
mountFiberRecursively(
nextChild,
- shouldIncludeInTree ? nextFiber : parentFiber
+ shouldIncludeInTree ? nextFiber : parentFiber,
);
shouldResetChildren = true;
}
@@ -1626,7 +1629,7 @@ export function attach(
(interaction: Interaction) => ({
...interaction,
timestamp: interaction.timestamp - profilingStartTime,
- })
+ }),
),
maxActualDuration: 0,
priorityLevel: null,
@@ -1670,7 +1673,7 @@ export function attach(
(interaction: Interaction) => ({
...interaction,
timestamp: interaction.timestamp - profilingStartTime,
- })
+ }),
),
maxActualDuration: 0,
priorityLevel:
@@ -1705,16 +1708,16 @@ export function attach(
if (isProfiling) {
const commitProfilingMetadata = ((rootToCommitProfilingMetadataMap: any): CommitProfilingMetadataMap).get(
- currentRootID
+ currentRootID,
);
if (commitProfilingMetadata != null) {
commitProfilingMetadata.push(
- ((currentCommitProfilingMetadata: any): CommitProfilingData)
+ ((currentCommitProfilingMetadata: any): CommitProfilingData),
);
} else {
((rootToCommitProfilingMetadataMap: any): CommitProfilingMetadataMap).set(
currentRootID,
- [((currentCommitProfilingMetadata: any): CommitProfilingData)]
+ [((currentCommitProfilingMetadata: any): CommitProfilingData)],
);
}
}
@@ -1786,7 +1789,7 @@ export function attach(
function getFiberIDForNative(
hostInstance,
- findNearestUnfilteredAncestor = false
+ findNearestUnfilteredAncestor = false,
) {
let fiber = renderer.findFiberByHostInstance(hostInstance);
if (fiber != null) {
@@ -1962,7 +1965,7 @@ export function attach(
if (!didFindChild) {
throw Error(
'Child was not found in either parent set. This indicates a bug ' +
- 'in React related to the return pointer. Please file an issue.'
+ 'in React related to the return pointer. Please file an issue.',
);
}
}
@@ -1971,7 +1974,7 @@ export function attach(
if (a.alternate !== b) {
throw Error(
"Return fibers should always be each others' alternates. " +
- 'This error is likely caused by a bug in React. Please file an issue.'
+ 'This error is likely caused by a bug in React. Please file an issue.',
);
}
}
@@ -1996,7 +1999,7 @@ export function attach(
return;
}
- const { elementType, tag, type } = fiber;
+ const {elementType, tag, type} = fiber;
switch (tag) {
case ClassComponent:
@@ -2027,7 +2030,7 @@ export function attach(
return null;
}
- const { _debugOwner } = fiber;
+ const {_debugOwner} = fiber;
const owners = [
{
@@ -2065,7 +2068,7 @@ export function attach(
style = fiber.memoizedProps.style;
}
- return { instance, style };
+ return {instance, style};
}
function inspectElementRaw(id: number): InspectedElement | null {
@@ -2146,7 +2149,7 @@ export function attach(
if (context !== null) {
// To simplify hydration and display logic for context, wrap in a value object.
// Otherwise simple values (e.g. strings, booleans) become harder to handle.
- context = { value: context };
+ context = {value: context};
}
let owners = null;
@@ -2182,7 +2185,7 @@ export function attach(
try {
hooks = inspectHooksOfFiber(
fiber,
- (renderer.currentDispatcherRef: any)
+ (renderer.currentDispatcherRef: any),
);
} finally {
// Restore original console functionality.
@@ -2259,7 +2262,7 @@ export function attach(
function createIsPathWhitelisted(
key: string | null,
- secondaryCategory: 'hooks' | null
+ secondaryCategory: 'hooks' | null,
) {
// This function helps prevent previously-inspected paths from being dehydrated in updates.
// This is important to avoid a bad user experience where expanded toggles collapse on update.
@@ -2300,7 +2303,7 @@ export function attach(
}
function updateSelectedElement(inspectedElement: InspectedElement): void {
- const { hooks, id, props } = inspectedElement;
+ const {hooks, id, props} = inspectedElement;
let fiber = idToFiberMap.get(id);
if (fiber == null) {
@@ -2308,7 +2311,7 @@ export function attach(
return;
}
- const { elementType, stateNode, tag, type } = fiber;
+ const {elementType, stateNode, tag, type} = fiber;
switch (tag) {
case ClassComponent:
@@ -2347,7 +2350,7 @@ export function attach(
function inspectElement(
id: number,
- path?: Array
+ path?: Array,
): InspectedElementPayload {
const isCurrent = isMostRecentlyInspectedElementCurrent(id);
@@ -2369,10 +2372,10 @@ export function attach(
value: cleanForBridge(
getInObject(
((mostRecentlyInspectedElement: any): InspectedElement),
- path
+ path,
),
createIsPathWhitelisted(null, secondaryCategory),
- path
+ path,
),
};
} else {
@@ -2413,22 +2416,22 @@ export function attach(
// Clone before cleaning so that we preserve the full data.
// This will enable us to send patches without re-inspecting if hydrated paths are requested.
// (Reducing how often we shallow-render is a better DX for function components that use hooks.)
- const cleanedInspectedElement = { ...mostRecentlyInspectedElement };
+ const cleanedInspectedElement = {...mostRecentlyInspectedElement};
cleanedInspectedElement.context = cleanForBridge(
cleanedInspectedElement.context,
- createIsPathWhitelisted('context', null)
+ createIsPathWhitelisted('context', null),
);
cleanedInspectedElement.hooks = cleanForBridge(
cleanedInspectedElement.hooks,
- createIsPathWhitelisted('hooks', 'hooks')
+ createIsPathWhitelisted('hooks', 'hooks'),
);
cleanedInspectedElement.props = cleanForBridge(
cleanedInspectedElement.props,
- createIsPathWhitelisted('props', null)
+ createIsPathWhitelisted('props', null),
);
cleanedInspectedElement.state = cleanForBridge(
cleanedInspectedElement.state,
- createIsPathWhitelisted('state', null)
+ createIsPathWhitelisted('state', null),
);
return {
@@ -2453,7 +2456,7 @@ export function attach(
console.groupCollapsed(
`[Click to expand] %c<${result.displayName || 'Component'} />`,
// --dom-tag-name-color is the CSS variable Chrome styles HTML elements with in the console.
- 'color: var(--dom-tag-name-color); font-weight: normal;'
+ 'color: var(--dom-tag-name-color); font-weight: normal;',
);
}
if (result.props !== null) {
@@ -2474,7 +2477,7 @@ export function attach(
}
if (window.chrome || /firefox/i.test(navigator.userAgent)) {
console.log(
- 'Right-click any value to save it as a global variable for further inspection.'
+ 'Right-click any value to save it as a global variable for further inspection.',
);
}
if (supportsGroup) {
@@ -2486,7 +2489,7 @@ export function attach(
id: number,
index: number,
path: Array,
- value: any
+ value: any,
) {
const fiber = findCurrentFiberUsingSlowPathById(id);
if (fiber !== null) {
@@ -2566,7 +2569,7 @@ export function attach(
if (rootToCommitProfilingMetadataMap === null) {
throw Error(
- 'getProfilingData() called before any profiling data was recorded'
+ 'getProfilingData() called before any profiling data was recorded',
);
}
@@ -2651,7 +2654,7 @@ export function attach(
interactions: Array.from(allInteractions.entries()),
rootID,
});
- }
+ },
);
return {
@@ -2680,7 +2683,7 @@ export function attach(
const rootID = getFiberID(getPrimaryFiber(root.current));
((displayNamesByRootID: any): DisplayNamesByRootID).set(
rootID,
- getDisplayNameForRoot(root.current)
+ getDisplayNameForRoot(root.current),
);
if (shouldRecordChangeDescriptions) {
@@ -2707,7 +2710,7 @@ export function attach(
) {
startProfiling(
sessionStorageGetItem(SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY) ===
- 'true'
+ 'true',
);
}
@@ -2730,7 +2733,7 @@ export function attach(
typeof scheduleUpdate !== 'function'
) {
throw new Error(
- 'Expected overrideSuspense() to not get called for earlier React versions.'
+ 'Expected overrideSuspense() to not get called for earlier React versions.',
);
}
if (forceFallback) {
@@ -2890,7 +2893,7 @@ export function attach(
}
function getPathFrame(fiber: Fiber): PathFrame {
- const { key } = fiber;
+ const {key} = fiber;
let displayName = getDisplayNameForFiber(fiber);
const index = fiber.index;
switch (fiber.tag) {
diff --git a/packages/react-devtools-shared/src/backend/types.js b/packages/react-devtools-shared/src/backend/types.js
index 2a08164decc21..6a23c0132c7b9 100644
--- a/packages/react-devtools-shared/src/backend/types.js
+++ b/packages/react-devtools-shared/src/backend/types.js
@@ -1,8 +1,11 @@
// @flow
-import type { ComponentFilter, ElementType } from 'react-devtools-shared/src/types';
-import type { Interaction } from 'react-devtools-shared/src/devtools/views/Profiler/types';
-import type { ResolveNativeStyle } from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
+import type {
+ ComponentFilter,
+ ElementType,
+} from 'react-devtools-shared/src/types';
+import type {Interaction} from 'react-devtools-shared/src/devtools/views/Profiler/types';
+import type {ResolveNativeStyle} from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
type BundleType =
| 0 // PROD
@@ -50,7 +53,7 @@ export type Fiber = {|
sibling: Fiber | null,
index: number,
- ref: null | (((handle: mixed) => void) & { _stringRef: ?string }) | RefObject,
+ ref: null | (((handle: mixed) => void) & {_stringRef: ?string}) | RefObject,
pendingProps: any, // This type will be more specific once we overload the tag.
memoizedProps: any, // The props used to create the output.
@@ -87,7 +90,7 @@ type Dispatcher = any;
export type GetFiberIDForNative = (
component: NativeType,
- findNearestUnfilteredAncestor?: boolean
+ findNearestUnfilteredAncestor?: boolean,
) => number | null;
export type FindNativeNodesForFiberID = (id: number) => ?Array;
@@ -122,14 +125,14 @@ export type ReactRenderer = {
fiber: Object,
id: number,
path: Array,
- value: any
+ value: any,
) => void,
// 16.7+
overrideProps?: ?(
fiber: Object,
path: Array,
- value: any
+ value: any,
) => void,
// 16.9+
@@ -137,7 +140,7 @@ export type ReactRenderer = {
setSuspenseHandler?: ?(shouldSuspend: (fiber: Object) => boolean) => void,
// Only injected by React v16.8+ in order to support hooks inspection.
- currentDispatcherRef?: {| current: null | Dispatcher |},
+ currentDispatcherRef?: {|current: null | Dispatcher|},
// Only injected by React v16.9+ in DEV mode.
// Enables DevTools to append owners-only component stack to error messages.
@@ -293,7 +296,7 @@ export type RendererInterface = {
handleCommitFiberUnmount: (fiber: Object) => void,
inspectElement: (
id: number,
- path?: Array
+ path?: Array,
) => InspectedElementPayload,
logElementToConsole: (id: number) => void,
overrideSuspense: (id: number, forceFallback: boolean) => void,
@@ -304,7 +307,7 @@ export type RendererInterface = {
id: number,
index: number,
path: Array,
- value: any
+ value: any,
) => void,
setInProps: (id: number, path: Array, value: any) => void,
setInState: (id: number, path: Array, value: any) => void,
@@ -317,7 +320,7 @@ export type RendererInterface = {
export type Handler = (data: any) => void;
export type DevToolsHook = {
- listeners: { [key: string]: Array },
+ listeners: {[key: string]: Array},
rendererInterfaces: Map,
renderers: Map,
@@ -339,7 +342,7 @@ export type DevToolsHook = {
onCommitFiberRoot: (
rendererID: RendererID,
fiber: Object,
- commitPriority?: number
+ commitPriority?: number,
) => void,
};
diff --git a/packages/react-devtools-shared/src/backend/utils.js b/packages/react-devtools-shared/src/backend/utils.js
index 3028805d736e1..af36eb3db7f09 100644
--- a/packages/react-devtools-shared/src/backend/utils.js
+++ b/packages/react-devtools-shared/src/backend/utils.js
@@ -1,13 +1,13 @@
// @flow
-import { dehydrate } from '../hydration';
+import {dehydrate} from '../hydration';
-import type { DehydratedData } from 'react-devtools-shared/src/devtools/views/Components/types';
+import type {DehydratedData} from 'react-devtools-shared/src/devtools/views/Components/types';
export function cleanForBridge(
data: Object | null,
isPathWhitelisted: (path: Array) => boolean,
- path?: Array = []
+ path?: Array = [],
): DehydratedData | null {
if (data !== null) {
const cleaned = [];
@@ -25,14 +25,14 @@ export function copyWithSet(
obj: Object | Array,
path: Array,
value: any,
- index: number = 0
+ index: number = 0,
): Object | Array {
console.log('[utils] copyWithSet()', obj, path, index, value);
if (index >= path.length) {
return value;
}
const key = path[index];
- const updated = Array.isArray(obj) ? obj.slice() : { ...obj };
+ const updated = Array.isArray(obj) ? obj.slice() : {...obj};
// $FlowFixMe number or string is fine here
updated[key] = copyWithSet(obj[key], path, value, index + 1);
return updated;
diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js b/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js
index 1d838f8c124fa..8a62e828a866c 100644
--- a/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js
+++ b/packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js
@@ -19,7 +19,7 @@ export function hideOverlay() {
export function showOverlay(
elements: Array | null,
componentName: string | null,
- hideAfterTimeout: boolean
+ hideAfterTimeout: boolean,
) {
// TODO (npm-packages) Detect RN and support it somehow
if (window.document == null) {
diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js b/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
index 5e59c2b93ff41..30bd10e261b1b 100644
--- a/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
+++ b/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
@@ -11,7 +11,7 @@ type Rect = {
width: number,
};
-type Box = {| top: number, left: number, width: number, height: number |};
+type Box = {|top: number, left: number, width: number, height: number|};
// Note that the Overlay components are not affected by the active Theme,
// because they highlight elements in the main Chrome window (outside of devtools).
@@ -211,11 +211,11 @@ export default class Overlay {
outerBox.top = Math.min(outerBox.top, box.top - dims.marginTop);
outerBox.right = Math.max(
outerBox.right,
- box.left + box.width + dims.marginRight
+ box.left + box.width + dims.marginRight,
);
outerBox.bottom = Math.max(
outerBox.bottom,
- box.top + box.height + dims.marginBottom
+ box.top + box.height + dims.marginBottom,
);
outerBox.left = Math.min(outerBox.left, box.left - dims.marginLeft);
@@ -234,11 +234,11 @@ export default class Overlay {
this.tip.updateText(
name,
outerBox.right - outerBox.left,
- outerBox.bottom - outerBox.top
+ outerBox.bottom - outerBox.top,
);
const tipBounds = getNestedBoundingClientRect(
this.tipBoundsWindow.document.documentElement,
- this.window
+ this.window,
);
this.tip.updatePosition(
@@ -253,7 +253,7 @@ export default class Overlay {
left: tipBounds.left + this.tipBoundsWindow.scrollX,
height: this.tipBoundsWindow.innerHeight,
width: this.tipBoundsWindow.innerWidth,
- }
+ },
);
}
}
@@ -280,7 +280,7 @@ function getFiber(node) {
return (node: any)[lastFoundInternalKey];
}
let internalKey = Object.keys(node).find(
- key => key.indexOf('__reactInternalInstance') === 0
+ key => key.indexOf('__reactInternalInstance') === 0,
);
if (internalKey) {
lastFoundInternalKey = internalKey;
@@ -322,7 +322,7 @@ function findTipPos(dims, bounds, tipSize) {
top += 'px';
left += 'px';
return {
- style: { top, left },
+ style: {top, left},
};
}
@@ -407,7 +407,7 @@ function mergeRectOffsets(rects: Array): Rect {
// taking into account any offsets caused by intermediate iframes.
function getNestedBoundingClientRect(
node: HTMLElement,
- boundaryWindow: typeof window
+ boundaryWindow: typeof window,
): Rect {
const ownerIframe = getOwnerIframe(node);
if (ownerIframe && ownerIframe !== boundaryWindow) {
diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/index.js b/packages/react-devtools-shared/src/backend/views/Highlighter/index.js
index b8a561fcdeac2..a0c25b2efdfc9 100644
--- a/packages/react-devtools-shared/src/backend/views/Highlighter/index.js
+++ b/packages/react-devtools-shared/src/backend/views/Highlighter/index.js
@@ -3,9 +3,9 @@
import memoize from 'memoize-one';
import throttle from 'lodash.throttle';
import Agent from 'react-devtools-shared/src/backend/agent';
-import { hideOverlay, showOverlay } from './Highlighter';
+import {hideOverlay, showOverlay} from './Highlighter';
-import type { BackendBridge } from 'react-devtools-shared/src/bridge';
+import type {BackendBridge} from 'react-devtools-shared/src/bridge';
// This plug-in provides in-page highlighting of the selected element.
// It is used by the browser extension nad the standalone DevTools shell (when connected to a browser).
@@ -16,11 +16,11 @@ let iframesListeningTo: Set = new Set();
export default function setupHighlighter(
bridge: BackendBridge,
- agent: Agent
+ agent: Agent,
): void {
bridge.addListener(
'clearNativeElementHighlight',
- clearNativeElementHighlight
+ clearNativeElementHighlight,
);
bridge.addListener('highlightNativeElement', highlightNativeElement);
bridge.addListener('shutdown', stopInspectingNative);
@@ -96,9 +96,9 @@ export default function setupHighlighter(
let nodes: ?Array = null;
if (renderer !== null) {
- nodes = ((renderer.findNativeNodesForFiberID(
- id
- ): any): ?Array);
+ nodes = ((renderer.findNativeNodesForFiberID(id): any): ?Array<
+ HTMLElement,
+ >);
}
if (nodes != null && nodes[0] != null) {
@@ -107,7 +107,7 @@ export default function setupHighlighter(
// If the node isn't visible show it before highlighting it.
// We may want to reconsider this; it might be a little disruptive.
// $FlowFixMe Flow only knows about 'start' | 'end'
- node.scrollIntoView({ block: 'nearest', inline: 'nearest' });
+ node.scrollIntoView({block: 'nearest', inline: 'nearest'});
}
showOverlay(nodes, displayName, hideAfterTimeout);
@@ -183,6 +183,6 @@ export default function setupHighlighter(
200,
// Don't change the selection in the very first 200ms
// because those are usually unintentional as you lift the cursor.
- { leading: false }
+ {leading: false},
);
}
diff --git a/packages/react-devtools-shared/src/bridge.js b/packages/react-devtools-shared/src/bridge.js
index c0396cb1fb138..8d9d0e6d4bb7f 100644
--- a/packages/react-devtools-shared/src/bridge.js
+++ b/packages/react-devtools-shared/src/bridge.js
@@ -2,18 +2,18 @@
import EventEmitter from 'node-events';
-import type { ComponentFilter, Wall } from './types';
+import type {ComponentFilter, Wall} from './types';
import type {
InspectedElementPayload,
OwnersList,
ProfilingDataBackend,
RendererID,
} from 'react-devtools-shared/src/backend/types';
-import type { StyleAndLayout as StyleAndLayoutPayload } from 'react-devtools-shared/src/backend/NativeStyleEditor/types';
+import type {StyleAndLayout as StyleAndLayoutPayload} from 'react-devtools-shared/src/backend/NativeStyleEditor/types';
const BATCH_DURATION = 100;
-type ElementAndRendererID = {| id: number, rendererID: RendererID |};
+type ElementAndRendererID = {|id: number, rendererID: RendererID|};
type Message = {|
event: string,
@@ -79,7 +79,7 @@ type BackendEvents = {|
// React Native style editor plug-in.
isNativeStyleEditorSupported: [
- {| isSupported: boolean, validAttributes: ?$ReadOnlyArray |},
+ {|isSupported: boolean, validAttributes: ?$ReadOnlyArray|},
],
NativeStyleEditor_styleAndLayout: [StyleAndLayoutPayload],
|};
@@ -87,7 +87,7 @@ type BackendEvents = {|
type FrontendEvents = {|
clearNativeElementHighlight: [],
getOwnersList: [ElementAndRendererID],
- getProfilingData: [{| rendererID: RendererID |}],
+ getProfilingData: [{|rendererID: RendererID|}],
getProfilingStatus: [],
highlightNativeElement: [HighlightElementInDOM],
inspectElement: [InspectElementParams],
@@ -117,7 +117,7 @@ type FrontendEvents = {|
class Bridge<
OutgoingEvents: Object,
- IncomingEvents: Object
+ IncomingEvents: Object,
> extends EventEmitter<{|
...IncomingEvents,
...OutgoingEvents,
@@ -151,7 +151,7 @@ class Bridge<
) {
if (this._isShutdown) {
console.warn(
- `Cannot send message "${event}" through a Bridge that has been shutdown.`
+ `Cannot send message "${event}" through a Bridge that has been shutdown.`,
);
return;
}
diff --git a/packages/react-devtools-shared/src/constants.js b/packages/react-devtools-shared/src/constants.js
index 4fa9fbbc95bcb..c538ddbfb60fe 100644
--- a/packages/react-devtools-shared/src/constants.js
+++ b/packages/react-devtools-shared/src/constants.js
@@ -57,4 +57,4 @@ try {
COMPACT_LINE_HEIGHT = 10;
}
-export { COMFORTABLE_LINE_HEIGHT, COMPACT_LINE_HEIGHT };
+export {COMFORTABLE_LINE_HEIGHT, COMPACT_LINE_HEIGHT};
diff --git a/packages/react-devtools-shared/src/devtools/ProfilerStore.js b/packages/react-devtools-shared/src/devtools/ProfilerStore.js
index e60233d8a17bb..4967ef1b38a9e 100644
--- a/packages/react-devtools-shared/src/devtools/ProfilerStore.js
+++ b/packages/react-devtools-shared/src/devtools/ProfilerStore.js
@@ -1,12 +1,12 @@
// @flow
import EventEmitter from 'node-events';
-import { prepareProfilingDataFrontendFromBackendAndStore } from './views/Profiler/utils';
+import {prepareProfilingDataFrontendFromBackendAndStore} from './views/Profiler/utils';
import ProfilingCache from './ProfilingCache';
import Store from './store';
-import type { FrontendBridge } from 'react-devtools-shared/src/bridge';
-import type { ProfilingDataBackend } from 'react-devtools-shared/src/backend/types';
+import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
+import type {ProfilingDataBackend} from 'react-devtools-shared/src/backend/types';
import type {
CommitDataFrontend,
ProfilingDataForRootFrontend,
@@ -71,7 +71,7 @@ export default class ProfilerStore extends EventEmitter<{|
constructor(
bridge: FrontendBridge,
store: Store,
- defaultIsProfiling: boolean
+ defaultIsProfiling: boolean,
) {
super();
@@ -103,7 +103,7 @@ export default class ProfilerStore extends EventEmitter<{|
}
throw Error(
- `Could not find commit data for root "${rootID}" and commit ${commitIndex}`
+ `Could not find commit data for root "${rootID}" and commit ${commitIndex}`,
);
}
@@ -143,7 +143,7 @@ export default class ProfilerStore extends EventEmitter<{|
set profilingData(value: ProfilingDataFrontend | null): void {
if (this._isProfiling) {
console.warn(
- 'Profiling data cannot be updated while profiling is in progress.'
+ 'Profiling data cannot be updated while profiling is in progress.',
);
return;
}
@@ -193,7 +193,7 @@ export default class ProfilerStore extends EventEmitter<{|
_takeProfilingSnapshotRecursive = (
elementID: number,
- profilingSnapshots: Map
+ profilingSnapshots: Map,
) => {
const element = this._store.getElementByID(elementID);
if (element !== null) {
@@ -207,7 +207,7 @@ export default class ProfilerStore extends EventEmitter<{|
profilingSnapshots.set(elementID, snapshotNode);
element.children.forEach(childID =>
- this._takeProfilingSnapshotRecursive(childID, profilingSnapshots)
+ this._takeProfilingSnapshotRecursive(childID, profilingSnapshots),
);
}
};
@@ -242,11 +242,11 @@ export default class ProfilerStore extends EventEmitter<{|
return;
}
- const { rendererID } = dataBackend;
+ const {rendererID} = dataBackend;
if (!this._rendererQueue.has(rendererID)) {
throw Error(
- `Unexpected profiling data update from renderer "${rendererID}"`
+ `Unexpected profiling data update from renderer "${rendererID}"`,
);
}
@@ -257,7 +257,7 @@ export default class ProfilerStore extends EventEmitter<{|
this._dataFrontend = prepareProfilingDataFrontendFromBackendAndStore(
this._dataBackends,
this._inProgressOperationsByRootID,
- this._initialSnapshotsByRootID
+ this._initialSnapshotsByRootID,
);
this._dataBackends.splice(0);
@@ -319,7 +319,7 @@ export default class ProfilerStore extends EventEmitter<{|
if (!this._rendererQueue.has(rendererID)) {
this._rendererQueue.add(rendererID);
- this._bridge.send('getProfilingData', { rendererID });
+ this._bridge.send('getProfilingData', {rendererID});
}
});
diff --git a/packages/react-devtools-shared/src/devtools/ProfilingCache.js b/packages/react-devtools-shared/src/devtools/ProfilingCache.js
index 6ffe360efdeee..d84b6dd036034 100644
--- a/packages/react-devtools-shared/src/devtools/ProfilingCache.js
+++ b/packages/react-devtools-shared/src/devtools/ProfilingCache.js
@@ -18,10 +18,10 @@ import {
invalidateChartData as invalidateRankedChartData,
} from 'react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder';
-import type { CommitTree } from 'react-devtools-shared/src/devtools/views/Profiler/types';
-import type { ChartData as FlamegraphChartData } from 'react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder';
-import type { ChartData as InteractionsChartData } from 'react-devtools-shared/src/devtools/views/Profiler/InteractionsChartBuilder';
-import type { ChartData as RankedChartData } from 'react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder';
+import type {CommitTree} from 'react-devtools-shared/src/devtools/views/Profiler/types';
+import type {ChartData as FlamegraphChartData} from 'react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder';
+import type {ChartData as InteractionsChartData} from 'react-devtools-shared/src/devtools/views/Profiler/InteractionsChartBuilder';
+import type {ChartData as RankedChartData} from 'react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder';
export default class ProfilingCache {
_fiberCommits: Map> = new Map();
diff --git a/packages/react-devtools-shared/src/devtools/cache.js b/packages/react-devtools-shared/src/devtools/cache.js
index 1e1279803093b..6c2abe0d8934b 100644
--- a/packages/react-devtools-shared/src/devtools/cache.js
+++ b/packages/react-devtools-shared/src/devtools/cache.js
@@ -1,6 +1,6 @@
// @flow
-import React, { createContext } from 'react';
+import React, {createContext} from 'react';
// Cache implementation was forked from the React repo:
// https://github.com/facebook/react/blob/master/packages/react-cache/src/ReactCache.js
@@ -58,7 +58,7 @@ function readContext(Context, observedBits) {
throw new Error(
'react-cache: read and preload may only be called from within a ' +
"component's render. They are not supported in event handlers or " +
- 'lifecycle methods.'
+ 'lifecycle methods.',
);
}
return dispatcher.readContext(Context, observedBits);
@@ -72,12 +72,12 @@ type Config = {
const entries: Map<
Resource,
- Map | WeakMap
+ Map | WeakMap,
> = new Map();
const resourceConfigs: Map, Config> = new Map();
function getEntriesForResource(
- resource: any
+ resource: any,
): Map | WeakMap {
let entriesForResource = ((entries.get(resource): any): Map);
if (entriesForResource === undefined) {
@@ -93,7 +93,7 @@ function accessResult (
resource: any,
fetch: Input => Thenable,
input: Input,
- key: Key
+ key: Key,
): Result {
const entriesForResource = getEntriesForResource(resource);
const entry = entriesForResource.get(key);
@@ -113,7 +113,7 @@ function accessResult (
rejectedResult.status = Rejected;
rejectedResult.value = error;
}
- }
+ },
);
const newResult: PendingResult = {
status: Pending,
@@ -129,7 +129,7 @@ function accessResult (
export function createResource (
fetch: Input => Thenable,
hashInput: Input => Key,
- config?: Config = {}
+ config?: Config = {},
): Resource {
const resource = {
clear(): void {
diff --git a/packages/react-devtools-shared/src/devtools/index.js b/packages/react-devtools-shared/src/devtools/index.js
index 7e5c8b76b2e82..df7a644d16833 100644
--- a/packages/react-devtools-shared/src/devtools/index.js
+++ b/packages/react-devtools-shared/src/devtools/index.js
@@ -1,6 +1,6 @@
// @flow
-import type { FrontendBridge } from 'react-devtools-shared/src/bridge';
+import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
type Shell = {|
connect: (callback: Function) => void,
diff --git a/packages/react-devtools-shared/src/devtools/store.js b/packages/react-devtools-shared/src/devtools/store.js
index 6dc4fd2334997..5a8e844107b1c 100644
--- a/packages/react-devtools-shared/src/devtools/store.js
+++ b/packages/react-devtools-shared/src/devtools/store.js
@@ -1,14 +1,14 @@
// @flow
import EventEmitter from 'node-events';
-import { inspect } from 'util';
+import {inspect} from 'util';
import {
TREE_OPERATION_ADD,
TREE_OPERATION_REMOVE,
TREE_OPERATION_REORDER_CHILDREN,
TREE_OPERATION_UPDATE_TREE_BASE_DURATION,
} from '../constants';
-import { ElementTypeRoot } from '../types';
+import {ElementTypeRoot} from '../types';
import {
getSavedComponentFilters,
saveComponentFilters,
@@ -16,14 +16,14 @@ import {
shallowDiffers,
utfDecodeString,
} from '../utils';
-import { localStorageGetItem, localStorageSetItem } from '../storage';
-import { __DEBUG__ } from '../constants';
-import { printStore } from './utils';
+import {localStorageGetItem, localStorageSetItem} from '../storage';
+import {__DEBUG__} from '../constants';
+import {printStore} from './utils';
import ProfilerStore from './ProfilerStore';
-import type { Element } from './views/Components/types';
-import type { ComponentFilter, ElementType } from '../types';
-import type { FrontendBridge } from 'react-devtools-shared/src/bridge';
+import type {Element} from './views/Components/types';
+import type {ComponentFilter, ElementType} from '../types';
+import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
const debug = (methodName, ...args) => {
if (__DEBUG__) {
@@ -31,7 +31,7 @@ const debug = (methodName, ...args) => {
`%cStore %c${methodName}`,
'color: green; font-weight: bold;',
'font-weight: bold;',
- ...args
+ ...args,
);
}
};
@@ -161,16 +161,16 @@ export default class Store extends EventEmitter<{|
bridge.addListener('operations', this.onBridgeOperations);
bridge.addListener(
'overrideComponentFilters',
- this.onBridgeOverrideComponentFilters
+ this.onBridgeOverrideComponentFilters,
);
bridge.addListener('shutdown', this.onBridgeShutdown);
bridge.addListener(
'isBackendStorageAPISupported',
- this.onBridgeStorageSupported
+ this.onBridgeStorageSupported,
);
bridge.addListener(
'isNativeStyleEditorSupported',
- this.onBridgeNativeStyleEditorSupported
+ this.onBridgeNativeStyleEditorSupported,
);
this._profilerStore = new ProfilerStore(bridge, this, isProfiling);
@@ -187,11 +187,11 @@ export default class Store extends EventEmitter<{|
// These maps should always be the same size as the number of roots
this.assertMapSizeMatchesRootCount(
this._rootIDToCapabilities,
- '_rootIDToCapabilities'
+ '_rootIDToCapabilities',
);
this.assertMapSizeMatchesRootCount(
this._rootIDToRendererID,
- '_rootIDToRendererID'
+ '_rootIDToRendererID',
);
}
@@ -204,7 +204,7 @@ export default class Store extends EventEmitter<{|
map.size
} items\n\n${inspect(map, {
depth: 20,
- })}`
+ })}`,
);
}
}
@@ -217,7 +217,7 @@ export default class Store extends EventEmitter<{|
localStorageSetItem(
LOCAL_STORAGE_COLLAPSE_ROOTS_BY_DEFAULT_KEY,
- value ? 'true' : 'false'
+ value ? 'true' : 'false',
);
this.emit('collapseNodesByDefault');
@@ -236,10 +236,10 @@ export default class Store extends EventEmitter<{|
// Filter updates are expensive to apply (since they impact the entire tree).
// Let's determine if they've changed and avoid doing this work if they haven't.
const prevEnabledComponentFilters = this._componentFilters.filter(
- filter => filter.isEnabled
+ filter => filter.isEnabled,
);
const nextEnabledComponentFilters = value.filter(
- filter => filter.isEnabled
+ filter => filter.isEnabled,
);
let haveEnabledFiltersChanged =
prevEnabledComponentFilters.length !== nextEnabledComponentFilters.length;
@@ -293,7 +293,7 @@ export default class Store extends EventEmitter<{|
localStorageSetItem(
LOCAL_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY,
- value ? 'true' : 'false'
+ value ? 'true' : 'false',
);
this.emit('recordChangeDescriptions');
@@ -339,7 +339,7 @@ export default class Store extends EventEmitter<{|
console.warn(
`Invalid index ${index} specified; store contains ${
this.numElements
- } items.`
+ } items.`,
);
return null;
@@ -417,7 +417,7 @@ export default class Store extends EventEmitter<{|
while (true) {
const current = ((this._idToElement.get(currentID): any): Element);
- const { children } = current;
+ const {children} = current;
for (let i = 0; i < children.length; i++) {
const childID = children[i];
if (childID === previousID) {
@@ -474,7 +474,7 @@ export default class Store extends EventEmitter<{|
const sortedIDs = Array.from(unsortedIDs).sort(
(idA, idB) =>
((this.getIndexOfElementID(idA): any): number) -
- ((this.getIndexOfElementID(idB): any): number)
+ ((this.getIndexOfElementID(idB): any): number),
);
// Next we need to determine the appropriate depth for each element in the list.
@@ -506,7 +506,7 @@ export default class Store extends EventEmitter<{|
throw Error('Invalid owners list');
}
- list.push({ ...element, depth });
+ list.push({...element, depth});
}
});
}
@@ -573,7 +573,7 @@ export default class Store extends EventEmitter<{|
const weightDelta = 1 - element.weight;
let parentElement = ((this._idToElement.get(
- element.parentID
+ element.parentID,
): any): Element);
while (parentElement != null) {
// We don't need to break on a collapsed parent in the same way as the expand case below.
@@ -599,7 +599,7 @@ export default class Store extends EventEmitter<{|
const weightDelta = newWeight - oldWeight;
let parentElement = ((this._idToElement.get(
- currentElement.parentID
+ currentElement.parentID,
): any): Element);
while (parentElement != null) {
parentElement.weight += weightDelta;
@@ -624,7 +624,7 @@ export default class Store extends EventEmitter<{|
if (didMutate) {
let weightAcrossRoots = 0;
this._roots.forEach(rootID => {
- const { weight } = ((this.getElementByID(rootID): any): Element);
+ const {weight} = ((this.getElementByID(rootID): any): Element);
weightAcrossRoots += weight;
});
this._weightAcrossRoots = weightAcrossRoots;
@@ -639,7 +639,7 @@ export default class Store extends EventEmitter<{|
_adjustParentTreeWeight = (
parentElement: Element | null,
- weightDelta: number
+ weightDelta: number,
) => {
let isInsideCollapsedSubTree = false;
@@ -654,7 +654,7 @@ export default class Store extends EventEmitter<{|
}
parentElement = ((this._idToElement.get(
- parentElement.parentID
+ parentElement.parentID,
): any): Element);
}
@@ -704,7 +704,7 @@ export default class Store extends EventEmitter<{|
while (i < stringTableEnd) {
const nextLength = operations[i++];
const nextString = utfDecodeString(
- (operations.slice(i, i + nextLength): any)
+ (operations.slice(i, i + nextLength): any),
);
stringTable.push(nextString);
i += nextLength;
@@ -721,7 +721,7 @@ export default class Store extends EventEmitter<{|
if (this._idToElement.has(id)) {
throw Error(
- `Cannot add node ${id} because a node with that id is already in the Store.`
+ `Cannot add node ${id} because a node with that id is already in the Store.`,
);
}
@@ -778,18 +778,18 @@ export default class Store extends EventEmitter<{|
if (__DEBUG__) {
debug(
'Add',
- `node ${id} (${displayName || 'null'}) as child of ${parentID}`
+ `node ${id} (${displayName || 'null'}) as child of ${parentID}`,
);
}
if (!this._idToElement.has(parentID)) {
throw Error(
- `Cannot add child ${id} to parent ${parentID} because parent node was not found in the Store.`
+ `Cannot add child ${id} to parent ${parentID} because parent node was not found in the Store.`,
);
}
const parentElement = ((this._idToElement.get(
- parentID
+ parentID,
): any): Element);
parentElement.children.push(id);
@@ -836,14 +836,14 @@ export default class Store extends EventEmitter<{|
if (!this._idToElement.has(id)) {
throw Error(
- `Cannot remove node ${id} because no matching node was found in the Store.`
+ `Cannot remove node ${id} because no matching node was found in the Store.`,
);
}
i = i + 1;
const element = ((this._idToElement.get(id): any): Element);
- const { children, ownerID, parentID, weight } = element;
+ const {children, ownerID, parentID, weight} = element;
if (children.length > 0) {
throw new Error(`Node ${id} was removed before its children.`);
}
@@ -868,7 +868,7 @@ export default class Store extends EventEmitter<{|
parentElement = ((this._idToElement.get(parentID): any): Element);
if (parentElement === undefined) {
throw Error(
- `Cannot remove node ${id} from parent ${parentID} because no matching node was found in the Store.`
+ `Cannot remove node ${id} from parent ${parentID} because no matching node was found in the Store.`,
);
}
const index = parentElement.children.indexOf(id);
@@ -895,7 +895,7 @@ export default class Store extends EventEmitter<{|
if (!this._idToElement.has(id)) {
throw Error(
- `Cannot reorder children for node ${id} because no matching node was found in the Store.`
+ `Cannot reorder children for node ${id} because no matching node was found in the Store.`,
);
}
@@ -903,7 +903,7 @@ export default class Store extends EventEmitter<{|
const children = element.children;
if (children.length !== numChildren) {
throw Error(
- `Children cannot be added or removed during a reorder operation.`
+ `Children cannot be added or removed during a reorder operation.`,
);
}
@@ -915,7 +915,7 @@ export default class Store extends EventEmitter<{|
const childElement = this._idToElement.get(childID);
if (childElement == null || childElement.parentID !== id) {
console.error(
- `Children cannot be added or removed during a reorder operation.`
+ `Children cannot be added or removed during a reorder operation.`,
);
}
}
@@ -946,14 +946,14 @@ export default class Store extends EventEmitter<{|
this._hasOwnerMetadata = false;
this._supportsProfiling = false;
this._rootIDToCapabilities.forEach(
- ({ hasOwnerMetadata, supportsProfiling }) => {
+ ({hasOwnerMetadata, supportsProfiling}) => {
if (hasOwnerMetadata) {
this._hasOwnerMetadata = true;
}
if (supportsProfiling) {
this._supportsProfiling = true;
}
- }
+ },
);
this.emit('roots');
@@ -977,7 +977,7 @@ export default class Store extends EventEmitter<{|
// This action should also override the saved filters too,
// else reloading the frontend without reloading the backend would leave things out of sync.
onBridgeOverrideComponentFilters = (
- componentFilters: Array
+ componentFilters: Array,
) => {
this._componentFilters = componentFilters;
@@ -993,7 +993,7 @@ export default class Store extends EventEmitter<{|
this._bridge.removeListener('shutdown', this.onBridgeShutdown);
this._bridge.removeListener(
'isBackendStorageAPISupported',
- this.onBridgeStorageSupported
+ this.onBridgeStorageSupported,
);
};
diff --git a/packages/react-devtools-shared/src/devtools/utils.js b/packages/react-devtools-shared/src/devtools/utils.js
index 2f70961ef789a..2979c640b2ec3 100644
--- a/packages/react-devtools-shared/src/devtools/utils.js
+++ b/packages/react-devtools-shared/src/devtools/utils.js
@@ -1,6 +1,6 @@
// @flow
-import type { Element } from './views/Components/types';
+import type {Element} from './views/Components/types';
import type Store from './store';
export function printElement(element: Element, includeWeight: boolean = false) {
@@ -28,7 +28,10 @@ export function printElement(element: Element, includeWeight: boolean = false) {
'null'}${key}>${hocs}${suffix}`;
}
-export function printOwnersList(elements: Array, includeWeight: boolean = false) {
+export function printOwnersList(
+ elements: Array,
+ includeWeight: boolean = false,
+) {
return elements
.map(element => printElement(element, includeWeight))
.join('\n');
@@ -40,7 +43,7 @@ export function printStore(store: Store, includeWeight: boolean = false) {
let rootWeight = 0;
store.roots.forEach(rootID => {
- const { weight } = ((store.getElementByID(rootID): any): Element);
+ const {weight} = ((store.getElementByID(rootID): any): Element);
snapshotLines.push('[root]' + (includeWeight ? ` (${weight})` : ''));
@@ -62,7 +65,7 @@ export function printStore(store: Store, includeWeight: boolean = false) {
throw Error(
`Inconsistent Store state. Individual root weights (${rootWeight}) do not match total weight (${
store.numElements
- })`
+ })`,
);
}
@@ -71,4 +74,4 @@ export function printStore(store: Store, includeWeight: boolean = false) {
store.assertExpectedRootMapSizes();
return snapshotLines.join('\n');
-}
\ No newline at end of file
+}
diff --git a/packages/react-devtools-shared/src/devtools/views/ButtonIcon.js b/packages/react-devtools-shared/src/devtools/views/ButtonIcon.js
index 6c3887fe66645..eea3a5d0d72f0 100644
--- a/packages/react-devtools-shared/src/devtools/views/ButtonIcon.js
+++ b/packages/react-devtools-shared/src/devtools/views/ButtonIcon.js
@@ -36,7 +36,7 @@ type Props = {|
type: IconType,
|};
-export default function ButtonIcon({ className = '', type }: Props) {
+export default function ButtonIcon({className = '', type}: Props) {
let pathData = null;
switch (type) {
case 'add':
@@ -128,8 +128,7 @@ export default function ButtonIcon({ className = '', type }: Props) {
className={`${styles.ButtonIcon} ${className}`}
width="24"
height="24"
- viewBox="0 0 24 24"
- >
+ viewBox="0 0 24 24">
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Badge.js b/packages/react-devtools-shared/src/devtools/views/Components/Badge.js
index 613a32a3961c6..845c06c089c71 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/Badge.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/Badge.js
@@ -1,10 +1,13 @@
// @flow
-import React, { Fragment } from 'react';
-import { ElementTypeMemo, ElementTypeForwardRef } from 'react-devtools-shared/src/types';
+import React, {Fragment} from 'react';
+import {
+ ElementTypeMemo,
+ ElementTypeForwardRef,
+} from 'react-devtools-shared/src/types';
import styles from './Badge.css';
-import type { ElementType } from 'react-devtools-shared/src/types';
+import type {ElementType} from 'react-devtools-shared/src/types';
type Props = {|
className?: string,
@@ -12,7 +15,7 @@ type Props = {|
type: ElementType,
|};
-export default function Badge({ className, hocDisplayNames, type }: Props) {
+export default function Badge({className, hocDisplayNames, type}: Props) {
let hocDisplayName = null;
let totalBadgeCount = 0;
let typeLabel = null;
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Components.js b/packages/react-devtools-shared/src/devtools/views/Components/Components.js
index 3b57757a47f7b..503470a85a7e8 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/Components.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/Components.js
@@ -1,15 +1,15 @@
// @flow
-import React, { Suspense } from 'react';
+import React, {Suspense} from 'react';
import Tree from './Tree';
import SelectedElement from './SelectedElement';
-import { InspectedElementContextController } from './InspectedElementContext';
-import { NativeStyleContextController } from './NativeStyleEditor/context';
-import { OwnersListContextController } from './OwnersListContext';
+import {InspectedElementContextController} from './InspectedElementContext';
+import {NativeStyleContextController} from './NativeStyleEditor/context';
+import {OwnersListContextController} from './OwnersListContext';
import portaledContent from '../portaledContent';
-import { ModalDialog } from '../ModalDialog';
+import {ModalDialog} from '../ModalDialog';
import SettingsModal from 'react-devtools-shared/src/devtools/views/Settings/SettingsModal';
-import { SettingsModalContextController } from 'react-devtools-shared/src/devtools/views/Settings/SettingsModalContext';
+import {SettingsModalContextController} from 'react-devtools-shared/src/devtools/views/Settings/SettingsModalContext';
import styles from './Components.css';
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js b/packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js
index 3238315a1572a..116902b9f31e0 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/EditableValue.js
@@ -1,6 +1,6 @@
// @flow
-import React, { Fragment, useCallback, useRef, useState } from 'react';
+import React, {Fragment, useCallback, useRef, useState} from 'react';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import styles from './EditableValue.css';
@@ -29,7 +29,7 @@ export default function EditableValue({
}
const handleChange = useCallback(
- ({ target }) => {
+ ({target}) => {
if (dataType === 'boolean') {
setEditableValue(target.checked);
overrideValueFn(path, target.checked);
@@ -38,24 +38,27 @@ export default function EditableValue({
}
setHasPendingChanges(true);
},
- [dataType, overrideValueFn, path]
+ [dataType, overrideValueFn, path],
);
- const handleReset = useCallback(() => {
- setEditableValue(value);
- setHasPendingChanges(false);
+ const handleReset = useCallback(
+ () => {
+ setEditableValue(value);
+ setHasPendingChanges(false);
- if (inputRef.current !== null) {
- inputRef.current.focus();
- }
- }, [value]);
+ if (inputRef.current !== null) {
+ inputRef.current.focus();
+ }
+ },
+ [value],
+ );
const handleKeyDown = useCallback(
event => {
// Prevent keydown events from e.g. change selected element in the tree
event.stopPropagation();
- const { key } = event;
+ const {key} = event;
if (key === 'Enter') {
if (dataType === 'number') {
@@ -75,7 +78,7 @@ export default function EditableValue({
setHasPendingChanges(false);
}
},
- [editableValue, dataType, overrideValueFn, path, value]
+ [editableValue, dataType, overrideValueFn, path, value],
);
// Render different input types based on the dataType
@@ -125,15 +128,15 @@ export default function EditableValue({
value={inputValue}
/>
)}
- {hasPendingChanges && dataType !== 'boolean' && (
-
-
-
- )}
+ {hasPendingChanges &&
+ dataType !== 'boolean' && (
+
+
+
+ )}
);
}
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/Element.js b/packages/react-devtools-shared/src/devtools/views/Components/Element.js
index a8dfebdb5901e..78e0a02bb560c 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/Element.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/Element.js
@@ -1,15 +1,15 @@
// @flow
-import React, { Fragment, useContext, useMemo, useState } from 'react';
+import React, {Fragment, useContext, useMemo, useState} from 'react';
import Store from 'react-devtools-shared/src/devtools/store';
import Badge from './Badge';
import ButtonIcon from '../ButtonIcon';
-import { createRegExp } from '../utils';
-import { TreeDispatcherContext, TreeStateContext } from './TreeContext';
-import { StoreContext } from '../context';
+import {createRegExp} from '../utils';
+import {TreeDispatcherContext, TreeStateContext} from './TreeContext';
+import {StoreContext} from '../context';
-import type { ItemData } from './Tree';
-import type { Element } from './types';
+import type {ItemData} from './Tree';
+import type {Element} from './types';
import styles from './Element.css';
@@ -19,10 +19,10 @@ type Props = {
style: Object,
};
-export default function ElementView({ data, index, style }: Props) {
+export default function ElementView({data, index, style}: Props) {
const store = useContext(StoreContext);
- const { ownerFlatTree, ownerID, selectedElementID } = useContext(
- TreeStateContext
+ const {ownerFlatTree, ownerID, selectedElementID} = useContext(
+ TreeStateContext,
);
const dispatch = useContext(TreeDispatcherContext);
@@ -33,17 +33,17 @@ export default function ElementView({ data, index, style }: Props) {
const [isHovered, setIsHovered] = useState(false);
- const { isNavigatingWithKeyboard, onElementMouseEnter, treeFocused } = data;
+ const {isNavigatingWithKeyboard, onElementMouseEnter, treeFocused} = data;
const id = element === null ? null : element.id;
const isSelected = selectedElementID === id;
const handleDoubleClick = () => {
if (id !== null) {
- dispatch({ type: 'SELECT_OWNER', payload: id });
+ dispatch({type: 'SELECT_OWNER', payload: id});
}
};
- const handleMouseDown = ({ metaKey }) => {
+ const handleMouseDown = ({metaKey}) => {
if (id !== null) {
dispatch({
type: 'SELECT_ELEMENT_BY_ID',
@@ -103,8 +103,7 @@ export default function ElementView({ data, index, style }: Props) {
onMouseDown={handleMouseDown}
onDoubleClick={handleDoubleClick}
style={style}
- data-depth={depth}
- >
+ data-depth={depth}>
{/* This wrapper is used by Tree for measurement purposes. */}
+ }}>
{ownerID === null ? (
) : null}
@@ -124,8 +122,7 @@ export default function ElementView({ data, index, style }: Props) {
+ onDoubleClick={handleKeyDoubleClick}>
{key}
"
@@ -152,8 +149,8 @@ type ExpandCollapseToggleProps = {|
store: Store,
|};
-function ExpandCollapseToggle({ element, store }: ExpandCollapseToggleProps) {
- const { children, id, isCollapsed } = element;
+function ExpandCollapseToggle({element, store}: ExpandCollapseToggleProps) {
+ const {children, id, isCollapsed} = element;
const toggleCollapsed = event => {
event.preventDefault();
@@ -176,8 +173,7 @@ function ExpandCollapseToggle({ element, store }: ExpandCollapseToggleProps) {
className={styles.ExpandCollapseToggle}
onMouseDown={stopPropagation}
onClick={toggleCollapsed}
- onDoubleClick={swallowDoubleClick}
- >
+ onDoubleClick={swallowDoubleClick}>
);
@@ -188,13 +184,14 @@ type DisplayNameProps = {|
id: number,
|};
-function DisplayName({ displayName, id }: DisplayNameProps) {
- const { searchIndex, searchResults, searchText } = useContext(
- TreeStateContext
+function DisplayName({displayName, id}: DisplayNameProps) {
+ const {searchIndex, searchResults, searchText} = useContext(TreeStateContext);
+ const isSearchResult = useMemo(
+ () => {
+ return searchResults.includes(id);
+ },
+ [id, searchResults],
);
- const isSearchResult = useMemo(() => {
- return searchResults.includes(id);
- }, [id, searchResults]);
const isCurrentResult =
searchIndex !== null && id === searchResults[searchIndex];
@@ -218,10 +215,9 @@ function DisplayName({ displayName, id }: DisplayNameProps) {
children.push(
+ className={isCurrentResult ? styles.CurrentHighlight : styles.Highlight}>
{displayName.slice(startIndex, stopIndex)}
-
+ ,
);
if (stopIndex < displayName.length) {
children.push({displayName.slice(stopIndex)} );
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/ExpandCollapseToggle.js b/packages/react-devtools-shared/src/devtools/views/Components/ExpandCollapseToggle.js
index 61fdca7f33d26..d47357839c105 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/ExpandCollapseToggle.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/ExpandCollapseToggle.js
@@ -19,8 +19,7 @@ export default function ExpandCollapseToggle({
setIsOpen(prevIsOpen => !prevIsOpen)}
- title={`${isOpen ? 'Collapse' : 'Expand'} prop value`}
- >
+ title={`${isOpen ? 'Collapse' : 'Expand'} prop value`}>
);
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/HocBadges.js b/packages/react-devtools-shared/src/devtools/views/Components/HocBadges.js
index e88dbdef07f15..0e57e7977266e 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/HocBadges.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/HocBadges.js
@@ -1,17 +1,20 @@
// @flow
import React from 'react';
-import { ElementTypeForwardRef, ElementTypeMemo } from 'react-devtools-shared/src/types';
+import {
+ ElementTypeForwardRef,
+ ElementTypeMemo,
+} from 'react-devtools-shared/src/types';
import styles from './HocBadges.css';
-import type { Element } from './types';
+import type {Element} from './types';
type Props = {|
element: Element,
|};
-export default function HocBadges({ element }: Props) {
- const { hocDisplayNames, type } = ((element: any): Element);
+export default function HocBadges({element}: Props) {
+ const {hocDisplayNames, type} = ((element: any): Element);
let typeBadge = null;
if (type === ElementTypeMemo) {
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js b/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js
index c35d0a743e3d7..2bc07bd4d9915 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/HooksTree.js
@@ -1,20 +1,20 @@
// @flow
-import { copy } from 'clipboard-js';
-import React, { useCallback, useContext, useState } from 'react';
-import { BridgeContext, StoreContext } from '../context';
+import {copy} from 'clipboard-js';
+import React, {useCallback, useContext, useState} from 'react';
+import {BridgeContext, StoreContext} from '../context';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import EditableValue from './EditableValue';
import ExpandCollapseToggle from './ExpandCollapseToggle';
-import { InspectedElementContext } from './InspectedElementContext';
+import {InspectedElementContext} from './InspectedElementContext';
import KeyValue from './KeyValue';
-import { serializeHooksForCopy } from '../utils';
+import {serializeHooksForCopy} from '../utils';
import styles from './HooksTree.css';
-import { meta } from '../../../hydration';
+import {meta} from '../../../hydration';
-import type { InspectPath } from './SelectedElement';
-import type { HooksNode, HooksTree } from 'react-debug-tools/src/ReactDebugHooks';
+import type {InspectPath} from './SelectedElement';
+import type {HooksNode, HooksTree} from 'react-debug-tools/src/ReactDebugHooks';
type HooksTreeViewProps = {|
canEditHooks: boolean,
@@ -22,13 +22,13 @@ type HooksTreeViewProps = {|
id: number,
|};
-export function HooksTreeView({ canEditHooks, hooks, id }: HooksTreeViewProps) {
- const { getInspectedElementPath } = useContext(InspectedElementContext);
+export function HooksTreeView({canEditHooks, hooks, id}: HooksTreeViewProps) {
+ const {getInspectedElementPath} = useContext(InspectedElementContext);
const inspectPath = useCallback(
(path: Array) => {
getInspectedElementPath(id, ['hooks', ...path]);
},
- [getInspectedElementPath, id]
+ [getInspectedElementPath, id],
);
const handleCopy = useCallback(() => copy(serializeHooksForCopy(hooks)), [
hooks,
@@ -93,14 +93,8 @@ type HookViewProps = {|
path: Array,
|};
-function HookView({
- canEditHooks,
- hook,
- id,
- inspectPath,
- path,
-}: HookViewProps) {
- const { name, id: hookID, isStateEditable, subHooks, value } = hook;
+function HookView({canEditHooks, hook, id, inspectPath, path}: HookViewProps) {
+ const {name, id: hookID, isStateEditable, subHooks, value} = hook;
const bridge = useContext(BridgeContext);
const store = useContext(StoreContext);
@@ -109,7 +103,7 @@ function HookView({
const toggleIsOpen = useCallback(
() => setIsOpen(prevIsOpen => !prevIsOpen),
- []
+ [],
);
if (hook.hasOwnProperty(meta.inspected)) {
@@ -178,8 +172,7 @@ function HookView({
+ className={name !== '' ? styles.Name : styles.NameAnonymous}>
{name || 'Anonymous'}
@@ -202,8 +195,7 @@ function HookView({
+ className={name !== '' ? styles.Name : styles.NameAnonymous}>
{name || 'Anonymous'}
{' '}
{/* $FlowFixMe */}
@@ -260,8 +252,7 @@ function HookView({
typeof overrideValueFn === 'function'
? styles.EditableName
: styles.Name
- }
- >
+ }>
{name}
{typeof overrideValueFn === 'function' ? (
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectHostNodesToggle.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectHostNodesToggle.js
index 06fad24c10977..bd2e6eee4036d 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectHostNodesToggle.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectHostNodesToggle.js
@@ -1,7 +1,7 @@
// @flow
-import React, { useCallback, useContext, useEffect, useState } from 'react';
-import { BridgeContext } from '../context';
+import React, {useCallback, useContext, useEffect, useState} from 'react';
+import {BridgeContext} from '../context';
import Toggle from '../Toggle';
import ButtonIcon from '../ButtonIcon';
@@ -19,22 +19,24 @@ export default function InspectHostNodesToggle() {
bridge.send('stopInspectingNative', false);
}
},
- [bridge]
+ [bridge],
);
- useEffect(() => {
- const onStopInspectingNative = () => setIsInspecting(false);
- bridge.addListener('stopInspectingNative', onStopInspectingNative);
- return () =>
- bridge.removeListener('stopInspectingNative', onStopInspectingNative);
- }, [bridge]);
+ useEffect(
+ () => {
+ const onStopInspectingNative = () => setIsInspecting(false);
+ bridge.addListener('stopInspectingNative', onStopInspectingNative);
+ return () =>
+ bridge.removeListener('stopInspectingNative', onStopInspectingNative);
+ },
+ [bridge],
+ );
return (
+ title="Select an element in the page to inspect it">
);
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js
index 951a34b34f2fc..a31229ace1c2d 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js
@@ -8,12 +8,12 @@ import React, {
useMemo,
useState,
} from 'react';
-import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';
-import { createResource } from '../../cache';
-import { BridgeContext, StoreContext } from '../context';
-import { hydrate, fillInPath } from 'react-devtools-shared/src/hydration';
-import { TreeStateContext } from './TreeContext';
-import { separateDisplayNameAndHOCs } from 'react-devtools-shared/src/utils';
+import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
+import {createResource} from '../../cache';
+import {BridgeContext, StoreContext} from '../context';
+import {hydrate, fillInPath} from 'react-devtools-shared/src/hydration';
+import {TreeStateContext} from './TreeContext';
+import {separateDisplayNameAndHOCs} from 'react-devtools-shared/src/utils';
import type {
InspectedElement as InspectedElementBackend,
@@ -24,14 +24,14 @@ import type {
Element,
InspectedElement as InspectedElementFrontend,
} from 'react-devtools-shared/src/devtools/views/Components/types';
-import type { Resource, Thenable } from '../../cache';
+import type {Resource, Thenable} from '../../cache';
export type GetInspectedElementPath = (
id: number,
- path: Array
+ path: Array,
) => void;
export type GetInspectedElement = (
- id: number
+ id: number,
) => InspectedElementFrontend | null;
type Context = {|
@@ -52,7 +52,7 @@ const inProgressRequests: WeakMap = new WeakMap();
const resource: Resource<
Element,
Element,
- InspectedElementFrontend
+ InspectedElementFrontend,
> = createResource(
(element: Element) => {
let request = inProgressRequests.get(element);
@@ -65,19 +65,19 @@ const resource: Resource<
resolveFn = resolve;
});
- inProgressRequests.set(element, { promise, resolveFn });
+ inProgressRequests.set(element, {promise, resolveFn});
return promise;
},
(element: Element) => element,
- { useWeakMap: true }
+ {useWeakMap: true},
);
type Props = {|
children: React$Node,
|};
-function InspectedElementContextController({ children }: Props) {
+function InspectedElementContextController({children}: Props) {
const bridge = useContext(BridgeContext);
const store = useContext(StoreContext);
@@ -86,10 +86,10 @@ function InspectedElementContextController({ children }: Props) {
(id: number, path: Array) => {
const rendererID = store.getRendererIDForElement(id);
if (rendererID !== null) {
- bridge.send('inspectElement', { id, path, rendererID });
+ bridge.send('inspectElement', {id, path, rendererID});
}
},
- [bridge, store]
+ [bridge, store],
);
const getInspectedElement = useCallback(
@@ -101,13 +101,13 @@ function InspectedElementContextController({ children }: Props) {
return null;
}
},
- [store]
+ [store],
);
// It's very important that this context consumes selectedElementID and not inspectedElementID.
// Otherwise the effect that sends the "inspect" message across the bridge-
// would itself be blocked by the same render that suspends (waiting for the data).
- const { selectedElementID } = useContext(TreeStateContext);
+ const {selectedElementID} = useContext(TreeStateContext);
const [
currentlyInspectedElement,
@@ -115,166 +115,173 @@ function InspectedElementContextController({ children }: Props) {
] = useState(null);
// This effect handler invalidates the suspense cache and schedules rendering updates with React.
- useEffect(() => {
- const onInspectedElement = (data: InspectedElementPayload) => {
- const { id } = data;
-
- let element;
-
- switch (data.type) {
- case 'no-change':
- case 'not-found':
- // No-op
- break;
- case 'hydrated-path':
- // Merge new data into previous object and invalidate cache
- element = store.getElementByID(id);
- if (element !== null) {
- if (currentlyInspectedElement != null) {
- const value = hydrateHelper(data.value, data.path);
- const inspectedElement = { ...currentlyInspectedElement };
-
- fillInPath(inspectedElement, data.path, value);
-
- resource.write(element, inspectedElement);
-
- // Schedule update with React if the curently-selected element has been invalidated.
- if (id === selectedElementID) {
- setCurrentlyInspectedElement(inspectedElement);
- }
- }
- }
- break;
- case 'full-data':
- const {
- canEditFunctionProps,
- canEditHooks,
- canToggleSuspense,
- canViewSource,
- source,
- type,
- owners,
- context,
- hooks,
- props,
- state,
- } = ((data.value: any): InspectedElementBackend);
-
- const inspectedElement: InspectedElementFrontend = {
- canEditFunctionProps,
- canEditHooks,
- canToggleSuspense,
- canViewSource,
- id,
- source,
- type,
- owners:
- owners === null
- ? null
- : owners.map(owner => {
- const [
- displayName,
- hocDisplayNames,
- ] = separateDisplayNameAndHOCs(
- owner.displayName,
- owner.type
- );
- return {
- ...owner,
- displayName,
- hocDisplayNames,
- };
- }),
- context: hydrateHelper(context),
- hooks: hydrateHelper(hooks),
- props: hydrateHelper(props),
- state: hydrateHelper(state),
- };
-
- element = store.getElementByID(id);
- if (element !== null) {
- const request = inProgressRequests.get(element);
- if (request != null) {
- inProgressRequests.delete(element);
- batchedUpdates(() => {
- request.resolveFn(inspectedElement);
- setCurrentlyInspectedElement(inspectedElement);
- });
- } else {
- resource.write(element, inspectedElement);
-
- // Schedule update with React if the curently-selected element has been invalidated.
- if (id === selectedElementID) {
- setCurrentlyInspectedElement(inspectedElement);
- }
- }
- }
- break;
- default:
- break;
- }
- };
-
- bridge.addListener('inspectedElement', onInspectedElement);
- return () => bridge.removeListener('inspectedElement', onInspectedElement);
- }, [bridge, currentlyInspectedElement, selectedElementID, store]);
-
- // This effect handler polls for updates on the currently selected element.
- useEffect(() => {
- if (selectedElementID === null) {
- return () => {};
- }
+ useEffect(
+ () => {
+ const onInspectedElement = (data: InspectedElementPayload) => {
+ const {id} = data;
- const rendererID = store.getRendererIDForElement(selectedElementID);
+ let element;
- let timeoutID: TimeoutID | null = null;
+ switch (data.type) {
+ case 'no-change':
+ case 'not-found':
+ // No-op
+ break;
+ case 'hydrated-path':
+ // Merge new data into previous object and invalidate cache
+ element = store.getElementByID(id);
+ if (element !== null) {
+ if (currentlyInspectedElement != null) {
+ const value = hydrateHelper(data.value, data.path);
+ const inspectedElement = {...currentlyInspectedElement};
- const sendRequest = () => {
- timeoutID = null;
+ fillInPath(inspectedElement, data.path, value);
- if (rendererID !== null) {
- bridge.send('inspectElement', { id: selectedElementID, rendererID });
- }
- };
-
- // Send the initial inspection request.
- // We'll poll for an update in the response handler below.
- sendRequest();
+ resource.write(element, inspectedElement);
- const onInspectedElement = (data: InspectedElementPayload) => {
- // If this is the element we requested, wait a little bit and then ask for another update.
- if (data.id === selectedElementID) {
- switch (data.type) {
- case 'no-change':
+ // Schedule update with React if the curently-selected element has been invalidated.
+ if (id === selectedElementID) {
+ setCurrentlyInspectedElement(inspectedElement);
+ }
+ }
+ }
+ break;
case 'full-data':
- case 'hydrated-path':
- if (timeoutID !== null) {
- clearTimeout(timeoutID);
+ const {
+ canEditFunctionProps,
+ canEditHooks,
+ canToggleSuspense,
+ canViewSource,
+ source,
+ type,
+ owners,
+ context,
+ hooks,
+ props,
+ state,
+ } = ((data.value: any): InspectedElementBackend);
+
+ const inspectedElement: InspectedElementFrontend = {
+ canEditFunctionProps,
+ canEditHooks,
+ canToggleSuspense,
+ canViewSource,
+ id,
+ source,
+ type,
+ owners:
+ owners === null
+ ? null
+ : owners.map(owner => {
+ const [
+ displayName,
+ hocDisplayNames,
+ ] = separateDisplayNameAndHOCs(
+ owner.displayName,
+ owner.type,
+ );
+ return {
+ ...owner,
+ displayName,
+ hocDisplayNames,
+ };
+ }),
+ context: hydrateHelper(context),
+ hooks: hydrateHelper(hooks),
+ props: hydrateHelper(props),
+ state: hydrateHelper(state),
+ };
+
+ element = store.getElementByID(id);
+ if (element !== null) {
+ const request = inProgressRequests.get(element);
+ if (request != null) {
+ inProgressRequests.delete(element);
+ batchedUpdates(() => {
+ request.resolveFn(inspectedElement);
+ setCurrentlyInspectedElement(inspectedElement);
+ });
+ } else {
+ resource.write(element, inspectedElement);
+
+ // Schedule update with React if the curently-selected element has been invalidated.
+ if (id === selectedElementID) {
+ setCurrentlyInspectedElement(inspectedElement);
+ }
+ }
}
- timeoutID = setTimeout(sendRequest, 1000);
break;
default:
break;
}
+ };
+
+ bridge.addListener('inspectedElement', onInspectedElement);
+ return () =>
+ bridge.removeListener('inspectedElement', onInspectedElement);
+ },
+ [bridge, currentlyInspectedElement, selectedElementID, store],
+ );
+
+ // This effect handler polls for updates on the currently selected element.
+ useEffect(
+ () => {
+ if (selectedElementID === null) {
+ return () => {};
}
- };
- bridge.addListener('inspectedElement', onInspectedElement);
+ const rendererID = store.getRendererIDForElement(selectedElementID);
- return () => {
- bridge.removeListener('inspectedElement', onInspectedElement);
+ let timeoutID: TimeoutID | null = null;
- if (timeoutID !== null) {
- clearTimeout(timeoutID);
- }
- };
- }, [bridge, selectedElementID, store]);
+ const sendRequest = () => {
+ timeoutID = null;
+
+ if (rendererID !== null) {
+ bridge.send('inspectElement', {id: selectedElementID, rendererID});
+ }
+ };
+
+ // Send the initial inspection request.
+ // We'll poll for an update in the response handler below.
+ sendRequest();
+
+ const onInspectedElement = (data: InspectedElementPayload) => {
+ // If this is the element we requested, wait a little bit and then ask for another update.
+ if (data.id === selectedElementID) {
+ switch (data.type) {
+ case 'no-change':
+ case 'full-data':
+ case 'hydrated-path':
+ if (timeoutID !== null) {
+ clearTimeout(timeoutID);
+ }
+ timeoutID = setTimeout(sendRequest, 1000);
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ bridge.addListener('inspectedElement', onInspectedElement);
+
+ return () => {
+ bridge.removeListener('inspectedElement', onInspectedElement);
+
+ if (timeoutID !== null) {
+ clearTimeout(timeoutID);
+ }
+ };
+ },
+ [bridge, selectedElementID, store],
+ );
const value = useMemo(
- () => ({ getInspectedElement, getInspectedElementPath }),
+ () => ({getInspectedElement, getInspectedElementPath}),
// InspectedElement is used to invalidate the cache and schedule an update with React.
// eslint-disable-next-line react-hooks/exhaustive-deps
- [currentlyInspectedElement, getInspectedElement, getInspectedElementPath]
+ [currentlyInspectedElement, getInspectedElement, getInspectedElementPath],
);
return (
@@ -286,13 +293,13 @@ function InspectedElementContextController({ children }: Props) {
function hydrateHelper(
dehydratedData: any | null,
- path?: Array
+ path?: Array,
): Object | null {
if (dehydratedData !== null) {
- let { cleaned, data } = dehydratedData;
+ let {cleaned, data} = dehydratedData;
if (path) {
- const { length } = path;
+ const {length} = path;
if (length > 0) {
// Hydration helper requires full paths, but inspection dehydrates with relative paths.
// In that event it's important that we adjust the "cleaned" paths to match.
@@ -306,4 +313,4 @@ function hydrateHelper(
}
}
-export { InspectedElementContext, InspectedElementContextController };
+export {InspectedElementContext, InspectedElementContextController};
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js
index a296a6306fb36..2accaeb317314 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js
@@ -1,14 +1,14 @@
// @flow
-import { copy } from 'clipboard-js';
-import React, { useCallback } from 'react';
+import {copy} from 'clipboard-js';
+import React, {useCallback} from 'react';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import KeyValue from './KeyValue';
-import { serializeDataForCopy } from '../utils';
+import {serializeDataForCopy} from '../utils';
import styles from './InspectedElementTree.css';
-import type { InspectPath } from './SelectedElement';
+import type {InspectPath} from './SelectedElement';
type OverrideValueFn = (path: Array, value: any) => void;
@@ -29,9 +29,10 @@ export default function InspectedElementTree({
}: Props) {
const isEmpty = data === null || Object.keys(data).length === 0;
- const handleCopy = useCallback(() => copy(serializeDataForCopy(((data: any): Object))), [
- data,
- ]);
+ const handleCopy = useCallback(
+ () => copy(serializeDataForCopy(((data: any): Object))),
+ [data],
+ );
if (isEmpty && !showWhenEmpty) {
return null;
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js
index 7fd333a0a8ff9..d312789c40e50 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js
@@ -1,14 +1,14 @@
// @flow
-import React, { useEffect, useRef, useState } from 'react';
-import type { Element } from 'react';
+import React, {useEffect, useRef, useState} from 'react';
+import type {Element} from 'react';
import EditableValue from './EditableValue';
import ExpandCollapseToggle from './ExpandCollapseToggle';
-import { getMetaValueLabel } from '../utils';
-import { meta } from '../../../hydration';
+import {getMetaValueLabel} from '../utils';
+import {meta} from '../../../hydration';
import styles from './KeyValue.css';
-import type { InspectPath } from './SelectedElement';
+import type {InspectPath} from './SelectedElement';
type OverrideValueFn = (path: Array, value: any) => void;
@@ -40,17 +40,20 @@ export default function KeyValue({
value[meta.inspectable] &&
value[meta.size] !== 0;
- useEffect(() => {
- if (
- isInspectable &&
- isOpen &&
- !prevIsOpenRef.current &&
- typeof inspectPath === 'function'
- ) {
- inspectPath(path);
- }
- prevIsOpenRef.current = isOpen;
- }, [inspectPath, isInspectable, isOpen, path]);
+ useEffect(
+ () => {
+ if (
+ isInspectable &&
+ isOpen &&
+ !prevIsOpenRef.current &&
+ typeof inspectPath === 'function'
+ ) {
+ inspectPath(path);
+ }
+ prevIsOpenRef.current = isOpen;
+ },
+ [inspectPath, isInspectable, isOpen, path],
+ );
const toggleIsOpen = () => setIsOpen(prevIsOpen => !prevIsOpen);
@@ -107,8 +110,7 @@ export default function KeyValue({
)}
+ onClick={isInspectable ? toggleIsOpen : undefined}>
{name}
{getMetaValueLabel(value)}
@@ -135,8 +137,7 @@ export default function KeyValue({
key={`${depth}-root`}
className={styles.Item}
hidden={hidden}
- style={style}
- >
+ style={style}>
{hasChildren ? (
) : (
@@ -144,12 +145,11 @@ export default function KeyValue({
)}
+ onClick={hasChildren ? toggleIsOpen : undefined}>
{name}
Array
-