@@ -4,7 +4,7 @@ import webpackHotLog from "webpack/hot/log.js";
4
4
import stripAnsi from "./utils/stripAnsi.js" ;
5
5
import parseURL from "./utils/parseURL.js" ;
6
6
import socket from "./socket.js" ;
7
- import { formatProblem , show , hide } from "./overlay.js" ;
7
+ import { formatProblem , createOverlay } from "./overlay.js" ;
8
8
import { log , logEnabledFeatures , setLogLevel } from "./utils/log.js" ;
9
9
import sendMessage from "./utils/sendMessage.js" ;
10
10
import reloadApp from "./utils/reloadApp.js" ;
@@ -115,6 +115,13 @@ self.addEventListener("beforeunload", () => {
115
115
status . isUnloading = true ;
116
116
} ) ;
117
117
118
+ const trustedTypesPolicyName =
119
+ typeof options . overlay === "object" && options . overlay . trustedTypesPolicyName ;
120
+
121
+ const overlay = createOverlay ( {
122
+ trustedTypesPolicyName,
123
+ } ) ;
124
+
118
125
const onSocketMessage = {
119
126
hot ( ) {
120
127
if ( parsedResourceQuery . hot === "false" ) {
@@ -135,7 +142,7 @@ const onSocketMessage = {
135
142
136
143
// Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
137
144
if ( options . overlay ) {
138
- hide ( ) ;
145
+ overlay . send ( { type : "DISMISS" } ) ;
139
146
}
140
147
141
148
sendMessage ( "Invalid" ) ;
@@ -192,7 +199,7 @@ const onSocketMessage = {
192
199
log . info ( "Nothing changed." ) ;
193
200
194
201
if ( options . overlay ) {
195
- hide ( ) ;
202
+ overlay . send ( { type : "DISMISS" } ) ;
196
203
}
197
204
198
205
sendMessage ( "StillOk" ) ;
@@ -201,7 +208,7 @@ const onSocketMessage = {
201
208
sendMessage ( "Ok" ) ;
202
209
203
210
if ( options . overlay ) {
204
- hide ( ) ;
211
+ overlay . send ( { type : "DISMISS" } ) ;
205
212
}
206
213
207
214
reloadApp ( options , status ) ;
@@ -256,10 +263,11 @@ const onSocketMessage = {
256
263
: options . overlay && options . overlay . warnings ;
257
264
258
265
if ( needShowOverlayForWarnings ) {
259
- const trustedTypesPolicyName =
260
- typeof options . overlay === "object" &&
261
- options . overlay . trustedTypesPolicyName ;
262
- show ( "warning" , warnings , trustedTypesPolicyName || null ) ;
266
+ overlay . send ( {
267
+ type : "BUILD_ERROR" ,
268
+ level : "warning" ,
269
+ messages : warnings ,
270
+ } ) ;
263
271
}
264
272
265
273
if ( params && params . preventReloading ) {
@@ -292,10 +300,11 @@ const onSocketMessage = {
292
300
: options . overlay && options . overlay . errors ;
293
301
294
302
if ( needShowOverlayForErrors ) {
295
- const trustedTypesPolicyName =
296
- typeof options . overlay === "object" &&
297
- options . overlay . trustedTypesPolicyName ;
298
- show ( "error" , errors , trustedTypesPolicyName || null ) ;
303
+ overlay . send ( {
304
+ type : "BUILD_ERROR" ,
305
+ level : "error" ,
306
+ messages : errors ,
307
+ } ) ;
299
308
}
300
309
} ,
301
310
/**
@@ -308,7 +317,7 @@ const onSocketMessage = {
308
317
log . info ( "Disconnected!" ) ;
309
318
310
319
if ( options . overlay ) {
311
- hide ( ) ;
320
+ overlay . send ( { type : "DISMISS" } ) ;
312
321
}
313
322
314
323
sendMessage ( "Close" ) ;
0 commit comments