@@ -6,77 +6,12 @@ import { features } from "ui/utils/prefs";
6
6
import Video from "../Video" ;
7
7
import WebConsoleApp from "devtools/client/webconsole/components/App" ;
8
8
import InspectorApp from "devtools/client/inspector/components/App" ;
9
- import {
10
- createBridge ,
11
- createStore ,
12
- initialize as createDevTools ,
13
- } from "react-devtools-inline/frontend" ;
14
- import { ThreadFront } from "protocol/thread" ;
15
9
16
10
import "./SecondaryToolbox.css" ;
17
11
import NodePicker from "../NodePicker" ;
18
12
import { selectors } from "../../reducers" ;
19
13
import { actions } from "../../actions" ;
20
-
21
- let bridge , store , wall , DevTools ;
22
-
23
- function InitReactDevTools ( ) {
24
- if ( ! features . reactDevtools ) {
25
- return null ;
26
- }
27
- const target = {
28
- postMessage : function ( ) { } ,
29
- } ;
30
-
31
- wall = {
32
- emit ( { data } ) { } ,
33
- listen ( listener ) {
34
- wall . _listener = listener ;
35
- } ,
36
- send ( event : string , payload : any , transferable ?: Array < any > ) {
37
- wall. _listener ( { event, payload } ) ;
38
- } ,
39
- } ;
40
-
41
- bridge = createBridge ( target , wall ) ;
42
- store = createStore ( bridge ) ;
43
- DevTools = createDevTools ( target , { bridge, store } ) ;
44
- }
45
-
46
- InitReactDevTools ( ) ;
47
-
48
- const messages = [ ] ;
49
- ThreadFront . getAnnotations ( ( { annotations } ) => {
50
- for ( const { point, time, kind, contents } of annotations ) {
51
- const message = JSON . parse ( contents ) ;
52
- messages . push ( { point, time, message } ) ;
53
- }
54
- } ) ;
55
-
56
- let currentTime = null ;
57
- let rerenderComponentsTab = null ;
58
-
59
- ThreadFront . on ( "paused" , data => {
60
- if ( currentTime === data . time ) {
61
- return ;
62
- }
63
-
64
- InitReactDevTools ( ) ;
65
-
66
- // TODO Use point AND time eventually
67
- messages
68
- . filter ( ( { time } ) => time <= data . time )
69
- . forEach ( ( { message } ) => {
70
- if ( message . event === "operations" ) {
71
- wall . send ( message . event , message . payload ) ;
72
- }
73
- } ) ;
74
-
75
- // HACK TODO This should use a subscription
76
- if ( typeof rerenderComponentsTab === "function" ) {
77
- rerenderComponentsTab ( ) ;
78
- }
79
- } ) ;
14
+ import { ReactDevtoolsPanel } from "./ReactDevTools" ;
80
15
81
16
function PanelButtons ( { selectedPanel, setSelectedPanel, narrowMode } ) {
82
17
const {
@@ -123,9 +58,9 @@ function PanelButtons({ selectedPanel, setSelectedPanel, narrowMode }) {
123
58
{ features . reactDevtools && (
124
59
< button
125
60
className = { classnames ( "components-panel-button" , {
126
- expanded : selectedPanel === "components" ,
61
+ expanded : selectedPanel === "react- components" ,
127
62
} ) }
128
- onClick = { ( ) => onClick ( "components" ) }
63
+ onClick = { ( ) => onClick ( "react- components" ) }
129
64
>
130
65
< div className = "label" > ⚛️ Components</ div >
131
66
</ button >
@@ -152,38 +87,6 @@ function InspectorPanel() {
152
87
) ;
153
88
}
154
89
155
- // TODO Pass custom bridge
156
- // TODO Use portal containers for Profiler & Components
157
- function Components ( ) {
158
- if ( ! features . reactDevtools ) {
159
- return null ;
160
- }
161
-
162
- const [ count , setCount ] = React . useState ( 0 ) ;
163
-
164
- // HACK TODO This hack handles the fact that DevTools wasn't writen
165
- // with the expectation that a new Bridge or Store prop would be pasesd
166
- // and doens't handle that case properly.
167
- rerenderComponentsTab = ( ) => {
168
- setCount ( count + 1 ) ;
169
- } ;
170
-
171
- React . useLayoutEffect ( ( ) => ( ) => {
172
- rerenderComponentsTab = null ;
173
- } ) ;
174
-
175
- return (
176
- < DevTools
177
- bridge = { bridge }
178
- browserTheme = "light"
179
- enabledInspectedElementContextMenu = { false }
180
- overrideTab = "components"
181
- showTabBar = { false }
182
- store = { store }
183
- />
184
- ) ;
185
- }
186
-
187
90
function SecondaryToolbox ( { selectedPanel, setSelectedPanel, narrowMode } ) {
188
91
const {
189
92
userSettings : { show_elements } ,
@@ -202,7 +105,7 @@ function SecondaryToolbox({ selectedPanel, setSelectedPanel, narrowMode }) {
202
105
{ selectedPanel == "console" ? < ConsolePanel /> : null }
203
106
{ selectedPanel == "inspector" && show_elements ? < InspectorPanel /> : null }
204
107
{ selectedPanel == "viewer" && narrowMode ? < Video /> : null }
205
- { selectedPanel == "components" ? < Components /> : null }
108
+ { selectedPanel == "react- components" ? < ReactDevtoolsPanel /> : null }
206
109
</ div >
207
110
</ div >
208
111
) ;
0 commit comments