[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
* @providesModule Inspector
|
|
|
|
* @flow
|
|
|
|
*/
|
2016-04-21 16:27:50 +00:00
|
|
|
|
|
|
|
/* eslint-disable dot-notation, no-dimensions-get-window */
|
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-01-03 21:38:50 +00:00
|
|
|
const Dimensions = require('Dimensions');
|
|
|
|
const InspectorOverlay = require('InspectorOverlay');
|
|
|
|
const InspectorPanel = require('InspectorPanel');
|
|
|
|
const Platform = require('Platform');
|
|
|
|
const React = require('React');
|
2017-05-30 16:55:20 +00:00
|
|
|
const ReactNative = require('ReactNative');
|
2017-01-03 21:38:50 +00:00
|
|
|
const StyleSheet = require('StyleSheet');
|
|
|
|
const Touchable = require('Touchable');
|
|
|
|
const UIManager = require('UIManager');
|
|
|
|
const View = require('View');
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
|
2017-05-30 16:55:20 +00:00
|
|
|
const emptyObject = require('fbjs/lib/emptyObject');
|
2017-06-19 15:42:34 +00:00
|
|
|
const invariant = require('fbjs/lib/invariant');
|
2017-05-30 16:55:20 +00:00
|
|
|
|
|
|
|
export type ReactRenderer = {
|
|
|
|
getInspectorDataForViewTag: (viewTag: number) => Object,
|
|
|
|
};
|
|
|
|
|
|
|
|
const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
|
|
const renderer: ReactRenderer = findRenderer();
|
|
|
|
// required for devtools to be able to edit react native styles
|
|
|
|
hook.resolveRNStyle = require('flattenStyle');
|
|
|
|
|
|
|
|
function findRenderer(): ReactRenderer {
|
|
|
|
const renderers = hook._renderers;
|
|
|
|
const keys = Object.keys(renderers);
|
|
|
|
invariant(keys.length === 1, 'Expected to find exactly one React Native renderer on DevTools hook.');
|
|
|
|
return renderers[keys[0]];
|
2015-07-14 19:03:17 +00:00
|
|
|
}
|
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
class Inspector extends React.Component {
|
2016-04-21 16:27:50 +00:00
|
|
|
props: {
|
|
|
|
inspectedViewTag: ?number,
|
|
|
|
onRequestRerenderApp: (callback: (tag: ?number) => void) => void
|
|
|
|
};
|
|
|
|
|
|
|
|
state: {
|
|
|
|
devtoolsAgent: ?Object,
|
|
|
|
hierarchy: any,
|
|
|
|
panelPos: string,
|
|
|
|
inspecting: bool,
|
|
|
|
selection: ?number,
|
|
|
|
perfing: bool,
|
|
|
|
inspected: any,
|
|
|
|
inspectedViewTag: any,
|
Intercept XMLHttpRequest network operations and gather their information in inspector tool
Summary:
This diff
- creates `XHRInterceptor` to intercept all XMLHttpRequest network operations in React Native by monkey-patching.
- enables `XHRInterceptor` in RN development tool "inspector".
This interception and inspector tool work well on both Android and iOS. And this supports interception on any network API based on XMLHttpRequest, especially the Fetch API.
By now, we can intercept 12 information fields of a XMLHttpRequest including method, url, data sent, status, response type, response size, requestHeaders, responseHeaders, response, responseURL, responseType and timeout.
Follow-up:
- Will add UIs in the inspector on top of this diff, to display all the network operation information. (Not in this diff just to make this shorter)
- Will extend this to gather other valuable information towards one XMLHttpRequest.
- Should support other network request APIs like WebSocket.
Reviewed By: davidaurelio
Differential Revision: D3598873
fbshipit-source-id: 3221050ab2ebd876a718fc326646c344d0944a5f
2016-07-27 19:17:03 +00:00
|
|
|
networking: bool,
|
2016-04-21 16:27:50 +00:00
|
|
|
};
|
|
|
|
|
2015-07-14 19:03:17 +00:00
|
|
|
_subs: ?Array<() => void>;
|
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
constructor(props: Object) {
|
|
|
|
super(props);
|
2015-07-14 19:03:17 +00:00
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
this.state = {
|
2015-07-22 23:36:46 +00:00
|
|
|
devtoolsAgent: null,
|
2016-04-21 16:27:50 +00:00
|
|
|
hierarchy: null,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
panelPos: 'bottom',
|
|
|
|
inspecting: true,
|
2015-06-23 22:30:54 +00:00
|
|
|
perfing: false,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
inspected: null,
|
2016-04-21 16:27:50 +00:00
|
|
|
selection: null,
|
2016-04-16 18:56:07 +00:00
|
|
|
inspectedViewTag: this.props.inspectedViewTag,
|
Intercept XMLHttpRequest network operations and gather their information in inspector tool
Summary:
This diff
- creates `XHRInterceptor` to intercept all XMLHttpRequest network operations in React Native by monkey-patching.
- enables `XHRInterceptor` in RN development tool "inspector".
This interception and inspector tool work well on both Android and iOS. And this supports interception on any network API based on XMLHttpRequest, especially the Fetch API.
By now, we can intercept 12 information fields of a XMLHttpRequest including method, url, data sent, status, response type, response size, requestHeaders, responseHeaders, response, responseURL, responseType and timeout.
Follow-up:
- Will add UIs in the inspector on top of this diff, to display all the network operation information. (Not in this diff just to make this shorter)
- Will extend this to gather other valuable information towards one XMLHttpRequest.
- Should support other network request APIs like WebSocket.
Reviewed By: davidaurelio
Differential Revision: D3598873
fbshipit-source-id: 3221050ab2ebd876a718fc326646c344d0944a5f
2016-07-27 19:17:03 +00:00
|
|
|
networking: false,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-07-14 19:03:17 +00:00
|
|
|
componentDidMount() {
|
2017-05-30 16:55:20 +00:00
|
|
|
hook.on('react-devtools', this.attachToDevtools);
|
|
|
|
// if devtools is already started
|
|
|
|
if (hook.reactDevtoolsAgent) {
|
|
|
|
this.attachToDevtools(hook.reactDevtoolsAgent);
|
2015-07-14 19:03:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
if (this._subs) {
|
|
|
|
this._subs.map(fn => fn());
|
|
|
|
}
|
2017-05-30 16:55:20 +00:00
|
|
|
hook.off('react-devtools', this.attachToDevtools);
|
2015-07-14 19:03:17 +00:00
|
|
|
}
|
|
|
|
|
2016-04-16 18:56:07 +00:00
|
|
|
componentWillReceiveProps(newProps: Object) {
|
|
|
|
this.setState({inspectedViewTag: newProps.inspectedViewTag});
|
|
|
|
}
|
|
|
|
|
2017-01-03 21:38:50 +00:00
|
|
|
attachToDevtools = (agent: Object) => {
|
|
|
|
let _hideWait = null;
|
|
|
|
const hlSub = agent.sub('highlight', ({node, name, props}) => {
|
2015-07-14 19:03:17 +00:00
|
|
|
clearTimeout(_hideWait);
|
2017-05-30 16:55:20 +00:00
|
|
|
|
|
|
|
if (typeof node !== 'number') {
|
|
|
|
// Fiber
|
|
|
|
node = ReactNative.findNodeHandle(node);
|
|
|
|
}
|
|
|
|
|
2015-07-14 19:03:17 +00:00
|
|
|
UIManager.measure(node, (x, y, width, height, left, top) => {
|
|
|
|
this.setState({
|
|
|
|
hierarchy: [],
|
|
|
|
inspected: {
|
|
|
|
frame: {left, top, width, height},
|
2017-05-30 16:55:20 +00:00
|
|
|
style: props ? props.style : emptyObject,
|
2015-07-14 19:03:17 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-01-03 21:38:50 +00:00
|
|
|
const hideSub = agent.sub('hideHighlight', () => {
|
2015-07-22 23:36:46 +00:00
|
|
|
if (this.state.inspected === null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-14 19:03:17 +00:00
|
|
|
// we wait to actually hide in order to avoid flicker
|
|
|
|
_hideWait = setTimeout(() => {
|
|
|
|
this.setState({
|
|
|
|
inspected: null,
|
|
|
|
});
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
this._subs = [hlSub, hideSub];
|
|
|
|
|
2015-07-22 23:36:46 +00:00
|
|
|
agent.on('shutdown', () => {
|
|
|
|
this.setState({devtoolsAgent: null});
|
2015-07-14 19:03:17 +00:00
|
|
|
this._subs = null;
|
|
|
|
});
|
|
|
|
this.setState({
|
2015-07-22 23:36:46 +00:00
|
|
|
devtoolsAgent: agent,
|
2015-07-14 19:03:17 +00:00
|
|
|
});
|
2017-01-03 21:38:50 +00:00
|
|
|
};
|
2015-07-14 19:03:17 +00:00
|
|
|
|
2017-05-30 16:55:20 +00:00
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
setSelection(i: number) {
|
2017-05-30 16:55:20 +00:00
|
|
|
const hierarchyItem = this.state.hierarchy[i];
|
|
|
|
// we pass in ReactNative.findNodeHandle as the method is injected
|
|
|
|
const {
|
|
|
|
measure,
|
|
|
|
props,
|
|
|
|
source,
|
|
|
|
} = hierarchyItem.getInspectorData(ReactNative.findNodeHandle);
|
|
|
|
|
|
|
|
measure((x, y, width, height, left, top) => {
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
this.setState({
|
|
|
|
inspected: {
|
|
|
|
frame: {left, top, width, height},
|
2017-05-30 16:55:20 +00:00
|
|
|
style: props.style,
|
2016-05-18 03:55:28 +00:00
|
|
|
source,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
},
|
|
|
|
selection: i,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-30 16:55:20 +00:00
|
|
|
onTouchViewTag(touchedViewTag: number, frame: Object, pointerY: number) {
|
2016-05-26 17:43:51 +00:00
|
|
|
// Most likely the touched instance is a native wrapper (like RCTView)
|
|
|
|
// which is not very interesting. Most likely user wants a composite
|
|
|
|
// instance that contains it (like View)
|
2017-05-30 16:55:20 +00:00
|
|
|
const {
|
|
|
|
hierarchy,
|
|
|
|
props,
|
|
|
|
selection,
|
|
|
|
source,
|
|
|
|
} = renderer.getInspectorDataForViewTag(touchedViewTag);
|
2016-05-26 17:43:51 +00:00
|
|
|
|
2015-07-22 23:36:46 +00:00
|
|
|
if (this.state.devtoolsAgent) {
|
2017-06-01 19:54:47 +00:00
|
|
|
// Skip host leafs
|
|
|
|
const offsetFromLeaf = hierarchy.length - 1 - selection;
|
|
|
|
this.state.devtoolsAgent.selectFromDOMNode(touchedViewTag, true, offsetFromLeaf);
|
2015-07-14 19:03:17 +00:00
|
|
|
}
|
2016-05-26 17:43:51 +00:00
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
this.setState({
|
|
|
|
panelPos: pointerY > Dimensions.get('window').height / 2 ? 'top' : 'bottom',
|
2017-05-30 16:55:20 +00:00
|
|
|
selection,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
hierarchy,
|
|
|
|
inspected: {
|
2017-05-30 16:55:20 +00:00
|
|
|
style: props.style,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
frame,
|
2016-05-18 03:55:28 +00:00
|
|
|
source,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-06-23 22:30:54 +00:00
|
|
|
setPerfing(val: bool) {
|
|
|
|
this.setState({
|
|
|
|
perfing: val,
|
|
|
|
inspecting: false,
|
|
|
|
inspected: null,
|
Intercept XMLHttpRequest network operations and gather their information in inspector tool
Summary:
This diff
- creates `XHRInterceptor` to intercept all XMLHttpRequest network operations in React Native by monkey-patching.
- enables `XHRInterceptor` in RN development tool "inspector".
This interception and inspector tool work well on both Android and iOS. And this supports interception on any network API based on XMLHttpRequest, especially the Fetch API.
By now, we can intercept 12 information fields of a XMLHttpRequest including method, url, data sent, status, response type, response size, requestHeaders, responseHeaders, response, responseURL, responseType and timeout.
Follow-up:
- Will add UIs in the inspector on top of this diff, to display all the network operation information. (Not in this diff just to make this shorter)
- Will extend this to gather other valuable information towards one XMLHttpRequest.
- Should support other network request APIs like WebSocket.
Reviewed By: davidaurelio
Differential Revision: D3598873
fbshipit-source-id: 3221050ab2ebd876a718fc326646c344d0944a5f
2016-07-27 19:17:03 +00:00
|
|
|
networking: false,
|
2015-06-23 22:30:54 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
setInspecting(val: bool) {
|
|
|
|
this.setState({
|
|
|
|
inspecting: val,
|
2015-06-23 22:30:54 +00:00
|
|
|
inspected: null
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-16 18:56:07 +00:00
|
|
|
setTouchTargetting(val: bool) {
|
|
|
|
Touchable.TOUCH_TARGET_DEBUG = val;
|
|
|
|
this.props.onRequestRerenderApp((inspectedViewTag) => {
|
|
|
|
this.setState({inspectedViewTag});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
Intercept XMLHttpRequest network operations and gather their information in inspector tool
Summary:
This diff
- creates `XHRInterceptor` to intercept all XMLHttpRequest network operations in React Native by monkey-patching.
- enables `XHRInterceptor` in RN development tool "inspector".
This interception and inspector tool work well on both Android and iOS. And this supports interception on any network API based on XMLHttpRequest, especially the Fetch API.
By now, we can intercept 12 information fields of a XMLHttpRequest including method, url, data sent, status, response type, response size, requestHeaders, responseHeaders, response, responseURL, responseType and timeout.
Follow-up:
- Will add UIs in the inspector on top of this diff, to display all the network operation information. (Not in this diff just to make this shorter)
- Will extend this to gather other valuable information towards one XMLHttpRequest.
- Should support other network request APIs like WebSocket.
Reviewed By: davidaurelio
Differential Revision: D3598873
fbshipit-source-id: 3221050ab2ebd876a718fc326646c344d0944a5f
2016-07-27 19:17:03 +00:00
|
|
|
setNetworking(val: bool) {
|
|
|
|
this.setState({
|
|
|
|
networking: val,
|
|
|
|
perfing: false,
|
|
|
|
inspecting: false,
|
|
|
|
inspected: null,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
render() {
|
2017-01-03 21:38:50 +00:00
|
|
|
const panelContainerStyle = (this.state.panelPos === 'bottom') ?
|
|
|
|
{bottom: 0} :
|
|
|
|
{top: Platform.OS === 'ios' ? 20 : 0};
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
return (
|
2015-06-18 12:42:45 +00:00
|
|
|
<View style={styles.container} pointerEvents="box-none">
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
{this.state.inspecting &&
|
|
|
|
<InspectorOverlay
|
|
|
|
inspected={this.state.inspected}
|
2016-04-16 18:56:07 +00:00
|
|
|
inspectedViewTag={this.state.inspectedViewTag}
|
2017-05-30 16:55:20 +00:00
|
|
|
onTouchViewTag={this.onTouchViewTag.bind(this)}
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
/>}
|
2015-06-18 12:42:45 +00:00
|
|
|
<View style={[styles.panelContainer, panelContainerStyle]}>
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
<InspectorPanel
|
2015-07-22 23:36:46 +00:00
|
|
|
devtoolsIsOpen={!!this.state.devtoolsAgent}
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
inspecting={this.state.inspecting}
|
2015-06-23 22:30:54 +00:00
|
|
|
perfing={this.state.perfing}
|
|
|
|
setPerfing={this.setPerfing.bind(this)}
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
setInspecting={this.setInspecting.bind(this)}
|
|
|
|
inspected={this.state.inspected}
|
|
|
|
hierarchy={this.state.hierarchy}
|
|
|
|
selection={this.state.selection}
|
|
|
|
setSelection={this.setSelection.bind(this)}
|
2016-04-16 18:56:07 +00:00
|
|
|
touchTargetting={Touchable.TOUCH_TARGET_DEBUG}
|
|
|
|
setTouchTargetting={this.setTouchTargetting.bind(this)}
|
Intercept XMLHttpRequest network operations and gather their information in inspector tool
Summary:
This diff
- creates `XHRInterceptor` to intercept all XMLHttpRequest network operations in React Native by monkey-patching.
- enables `XHRInterceptor` in RN development tool "inspector".
This interception and inspector tool work well on both Android and iOS. And this supports interception on any network API based on XMLHttpRequest, especially the Fetch API.
By now, we can intercept 12 information fields of a XMLHttpRequest including method, url, data sent, status, response type, response size, requestHeaders, responseHeaders, response, responseURL, responseType and timeout.
Follow-up:
- Will add UIs in the inspector on top of this diff, to display all the network operation information. (Not in this diff just to make this shorter)
- Will extend this to gather other valuable information towards one XMLHttpRequest.
- Should support other network request APIs like WebSocket.
Reviewed By: davidaurelio
Differential Revision: D3598873
fbshipit-source-id: 3221050ab2ebd876a718fc326646c344d0944a5f
2016-07-27 19:17:03 +00:00
|
|
|
networking={this.state.networking}
|
|
|
|
setNetworking={this.setNetworking.bind(this)}
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-03 21:38:50 +00:00
|
|
|
const styles = StyleSheet.create({
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
container: {
|
|
|
|
position: 'absolute',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
2015-06-18 12:42:45 +00:00
|
|
|
bottom: 0,
|
[ReactNative] refactor the inspector
Summary:
The `InspectorOverlay` component was getting unwieldy, so I broke it into three components:
- Inspector
- InspectorOverlay
- InspectorPanel
and added @flow types.
The inspector was also living under the `ReactIOS` directory, and I moved it
up into the `Libraries` directory, as the inspector will soon be usable [on
Android](https://phabricator.fb.com/D2138319).
All features of the inspector should remain functional, with the addition of
one feature:
- you can toggle "touch to inspect" by tapping the "Inspect" button at the
bottom of the inspection panel. When inspection is disabled, the panel remains, but you can interact with
the app normally without touches being intercepted
@public
Test Plan:
Open the inspector:
- touch to inspect things, verify that margin, padding, size and position are
reported correctly, and that the component hierarchy is navigable.
- tap the "Inspect" button, and verify that you can interact with the app
normally.
{F22548949}
[Video of toggling inspection](https://www.latest.facebook.com/pxlcld/mrs9)
2015-06-11 20:50:48 +00:00
|
|
|
},
|
|
|
|
panelContainer: {
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Inspector;
|