webpack-dev-server 4.6.0 → 4.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -66
- package/bin/cli-flags.js +265 -267
- package/bin/process-arguments.js +87 -7
- package/bin/webpack-dev-server.js +3 -0
- package/client/clients/SockJSClient.js +26 -3
- package/client/clients/WebSocketClient.js +16 -1
- package/client/index.js +71 -2
- package/client/modules/logger/index.js +3 -0
- package/client/modules/sockjs-client/index.js +15 -4
- package/client/overlay.js +38 -3
- package/client/socket.js +17 -6
- package/client/utils/createSocketURL.js +71 -4
- package/client/utils/getCurrentScriptSource.js +3 -0
- package/client/utils/log.js +6 -1
- package/client/utils/parseURL.js +17 -19
- package/client/utils/reloadApp.js +15 -2
- package/client/utils/sendMessage.js +5 -0
- package/lib/Server.js +1673 -759
- package/lib/options.json +37 -18
- package/lib/servers/BaseServer.js +8 -0
- package/lib/servers/SockJSServer.js +42 -9
- package/lib/servers/WebsocketServer.js +66 -35
- package/package.json +24 -14
- package/types/bin/cli-flags.d.ts +934 -0
- package/types/bin/process-arguments.d.ts +50 -0
- package/types/bin/webpack-dev-server.d.ts +27 -0
- package/types/lib/Server.d.ts +3388 -0
- package/types/lib/servers/BaseServer.d.ts +15 -0
- package/types/lib/servers/SockJSServer.d.ts +12 -0
- package/types/lib/servers/WebsocketServer.d.ts +13 -0
package/bin/process-arguments.js
CHANGED
|
@@ -5,8 +5,50 @@ const path = require("path");
|
|
|
5
5
|
// Based on https://github.com/webpack/webpack/blob/master/lib/cli.js
|
|
6
6
|
// Please do not modify it
|
|
7
7
|
|
|
8
|
+
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} Problem
|
|
12
|
+
* @property {ProblemType} type
|
|
13
|
+
* @property {string} path
|
|
14
|
+
* @property {string} argument
|
|
15
|
+
* @property {any=} value
|
|
16
|
+
* @property {number=} index
|
|
17
|
+
* @property {string=} expected
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} LocalProblem
|
|
22
|
+
* @property {ProblemType} type
|
|
23
|
+
* @property {string} path
|
|
24
|
+
* @property {string=} expected
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} ArgumentConfig
|
|
29
|
+
* @property {string} description
|
|
30
|
+
* @property {string} path
|
|
31
|
+
* @property {boolean} multiple
|
|
32
|
+
* @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type
|
|
33
|
+
* @property {any[]=} values
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {Object} Argument
|
|
38
|
+
* @property {string} description
|
|
39
|
+
* @property {"string"|"number"|"boolean"} simpleType
|
|
40
|
+
* @property {boolean} multiple
|
|
41
|
+
* @property {ArgumentConfig[]} configs
|
|
42
|
+
*/
|
|
43
|
+
|
|
8
44
|
const cliAddedItems = new WeakMap();
|
|
9
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @param {any} config configuration
|
|
48
|
+
* @param {string} schemaPath path in the config
|
|
49
|
+
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
|
|
50
|
+
* @returns {{ problem?: LocalProblem, object?: any, property?: string | number, value?: any }} problem or object with property and value
|
|
51
|
+
*/
|
|
10
52
|
const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
11
53
|
if (!schemaPath) {
|
|
12
54
|
return { value: config };
|
|
@@ -81,10 +123,10 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
|
81
123
|
i++;
|
|
82
124
|
}
|
|
83
125
|
|
|
84
|
-
const value = current[property];
|
|
126
|
+
const value = current[/** @type {string} */ (property)];
|
|
85
127
|
|
|
86
|
-
if (property.endsWith("[]")) {
|
|
87
|
-
const name = property.slice(0, -2);
|
|
128
|
+
if (/** @type {string} */ (property).endsWith("[]")) {
|
|
129
|
+
const name = /** @type {string} */ (property).slice(0, -2);
|
|
88
130
|
// eslint-disable-next-line no-shadow
|
|
89
131
|
const value = current[name];
|
|
90
132
|
|
|
@@ -140,6 +182,11 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
|
140
182
|
return { object: current, property, value };
|
|
141
183
|
};
|
|
142
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @param {ArgumentConfig} argConfig processing instructions
|
|
187
|
+
* @param {any} value the value
|
|
188
|
+
* @returns {any | undefined} parsed value
|
|
189
|
+
*/
|
|
143
190
|
const parseValueForArgumentConfig = (argConfig, value) => {
|
|
144
191
|
// eslint-disable-next-line default-case
|
|
145
192
|
switch (argConfig.type) {
|
|
@@ -194,11 +241,11 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
|
194
241
|
|
|
195
242
|
break;
|
|
196
243
|
case "enum":
|
|
197
|
-
if (argConfig.values.includes(value)) {
|
|
244
|
+
if (/** @type {any[]} */ (argConfig.values).includes(value)) {
|
|
198
245
|
return value;
|
|
199
246
|
}
|
|
200
247
|
|
|
201
|
-
for (const item of argConfig.values) {
|
|
248
|
+
for (const item of /** @type {any[]} */ (argConfig.values)) {
|
|
202
249
|
if (`${item}` === value) return item;
|
|
203
250
|
}
|
|
204
251
|
|
|
@@ -212,6 +259,10 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
|
212
259
|
}
|
|
213
260
|
};
|
|
214
261
|
|
|
262
|
+
/**
|
|
263
|
+
* @param {ArgumentConfig} argConfig processing instructions
|
|
264
|
+
* @returns {string | undefined} expected message
|
|
265
|
+
*/
|
|
215
266
|
const getExpectedValue = (argConfig) => {
|
|
216
267
|
switch (argConfig.type) {
|
|
217
268
|
default:
|
|
@@ -221,12 +272,21 @@ const getExpectedValue = (argConfig) => {
|
|
|
221
272
|
case "RegExp":
|
|
222
273
|
return "regular expression (example: /ab?c*/)";
|
|
223
274
|
case "enum":
|
|
224
|
-
return
|
|
275
|
+
return /** @type {any[]} */ (argConfig.values)
|
|
276
|
+
.map((v) => `${v}`)
|
|
277
|
+
.join(" | ");
|
|
225
278
|
case "reset":
|
|
226
279
|
return "true (will reset the previous value to an empty array)";
|
|
227
280
|
}
|
|
228
281
|
};
|
|
229
282
|
|
|
283
|
+
/**
|
|
284
|
+
* @param {any} config configuration
|
|
285
|
+
* @param {string} schemaPath path in the config
|
|
286
|
+
* @param {any} value parsed value
|
|
287
|
+
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
|
|
288
|
+
* @returns {LocalProblem | null} problem or null for success
|
|
289
|
+
*/
|
|
230
290
|
const setValue = (config, schemaPath, value, index) => {
|
|
231
291
|
const { problem, object, property } = getObjectAndProperty(
|
|
232
292
|
config,
|
|
@@ -238,11 +298,18 @@ const setValue = (config, schemaPath, value, index) => {
|
|
|
238
298
|
return problem;
|
|
239
299
|
}
|
|
240
300
|
|
|
241
|
-
object[property] = value;
|
|
301
|
+
object[/** @type {string} */ (property)] = value;
|
|
242
302
|
|
|
243
303
|
return null;
|
|
244
304
|
};
|
|
245
305
|
|
|
306
|
+
/**
|
|
307
|
+
* @param {ArgumentConfig} argConfig processing instructions
|
|
308
|
+
* @param {any} config configuration
|
|
309
|
+
* @param {any} value the value
|
|
310
|
+
* @param {number | undefined} index the index if multiple values provided
|
|
311
|
+
* @returns {LocalProblem | null} a problem if any
|
|
312
|
+
*/
|
|
246
313
|
const processArgumentConfig = (argConfig, config, value, index) => {
|
|
247
314
|
// eslint-disable-next-line no-undefined
|
|
248
315
|
if (index !== undefined && !argConfig.multiple) {
|
|
@@ -272,7 +339,16 @@ const processArgumentConfig = (argConfig, config, value, index) => {
|
|
|
272
339
|
return null;
|
|
273
340
|
};
|
|
274
341
|
|
|
342
|
+
/**
|
|
343
|
+
* @param {Record<string, Argument>} args object of arguments
|
|
344
|
+
* @param {any} config configuration
|
|
345
|
+
* @param {Record<string, string | number | boolean | RegExp | (string | number | boolean | RegExp)[]>} values object with values
|
|
346
|
+
* @returns {Problem[] | null} problems or null for success
|
|
347
|
+
*/
|
|
275
348
|
const processArguments = (args, config, values) => {
|
|
349
|
+
/**
|
|
350
|
+
* @type {Problem[]}
|
|
351
|
+
*/
|
|
276
352
|
const problems = [];
|
|
277
353
|
|
|
278
354
|
for (const key of Object.keys(values)) {
|
|
@@ -289,6 +365,10 @@ const processArguments = (args, config, values) => {
|
|
|
289
365
|
continue;
|
|
290
366
|
}
|
|
291
367
|
|
|
368
|
+
/**
|
|
369
|
+
* @param {any} value
|
|
370
|
+
* @param {number | undefined} i
|
|
371
|
+
*/
|
|
292
372
|
const processValue = (value, i) => {
|
|
293
373
|
const currentProblems = [];
|
|
294
374
|
|
|
@@ -2,38 +2,61 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
2
2
|
|
|
3
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
4
4
|
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
6
|
|
|
7
7
|
import SockJS from "../modules/sockjs-client/index.js";
|
|
8
8
|
import { log } from "../utils/log.js";
|
|
9
9
|
|
|
10
10
|
var SockJSClient = /*#__PURE__*/function () {
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} url
|
|
13
|
+
*/
|
|
11
14
|
function SockJSClient(url) {
|
|
12
15
|
_classCallCheck(this, SockJSClient);
|
|
13
16
|
|
|
14
17
|
// SockJS requires `http` and `https` protocols
|
|
15
18
|
this.sock = new SockJS(url.replace(/^ws:/i, "http:").replace(/^wss:/i, "https:"));
|
|
16
19
|
|
|
17
|
-
this.sock.onerror =
|
|
20
|
+
this.sock.onerror =
|
|
21
|
+
/**
|
|
22
|
+
* @param {Error} error
|
|
23
|
+
*/
|
|
24
|
+
function (error) {
|
|
18
25
|
log.error(error);
|
|
19
26
|
};
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @param {(...args: any[]) => void} f
|
|
30
|
+
*/
|
|
31
|
+
|
|
21
32
|
|
|
22
33
|
_createClass(SockJSClient, [{
|
|
23
34
|
key: "onOpen",
|
|
24
35
|
value: function onOpen(f) {
|
|
25
36
|
this.sock.onopen = f;
|
|
26
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* @param {(...args: any[]) => void} f
|
|
40
|
+
*/
|
|
41
|
+
|
|
27
42
|
}, {
|
|
28
43
|
key: "onClose",
|
|
29
44
|
value: function onClose(f) {
|
|
30
45
|
this.sock.onclose = f;
|
|
31
46
|
} // call f with the message string as the first argument
|
|
32
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @param {(...args: any[]) => void} f
|
|
50
|
+
*/
|
|
51
|
+
|
|
33
52
|
}, {
|
|
34
53
|
key: "onMessage",
|
|
35
54
|
value: function onMessage(f) {
|
|
36
|
-
this.sock.onmessage =
|
|
55
|
+
this.sock.onmessage =
|
|
56
|
+
/**
|
|
57
|
+
* @param {Error & { data: string }} e
|
|
58
|
+
*/
|
|
59
|
+
function (e) {
|
|
37
60
|
f(e.data);
|
|
38
61
|
};
|
|
39
62
|
}
|
|
@@ -2,11 +2,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
2
2
|
|
|
3
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
4
4
|
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
6
|
|
|
7
7
|
import { log } from "../utils/log.js";
|
|
8
8
|
|
|
9
9
|
var WebSocketClient = /*#__PURE__*/function () {
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} url
|
|
12
|
+
*/
|
|
10
13
|
function WebSocketClient(url) {
|
|
11
14
|
_classCallCheck(this, WebSocketClient);
|
|
12
15
|
|
|
@@ -16,18 +19,30 @@ var WebSocketClient = /*#__PURE__*/function () {
|
|
|
16
19
|
log.error(error);
|
|
17
20
|
};
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* @param {(...args: any[]) => void} f
|
|
24
|
+
*/
|
|
25
|
+
|
|
19
26
|
|
|
20
27
|
_createClass(WebSocketClient, [{
|
|
21
28
|
key: "onOpen",
|
|
22
29
|
value: function onOpen(f) {
|
|
23
30
|
this.client.onopen = f;
|
|
24
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @param {(...args: any[]) => void} f
|
|
34
|
+
*/
|
|
35
|
+
|
|
25
36
|
}, {
|
|
26
37
|
key: "onClose",
|
|
27
38
|
value: function onClose(f) {
|
|
28
39
|
this.client.onclose = f;
|
|
29
40
|
} // call f with the message string as the first argument
|
|
30
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @param {(...args: any[]) => void} f
|
|
44
|
+
*/
|
|
45
|
+
|
|
31
46
|
}, {
|
|
32
47
|
key: "onMessage",
|
|
33
48
|
value: function onMessage(f) {
|
package/client/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* global __resourceQuery, __webpack_hash__ */
|
|
2
|
+
/// <reference types="webpack/module" />
|
|
2
3
|
import webpackHotLog from "webpack/hot/log.js";
|
|
3
4
|
import stripAnsi from "./modules/strip-ansi/index.js";
|
|
4
5
|
import parseURL from "./utils/parseURL.js";
|
|
@@ -8,12 +9,35 @@ import { log, setLogLevel } from "./utils/log.js";
|
|
|
8
9
|
import sendMessage from "./utils/sendMessage.js";
|
|
9
10
|
import reloadApp from "./utils/reloadApp.js";
|
|
10
11
|
import createSocketURL from "./utils/createSocketURL.js";
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} Options
|
|
14
|
+
* @property {boolean} hot
|
|
15
|
+
* @property {boolean} liveReload
|
|
16
|
+
* @property {boolean} progress
|
|
17
|
+
* @property {boolean | { warnings?: boolean, errors?: boolean }} overlay
|
|
18
|
+
* @property {string} [logging]
|
|
19
|
+
* @property {number} [reconnect]
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} Status
|
|
24
|
+
* @property {boolean} isUnloading
|
|
25
|
+
* @property {string} currentHash
|
|
26
|
+
* @property {string} [previousHash]
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type {Status}
|
|
31
|
+
*/
|
|
32
|
+
|
|
11
33
|
var status = {
|
|
12
34
|
isUnloading: false,
|
|
13
35
|
// TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement
|
|
14
36
|
// eslint-disable-next-line camelcase
|
|
15
37
|
currentHash: typeof __webpack_hash__ !== "undefined" ? __webpack_hash__ : ""
|
|
16
38
|
};
|
|
39
|
+
/** @type {Options} */
|
|
40
|
+
|
|
17
41
|
var options = {
|
|
18
42
|
hot: false,
|
|
19
43
|
liveReload: false,
|
|
@@ -39,6 +63,10 @@ if (parsedResourceQuery.logging) {
|
|
|
39
63
|
if (typeof parsedResourceQuery.reconnect !== "undefined") {
|
|
40
64
|
options.reconnect = Number(parsedResourceQuery.reconnect);
|
|
41
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} level
|
|
68
|
+
*/
|
|
69
|
+
|
|
42
70
|
|
|
43
71
|
function setAllLogLevel(level) {
|
|
44
72
|
// This is needed because the HMR logger operate separately from dev server logger
|
|
@@ -79,11 +107,19 @@ var onSocketMessage = {
|
|
|
79
107
|
|
|
80
108
|
sendMessage("Invalid");
|
|
81
109
|
},
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {string} hash
|
|
113
|
+
*/
|
|
82
114
|
hash: function hash(_hash) {
|
|
83
115
|
status.previousHash = status.currentHash;
|
|
84
116
|
status.currentHash = _hash;
|
|
85
117
|
},
|
|
86
118
|
logging: setAllLogLevel,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @param {boolean} value
|
|
122
|
+
*/
|
|
87
123
|
overlay: function overlay(value) {
|
|
88
124
|
if (typeof document === "undefined") {
|
|
89
125
|
return;
|
|
@@ -91,6 +127,10 @@ var onSocketMessage = {
|
|
|
91
127
|
|
|
92
128
|
options.overlay = value;
|
|
93
129
|
},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @param {number} value
|
|
133
|
+
*/
|
|
94
134
|
reconnect: function reconnect(value) {
|
|
95
135
|
if (parsedResourceQuery.reconnect === "false") {
|
|
96
136
|
return;
|
|
@@ -98,9 +138,17 @@ var onSocketMessage = {
|
|
|
98
138
|
|
|
99
139
|
options.reconnect = value;
|
|
100
140
|
},
|
|
101
|
-
|
|
102
|
-
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {boolean} value
|
|
144
|
+
*/
|
|
145
|
+
progress: function progress(value) {
|
|
146
|
+
options.progress = value;
|
|
103
147
|
},
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @param {{ pluginName?: string, percent: number, msg: string }} data
|
|
151
|
+
*/
|
|
104
152
|
"progress-update": function progressUpdate(data) {
|
|
105
153
|
if (options.progress) {
|
|
106
154
|
log.info("".concat(data.pluginName ? "[".concat(data.pluginName, "] ") : "").concat(data.percent, "% - ").concat(data.msg, "."));
|
|
@@ -127,14 +175,27 @@ var onSocketMessage = {
|
|
|
127
175
|
reloadApp(options, status);
|
|
128
176
|
},
|
|
129
177
|
// TODO: remove in v5 in favor of 'static-changed'
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @param {string} file
|
|
181
|
+
*/
|
|
130
182
|
"content-changed": function contentChanged(file) {
|
|
131
183
|
log.info("".concat(file ? "\"".concat(file, "\"") : "Content", " from static directory was changed. Reloading..."));
|
|
132
184
|
self.location.reload();
|
|
133
185
|
},
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {string} file
|
|
189
|
+
*/
|
|
134
190
|
"static-changed": function staticChanged(file) {
|
|
135
191
|
log.info("".concat(file ? "\"".concat(file, "\"") : "Content", " from static directory was changed. Reloading..."));
|
|
136
192
|
self.location.reload();
|
|
137
193
|
},
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @param {Error[]} warnings
|
|
197
|
+
* @param {any} params
|
|
198
|
+
*/
|
|
138
199
|
warnings: function warnings(_warnings, params) {
|
|
139
200
|
log.warn("Warnings while compiling.");
|
|
140
201
|
|
|
@@ -164,6 +225,10 @@ var onSocketMessage = {
|
|
|
164
225
|
|
|
165
226
|
reloadApp(options, status);
|
|
166
227
|
},
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param {Error[]} errors
|
|
231
|
+
*/
|
|
167
232
|
errors: function errors(_errors) {
|
|
168
233
|
log.error("Errors while compiling. Reload prevented.");
|
|
169
234
|
|
|
@@ -187,6 +252,10 @@ var onSocketMessage = {
|
|
|
187
252
|
show("error", _errors);
|
|
188
253
|
}
|
|
189
254
|
},
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @param {Error} error
|
|
258
|
+
*/
|
|
190
259
|
error: function error(_error) {
|
|
191
260
|
log.error(_error);
|
|
192
261
|
},
|
|
@@ -87,6 +87,9 @@ function _defineProperties(target, props) {
|
|
|
87
87
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
88
88
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
89
89
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
90
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
91
|
+
writable: false
|
|
92
|
+
});
|
|
90
93
|
return Constructor;
|
|
91
94
|
}
|
|
92
95
|
|
|
@@ -6459,7 +6459,7 @@ function Url(address, location, parser) {
|
|
|
6459
6459
|
|
|
6460
6460
|
if (url.auth) {
|
|
6461
6461
|
instruction = url.auth.split(':');
|
|
6462
|
-
url.username = instruction[0]
|
|
6462
|
+
url.username = instruction[0];
|
|
6463
6463
|
url.password = instruction[1] || '';
|
|
6464
6464
|
}
|
|
6465
6465
|
|
|
@@ -6544,8 +6544,15 @@ function set(part, value, fn) {
|
|
|
6544
6544
|
|
|
6545
6545
|
break;
|
|
6546
6546
|
|
|
6547
|
-
|
|
6548
|
-
|
|
6547
|
+
case 'username':
|
|
6548
|
+
case 'password':
|
|
6549
|
+
url[part] = encodeURIComponent(value);
|
|
6550
|
+
break;
|
|
6551
|
+
|
|
6552
|
+
case 'auth':
|
|
6553
|
+
var splits = value.split(':');
|
|
6554
|
+
url.username = splits[0];
|
|
6555
|
+
url.password = splits.length === 2 ? splits[1] : '';
|
|
6549
6556
|
}
|
|
6550
6557
|
|
|
6551
6558
|
for (var i = 0; i < rules.length; i++) {
|
|
@@ -6553,6 +6560,7 @@ function set(part, value, fn) {
|
|
|
6553
6560
|
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
6554
6561
|
}
|
|
6555
6562
|
|
|
6563
|
+
url.auth = url.password ? url.username + ':' + url.password : url.username;
|
|
6556
6564
|
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host ? url.protocol + '//' + url.host : 'null';
|
|
6557
6565
|
url.href = url.toString();
|
|
6558
6566
|
return url;
|
|
@@ -6572,12 +6580,15 @@ function toString(stringify) {
|
|
|
6572
6580
|
url = this,
|
|
6573
6581
|
protocol = url.protocol;
|
|
6574
6582
|
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
|
|
6575
|
-
var result = protocol + (url.slashes || isSpecial(url.protocol) ? '//' : '');
|
|
6583
|
+
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? '//' : '');
|
|
6576
6584
|
|
|
6577
6585
|
if (url.username) {
|
|
6578
6586
|
result += url.username;
|
|
6579
6587
|
if (url.password) result += ':' + url.password;
|
|
6580
6588
|
result += '@';
|
|
6589
|
+
} else if (url.password) {
|
|
6590
|
+
result += ':' + url.password;
|
|
6591
|
+
result += '@';
|
|
6581
6592
|
}
|
|
6582
6593
|
|
|
6583
6594
|
result += url.host + url.pathname;
|
package/client/overlay.js
CHANGED
|
@@ -14,8 +14,14 @@ var colors = {
|
|
|
14
14
|
lightgrey: "EBE7E3",
|
|
15
15
|
darkgrey: "6D7891"
|
|
16
16
|
};
|
|
17
|
+
/** @type {HTMLIFrameElement | null | undefined} */
|
|
18
|
+
|
|
17
19
|
var iframeContainerElement;
|
|
20
|
+
/** @type {HTMLDivElement | null | undefined} */
|
|
21
|
+
|
|
18
22
|
var containerElement;
|
|
23
|
+
/** @type {Array<(element: HTMLDivElement) => void>} */
|
|
24
|
+
|
|
19
25
|
var onLoadQueue = [];
|
|
20
26
|
ansiHTML.setColors(colors);
|
|
21
27
|
|
|
@@ -34,7 +40,11 @@ function createContainer() {
|
|
|
34
40
|
iframeContainerElement.style.zIndex = 9999999999;
|
|
35
41
|
|
|
36
42
|
iframeContainerElement.onload = function () {
|
|
37
|
-
containerElement =
|
|
43
|
+
containerElement =
|
|
44
|
+
/** @type {Document} */
|
|
45
|
+
|
|
46
|
+
/** @type {HTMLIFrameElement} */
|
|
47
|
+
iframeContainerElement.contentDocument.createElement("div");
|
|
38
48
|
containerElement.id = "webpack-dev-server-client-overlay-div";
|
|
39
49
|
containerElement.style.position = "fixed";
|
|
40
50
|
containerElement.style.boxSizing = "border-box";
|
|
@@ -62,7 +72,8 @@ function createContainer() {
|
|
|
62
72
|
closeButtonElement.style.fontWeight = "bold";
|
|
63
73
|
closeButtonElement.style.color = "white";
|
|
64
74
|
closeButtonElement.style.cursor = "pointer";
|
|
65
|
-
closeButtonElement.style.cssFloat = "right";
|
|
75
|
+
closeButtonElement.style.cssFloat = "right"; // @ts-ignore
|
|
76
|
+
|
|
66
77
|
closeButtonElement.style.styleFloat = "right";
|
|
67
78
|
closeButtonElement.addEventListener("click", function () {
|
|
68
79
|
hide();
|
|
@@ -71,16 +82,27 @@ function createContainer() {
|
|
|
71
82
|
containerElement.appendChild(closeButtonElement);
|
|
72
83
|
containerElement.appendChild(document.createElement("br"));
|
|
73
84
|
containerElement.appendChild(document.createElement("br"));
|
|
85
|
+
/** @type {Document} */
|
|
86
|
+
|
|
87
|
+
/** @type {HTMLIFrameElement} */
|
|
74
88
|
iframeContainerElement.contentDocument.body.appendChild(containerElement);
|
|
75
89
|
onLoadQueue.forEach(function (onLoad) {
|
|
76
|
-
onLoad(
|
|
90
|
+
onLoad(
|
|
91
|
+
/** @type {HTMLDivElement} */
|
|
92
|
+
containerElement);
|
|
77
93
|
});
|
|
78
94
|
onLoadQueue = [];
|
|
95
|
+
/** @type {HTMLIFrameElement} */
|
|
96
|
+
|
|
79
97
|
iframeContainerElement.onload = null;
|
|
80
98
|
};
|
|
81
99
|
|
|
82
100
|
document.body.appendChild(iframeContainerElement);
|
|
83
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* @param {(element: HTMLDivElement) => void} callback
|
|
104
|
+
*/
|
|
105
|
+
|
|
84
106
|
|
|
85
107
|
function ensureOverlayExists(callback) {
|
|
86
108
|
if (containerElement) {
|
|
@@ -109,6 +131,12 @@ function hide() {
|
|
|
109
131
|
iframeContainerElement = null;
|
|
110
132
|
containerElement = null;
|
|
111
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* @param {string} type
|
|
136
|
+
* @param {string | { file?: string, moduleName?: string, loc?: string, message?: string }} item
|
|
137
|
+
* @returns {{ header: string, body: string }}
|
|
138
|
+
*/
|
|
139
|
+
|
|
112
140
|
|
|
113
141
|
function formatProblem(type, item) {
|
|
114
142
|
var header = type === "warning" ? "WARNING" : "ERROR";
|
|
@@ -131,6 +159,11 @@ function formatProblem(type, item) {
|
|
|
131
159
|
};
|
|
132
160
|
} // Compilation with errors (e.g. syntax error or missing modules).
|
|
133
161
|
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} type
|
|
164
|
+
* @param {Array<string | { file?: string, moduleName?: string, loc?: string, message?: string }>} messages
|
|
165
|
+
*/
|
|
166
|
+
|
|
134
167
|
|
|
135
168
|
function show(type, messages) {
|
|
136
169
|
ensureOverlayExists(function () {
|
|
@@ -154,6 +187,8 @@ function show(type, messages) {
|
|
|
154
187
|
entryElement.appendChild(messageTextNode);
|
|
155
188
|
entryElement.appendChild(document.createElement("br"));
|
|
156
189
|
entryElement.appendChild(document.createElement("br"));
|
|
190
|
+
/** @type {HTMLDivElement} */
|
|
191
|
+
|
|
157
192
|
containerElement.appendChild(entryElement);
|
|
158
193
|
});
|
|
159
194
|
});
|
package/client/socket.js
CHANGED
|
@@ -4,20 +4,27 @@ import { log } from "./utils/log.js"; // this WebsocketClient is here as a defau
|
|
|
4
4
|
|
|
5
5
|
/* eslint-disable camelcase */
|
|
6
6
|
|
|
7
|
-
var Client = // eslint-disable-next-line
|
|
8
|
-
typeof __webpack_dev_server_client__ !== "undefined" ?
|
|
9
|
-
typeof __webpack_dev_server_client__.default !== "undefined" ? __webpack_dev_server_client__.default : __webpack_dev_server_client__ : WebSocketClient;
|
|
7
|
+
var Client = // eslint-disable-next-line no-nested-ternary
|
|
8
|
+
typeof __webpack_dev_server_client__ !== "undefined" ? typeof __webpack_dev_server_client__.default !== "undefined" ? __webpack_dev_server_client__.default : __webpack_dev_server_client__ : WebSocketClient;
|
|
10
9
|
/* eslint-enable camelcase */
|
|
11
10
|
|
|
12
11
|
var retries = 0;
|
|
13
12
|
var maxRetries = 10;
|
|
14
13
|
var client = null;
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} url
|
|
16
|
+
* @param {{ [handler: string]: (data?: any, params?: any) => any }} handlers
|
|
17
|
+
* @param {number} [reconnect]
|
|
18
|
+
*/
|
|
15
19
|
|
|
16
20
|
var socket = function initSocket(url, handlers, reconnect) {
|
|
17
21
|
client = new Client(url);
|
|
18
22
|
client.onOpen(function () {
|
|
19
23
|
retries = 0;
|
|
20
|
-
|
|
24
|
+
|
|
25
|
+
if (typeof reconnect !== "undefined") {
|
|
26
|
+
maxRetries = reconnect;
|
|
27
|
+
}
|
|
21
28
|
});
|
|
22
29
|
client.onClose(function () {
|
|
23
30
|
if (retries === 0) {
|
|
@@ -30,7 +37,7 @@ var socket = function initSocket(url, handlers, reconnect) {
|
|
|
30
37
|
if (retries < maxRetries) {
|
|
31
38
|
// Exponentially increase timeout to reconnect.
|
|
32
39
|
// Respectfully copied from the package `got`.
|
|
33
|
-
// eslint-disable-next-line no-
|
|
40
|
+
// eslint-disable-next-line no-restricted-properties
|
|
34
41
|
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
|
|
35
42
|
retries += 1;
|
|
36
43
|
log.info("Trying to reconnect...");
|
|
@@ -39,7 +46,11 @@ var socket = function initSocket(url, handlers, reconnect) {
|
|
|
39
46
|
}, retryInMs);
|
|
40
47
|
}
|
|
41
48
|
});
|
|
42
|
-
client.onMessage(
|
|
49
|
+
client.onMessage(
|
|
50
|
+
/**
|
|
51
|
+
* @param {any} data
|
|
52
|
+
*/
|
|
53
|
+
function (data) {
|
|
43
54
|
var message = JSON.parse(data);
|
|
44
55
|
|
|
45
56
|
if (handlers[message.type]) {
|