[DevTools] Add events necessary for click to inspect on RN (#25111)
* Add inspectingNative events for RN * Enable inspection toggle UI for RN * Add a stopInspectingNative method for agent
Tianyu Yao committed
Aug 19, 2022 at 16:18 UTC
26ba5fb2e003e334c51b0e2ea750faa32a27a8f9
3 files changed
+11
-1
packages/react-devtools-core/src/standalone.js
+1
-1
@@ -256,7 +256,7 @@ function initialize(socket: WebSocket) {
256
257
store = new Store(bridge, {
258
checkBridgeProtocolCompatibility: true,
259
- supportsNativeInspection: false,
259
+ supportsNativeInspection: true,
260
});
261
262
log('Connected');
packages/react-devtools-shared/src/backend/agent.js
+6
@@ -144,6 +144,8 @@ type PersistedSelection = {|
144
export default class Agent extends EventEmitter<{|
145
hideNativeHighlight: [],
146
showNativeHighlight: [NativeType],
147
+ startInspectingNative: [],
148
+ stopInspectingNative: [],
149
shutdown: [],
150
traceUpdates: [Set<NativeType>],
151
|}> {
@@ -655,6 +657,10 @@ export default class Agent extends EventEmitter<{|
657
this._bridge.send('profilingStatus', this._isProfiling);
658
};
659
660
+ stopInspectingNative = (selected: boolean) => {
661
+ this._bridge.send('stopInspectingNative', selected);
662
+ };
663
+
664
storeAsGlobal = ({count, id, path, rendererID}: StoreAsGlobalParams) => {
665
const renderer = this._rendererInterfaces[rendererID];
666
if (renderer == null) {
packages/react-devtools-shared/src/backend/views/Highlighter/index.js
+4
@@ -48,6 +48,8 @@ export default function setupHighlighter(
48
window.addEventListener('pointerdown', onPointerDown, true);
49
window.addEventListener('pointerover', onPointerOver, true);
50
window.addEventListener('pointerup', onPointerUp, true);
51
+ } else {
52
+ agent.emit('startInspectingNative');
53
}
54
}
55
@@ -74,6 +76,8 @@ export default function setupHighlighter(
76
window.removeEventListener('pointerdown', onPointerDown, true);
77
window.removeEventListener('pointerover', onPointerOver, true);
78
window.removeEventListener('pointerup', onPointerUp, true);
79
+ } else {
80
+ agent.emit('stopInspectingNative');
81
}
82
}
83