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

Commit 1205ca4

Browse files
committed
Merge branch 'master' into tabs
Conflicts: frontend/Store.js
2 parents fc453b5 + 8f4d693 commit 1205ca4

File tree

9 files changed

+202
-11
lines changed

9 files changed

+202
-11
lines changed

agent/Bridge.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ type PayloadType = {
4545
type: 'callback',
4646
id: string,
4747
args: Array<any>,
48+
} | {
49+
type: 'pause',
50+
} | {
51+
type: 'resume',
4852
} | EventPayload;
4953

5054
/**
@@ -113,6 +117,7 @@ class Bridge {
113117
_waiting: ?number;
114118
_wall: Wall;
115119
_callers: {[key: string]: AnyFn};
120+
_paused: boolean;
116121

117122
constructor() {
118123
this._cbs = new Map();
@@ -123,6 +128,7 @@ class Bridge {
123128
this._waiting = null;
124129
this._lastTime = 5;
125130
this._callers = {};
131+
this._paused = false;
126132
}
127133

128134
attach(wall: Wall) {
@@ -172,6 +178,18 @@ class Bridge {
172178
this._callers[name] = handler;
173179
}
174180

181+
pause() {
182+
this._wall.send({
183+
type: 'pause',
184+
});
185+
}
186+
187+
resume() {
188+
this._wall.send({
189+
type: 'resume',
190+
});
191+
}
192+
175193
sendOne(evt: string, data: any) {
176194
var cleaned = [];
177195
var san = dehydrate(data, cleaned);
@@ -182,7 +200,7 @@ class Bridge {
182200
}
183201

184202
send(evt: string, data: any) {
185-
if (!this._waiting) {
203+
if (!this._waiting && !this._paused) {
186204
this._buffer = [];
187205
var nextTime = this._lastTime * 3;
188206
if (nextTime > 500) {
@@ -245,6 +263,20 @@ class Bridge {
245263
}
246264

247265
_handleMessage(payload: PayloadType) {
266+
if (payload.type === 'resume') {
267+
this._paused = false;
268+
this._waiting = null;
269+
this.flush();
270+
return;
271+
}
272+
273+
if (payload.type === 'pause') {
274+
this._paused = true;
275+
clearTimeout(this._waiting);
276+
this._waiting = null;
277+
return;
278+
}
279+
248280
if (payload.type === 'callback') {
249281
this._cbs.get(payload.id)(...payload.args);
250282
this._cbs.delete(payload.id);

frontend/Breadcrumb.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @flow
10+
*/
11+
'use strict';
12+
13+
import type Store from './Store';
14+
import type {ElementID} from './types';
15+
16+
var React = require('react');
17+
var assign = require('object-assign');
18+
var decorate = require('./decorate');
19+
20+
class Breadcrumb extends React.Component {
21+
render() {
22+
return (
23+
<ul style={styles.container}>
24+
{this.props.path.map(({id, node}) => {
25+
var isSelected = id === this.props.selected;
26+
var style = assign(
27+
{},
28+
styles.item,
29+
node.get('nodeType') === 'Composite' && styles.composite,
30+
isSelected && styles.selected
31+
);
32+
return (
33+
<li
34+
style={style}
35+
onMouseOver={() => this.props.hover(id, true)}
36+
onMouseOut={() => this.props.hover(id, false)}
37+
onClick={isSelected ? null : () => this.props.select(id)}
38+
>
39+
{node.get('name') || '"' + node.get('text') + '"'}
40+
</li>
41+
);
42+
})}
43+
</ul>
44+
);
45+
}
46+
}
47+
48+
var styles = {
49+
container: {
50+
borderTop: '1px solid #ccc',
51+
backgroundColor: 'white',
52+
listStyle: 'none',
53+
padding: 0,
54+
margin: 0,
55+
},
56+
57+
selected: {
58+
cursor: 'default',
59+
backgroundColor: 'rgb(56, 121, 217)',
60+
color: 'white',
61+
},
62+
63+
composite: {
64+
color: 'rgb(136, 18, 128)',
65+
},
66+
67+
item: {
68+
padding: '3px 7px',
69+
cursor: 'pointer',
70+
display: 'inline-block',
71+
},
72+
};
73+
74+
function getBreadcrumbPath(store: Store): Array<{id: ElementID, node: Object}> {
75+
var path = [];
76+
var current = store.breadcrumbHead;
77+
while (current) {
78+
path.unshift({
79+
id: current,
80+
node: store.get(current),
81+
});
82+
current = store.skipWrapper(store.getParent(current), true);
83+
}
84+
return path;
85+
}
86+
87+
module.exports = decorate({
88+
listeners: () => ['breadcrumbHead', 'selected'],
89+
props(store, props) {
90+
return {
91+
select: id => store.selectBreadcrumb(id),
92+
hover: (id, isHovered) => store.setHover(id, isHovered),
93+
selected: store.selected,
94+
path: getBreadcrumbPath(store),
95+
};
96+
},
97+
}, Breadcrumb);

frontend/Panel.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ class Panel extends React.Component {
8282
}
8383
}
8484

85+
pauseTransfer() {
86+
if (this._bridge) {
87+
this._bridge.pause();
88+
}
89+
}
90+
91+
resumeTransfer() {
92+
if (this._bridge) {
93+
this._bridge.resume();
94+
}
95+
}
96+
8597
reload() {
8698
if (this._unsub) {
8799
this._unsub();

frontend/Store.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Store extends EventEmitter {
8181
_nodes: Map;
8282
_parents: Map;
8383
_nodesByName: Map;
84+
_eventQueue: Array<string>;
85+
_eventTimer: ?number;
8486

8587
// Public state
8688
contextMenu: ?ContextMenu;
@@ -91,6 +93,7 @@ class Store extends EventEmitter {
9193
searchText: string;
9294
selectedTab: string;
9395
selected: ?ElementID;
96+
breadcrumbHead: ?ElementID;
9497
// an object describing the capabilities of the inspected runtime.
9598
capabilities: {
9699
scroll?: boolean,
@@ -110,6 +113,7 @@ class Store extends EventEmitter {
110113
this.hovered = null;
111114
this.selected = null;
112115
this.selectedTab = 'Elements';
116+
this.breadcrumbHead = null;
113117
this.isBottomTagSelected = false;
114118
this.searchText = '';
115119
this.capabilities = {};
@@ -125,7 +129,9 @@ class Store extends EventEmitter {
125129
this.roots = this.roots.push(id);
126130
if (!this.selected) {
127131
this.selected = this.skipWrapper(id);
132+
this.breadcrumbHead = this.selected;
128133
this.emit('selected');
134+
this.emit('breadcrumbHead');
129135
this._bridge.send('selected', this.selected);
130136
}
131137
this.emit('roots');
@@ -140,6 +146,24 @@ class Store extends EventEmitter {
140146
});
141147

142148
this._establishConnection();
149+
this._eventQueue = [];
150+
this._eventTimer = null;
151+
}
152+
153+
emit(evt: string): boolean {
154+
if (!this._eventTimer) {
155+
this._eventTimer = setTimeout(() => {
156+
this._eventQueue.forEach(evt => EventEmitter.prototype.emit.call(this, evt));
157+
this._eventQueue = [];
158+
this._eventTimer = null;
159+
}, 50);
160+
this._eventQueue = [];
161+
}
162+
if (this._eventQueue.indexOf(evt) === -1) {
163+
this._eventQueue.push(evt);
164+
}
165+
// to appease flow
166+
return true;
143167
}
144168

145169
// Public actions
@@ -310,6 +334,13 @@ class Store extends EventEmitter {
310334
this.emit('hover');
311335
}
312336

337+
selectBreadcrumb(id: ElementID) {
338+
this._revealDeep(id);
339+
this.changeSearch('');
340+
this.isBottomTagSelected = false;
341+
this.select(id, false, true);
342+
}
343+
313344
selectTop(id: ?ElementID, noHighlight?: boolean) {
314345
this.isBottomTagSelected = false;
315346
this.select(id, noHighlight);
@@ -320,7 +351,7 @@ class Store extends EventEmitter {
320351
this.select(id);
321352
}
322353

323-
select(id: ?ElementID, noHighlight?: boolean) {
354+
select(id: ?ElementID, noHighlight?: boolean, keepBreadcrumb?: boolean) {
324355
var oldSel = this.selected;
325356
this.selected = id;
326357
if (oldSel) {
@@ -329,6 +360,10 @@ class Store extends EventEmitter {
329360
if (id) {
330361
this.emit(id);
331362
}
363+
if (!keepBreadcrumb) {
364+
this.breadcrumbHead = id;
365+
this.emit('breadcrumbHead');
366+
}
332367
this.emit('selected');
333368
this._bridge.send('selected', id);
334369
if (!noHighlight) {

frontend/TreeView.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
var React = require('react');
1414
var Node = require('./Node');
15+
var Breadcrumb = require('./Breadcrumb');
1516

1617
var decorate = require('./decorate');
1718

@@ -72,9 +73,12 @@ class TreeView extends React.Component {
7273

7374
return (
7475
<div style={styles.container}>
75-
{this.props.roots.map(id => (
76-
<Node key={id} id={id} depth={0} />
77-
)).toJS()}
76+
<div style={styles.scroll}>
77+
{this.props.roots.map(id => (
78+
<Node key={id} id={id} depth={0} />
79+
)).toJS()}
80+
</div>
81+
<Breadcrumb />
7882
</div>
7983
);
8084
}
@@ -86,17 +90,24 @@ TreeView.childContextTypes = {
8690

8791
var styles = {
8892
container: {
89-
padding: 3,
90-
overflow: 'auto',
9193
fontFamily: 'Menlo, monospace',
9294
fontSize: '11px',
9395
flex: 1,
96+
display: 'flex',
97+
flexDirection: 'column',
98+
minHeight: 0,
9499

95100
WebkitUserSelect: 'none',
96101
MozUserSelect: 'none',
97102
MsUserSelect: 'none',
98103
userSelect: 'none',
99104
},
105+
scroll: {
106+
padding: 3,
107+
overflow: 'auto',
108+
minHeight: 0,
109+
flex: 1,
110+
},
100111
};
101112

102113
var WrappedTreeView = decorate({

shells/chrome/manifest.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"manifest_version": 2,
33
"name": "React Developer Tools",
44
"description": "Adds React debugging tools to the Chrome Developer Tools.",
5-
"version": "0.14",
5+
"version": "0.14.1",
6+
"minimum_chrome_version": "43",
67
"icons": {
78
"48": "icons/icon48.png",
89
"128": "icons/icon128.png"
@@ -14,7 +15,7 @@
1415
"web_accessible_resources": [ "main.html", "panel.html", "build/backend.js"],
1516

1617
"background": {
17-
"scripts": [ "./build/background.js" ],
18+
"scripts": [ "build/background.js" ],
1819
"persistent": false
1920
},
2021

@@ -26,7 +27,7 @@
2627
"content_scripts": [
2728
{
2829
"matches": ["<all_urls>"],
29-
"js": ["./build/inject.js"],
30+
"js": ["build/inject.js"],
3031
"run_at": "document_start"
3132
}
3233
]

shells/chrome/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ function createPanelIfReactLoaded() {
5757
// selection
5858
window.panel.getNewSelection();
5959
reactPanel = window.panel;
60+
reactPanel.resumeTransfer();
6061
});
6162
panel.onHidden.addListener(function () {
6263
if (reactPanel) {
6364
reactPanel.hideHighlight();
65+
reactPanel.pauseTransfer();
6466
}
6567
});
6668
});

shells/plain/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#target {
88
flex: 1;
99
border: none;
10+
border-bottom: 1px solid #ccc;
1011
}
1112
#container {
1213
display: flex;

shells/plain/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
module.exports = {
13-
devtool: 'cheap-module-eval-source-map',
13+
devtool: false,//'cheap-module-eval-source-map',
1414
entry: {
1515
backend: './backend.js',
1616
container: './container.js',

0 commit comments

Comments
 (0)