@@ -21,9 +21,8 @@ const defaultOptions = {
21
21
hotReload : true ,
22
22
liveReload : false ,
23
23
initial : true ,
24
- useWarningOverlay : false ,
25
- useErrorOverlay : false ,
26
- useProgress : false ,
24
+ progress : false ,
25
+ overlay : false ,
27
26
} ;
28
27
const parsedResourceQuery = parseURL ( __resourceQuery ) ;
29
28
const options = defaultOptions ;
@@ -84,8 +83,8 @@ const onSocketMessage = {
84
83
invalid ( ) {
85
84
log . info ( 'App updated. Recompiling...' ) ;
86
85
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 ) {
89
88
overlay . clear ( ) ;
90
89
}
91
90
@@ -94,43 +93,37 @@ const onSocketMessage = {
94
93
hash ( hash ) {
95
94
status . currentHash = hash ;
96
95
} ,
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
- } ,
106
96
logging : setAllLogLevel ,
107
97
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 ;
116
100
}
101
+
102
+ options . overlay = value ;
117
103
} ,
118
104
progress ( progress ) {
119
- if ( typeof document !== 'undefined' ) {
120
- options . useProgress = progress ;
121
- }
105
+ options . progress = progress ;
122
106
} ,
123
107
'progress-update' : function progressUpdate ( data ) {
124
- if ( options . useProgress ) {
108
+ if ( options . progress ) {
125
109
log . info ( `${ data . percent } % - ${ data . msg } .` ) ;
126
110
}
127
111
128
112
sendMessage ( 'Progress' , data ) ;
129
113
} ,
114
+ 'still-ok' : function stillOk ( ) {
115
+ log . info ( 'Nothing changed.' ) ;
116
+
117
+ if ( options . overlay ) {
118
+ overlay . clear ( ) ;
119
+ }
120
+
121
+ sendMessage ( 'StillOk' ) ;
122
+ } ,
130
123
ok ( ) {
131
124
sendMessage ( 'Ok' ) ;
132
125
133
- if ( options . useWarningOverlay || options . useErrorOverlay ) {
126
+ if ( options . overlay ) {
134
127
overlay . clear ( ) ;
135
128
}
136
129
@@ -158,7 +151,12 @@ const onSocketMessage = {
158
151
log . warn ( strippedWarnings [ i ] ) ;
159
152
}
160
153
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 ) {
162
160
overlay . showMessage ( warnings ) ;
163
161
}
164
162
@@ -181,7 +179,12 @@ const onSocketMessage = {
181
179
log . error ( strippedErrors [ i ] ) ;
182
180
}
183
181
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 ) {
185
188
overlay . showMessage ( errors ) ;
186
189
}
187
190
0 commit comments