mw-common-components 0.0.1-security → 99.99.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mw-common-components might be problematic. Click here for more details.
- package/README.md +3 -3
- package/config/dev.env.js +37 -0
- package/config/hap.amend.js +29 -0
- package/config/index.js +8 -0
- package/config/prod.env.js +28 -0
- package/index.d.ts +130 -0
- package/index.js +1 -0
- package/package.json +44 -3
- package/src/index.html +12 -0
- package/src/lib/app.js +103 -0
- package/src/lib/axios/CHANGELOG.md +245 -0
- package/src/lib/axios/LICENSE +19 -0
- package/src/lib/axios/README.md +625 -0
- package/src/lib/axios/UPGRADE_GUIDE.md +162 -0
- package/src/lib/axios/dist/axios.js +1603 -0
- package/src/lib/axios/dist/axios.map +1 -0
- package/src/lib/axios/dist/axios.min.js +9 -0
- package/src/lib/axios/dist/axios.min.map +1 -0
- package/src/lib/axios/index.d.ts +131 -0
- package/src/lib/axios/index.js +1 -0
- package/src/lib/axios/lib/adapters/README.md +37 -0
- package/src/lib/axios/lib/adapters/http.js +237 -0
- package/src/lib/axios/lib/adapters/xhr.js +180 -0
- package/src/lib/axios/lib/axios.js +52 -0
- package/src/lib/axios/lib/cancel/Cancel.js +19 -0
- package/src/lib/axios/lib/cancel/CancelToken.js +57 -0
- package/src/lib/axios/lib/cancel/isCancel.js +5 -0
- package/src/lib/axios/lib/core/Axios.js +79 -0
- package/src/lib/axios/lib/core/InterceptorManager.js +52 -0
- package/src/lib/axios/lib/core/README.md +7 -0
- package/src/lib/axios/lib/core/createError.js +18 -0
- package/src/lib/axios/lib/core/dispatchRequest.js +86 -0
- package/src/lib/axios/lib/core/enhanceError.js +21 -0
- package/src/lib/axios/lib/core/settle.js +26 -0
- package/src/lib/axios/lib/core/transformData.js +20 -0
- package/src/lib/axios/lib/defaults.js +96 -0
- package/src/lib/axios/lib/helpers/README.md +7 -0
- package/src/lib/axios/lib/helpers/bind.js +11 -0
- package/src/lib/axios/lib/helpers/btoa.js +36 -0
- package/src/lib/axios/lib/helpers/buildURL.js +66 -0
- package/src/lib/axios/lib/helpers/combineURLs.js +14 -0
- package/src/lib/axios/lib/helpers/cookies.js +53 -0
- package/src/lib/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/src/lib/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/src/lib/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/src/lib/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/src/lib/axios/lib/helpers/parseHeaders.js +53 -0
- package/src/lib/axios/lib/helpers/spread.js +27 -0
- package/src/lib/axios/lib/utils.js +303 -0
- package/src/lib/axios/modules/debug/CHANGELOG.md +395 -0
- package/src/lib/axios/modules/debug/LICENSE +19 -0
- package/src/lib/axios/modules/debug/README.md +437 -0
- package/src/lib/axios/modules/debug/dist/debug.js +886 -0
- package/src/lib/axios/modules/debug/node.js +1 -0
- package/src/lib/axios/modules/debug/package.json +96 -0
- package/src/lib/axios/modules/debug/src/browser.js +180 -0
- package/src/lib/axios/modules/debug/src/common.js +249 -0
- package/src/lib/axios/modules/debug/src/index.js +12 -0
- package/src/lib/axios/modules/debug/src/node.js +174 -0
- package/src/lib/axios/modules/follow-redirects/LICENSE +18 -0
- package/src/lib/axios/modules/follow-redirects/README.md +145 -0
- package/src/lib/axios/modules/follow-redirects/http.js +1 -0
- package/src/lib/axios/modules/follow-redirects/https.js +1 -0
- package/src/lib/axios/modules/follow-redirects/index.js +452 -0
- package/src/lib/axios/modules/follow-redirects/package.json +92 -0
- package/src/lib/axios/modules/is-buffer/LICENSE +21 -0
- package/src/lib/axios/modules/is-buffer/README.md +53 -0
- package/src/lib/axios/modules/is-buffer/index.js +21 -0
- package/src/lib/axios/modules/is-buffer/package.json +90 -0
- package/src/lib/axios/modules/is-buffer/test/basic.js +24 -0
- package/src/lib/axios/modules/ms/index.js +162 -0
- package/src/lib/axios/modules/ms/license.md +21 -0
- package/src/lib/axios/modules/ms/package.json +72 -0
- package/src/lib/axios/modules/ms/readme.md +60 -0
- package/src/lib/axios/package-lock.json +10437 -0
- package/src/lib/axios/package.json +111 -0
- package/src/lib/axios.min.js +10 -0
- package/src/lib/axiosRequest.js +84 -0
- package/src/lib/bmob.js +36 -0
- package/src/lib/common.js +227 -0
- package/src/lib/config.dev.js +62 -0
- package/src/lib/config.js +69 -0
- package/src/lib/dataType.js +17 -0
- package/src/lib/error.js +32 -0
- package/src/lib/file.js +250 -0
- package/src/lib/hapRequest.js +68 -0
- package/src/lib/hapStorage.js +62 -0
- package/src/lib/init.js +0 -0
- package/src/lib/nodestorage.js +14 -0
- package/src/lib/pay.js +19 -0
- package/src/lib/pointer.js +18 -0
- package/src/lib/query.js +689 -0
- package/src/lib/relation.js +45 -0
- package/src/lib/request.js +21 -0
- package/src/lib/sms.js +40 -0
- package/src/lib/socket.js +292 -0
- package/src/lib/storage.js +21 -0
- package/src/lib/user.js +225 -0
- package/src/lib/utf8md5.js +205 -0
- package/src/lib/utils.js +61 -0
- package/src/lib/webstorage.js +32 -0
- package/src/lib/wxRequest.js +88 -0
- package/src/lib/wxstorage.js +27 -0
- package/src/main.js +27 -0
- package/test/index.html +15 -0
- package/test/index.js +12 -0
- package/tsconfig.json +100 -0
@@ -0,0 +1,886 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4
|
+
|
5
|
+
(function (f) {
|
6
|
+
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
|
7
|
+
module.exports = f();
|
8
|
+
} else if (typeof define === "function" && define.amd) {
|
9
|
+
define([], f);
|
10
|
+
} else {
|
11
|
+
var g;
|
12
|
+
|
13
|
+
if (typeof window !== "undefined") {
|
14
|
+
g = window;
|
15
|
+
} else if (typeof global !== "undefined") {
|
16
|
+
g = global;
|
17
|
+
} else if (typeof self !== "undefined") {
|
18
|
+
g = self;
|
19
|
+
} else {
|
20
|
+
g = this;
|
21
|
+
}
|
22
|
+
|
23
|
+
g.debug = f();
|
24
|
+
}
|
25
|
+
})(function () {
|
26
|
+
var define, module, exports;
|
27
|
+
return function () {
|
28
|
+
function r(e, n, t) {
|
29
|
+
function o(i, f) {
|
30
|
+
if (!n[i]) {
|
31
|
+
if (!e[i]) {
|
32
|
+
var c = "function" == typeof require && require;
|
33
|
+
if (!f && c) return c(i, !0);
|
34
|
+
if (u) return u(i, !0);
|
35
|
+
var a = new Error("Cannot find module '" + i + "'");
|
36
|
+
throw a.code = "MODULE_NOT_FOUND", a;
|
37
|
+
}
|
38
|
+
|
39
|
+
var p = n[i] = {
|
40
|
+
exports: {}
|
41
|
+
};
|
42
|
+
e[i][0].call(p.exports, function (r) {
|
43
|
+
var n = e[i][1][r];
|
44
|
+
return o(n || r);
|
45
|
+
}, p, p.exports, r, e, n, t);
|
46
|
+
}
|
47
|
+
|
48
|
+
return n[i].exports;
|
49
|
+
}
|
50
|
+
|
51
|
+
for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
|
52
|
+
o(t[i]);
|
53
|
+
}
|
54
|
+
|
55
|
+
return o;
|
56
|
+
}
|
57
|
+
|
58
|
+
return r;
|
59
|
+
}()({
|
60
|
+
1: [function (require, module, exports) {
|
61
|
+
/**
|
62
|
+
* Helpers.
|
63
|
+
*/
|
64
|
+
var s = 1000;
|
65
|
+
var m = s * 60;
|
66
|
+
var h = m * 60;
|
67
|
+
var d = h * 24;
|
68
|
+
var w = d * 7;
|
69
|
+
var y = d * 365.25;
|
70
|
+
/**
|
71
|
+
* Parse or format the given `val`.
|
72
|
+
*
|
73
|
+
* Options:
|
74
|
+
*
|
75
|
+
* - `long` verbose formatting [false]
|
76
|
+
*
|
77
|
+
* @param {String|Number} val
|
78
|
+
* @param {Object} [options]
|
79
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
80
|
+
* @return {String|Number}
|
81
|
+
* @api public
|
82
|
+
*/
|
83
|
+
|
84
|
+
module.exports = function (val, options) {
|
85
|
+
options = options || {};
|
86
|
+
|
87
|
+
var type = _typeof(val);
|
88
|
+
|
89
|
+
if (type === 'string' && val.length > 0) {
|
90
|
+
return parse(val);
|
91
|
+
} else if (type === 'number' && isNaN(val) === false) {
|
92
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
93
|
+
}
|
94
|
+
|
95
|
+
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
96
|
+
};
|
97
|
+
/**
|
98
|
+
* Parse the given `str` and return milliseconds.
|
99
|
+
*
|
100
|
+
* @param {String} str
|
101
|
+
* @return {Number}
|
102
|
+
* @api private
|
103
|
+
*/
|
104
|
+
|
105
|
+
|
106
|
+
function parse(str) {
|
107
|
+
str = String(str);
|
108
|
+
|
109
|
+
if (str.length > 100) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
|
113
|
+
var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
114
|
+
|
115
|
+
if (!match) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
|
119
|
+
var n = parseFloat(match[1]);
|
120
|
+
var type = (match[2] || 'ms').toLowerCase();
|
121
|
+
|
122
|
+
switch (type) {
|
123
|
+
case 'years':
|
124
|
+
case 'year':
|
125
|
+
case 'yrs':
|
126
|
+
case 'yr':
|
127
|
+
case 'y':
|
128
|
+
return n * y;
|
129
|
+
|
130
|
+
case 'weeks':
|
131
|
+
case 'week':
|
132
|
+
case 'w':
|
133
|
+
return n * w;
|
134
|
+
|
135
|
+
case 'days':
|
136
|
+
case 'day':
|
137
|
+
case 'd':
|
138
|
+
return n * d;
|
139
|
+
|
140
|
+
case 'hours':
|
141
|
+
case 'hour':
|
142
|
+
case 'hrs':
|
143
|
+
case 'hr':
|
144
|
+
case 'h':
|
145
|
+
return n * h;
|
146
|
+
|
147
|
+
case 'minutes':
|
148
|
+
case 'minute':
|
149
|
+
case 'mins':
|
150
|
+
case 'min':
|
151
|
+
case 'm':
|
152
|
+
return n * m;
|
153
|
+
|
154
|
+
case 'seconds':
|
155
|
+
case 'second':
|
156
|
+
case 'secs':
|
157
|
+
case 'sec':
|
158
|
+
case 's':
|
159
|
+
return n * s;
|
160
|
+
|
161
|
+
case 'milliseconds':
|
162
|
+
case 'millisecond':
|
163
|
+
case 'msecs':
|
164
|
+
case 'msec':
|
165
|
+
case 'ms':
|
166
|
+
return n;
|
167
|
+
|
168
|
+
default:
|
169
|
+
return undefined;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
/**
|
173
|
+
* Short format for `ms`.
|
174
|
+
*
|
175
|
+
* @param {Number} ms
|
176
|
+
* @return {String}
|
177
|
+
* @api private
|
178
|
+
*/
|
179
|
+
|
180
|
+
|
181
|
+
function fmtShort(ms) {
|
182
|
+
var msAbs = Math.abs(ms);
|
183
|
+
|
184
|
+
if (msAbs >= d) {
|
185
|
+
return Math.round(ms / d) + 'd';
|
186
|
+
}
|
187
|
+
|
188
|
+
if (msAbs >= h) {
|
189
|
+
return Math.round(ms / h) + 'h';
|
190
|
+
}
|
191
|
+
|
192
|
+
if (msAbs >= m) {
|
193
|
+
return Math.round(ms / m) + 'm';
|
194
|
+
}
|
195
|
+
|
196
|
+
if (msAbs >= s) {
|
197
|
+
return Math.round(ms / s) + 's';
|
198
|
+
}
|
199
|
+
|
200
|
+
return ms + 'ms';
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Long format for `ms`.
|
204
|
+
*
|
205
|
+
* @param {Number} ms
|
206
|
+
* @return {String}
|
207
|
+
* @api private
|
208
|
+
*/
|
209
|
+
|
210
|
+
|
211
|
+
function fmtLong(ms) {
|
212
|
+
var msAbs = Math.abs(ms);
|
213
|
+
|
214
|
+
if (msAbs >= d) {
|
215
|
+
return plural(ms, msAbs, d, 'day');
|
216
|
+
}
|
217
|
+
|
218
|
+
if (msAbs >= h) {
|
219
|
+
return plural(ms, msAbs, h, 'hour');
|
220
|
+
}
|
221
|
+
|
222
|
+
if (msAbs >= m) {
|
223
|
+
return plural(ms, msAbs, m, 'minute');
|
224
|
+
}
|
225
|
+
|
226
|
+
if (msAbs >= s) {
|
227
|
+
return plural(ms, msAbs, s, 'second');
|
228
|
+
}
|
229
|
+
|
230
|
+
return ms + ' ms';
|
231
|
+
}
|
232
|
+
/**
|
233
|
+
* Pluralization helper.
|
234
|
+
*/
|
235
|
+
|
236
|
+
|
237
|
+
function plural(ms, msAbs, n, name) {
|
238
|
+
var isPlural = msAbs >= n * 1.5;
|
239
|
+
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
240
|
+
}
|
241
|
+
}, {}],
|
242
|
+
2: [function (require, module, exports) {
|
243
|
+
// shim for using process in browser
|
244
|
+
var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
|
245
|
+
// don't break things. But we need to wrap it in a try catch in case it is
|
246
|
+
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
247
|
+
// function because try/catches deoptimize in certain engines.
|
248
|
+
|
249
|
+
var cachedSetTimeout;
|
250
|
+
var cachedClearTimeout;
|
251
|
+
|
252
|
+
function defaultSetTimout() {
|
253
|
+
throw new Error('setTimeout has not been defined');
|
254
|
+
}
|
255
|
+
|
256
|
+
function defaultClearTimeout() {
|
257
|
+
throw new Error('clearTimeout has not been defined');
|
258
|
+
}
|
259
|
+
|
260
|
+
(function () {
|
261
|
+
try {
|
262
|
+
if (typeof setTimeout === 'function') {
|
263
|
+
cachedSetTimeout = setTimeout;
|
264
|
+
} else {
|
265
|
+
cachedSetTimeout = defaultSetTimout;
|
266
|
+
}
|
267
|
+
} catch (e) {
|
268
|
+
cachedSetTimeout = defaultSetTimout;
|
269
|
+
}
|
270
|
+
|
271
|
+
try {
|
272
|
+
if (typeof clearTimeout === 'function') {
|
273
|
+
cachedClearTimeout = clearTimeout;
|
274
|
+
} else {
|
275
|
+
cachedClearTimeout = defaultClearTimeout;
|
276
|
+
}
|
277
|
+
} catch (e) {
|
278
|
+
cachedClearTimeout = defaultClearTimeout;
|
279
|
+
}
|
280
|
+
})();
|
281
|
+
|
282
|
+
function runTimeout(fun) {
|
283
|
+
if (cachedSetTimeout === setTimeout) {
|
284
|
+
//normal enviroments in sane situations
|
285
|
+
return setTimeout(fun, 0);
|
286
|
+
} // if setTimeout wasn't available but was latter defined
|
287
|
+
|
288
|
+
|
289
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
290
|
+
cachedSetTimeout = setTimeout;
|
291
|
+
return setTimeout(fun, 0);
|
292
|
+
}
|
293
|
+
|
294
|
+
try {
|
295
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
296
|
+
return cachedSetTimeout(fun, 0);
|
297
|
+
} catch (e) {
|
298
|
+
try {
|
299
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
300
|
+
return cachedSetTimeout.call(null, fun, 0);
|
301
|
+
} catch (e) {
|
302
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
303
|
+
return cachedSetTimeout.call(this, fun, 0);
|
304
|
+
}
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
function runClearTimeout(marker) {
|
309
|
+
if (cachedClearTimeout === clearTimeout) {
|
310
|
+
//normal enviroments in sane situations
|
311
|
+
return clearTimeout(marker);
|
312
|
+
} // if clearTimeout wasn't available but was latter defined
|
313
|
+
|
314
|
+
|
315
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
316
|
+
cachedClearTimeout = clearTimeout;
|
317
|
+
return clearTimeout(marker);
|
318
|
+
}
|
319
|
+
|
320
|
+
try {
|
321
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
322
|
+
return cachedClearTimeout(marker);
|
323
|
+
} catch (e) {
|
324
|
+
try {
|
325
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
326
|
+
return cachedClearTimeout.call(null, marker);
|
327
|
+
} catch (e) {
|
328
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
329
|
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
330
|
+
return cachedClearTimeout.call(this, marker);
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
|
335
|
+
var queue = [];
|
336
|
+
var draining = false;
|
337
|
+
var currentQueue;
|
338
|
+
var queueIndex = -1;
|
339
|
+
|
340
|
+
function cleanUpNextTick() {
|
341
|
+
if (!draining || !currentQueue) {
|
342
|
+
return;
|
343
|
+
}
|
344
|
+
|
345
|
+
draining = false;
|
346
|
+
|
347
|
+
if (currentQueue.length) {
|
348
|
+
queue = currentQueue.concat(queue);
|
349
|
+
} else {
|
350
|
+
queueIndex = -1;
|
351
|
+
}
|
352
|
+
|
353
|
+
if (queue.length) {
|
354
|
+
drainQueue();
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
function drainQueue() {
|
359
|
+
if (draining) {
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
|
363
|
+
var timeout = runTimeout(cleanUpNextTick);
|
364
|
+
draining = true;
|
365
|
+
var len = queue.length;
|
366
|
+
|
367
|
+
while (len) {
|
368
|
+
currentQueue = queue;
|
369
|
+
queue = [];
|
370
|
+
|
371
|
+
while (++queueIndex < len) {
|
372
|
+
if (currentQueue) {
|
373
|
+
currentQueue[queueIndex].run();
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
queueIndex = -1;
|
378
|
+
len = queue.length;
|
379
|
+
}
|
380
|
+
|
381
|
+
currentQueue = null;
|
382
|
+
draining = false;
|
383
|
+
runClearTimeout(timeout);
|
384
|
+
}
|
385
|
+
|
386
|
+
process.nextTick = function (fun) {
|
387
|
+
var args = new Array(arguments.length - 1);
|
388
|
+
|
389
|
+
if (arguments.length > 1) {
|
390
|
+
for (var i = 1; i < arguments.length; i++) {
|
391
|
+
args[i - 1] = arguments[i];
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
queue.push(new Item(fun, args));
|
396
|
+
|
397
|
+
if (queue.length === 1 && !draining) {
|
398
|
+
runTimeout(drainQueue);
|
399
|
+
}
|
400
|
+
}; // v8 likes predictible objects
|
401
|
+
|
402
|
+
|
403
|
+
function Item(fun, array) {
|
404
|
+
this.fun = fun;
|
405
|
+
this.array = array;
|
406
|
+
}
|
407
|
+
|
408
|
+
Item.prototype.run = function () {
|
409
|
+
this.fun.apply(null, this.array);
|
410
|
+
};
|
411
|
+
|
412
|
+
process.title = 'browser';
|
413
|
+
process.browser = true;
|
414
|
+
process.env = {};
|
415
|
+
process.argv = [];
|
416
|
+
process.version = ''; // empty string to avoid regexp issues
|
417
|
+
|
418
|
+
process.versions = {};
|
419
|
+
|
420
|
+
function noop() {}
|
421
|
+
|
422
|
+
process.on = noop;
|
423
|
+
process.addListener = noop;
|
424
|
+
process.once = noop;
|
425
|
+
process.off = noop;
|
426
|
+
process.removeListener = noop;
|
427
|
+
process.removeAllListeners = noop;
|
428
|
+
process.emit = noop;
|
429
|
+
process.prependListener = noop;
|
430
|
+
process.prependOnceListener = noop;
|
431
|
+
|
432
|
+
process.listeners = function (name) {
|
433
|
+
return [];
|
434
|
+
};
|
435
|
+
|
436
|
+
process.binding = function (name) {
|
437
|
+
throw new Error('process.binding is not supported');
|
438
|
+
};
|
439
|
+
|
440
|
+
process.cwd = function () {
|
441
|
+
return '/';
|
442
|
+
};
|
443
|
+
|
444
|
+
process.chdir = function (dir) {
|
445
|
+
throw new Error('process.chdir is not supported');
|
446
|
+
};
|
447
|
+
|
448
|
+
process.umask = function () {
|
449
|
+
return 0;
|
450
|
+
};
|
451
|
+
}, {}],
|
452
|
+
3: [function (require, module, exports) {
|
453
|
+
/**
|
454
|
+
* This is the common logic for both the Node.js and web browser
|
455
|
+
* implementations of `debug()`.
|
456
|
+
*/
|
457
|
+
function setup(env) {
|
458
|
+
createDebug.debug = createDebug;
|
459
|
+
createDebug.default = createDebug;
|
460
|
+
createDebug.coerce = coerce;
|
461
|
+
createDebug.disable = disable;
|
462
|
+
createDebug.enable = enable;
|
463
|
+
createDebug.enabled = enabled;
|
464
|
+
createDebug.humanize = require('ms');
|
465
|
+
Object.keys(env).forEach(function (key) {
|
466
|
+
createDebug[key] = env[key];
|
467
|
+
});
|
468
|
+
/**
|
469
|
+
* Active `debug` instances.
|
470
|
+
*/
|
471
|
+
|
472
|
+
createDebug.instances = [];
|
473
|
+
/**
|
474
|
+
* The currently active debug mode names, and names to skip.
|
475
|
+
*/
|
476
|
+
|
477
|
+
createDebug.names = [];
|
478
|
+
createDebug.skips = [];
|
479
|
+
/**
|
480
|
+
* Map of special "%n" handling functions, for the debug "format" argument.
|
481
|
+
*
|
482
|
+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
483
|
+
*/
|
484
|
+
|
485
|
+
createDebug.formatters = {};
|
486
|
+
/**
|
487
|
+
* Selects a color for a debug namespace
|
488
|
+
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
489
|
+
* @return {Number|String} An ANSI color code for the given namespace
|
490
|
+
* @api private
|
491
|
+
*/
|
492
|
+
|
493
|
+
function selectColor(namespace) {
|
494
|
+
var hash = 0;
|
495
|
+
|
496
|
+
for (var i = 0; i < namespace.length; i++) {
|
497
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
498
|
+
hash |= 0; // Convert to 32bit integer
|
499
|
+
}
|
500
|
+
|
501
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
502
|
+
}
|
503
|
+
|
504
|
+
createDebug.selectColor = selectColor;
|
505
|
+
/**
|
506
|
+
* Create a debugger with the given `namespace`.
|
507
|
+
*
|
508
|
+
* @param {String} namespace
|
509
|
+
* @return {Function}
|
510
|
+
* @api public
|
511
|
+
*/
|
512
|
+
|
513
|
+
function createDebug(namespace) {
|
514
|
+
var prevTime;
|
515
|
+
|
516
|
+
function debug() {
|
517
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
518
|
+
args[_key] = arguments[_key];
|
519
|
+
}
|
520
|
+
|
521
|
+
// Disabled?
|
522
|
+
if (!debug.enabled) {
|
523
|
+
return;
|
524
|
+
}
|
525
|
+
|
526
|
+
var self = debug; // Set `diff` timestamp
|
527
|
+
|
528
|
+
var curr = Number(new Date());
|
529
|
+
var ms = curr - (prevTime || curr);
|
530
|
+
self.diff = ms;
|
531
|
+
self.prev = prevTime;
|
532
|
+
self.curr = curr;
|
533
|
+
prevTime = curr;
|
534
|
+
args[0] = createDebug.coerce(args[0]);
|
535
|
+
|
536
|
+
if (typeof args[0] !== 'string') {
|
537
|
+
// Anything else let's inspect with %O
|
538
|
+
args.unshift('%O');
|
539
|
+
} // Apply any `formatters` transformations
|
540
|
+
|
541
|
+
|
542
|
+
var index = 0;
|
543
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
|
544
|
+
// If we encounter an escaped % then don't increase the array index
|
545
|
+
if (match === '%%') {
|
546
|
+
return match;
|
547
|
+
}
|
548
|
+
|
549
|
+
index++;
|
550
|
+
var formatter = createDebug.formatters[format];
|
551
|
+
|
552
|
+
if (typeof formatter === 'function') {
|
553
|
+
var val = args[index];
|
554
|
+
match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
555
|
+
|
556
|
+
args.splice(index, 1);
|
557
|
+
index--;
|
558
|
+
}
|
559
|
+
|
560
|
+
return match;
|
561
|
+
}); // Apply env-specific formatting (colors, etc.)
|
562
|
+
|
563
|
+
createDebug.formatArgs.call(self, args);
|
564
|
+
var logFn = self.log || createDebug.log;
|
565
|
+
logFn.apply(self, args);
|
566
|
+
}
|
567
|
+
|
568
|
+
debug.namespace = namespace;
|
569
|
+
debug.enabled = createDebug.enabled(namespace);
|
570
|
+
debug.useColors = createDebug.useColors();
|
571
|
+
debug.color = selectColor(namespace);
|
572
|
+
debug.destroy = destroy;
|
573
|
+
debug.extend = extend; // Debug.formatArgs = formatArgs;
|
574
|
+
// debug.rawLog = rawLog;
|
575
|
+
// env-specific initialization logic for debug instances
|
576
|
+
|
577
|
+
if (typeof createDebug.init === 'function') {
|
578
|
+
createDebug.init(debug);
|
579
|
+
}
|
580
|
+
|
581
|
+
createDebug.instances.push(debug);
|
582
|
+
return debug;
|
583
|
+
}
|
584
|
+
|
585
|
+
function destroy() {
|
586
|
+
var index = createDebug.instances.indexOf(this);
|
587
|
+
|
588
|
+
if (index !== -1) {
|
589
|
+
createDebug.instances.splice(index, 1);
|
590
|
+
return true;
|
591
|
+
}
|
592
|
+
|
593
|
+
return false;
|
594
|
+
}
|
595
|
+
|
596
|
+
function extend(namespace, delimiter) {
|
597
|
+
return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
598
|
+
}
|
599
|
+
/**
|
600
|
+
* Enables a debug mode by namespaces. This can include modes
|
601
|
+
* separated by a colon and wildcards.
|
602
|
+
*
|
603
|
+
* @param {String} namespaces
|
604
|
+
* @api public
|
605
|
+
*/
|
606
|
+
|
607
|
+
|
608
|
+
function enable(namespaces) {
|
609
|
+
createDebug.save(namespaces);
|
610
|
+
createDebug.names = [];
|
611
|
+
createDebug.skips = [];
|
612
|
+
var i;
|
613
|
+
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
614
|
+
var len = split.length;
|
615
|
+
|
616
|
+
for (i = 0; i < len; i++) {
|
617
|
+
if (!split[i]) {
|
618
|
+
// ignore empty strings
|
619
|
+
continue;
|
620
|
+
}
|
621
|
+
|
622
|
+
namespaces = split[i].replace(/\*/g, '.*?');
|
623
|
+
|
624
|
+
if (namespaces[0] === '-') {
|
625
|
+
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
626
|
+
} else {
|
627
|
+
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
628
|
+
}
|
629
|
+
}
|
630
|
+
|
631
|
+
for (i = 0; i < createDebug.instances.length; i++) {
|
632
|
+
var instance = createDebug.instances[i];
|
633
|
+
instance.enabled = createDebug.enabled(instance.namespace);
|
634
|
+
}
|
635
|
+
}
|
636
|
+
/**
|
637
|
+
* Disable debug output.
|
638
|
+
*
|
639
|
+
* @api public
|
640
|
+
*/
|
641
|
+
|
642
|
+
|
643
|
+
function disable() {
|
644
|
+
createDebug.enable('');
|
645
|
+
}
|
646
|
+
/**
|
647
|
+
* Returns true if the given mode name is enabled, false otherwise.
|
648
|
+
*
|
649
|
+
* @param {String} name
|
650
|
+
* @return {Boolean}
|
651
|
+
* @api public
|
652
|
+
*/
|
653
|
+
|
654
|
+
|
655
|
+
function enabled(name) {
|
656
|
+
if (name[name.length - 1] === '*') {
|
657
|
+
return true;
|
658
|
+
}
|
659
|
+
|
660
|
+
var i;
|
661
|
+
var len;
|
662
|
+
|
663
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
664
|
+
if (createDebug.skips[i].test(name)) {
|
665
|
+
return false;
|
666
|
+
}
|
667
|
+
}
|
668
|
+
|
669
|
+
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
670
|
+
if (createDebug.names[i].test(name)) {
|
671
|
+
return true;
|
672
|
+
}
|
673
|
+
}
|
674
|
+
|
675
|
+
return false;
|
676
|
+
}
|
677
|
+
/**
|
678
|
+
* Coerce `val`.
|
679
|
+
*
|
680
|
+
* @param {Mixed} val
|
681
|
+
* @return {Mixed}
|
682
|
+
* @api private
|
683
|
+
*/
|
684
|
+
|
685
|
+
|
686
|
+
function coerce(val) {
|
687
|
+
if (val instanceof Error) {
|
688
|
+
return val.stack || val.message;
|
689
|
+
}
|
690
|
+
|
691
|
+
return val;
|
692
|
+
}
|
693
|
+
|
694
|
+
createDebug.enable(createDebug.load());
|
695
|
+
return createDebug;
|
696
|
+
}
|
697
|
+
|
698
|
+
module.exports = setup;
|
699
|
+
}, {
|
700
|
+
"ms": 1
|
701
|
+
}],
|
702
|
+
4: [function (require, module, exports) {
|
703
|
+
(function (process) {
|
704
|
+
/* eslint-env browser */
|
705
|
+
|
706
|
+
/**
|
707
|
+
* This is the web browser implementation of `debug()`.
|
708
|
+
*/
|
709
|
+
exports.log = log;
|
710
|
+
exports.formatArgs = formatArgs;
|
711
|
+
exports.save = save;
|
712
|
+
exports.load = load;
|
713
|
+
exports.useColors = useColors;
|
714
|
+
exports.storage = localstorage();
|
715
|
+
/**
|
716
|
+
* Colors.
|
717
|
+
*/
|
718
|
+
|
719
|
+
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
720
|
+
/**
|
721
|
+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
722
|
+
* and the Firebug extension (any Firefox version) are known
|
723
|
+
* to support "%c" CSS customizations.
|
724
|
+
*
|
725
|
+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
726
|
+
*/
|
727
|
+
// eslint-disable-next-line complexity
|
728
|
+
|
729
|
+
function useColors() {
|
730
|
+
// NB: In an Electron preload script, document will be defined but not fully
|
731
|
+
// initialized. Since we know we're in Chrome, we'll just detect this case
|
732
|
+
// explicitly
|
733
|
+
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
734
|
+
return true;
|
735
|
+
} // Internet Explorer and Edge do not support colors.
|
736
|
+
|
737
|
+
|
738
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
739
|
+
return false;
|
740
|
+
} // Is webkit? http://stackoverflow.com/a/16459606/376773
|
741
|
+
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
742
|
+
|
743
|
+
|
744
|
+
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
745
|
+
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
746
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
747
|
+
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
748
|
+
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
749
|
+
}
|
750
|
+
/**
|
751
|
+
* Colorize log arguments if enabled.
|
752
|
+
*
|
753
|
+
* @api public
|
754
|
+
*/
|
755
|
+
|
756
|
+
|
757
|
+
function formatArgs(args) {
|
758
|
+
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
759
|
+
|
760
|
+
if (!this.useColors) {
|
761
|
+
return;
|
762
|
+
}
|
763
|
+
|
764
|
+
var c = 'color: ' + this.color;
|
765
|
+
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
766
|
+
// arguments passed either before or after the %c, so we need to
|
767
|
+
// figure out the correct index to insert the CSS into
|
768
|
+
|
769
|
+
var index = 0;
|
770
|
+
var lastC = 0;
|
771
|
+
args[0].replace(/%[a-zA-Z%]/g, function (match) {
|
772
|
+
if (match === '%%') {
|
773
|
+
return;
|
774
|
+
}
|
775
|
+
|
776
|
+
index++;
|
777
|
+
|
778
|
+
if (match === '%c') {
|
779
|
+
// We only are interested in the *last* %c
|
780
|
+
// (the user may have provided their own)
|
781
|
+
lastC = index;
|
782
|
+
}
|
783
|
+
});
|
784
|
+
args.splice(lastC, 0, c);
|
785
|
+
}
|
786
|
+
/**
|
787
|
+
* Invokes `console.log()` when available.
|
788
|
+
* No-op when `console.log` is not a "function".
|
789
|
+
*
|
790
|
+
* @api public
|
791
|
+
*/
|
792
|
+
|
793
|
+
|
794
|
+
function log() {
|
795
|
+
var _console;
|
796
|
+
|
797
|
+
// This hackery is required for IE8/9, where
|
798
|
+
// the `console.log` function doesn't have 'apply'
|
799
|
+
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
|
800
|
+
}
|
801
|
+
/**
|
802
|
+
* Save `namespaces`.
|
803
|
+
*
|
804
|
+
* @param {String} namespaces
|
805
|
+
* @api private
|
806
|
+
*/
|
807
|
+
|
808
|
+
|
809
|
+
function save(namespaces) {
|
810
|
+
try {
|
811
|
+
if (namespaces) {
|
812
|
+
exports.storage.setItem('debug', namespaces);
|
813
|
+
} else {
|
814
|
+
exports.storage.removeItem('debug');
|
815
|
+
}
|
816
|
+
} catch (error) {// Swallow
|
817
|
+
// XXX (@Qix-) should we be logging these?
|
818
|
+
}
|
819
|
+
}
|
820
|
+
/**
|
821
|
+
* Load `namespaces`.
|
822
|
+
*
|
823
|
+
* @return {String} returns the previously persisted debug modes
|
824
|
+
* @api private
|
825
|
+
*/
|
826
|
+
|
827
|
+
|
828
|
+
function load() {
|
829
|
+
var r;
|
830
|
+
|
831
|
+
try {
|
832
|
+
r = exports.storage.getItem('debug');
|
833
|
+
} catch (error) {} // Swallow
|
834
|
+
// XXX (@Qix-) should we be logging these?
|
835
|
+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
836
|
+
|
837
|
+
|
838
|
+
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
839
|
+
r = process.env.DEBUG;
|
840
|
+
}
|
841
|
+
|
842
|
+
return r;
|
843
|
+
}
|
844
|
+
/**
|
845
|
+
* Localstorage attempts to return the localstorage.
|
846
|
+
*
|
847
|
+
* This is necessary because safari throws
|
848
|
+
* when a user disables cookies/localstorage
|
849
|
+
* and you attempt to access it.
|
850
|
+
*
|
851
|
+
* @return {LocalStorage}
|
852
|
+
* @api private
|
853
|
+
*/
|
854
|
+
|
855
|
+
|
856
|
+
function localstorage() {
|
857
|
+
try {
|
858
|
+
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
859
|
+
// The Browser also has localStorage in the global context.
|
860
|
+
return localStorage;
|
861
|
+
} catch (error) {// Swallow
|
862
|
+
// XXX (@Qix-) should we be logging these?
|
863
|
+
}
|
864
|
+
}
|
865
|
+
|
866
|
+
module.exports = require('./common')(exports);
|
867
|
+
var formatters = module.exports.formatters;
|
868
|
+
/**
|
869
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
870
|
+
*/
|
871
|
+
|
872
|
+
formatters.j = function (v) {
|
873
|
+
try {
|
874
|
+
return JSON.stringify(v);
|
875
|
+
} catch (error) {
|
876
|
+
return '[UnexpectedJSONParseError]: ' + error.message;
|
877
|
+
}
|
878
|
+
};
|
879
|
+
}).call(this, require('_process'));
|
880
|
+
}, {
|
881
|
+
"./common": 3,
|
882
|
+
"_process": 2
|
883
|
+
}]
|
884
|
+
}, {}, [4])(4);
|
885
|
+
});
|
886
|
+
|