Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit e303b2e

Browse files
committed
Merge pull request #118 from facebook/fix-show-elements-pane
fix "show elements pane" in chrome extension #109
2 parents 10e4f68 + 2af26cf commit e303b2e

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

agent/Bridge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var hydrate = require('./hydrate');
1515
var dehydrate = require('./dehydrate');
1616

1717
type AnyFn = (...x: any) => any;
18-
type Wall = {
18+
export type Wall = {
1919
listen: (fn: (data: PayloadType) => void) => void,
2020
send: (data: PayloadType) => void,
2121
};

frontend/Panel.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@ var NativeStyler = require('../plugins/ReactNativeStyle/ReactNativeStyle.js');
2222
var consts = require('../agent/consts');
2323

2424
import type {DOMEvent} from './types';
25+
import type {Wall} from '../agent/Bridge';
2526

26-
type Props = {
27+
export type Props = {
2728
alreadyFoundReact: boolean,
28-
inject: () => void,
29+
inject: (done: (wall: Wall, onDisconnect?: () => void) => void) => void,
2930
checkForReact: (cb: (isReact: boolean) => void) => void,
3031
reload: () => void,
3132

3233
// optionals
3334
showComponentSource: ?() => void,
34-
reloadSubscribe: ?() => () => void,
35-
showAttrSource: ?() => void,
36-
executeFn: ?() => void,
37-
selectElement: ?() => void,
38-
getNewSelection: ?() => void,
35+
reloadSubscribe: ?(reloadFn: () => void) => () => void,
36+
showAttrSource: ?(path: Array<string>) => void,
37+
executeFn: ?(path: Array<string>) => void,
38+
selectElement: ?(id: string, bridge: Bridge) => void,
39+
getNewSelection: ?(bridge: Bridge) => void,
3940
};
4041

4142
class Panel extends React.Component {
@@ -107,6 +108,7 @@ class Panel extends React.Component {
107108
return;
108109
}
109110
invariant(this.props.selectElement, 'cannot send selection if props.selectElement is not defined');
111+
// $FlowFixMe either id or this._store.selected is a string
110112
this.props.selectElement(id || this._store.selected, this._bridge);
111113
}
112114

shells/chrome/src/panel.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
var checkForReact = require('./checkForReact');
1414
var inject = require('./inject');
1515

16+
import type {Props} from '../../../frontend/Panel';
17+
1618
type Listenable = {
1719
addListener: (fn: (message: Object) => void) => void,
1820
}
@@ -43,9 +45,10 @@ declare var chrome: {
4345
},
4446
};
4547

46-
var config = {
48+
var config: Props = {
4749
reload,
4850
checkForReact,
51+
alreadyFoundReact: false,
4952
reloadSubscribe(reloadFn) {
5053
chrome.devtools.network.onNavigated.addListener(reloadFn);
5154
return () => {
@@ -56,7 +59,7 @@ var config = {
5659
chrome.devtools.inspectedWindow.eval('window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0 = $0');
5760
bridge.send('checkSelection');
5861
},
59-
selectElement(bridge, id) {
62+
selectElement(id, bridge) {
6063
bridge.send('putSelectedNode', id);
6164
setTimeout(() => {
6265
chrome.devtools.inspectedWindow.eval('inspect(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$node)');
@@ -94,7 +97,7 @@ var config = {
9497
},
9598
inject(done) {
9699
inject(chrome.runtime.getURL('build/backend.js'), () => {
97-
var port = this._port = chrome.runtime.connect({
100+
var port = chrome.runtime.connect({
98101
name: '' + chrome.devtools.inspectedWindow.tabId,
99102
});
100103
var disconnected = false;

0 commit comments

Comments
 (0)