13
import {hideOverlay, showOverlay} from './Highlighter';
14
15
import type {BackendBridge} from 'react-devtools-shared/src/bridge';
16
+import type {HostInstance} from '../../types';
17
18
// This plug-in provides in-page highlighting of the selected element.
19
// It is used by the browser extension and the standalone DevTools shell (when connected to a browser).
26
bridge: BackendBridge,
27
agent: Agent,
28
): void {
28
- bridge.addListener(
29
- 'clearNativeElementHighlight',
30
- clearNativeElementHighlight,
31
- );
32
- bridge.addListener('highlightNativeElement', highlightNativeElement);
33
- bridge.addListener('shutdown', stopInspectingNative);
34
- bridge.addListener('startInspectingNative', startInspectingNative);
35
- bridge.addListener('stopInspectingNative', stopInspectingNative);
29
+ bridge.addListener('clearHostInstanceHighlight', clearHostInstanceHighlight);
30
+ bridge.addListener('highlightHostInstance', highlightHostInstance);
31
+ bridge.addListener('shutdown', stopInspectingHost);
32
+ bridge.addListener('startInspectingHost', startInspectingHost);
33
+ bridge.addListener('stopInspectingHost', stopInspectingHost);
34
37
- function startInspectingNative() {
35
+ function startInspectingHost() {
36
registerListenersOnWindow(window);
37
}
38
51
}
52
}
53
56
- function stopInspectingNative() {
54
+ function stopInspectingHost() {
55
hideOverlay(agent);
56
removeListenersOnWindow(window);
57
iframesListeningTo.forEach(function (frame) {
79
}
80
}
81
84
- function clearNativeElementHighlight() {
82
+ function clearHostInstanceHighlight() {
83
hideOverlay(agent);
84
}
85
88
- function highlightNativeElement({
86
+ function highlightHostInstance({
87
displayName,
88
hideAfterTimeout,
89
id,
92
- openNativeElementsPanel,
90
+ openBuiltinElementsPanel,
91
rendererID,
92
scrollIntoView,
93
}: {
94
displayName: string | null,
95
hideAfterTimeout: boolean,
96
id: number,
99
- openNativeElementsPanel: boolean,
97
+ openBuiltinElementsPanel: boolean,
98
rendererID: number,
99
scrollIntoView: boolean,
100
...
113
return;
114
}
115
118
- const nodes: ?Array<HTMLElement> = (renderer.findNativeNodesForElementID(
119
- id,
120
- ): any);
116
+ const nodes: ?Array<HostInstance> =
117
+ renderer.findHostInstancesForElementID(id);
118
119
if (nodes != null && nodes[0] != null) {
120
const node = nodes[0];
127
128
showOverlay(nodes, displayName, agent, hideAfterTimeout);
129
133
- if (openNativeElementsPanel) {
130
+ if (openBuiltinElementsPanel) {
131
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0 = node;
135
- bridge.send('syncSelectionToNativeElementsPanel');
132
+ bridge.send('syncSelectionToBuiltinElementsPanel');
133
}
134
} else {
135
hideOverlay(agent);
140
event.preventDefault();
141
event.stopPropagation();
142
146
- stopInspectingNative();
143
+ stopInspectingHost();
144
148
- bridge.send('stopInspectingNative', true);
145
+ bridge.send('stopInspectingHost', true);
146
}
147
148
function onMouseEvent(event: MouseEvent) {