@@ -19,21 +19,20 @@ import '../../panels/timeline/timeline-meta.js';
19
19
import * as Host from '../../core/host/host.js' ;
20
20
import * as i18n from '../../core/i18n/i18n.js' ;
21
21
import * as Root from '../../core/root/root.js' ;
22
+ import * as RNExperiments from '../../core/rn_experiments/rn_experiments.js' ;
22
23
import * as SDK from '../../core/sdk/sdk.js' ;
23
24
import * as UI from '../../ui/legacy/legacy.js' ;
24
25
import * as Main from '../main/main.js' ;
25
26
import * as Common from '../../core/common/common.js' ;
26
27
import * as Protocol from '../../generated/protocol.js' ;
28
+ import FuseboxReconnectDeviceButton from './FuseboxReconnectDeviceButton.js' ;
29
+ import FuseboxProfilingBuildObserver from './FuseboxProfilingBuildObserver.js' ;
27
30
28
31
import type * as Platform from '../../core/platform/platform.js' ;
29
32
import type * as Sources from '../../panels/sources/sources.js' ;
30
- import * as RNExperiments from '../../core/rn_experiments/rn_experiments.js' ;
31
- import FuseboxProfilingBuildObserver from './FuseboxProfilingBuildObserver.js' ;
32
33
33
- /*
34
- * To ensure accurate timing measurements,
35
- * please make sure these perf metrics lines are called ahead of everything else
36
- */
34
+ // To ensure accurate timing measurements, please make sure these perf metrics
35
+ // lines are called ahead of everything else
37
36
Host . rnPerfMetrics . registerPerfMetricsGlobalPostMessageHandler ( ) ;
38
37
Host . rnPerfMetrics . registerGlobalErrorReporting ( ) ;
39
38
Host . rnPerfMetrics . setLaunchId ( Root . Runtime . Runtime . queryParam ( 'launchId' ) ) ;
@@ -52,14 +51,6 @@ const UIStrings = {
52
51
*@description Label of the FB-only 'send feedback' action button in the toolbar
53
52
*/
54
53
sendFeedback : '[FB-only] Send feedback' ,
55
- /**
56
- *@description Tooltip of the connection status toolbar button while disconnected
57
- */
58
- connectionStatusDisconnectedTooltip : 'Debugging connection was closed' ,
59
- /**
60
- *@description Button label of the connection status toolbar button while disconnected
61
- */
62
- connectionStatusDisconnectedLabel : 'Reconnect DevTools' ,
63
54
} ;
64
55
const str_ = i18n . i18n . registerUIStrings ( 'entrypoints/rn_fusebox/rn_fusebox.ts' , UIStrings ) ;
65
56
const i18nLazyString = i18n . i18n . getLazilyComputedLocalizedString . bind ( undefined , str_ ) ;
@@ -141,9 +132,9 @@ if (globalThis.FB_ONLY__reactNativeFeedbackLink) {
141
132
if ( incomingActionId !== actionId ) {
142
133
return false ;
143
134
}
144
- Host . InspectorFrontendHost . InspectorFrontendHostInstance . openInNewTab (
145
- feedbackLink ,
146
- ) ;
135
+ Host . InspectorFrontendHost . InspectorFrontendHostInstance . openInNewTab (
136
+ feedbackLink ,
137
+ ) ;
147
138
148
139
return true ;
149
140
} ,
@@ -166,67 +157,10 @@ if (globalThis.FB_ONLY__reactNativeFeedbackLink) {
166
157
} ) ;
167
158
}
168
159
169
- class ConnectionStatusToolbarItemProvider extends SDK . TargetManager . Observer implements UI . Toolbar . Provider {
170
- #button = new UI . Toolbar . ToolbarButton ( '' ) ;
171
-
172
- constructor ( ) {
173
- super ( ) ;
174
- this . #button. setVisible ( false ) ;
175
- this . #button. element . classList . add ( 'fusebox-connection-status' ) ;
176
- this . #button. addEventListener ( UI . Toolbar . ToolbarButton . Events . Click , this . onClick . bind ( this ) ) ;
177
-
178
- SDK . TargetManager . TargetManager . instance ( ) . observeTargets ( this , { scoped : true } ) ;
179
- }
180
-
181
- override targetAdded ( target : SDK . Target . Target ) : void {
182
- this . #onTargetChanged( target ) ;
183
- }
184
-
185
- override targetRemoved ( target : SDK . Target . Target ) : void {
186
- this . #onTargetChanged( target ) ;
187
- }
188
-
189
- #onTargetChanged( target : SDK . Target . Target ) : void {
190
- const rootTarget = SDK . TargetManager . TargetManager . instance ( ) . rootTarget ( ) ;
191
- this . #button. setTitle ( i18nLazyString ( UIStrings . connectionStatusDisconnectedTooltip ) ( ) ) ;
192
- this . #button. setText ( i18nLazyString ( UIStrings . connectionStatusDisconnectedLabel ) ( ) ) ;
193
- this . #button. setVisible ( ! rootTarget ) ;
194
-
195
- if ( ! rootTarget ) {
196
- this . #printPreserveLogPrompt( target ) ;
197
- }
198
- }
199
-
200
- #printPreserveLogPrompt( target : SDK . Target . Target ) : void {
201
- if ( Common . Settings . Settings . instance ( ) . moduleSetting ( 'preserve-console-log' ) . get ( ) ) {
202
- return ;
203
- }
204
-
205
- target . model ( SDK . ConsoleModel . ConsoleModel )
206
- ?. addMessage ( new SDK . ConsoleModel . ConsoleMessage (
207
- target . model ( SDK . RuntimeModel . RuntimeModel ) , Protocol . Log . LogEntrySource . Recommendation ,
208
- Protocol . Log . LogEntryLevel . Info ,
209
- '[React Native] Console messages are currently cleared upon DevTools disconnection. You can preserve logs in settings: ' ,
210
- {
211
- type : SDK . ConsoleModel . FrontendMessageType . System ,
212
- context : 'fusebox_preserve_log_rec' ,
213
- } ) ) ;
214
- }
215
-
216
- onClick ( ) : void {
217
- window . location . reload ( ) ;
218
- }
219
-
220
- item ( ) : UI . Toolbar . ToolbarItem {
221
- return this . #button;
222
- }
223
- }
224
-
225
- const connectionStatusToolbarItemProvider = new ConnectionStatusToolbarItemProvider ( ) ;
226
160
UI . Toolbar . registerToolbarItem ( {
227
161
location : UI . Toolbar . ToolbarItemLocation . MAIN_TOOLBAR_RIGHT ,
228
162
loadItem : async ( ) => {
229
- return connectionStatusToolbarItemProvider ;
163
+ return FuseboxReconnectDeviceButton . instance ( ) ;
230
164
} ,
231
165
} ) ;
232
166
0 commit comments