webpack-dev-server 5.0.2 → 5.2.2
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 +1 -1
- package/client/clients/SockJSClient.js +7 -7
- package/client/clients/WebSocketClient.js +7 -7
- package/client/index.js +303 -23
- package/client/modules/logger/index.js +240 -133
- package/client/modules/sockjs-client/index.js +18 -12
- package/client/overlay.js +365 -18
- package/client/progress.js +125 -0
- package/client/socket.js +5 -1
- package/client/utils/log.js +1 -17
- package/lib/Server.js +831 -479
- package/lib/options.json +23 -5
- package/package.json +37 -36
- package/types/bin/cli-flags.d.ts +15 -0
- package/types/lib/Server.d.ts +216 -339
- package/types/lib/servers/WebsocketServer.d.ts +0 -1
- 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
|
@@ -0,0 +1,125 @@
|
|
|
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); }
|
|
2
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
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); } }
|
|
4
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
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); }
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
9
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
10
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
11
|
+
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
12
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
13
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
15
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
16
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
17
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
18
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
19
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
20
|
+
export function isProgressSupported() {
|
|
21
|
+
return "customElements" in self && !!HTMLElement.prototype.attachShadow;
|
|
22
|
+
}
|
|
23
|
+
export function defineProgressElement() {
|
|
24
|
+
var _WebpackDevServerProgress;
|
|
25
|
+
if (customElements.get("wds-progress")) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
var _WebpackDevServerProgress_brand = /*#__PURE__*/new WeakSet();
|
|
29
|
+
var WebpackDevServerProgress = /*#__PURE__*/function (_HTMLElement) {
|
|
30
|
+
function WebpackDevServerProgress() {
|
|
31
|
+
var _this;
|
|
32
|
+
_classCallCheck(this, WebpackDevServerProgress);
|
|
33
|
+
_this = _callSuper(this, WebpackDevServerProgress);
|
|
34
|
+
_classPrivateMethodInitSpec(_this, _WebpackDevServerProgress_brand);
|
|
35
|
+
_this.attachShadow({
|
|
36
|
+
mode: "open"
|
|
37
|
+
});
|
|
38
|
+
_this.maxDashOffset = -219.99078369140625;
|
|
39
|
+
_this.animationTimer = null;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_inherits(WebpackDevServerProgress, _HTMLElement);
|
|
43
|
+
return _createClass(WebpackDevServerProgress, [{
|
|
44
|
+
key: "connectedCallback",
|
|
45
|
+
value: function connectedCallback() {
|
|
46
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, this, _reset).call(this);
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "attributeChangedCallback",
|
|
50
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
51
|
+
if (name === "progress") {
|
|
52
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, this, _update).call(this, Number(newValue));
|
|
53
|
+
} else if (name === "type") {
|
|
54
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, this, _reset).call(this);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}], [{
|
|
58
|
+
key: "observedAttributes",
|
|
59
|
+
get: function get() {
|
|
60
|
+
return ["progress", "type"];
|
|
61
|
+
}
|
|
62
|
+
}]);
|
|
63
|
+
}(/*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
|
64
|
+
_WebpackDevServerProgress = WebpackDevServerProgress;
|
|
65
|
+
function _reset() {
|
|
66
|
+
var _this$getAttribute, _Number;
|
|
67
|
+
clearTimeout(this.animationTimer);
|
|
68
|
+
this.animationTimer = null;
|
|
69
|
+
var typeAttr = (_this$getAttribute = this.getAttribute("type")) === null || _this$getAttribute === void 0 ? void 0 : _this$getAttribute.toLowerCase();
|
|
70
|
+
this.type = typeAttr === "circular" ? "circular" : "linear";
|
|
71
|
+
var innerHTML = this.type === "circular" ? _circularTemplate.call(_WebpackDevServerProgress) : _linearTemplate.call(_WebpackDevServerProgress);
|
|
72
|
+
this.shadowRoot.innerHTML = innerHTML;
|
|
73
|
+
this.initialProgress = (_Number = Number(this.getAttribute("progress"))) !== null && _Number !== void 0 ? _Number : 0;
|
|
74
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, this, _update).call(this, this.initialProgress);
|
|
75
|
+
}
|
|
76
|
+
function _circularTemplate() {
|
|
77
|
+
return "\n <style>\n :host {\n width: 200px;\n height: 200px;\n position: fixed;\n right: 5%;\n top: 5%;\n transition: opacity .25s ease-in-out;\n z-index: 2147483645;\n }\n\n circle {\n fill: #282d35;\n }\n\n path {\n fill: rgba(0, 0, 0, 0);\n stroke: rgb(186, 223, 172);\n stroke-dasharray: 219.99078369140625;\n stroke-dashoffset: -219.99078369140625;\n stroke-width: 10;\n transform: rotate(90deg) translate(0px, -80px);\n }\n\n text {\n font-family: 'Open Sans', sans-serif;\n font-size: 18px;\n fill: #ffffff;\n dominant-baseline: middle;\n text-anchor: middle;\n }\n\n tspan#percent-super {\n fill: #bdc3c7;\n font-size: 0.45em;\n baseline-shift: 10%;\n }\n\n @keyframes fade {\n 0% { opacity: 1; transform: scale(1); }\n 100% { opacity: 0; transform: scale(0); }\n }\n\n .disappear {\n animation: fade 0.3s;\n animation-fill-mode: forwards;\n animation-delay: 0.5s;\n }\n\n .hidden {\n display: none;\n }\n </style>\n <svg id=\"progress\" class=\"hidden noselect\" viewBox=\"0 0 80 80\">\n <circle cx=\"50%\" cy=\"50%\" r=\"35\"></circle>\n <path d=\"M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0\"></path>\n <text x=\"50%\" y=\"51%\">\n <tspan id=\"percent-value\">0</tspan>\n <tspan id=\"percent-super\">%</tspan>\n </text>\n </svg>\n ";
|
|
78
|
+
}
|
|
79
|
+
function _linearTemplate() {
|
|
80
|
+
return "\n <style>\n :host {\n position: fixed;\n top: 0;\n left: 0;\n height: 4px;\n width: 100vw;\n z-index: 2147483645;\n }\n\n #bar {\n width: 0%;\n height: 4px;\n background-color: rgb(186, 223, 172);\n }\n\n @keyframes fade {\n 0% { opacity: 1; }\n 100% { opacity: 0; }\n }\n\n .disappear {\n animation: fade 0.3s;\n animation-fill-mode: forwards;\n animation-delay: 0.5s;\n }\n\n .hidden {\n display: none;\n }\n </style>\n <div id=\"progress\"></div>\n ";
|
|
81
|
+
}
|
|
82
|
+
function _update(percent) {
|
|
83
|
+
var element = this.shadowRoot.querySelector("#progress");
|
|
84
|
+
if (this.type === "circular") {
|
|
85
|
+
var path = this.shadowRoot.querySelector("path");
|
|
86
|
+
var value = this.shadowRoot.querySelector("#percent-value");
|
|
87
|
+
var offset = (100 - percent) / 100 * this.maxDashOffset;
|
|
88
|
+
path.style.strokeDashoffset = offset;
|
|
89
|
+
value.textContent = percent;
|
|
90
|
+
} else {
|
|
91
|
+
element.style.width = "".concat(percent, "%");
|
|
92
|
+
}
|
|
93
|
+
if (percent >= 100) {
|
|
94
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, this, _hide).call(this);
|
|
95
|
+
} else if (percent > 0) {
|
|
96
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, this, _show).call(this);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function _show() {
|
|
100
|
+
var element = this.shadowRoot.querySelector("#progress");
|
|
101
|
+
element.classList.remove("hidden");
|
|
102
|
+
}
|
|
103
|
+
function _hide() {
|
|
104
|
+
var _this2 = this;
|
|
105
|
+
var element = this.shadowRoot.querySelector("#progress");
|
|
106
|
+
if (this.type === "circular") {
|
|
107
|
+
element.classList.add("disappear");
|
|
108
|
+
element.addEventListener("animationend", function () {
|
|
109
|
+
element.classList.add("hidden");
|
|
110
|
+
_assertClassBrand(_WebpackDevServerProgress_brand, _this2, _update).call(_this2, 0);
|
|
111
|
+
}, {
|
|
112
|
+
once: true
|
|
113
|
+
});
|
|
114
|
+
} else if (this.type === "linear") {
|
|
115
|
+
element.classList.add("disappear");
|
|
116
|
+
this.animationTimer = setTimeout(function () {
|
|
117
|
+
element.classList.remove("disappear");
|
|
118
|
+
element.classList.add("hidden");
|
|
119
|
+
element.style.width = "0%";
|
|
120
|
+
_this2.animationTimer = null;
|
|
121
|
+
}, 800);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
customElements.define("wds-progress", WebpackDevServerProgress);
|
|
125
|
+
}
|
package/client/socket.js
CHANGED
|
@@ -17,6 +17,7 @@ var maxRetries = 10;
|
|
|
17
17
|
// It is mutable to enforce singleton
|
|
18
18
|
// eslint-disable-next-line import/no-mutable-exports
|
|
19
19
|
export var client = null;
|
|
20
|
+
var timeout;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @param {string} url
|
|
@@ -27,6 +28,9 @@ var socket = function initSocket(url, handlers, reconnect) {
|
|
|
27
28
|
client = new Client(url);
|
|
28
29
|
client.onOpen(function () {
|
|
29
30
|
retries = 0;
|
|
31
|
+
if (timeout) {
|
|
32
|
+
clearTimeout(timeout);
|
|
33
|
+
}
|
|
30
34
|
if (typeof reconnect !== "undefined") {
|
|
31
35
|
maxRetries = reconnect;
|
|
32
36
|
}
|
|
@@ -47,7 +51,7 @@ var socket = function initSocket(url, handlers, reconnect) {
|
|
|
47
51
|
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
|
|
48
52
|
retries += 1;
|
|
49
53
|
log.info("Trying to reconnect...");
|
|
50
|
-
setTimeout(function () {
|
|
54
|
+
timeout = setTimeout(function () {
|
|
51
55
|
socket(url, handlers, reconnect);
|
|
52
56
|
}, retryInMs);
|
|
53
57
|
}
|
package/client/utils/log.js
CHANGED
|
@@ -16,20 +16,4 @@ function setLogLevel(level) {
|
|
|
16
16
|
}
|
|
17
17
|
setLogLevel(defaultLevel);
|
|
18
18
|
var log = logger.getLogger(name);
|
|
19
|
-
|
|
20
|
-
var enabledFeatures = Object.keys(features);
|
|
21
|
-
if (!features || enabledFeatures.length === 0) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
var logString = "Server started:";
|
|
25
|
-
|
|
26
|
-
// Server started: Hot Module Replacement enabled, Live Reloading enabled, Overlay disabled.
|
|
27
|
-
for (var i = 0; i < enabledFeatures.length; i++) {
|
|
28
|
-
var key = enabledFeatures[i];
|
|
29
|
-
logString += " ".concat(key, " ").concat(features[key] ? "enabled" : "disabled", ",");
|
|
30
|
-
}
|
|
31
|
-
// replace last comma with a period
|
|
32
|
-
logString = logString.slice(0, -1).concat(".");
|
|
33
|
-
log.info(logString);
|
|
34
|
-
};
|
|
35
|
-
export { log, logEnabledFeatures, setLogLevel };
|
|
19
|
+
export { log, setLogLevel };
|