webpack-dev-server 4.11.1 → 4.13.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/bin/cli-flags.js +17 -0
- package/bin/webpack-dev-server.js +12 -0
- package/client/clients/SockJSClient.js +7 -14
- package/client/clients/WebSocketClient.js +7 -14
- package/client/index.js +49 -71
- package/client/modules/logger/index.js +66 -165
- package/client/modules/sockjs-client/index.js +516 -1166
- package/client/overlay/fsm.js +64 -0
- package/client/overlay/runtime-error.js +31 -0
- package/client/overlay/state-machine.js +95 -0
- package/client/overlay/styles.js +74 -0
- package/client/overlay.js +202 -167
- package/client/socket.js +13 -12
- package/client/utils/createSocketURL.js +20 -36
- package/client/utils/getCurrentScriptSource.js +4 -6
- package/client/utils/log.js +8 -13
- package/client/utils/parseURL.js +3 -8
- package/client/utils/reloadApp.js +9 -18
- package/client/utils/sendMessage.js +1 -2
- package/client/utils/stripAnsi.js +1 -3
- package/lib/Server.js +56 -16
- package/lib/options.json +7 -0
- package/lib/servers/SockJSServer.js +22 -10
- package/package.json +15 -12
- package/types/bin/cli-flags.d.ts +12 -0
- package/types/lib/Server.d.ts +173 -196
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
/***/ (function(module) {
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Client stub for tapable SyncBailHook
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
module.exports = function clientTapableSyncBailHook() {
|
|
17
17
|
return {
|
|
18
18
|
call: function call() {}
|
|
@@ -33,14 +33,13 @@ module.exports = function clientTapableSyncBailHook() {
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
|
|
36
37
|
function _toConsumableArray(arr) {
|
|
37
38
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
38
39
|
}
|
|
39
|
-
|
|
40
40
|
function _nonIterableSpread() {
|
|
41
41
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
42
42
|
}
|
|
43
|
-
|
|
44
43
|
function _unsupportedIterableToArray(o, minLen) {
|
|
45
44
|
if (!o) return;
|
|
46
45
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -49,41 +48,31 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
49
48
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
50
49
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
51
50
|
}
|
|
52
|
-
|
|
53
51
|
function _iterableToArray(iter) {
|
|
54
52
|
if (typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) !== "undefined" && iter[(typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
function _arrayWithoutHoles(arr) {
|
|
58
55
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
function _arrayLikeToArray(arr, len) {
|
|
62
58
|
if (len == null || len > arr.length) len = arr.length;
|
|
63
|
-
|
|
64
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
65
|
-
arr2[i] = arr[i];
|
|
66
|
-
}
|
|
67
|
-
|
|
59
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
68
60
|
return arr2;
|
|
69
61
|
}
|
|
70
|
-
|
|
71
62
|
function _classCallCheck(instance, Constructor) {
|
|
72
63
|
if (!(instance instanceof Constructor)) {
|
|
73
64
|
throw new TypeError("Cannot call a class as a function");
|
|
74
65
|
}
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
function _defineProperties(target, props) {
|
|
78
68
|
for (var i = 0; i < props.length; i++) {
|
|
79
69
|
var descriptor = props[i];
|
|
80
70
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
81
71
|
descriptor.configurable = true;
|
|
82
72
|
if ("value" in descriptor) descriptor.writable = true;
|
|
83
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
73
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
84
74
|
}
|
|
85
75
|
}
|
|
86
|
-
|
|
87
76
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
88
77
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
89
78
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -92,72 +81,62 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
92
81
|
});
|
|
93
82
|
return Constructor;
|
|
94
83
|
}
|
|
95
|
-
|
|
84
|
+
function _toPropertyKey(arg) {
|
|
85
|
+
var key = _toPrimitive(arg, "string");
|
|
86
|
+
return typeof key === "symbol" ? key : String(key);
|
|
87
|
+
}
|
|
88
|
+
function _toPrimitive(input, hint) {
|
|
89
|
+
if (typeof input !== "object" || input === null) return input;
|
|
90
|
+
var prim = input[(typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).toPrimitive];
|
|
91
|
+
if (prim !== undefined) {
|
|
92
|
+
var res = prim.call(input, hint || "default");
|
|
93
|
+
if (typeof res !== "object") return res;
|
|
94
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
95
|
+
}
|
|
96
|
+
return (hint === "string" ? String : Number)(input);
|
|
97
|
+
}
|
|
96
98
|
var LogType = Object.freeze({
|
|
97
|
-
error:
|
|
98
|
-
/** @type {"error"} */
|
|
99
|
-
"error",
|
|
99
|
+
error: /** @type {"error"} */"error",
|
|
100
100
|
// message, c style arguments
|
|
101
|
-
warn:
|
|
102
|
-
/** @type {"warn"} */
|
|
103
|
-
"warn",
|
|
101
|
+
warn: /** @type {"warn"} */"warn",
|
|
104
102
|
// message, c style arguments
|
|
105
|
-
info:
|
|
106
|
-
/** @type {"info"} */
|
|
107
|
-
"info",
|
|
103
|
+
info: /** @type {"info"} */"info",
|
|
108
104
|
// message, c style arguments
|
|
109
|
-
log:
|
|
110
|
-
/** @type {"log"} */
|
|
111
|
-
"log",
|
|
105
|
+
log: /** @type {"log"} */"log",
|
|
112
106
|
// message, c style arguments
|
|
113
|
-
debug:
|
|
114
|
-
/** @type {"debug"} */
|
|
115
|
-
"debug",
|
|
107
|
+
debug: /** @type {"debug"} */"debug",
|
|
116
108
|
// message, c style arguments
|
|
117
|
-
|
|
118
|
-
/** @type {"trace"} */
|
|
119
|
-
"trace",
|
|
109
|
+
|
|
110
|
+
trace: /** @type {"trace"} */"trace",
|
|
120
111
|
// no arguments
|
|
121
|
-
|
|
122
|
-
/** @type {"group"} */
|
|
123
|
-
"group",
|
|
112
|
+
|
|
113
|
+
group: /** @type {"group"} */"group",
|
|
124
114
|
// [label]
|
|
125
|
-
groupCollapsed:
|
|
126
|
-
/** @type {"groupCollapsed"} */
|
|
127
|
-
"groupCollapsed",
|
|
115
|
+
groupCollapsed: /** @type {"groupCollapsed"} */"groupCollapsed",
|
|
128
116
|
// [label]
|
|
129
|
-
groupEnd:
|
|
130
|
-
/** @type {"groupEnd"} */
|
|
131
|
-
"groupEnd",
|
|
117
|
+
groupEnd: /** @type {"groupEnd"} */"groupEnd",
|
|
132
118
|
// [label]
|
|
133
|
-
|
|
134
|
-
/** @type {"profile"} */
|
|
135
|
-
"profile",
|
|
119
|
+
|
|
120
|
+
profile: /** @type {"profile"} */"profile",
|
|
136
121
|
// [profileName]
|
|
137
|
-
profileEnd:
|
|
138
|
-
/** @type {"profileEnd"} */
|
|
139
|
-
"profileEnd",
|
|
122
|
+
profileEnd: /** @type {"profileEnd"} */"profileEnd",
|
|
140
123
|
// [profileName]
|
|
141
|
-
|
|
142
|
-
/** @type {"time"} */
|
|
143
|
-
"time",
|
|
124
|
+
|
|
125
|
+
time: /** @type {"time"} */"time",
|
|
144
126
|
// name, time as [seconds, nanoseconds]
|
|
145
|
-
clear:
|
|
146
|
-
/** @type {"clear"} */
|
|
147
|
-
"clear",
|
|
148
|
-
// no arguments
|
|
149
|
-
status:
|
|
150
|
-
/** @type {"status"} */
|
|
151
|
-
"status" // message, arguments
|
|
152
127
|
|
|
128
|
+
clear: /** @type {"clear"} */"clear",
|
|
129
|
+
// no arguments
|
|
130
|
+
status: /** @type {"status"} */"status" // message, arguments
|
|
153
131
|
});
|
|
132
|
+
|
|
154
133
|
exports.LogType = LogType;
|
|
134
|
+
|
|
155
135
|
/** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */
|
|
156
136
|
|
|
157
137
|
var LOG_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })("webpack logger raw log method");
|
|
158
138
|
var TIMERS_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })("webpack logger times");
|
|
159
139
|
var TIMERS_AGGREGATES_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })("webpack logger aggregated times");
|
|
160
|
-
|
|
161
140
|
var WebpackLogger = /*#__PURE__*/function () {
|
|
162
141
|
/**
|
|
163
142
|
* @param {function(LogTypeEnum, any[]=): void} log log function
|
|
@@ -165,18 +144,15 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
165
144
|
*/
|
|
166
145
|
function WebpackLogger(log, getChildLogger) {
|
|
167
146
|
_classCallCheck(this, WebpackLogger);
|
|
168
|
-
|
|
169
147
|
this[LOG_SYMBOL] = log;
|
|
170
148
|
this.getChildLogger = getChildLogger;
|
|
171
149
|
}
|
|
172
|
-
|
|
173
150
|
_createClass(WebpackLogger, [{
|
|
174
151
|
key: "error",
|
|
175
152
|
value: function error() {
|
|
176
153
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
177
154
|
args[_key] = arguments[_key];
|
|
178
155
|
}
|
|
179
|
-
|
|
180
156
|
this[LOG_SYMBOL](LogType.error, args);
|
|
181
157
|
}
|
|
182
158
|
}, {
|
|
@@ -185,7 +161,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
185
161
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
186
162
|
args[_key2] = arguments[_key2];
|
|
187
163
|
}
|
|
188
|
-
|
|
189
164
|
this[LOG_SYMBOL](LogType.warn, args);
|
|
190
165
|
}
|
|
191
166
|
}, {
|
|
@@ -194,7 +169,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
194
169
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
195
170
|
args[_key3] = arguments[_key3];
|
|
196
171
|
}
|
|
197
|
-
|
|
198
172
|
this[LOG_SYMBOL](LogType.info, args);
|
|
199
173
|
}
|
|
200
174
|
}, {
|
|
@@ -203,7 +177,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
203
177
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
204
178
|
args[_key4] = arguments[_key4];
|
|
205
179
|
}
|
|
206
|
-
|
|
207
180
|
this[LOG_SYMBOL](LogType.log, args);
|
|
208
181
|
}
|
|
209
182
|
}, {
|
|
@@ -212,7 +185,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
212
185
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
213
186
|
args[_key5] = arguments[_key5];
|
|
214
187
|
}
|
|
215
|
-
|
|
216
188
|
this[LOG_SYMBOL](LogType.debug, args);
|
|
217
189
|
}
|
|
218
190
|
}, {
|
|
@@ -222,7 +194,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
222
194
|
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
223
195
|
args[_key6 - 1] = arguments[_key6];
|
|
224
196
|
}
|
|
225
|
-
|
|
226
197
|
this[LOG_SYMBOL](LogType.error, args);
|
|
227
198
|
}
|
|
228
199
|
}
|
|
@@ -242,7 +213,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
242
213
|
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
243
214
|
args[_key7] = arguments[_key7];
|
|
244
215
|
}
|
|
245
|
-
|
|
246
216
|
this[LOG_SYMBOL](LogType.status, args);
|
|
247
217
|
}
|
|
248
218
|
}, {
|
|
@@ -251,7 +221,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
251
221
|
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
252
222
|
args[_key8] = arguments[_key8];
|
|
253
223
|
}
|
|
254
|
-
|
|
255
224
|
this[LOG_SYMBOL](LogType.group, args);
|
|
256
225
|
}
|
|
257
226
|
}, {
|
|
@@ -260,7 +229,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
260
229
|
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
261
230
|
args[_key9] = arguments[_key9];
|
|
262
231
|
}
|
|
263
|
-
|
|
264
232
|
this[LOG_SYMBOL](LogType.groupCollapsed, args);
|
|
265
233
|
}
|
|
266
234
|
}, {
|
|
@@ -269,7 +237,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
269
237
|
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
270
238
|
args[_key10] = arguments[_key10];
|
|
271
239
|
}
|
|
272
|
-
|
|
273
240
|
this[LOG_SYMBOL](LogType.groupEnd, args);
|
|
274
241
|
}
|
|
275
242
|
}, {
|
|
@@ -292,11 +259,9 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
292
259
|
key: "timeLog",
|
|
293
260
|
value: function timeLog(label) {
|
|
294
261
|
var prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
|
295
|
-
|
|
296
262
|
if (!prev) {
|
|
297
263
|
throw new Error("No such label '".concat(label, "' for WebpackLogger.timeLog()"));
|
|
298
264
|
}
|
|
299
|
-
|
|
300
265
|
var time = process.hrtime(prev);
|
|
301
266
|
this[LOG_SYMBOL](LogType.time, [label].concat(_toConsumableArray(time)));
|
|
302
267
|
}
|
|
@@ -304,11 +269,9 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
304
269
|
key: "timeEnd",
|
|
305
270
|
value: function timeEnd(label) {
|
|
306
271
|
var prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
|
307
|
-
|
|
308
272
|
if (!prev) {
|
|
309
273
|
throw new Error("No such label '".concat(label, "' for WebpackLogger.timeEnd()"));
|
|
310
274
|
}
|
|
311
|
-
|
|
312
275
|
var time = process.hrtime(prev);
|
|
313
276
|
this[TIMERS_SYMBOL].delete(label);
|
|
314
277
|
this[LOG_SYMBOL](LogType.time, [label].concat(_toConsumableArray(time)));
|
|
@@ -317,16 +280,13 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
317
280
|
key: "timeAggregate",
|
|
318
281
|
value: function timeAggregate(label) {
|
|
319
282
|
var prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
|
320
|
-
|
|
321
283
|
if (!prev) {
|
|
322
284
|
throw new Error("No such label '".concat(label, "' for WebpackLogger.timeAggregate()"));
|
|
323
285
|
}
|
|
324
|
-
|
|
325
286
|
var time = process.hrtime(prev);
|
|
326
287
|
this[TIMERS_SYMBOL].delete(label);
|
|
327
288
|
this[TIMERS_AGGREGATES_SYMBOL] = this[TIMERS_AGGREGATES_SYMBOL] || new Map();
|
|
328
289
|
var current = this[TIMERS_AGGREGATES_SYMBOL].get(label);
|
|
329
|
-
|
|
330
290
|
if (current !== undefined) {
|
|
331
291
|
if (time[1] + current[1] > 1e9) {
|
|
332
292
|
time[0] += current[0] + 1;
|
|
@@ -336,7 +296,6 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
336
296
|
time[1] += current[1];
|
|
337
297
|
}
|
|
338
298
|
}
|
|
339
|
-
|
|
340
299
|
this[TIMERS_AGGREGATES_SYMBOL].set(label, time);
|
|
341
300
|
}
|
|
342
301
|
}, {
|
|
@@ -349,10 +308,8 @@ var WebpackLogger = /*#__PURE__*/function () {
|
|
|
349
308
|
this[LOG_SYMBOL](LogType.time, [label].concat(_toConsumableArray(time)));
|
|
350
309
|
}
|
|
351
310
|
}]);
|
|
352
|
-
|
|
353
311
|
return WebpackLogger;
|
|
354
312
|
}();
|
|
355
|
-
|
|
356
313
|
exports.Logger = WebpackLogger;
|
|
357
314
|
|
|
358
315
|
/***/ }),
|
|
@@ -369,14 +326,13 @@ exports.Logger = WebpackLogger;
|
|
|
369
326
|
*/
|
|
370
327
|
|
|
371
328
|
|
|
329
|
+
|
|
372
330
|
function _toConsumableArray(arr) {
|
|
373
331
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
374
332
|
}
|
|
375
|
-
|
|
376
333
|
function _nonIterableSpread() {
|
|
377
334
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
378
335
|
}
|
|
379
|
-
|
|
380
336
|
function _unsupportedIterableToArray(o, minLen) {
|
|
381
337
|
if (!o) return;
|
|
382
338
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -385,31 +341,22 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
385
341
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
386
342
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
387
343
|
}
|
|
388
|
-
|
|
389
344
|
function _iterableToArray(iter) {
|
|
390
345
|
if (typeof (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }) !== "undefined" && iter[(typeof Symbol !== "undefined" ? Symbol : function (i) { return i; }).iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
391
346
|
}
|
|
392
|
-
|
|
393
347
|
function _arrayWithoutHoles(arr) {
|
|
394
348
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
395
349
|
}
|
|
396
|
-
|
|
397
350
|
function _arrayLikeToArray(arr, len) {
|
|
398
351
|
if (len == null || len > arr.length) len = arr.length;
|
|
399
|
-
|
|
400
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
401
|
-
arr2[i] = arr[i];
|
|
402
|
-
}
|
|
403
|
-
|
|
352
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
404
353
|
return arr2;
|
|
405
354
|
}
|
|
406
|
-
|
|
407
355
|
var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/logging/Logger.js"),
|
|
408
|
-
|
|
409
|
-
/** @typedef {import("../../declarations/WebpackOptions").FilterItemTypes} FilterItemTypes */
|
|
356
|
+
LogType = _require.LogType;
|
|
410
357
|
|
|
358
|
+
/** @typedef {import("../../declarations/WebpackOptions").FilterItemTypes} FilterItemTypes */
|
|
411
359
|
/** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
|
|
412
|
-
|
|
413
360
|
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
|
|
414
361
|
|
|
415
362
|
/** @typedef {function(string): boolean} FilterFunction */
|
|
@@ -443,38 +390,33 @@ var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/l
|
|
|
443
390
|
* @param {FilterItemTypes} item an input item
|
|
444
391
|
* @returns {FilterFunction} filter function
|
|
445
392
|
*/
|
|
446
|
-
|
|
447
|
-
|
|
448
393
|
var filterToFunction = function filterToFunction(item) {
|
|
449
394
|
if (typeof item === "string") {
|
|
450
|
-
var regExp = new RegExp("[\\\\/]".concat(item.replace(
|
|
395
|
+
var regExp = new RegExp("[\\\\/]".concat(item.replace(
|
|
396
|
+
// eslint-disable-next-line no-useless-escape
|
|
451
397
|
/[-[\]{}()*+?.\\^$|]/g, "\\$&"), "([\\\\/]|$|!|\\?)"));
|
|
452
398
|
return function (ident) {
|
|
453
399
|
return regExp.test(ident);
|
|
454
400
|
};
|
|
455
401
|
}
|
|
456
|
-
|
|
457
402
|
if (item && typeof item === "object" && typeof item.test === "function") {
|
|
458
403
|
return function (ident) {
|
|
459
404
|
return item.test(ident);
|
|
460
405
|
};
|
|
461
406
|
}
|
|
462
|
-
|
|
463
407
|
if (typeof item === "function") {
|
|
464
408
|
return item;
|
|
465
409
|
}
|
|
466
|
-
|
|
467
410
|
if (typeof item === "boolean") {
|
|
468
411
|
return function () {
|
|
469
412
|
return item;
|
|
470
413
|
};
|
|
471
414
|
}
|
|
472
415
|
};
|
|
416
|
+
|
|
473
417
|
/**
|
|
474
418
|
* @enum {number}
|
|
475
419
|
*/
|
|
476
|
-
|
|
477
|
-
|
|
478
420
|
var LogLevel = {
|
|
479
421
|
none: 6,
|
|
480
422
|
false: 6,
|
|
@@ -485,32 +427,29 @@ var LogLevel = {
|
|
|
485
427
|
true: 2,
|
|
486
428
|
verbose: 1
|
|
487
429
|
};
|
|
430
|
+
|
|
488
431
|
/**
|
|
489
432
|
* @param {LoggerOptions} options options object
|
|
490
433
|
* @returns {function(string, LogTypeEnum, any[]): void} logging function
|
|
491
434
|
*/
|
|
492
|
-
|
|
493
435
|
module.exports = function (_ref) {
|
|
494
436
|
var _ref$level = _ref.level,
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
437
|
+
level = _ref$level === void 0 ? "info" : _ref$level,
|
|
438
|
+
_ref$debug = _ref.debug,
|
|
439
|
+
debug = _ref$debug === void 0 ? false : _ref$debug,
|
|
440
|
+
console = _ref.console;
|
|
499
441
|
var debugFilters = typeof debug === "boolean" ? [function () {
|
|
500
442
|
return debug;
|
|
501
|
-
}] :
|
|
502
|
-
/** @type {FilterItemTypes[]} */
|
|
503
|
-
[].concat(debug).map(filterToFunction);
|
|
443
|
+
}] : /** @type {FilterItemTypes[]} */[].concat(debug).map(filterToFunction);
|
|
504
444
|
/** @type {number} */
|
|
505
|
-
|
|
506
445
|
var loglevel = LogLevel["".concat(level)] || 0;
|
|
446
|
+
|
|
507
447
|
/**
|
|
508
448
|
* @param {string} name name of the logger
|
|
509
449
|
* @param {LogTypeEnum} type type of the log entry
|
|
510
450
|
* @param {any[]} args arguments of the log entry
|
|
511
451
|
* @returns {void}
|
|
512
452
|
*/
|
|
513
|
-
|
|
514
453
|
var logger = function logger(name, type, args) {
|
|
515
454
|
var labeledArgs = function labeledArgs() {
|
|
516
455
|
if (Array.isArray(args)) {
|
|
@@ -523,52 +462,42 @@ module.exports = function (_ref) {
|
|
|
523
462
|
return [];
|
|
524
463
|
}
|
|
525
464
|
};
|
|
526
|
-
|
|
527
465
|
var debug = debugFilters.some(function (f) {
|
|
528
466
|
return f(name);
|
|
529
467
|
});
|
|
530
|
-
|
|
531
468
|
switch (type) {
|
|
532
469
|
case LogType.debug:
|
|
533
|
-
if (!debug) return;
|
|
534
|
-
|
|
470
|
+
if (!debug) return;
|
|
471
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
535
472
|
if (typeof console.debug === "function") {
|
|
536
473
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
537
474
|
console.debug.apply(console, _toConsumableArray(labeledArgs()));
|
|
538
475
|
} else {
|
|
539
476
|
console.log.apply(console, _toConsumableArray(labeledArgs()));
|
|
540
477
|
}
|
|
541
|
-
|
|
542
478
|
break;
|
|
543
|
-
|
|
544
479
|
case LogType.log:
|
|
545
480
|
if (!debug && loglevel > LogLevel.log) return;
|
|
546
481
|
console.log.apply(console, _toConsumableArray(labeledArgs()));
|
|
547
482
|
break;
|
|
548
|
-
|
|
549
483
|
case LogType.info:
|
|
550
484
|
if (!debug && loglevel > LogLevel.info) return;
|
|
551
485
|
console.info.apply(console, _toConsumableArray(labeledArgs()));
|
|
552
486
|
break;
|
|
553
|
-
|
|
554
487
|
case LogType.warn:
|
|
555
488
|
if (!debug && loglevel > LogLevel.warn) return;
|
|
556
489
|
console.warn.apply(console, _toConsumableArray(labeledArgs()));
|
|
557
490
|
break;
|
|
558
|
-
|
|
559
491
|
case LogType.error:
|
|
560
492
|
if (!debug && loglevel > LogLevel.error) return;
|
|
561
493
|
console.error.apply(console, _toConsumableArray(labeledArgs()));
|
|
562
494
|
break;
|
|
563
|
-
|
|
564
495
|
case LogType.trace:
|
|
565
496
|
if (!debug) return;
|
|
566
497
|
console.trace();
|
|
567
498
|
break;
|
|
568
|
-
|
|
569
499
|
case LogType.groupCollapsed:
|
|
570
500
|
if (!debug && loglevel > LogLevel.log) return;
|
|
571
|
-
|
|
572
501
|
if (!debug && loglevel > LogLevel.verbose) {
|
|
573
502
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
574
503
|
if (typeof console.groupCollapsed === "function") {
|
|
@@ -577,80 +506,63 @@ module.exports = function (_ref) {
|
|
|
577
506
|
} else {
|
|
578
507
|
console.log.apply(console, _toConsumableArray(labeledArgs()));
|
|
579
508
|
}
|
|
580
|
-
|
|
581
509
|
break;
|
|
582
510
|
}
|
|
583
|
-
|
|
584
511
|
// falls through
|
|
585
|
-
|
|
586
512
|
case LogType.group:
|
|
587
|
-
if (!debug && loglevel > LogLevel.log) return;
|
|
588
|
-
|
|
513
|
+
if (!debug && loglevel > LogLevel.log) return;
|
|
514
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
589
515
|
if (typeof console.group === "function") {
|
|
590
516
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
591
517
|
console.group.apply(console, _toConsumableArray(labeledArgs()));
|
|
592
518
|
} else {
|
|
593
519
|
console.log.apply(console, _toConsumableArray(labeledArgs()));
|
|
594
520
|
}
|
|
595
|
-
|
|
596
521
|
break;
|
|
597
|
-
|
|
598
522
|
case LogType.groupEnd:
|
|
599
|
-
if (!debug && loglevel > LogLevel.log) return;
|
|
600
|
-
|
|
523
|
+
if (!debug && loglevel > LogLevel.log) return;
|
|
524
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
601
525
|
if (typeof console.groupEnd === "function") {
|
|
602
526
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
603
527
|
console.groupEnd();
|
|
604
528
|
}
|
|
605
|
-
|
|
606
529
|
break;
|
|
607
|
-
|
|
608
530
|
case LogType.time:
|
|
609
531
|
{
|
|
610
532
|
if (!debug && loglevel > LogLevel.log) return;
|
|
611
533
|
var ms = args[1] * 1000 + args[2] / 1000000;
|
|
612
534
|
var msg = "[".concat(name, "] ").concat(args[0], ": ").concat(ms, " ms");
|
|
613
|
-
|
|
614
535
|
if (typeof console.logTime === "function") {
|
|
615
536
|
console.logTime(msg);
|
|
616
537
|
} else {
|
|
617
538
|
console.log(msg);
|
|
618
539
|
}
|
|
619
|
-
|
|
620
540
|
break;
|
|
621
541
|
}
|
|
622
|
-
|
|
623
542
|
case LogType.profile:
|
|
624
543
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
625
544
|
if (typeof console.profile === "function") {
|
|
626
545
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
627
546
|
console.profile.apply(console, _toConsumableArray(labeledArgs()));
|
|
628
547
|
}
|
|
629
|
-
|
|
630
548
|
break;
|
|
631
|
-
|
|
632
549
|
case LogType.profileEnd:
|
|
633
550
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
634
551
|
if (typeof console.profileEnd === "function") {
|
|
635
552
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
636
553
|
console.profileEnd.apply(console, _toConsumableArray(labeledArgs()));
|
|
637
554
|
}
|
|
638
|
-
|
|
639
555
|
break;
|
|
640
|
-
|
|
641
556
|
case LogType.clear:
|
|
642
|
-
if (!debug && loglevel > LogLevel.log) return;
|
|
643
|
-
|
|
557
|
+
if (!debug && loglevel > LogLevel.log) return;
|
|
558
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
644
559
|
if (typeof console.clear === "function") {
|
|
645
560
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
646
561
|
console.clear();
|
|
647
562
|
}
|
|
648
|
-
|
|
649
563
|
break;
|
|
650
|
-
|
|
651
564
|
case LogType.status:
|
|
652
565
|
if (!debug && loglevel > LogLevel.info) return;
|
|
653
|
-
|
|
654
566
|
if (typeof console.status === "function") {
|
|
655
567
|
if (args.length === 0) {
|
|
656
568
|
console.status();
|
|
@@ -662,14 +574,11 @@ module.exports = function (_ref) {
|
|
|
662
574
|
console.info.apply(console, _toConsumableArray(labeledArgs()));
|
|
663
575
|
}
|
|
664
576
|
}
|
|
665
|
-
|
|
666
577
|
break;
|
|
667
|
-
|
|
668
578
|
default:
|
|
669
579
|
throw new Error("Unexpected LogType ".concat(type));
|
|
670
580
|
}
|
|
671
581
|
};
|
|
672
|
-
|
|
673
582
|
return logger;
|
|
674
583
|
};
|
|
675
584
|
|
|
@@ -687,43 +596,38 @@ module.exports = function (_ref) {
|
|
|
687
596
|
*/
|
|
688
597
|
|
|
689
598
|
|
|
599
|
+
|
|
690
600
|
function _extends() {
|
|
691
601
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
692
602
|
for (var i = 1; i < arguments.length; i++) {
|
|
693
603
|
var source = arguments[i];
|
|
694
|
-
|
|
695
604
|
for (var key in source) {
|
|
696
605
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
697
606
|
target[key] = source[key];
|
|
698
607
|
}
|
|
699
608
|
}
|
|
700
609
|
}
|
|
701
|
-
|
|
702
610
|
return target;
|
|
703
611
|
};
|
|
704
612
|
return _extends.apply(this, arguments);
|
|
705
613
|
}
|
|
706
|
-
|
|
707
614
|
var SyncBailHook = __webpack_require__(/*! tapable/lib/SyncBailHook */ "./client-src/modules/logger/SyncBailHookFake.js");
|
|
708
|
-
|
|
709
615
|
var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/logging/Logger.js"),
|
|
710
|
-
|
|
711
|
-
|
|
616
|
+
Logger = _require.Logger;
|
|
712
617
|
var createConsoleLogger = __webpack_require__(/*! ./createConsoleLogger */ "./node_modules/webpack/lib/logging/createConsoleLogger.js");
|
|
713
|
-
/** @type {createConsoleLogger.LoggerOptions} */
|
|
714
|
-
|
|
715
618
|
|
|
619
|
+
/** @type {createConsoleLogger.LoggerOptions} */
|
|
716
620
|
var currentDefaultLoggerOptions = {
|
|
717
621
|
level: "info",
|
|
718
622
|
debug: false,
|
|
719
623
|
console: console
|
|
720
624
|
};
|
|
721
625
|
var currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
|
626
|
+
|
|
722
627
|
/**
|
|
723
628
|
* @param {string} name name of the logger
|
|
724
629
|
* @returns {Logger} a logger
|
|
725
630
|
*/
|
|
726
|
-
|
|
727
631
|
exports.getLogger = function (name) {
|
|
728
632
|
return new Logger(function (type, args) {
|
|
729
633
|
if (exports.hooks.log.call(name, type, args) === undefined) {
|
|
@@ -733,18 +637,15 @@ exports.getLogger = function (name) {
|
|
|
733
637
|
return exports.getLogger("".concat(name, "/").concat(childName));
|
|
734
638
|
});
|
|
735
639
|
};
|
|
640
|
+
|
|
736
641
|
/**
|
|
737
642
|
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
|
738
643
|
* @returns {void}
|
|
739
644
|
*/
|
|
740
|
-
|
|
741
|
-
|
|
742
645
|
exports.configureDefaultLogger = function (options) {
|
|
743
646
|
_extends(currentDefaultLoggerOptions, options);
|
|
744
|
-
|
|
745
647
|
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
|
746
648
|
};
|
|
747
|
-
|
|
748
649
|
exports.hooks = {
|
|
749
650
|
log: new SyncBailHook(["origin", "type", "args"])
|
|
750
651
|
};
|