webpack-dev-server 5.0.4 → 5.2.0

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/overlay.js CHANGED
@@ -1,16 +1,357 @@
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
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
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
6
  // The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
7
7
  // They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
8
8
 
9
9
  import ansiHTML from "ansi-html-community";
10
- import { encode } from "html-entities";
11
- import { listenToRuntimeError, listenToUnhandledRejection, parseErrorToStacks } from "./overlay/runtime-error.js";
12
- import createOverlayMachine from "./overlay/state-machine.js";
13
- import { containerStyle, dismissButtonStyle, headerStyle, iframeStyle, msgStyles, msgTextStyle, msgTypeStyle } from "./overlay/styles.js";
10
+
11
+ /**
12
+ * @type {(input: string, position: number) => string}
13
+ */
14
+ var getCodePoint = String.prototype.codePointAt ? function (input, position) {
15
+ return input.codePointAt(position);
16
+ } : function (input, position) {
17
+ return (input.charCodeAt(position) - 0xd800) * 0x400 + input.charCodeAt(position + 1) - 0xdc00 + 0x10000;
18
+ };
19
+
20
+ /**
21
+ * @param {string} macroText
22
+ * @param {RegExp} macroRegExp
23
+ * @param {(input: string) => string} macroReplacer
24
+ * @returns {string}
25
+ */
26
+ var replaceUsingRegExp = function replaceUsingRegExp(macroText, macroRegExp, macroReplacer) {
27
+ macroRegExp.lastIndex = 0;
28
+ var replaceMatch = macroRegExp.exec(macroText);
29
+ var replaceResult;
30
+ if (replaceMatch) {
31
+ replaceResult = "";
32
+ var replaceLastIndex = 0;
33
+ do {
34
+ if (replaceLastIndex !== replaceMatch.index) {
35
+ replaceResult += macroText.substring(replaceLastIndex, replaceMatch.index);
36
+ }
37
+ var replaceInput = replaceMatch[0];
38
+ replaceResult += macroReplacer(replaceInput);
39
+ replaceLastIndex = replaceMatch.index + replaceInput.length;
40
+ // eslint-disable-next-line no-cond-assign
41
+ } while (replaceMatch = macroRegExp.exec(macroText));
42
+ if (replaceLastIndex !== macroText.length) {
43
+ replaceResult += macroText.substring(replaceLastIndex);
44
+ }
45
+ } else {
46
+ replaceResult = macroText;
47
+ }
48
+ return replaceResult;
49
+ };
50
+ var references = {
51
+ "<": "&lt;",
52
+ ">": "&gt;",
53
+ '"': "&quot;",
54
+ "'": "&apos;",
55
+ "&": "&amp;"
56
+ };
57
+
58
+ /**
59
+ * @param {string} text text
60
+ * @returns {string}
61
+ */
62
+ function encode(text) {
63
+ if (!text) {
64
+ return "";
65
+ }
66
+ return replaceUsingRegExp(text, /[<>'"&]/g, function (input) {
67
+ var result = references[input];
68
+ if (!result) {
69
+ var code = input.length > 1 ? getCodePoint(input, 0) : input.charCodeAt(0);
70
+ result = "&#".concat(code, ";");
71
+ }
72
+ return result;
73
+ });
74
+ }
75
+
76
+ /**
77
+ * @typedef {Object} StateDefinitions
78
+ * @property {{[event: string]: { target: string; actions?: Array<string> }}} [on]
79
+ */
80
+
81
+ /**
82
+ * @typedef {Object} Options
83
+ * @property {{[state: string]: StateDefinitions}} states
84
+ * @property {object} context;
85
+ * @property {string} initial
86
+ */
87
+
88
+ /**
89
+ * @typedef {Object} Implementation
90
+ * @property {{[actionName: string]: (ctx: object, event: any) => object}} actions
91
+ */
92
+
93
+ /**
94
+ * A simplified `createMachine` from `@xstate/fsm` with the following differences:
95
+ *
96
+ * - the returned machine is technically a "service". No `interpret(machine).start()` is needed.
97
+ * - the state definition only support `on` and target must be declared with { target: 'nextState', actions: [] } explicitly.
98
+ * - event passed to `send` must be an object with `type` property.
99
+ * - actions implementation will be [assign action](https://xstate.js.org/docs/guides/context.html#assign-action) if you return any value.
100
+ * Do not return anything if you just want to invoke side effect.
101
+ *
102
+ * The goal of this custom function is to avoid installing the entire `'xstate/fsm'` package, while enabling modeling using
103
+ * state machine. You can copy the first parameter into the editor at https://stately.ai/viz to visualize the state machine.
104
+ *
105
+ * @param {Options} options
106
+ * @param {Implementation} implementation
107
+ */
108
+ function createMachine(_ref, _ref2) {
109
+ var states = _ref.states,
110
+ context = _ref.context,
111
+ initial = _ref.initial;
112
+ var actions = _ref2.actions;
113
+ var currentState = initial;
114
+ var currentContext = context;
115
+ return {
116
+ send: function send(event) {
117
+ var currentStateOn = states[currentState].on;
118
+ var transitionConfig = currentStateOn && currentStateOn[event.type];
119
+ if (transitionConfig) {
120
+ currentState = transitionConfig.target;
121
+ if (transitionConfig.actions) {
122
+ transitionConfig.actions.forEach(function (actName) {
123
+ var actionImpl = actions[actName];
124
+ var nextContextValue = actionImpl && actionImpl(currentContext, event);
125
+ if (nextContextValue) {
126
+ currentContext = _objectSpread(_objectSpread({}, currentContext), nextContextValue);
127
+ }
128
+ });
129
+ }
130
+ }
131
+ }
132
+ };
133
+ }
134
+
135
+ /**
136
+ * @typedef {Object} ShowOverlayData
137
+ * @property {'warning' | 'error'} level
138
+ * @property {Array<string | { moduleIdentifier?: string, moduleName?: string, loc?: string, message?: string }>} messages
139
+ * @property {'build' | 'runtime'} messageSource
140
+ */
141
+
142
+ /**
143
+ * @typedef {Object} CreateOverlayMachineOptions
144
+ * @property {(data: ShowOverlayData) => void} showOverlay
145
+ * @property {() => void} hideOverlay
146
+ */
147
+
148
+ /**
149
+ * @param {CreateOverlayMachineOptions} options
150
+ */
151
+ var createOverlayMachine = function createOverlayMachine(options) {
152
+ var hideOverlay = options.hideOverlay,
153
+ showOverlay = options.showOverlay;
154
+ return createMachine({
155
+ initial: "hidden",
156
+ context: {
157
+ level: "error",
158
+ messages: [],
159
+ messageSource: "build"
160
+ },
161
+ states: {
162
+ hidden: {
163
+ on: {
164
+ BUILD_ERROR: {
165
+ target: "displayBuildError",
166
+ actions: ["setMessages", "showOverlay"]
167
+ },
168
+ RUNTIME_ERROR: {
169
+ target: "displayRuntimeError",
170
+ actions: ["setMessages", "showOverlay"]
171
+ }
172
+ }
173
+ },
174
+ displayBuildError: {
175
+ on: {
176
+ DISMISS: {
177
+ target: "hidden",
178
+ actions: ["dismissMessages", "hideOverlay"]
179
+ },
180
+ BUILD_ERROR: {
181
+ target: "displayBuildError",
182
+ actions: ["appendMessages", "showOverlay"]
183
+ }
184
+ }
185
+ },
186
+ displayRuntimeError: {
187
+ on: {
188
+ DISMISS: {
189
+ target: "hidden",
190
+ actions: ["dismissMessages", "hideOverlay"]
191
+ },
192
+ RUNTIME_ERROR: {
193
+ target: "displayRuntimeError",
194
+ actions: ["appendMessages", "showOverlay"]
195
+ },
196
+ BUILD_ERROR: {
197
+ target: "displayBuildError",
198
+ actions: ["setMessages", "showOverlay"]
199
+ }
200
+ }
201
+ }
202
+ }
203
+ }, {
204
+ actions: {
205
+ dismissMessages: function dismissMessages() {
206
+ return {
207
+ messages: [],
208
+ level: "error",
209
+ messageSource: "build"
210
+ };
211
+ },
212
+ appendMessages: function appendMessages(context, event) {
213
+ return {
214
+ messages: context.messages.concat(event.messages),
215
+ level: event.level || context.level,
216
+ messageSource: event.type === "RUNTIME_ERROR" ? "runtime" : "build"
217
+ };
218
+ },
219
+ setMessages: function setMessages(context, event) {
220
+ return {
221
+ messages: event.messages,
222
+ level: event.level || context.level,
223
+ messageSource: event.type === "RUNTIME_ERROR" ? "runtime" : "build"
224
+ };
225
+ },
226
+ hideOverlay: hideOverlay,
227
+ showOverlay: showOverlay
228
+ }
229
+ });
230
+ };
231
+
232
+ /**
233
+ *
234
+ * @param {Error} error
235
+ */
236
+ var parseErrorToStacks = function parseErrorToStacks(error) {
237
+ if (!error || !(error instanceof Error)) {
238
+ throw new Error("parseErrorToStacks expects Error object");
239
+ }
240
+ if (typeof error.stack === "string") {
241
+ return error.stack.split("\n").filter(function (stack) {
242
+ return stack !== "Error: ".concat(error.message);
243
+ });
244
+ }
245
+ };
246
+
247
+ /**
248
+ * @callback ErrorCallback
249
+ * @param {ErrorEvent} error
250
+ * @returns {void}
251
+ */
252
+
253
+ /**
254
+ * @param {ErrorCallback} callback
255
+ */
256
+ var listenToRuntimeError = function listenToRuntimeError(callback) {
257
+ window.addEventListener("error", callback);
258
+ return function cleanup() {
259
+ window.removeEventListener("error", callback);
260
+ };
261
+ };
262
+
263
+ /**
264
+ * @callback UnhandledRejectionCallback
265
+ * @param {PromiseRejectionEvent} rejectionEvent
266
+ * @returns {void}
267
+ */
268
+
269
+ /**
270
+ * @param {UnhandledRejectionCallback} callback
271
+ */
272
+ var listenToUnhandledRejection = function listenToUnhandledRejection(callback) {
273
+ window.addEventListener("unhandledrejection", callback);
274
+ return function cleanup() {
275
+ window.removeEventListener("unhandledrejection", callback);
276
+ };
277
+ };
278
+
279
+ // Styles are inspired by `react-error-overlay`
280
+
281
+ var msgStyles = {
282
+ error: {
283
+ backgroundColor: "rgba(206, 17, 38, 0.1)",
284
+ color: "#fccfcf"
285
+ },
286
+ warning: {
287
+ backgroundColor: "rgba(251, 245, 180, 0.1)",
288
+ color: "#fbf5b4"
289
+ }
290
+ };
291
+ var iframeStyle = {
292
+ position: "fixed",
293
+ top: 0,
294
+ left: 0,
295
+ right: 0,
296
+ bottom: 0,
297
+ width: "100vw",
298
+ height: "100vh",
299
+ border: "none",
300
+ "z-index": 9999999999
301
+ };
302
+ var containerStyle = {
303
+ position: "fixed",
304
+ boxSizing: "border-box",
305
+ left: 0,
306
+ top: 0,
307
+ right: 0,
308
+ bottom: 0,
309
+ width: "100vw",
310
+ height: "100vh",
311
+ fontSize: "large",
312
+ padding: "2rem 2rem 4rem 2rem",
313
+ lineHeight: "1.2",
314
+ whiteSpace: "pre-wrap",
315
+ overflow: "auto",
316
+ backgroundColor: "rgba(0, 0, 0, 0.9)",
317
+ color: "white"
318
+ };
319
+ var headerStyle = {
320
+ color: "#e83b46",
321
+ fontSize: "2em",
322
+ whiteSpace: "pre-wrap",
323
+ fontFamily: "sans-serif",
324
+ margin: "0 2rem 2rem 0",
325
+ flex: "0 0 auto",
326
+ maxHeight: "50%",
327
+ overflow: "auto"
328
+ };
329
+ var dismissButtonStyle = {
330
+ color: "#ffffff",
331
+ lineHeight: "1rem",
332
+ fontSize: "1.5rem",
333
+ padding: "1rem",
334
+ cursor: "pointer",
335
+ position: "absolute",
336
+ right: 0,
337
+ top: 0,
338
+ backgroundColor: "transparent",
339
+ border: "none"
340
+ };
341
+ var msgTypeStyle = {
342
+ color: "#e83b46",
343
+ fontSize: "1.2em",
344
+ marginBottom: "1rem",
345
+ fontFamily: "sans-serif"
346
+ };
347
+ var msgTextStyle = {
348
+ lineHeight: "1.5",
349
+ fontSize: "1rem",
350
+ fontFamily: "Menlo, Consolas, monospace"
351
+ };
352
+
353
+ // ANSI HTML
354
+
14
355
  var colors = {
15
356
  reset: ["transparent", "transparent"],
16
357
  black: "181818",
@@ -30,7 +371,7 @@ ansiHTML.setColors(colors);
30
371
  * @param {string | { file?: string, moduleName?: string, loc?: string, message?: string; stack?: string[] }} item
31
372
  * @returns {{ header: string, body: string }}
32
373
  */
33
- function formatProblem(type, item) {
374
+ var formatProblem = function formatProblem(type, item) {
34
375
  var header = type === "warning" ? "WARNING" : "ERROR";
35
376
  var body = "";
36
377
  if (typeof item === "string") {
@@ -54,7 +395,7 @@ function formatProblem(type, item) {
54
395
  header: header,
55
396
  body: body
56
397
  };
57
- }
398
+ };
58
399
 
59
400
  /**
60
401
  * @typedef {Object} CreateOverlayOptions
@@ -107,10 +448,10 @@ var createOverlay = function createOverlay(options) {
107
448
  applyStyle(iframeContainerElement, iframeStyle);
108
449
  iframeContainerElement.onload = function () {
109
450
  var contentElement = /** @type {Document} */
110
- ( /** @type {HTMLIFrameElement} */
451
+ (/** @type {HTMLIFrameElement} */
111
452
  iframeContainerElement.contentDocument).createElement("div");
112
453
  containerElement = /** @type {Document} */
113
- ( /** @type {HTMLIFrameElement} */
454
+ (/** @type {HTMLIFrameElement} */
114
455
  iframeContainerElement.contentDocument).createElement("div");
115
456
  contentElement.id = "webpack-dev-server-client-overlay-div";
116
457
  applyStyle(contentElement, containerStyle);
@@ -132,10 +473,10 @@ var createOverlay = function createOverlay(options) {
132
473
  contentElement.appendChild(containerElement);
133
474
 
134
475
  /** @type {Document} */
135
- ( /** @type {HTMLIFrameElement} */
476
+ (/** @type {HTMLIFrameElement} */
136
477
  iframeContainerElement.contentDocument).body.appendChild(contentElement);
137
478
  onLoadQueue.forEach(function (onLoad) {
138
- onLoad( /** @type {HTMLDivElement} */contentElement);
479
+ onLoad(/** @type {HTMLDivElement} */contentElement);
139
480
  });
140
481
  onLoadQueue = [];
141
482
 
@@ -222,11 +563,11 @@ var createOverlay = function createOverlay(options) {
222
563
  }, trustedTypesPolicyName);
223
564
  }
224
565
  var overlayService = createOverlayMachine({
225
- showOverlay: function showOverlay(_ref) {
226
- var _ref$level = _ref.level,
227
- level = _ref$level === void 0 ? "error" : _ref$level,
228
- messages = _ref.messages,
229
- messageSource = _ref.messageSource;
566
+ showOverlay: function showOverlay(_ref3) {
567
+ var _ref3$level = _ref3.level,
568
+ level = _ref3$level === void 0 ? "error" : _ref3$level,
569
+ messages = _ref3.messages,
570
+ messageSource = _ref3.messageSource;
230
571
  return show(level, messages, options.trustedTypesPolicyName, messageSource);
231
572
  },
232
573
  hideOverlay: hide
@@ -0,0 +1,124 @@
1
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2
+ 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
+ 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" == 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 _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
+ 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); }
8
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
9
+ 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); }
10
+ 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); }
11
+ 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; }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
14
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
16
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
17
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
18
+ 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"); }
19
+ export function isProgressSupported() {
20
+ return "customElements" in self && !!HTMLElement.prototype.attachShadow;
21
+ }
22
+ export function defineProgressElement() {
23
+ var _WebpackDevServerProgress;
24
+ if (customElements.get("wds-progress")) {
25
+ return;
26
+ }
27
+ var _WebpackDevServerProgress_brand = /*#__PURE__*/new WeakSet();
28
+ var WebpackDevServerProgress = /*#__PURE__*/function (_HTMLElement) {
29
+ function WebpackDevServerProgress() {
30
+ var _this;
31
+ _classCallCheck(this, WebpackDevServerProgress);
32
+ _this = _callSuper(this, WebpackDevServerProgress);
33
+ _classPrivateMethodInitSpec(_this, _WebpackDevServerProgress_brand);
34
+ _this.attachShadow({
35
+ mode: "open"
36
+ });
37
+ _this.maxDashOffset = -219.99078369140625;
38
+ _this.animationTimer = null;
39
+ return _this;
40
+ }
41
+ _inherits(WebpackDevServerProgress, _HTMLElement);
42
+ return _createClass(WebpackDevServerProgress, [{
43
+ key: "connectedCallback",
44
+ value: function connectedCallback() {
45
+ _assertClassBrand(_WebpackDevServerProgress_brand, this, _reset).call(this);
46
+ }
47
+ }, {
48
+ key: "attributeChangedCallback",
49
+ value: function attributeChangedCallback(name, oldValue, newValue) {
50
+ if (name === "progress") {
51
+ _assertClassBrand(_WebpackDevServerProgress_brand, this, _update).call(this, Number(newValue));
52
+ } else if (name === "type") {
53
+ _assertClassBrand(_WebpackDevServerProgress_brand, this, _reset).call(this);
54
+ }
55
+ }
56
+ }], [{
57
+ key: "observedAttributes",
58
+ get: function get() {
59
+ return ["progress", "type"];
60
+ }
61
+ }]);
62
+ }(/*#__PURE__*/_wrapNativeSuper(HTMLElement));
63
+ _WebpackDevServerProgress = WebpackDevServerProgress;
64
+ function _reset() {
65
+ var _this$getAttribute, _Number;
66
+ clearTimeout(this.animationTimer);
67
+ this.animationTimer = null;
68
+ var typeAttr = (_this$getAttribute = this.getAttribute("type")) === null || _this$getAttribute === void 0 ? void 0 : _this$getAttribute.toLowerCase();
69
+ this.type = typeAttr === "circular" ? "circular" : "linear";
70
+ var innerHTML = this.type === "circular" ? _circularTemplate.call(_WebpackDevServerProgress) : _linearTemplate.call(_WebpackDevServerProgress);
71
+ this.shadowRoot.innerHTML = innerHTML;
72
+ this.initialProgress = (_Number = Number(this.getAttribute("progress"))) !== null && _Number !== void 0 ? _Number : 0;
73
+ _assertClassBrand(_WebpackDevServerProgress_brand, this, _update).call(this, this.initialProgress);
74
+ }
75
+ function _circularTemplate() {
76
+ 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 ";
77
+ }
78
+ function _linearTemplate() {
79
+ 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 ";
80
+ }
81
+ function _update(percent) {
82
+ var element = this.shadowRoot.querySelector("#progress");
83
+ if (this.type === "circular") {
84
+ var path = this.shadowRoot.querySelector("path");
85
+ var value = this.shadowRoot.querySelector("#percent-value");
86
+ var offset = (100 - percent) / 100 * this.maxDashOffset;
87
+ path.style.strokeDashoffset = offset;
88
+ value.textContent = percent;
89
+ } else {
90
+ element.style.width = "".concat(percent, "%");
91
+ }
92
+ if (percent >= 100) {
93
+ _assertClassBrand(_WebpackDevServerProgress_brand, this, _hide).call(this);
94
+ } else if (percent > 0) {
95
+ _assertClassBrand(_WebpackDevServerProgress_brand, this, _show).call(this);
96
+ }
97
+ }
98
+ function _show() {
99
+ var element = this.shadowRoot.querySelector("#progress");
100
+ element.classList.remove("hidden");
101
+ }
102
+ function _hide() {
103
+ var _this2 = this;
104
+ var element = this.shadowRoot.querySelector("#progress");
105
+ if (this.type === "circular") {
106
+ element.classList.add("disappear");
107
+ element.addEventListener("animationend", function () {
108
+ element.classList.add("hidden");
109
+ _assertClassBrand(_WebpackDevServerProgress_brand, _this2, _update).call(_this2, 0);
110
+ }, {
111
+ once: true
112
+ });
113
+ } else if (this.type === "linear") {
114
+ element.classList.add("disappear");
115
+ this.animationTimer = setTimeout(function () {
116
+ element.classList.remove("disappear");
117
+ element.classList.add("hidden");
118
+ element.style.width = "0%";
119
+ _this2.animationTimer = null;
120
+ }, 800);
121
+ }
122
+ }
123
+ customElements.define("wds-progress", WebpackDevServerProgress);
124
+ }
@@ -16,20 +16,4 @@ function setLogLevel(level) {
16
16
  }
17
17
  setLogLevel(defaultLevel);
18
18
  var log = logger.getLogger(name);
19
- var logEnabledFeatures = function logEnabledFeatures(features) {
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 };