webpack-dev-server 5.1.0 → 5.2.1
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/client/clients/SockJSClient.js +3 -2
- package/client/clients/WebSocketClient.js +3 -2
- package/client/index.js +288 -21
- package/client/modules/logger/index.js +51 -30
- package/client/modules/sockjs-client/index.js +17 -11
- package/client/overlay.js +359 -13
- package/client/progress.js +4 -3
- package/client/socket.js +5 -1
- package/client/utils/log.js +1 -17
- package/lib/Server.js +194 -65
- package/package.json +26 -26
- package/types/lib/Server.d.ts +26 -11
- package/client/overlay/fsm.js +0 -64
- package/client/overlay/runtime-error.js +0 -47
- package/client/overlay/state-machine.js +0 -100
- package/client/overlay/styles.js +0 -74
- package/client/utils/createSocketURL.js +0 -121
- package/client/utils/getCurrentScriptSource.js +0 -24
- package/client/utils/parseURL.js +0 -36
- package/client/utils/reloadApp.js +0 -63
- package/client/utils/stripAnsi.js +0 -18
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
2
3
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
3
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
7
|
import SockJS from "../modules/sockjs-client/index.js";
|
|
7
8
|
import { log } from "../utils/log.js";
|
|
8
9
|
var SockJSClient = /*#__PURE__*/function () {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
2
3
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
3
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
7
|
import { log } from "../utils/log.js";
|
|
7
8
|
var WebSocketClient = /*#__PURE__*/function () {
|
|
8
9
|
/**
|
package/client/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
2
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
3
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
7
|
/* global __resourceQuery, __webpack_hash__ */
|
|
7
8
|
/// <reference types="webpack/module" />
|
|
8
9
|
import webpackHotLog from "webpack/hot/log.js";
|
|
9
|
-
import
|
|
10
|
-
import parseURL from "./utils/parseURL.js";
|
|
10
|
+
import hotEmitter from "webpack/hot/emitter.js";
|
|
11
11
|
import socket from "./socket.js";
|
|
12
12
|
import { formatProblem, createOverlay } from "./overlay.js";
|
|
13
|
-
import { log,
|
|
13
|
+
import { log, setLogLevel } from "./utils/log.js";
|
|
14
14
|
import sendMessage from "./utils/sendMessage.js";
|
|
15
|
-
import reloadApp from "./utils/reloadApp.js";
|
|
16
|
-
import createSocketURL from "./utils/createSocketURL.js";
|
|
17
15
|
import { isProgressSupported, defineProgressElement } from "./progress.js";
|
|
18
16
|
|
|
19
17
|
/**
|
|
@@ -45,14 +43,13 @@ import { isProgressSupported, defineProgressElement } from "./progress.js";
|
|
|
45
43
|
* @param {boolean | { warnings?: boolean | string; errors?: boolean | string; runtimeErrors?: boolean | string; }} overlayOptions
|
|
46
44
|
*/
|
|
47
45
|
var decodeOverlayOptions = function decodeOverlayOptions(overlayOptions) {
|
|
48
|
-
if (
|
|
46
|
+
if (_typeof(overlayOptions) === "object") {
|
|
49
47
|
["warnings", "errors", "runtimeErrors"].forEach(function (property) {
|
|
50
48
|
if (typeof overlayOptions[property] === "string") {
|
|
51
49
|
var overlayFilterFunctionString = decodeURIComponent(overlayOptions[property]);
|
|
52
50
|
|
|
53
51
|
// eslint-disable-next-line no-new-func
|
|
54
|
-
|
|
55
|
-
overlayOptions[property] = overlayFilterFunction;
|
|
52
|
+
overlayOptions[property] = new Function("message", "var callback = ".concat(overlayFilterFunctionString, "\n return callback(message)"));
|
|
56
53
|
}
|
|
57
54
|
});
|
|
58
55
|
}
|
|
@@ -67,12 +64,62 @@ var status = {
|
|
|
67
64
|
currentHash: __webpack_hash__
|
|
68
65
|
};
|
|
69
66
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
/**
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
var getCurrentScriptSource = function getCurrentScriptSource() {
|
|
71
|
+
// `document.currentScript` is the most accurate way to find the current script,
|
|
72
|
+
// but is not supported in all browsers.
|
|
73
|
+
if (document.currentScript) {
|
|
74
|
+
return document.currentScript.getAttribute("src");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Fallback to getting all scripts running in the document.
|
|
78
|
+
var scriptElements = document.scripts || [];
|
|
79
|
+
var scriptElementsWithSrc = Array.prototype.filter.call(scriptElements, function (element) {
|
|
80
|
+
return element.getAttribute("src");
|
|
81
|
+
});
|
|
82
|
+
if (scriptElementsWithSrc.length > 0) {
|
|
83
|
+
var currentScript = scriptElementsWithSrc[scriptElementsWithSrc.length - 1];
|
|
84
|
+
return currentScript.getAttribute("src");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Fail as there was no script to use.
|
|
88
|
+
throw new Error("[webpack-dev-server] Failed to get current script source.");
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {string} resourceQuery
|
|
93
|
+
* @returns {{ [key: string]: string | boolean }}
|
|
94
|
+
*/
|
|
95
|
+
var parseURL = function parseURL(resourceQuery) {
|
|
96
|
+
/** @type {{ [key: string]: string }} */
|
|
97
|
+
var result = {};
|
|
98
|
+
if (typeof resourceQuery === "string" && resourceQuery !== "") {
|
|
99
|
+
var searchParams = resourceQuery.slice(1).split("&");
|
|
100
|
+
for (var i = 0; i < searchParams.length; i++) {
|
|
101
|
+
var pair = searchParams[i].split("=");
|
|
102
|
+
result[pair[0]] = decodeURIComponent(pair[1]);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
// Else, get the url from the <script> this file was called with.
|
|
106
|
+
var scriptSource = getCurrentScriptSource();
|
|
107
|
+
var scriptSourceURL;
|
|
108
|
+
try {
|
|
109
|
+
// The placeholder `baseURL` with `window.location.href`,
|
|
110
|
+
// is to allow parsing of path-relative or protocol-relative URLs,
|
|
111
|
+
// and will have no effect if `scriptSource` is a fully valid URL.
|
|
112
|
+
scriptSourceURL = new URL(scriptSource, self.location.href);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
// URL parsing failed, do nothing.
|
|
115
|
+
// We will still proceed to see if we can recover using `resourceQuery`
|
|
116
|
+
}
|
|
117
|
+
if (scriptSourceURL) {
|
|
118
|
+
result = scriptSourceURL;
|
|
119
|
+
result.fromCurrentScript = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
76
123
|
};
|
|
77
124
|
var parsedResourceQuery = parseURL(__resourceQuery);
|
|
78
125
|
var enabledFeatures = {
|
|
@@ -81,6 +128,14 @@ var enabledFeatures = {
|
|
|
81
128
|
Progress: false,
|
|
82
129
|
Overlay: false
|
|
83
130
|
};
|
|
131
|
+
|
|
132
|
+
/** @type {Options} */
|
|
133
|
+
var options = {
|
|
134
|
+
hot: false,
|
|
135
|
+
liveReload: false,
|
|
136
|
+
progress: false,
|
|
137
|
+
overlay: false
|
|
138
|
+
};
|
|
84
139
|
if (parsedResourceQuery.hot === "true") {
|
|
85
140
|
options.hot = true;
|
|
86
141
|
enabledFeatures["Hot Module Replacement"] = true;
|
|
@@ -101,7 +156,7 @@ if (parsedResourceQuery.overlay) {
|
|
|
101
156
|
}
|
|
102
157
|
|
|
103
158
|
// Fill in default "true" params for partially-specified objects.
|
|
104
|
-
if (
|
|
159
|
+
if (_typeof(options.overlay) === "object") {
|
|
105
160
|
options.overlay = _objectSpread({
|
|
106
161
|
errors: true,
|
|
107
162
|
warnings: true,
|
|
@@ -121,19 +176,35 @@ if (typeof parsedResourceQuery.reconnect !== "undefined") {
|
|
|
121
176
|
/**
|
|
122
177
|
* @param {string} level
|
|
123
178
|
*/
|
|
124
|
-
function setAllLogLevel(level) {
|
|
179
|
+
var setAllLogLevel = function setAllLogLevel(level) {
|
|
125
180
|
// This is needed because the HMR logger operate separately from dev server logger
|
|
126
181
|
webpackHotLog.setLogLevel(level === "verbose" || level === "log" ? "info" : level);
|
|
127
182
|
setLogLevel(level);
|
|
128
|
-
}
|
|
183
|
+
};
|
|
129
184
|
if (options.logging) {
|
|
130
185
|
setAllLogLevel(options.logging);
|
|
131
186
|
}
|
|
187
|
+
var logEnabledFeatures = function logEnabledFeatures(features) {
|
|
188
|
+
var listEnabledFeatures = Object.keys(features);
|
|
189
|
+
if (!features || listEnabledFeatures.length === 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
var logString = "Server started:";
|
|
193
|
+
|
|
194
|
+
// Server started: Hot Module Replacement enabled, Live Reloading enabled, Overlay disabled.
|
|
195
|
+
for (var i = 0; i < listEnabledFeatures.length; i++) {
|
|
196
|
+
var key = listEnabledFeatures[i];
|
|
197
|
+
logString += " ".concat(key, " ").concat(features[key] ? "enabled" : "disabled", ",");
|
|
198
|
+
}
|
|
199
|
+
// replace last comma with a period
|
|
200
|
+
logString = logString.slice(0, -1).concat(".");
|
|
201
|
+
log.info(logString);
|
|
202
|
+
};
|
|
132
203
|
logEnabledFeatures(enabledFeatures);
|
|
133
204
|
self.addEventListener("beforeunload", function () {
|
|
134
205
|
status.isUnloading = true;
|
|
135
206
|
});
|
|
136
|
-
var overlay = typeof window !== "undefined" ? createOverlay(
|
|
207
|
+
var overlay = typeof window !== "undefined" ? createOverlay(_typeof(options.overlay) === "object" ? {
|
|
137
208
|
trustedTypesPolicyName: options.overlay.trustedTypesPolicyName,
|
|
138
209
|
catchRuntimeError: options.overlay.runtimeErrors
|
|
139
210
|
} : {
|
|
@@ -142,6 +213,80 @@ var overlay = typeof window !== "undefined" ? createOverlay(typeof options.overl
|
|
|
142
213
|
}) : {
|
|
143
214
|
send: function send() {}
|
|
144
215
|
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @param {Options} options
|
|
219
|
+
* @param {Status} currentStatus
|
|
220
|
+
*/
|
|
221
|
+
var reloadApp = function reloadApp(_ref, currentStatus) {
|
|
222
|
+
var hot = _ref.hot,
|
|
223
|
+
liveReload = _ref.liveReload;
|
|
224
|
+
if (currentStatus.isUnloading) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
var currentHash = currentStatus.currentHash,
|
|
228
|
+
previousHash = currentStatus.previousHash;
|
|
229
|
+
var isInitial = currentHash.indexOf(/** @type {string} */previousHash) >= 0;
|
|
230
|
+
if (isInitial) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @param {Window} rootWindow
|
|
236
|
+
* @param {number} intervalId
|
|
237
|
+
*/
|
|
238
|
+
function applyReload(rootWindow, intervalId) {
|
|
239
|
+
clearInterval(intervalId);
|
|
240
|
+
log.info("App updated. Reloading...");
|
|
241
|
+
rootWindow.location.reload();
|
|
242
|
+
}
|
|
243
|
+
var search = self.location.search.toLowerCase();
|
|
244
|
+
var allowToHot = search.indexOf("webpack-dev-server-hot=false") === -1;
|
|
245
|
+
var allowToLiveReload = search.indexOf("webpack-dev-server-live-reload=false") === -1;
|
|
246
|
+
if (hot && allowToHot) {
|
|
247
|
+
log.info("App hot update...");
|
|
248
|
+
hotEmitter.emit("webpackHotUpdate", currentStatus.currentHash);
|
|
249
|
+
if (typeof self !== "undefined" && self.window) {
|
|
250
|
+
// broadcast update to window
|
|
251
|
+
self.postMessage("webpackHotUpdate".concat(currentStatus.currentHash), "*");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// allow refreshing the page only if liveReload isn't disabled
|
|
255
|
+
else if (liveReload && allowToLiveReload) {
|
|
256
|
+
var rootWindow = self;
|
|
257
|
+
|
|
258
|
+
// use parent window for reload (in case we're in an iframe with no valid src)
|
|
259
|
+
var intervalId = self.setInterval(function () {
|
|
260
|
+
if (rootWindow.location.protocol !== "about:") {
|
|
261
|
+
// reload immediately if protocol is valid
|
|
262
|
+
applyReload(rootWindow, intervalId);
|
|
263
|
+
} else {
|
|
264
|
+
rootWindow = rootWindow.parent;
|
|
265
|
+
if (rootWindow.parent === rootWindow) {
|
|
266
|
+
// if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
|
|
267
|
+
applyReload(rootWindow, intervalId);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var ansiRegex = new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|"), "g");
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
*
|
|
277
|
+
* Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
|
|
278
|
+
* Adapted from code originally released by Sindre Sorhus
|
|
279
|
+
* Licensed the MIT License
|
|
280
|
+
*
|
|
281
|
+
* @param {string} string
|
|
282
|
+
* @return {string}
|
|
283
|
+
*/
|
|
284
|
+
var stripAnsi = function stripAnsi(string) {
|
|
285
|
+
if (typeof string !== "string") {
|
|
286
|
+
throw new TypeError("Expected a `string`, got `".concat(_typeof(string), "`"));
|
|
287
|
+
}
|
|
288
|
+
return string.replace(ansiRegex, "");
|
|
289
|
+
};
|
|
145
290
|
var onSocketMessage = {
|
|
146
291
|
hot: function hot() {
|
|
147
292
|
if (parsedResourceQuery.hot === "false") {
|
|
@@ -320,5 +465,127 @@ var onSocketMessage = {
|
|
|
320
465
|
sendMessage("Close");
|
|
321
466
|
}
|
|
322
467
|
};
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @param {{ protocol?: string, auth?: string, hostname?: string, port?: string, pathname?: string, search?: string, hash?: string, slashes?: boolean }} objURL
|
|
471
|
+
* @returns {string}
|
|
472
|
+
*/
|
|
473
|
+
var formatURL = function formatURL(objURL) {
|
|
474
|
+
var protocol = objURL.protocol || "";
|
|
475
|
+
if (protocol && protocol.substr(-1) !== ":") {
|
|
476
|
+
protocol += ":";
|
|
477
|
+
}
|
|
478
|
+
var auth = objURL.auth || "";
|
|
479
|
+
if (auth) {
|
|
480
|
+
auth = encodeURIComponent(auth);
|
|
481
|
+
auth = auth.replace(/%3A/i, ":");
|
|
482
|
+
auth += "@";
|
|
483
|
+
}
|
|
484
|
+
var host = "";
|
|
485
|
+
if (objURL.hostname) {
|
|
486
|
+
host = auth + (objURL.hostname.indexOf(":") === -1 ? objURL.hostname : "[".concat(objURL.hostname, "]"));
|
|
487
|
+
if (objURL.port) {
|
|
488
|
+
host += ":".concat(objURL.port);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
var pathname = objURL.pathname || "";
|
|
492
|
+
if (objURL.slashes) {
|
|
493
|
+
host = "//".concat(host || "");
|
|
494
|
+
if (pathname && pathname.charAt(0) !== "/") {
|
|
495
|
+
pathname = "/".concat(pathname);
|
|
496
|
+
}
|
|
497
|
+
} else if (!host) {
|
|
498
|
+
host = "";
|
|
499
|
+
}
|
|
500
|
+
var search = objURL.search || "";
|
|
501
|
+
if (search && search.charAt(0) !== "?") {
|
|
502
|
+
search = "?".concat(search);
|
|
503
|
+
}
|
|
504
|
+
var hash = objURL.hash || "";
|
|
505
|
+
if (hash && hash.charAt(0) !== "#") {
|
|
506
|
+
hash = "#".concat(hash);
|
|
507
|
+
}
|
|
508
|
+
pathname = pathname.replace(/[?#]/g,
|
|
509
|
+
/**
|
|
510
|
+
* @param {string} match
|
|
511
|
+
* @returns {string}
|
|
512
|
+
*/
|
|
513
|
+
function (match) {
|
|
514
|
+
return encodeURIComponent(match);
|
|
515
|
+
});
|
|
516
|
+
search = search.replace("#", "%23");
|
|
517
|
+
return "".concat(protocol).concat(host).concat(pathname).concat(search).concat(hash);
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* @param {URL & { fromCurrentScript?: boolean }} parsedURL
|
|
522
|
+
* @returns {string}
|
|
523
|
+
*/
|
|
524
|
+
var createSocketURL = function createSocketURL(parsedURL) {
|
|
525
|
+
var hostname = parsedURL.hostname;
|
|
526
|
+
|
|
527
|
+
// Node.js module parses it as `::`
|
|
528
|
+
// `new URL(urlString, [baseURLString])` parses it as '[::]'
|
|
529
|
+
var isInAddrAny = hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]";
|
|
530
|
+
|
|
531
|
+
// why do we need this check?
|
|
532
|
+
// hostname n/a for file protocol (example, when using electron, ionic)
|
|
533
|
+
// see: https://github.com/webpack/webpack-dev-server/pull/384
|
|
534
|
+
if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf("http") === 0) {
|
|
535
|
+
hostname = self.location.hostname;
|
|
536
|
+
}
|
|
537
|
+
var socketURLProtocol = parsedURL.protocol || self.location.protocol;
|
|
538
|
+
|
|
539
|
+
// When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.
|
|
540
|
+
if (socketURLProtocol === "auto:" || hostname && isInAddrAny && self.location.protocol === "https:") {
|
|
541
|
+
socketURLProtocol = self.location.protocol;
|
|
542
|
+
}
|
|
543
|
+
socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, "ws");
|
|
544
|
+
var socketURLAuth = "";
|
|
545
|
+
|
|
546
|
+
// `new URL(urlString, [baseURLstring])` doesn't have `auth` property
|
|
547
|
+
// Parse authentication credentials in case we need them
|
|
548
|
+
if (parsedURL.username) {
|
|
549
|
+
socketURLAuth = parsedURL.username;
|
|
550
|
+
|
|
551
|
+
// Since HTTP basic authentication does not allow empty username,
|
|
552
|
+
// we only include password if the username is not empty.
|
|
553
|
+
if (parsedURL.password) {
|
|
554
|
+
// Result: <username>:<password>
|
|
555
|
+
socketURLAuth = socketURLAuth.concat(":", parsedURL.password);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// In case the host is a raw IPv6 address, it can be enclosed in
|
|
560
|
+
// the brackets as the brackets are needed in the final URL string.
|
|
561
|
+
// Need to remove those as url.format blindly adds its own set of brackets
|
|
562
|
+
// if the host string contains colons. That would lead to non-working
|
|
563
|
+
// double brackets (e.g. [[::]]) host
|
|
564
|
+
//
|
|
565
|
+
// All of these web socket url params are optionally passed in through resourceQuery,
|
|
566
|
+
// so we need to fall back to the default if they are not provided
|
|
567
|
+
var socketURLHostname = (hostname || self.location.hostname || "localhost").replace(/^\[(.*)\]$/, "$1");
|
|
568
|
+
var socketURLPort = parsedURL.port;
|
|
569
|
+
if (!socketURLPort || socketURLPort === "0") {
|
|
570
|
+
socketURLPort = self.location.port;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// If path is provided it'll be passed in via the resourceQuery as a
|
|
574
|
+
// query param so it has to be parsed out of the querystring in order for the
|
|
575
|
+
// client to open the socket to the correct location.
|
|
576
|
+
var socketURLPathname = "/ws";
|
|
577
|
+
if (parsedURL.pathname && !parsedURL.fromCurrentScript) {
|
|
578
|
+
socketURLPathname = parsedURL.pathname;
|
|
579
|
+
}
|
|
580
|
+
return formatURL({
|
|
581
|
+
protocol: socketURLProtocol,
|
|
582
|
+
auth: socketURLAuth,
|
|
583
|
+
hostname: socketURLHostname,
|
|
584
|
+
port: socketURLPort,
|
|
585
|
+
pathname: socketURLPathname,
|
|
586
|
+
slashes: true
|
|
587
|
+
});
|
|
588
|
+
};
|
|
323
589
|
var socketURL = createSocketURL(parsedResourceQuery);
|
|
324
|
-
socket(socketURL, onSocketMessage, options.reconnect);
|
|
590
|
+
socket(socketURL, onSocketMessage, options.reconnect);
|
|
591
|
+
export { getCurrentScriptSource, parseURL, createSocketURL };
|
|
@@ -39,6 +39,15 @@ function SyncBailHook() {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
function _typeof(o) {
|
|
43
|
+
"@babel/helpers - typeof";
|
|
44
|
+
|
|
45
|
+
return _typeof = "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && "symbol" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).iterator ? function (o) {
|
|
46
|
+
return typeof o;
|
|
47
|
+
} : function (o) {
|
|
48
|
+
return o && "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o.constructor === (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o !== (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).prototype ? "symbol" : typeof o;
|
|
49
|
+
}, _typeof(o);
|
|
50
|
+
}
|
|
42
51
|
function _toConsumableArray(r) {
|
|
43
52
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
44
53
|
}
|
|
@@ -79,14 +88,14 @@ function _createClass(e, r, t) {
|
|
|
79
88
|
}
|
|
80
89
|
function _toPropertyKey(t) {
|
|
81
90
|
var i = _toPrimitive(t, "string");
|
|
82
|
-
return "symbol" ==
|
|
91
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
83
92
|
}
|
|
84
93
|
function _toPrimitive(t, r) {
|
|
85
|
-
if ("object" !=
|
|
94
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
86
95
|
var e = t[(typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).toPrimitive];
|
|
87
96
|
if (void 0 !== e) {
|
|
88
97
|
var i = e.call(t, r || "default");
|
|
89
|
-
if ("object" !=
|
|
98
|
+
if ("object" != _typeof(i)) return i;
|
|
90
99
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
91
100
|
}
|
|
92
101
|
return ("string" === r ? String : Number)(t);
|
|
@@ -134,7 +143,7 @@ var TIMERS_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { ret
|
|
|
134
143
|
var TIMERS_AGGREGATES_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })("webpack logger aggregated times");
|
|
135
144
|
var WebpackLogger = /*#__PURE__*/function () {
|
|
136
145
|
/**
|
|
137
|
-
* @param {function(LogTypeEnum,
|
|
146
|
+
* @param {function(LogTypeEnum, EXPECTED_ANY[]=): void} log log function
|
|
138
147
|
* @param {function(string | function(): string): WebpackLogger} getChildLogger function to create child logger
|
|
139
148
|
*/
|
|
140
149
|
function WebpackLogger(log, getChildLogger) {
|
|
@@ -144,7 +153,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
/**
|
|
147
|
-
* @param {...
|
|
156
|
+
* @param {...EXPECTED_ANY} args args
|
|
148
157
|
*/
|
|
149
158
|
return _createClass(WebpackLogger, [{
|
|
150
159
|
key: "error",
|
|
@@ -156,7 +165,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
/**
|
|
159
|
-
* @param {...
|
|
168
|
+
* @param {...EXPECTED_ANY} args args
|
|
160
169
|
*/
|
|
161
170
|
}, {
|
|
162
171
|
key: "warn",
|
|
@@ -168,7 +177,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
168
177
|
}
|
|
169
178
|
|
|
170
179
|
/**
|
|
171
|
-
* @param {...
|
|
180
|
+
* @param {...EXPECTED_ANY} args args
|
|
172
181
|
*/
|
|
173
182
|
}, {
|
|
174
183
|
key: "info",
|
|
@@ -180,7 +189,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
/**
|
|
183
|
-
* @param {...
|
|
192
|
+
* @param {...EXPECTED_ANY} args args
|
|
184
193
|
*/
|
|
185
194
|
}, {
|
|
186
195
|
key: "log",
|
|
@@ -192,7 +201,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
/**
|
|
195
|
-
* @param {...
|
|
204
|
+
* @param {...EXPECTED_ANY} args args
|
|
196
205
|
*/
|
|
197
206
|
}, {
|
|
198
207
|
key: "debug",
|
|
@@ -204,8 +213,8 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
204
213
|
}
|
|
205
214
|
|
|
206
215
|
/**
|
|
207
|
-
* @param {
|
|
208
|
-
* @param {...
|
|
216
|
+
* @param {EXPECTED_ANY} assertion assertion
|
|
217
|
+
* @param {...EXPECTED_ANY} args args
|
|
209
218
|
*/
|
|
210
219
|
}, {
|
|
211
220
|
key: "assert",
|
|
@@ -229,7 +238,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
/**
|
|
232
|
-
* @param {...
|
|
241
|
+
* @param {...EXPECTED_ANY} args args
|
|
233
242
|
*/
|
|
234
243
|
}, {
|
|
235
244
|
key: "status",
|
|
@@ -241,7 +250,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
/**
|
|
244
|
-
* @param {...
|
|
253
|
+
* @param {...EXPECTED_ANY} args args
|
|
245
254
|
*/
|
|
246
255
|
}, {
|
|
247
256
|
key: "group",
|
|
@@ -253,7 +262,7 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
253
262
|
}
|
|
254
263
|
|
|
255
264
|
/**
|
|
256
|
-
* @param {...
|
|
265
|
+
* @param {...EXPECTED_ANY} args args
|
|
257
266
|
*/
|
|
258
267
|
}, {
|
|
259
268
|
key: "groupCollapsed",
|
|
@@ -447,6 +456,15 @@ function _arrayLikeToArray(r, a) {
|
|
|
447
456
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
448
457
|
return n;
|
|
449
458
|
}
|
|
459
|
+
function _typeof(o) {
|
|
460
|
+
"@babel/helpers - typeof";
|
|
461
|
+
|
|
462
|
+
return _typeof = "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && "symbol" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).iterator ? function (o) {
|
|
463
|
+
return typeof o;
|
|
464
|
+
} : function (o) {
|
|
465
|
+
return o && "function" == typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o.constructor === (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) && o !== (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).prototype ? "symbol" : typeof o;
|
|
466
|
+
}, _typeof(o);
|
|
467
|
+
}
|
|
450
468
|
var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/logging/Logger.js"),
|
|
451
469
|
LogType = _require.LogType;
|
|
452
470
|
|
|
@@ -455,24 +473,24 @@ var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/l
|
|
|
455
473
|
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
|
|
456
474
|
|
|
457
475
|
/** @typedef {function(string): boolean} FilterFunction */
|
|
458
|
-
/** @typedef {function(string, LogTypeEnum,
|
|
476
|
+
/** @typedef {function(string, LogTypeEnum, EXPECTED_ANY[]=): void} LoggingFunction */
|
|
459
477
|
|
|
460
478
|
/**
|
|
461
479
|
* @typedef {object} LoggerConsole
|
|
462
480
|
* @property {function(): void} clear
|
|
463
481
|
* @property {function(): void} trace
|
|
464
|
-
* @property {(...args:
|
|
465
|
-
* @property {(...args:
|
|
466
|
-
* @property {(...args:
|
|
467
|
-
* @property {(...args:
|
|
468
|
-
* @property {(...args:
|
|
469
|
-
* @property {(...args:
|
|
470
|
-
* @property {(...args:
|
|
471
|
-
* @property {(...args:
|
|
472
|
-
* @property {(...args:
|
|
473
|
-
* @property {(...args:
|
|
474
|
-
* @property {(...args:
|
|
475
|
-
* @property {(...args:
|
|
482
|
+
* @property {(...args: EXPECTED_ANY[]) => void} info
|
|
483
|
+
* @property {(...args: EXPECTED_ANY[]) => void} log
|
|
484
|
+
* @property {(...args: EXPECTED_ANY[]) => void} warn
|
|
485
|
+
* @property {(...args: EXPECTED_ANY[]) => void} error
|
|
486
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} debug
|
|
487
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} group
|
|
488
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} groupCollapsed
|
|
489
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} groupEnd
|
|
490
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} status
|
|
491
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} profile
|
|
492
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} profileEnd
|
|
493
|
+
* @property {(...args: EXPECTED_ANY[]) => void=} logTime
|
|
476
494
|
*/
|
|
477
495
|
|
|
478
496
|
/**
|
|
@@ -493,7 +511,7 @@ var filterToFunction = function filterToFunction(item) {
|
|
|
493
511
|
return regExp.test(ident);
|
|
494
512
|
};
|
|
495
513
|
}
|
|
496
|
-
if (item &&
|
|
514
|
+
if (item && _typeof(item) === "object" && typeof item.test === "function") {
|
|
497
515
|
return function (ident) {
|
|
498
516
|
return item.test(ident);
|
|
499
517
|
};
|
|
@@ -543,7 +561,7 @@ module.exports = function (_ref) {
|
|
|
543
561
|
/**
|
|
544
562
|
* @param {string} name name of the logger
|
|
545
563
|
* @param {LogTypeEnum} type type of the log entry
|
|
546
|
-
* @param {
|
|
564
|
+
* @param {EXPECTED_ANY[]=} args arguments of the log entry
|
|
547
565
|
* @returns {void}
|
|
548
566
|
*/
|
|
549
567
|
var logger = function logger(name, type, args) {
|
|
@@ -788,6 +806,8 @@ module.exports.hooks = {
|
|
|
788
806
|
/******/
|
|
789
807
|
/************************************************************************/
|
|
790
808
|
var __webpack_exports__ = {};
|
|
809
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
810
|
+
!function() {
|
|
791
811
|
/*!********************************************!*\
|
|
792
812
|
!*** ./client-src/modules/logger/index.js ***!
|
|
793
813
|
\********************************************/
|
|
@@ -797,8 +817,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
797
817
|
/* harmony export */ });
|
|
798
818
|
/* harmony import */ var webpack_lib_logging_runtime_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! webpack/lib/logging/runtime.js */ "./node_modules/webpack/lib/logging/runtime.js");
|
|
799
819
|
|
|
820
|
+
}();
|
|
800
821
|
var __webpack_export_target__ = exports;
|
|
801
|
-
for(var
|
|
822
|
+
for(var __webpack_i__ in __webpack_exports__) __webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
802
823
|
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
803
824
|
/******/ })()
|
|
804
825
|
;
|