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

Commit 3f63d11

Browse files
committed
Merge branch 'master' into tabs
Conflicts: frontend/Store.js
2 parents fc453b5 + e4c55f4 commit 3f63d11

34 files changed

+455
-443
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
**/build/**
44
**/node_modules/**
5+
flow/*

.eslintrc

Lines changed: 54 additions & 222 deletions
Large diffs are not rendered by default.

.flowconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
.*node_modules/node-libs-browser.*
66
.*node_modules/webpack.*
77

8-
[include]
9-
108
[libs]
11-
agent/flow.js
9+
flow
1210

1311
[options]
1412
suppress_type=$FlowIssue
@@ -18,3 +16,6 @@ suppress_type=$FixMe
1816
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-3]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
1917
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-3]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+
2018
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
19+
20+
[version]
21+
0.15.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Atom/Nuclide, and as a standalone Electron app.
1414
The official extensions represent the current stable release.
1515

1616
- [Chrome extension](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi)
17-
- Firefox extension (coming soon)
17+
- [Firefox extension](https://addons.mozilla.org/firefox/addon/react-devtools/)
1818
- Standalone app (coming soon)
1919

2020
If you inspect an element or launch the developer tools on a React page, you

agent/Agent.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ class Agent extends EventEmitter {
236236
}
237237
var renderer = this.renderers.get(id);
238238
if (this.reactInternals[renderer].getNativeFromReactElement) {
239-
// $FlowFixMe I literally just checked this
240239
return this.reactInternals[renderer].getNativeFromReactElement(component);
241240
}
242241
}
@@ -268,7 +267,7 @@ class Agent extends EventEmitter {
268267
try {
269268
// $FlowFixMe possibly null - it's not null
270269
component = this.reactInternals[renderer].getReactElementFromNative(node);
271-
} catch (e){}
270+
} catch (e) {}
272271
if (component) {
273272
return this.getId(component);
274273
}

agent/Bridge.js

Lines changed: 33 additions & 2 deletions
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);
@@ -325,7 +357,6 @@ class Bridge {
325357
if (isFn && (name === 'arguments' || name === 'callee' || name === 'caller')) {
326358
return;
327359
}
328-
// $FlowFixMe flow thinks `val` might be null
329360
result[name] = dehydrate(val[name], cleaned, [name]);
330361
});
331362

backend/getData.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ function getData(element: Object): DataType {
2727
var text = null;
2828
var publicInstance = null;
2929
var nodeType = 'Native';
30-
if (element._renderedComponent) {
30+
if (element._currentElement === null || element._currentElement === false) {
31+
nodeType = 'Empty';
32+
} else if (element._renderedComponent) {
3133
nodeType = 'NativeWrapper';
3234
children = [element._renderedComponent];
3335
props = element._instance.props;

backend/types.js

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

1313
export type DataType = {
14-
nodeType: 'Native' | 'Wrapper' | 'NativeWrapper' | 'Composite' | 'Text',
14+
nodeType: 'Native' | 'Wrapper' | 'NativeWrapper' | 'Composite' | 'Text' | 'Empty',
1515
type: ?(string | AnyFn),
1616
name: ?string,
1717
props: ?Object,

flow/chrome.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
declare var chrome: {
14+
devtools: {
15+
network: {
16+
onNavigated: {
17+
addListener: (cb: (url: string) => void) => void,
18+
removeListener: (cb: () => void) => void,
19+
},
20+
},
21+
inspectedWindow: {
22+
eval: (code: string, cb?: (res: any, err: ?Object) => any) => void,
23+
tabId: number,
24+
},
25+
panels: {
26+
create: (title: string, icon: string, filename: string, cb: (panel: {
27+
onHidden: {
28+
addListener: (cb: (window: Object) => void) => void,
29+
},
30+
onShown: {
31+
addListener: (cb: (window: Object) => void) => void,
32+
}
33+
}) => void) => void,
34+
},
35+
},
36+
tabs: {
37+
executeScript: (tabId: number, options: Object, fn: () => void) => void,
38+
},
39+
runtime: {
40+
getURL: (path: string) => string,
41+
connect: (config: Object) => {
42+
disconnect: () => void,
43+
onMessage: {
44+
addListener: (fn: (message: Object) => void) => void,
45+
},
46+
onDisconnect: {
47+
addListener: (fn: (message: Object) => void) => void,
48+
},
49+
postMessage: (data: Object) => void,
50+
},
51+
onConnect: {
52+
addListener: (fn: (port: {
53+
name: string,
54+
sender: {
55+
tab: {
56+
id: number,
57+
},
58+
},
59+
}) => void) => void,
60+
},
61+
},
62+
};
File renamed without changes.

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/ContextMenu.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ var HighlightHover = require('./HighlightHover');
1616
var assign = require('object-assign');
1717
var decorate = require('./decorate');
1818

19-
type MenuItem = {
19+
export type MenuItem = {
2020
title: string,
2121
action: () => void
2222
};
2323

24-
export type MenuItem = MenuItem;
25-
2624
class ContextMenu {
2725
_clickout: (evt: Object) => void;
2826

frontend/Node.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,44 @@ class Node {
101101
onMouseDown: this.props.onSelect,
102102
};
103103

104-
if (node.get('name') === null) {
105-
var content = children || node.get('text');
104+
var nodeType = node.get('nodeType');
105+
if (nodeType === 'Text' || nodeType === 'Empty') {
106+
var tag;
107+
if (nodeType === 'Text') {
108+
var content = node.get('text');
109+
tag =
110+
<span style={styles.tagText}>
111+
<span style={styles.openTag}>
112+
"
113+
</span>
114+
<span style={styles.textContent}>{content}</span>
115+
<span style={styles.closeTag}>
116+
"
117+
</span>
118+
</span>;
119+
} else if (nodeType === 'Empty') {
120+
tag =
121+
<span style={styles.tagText}>
122+
<span style={styles.falseyLiteral}>null</span>
123+
</span>;
124+
}
106125
return (
107126
<div style={styles.container}>
108127
<div style={headStyles} ref={h => this._head = h} {...tagEvents}>
109-
<span style={styles.tagText}>
110-
<span style={styles.openTag}>
111-
"
112-
</span>
113-
<span style={styles.textContent}>{content}</span>
114-
<span style={styles.closeTag}>
115-
"
116-
</span>
117-
</span>
128+
{tag}
118129
</div>
119130
</div>
120131
);
121132
}
122133

123-
var isCustom = node.get('nodeType') === 'Composite';
134+
var isCustom = nodeType === 'Composite';
124135

125136
var tagStyle = isCustom ? styles.customTagName : styles.tagName;
126137

127138
// Single-line tag (collapsed / simple content / no content)
128139
if (!children || typeof children === 'string' || !children.length) {
129140
var name = node.get('name');
130-
var content = children || node.get('text');
141+
var content = children;
131142
return (
132143
<div style={styles.container}>
133144
<div style={headStyles} ref={h => this._head = h} {...tagEvents}>
@@ -280,6 +291,10 @@ var styles = {
280291
textContent: {
281292
},
282293

294+
falseyLiteral: {
295+
fontStyle: 'italic',
296+
},
297+
283298
closeTag: {
284299
},
285300

0 commit comments

Comments
 (0)