11// @flow
22
3- // $FlowFixMe Cannot resolve module
4- import rawStyleString from '!!raw-loader!src/devtools/views/root.css' ; // eslint-disable-line import/no-webpack-loader-syntax
5-
63// Flip this flag to true to enable verbose console debug logging.
74export const __DEBUG__ = false ;
85
9- const extractVar = varName => {
10- const regExp = new RegExp ( `${ varName } : ([0-9]+)` ) ;
11- const match = rawStyleString . match ( regExp ) ;
12- return parseInt ( match [ 1 ] , 10 ) ;
13- } ;
14-
15- // TRICKY
16- // Extracting during build time avoids a temporarily invalid state for the inline target.
17- // Sometimes the inline target is rendered before root styles are applied,
18- // which would result in e.g. NaN itemSize being passed to react-window list.
19- export const COMFORTABLE_LINE_HEIGHT = extractVar (
20- 'comfortable-line-height-data'
21- ) ;
22- export const COMPACT_LINE_HEIGHT = extractVar ( 'compact-line-height-data' ) ;
23-
246export const TREE_OPERATION_ADD = 1 ;
257export const TREE_OPERATION_REMOVE = 2 ;
268export const TREE_OPERATION_REORDER_CHILDREN = 3 ;
@@ -45,3 +27,31 @@ export const PROFILER_EXPORT_VERSION = 4;
4527
4628export const CHANGE_LOG_URL =
4729 'https://github.com/bvaughn/react-devtools-experimental/blob/master/CHANGELOG.md' ;
30+
31+ // HACK
32+ //
33+ // Extracting during build time avoids a temporarily invalid state for the inline target.
34+ // Sometimes the inline target is rendered before root styles are applied,
35+ // which would result in e.g. NaN itemSize being passed to react-window list.
36+ //
37+ // We can't use the Webpack loader syntax in the context of Jest though,
38+ // so tests need some reasonably meaningful fallback value.
39+ let COMFORTABLE_LINE_HEIGHT = 15 ;
40+ let COMPACT_LINE_HEIGHT = 10 ;
41+
42+ if ( ! __TEST__ ) {
43+ // $FlowFixMe
44+ const rawStyleString = require ( '!!raw-loader!src/devtools/views/root.css' ) // eslint-disable-line import/no-webpack-loader-syntax
45+ . default ;
46+
47+ const extractVar = varName => {
48+ const regExp = new RegExp ( `${ varName } : ([0-9]+)` ) ;
49+ const match = rawStyleString . match ( regExp ) ;
50+ return parseInt ( match [ 1 ] , 10 ) ;
51+ } ;
52+
53+ COMFORTABLE_LINE_HEIGHT = extractVar ( 'comfortable-line-height-data' ) ;
54+ COMPACT_LINE_HEIGHT = extractVar ( 'compact-line-height-data' ) ;
55+ }
56+
57+ export { COMFORTABLE_LINE_HEIGHT , COMPACT_LINE_HEIGHT } ;
0 commit comments