@@ -15,15 +15,8 @@ import {format} from './utils';
15
15
import { getInternalReactConstants } from './renderer' ;
16
16
import { getStackByFiberInDevAndProd } from './DevToolsFiberComponentStack' ;
17
17
18
- // NOTE: KEEP IN SYNC with src/hook.js
19
18
const OVERRIDE_CONSOLE_METHODS = [ 'error' , 'trace' , 'warn' , 'log' ] ;
20
19
const DIMMED_NODE_CONSOLE_COLOR = '\x1b[2m%s\x1b[0m' ;
21
- const DARK_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.5)' ;
22
- const DARK_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.5)' ;
23
- const DARK_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.5)' ;
24
- const LIGHT_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.75)' ;
25
- const LIGHT_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.75)' ;
26
- const LIGHT_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.75)' ;
27
20
28
21
// React's custom built component stack strings match "\s{4}in"
29
22
// Chrome's prefix matches "\s{4}at"
@@ -256,25 +249,29 @@ export function patch({
256
249
case 'warn' :
257
250
color =
258
251
browserTheme === 'light'
259
- ? LIGHT_MODE_DIMMED_WARNING_COLOR
260
- : DARK_MODE_DIMMED_WARNING_COLOR ;
252
+ ? process . env . LIGHT_MODE_DIMMED_WARNING_COLOR
253
+ : process . env . DARK_MODE_DIMMED_WARNING_COLOR ;
261
254
break ;
262
255
case 'error' :
263
256
color =
264
257
browserTheme === 'light'
265
- ? LIGHT_MODE_DIMMED_ERROR_COLOR
266
- : DARK_MODE_DIMMED_ERROR_COLOR ;
258
+ ? process . env . LIGHT_MODE_DIMMED_ERROR_COLOR
259
+ : process . env . DARK_MODE_DIMMED_ERROR_COLOR ;
267
260
break ;
268
261
case 'log' :
269
262
default :
270
263
color =
271
264
browserTheme === 'light'
272
- ? LIGHT_MODE_DIMMED_LOG_COLOR
273
- : DARK_MODE_DIMMED_LOG_COLOR ;
265
+ ? process . env . LIGHT_MODE_DIMMED_LOG_COLOR
266
+ : process . env . DARK_MODE_DIMMED_LOG_COLOR ;
274
267
break ;
275
268
}
276
269
277
- originalMethod ( `%c${ format ( ...args ) } ` , `color: ${ color } ` ) ;
270
+ if ( color ) {
271
+ originalMethod ( `%c${ format ( ...args ) } ` , `color: ${ color } ` ) ;
272
+ } else {
273
+ throw Error ( 'Console color is not defined' ) ;
274
+ }
278
275
}
279
276
}
280
277
} else {
0 commit comments