@@ -21,9 +21,8 @@ const defaultOptions = {
2121 hotReload : true ,
2222 liveReload : false ,
2323 initial : true ,
24- useWarningOverlay : false ,
25- useErrorOverlay : false ,
26- useProgress : false ,
24+ progress : false ,
25+ overlay : false ,
2726} ;
2827const parsedResourceQuery = parseURL ( __resourceQuery ) ;
2928const options = defaultOptions ;
@@ -84,8 +83,8 @@ const onSocketMessage = {
8483 invalid ( ) {
8584 log . info ( 'App updated. Recompiling...' ) ;
8685
87- // fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
88- if ( options . useWarningOverlay || options . useErrorOverlay ) {
86+ // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
87+ if ( options . overlay ) {
8988 overlay . clear ( ) ;
9089 }
9190
@@ -94,43 +93,37 @@ const onSocketMessage = {
9493 hash ( hash ) {
9594 status . currentHash = hash ;
9695 } ,
97- 'still-ok' : function stillOk ( ) {
98- log . info ( 'Nothing changed.' ) ;
99-
100- if ( options . useWarningOverlay || options . useErrorOverlay ) {
101- overlay . clear ( ) ;
102- }
103-
104- sendMessage ( 'StillOk' ) ;
105- } ,
10696 logging : setAllLogLevel ,
10797 overlay ( value ) {
108- if ( typeof document !== 'undefined' ) {
109- if ( typeof value === 'boolean' ) {
110- options . useWarningOverlay = false ;
111- options . useErrorOverlay = value ;
112- } else if ( value ) {
113- options . useWarningOverlay = value . warnings ;
114- options . useErrorOverlay = value . errors ;
115- }
98+ if ( typeof document === 'undefined' ) {
99+ return ;
116100 }
101+
102+ options . overlay = value ;
117103 } ,
118104 progress ( progress ) {
119- if ( typeof document !== 'undefined' ) {
120- options . useProgress = progress ;
121- }
105+ options . progress = progress ;
122106 } ,
123107 'progress-update' : function progressUpdate ( data ) {
124- if ( options . useProgress ) {
108+ if ( options . progress ) {
125109 log . info ( `${ data . percent } % - ${ data . msg } .` ) ;
126110 }
127111
128112 sendMessage ( 'Progress' , data ) ;
129113 } ,
114+ 'still-ok' : function stillOk ( ) {
115+ log . info ( 'Nothing changed.' ) ;
116+
117+ if ( options . overlay ) {
118+ overlay . clear ( ) ;
119+ }
120+
121+ sendMessage ( 'StillOk' ) ;
122+ } ,
130123 ok ( ) {
131124 sendMessage ( 'Ok' ) ;
132125
133- if ( options . useWarningOverlay || options . useErrorOverlay ) {
126+ if ( options . overlay ) {
134127 overlay . clear ( ) ;
135128 }
136129
@@ -158,7 +151,12 @@ const onSocketMessage = {
158151 log . warn ( strippedWarnings [ i ] ) ;
159152 }
160153
161- if ( options . useWarningOverlay ) {
154+ const needShowOverlay =
155+ typeof options . overlay === 'boolean'
156+ ? options . overlay
157+ : options . overlay && options . overlay . warnings ;
158+
159+ if ( needShowOverlay ) {
162160 overlay . showMessage ( warnings ) ;
163161 }
164162
@@ -181,7 +179,12 @@ const onSocketMessage = {
181179 log . error ( strippedErrors [ i ] ) ;
182180 }
183181
184- if ( options . useErrorOverlay ) {
182+ const needShowOverlay =
183+ typeof options . overlay === 'boolean'
184+ ? options . overlay
185+ : options . overlay && options . overlay . errors ;
186+
187+ if ( needShowOverlay ) {
185188 overlay . showMessage ( errors ) ;
186189 }
187190
0 commit comments