@@ -17,66 +17,63 @@ declare var console: typeof console & {_isPolyfilled: boolean, ...};
17
17
* You can use this module directly, or just require InitializeCore.
18
18
*/
19
19
if ( __DEV__ ) {
20
- // TODO (T45803484) Enable devtools for bridgeless RN Android.
21
- if ( ! global . RN$Bridgeless || Platform . OS === 'ios' ) {
22
- if ( ! global . __RCTProfileIsProfiling ) {
23
- require ( './setUpReactDevTools' ) ;
20
+ if ( ! global . __RCTProfileIsProfiling ) {
21
+ require ( './setUpReactDevTools' ) ;
24
22
25
- // Set up inspector
26
- const JSInspector = require ( '../JSInspector/JSInspector' ) ;
27
- JSInspector . registerAgent ( require ( '../JSInspector/NetworkAgent' ) ) ;
28
- }
23
+ // Set up inspector
24
+ const JSInspector = require ( '../JSInspector/JSInspector' ) ;
25
+ JSInspector . registerAgent ( require ( '../JSInspector/NetworkAgent' ) ) ;
26
+ }
29
27
30
- // Note we can't check if console is "native" because it would appear "native" in JSC and Hermes.
31
- // We also can't check any properties that don't exist in the Chrome worker environment.
32
- // So we check a navigator property that's set to a particular value ("Netscape") in all real browsers.
33
- const isLikelyARealBrowser =
34
- global . navigator != null &&
35
- /* _
36
- * | |
37
- * _ __ ___| |_ ___ ___ __ _ _ __ ___
38
- * | '_ \ / _ \ __/ __|/ __/ _` | '_ \ / _ \
39
- * | | | | __/ |_\__ \ (_| (_| | |_) | __/
40
- * |_| |_|\___|\__|___/\___\__,_| .__/ \___|
41
- * | |
42
- * |_|
43
- */
44
- global . navigator . appName === 'Netscape' ; // Any real browser
28
+ // Note we can't check if console is "native" because it would appear "native" in JSC and Hermes.
29
+ // We also can't check any properties that don't exist in the Chrome worker environment.
30
+ // So we check a navigator property that's set to a particular value ("Netscape") in all real browsers.
31
+ const isLikelyARealBrowser =
32
+ global . navigator != null &&
33
+ /* _
34
+ * | |
35
+ * _ __ ___| |_ ___ ___ __ _ _ __ ___
36
+ * | '_ \ / _ \ __/ __|/ __/ _` | '_ \ / _ \
37
+ * | | | | __/ |_\__ \ (_| (_| | |_) | __/
38
+ * |_| |_|\___|\__|___/\___\__,_| .__/ \___|
39
+ * | |
40
+ * |_|
41
+ */
42
+ global . navigator . appName === 'Netscape' ; // Any real browser
45
43
46
- if ( ! Platform . isTesting ) {
47
- const HMRClient = require ( '../Utilities/HMRClient' ) ;
44
+ if ( ! Platform . isTesting ) {
45
+ const HMRClient = require ( '../Utilities/HMRClient' ) ;
48
46
49
- if ( console . _isPolyfilled ) {
50
- // We assume full control over the console and send JavaScript logs to Metro.
51
- [
52
- 'trace' ,
53
- 'info' ,
54
- 'warn' ,
55
- 'error' ,
56
- 'log' ,
57
- 'group' ,
58
- 'groupCollapsed' ,
59
- 'groupEnd' ,
60
- 'debug' ,
61
- ] . forEach ( level => {
62
- const originalFunction = console [ level ] ;
63
- console [ level ] = function ( ...args ) {
64
- HMRClient . log ( level , args ) ;
65
- originalFunction . apply ( console , args ) ;
66
- } ;
67
- } ) ;
68
- } else {
69
- // We assume the environment has a real rich console (like Chrome), and don't hijack it to log to Metro.
70
- // It's likely the developer is using rich console to debug anyway, and hijacking it would
71
- // lose the filenames in console.log calls: https://github.com/facebook/react-native/issues/26788.
72
- HMRClient . log ( 'log' , [
73
- `JavaScript logs will appear in your ${
74
- isLikelyARealBrowser ? 'browser' : 'environment'
75
- } console`,
76
- ] ) ;
77
- }
47
+ if ( console . _isPolyfilled ) {
48
+ // We assume full control over the console and send JavaScript logs to Metro.
49
+ [
50
+ 'trace' ,
51
+ 'info' ,
52
+ 'warn' ,
53
+ 'error' ,
54
+ 'log' ,
55
+ 'group' ,
56
+ 'groupCollapsed' ,
57
+ 'groupEnd' ,
58
+ 'debug' ,
59
+ ] . forEach ( level => {
60
+ const originalFunction = console [ level ] ;
61
+ console [ level ] = function ( ...args ) {
62
+ HMRClient . log ( level , args ) ;
63
+ originalFunction . apply ( console , args ) ;
64
+ } ;
65
+ } ) ;
66
+ } else {
67
+ // We assume the environment has a real rich console (like Chrome), and don't hijack it to log to Metro.
68
+ // It's likely the developer is using rich console to debug anyway, and hijacking it would
69
+ // lose the filenames in console.log calls: https://github.com/facebook/react-native/issues/26788.
70
+ HMRClient . log ( 'log' , [
71
+ `JavaScript logs will appear in your ${
72
+ isLikelyARealBrowser ? 'browser' : 'environment'
73
+ } console`,
74
+ ] ) ;
78
75
}
79
-
80
- require ( './setUpReactRefresh' ) ;
81
76
}
77
+
78
+ require ( './setUpReactRefresh' ) ;
82
79
}
0 commit comments