spy-client 2.0.7 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -10
- package/dist/head/base.d.ts +1 -1
- package/dist/lib/huffman.d.ts +9 -0
- package/dist/lib/interface.d.ts +59 -1
- package/dist/lib/util.d.ts +22 -0
- package/dist/module/longtask.d.ts +1 -1
- package/dist/module/resource.d.ts +19 -9
- package/dist/module/tti.d.ts +1 -1
- package/dist/spy-client-basic.esm.js +233 -1167
- package/dist/spy-client-basic.iife.js +237 -1171
- package/dist/spy-client-basic.iife.min.js +1 -1
- package/dist/spy-client-basic.js +238 -1172
- package/dist/spy-client-basic.min.js +1 -1
- package/dist/spy-client-basic.mjs +82 -54
- package/dist/spy-client.d.ts +5 -4
- package/dist/spy-client.esm.js +1393 -5662
- package/dist/spy-client.iife.js +1401 -5670
- package/dist/spy-client.iife.min.js +1 -1
- package/dist/spy-client.js +1402 -5671
- package/dist/spy-client.min.js +1 -1
- package/dist/spy-client.mjs +704 -455
- package/dist/spy-head.js +330 -276
- package/dist/spy-head.min.js +1 -1
- package/dist/spy-local-cache.d.ts +18 -0
- package/dist/spy-local-cache.js +690 -0
- package/dist/spy-local-cache.min.js +1 -0
- package/example/index.html +8 -2
- package/example/local-cache.html +97 -0
- package/example/saveCache.js +41 -0
- package/karma.conf.js +111 -0
- package/package.json +21 -20
- package/src/head/error.ts +14 -15
- package/src/head/whitescreen.ts +8 -5
- package/src/lib/huffman.ts +326 -0
- package/src/lib/interface.ts +70 -1
- package/src/lib/util.ts +101 -0
- package/src/module/resource.ts +226 -129
- package/src/spy-client-basic.ts +8 -7
- package/src/spy-client.ts +15 -6
- package/src/spy-local-cache.ts +385 -0
- package/src/types/globals.d.ts +1 -1
|
@@ -1,1174 +1,240 @@
|
|
|
1
1
|
var SpyClient = (function () {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var enforce = function (it) {
|
|
240
|
-
return has$1(it) ? get(it) : set(it, {});
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
var getterFor = function (TYPE) {
|
|
244
|
-
return function (it) {
|
|
245
|
-
var state;
|
|
246
|
-
if (!isObject(it) || (state = get(it)).type !== TYPE) {
|
|
247
|
-
throw TypeError('Incompatible receiver, ' + TYPE + ' required');
|
|
248
|
-
} return state;
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
if (nativeWeakMap) {
|
|
253
|
-
var store$1 = new WeakMap$1();
|
|
254
|
-
var wmget = store$1.get;
|
|
255
|
-
var wmhas = store$1.has;
|
|
256
|
-
var wmset = store$1.set;
|
|
257
|
-
set = function (it, metadata) {
|
|
258
|
-
wmset.call(store$1, it, metadata);
|
|
259
|
-
return metadata;
|
|
260
|
-
};
|
|
261
|
-
get = function (it) {
|
|
262
|
-
return wmget.call(store$1, it) || {};
|
|
263
|
-
};
|
|
264
|
-
has$1 = function (it) {
|
|
265
|
-
return wmhas.call(store$1, it);
|
|
266
|
-
};
|
|
267
|
-
} else {
|
|
268
|
-
var STATE = sharedKey('state');
|
|
269
|
-
hiddenKeys[STATE] = true;
|
|
270
|
-
set = function (it, metadata) {
|
|
271
|
-
createNonEnumerableProperty(it, STATE, metadata);
|
|
272
|
-
return metadata;
|
|
273
|
-
};
|
|
274
|
-
get = function (it) {
|
|
275
|
-
return has(it, STATE) ? it[STATE] : {};
|
|
276
|
-
};
|
|
277
|
-
has$1 = function (it) {
|
|
278
|
-
return has(it, STATE);
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
var internalState = {
|
|
283
|
-
set: set,
|
|
284
|
-
get: get,
|
|
285
|
-
has: has$1,
|
|
286
|
-
enforce: enforce,
|
|
287
|
-
getterFor: getterFor
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
var redefine = createCommonjsModule(function (module) {
|
|
291
|
-
var getInternalState = internalState.get;
|
|
292
|
-
var enforceInternalState = internalState.enforce;
|
|
293
|
-
var TEMPLATE = String(String).split('String');
|
|
294
|
-
|
|
295
|
-
(module.exports = function (O, key, value, options) {
|
|
296
|
-
var unsafe = options ? !!options.unsafe : false;
|
|
297
|
-
var simple = options ? !!options.enumerable : false;
|
|
298
|
-
var noTargetGet = options ? !!options.noTargetGet : false;
|
|
299
|
-
if (typeof value == 'function') {
|
|
300
|
-
if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
|
|
301
|
-
enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
|
|
302
|
-
}
|
|
303
|
-
if (O === global_1) {
|
|
304
|
-
if (simple) O[key] = value;
|
|
305
|
-
else setGlobal(key, value);
|
|
306
|
-
return;
|
|
307
|
-
} else if (!unsafe) {
|
|
308
|
-
delete O[key];
|
|
309
|
-
} else if (!noTargetGet && O[key]) {
|
|
310
|
-
simple = true;
|
|
311
|
-
}
|
|
312
|
-
if (simple) O[key] = value;
|
|
313
|
-
else createNonEnumerableProperty(O, key, value);
|
|
314
|
-
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
|
|
315
|
-
})(Function.prototype, 'toString', function toString() {
|
|
316
|
-
return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
var path = global_1;
|
|
321
|
-
|
|
322
|
-
var aFunction = function (variable) {
|
|
323
|
-
return typeof variable == 'function' ? variable : undefined;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
var getBuiltIn = function (namespace, method) {
|
|
327
|
-
return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
|
|
328
|
-
: path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
var ceil = Math.ceil;
|
|
332
|
-
var floor = Math.floor;
|
|
333
|
-
|
|
334
|
-
// `ToInteger` abstract operation
|
|
335
|
-
// https://tc39.github.io/ecma262/#sec-tointeger
|
|
336
|
-
var toInteger = function (argument) {
|
|
337
|
-
return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
var min = Math.min;
|
|
341
|
-
|
|
342
|
-
// `ToLength` abstract operation
|
|
343
|
-
// https://tc39.github.io/ecma262/#sec-tolength
|
|
344
|
-
var toLength = function (argument) {
|
|
345
|
-
return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
var max = Math.max;
|
|
349
|
-
var min$1 = Math.min;
|
|
350
|
-
|
|
351
|
-
// Helper for a popular repeating case of the spec:
|
|
352
|
-
// Let integer be ? ToInteger(index).
|
|
353
|
-
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
|
|
354
|
-
var toAbsoluteIndex = function (index, length) {
|
|
355
|
-
var integer = toInteger(index);
|
|
356
|
-
return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
// `Array.prototype.{ indexOf, includes }` methods implementation
|
|
360
|
-
var createMethod = function (IS_INCLUDES) {
|
|
361
|
-
return function ($this, el, fromIndex) {
|
|
362
|
-
var O = toIndexedObject($this);
|
|
363
|
-
var length = toLength(O.length);
|
|
364
|
-
var index = toAbsoluteIndex(fromIndex, length);
|
|
365
|
-
var value;
|
|
366
|
-
// Array#includes uses SameValueZero equality algorithm
|
|
367
|
-
// eslint-disable-next-line no-self-compare
|
|
368
|
-
if (IS_INCLUDES && el != el) while (length > index) {
|
|
369
|
-
value = O[index++];
|
|
370
|
-
// eslint-disable-next-line no-self-compare
|
|
371
|
-
if (value != value) return true;
|
|
372
|
-
// Array#indexOf ignores holes, Array#includes - not
|
|
373
|
-
} else for (;length > index; index++) {
|
|
374
|
-
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
|
|
375
|
-
} return !IS_INCLUDES && -1;
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
var arrayIncludes = {
|
|
380
|
-
// `Array.prototype.includes` method
|
|
381
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
|
|
382
|
-
includes: createMethod(true),
|
|
383
|
-
// `Array.prototype.indexOf` method
|
|
384
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.indexof
|
|
385
|
-
indexOf: createMethod(false)
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
var indexOf = arrayIncludes.indexOf;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
var objectKeysInternal = function (object, names) {
|
|
392
|
-
var O = toIndexedObject(object);
|
|
393
|
-
var i = 0;
|
|
394
|
-
var result = [];
|
|
395
|
-
var key;
|
|
396
|
-
for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
|
|
397
|
-
// Don't enum bug & hidden keys
|
|
398
|
-
while (names.length > i) if (has(O, key = names[i++])) {
|
|
399
|
-
~indexOf(result, key) || result.push(key);
|
|
400
|
-
}
|
|
401
|
-
return result;
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
// IE8- don't enum bug keys
|
|
405
|
-
var enumBugKeys = [
|
|
406
|
-
'constructor',
|
|
407
|
-
'hasOwnProperty',
|
|
408
|
-
'isPrototypeOf',
|
|
409
|
-
'propertyIsEnumerable',
|
|
410
|
-
'toLocaleString',
|
|
411
|
-
'toString',
|
|
412
|
-
'valueOf'
|
|
413
|
-
];
|
|
414
|
-
|
|
415
|
-
var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
|
|
416
|
-
|
|
417
|
-
// `Object.getOwnPropertyNames` method
|
|
418
|
-
// https://tc39.github.io/ecma262/#sec-object.getownpropertynames
|
|
419
|
-
var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
|
420
|
-
return objectKeysInternal(O, hiddenKeys$1);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
var objectGetOwnPropertyNames = {
|
|
424
|
-
f: f$3
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
var f$4 = Object.getOwnPropertySymbols;
|
|
428
|
-
|
|
429
|
-
var objectGetOwnPropertySymbols = {
|
|
430
|
-
f: f$4
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
// all object keys, includes non-enumerable and symbols
|
|
434
|
-
var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
|
|
435
|
-
var keys = objectGetOwnPropertyNames.f(anObject(it));
|
|
436
|
-
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
|
|
437
|
-
return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
var copyConstructorProperties = function (target, source) {
|
|
441
|
-
var keys = ownKeys(source);
|
|
442
|
-
var defineProperty = objectDefineProperty.f;
|
|
443
|
-
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
|
444
|
-
for (var i = 0; i < keys.length; i++) {
|
|
445
|
-
var key = keys[i];
|
|
446
|
-
if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
var replacement = /#|\.prototype\./;
|
|
451
|
-
|
|
452
|
-
var isForced = function (feature, detection) {
|
|
453
|
-
var value = data[normalize(feature)];
|
|
454
|
-
return value == POLYFILL ? true
|
|
455
|
-
: value == NATIVE ? false
|
|
456
|
-
: typeof detection == 'function' ? fails(detection)
|
|
457
|
-
: !!detection;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
var normalize = isForced.normalize = function (string) {
|
|
461
|
-
return String(string).replace(replacement, '.').toLowerCase();
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
var data = isForced.data = {};
|
|
465
|
-
var NATIVE = isForced.NATIVE = 'N';
|
|
466
|
-
var POLYFILL = isForced.POLYFILL = 'P';
|
|
467
|
-
|
|
468
|
-
var isForced_1 = isForced;
|
|
469
|
-
|
|
470
|
-
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
/*
|
|
478
|
-
options.target - name of the target object
|
|
479
|
-
options.global - target is the global object
|
|
480
|
-
options.stat - export as static methods of target
|
|
481
|
-
options.proto - export as prototype methods of target
|
|
482
|
-
options.real - real prototype method for the `pure` version
|
|
483
|
-
options.forced - export even if the native feature is available
|
|
484
|
-
options.bind - bind methods to the target, required for the `pure` version
|
|
485
|
-
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
|
|
486
|
-
options.unsafe - use the simple assignment of property instead of delete + defineProperty
|
|
487
|
-
options.sham - add a flag to not completely full polyfills
|
|
488
|
-
options.enumerable - export as enumerable property
|
|
489
|
-
options.noTargetGet - prevent calling a getter on target
|
|
490
|
-
*/
|
|
491
|
-
var _export = function (options, source) {
|
|
492
|
-
var TARGET = options.target;
|
|
493
|
-
var GLOBAL = options.global;
|
|
494
|
-
var STATIC = options.stat;
|
|
495
|
-
var FORCED, target, key, targetProperty, sourceProperty, descriptor;
|
|
496
|
-
if (GLOBAL) {
|
|
497
|
-
target = global_1;
|
|
498
|
-
} else if (STATIC) {
|
|
499
|
-
target = global_1[TARGET] || setGlobal(TARGET, {});
|
|
500
|
-
} else {
|
|
501
|
-
target = (global_1[TARGET] || {}).prototype;
|
|
502
|
-
}
|
|
503
|
-
if (target) for (key in source) {
|
|
504
|
-
sourceProperty = source[key];
|
|
505
|
-
if (options.noTargetGet) {
|
|
506
|
-
descriptor = getOwnPropertyDescriptor$1(target, key);
|
|
507
|
-
targetProperty = descriptor && descriptor.value;
|
|
508
|
-
} else targetProperty = target[key];
|
|
509
|
-
FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
|
510
|
-
// contained in target
|
|
511
|
-
if (!FORCED && targetProperty !== undefined) {
|
|
512
|
-
if (typeof sourceProperty === typeof targetProperty) continue;
|
|
513
|
-
copyConstructorProperties(sourceProperty, targetProperty);
|
|
514
|
-
}
|
|
515
|
-
// add a flag to not completely full polyfills
|
|
516
|
-
if (options.sham || (targetProperty && targetProperty.sham)) {
|
|
517
|
-
createNonEnumerableProperty(sourceProperty, 'sham', true);
|
|
518
|
-
}
|
|
519
|
-
// extend global
|
|
520
|
-
redefine(target, key, sourceProperty, options);
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
// `IsArray` abstract operation
|
|
525
|
-
// https://tc39.github.io/ecma262/#sec-isarray
|
|
526
|
-
var isArray = Array.isArray || function isArray(arg) {
|
|
527
|
-
return classofRaw(arg) == 'Array';
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
// `ToObject` abstract operation
|
|
531
|
-
// https://tc39.github.io/ecma262/#sec-toobject
|
|
532
|
-
var toObject = function (argument) {
|
|
533
|
-
return Object(requireObjectCoercible(argument));
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
var createProperty = function (object, key, value) {
|
|
537
|
-
var propertyKey = toPrimitive(key);
|
|
538
|
-
if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
|
|
539
|
-
else object[propertyKey] = value;
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
|
|
543
|
-
// Chrome 38 Symbol has incorrect toString conversion
|
|
544
|
-
// eslint-disable-next-line no-undef
|
|
545
|
-
return !String(Symbol());
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
var useSymbolAsUid = nativeSymbol
|
|
549
|
-
// eslint-disable-next-line no-undef
|
|
550
|
-
&& !Symbol.sham
|
|
551
|
-
// eslint-disable-next-line no-undef
|
|
552
|
-
&& typeof Symbol.iterator == 'symbol';
|
|
553
|
-
|
|
554
|
-
var WellKnownSymbolsStore = shared('wks');
|
|
555
|
-
var Symbol$1 = global_1.Symbol;
|
|
556
|
-
var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
|
|
557
|
-
|
|
558
|
-
var wellKnownSymbol = function (name) {
|
|
559
|
-
if (!has(WellKnownSymbolsStore, name)) {
|
|
560
|
-
if (nativeSymbol && has(Symbol$1, name)) WellKnownSymbolsStore[name] = Symbol$1[name];
|
|
561
|
-
else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
|
|
562
|
-
} return WellKnownSymbolsStore[name];
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
var SPECIES = wellKnownSymbol('species');
|
|
566
|
-
|
|
567
|
-
// `ArraySpeciesCreate` abstract operation
|
|
568
|
-
// https://tc39.github.io/ecma262/#sec-arrayspeciescreate
|
|
569
|
-
var arraySpeciesCreate = function (originalArray, length) {
|
|
570
|
-
var C;
|
|
571
|
-
if (isArray(originalArray)) {
|
|
572
|
-
C = originalArray.constructor;
|
|
573
|
-
// cross-realm fallback
|
|
574
|
-
if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
|
|
575
|
-
else if (isObject(C)) {
|
|
576
|
-
C = C[SPECIES];
|
|
577
|
-
if (C === null) C = undefined;
|
|
578
|
-
}
|
|
579
|
-
} return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
|
|
583
|
-
|
|
584
|
-
var process = global_1.process;
|
|
585
|
-
var versions = process && process.versions;
|
|
586
|
-
var v8 = versions && versions.v8;
|
|
587
|
-
var match, version;
|
|
588
|
-
|
|
589
|
-
if (v8) {
|
|
590
|
-
match = v8.split('.');
|
|
591
|
-
version = match[0] + match[1];
|
|
592
|
-
} else if (engineUserAgent) {
|
|
593
|
-
match = engineUserAgent.match(/Edge\/(\d+)/);
|
|
594
|
-
if (!match || match[1] >= 74) {
|
|
595
|
-
match = engineUserAgent.match(/Chrome\/(\d+)/);
|
|
596
|
-
if (match) version = match[1];
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
var engineV8Version = version && +version;
|
|
601
|
-
|
|
602
|
-
var SPECIES$1 = wellKnownSymbol('species');
|
|
603
|
-
|
|
604
|
-
var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
|
|
605
|
-
// We can't use this feature detection in V8 since it causes
|
|
606
|
-
// deoptimization and serious performance degradation
|
|
607
|
-
// https://github.com/zloirock/core-js/issues/677
|
|
608
|
-
return engineV8Version >= 51 || !fails(function () {
|
|
609
|
-
var array = [];
|
|
610
|
-
var constructor = array.constructor = {};
|
|
611
|
-
constructor[SPECIES$1] = function () {
|
|
612
|
-
return { foo: 1 };
|
|
613
|
-
};
|
|
614
|
-
return array[METHOD_NAME](Boolean).foo !== 1;
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
|
|
619
|
-
var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
|
|
620
|
-
var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
|
|
621
|
-
|
|
622
|
-
// We can't use this feature detection in V8 since it causes
|
|
623
|
-
// deoptimization and serious performance degradation
|
|
624
|
-
// https://github.com/zloirock/core-js/issues/679
|
|
625
|
-
var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () {
|
|
626
|
-
var array = [];
|
|
627
|
-
array[IS_CONCAT_SPREADABLE] = false;
|
|
628
|
-
return array.concat()[0] !== array;
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
|
|
632
|
-
|
|
633
|
-
var isConcatSpreadable = function (O) {
|
|
634
|
-
if (!isObject(O)) return false;
|
|
635
|
-
var spreadable = O[IS_CONCAT_SPREADABLE];
|
|
636
|
-
return spreadable !== undefined ? !!spreadable : isArray(O);
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
|
|
640
|
-
|
|
641
|
-
// `Array.prototype.concat` method
|
|
642
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.concat
|
|
643
|
-
// with adding support of @@isConcatSpreadable and @@species
|
|
644
|
-
_export({ target: 'Array', proto: true, forced: FORCED }, {
|
|
645
|
-
concat: function concat(arg) { // eslint-disable-line no-unused-vars
|
|
646
|
-
var O = toObject(this);
|
|
647
|
-
var A = arraySpeciesCreate(O, 0);
|
|
648
|
-
var n = 0;
|
|
649
|
-
var i, k, length, len, E;
|
|
650
|
-
for (i = -1, length = arguments.length; i < length; i++) {
|
|
651
|
-
E = i === -1 ? O : arguments[i];
|
|
652
|
-
if (isConcatSpreadable(E)) {
|
|
653
|
-
len = toLength(E.length);
|
|
654
|
-
if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
|
|
655
|
-
for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
|
|
656
|
-
} else {
|
|
657
|
-
if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
|
|
658
|
-
createProperty(A, n++, E);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
A.length = n;
|
|
662
|
-
return A;
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
var arrayMethodIsStrict = function (METHOD_NAME, argument) {
|
|
667
|
-
var method = [][METHOD_NAME];
|
|
668
|
-
return !!method && fails(function () {
|
|
669
|
-
// eslint-disable-next-line no-useless-call,no-throw-literal
|
|
670
|
-
method.call(null, argument || function () { throw 1; }, 1);
|
|
671
|
-
});
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
var defineProperty = Object.defineProperty;
|
|
675
|
-
var cache = {};
|
|
676
|
-
|
|
677
|
-
var thrower = function (it) { throw it; };
|
|
678
|
-
|
|
679
|
-
var arrayMethodUsesToLength = function (METHOD_NAME, options) {
|
|
680
|
-
if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
|
|
681
|
-
if (!options) options = {};
|
|
682
|
-
var method = [][METHOD_NAME];
|
|
683
|
-
var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
|
|
684
|
-
var argument0 = has(options, 0) ? options[0] : thrower;
|
|
685
|
-
var argument1 = has(options, 1) ? options[1] : undefined;
|
|
686
|
-
|
|
687
|
-
return cache[METHOD_NAME] = !!method && !fails(function () {
|
|
688
|
-
if (ACCESSORS && !descriptors) return true;
|
|
689
|
-
var O = { length: -1 };
|
|
690
|
-
|
|
691
|
-
if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });
|
|
692
|
-
else O[1] = 1;
|
|
693
|
-
|
|
694
|
-
method.call(O, argument0, argument1);
|
|
695
|
-
});
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
var $indexOf = arrayIncludes.indexOf;
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
var nativeIndexOf = [].indexOf;
|
|
703
|
-
|
|
704
|
-
var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
|
|
705
|
-
var STRICT_METHOD = arrayMethodIsStrict('indexOf');
|
|
706
|
-
var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
|
|
707
|
-
|
|
708
|
-
// `Array.prototype.indexOf` method
|
|
709
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.indexof
|
|
710
|
-
_export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH }, {
|
|
711
|
-
indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
|
|
712
|
-
return NEGATIVE_ZERO
|
|
713
|
-
// convert -0 to +0
|
|
714
|
-
? nativeIndexOf.apply(this, arguments) || 0
|
|
715
|
-
: $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
var nativeJoin = [].join;
|
|
720
|
-
|
|
721
|
-
var ES3_STRINGS = indexedObject != Object;
|
|
722
|
-
var STRICT_METHOD$1 = arrayMethodIsStrict('join', ',');
|
|
723
|
-
|
|
724
|
-
// `Array.prototype.join` method
|
|
725
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.join
|
|
726
|
-
_export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$1 }, {
|
|
727
|
-
join: function join(separator) {
|
|
728
|
-
return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
var aFunction$1 = function (it) {
|
|
733
|
-
if (typeof it != 'function') {
|
|
734
|
-
throw TypeError(String(it) + ' is not a function');
|
|
735
|
-
} return it;
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
// optional / simple context binding
|
|
739
|
-
var functionBindContext = function (fn, that, length) {
|
|
740
|
-
aFunction$1(fn);
|
|
741
|
-
if (that === undefined) return fn;
|
|
742
|
-
switch (length) {
|
|
743
|
-
case 0: return function () {
|
|
744
|
-
return fn.call(that);
|
|
745
|
-
};
|
|
746
|
-
case 1: return function (a) {
|
|
747
|
-
return fn.call(that, a);
|
|
748
|
-
};
|
|
749
|
-
case 2: return function (a, b) {
|
|
750
|
-
return fn.call(that, a, b);
|
|
751
|
-
};
|
|
752
|
-
case 3: return function (a, b, c) {
|
|
753
|
-
return fn.call(that, a, b, c);
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
return function (/* ...args */) {
|
|
757
|
-
return fn.apply(that, arguments);
|
|
758
|
-
};
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
var push = [].push;
|
|
762
|
-
|
|
763
|
-
// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
|
|
764
|
-
var createMethod$1 = function (TYPE) {
|
|
765
|
-
var IS_MAP = TYPE == 1;
|
|
766
|
-
var IS_FILTER = TYPE == 2;
|
|
767
|
-
var IS_SOME = TYPE == 3;
|
|
768
|
-
var IS_EVERY = TYPE == 4;
|
|
769
|
-
var IS_FIND_INDEX = TYPE == 6;
|
|
770
|
-
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
|
771
|
-
return function ($this, callbackfn, that, specificCreate) {
|
|
772
|
-
var O = toObject($this);
|
|
773
|
-
var self = indexedObject(O);
|
|
774
|
-
var boundFunction = functionBindContext(callbackfn, that, 3);
|
|
775
|
-
var length = toLength(self.length);
|
|
776
|
-
var index = 0;
|
|
777
|
-
var create = specificCreate || arraySpeciesCreate;
|
|
778
|
-
var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
|
779
|
-
var value, result;
|
|
780
|
-
for (;length > index; index++) if (NO_HOLES || index in self) {
|
|
781
|
-
value = self[index];
|
|
782
|
-
result = boundFunction(value, index, O);
|
|
783
|
-
if (TYPE) {
|
|
784
|
-
if (IS_MAP) target[index] = result; // map
|
|
785
|
-
else if (result) switch (TYPE) {
|
|
786
|
-
case 3: return true; // some
|
|
787
|
-
case 5: return value; // find
|
|
788
|
-
case 6: return index; // findIndex
|
|
789
|
-
case 2: push.call(target, value); // filter
|
|
790
|
-
} else if (IS_EVERY) return false; // every
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
|
|
794
|
-
};
|
|
795
|
-
};
|
|
796
|
-
|
|
797
|
-
var arrayIteration = {
|
|
798
|
-
// `Array.prototype.forEach` method
|
|
799
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach
|
|
800
|
-
forEach: createMethod$1(0),
|
|
801
|
-
// `Array.prototype.map` method
|
|
802
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.map
|
|
803
|
-
map: createMethod$1(1),
|
|
804
|
-
// `Array.prototype.filter` method
|
|
805
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.filter
|
|
806
|
-
filter: createMethod$1(2),
|
|
807
|
-
// `Array.prototype.some` method
|
|
808
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.some
|
|
809
|
-
some: createMethod$1(3),
|
|
810
|
-
// `Array.prototype.every` method
|
|
811
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.every
|
|
812
|
-
every: createMethod$1(4),
|
|
813
|
-
// `Array.prototype.find` method
|
|
814
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.find
|
|
815
|
-
find: createMethod$1(5),
|
|
816
|
-
// `Array.prototype.findIndex` method
|
|
817
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
|
|
818
|
-
findIndex: createMethod$1(6)
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
var $map = arrayIteration.map;
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
|
|
826
|
-
// FF49- issue
|
|
827
|
-
var USES_TO_LENGTH$1 = arrayMethodUsesToLength('map');
|
|
828
|
-
|
|
829
|
-
// `Array.prototype.map` method
|
|
830
|
-
// https://tc39.github.io/ecma262/#sec-array.prototype.map
|
|
831
|
-
// with adding support of @@species
|
|
832
|
-
_export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH$1 }, {
|
|
833
|
-
map: function map(callbackfn /* , thisArg */) {
|
|
834
|
-
return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
// `Date.now` method
|
|
839
|
-
// https://tc39.github.io/ecma262/#sec-date.now
|
|
840
|
-
_export({ target: 'Date', stat: true }, {
|
|
841
|
-
now: function now() {
|
|
842
|
-
return new Date().getTime();
|
|
843
|
-
}
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
var DatePrototype = Date.prototype;
|
|
847
|
-
var INVALID_DATE = 'Invalid Date';
|
|
848
|
-
var TO_STRING = 'toString';
|
|
849
|
-
var nativeDateToString = DatePrototype[TO_STRING];
|
|
850
|
-
var getTime = DatePrototype.getTime;
|
|
851
|
-
|
|
852
|
-
// `Date.prototype.toString` method
|
|
853
|
-
// https://tc39.github.io/ecma262/#sec-date.prototype.tostring
|
|
854
|
-
if (new Date(NaN) + '' != INVALID_DATE) {
|
|
855
|
-
redefine(DatePrototype, TO_STRING, function toString() {
|
|
856
|
-
var value = getTime.call(this);
|
|
857
|
-
// eslint-disable-next-line no-self-compare
|
|
858
|
-
return value === value ? nativeDateToString.call(this) : INVALID_DATE;
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
// `Object.keys` method
|
|
863
|
-
// https://tc39.github.io/ecma262/#sec-object.keys
|
|
864
|
-
var objectKeys = Object.keys || function keys(O) {
|
|
865
|
-
return objectKeysInternal(O, enumBugKeys);
|
|
866
|
-
};
|
|
867
|
-
|
|
868
|
-
var nativeAssign = Object.assign;
|
|
869
|
-
var defineProperty$1 = Object.defineProperty;
|
|
870
|
-
|
|
871
|
-
// `Object.assign` method
|
|
872
|
-
// https://tc39.github.io/ecma262/#sec-object.assign
|
|
873
|
-
var objectAssign = !nativeAssign || fails(function () {
|
|
874
|
-
// should have correct order of operations (Edge bug)
|
|
875
|
-
if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty$1({}, 'a', {
|
|
876
|
-
enumerable: true,
|
|
877
|
-
get: function () {
|
|
878
|
-
defineProperty$1(this, 'b', {
|
|
879
|
-
value: 3,
|
|
880
|
-
enumerable: false
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
}), { b: 2 })).b !== 1) return true;
|
|
884
|
-
// should work with symbols and should have deterministic property order (V8 bug)
|
|
885
|
-
var A = {};
|
|
886
|
-
var B = {};
|
|
887
|
-
// eslint-disable-next-line no-undef
|
|
888
|
-
var symbol = Symbol();
|
|
889
|
-
var alphabet = 'abcdefghijklmnopqrst';
|
|
890
|
-
A[symbol] = 7;
|
|
891
|
-
alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
|
892
|
-
return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
|
|
893
|
-
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
|
|
894
|
-
var T = toObject(target);
|
|
895
|
-
var argumentsLength = arguments.length;
|
|
896
|
-
var index = 1;
|
|
897
|
-
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
|
|
898
|
-
var propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
899
|
-
while (argumentsLength > index) {
|
|
900
|
-
var S = indexedObject(arguments[index++]);
|
|
901
|
-
var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
|
|
902
|
-
var length = keys.length;
|
|
903
|
-
var j = 0;
|
|
904
|
-
var key;
|
|
905
|
-
while (length > j) {
|
|
906
|
-
key = keys[j++];
|
|
907
|
-
if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
|
|
908
|
-
}
|
|
909
|
-
} return T;
|
|
910
|
-
} : nativeAssign;
|
|
911
|
-
|
|
912
|
-
// `Object.assign` method
|
|
913
|
-
// https://tc39.github.io/ecma262/#sec-object.assign
|
|
914
|
-
_export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, {
|
|
915
|
-
assign: objectAssign
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
|
|
919
|
-
|
|
920
|
-
// `Object.keys` method
|
|
921
|
-
// https://tc39.github.io/ecma262/#sec-object.keys
|
|
922
|
-
_export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
|
|
923
|
-
keys: function keys(it) {
|
|
924
|
-
return objectKeys(toObject(it));
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
function _classCallCheck(instance, Constructor) {
|
|
929
|
-
if (!(instance instanceof Constructor)) {
|
|
930
|
-
throw new TypeError("Cannot call a class as a function");
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
function _defineProperties(target, props) {
|
|
935
|
-
for (var i = 0; i < props.length; i++) {
|
|
936
|
-
var descriptor = props[i];
|
|
937
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
938
|
-
descriptor.configurable = true;
|
|
939
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
940
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
945
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
946
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
947
|
-
return Constructor;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
var defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
|
|
951
|
-
var isIos = /(iPhone|iPod|iPad)/.test(navigator.userAgent);
|
|
952
|
-
|
|
953
|
-
function err(msg) {
|
|
954
|
-
console.error("[SpyClient_log]".concat(msg));
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
function stringify(obj) {
|
|
958
|
-
return Object.keys(obj).map(function (key) {
|
|
959
|
-
var value = obj[key];
|
|
960
|
-
|
|
961
|
-
if (typeof value === 'undefined') {
|
|
962
|
-
value = '';
|
|
963
|
-
} else if (typeof value !== 'string') {
|
|
964
|
-
value = JSON.stringify(value);
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
return encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
968
|
-
}).join('&');
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
var SpyClient = function () {
|
|
972
|
-
function SpyClient(option) {
|
|
973
|
-
_classCallCheck(this, SpyClient);
|
|
974
|
-
|
|
975
|
-
this.sample = {};
|
|
976
|
-
this.markCache = {};
|
|
977
|
-
|
|
978
|
-
if (!option.pid) {
|
|
979
|
-
throw new Error('pid is required');
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
this.option = {
|
|
983
|
-
pid: option.pid,
|
|
984
|
-
lid: option.lid,
|
|
985
|
-
check: option.check !== false,
|
|
986
|
-
sample: option.sample,
|
|
987
|
-
logServer: option.logServer || defaultLogServer
|
|
988
|
-
};
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
_createClass(SpyClient, [{
|
|
992
|
-
key: "send",
|
|
993
|
-
value: function send(query) {
|
|
994
|
-
if (!this.check(query)) {
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
if (typeof query.sample === 'number') {
|
|
999
|
-
if (Math.random() > query.sample) {
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
1002
|
-
} else if (typeof this.option.sample === 'number' && Math.random() > this.option.sample) {
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
query = Object.assign({
|
|
1007
|
-
pid: this.option.pid,
|
|
1008
|
-
lid: this.option.lid,
|
|
1009
|
-
ts: Date.now(),
|
|
1010
|
-
group: 'common'
|
|
1011
|
-
}, query);
|
|
1012
|
-
delete query.sample;
|
|
1013
|
-
var url = this.option.logServer + stringify(query);
|
|
1014
|
-
|
|
1015
|
-
if (!(!isIos && navigator.sendBeacon && navigator.sendBeacon(url))) {
|
|
1016
|
-
new Image().src = url;
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}, {
|
|
1020
|
-
key: "check",
|
|
1021
|
-
value: function check(query) {
|
|
1022
|
-
if (!this.option.check) {
|
|
1023
|
-
return true;
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
var types = ['perf', 'except', 'dist', 'count'];
|
|
1027
|
-
|
|
1028
|
-
if (types.indexOf(query.type) === -1) {
|
|
1029
|
-
err('type only is one of ' + types.join(', '));
|
|
1030
|
-
return false;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
if (query.group && query.group.length > 30) {
|
|
1034
|
-
err('group length execeeds 30');
|
|
1035
|
-
return false;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
var simpleReg = /^[a-zA-Z0-9-_]{0,30}$/;
|
|
1039
|
-
|
|
1040
|
-
if (query.type === 'except') {
|
|
1041
|
-
if (!(typeof query.info.msg === 'string' && query.info.msg.length)) {
|
|
1042
|
-
err('info.msg field must be not empty and is String');
|
|
1043
|
-
return false;
|
|
1044
|
-
}
|
|
1045
|
-
} else {
|
|
1046
|
-
for (var _i = 0, _Object$keys = Object.keys(query.info); _i < _Object$keys.length; _i++) {
|
|
1047
|
-
var infoKey = _Object$keys[_i];
|
|
1048
|
-
|
|
1049
|
-
if (!simpleReg.test(infoKey)) {
|
|
1050
|
-
err("info.".concat(infoKey, " is unexpected. ") + 'Length must be not more than 30. ' + 'Supported chars: a-zA-Z0-9-_');
|
|
1051
|
-
return false;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
var infoVal = query.info[infoKey];
|
|
1055
|
-
|
|
1056
|
-
if (query.type === 'dist') {
|
|
1057
|
-
if (infoVal.length > 30) {
|
|
1058
|
-
err("info.".concat(infoKey, " value length execeeds 30 when type == 'dist'"));
|
|
1059
|
-
return false;
|
|
1060
|
-
}
|
|
1061
|
-
} else if (typeof infoVal !== 'number') {
|
|
1062
|
-
err("info.".concat(infoKey, " value must be number"));
|
|
1063
|
-
return false;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
if (query.dim) {
|
|
1069
|
-
for (var _i2 = 0, _Object$keys2 = Object.keys(query.dim); _i2 < _Object$keys2.length; _i2++) {
|
|
1070
|
-
var dimKey = _Object$keys2[_i2];
|
|
1071
|
-
|
|
1072
|
-
if (!simpleReg.test(dimKey)) {
|
|
1073
|
-
err("dim key [".concat(dimKey, "] is unexpected. ") + 'Length must be not more than 30. ' + 'Supported chars: a-zA-Z0-9-_');
|
|
1074
|
-
return false;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
var dimVal = query.dim[dimKey];
|
|
1078
|
-
|
|
1079
|
-
if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
|
|
1080
|
-
err("dim.".concat(dimKey, " value [").concat(dimVal, "] is unexpected. ") + 'Length must be not more than 30. ' + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
|
|
1081
|
-
return false;
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
return true;
|
|
1087
|
-
}
|
|
1088
|
-
}, {
|
|
1089
|
-
key: "sendPerf",
|
|
1090
|
-
value: function sendPerf(option) {
|
|
1091
|
-
this.send(Object.assign({
|
|
1092
|
-
type: 'perf'
|
|
1093
|
-
}, option));
|
|
1094
|
-
}
|
|
1095
|
-
}, {
|
|
1096
|
-
key: "sendExcept",
|
|
1097
|
-
value: function sendExcept(option) {
|
|
1098
|
-
this.send(Object.assign({
|
|
1099
|
-
type: 'except'
|
|
1100
|
-
}, option));
|
|
1101
|
-
}
|
|
1102
|
-
}, {
|
|
1103
|
-
key: "sendDist",
|
|
1104
|
-
value: function sendDist(option) {
|
|
1105
|
-
this.send(Object.assign({
|
|
1106
|
-
type: 'dist'
|
|
1107
|
-
}, option));
|
|
1108
|
-
}
|
|
1109
|
-
}, {
|
|
1110
|
-
key: "sendCount",
|
|
1111
|
-
value: function sendCount(option) {
|
|
1112
|
-
this.send(Object.assign({
|
|
1113
|
-
type: 'count'
|
|
1114
|
-
}, option));
|
|
1115
|
-
}
|
|
1116
|
-
}, {
|
|
1117
|
-
key: "sendExceptForError",
|
|
1118
|
-
value: function sendExceptForError(e, option) {
|
|
1119
|
-
var newOpt = Object.assign({}, option);
|
|
1120
|
-
newOpt.info = Object.assign({}, option.info || {}, {
|
|
1121
|
-
msg: e.message,
|
|
1122
|
-
stack: e.stack
|
|
1123
|
-
});
|
|
1124
|
-
this.sendExcept(newOpt);
|
|
1125
|
-
}
|
|
1126
|
-
}, {
|
|
1127
|
-
key: "startMark",
|
|
1128
|
-
value: function startMark(sign) {
|
|
1129
|
-
this.markCache[sign] = {
|
|
1130
|
-
start: Date.now()
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
}, {
|
|
1134
|
-
key: "endMark",
|
|
1135
|
-
value: function endMark(sign) {
|
|
1136
|
-
if (this.markCache[sign]) {
|
|
1137
|
-
this.markCache[sign].total = Date.now() - this.markCache[sign].start;
|
|
1138
|
-
return this.markCache[sign].total;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
return 0;
|
|
1142
|
-
}
|
|
1143
|
-
}, {
|
|
1144
|
-
key: "clearMark",
|
|
1145
|
-
value: function clearMark(sign) {
|
|
1146
|
-
if (this.markCache[sign]) {
|
|
1147
|
-
delete this.markCache[sign];
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
}, {
|
|
1151
|
-
key: "getAllMark",
|
|
1152
|
-
value: function getAllMark() {
|
|
1153
|
-
var ret = {};
|
|
1154
|
-
|
|
1155
|
-
for (var _i3 = 0, _Object$keys3 = Object.keys(this.markCache); _i3 < _Object$keys3.length; _i3++) {
|
|
1156
|
-
var sign = _Object$keys3[_i3];
|
|
1157
|
-
ret[sign] = this.markCache[sign].total;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
return ret;
|
|
1161
|
-
}
|
|
1162
|
-
}, {
|
|
1163
|
-
key: "clearAllMark",
|
|
1164
|
-
value: function clearAllMark() {
|
|
1165
|
-
this.markCache = {};
|
|
1166
|
-
}
|
|
1167
|
-
}]);
|
|
1168
|
-
|
|
1169
|
-
return SpyClient;
|
|
1170
|
-
}();
|
|
1171
|
-
|
|
1172
|
-
return SpyClient;
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file utils
|
|
6
|
+
* @author kaivean
|
|
7
|
+
*/
|
|
8
|
+
function assign() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var __assign = Object.assign || function __assign(t) {
|
|
14
|
+
for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
// eslint-disable-next-line prefer-rest-params
|
|
16
|
+
s = arguments[i];
|
|
17
|
+
for (var p in s) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) {
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, args);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @file SpyClient
|
|
30
|
+
* @author kaivean
|
|
31
|
+
*/
|
|
32
|
+
var defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
|
|
33
|
+
var isIos = /(iPhone|iPod|iPad)/.test(navigator.userAgent);
|
|
34
|
+
function err(msg) {
|
|
35
|
+
console.error("[SpyClient_log]" + msg);
|
|
36
|
+
// throw new Error(msg);
|
|
37
|
+
}
|
|
38
|
+
function stringify(obj) {
|
|
39
|
+
return Object.keys(obj).map(function (key) {
|
|
40
|
+
var value = obj[key];
|
|
41
|
+
if (typeof value === 'undefined') {
|
|
42
|
+
value = '';
|
|
43
|
+
}
|
|
44
|
+
else if (typeof value !== 'string') {
|
|
45
|
+
value = JSON.stringify(value);
|
|
46
|
+
}
|
|
47
|
+
return encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
48
|
+
}).join('&');
|
|
49
|
+
}
|
|
50
|
+
var SpyClient = /** @class */ (function () {
|
|
51
|
+
function SpyClient(option) {
|
|
52
|
+
this.sample = {};
|
|
53
|
+
this.markCache = {};
|
|
54
|
+
if (!option.pid) {
|
|
55
|
+
throw new Error('pid is required');
|
|
56
|
+
}
|
|
57
|
+
this.option = {
|
|
58
|
+
pid: option.pid,
|
|
59
|
+
lid: option.lid,
|
|
60
|
+
check: option.check !== false,
|
|
61
|
+
sample: option.sample,
|
|
62
|
+
logServer: option.logServer || defaultLogServer,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
SpyClient.prototype.send = function (query) {
|
|
66
|
+
if (!this.check(query)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// 当前api设置了抽样,
|
|
70
|
+
if (typeof query.sample === 'number') {
|
|
71
|
+
if (Math.random() > query.sample) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (typeof this.option.sample === 'number' && Math.random() > this.option.sample) { // 否则,用全局抽样
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
query = assign({
|
|
79
|
+
pid: this.option.pid,
|
|
80
|
+
lid: this.option.lid,
|
|
81
|
+
ts: Date.now(),
|
|
82
|
+
group: 'common',
|
|
83
|
+
}, query);
|
|
84
|
+
delete query.sample;
|
|
85
|
+
var url = this.option.logServer + stringify(query);
|
|
86
|
+
// 目前服务器端支持sendBeacon的post请求,可以优先采用,该api可以降低打点丢失率
|
|
87
|
+
// 但是ios有些问题:在webkit浏览内核环境下,beacon requests的请求方式存在证书验证的bug.
|
|
88
|
+
// 修复说明在如下链接中:https://bugs.webkit.org/show_bug.cgi?id=193508
|
|
89
|
+
// 但是目前为止,在iOS12.2版本中该问题依旧存在
|
|
90
|
+
if (!(!isIos
|
|
91
|
+
&& navigator.sendBeacon
|
|
92
|
+
&& navigator.sendBeacon(url))) {
|
|
93
|
+
(new Image()).src = url;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
SpyClient.prototype.check = function (query) {
|
|
97
|
+
if (!this.option.check) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
var types = ['perf', 'except', 'dist', 'count'];
|
|
101
|
+
if (types.indexOf(query.type) === -1) {
|
|
102
|
+
err('type only is one of ' + types.join(', '));
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (query.group && query.group.length > 30) {
|
|
106
|
+
err('group length execeeds 30');
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
var simpleReg = /^[a-zA-Z0-9-_]{0,30}$/;
|
|
110
|
+
if (query.type === 'except') {
|
|
111
|
+
if (!(typeof query.info.msg === 'string' && query.info.msg.length)) {
|
|
112
|
+
err('info.msg field must be not empty and is String');
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
|
|
118
|
+
var infoKey = _a[_i];
|
|
119
|
+
if (!simpleReg.test(infoKey)) {
|
|
120
|
+
err("info." + infoKey + " is unexpected. "
|
|
121
|
+
+ 'Length must be not more than 30. '
|
|
122
|
+
+ 'Supported chars: a-zA-Z0-9-_');
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
var infoVal = query.info[infoKey];
|
|
126
|
+
if (query.type === 'dist') {
|
|
127
|
+
if (infoVal.length > 30) {
|
|
128
|
+
err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (typeof infoVal !== 'number') {
|
|
133
|
+
err("info." + infoKey + " value must be number");
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (query.dim) {
|
|
139
|
+
for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
|
|
140
|
+
var dimKey = _c[_b];
|
|
141
|
+
if (!simpleReg.test(dimKey)) {
|
|
142
|
+
err("dim key [" + dimKey + "] is unexpected. "
|
|
143
|
+
+ 'Length must be not more than 30. '
|
|
144
|
+
+ 'Supported chars: a-zA-Z0-9-_');
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
var dimVal = query.dim[dimKey];
|
|
148
|
+
if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
|
|
149
|
+
err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
|
|
150
|
+
+ 'Length must be not more than 30. '
|
|
151
|
+
+ 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* @param option 配置
|
|
161
|
+
*/
|
|
162
|
+
SpyClient.prototype.sendPerf = function (option) {
|
|
163
|
+
this.send(assign({
|
|
164
|
+
type: 'perf',
|
|
165
|
+
}, option));
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* @param option 错误配置项
|
|
170
|
+
*/
|
|
171
|
+
SpyClient.prototype.sendExcept = function (option) {
|
|
172
|
+
this.send(assign({
|
|
173
|
+
type: 'except',
|
|
174
|
+
}, option));
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
* @param option 配置
|
|
179
|
+
*/
|
|
180
|
+
SpyClient.prototype.sendDist = function (option) {
|
|
181
|
+
this.send(assign({
|
|
182
|
+
type: 'dist',
|
|
183
|
+
}, option));
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param option 配置
|
|
188
|
+
*/
|
|
189
|
+
SpyClient.prototype.sendCount = function (option) {
|
|
190
|
+
this.send(assign({
|
|
191
|
+
type: 'count',
|
|
192
|
+
}, option));
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
* @param e 错误实例
|
|
197
|
+
* @param option 错误配置项
|
|
198
|
+
*/
|
|
199
|
+
SpyClient.prototype.sendExceptForError = function (e, option) {
|
|
200
|
+
var newOpt = assign({}, option);
|
|
201
|
+
newOpt.info = assign({}, option.info || {}, {
|
|
202
|
+
msg: e.message,
|
|
203
|
+
stack: e.stack,
|
|
204
|
+
});
|
|
205
|
+
this.sendExcept(newOpt);
|
|
206
|
+
};
|
|
207
|
+
SpyClient.prototype.startMark = function (sign) {
|
|
208
|
+
this.markCache[sign] = {
|
|
209
|
+
start: Date.now(),
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
SpyClient.prototype.endMark = function (sign) {
|
|
213
|
+
if (this.markCache[sign]) {
|
|
214
|
+
this.markCache[sign].total = Date.now() - this.markCache[sign].start;
|
|
215
|
+
return this.markCache[sign].total;
|
|
216
|
+
}
|
|
217
|
+
return 0;
|
|
218
|
+
};
|
|
219
|
+
SpyClient.prototype.clearMark = function (sign) {
|
|
220
|
+
if (this.markCache[sign]) {
|
|
221
|
+
delete this.markCache[sign];
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
SpyClient.prototype.getAllMark = function () {
|
|
225
|
+
var ret = {};
|
|
226
|
+
for (var _i = 0, _a = Object.keys(this.markCache); _i < _a.length; _i++) {
|
|
227
|
+
var sign = _a[_i];
|
|
228
|
+
ret[sign] = this.markCache[sign].total;
|
|
229
|
+
}
|
|
230
|
+
return ret;
|
|
231
|
+
};
|
|
232
|
+
SpyClient.prototype.clearAllMark = function () {
|
|
233
|
+
this.markCache = {};
|
|
234
|
+
};
|
|
235
|
+
return SpyClient;
|
|
236
|
+
}());
|
|
237
|
+
|
|
238
|
+
return SpyClient;
|
|
1173
239
|
|
|
1174
240
|
}());
|