hina-cloud-js-sdk 3.1.8 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/dist/hina.cjs.js +1 -0
  2. package/dist/hina.esm.full.js +1 -0
  3. package/dist/hina.esm.js +1 -0
  4. package/dist/hina.full.js +1 -0
  5. package/dist/hina.iife.js +1 -0
  6. package/dist/index.d.ts +411 -0
  7. package/package.json +28 -38
  8. package/readme.md +1 -0
  9. package/.eslintrc.js +0 -12
  10. package/.gitlab-ci.yml +0 -16
  11. package/.vscode/settings.json +0 -5
  12. package/build/hina.cjs.min.js +0 -1
  13. package/build/hina.esm.min.js +0 -1
  14. package/build/hina.min.js +0 -1
  15. package/build/hotAnalyse.min.js +0 -1
  16. package/packages/core/dist/index.cjs.js +0 -64
  17. package/packages/core/dist/index.cjs.js.map +0 -1
  18. package/packages/core/dist/index.d.ts +0 -45
  19. package/packages/core/dist/index.esm.js +0 -62
  20. package/packages/core/dist/index.esm.js.map +0 -1
  21. package/packages/core/dist/index.global.js +0 -1199
  22. package/packages/core/dist/index.global.js.map +0 -1
  23. package/packages/core/dist/index.js +0 -1200
  24. package/packages/core/dist/index.js.map +0 -1
  25. package/packages/monitor/dist/index.cjs.js +0 -150
  26. package/packages/monitor/dist/index.cjs.js.map +0 -1
  27. package/packages/monitor/dist/index.d.ts +0 -35
  28. package/packages/monitor/dist/index.esm.js +0 -145
  29. package/packages/monitor/dist/index.esm.js.map +0 -1
  30. package/packages/monitor/dist/index.global.js +0 -1343
  31. package/packages/monitor/dist/index.global.js.map +0 -1
  32. package/packages/monitor/dist/index.js +0 -1344
  33. package/packages/monitor/dist/index.js.map +0 -1
  34. package/packages/track/dist/index.cjs.js +0 -1930
  35. package/packages/track/dist/index.cjs.js.map +0 -1
  36. package/packages/track/dist/index.d.ts +0 -212
  37. package/packages/track/dist/index.esm.js +0 -1925
  38. package/packages/track/dist/index.esm.js.map +0 -1
  39. package/packages/track/dist/index.global.js +0 -4259
  40. package/packages/track/dist/index.global.js.map +0 -1
  41. package/packages/track/dist/index.js +0 -4260
  42. package/packages/track/dist/index.js.map +0 -1
  43. package/packages/types/dist/index.d.ts +0 -603
  44. package/packages/types/dist/index.esm.js +0 -25
  45. package/packages/types/dist/index.esm.js.map +0 -1
  46. package/packages/utils/dist/index.cjs.js +0 -1535
  47. package/packages/utils/dist/index.cjs.js.map +0 -1
  48. package/packages/utils/dist/index.d.ts +0 -394
  49. package/packages/utils/dist/index.esm.js +0 -1465
  50. package/packages/utils/dist/index.esm.js.map +0 -1
  51. package/packages/utils/dist/index.global.js +0 -2507
  52. package/packages/utils/dist/index.global.js.map +0 -1
  53. package/packages/utils/dist/index.js +0 -2508
  54. package/packages/utils/dist/index.js.map +0 -1
  55. package/report.json +0 -101
  56. package/rollup.config.epm.js +0 -42
  57. package/rollup.config.sdk.js +0 -42
  58. package/sonar-project.properties +0 -3
@@ -1,2508 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.HinaCloudUtils = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- var MAX_REFERRER_STRING_LENGTH = 2000;
8
- var MAX_STRING_LENGTH = 1024 * 4;
9
- var PV_LIB_VERSION = '4.0.0';
10
- var EPM_LIB_VERSION = '1.0.0';
11
- var COOKIE_TEST_NAME = 'hinasdk_domain_test';
12
- var utmTypes = [
13
- 'utm_source',
14
- 'utm_medium',
15
- 'utm_campaign',
16
- 'utm_content',
17
- 'utm_term'
18
- ];
19
- var searchTypes = [
20
- 'www.baidu.',
21
- 'm.baidu.',
22
- 'm.sm.cn',
23
- 'so.com',
24
- 'sogou.com',
25
- 'youdao.com',
26
- 'google.',
27
- 'yahoo.com/',
28
- 'bing.com/',
29
- 'ask.com/'
30
- ];
31
- var socialTypes = [
32
- 'weibo.com',
33
- 'renren.com',
34
- 'kaixin001.com',
35
- 'douban.com',
36
- 'qzone.qq.com',
37
- 'zhihu.com',
38
- 'tieba.baidu.com',
39
- 'weixin.qq.com'
40
- ];
41
- var searchKeywords = {
42
- baidu: ['wd', 'word', 'kw', 'keyword'],
43
- google: 'q',
44
- bing: 'q',
45
- yahoo: 'p',
46
- sogou: ['query', 'keyword'],
47
- so: 'q',
48
- sm: 'q'
49
- };
50
-
51
- var toString = Object.prototype.toString;
52
- function isObject(val) {
53
- return Object.prototype.toString.call(val) === '[object Object]';
54
- }
55
- function isUndefined(val) {
56
- return val === void 0;
57
- }
58
- function isValid(val) {
59
- return val !== null && val !== undefined;
60
- }
61
- function isArray(val) {
62
- return Array.isArray(val);
63
- }
64
- function isDate(val) {
65
- return toString.call(val) === '[object Date]';
66
- }
67
- function isFunction(val) {
68
- return typeof val === 'function';
69
- }
70
- function isString(val) {
71
- return typeof val === 'string';
72
- }
73
- function isNumber(val) {
74
- return typeof val === 'number';
75
- }
76
- function isBoolean(val) {
77
- return typeof val === 'boolean';
78
- }
79
- function noop() { }
80
- function isJSONString(val) {
81
- try {
82
- JSON.parse(val);
83
- }
84
- catch (e) {
85
- return false;
86
- }
87
- return true;
88
- }
89
- function safeJSONParse(val) {
90
- try {
91
- return JSON.parse(val);
92
- }
93
- catch (e) { }
94
- return val;
95
- }
96
- function isEmptyObject(obj) {
97
- return Object.keys(obj).length === 0;
98
- }
99
- function nowStamp() {
100
- if (Date.now && isFunction(Date.now)) {
101
- return Date.now();
102
- }
103
- return new Date().getTime();
104
- }
105
- function merge() {
106
- var args = [];
107
- for (var _i = 0; _i < arguments.length; _i++) {
108
- args[_i] = arguments[_i];
109
- }
110
- var result = Object.create(null);
111
- args.forEach(function (obj) {
112
- if (obj) {
113
- Object.keys(obj).forEach(function (key) {
114
- var val = obj[key];
115
- if (isObject(val)) {
116
- if (isObject(result[key])) {
117
- result[key] = merge(result[key], val);
118
- }
119
- else {
120
- result[key] = merge(val);
121
- }
122
- }
123
- else {
124
- result[key] = val;
125
- }
126
- });
127
- }
128
- });
129
- return result;
130
- }
131
- function stripEmptyProperties(obj) {
132
- return Object.keys(obj).reduce(function (acc, key) {
133
- if (isValid(obj[key]) && obj[key] !== '') {
134
- acc[key] = obj[key];
135
- }
136
- return acc;
137
- }, {});
138
- }
139
- /**
140
- * 返回URL对象
141
- * @param url
142
- */
143
- function getURL(url) {
144
- var urlObj = {};
145
- try {
146
- urlObj = new URL(url);
147
- }
148
- catch (e) { }
149
- return urlObj;
150
- }
151
- /**
152
- * 获取URL上的search参数
153
- * @param queryString
154
- */
155
- function getURLSearchParams(queryString) {
156
- queryString = queryString || '';
157
- var args = {};
158
- var searchParams = new URLSearchParams(queryString);
159
- searchParams.forEach(function (value, key) {
160
- args[key] = value;
161
- });
162
- return args;
163
- }
164
- function formatDecimal(num, decimal) {
165
- if (decimal === void 0) { decimal = 3; }
166
- if (!num) {
167
- return num;
168
- }
169
- var str = num.toString();
170
- var index = str.indexOf('.');
171
- if (index !== -1) {
172
- str = str.substring(0, index + decimal + 1);
173
- }
174
- else {
175
- str = str.substring(0);
176
- }
177
- return parseFloat(str);
178
- }
179
- /**
180
- * 获取cookie顶级域名
181
- * @param hostname
182
- */
183
- function getCookieTopLevelDomain(hostname) {
184
- hostname = hostname || window.location.hostname;
185
- if (!/^[a-zA-Z0-9\u4e00-\u9fa5\-\\.]+$/.exec(hostname)) {
186
- hostname = '';
187
- }
188
- var splitResult = hostname.split('.');
189
- if (splitResult.length >= 2 && !/^(\d+\.)+\d+$/.test(hostname)) {
190
- var domainStr = ".".concat(splitResult.splice(splitResult.length - 1, 1));
191
- while (splitResult.length > 0) {
192
- domainStr = ".".concat(splitResult.splice(splitResult.length - 1, 1)).concat(domainStr);
193
- document.cookie = "".concat(COOKIE_TEST_NAME, "=true; path=/; domain=").concat(domainStr);
194
- if (document.cookie.indexOf("".concat(COOKIE_TEST_NAME, "=true")) !== -1) {
195
- document.cookie = "".concat(COOKIE_TEST_NAME, "=true; path=/; domain=").concat(domainStr, "; max-age=0");
196
- return domainStr;
197
- }
198
- }
199
- }
200
- return '';
201
- }
202
- /**
203
- * 获取当前页面的domain
204
- * 注意这里的domain,并不是普通的window.location.hostname值,而是拥有相同子域名的域名,因为浏览器的cookie是二级域名共享的
205
- */
206
- function getCurrentDomain() {
207
- var cookieDomain = getCookieTopLevelDomain();
208
- if (cookieDomain === '') {
209
- return 'url解析失败';
210
- }
211
- return cookieDomain;
212
- }
213
- /**
214
- * 获取当前页面的referrer
215
- */
216
- function getReferrer(value) {
217
- var referrer = value || document.referrer;
218
- if (typeof referrer !== 'string') {
219
- return "referrer exception".concat(String(referrer));
220
- }
221
- if (referrer.startsWith('https://www.baidu.com/')) {
222
- referrer = referrer.split('?')[0];
223
- }
224
- referrer = referrer.slice(0, MAX_REFERRER_STRING_LENGTH);
225
- return typeof referrer === 'string' ? referrer : '';
226
- }
227
- /**
228
- * 获取hostname
229
- * @param url
230
- * @param defaultValue
231
- */
232
- function getHostname(url, defaultValue) {
233
- if (!defaultValue || typeof defaultValue !== 'string') {
234
- defaultValue = 'hostname解析异常';
235
- }
236
- if (!url) {
237
- return defaultValue;
238
- }
239
- var hostname = getURL(url).hostname || '';
240
- return hostname || defaultValue;
241
- }
242
- /**
243
- * 此函数有两个作用
244
- * 1:referrer为空时,直接返回true
245
- * 2:referrer不为空时,判断是否是外链流量 document.referrer对应的hostname是否和当前URL的hostname是否相同
246
- * @param referrer
247
- */
248
- function isReferralTraffic(referrer) {
249
- referrer = referrer || document.referrer;
250
- if (referrer === '') {
251
- return true;
252
- }
253
- return (getCookieTopLevelDomain(getHostname(referrer)) !== getCookieTopLevelDomain());
254
- }
255
- /**
256
- * 获取浏览器scrollTop
257
- */
258
- function getScrollTop() {
259
- return document.documentElement.scrollTop || document.body.scrollTop || 0;
260
- }
261
- /**
262
- * 获取浏览器scrollLeft
263
- */
264
- function getScrollLeft() {
265
- return document.documentElement.scrollLeft || document.body.scrollLeft || 0;
266
- }
267
- /**
268
- * 获取浏览器可视高度
269
- */
270
- function getScreenHeight() {
271
- return (window.innerHeight ||
272
- document.documentElement.clientHeight ||
273
- document.body.clientHeight ||
274
- 0);
275
- }
276
- /**
277
- * 获取浏览器可视宽度
278
- */
279
- function getScreenWidth() {
280
- return (window.innerWidth ||
281
- document.documentElement.clientWidth ||
282
- document.body.clientWidth ||
283
- 0);
284
- }
285
- /**
286
- * 获取浏览器网络类型
287
- */
288
- function networkType() {
289
- if (navigator.connection === undefined)
290
- return 'unknown';
291
- var connection = navigator.connection;
292
- if (connection.effectiveType) {
293
- return connection.effectiveType;
294
- }
295
- if (connection.type) {
296
- return connection.type;
297
- }
298
- return '取值异常';
299
- }
300
- /**
301
- * 生成随机数
302
- */
303
- function getRandom() {
304
- var date = new Date();
305
- var seed = date.getTime();
306
- var num = Math.floor(Math.random() * 1000000);
307
- return "".concat(seed, "_").concat(num);
308
- }
309
- var ListenPageState = /** @class */ (function () {
310
- function ListenPageState(payload) {
311
- this.visibleHandler = function () { };
312
- this.hiddenHandler = function () { };
313
- var visible = payload.visible, hidden = payload.hidden;
314
- if (isFunction(visible)) {
315
- this.visibleHandler = visible;
316
- }
317
- if (isFunction(hidden)) {
318
- this.hiddenHandler = hidden;
319
- }
320
- this.init();
321
- }
322
- ListenPageState.prototype.isSupport = function () {
323
- return typeof document.hidden !== 'undefined';
324
- };
325
- ListenPageState.prototype.init = function () {
326
- var _this = this;
327
- if (this.isSupport()) {
328
- document.addEventListener('visibilitychange', function () {
329
- if (document.hidden) {
330
- _this.hiddenHandler();
331
- }
332
- else {
333
- _this.visibleHandler();
334
- }
335
- });
336
- }
337
- else {
338
- window.addEventListener('focus', this.visibleHandler);
339
- window.addEventListener('blur', this.hiddenHandler);
340
- }
341
- };
342
- return ListenPageState;
343
- }());
344
- function generatorUUID() {
345
- var T = function () {
346
- var d = nowStamp();
347
- var i = 0;
348
- while (d === nowStamp()) {
349
- i++;
350
- }
351
- return d.toString(16) + i.toString(16);
352
- };
353
- var R = function () {
354
- return Math.random().toString(16).replace('.', '');
355
- };
356
- var UA = function () {
357
- var ua = navigator.userAgent;
358
- var i;
359
- var ch;
360
- var buffer = [];
361
- var ret = 0;
362
- function xor(result, byteArray) {
363
- var j;
364
- var tmp = 0;
365
- for (j = 0; j < byteArray.length; j++) {
366
- tmp |= buffer[j] << (j * 8);
367
- }
368
- return result ^ tmp;
369
- }
370
- for (i = 0; i < ua.length; i++) {
371
- ch = ua.charCodeAt(i);
372
- buffer.unshift(ch & 0xff);
373
- if (buffer.length >= 4) {
374
- ret = xor(ret, buffer);
375
- buffer = [];
376
- }
377
- }
378
- if (buffer.length > 0) {
379
- ret = xor(ret, buffer);
380
- }
381
- return ret.toString(16);
382
- };
383
- var se = String(window.screen.height * window.screen.width);
384
- if (se && /\d{5,}/.test(se)) {
385
- // @ts-ignore
386
- se = se.toString(16);
387
- }
388
- else {
389
- se = String(Math.random() * 31242)
390
- .replace('.', '')
391
- .slice(0, 8);
392
- }
393
- var val = "".concat(T(), "-").concat(R(), "-").concat(UA(), "-").concat(se, "-").concat(T());
394
- if (val) {
395
- return val;
396
- }
397
- return (String(Math.random()) +
398
- String(Math.random()) +
399
- String(Math.random())).slice(2, 15);
400
- }
401
- /**
402
- * 查找指定url中的参数
403
- * replace(/[\[]/, "\\[") 将 [ 替换为 \[。
404
- * replace(/[\]]/, "\\]") 将 ] 替换为 \]。
405
- * example[123]=>example\[123\]
406
- * @param url
407
- * @param key
408
- */
409
- function getQueryParam(url, key) {
410
- key = key.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
411
- url = decodeURIComponent(url);
412
- var regex = new RegExp("[\\?&]".concat(key, "=([^&#]*)"));
413
- var results = regex.exec(url);
414
- if (results === null ||
415
- (results && typeof results[1] !== 'string' && results[1].length)) {
416
- return '';
417
- }
418
- return decodeURIComponent(results[1]);
419
- }
420
- function base64Encode(str) {
421
- try {
422
- return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (e, t) {
423
- return String.fromCharCode(Number("0x".concat(t)));
424
- }));
425
- }
426
- catch (e) {
427
- return str;
428
- }
429
- }
430
- function base64Decode(str) {
431
- var result = [];
432
- try {
433
- result = atob(str)
434
- .split('')
435
- .map(function (v) {
436
- return "%".concat("00".concat(v.charCodeAt(0).toString(16)).slice(-2));
437
- });
438
- }
439
- catch (e) {
440
- result = [];
441
- }
442
- try {
443
- return decodeURIComponent(result.join(''));
444
- }
445
- catch (e) {
446
- return result.join('');
447
- }
448
- }
449
- function handleDecodeURLComponent(val) {
450
- var result = val;
451
- try {
452
- result = decodeURIComponent(val);
453
- }
454
- catch (e) { }
455
- return result;
456
- }
457
- function handleEncodeURLComponent(val) {
458
- var result = val;
459
- try {
460
- result = encodeURIComponent(val);
461
- }
462
- catch (e) { }
463
- return result;
464
- }
465
- /**
466
- * 对原生方法进行重写
467
- * @param source 需要被重写的对象
468
- * @param name 重写方法名
469
- * @param replacement 重写方法
470
- * @param isForced 是否强制重写(可能原先没有该属性)
471
- */
472
- function replaceOld(source, name, replacement, isForced) {
473
- if (source === undefined)
474
- return;
475
- if (name in source || isForced) {
476
- var original = source[name];
477
- var wrapped = replacement(original);
478
- if (isFunction(wrapped)) {
479
- source[name] = wrapped;
480
- }
481
- }
482
- }
483
- function supportHistory() {
484
- return window && !!window.history.pushState && !!window.history.replaceState;
485
- }
486
-
487
- /******************************************************************************
488
- Copyright (c) Microsoft Corporation.
489
-
490
- Permission to use, copy, modify, and/or distribute this software for any
491
- purpose with or without fee is hereby granted.
492
-
493
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
494
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
495
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
496
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
497
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
498
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
499
- PERFORMANCE OF THIS SOFTWARE.
500
- ***************************************************************************** */
501
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
502
-
503
- var extendStatics = function(d, b) {
504
- extendStatics = Object.setPrototypeOf ||
505
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
506
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
507
- return extendStatics(d, b);
508
- };
509
-
510
- function __extends(d, b) {
511
- if (typeof b !== "function" && b !== null)
512
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
513
- extendStatics(d, b);
514
- function __() { this.constructor = d; }
515
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
516
- }
517
-
518
- function __values(o) {
519
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
520
- if (m) return m.call(o);
521
- if (o && typeof o.length === "number") return {
522
- next: function () {
523
- if (o && i >= o.length) o = void 0;
524
- return { value: o && o[i++], done: !o };
525
- }
526
- };
527
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
528
- }
529
-
530
- function __read(o, n) {
531
- var m = typeof Symbol === "function" && o[Symbol.iterator];
532
- if (!m) return o;
533
- var i = m.call(o), r, ar = [], e;
534
- try {
535
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
536
- }
537
- catch (error) { e = { error: error }; }
538
- finally {
539
- try {
540
- if (r && !r.done && (m = i["return"])) m.call(i);
541
- }
542
- finally { if (e) throw e.error; }
543
- }
544
- return ar;
545
- }
546
-
547
- function __spreadArray(to, from, pack) {
548
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
549
- if (ar || !(i in from)) {
550
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
551
- ar[i] = from[i];
552
- }
553
- }
554
- return to.concat(ar || Array.prototype.slice.call(from));
555
- }
556
-
557
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
558
- var e = new Error(message);
559
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
560
- };
561
-
562
- /**
563
- * cookie 操作
564
- */
565
- var CookieStorage = /** @class */ (function () {
566
- function CookieStorage() {
567
- this.name = 'CookieStorage';
568
- }
569
- /**
570
- * 用于判断是否支持cookie
571
- * @param testKey
572
- * @param testValue
573
- */
574
- CookieStorage.prototype.isSupport = function (testKey, testValue) {
575
- var _this = this;
576
- if (testKey === void 0) { testKey = 'cookie_support_test'; }
577
- if (testValue === void 0) { testValue = '1'; }
578
- var test = function () {
579
- _this.set(testKey, testValue);
580
- var value = _this.get(testKey);
581
- if (value !== testValue)
582
- return false;
583
- _this.remove(testKey);
584
- return true;
585
- };
586
- return navigator.cookieEnabled && test();
587
- };
588
- /**
589
- * 获取指定的cookie值
590
- * @param name
591
- */
592
- CookieStorage.prototype.get = function (name) {
593
- var e_1, _a;
594
- var cookieList = document.cookie.split(';');
595
- try {
596
- for (var cookieList_1 = __values(cookieList), cookieList_1_1 = cookieList_1.next(); !cookieList_1_1.done; cookieList_1_1 = cookieList_1.next()) {
597
- var cookie = cookieList_1_1.value;
598
- var cookiePair = cookie.split('=');
599
- if (cookiePair[0].trim() === name) {
600
- return decodeURIComponent(cookiePair[1]);
601
- }
602
- }
603
- }
604
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
605
- finally {
606
- try {
607
- if (cookieList_1_1 && !cookieList_1_1.done && (_a = cookieList_1.return)) _a.call(cookieList_1);
608
- }
609
- finally { if (e_1) throw e_1.error; }
610
- }
611
- // 如果没有找到对应的cookie,则返回null
612
- return null;
613
- };
614
- /**
615
- * 设置cookie
616
- * @param name cookie名称
617
- * @param value cookie值
618
- * @param timeStamp 过期时间戳 单位s
619
- * @param path 路径
620
- * @param domain cookie域名
621
- * @param sameSite 跨域设置
622
- * @param secure 是否仅通过 HTTPS 协议传输
623
- */
624
- CookieStorage.prototype.set = function (name, value, timeStamp, path, domain, sameSite, secure) {
625
- path = path || '/';
626
- name = name.trim();
627
- value = value.trim();
628
- var cookieStr = "".concat(name, "=").concat(encodeURIComponent(value), "; path=").concat(path, ";");
629
- timeStamp = isValid(timeStamp) ? timeStamp : 73000;
630
- // 设置过期时间
631
- cookieStr += " max-age=".concat(timeStamp, ";");
632
- // 是否仅通过 HTTPS 协议传输
633
- if (secure) {
634
- cookieStr += ' secure;';
635
- }
636
- // 设置域名
637
- if (domain) {
638
- cookieStr += " domain=".concat(domain, ";");
639
- }
640
- // 设置跨域
641
- if (['Strict', 'Lax', 'None'].includes(sameSite)) {
642
- cookieStr += " SameSite=".concat(sameSite, ";");
643
- }
644
- document.cookie = cookieStr;
645
- };
646
- /**
647
- * 删除指定cookie
648
- * @param name
649
- * @param path
650
- */
651
- CookieStorage.prototype.remove = function (name, path) {
652
- if (path === void 0) { path = '/'; }
653
- this.set(name, '1', 0, path);
654
- };
655
- /**
656
- * 将cookie设置到当前子域名下,用于跨站共享
657
- * @param name
658
- * @param value
659
- * @param timeStamp
660
- */
661
- CookieStorage.prototype.setDomain = function (name, value, timeStamp) {
662
- var domain = getCurrentDomain();
663
- if (domain === 'url解析失败') {
664
- domain = '';
665
- }
666
- this.set(name, value, timeStamp, '/', domain);
667
- };
668
- return CookieStorage;
669
- }());
670
- /**
671
- * localStorage 操作
672
- */
673
- var LocalStorage = /** @class */ (function () {
674
- function LocalStorage() {
675
- this.name = 'LocalStorage';
676
- }
677
- /**
678
- * 判断是否支持localStorage
679
- */
680
- LocalStorage.prototype.isSupport = function () {
681
- var supported = true;
682
- try {
683
- var supportName = '__localStorageSupport__';
684
- var val = 'testIsSupportStorage';
685
- this.set(supportName, val);
686
- if (this.get(supportName) !== val) {
687
- supported = false;
688
- }
689
- this.remove(supportName);
690
- }
691
- catch (e) {
692
- supported = false;
693
- }
694
- return supported;
695
- };
696
- LocalStorage.prototype.key = function (index) {
697
- return window.localStorage.key(index);
698
- };
699
- LocalStorage.prototype.get = function (key) {
700
- return window.localStorage.getItem(key);
701
- };
702
- LocalStorage.prototype.length = function () {
703
- return window.localStorage.length;
704
- };
705
- LocalStorage.prototype.set = function (key, value) {
706
- try {
707
- window.localStorage.setItem(key, value);
708
- }
709
- catch (e) { }
710
- };
711
- LocalStorage.prototype.remove = function (key) {
712
- window.localStorage.removeItem(key);
713
- };
714
- LocalStorage.prototype.parse = function (key) {
715
- var result = this.get(key);
716
- try {
717
- result = JSON.parse(result);
718
- }
719
- catch (e) {
720
- result = '';
721
- }
722
- return result;
723
- };
724
- return LocalStorage;
725
- }());
726
- /**
727
- * memoryStorage 操作
728
- */
729
- var MemoryStorage = /** @class */ (function () {
730
- function MemoryStorage() {
731
- this.name = 'MemoryStorage';
732
- this.data = {};
733
- }
734
- MemoryStorage.prototype.get = function (key) {
735
- var result = this.data[key];
736
- if (isValid(result === null || result === void 0 ? void 0 : result.expireTime)) {
737
- if (result.expireTime < nowStamp()) {
738
- return null;
739
- }
740
- return result.value;
741
- }
742
- return result === null || result === void 0 ? void 0 : result.value;
743
- };
744
- /**
745
- * 存储数据
746
- * @param key
747
- * @param value
748
- * @param expires 单位 s
749
- */
750
- MemoryStorage.prototype.set = function (key, value, expires) {
751
- if (isValid(expires)) {
752
- var expireTime = nowStamp() + expires * 1000;
753
- this.data[key] = {
754
- value: value,
755
- expireTime: expireTime
756
- };
757
- }
758
- this.data[key] = { value: value };
759
- };
760
- MemoryStorage.prototype.setDomain = function (name, value, timeStamp) {
761
- this.set(name, value, timeStamp);
762
- };
763
- return MemoryStorage;
764
- }());
765
-
766
- function isElement(val) {
767
- return (val === null || val === void 0 ? void 0 : val.nodeType) === 1;
768
- }
769
- /**
770
- * 获取指定元素以及其父元素组成的路径
771
- * @param element
772
- */
773
- function getElementParents(element) {
774
- var pathArr = [element];
775
- try {
776
- if (!isElement(element)) {
777
- return pathArr;
778
- }
779
- if (element === null || element.parentElement === null) {
780
- return pathArr;
781
- }
782
- while (element.parentElement !== null) {
783
- element = element.parentElement;
784
- pathArr.push(element);
785
- }
786
- return pathArr;
787
- }
788
- catch (error) { }
789
- return pathArr;
790
- }
791
- /**
792
- * 获取input元素的内容
793
- * @param element
794
- * @param isCollectInput 是否采集input
795
- */
796
- function getInputElementContent(element, isCollectInput) {
797
- var _a;
798
- var tagName = (_a = element.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
799
- if (tagName === 'input') {
800
- if (['button', 'submit'].includes(element.type) || isCollectInput) {
801
- return element.value || '';
802
- }
803
- return '';
804
- }
805
- var textContent = '';
806
- if (element.textContent) {
807
- textContent = element.textContent.trim();
808
- }
809
- else if (element.innerText) {
810
- textContent = element.innerText.trim();
811
- }
812
- if (textContent) {
813
- textContent = textContent
814
- .replace(/[\r\n]/g, ' ')
815
- .replace(/[ ]+/g, ' ')
816
- .substring(0, 255);
817
- }
818
- return textContent || '';
819
- }
820
- /**
821
- * 获取元素信息
822
- * @param element 元素
823
- * @param isCollectInput 是否采集input
824
- */
825
- function getElementProperties(element, isCollectInput) {
826
- var _a;
827
- if (!isElement(element))
828
- return {};
829
- var tagName = (_a = element.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
830
- var props = {
831
- H_element_type: tagName,
832
- H_element_name: element.getAttribute('name'),
833
- H_element_id: element.getAttribute('id'),
834
- H_element_target_url: element.getAttribute('href'),
835
- H_element_class_name: element.getAttribute('className'),
836
- H_element_content: getInputElementContent(element, isCollectInput)
837
- };
838
- return stripEmptyProperties(props);
839
- }
840
- /**
841
- * 获取页面信息
842
- */
843
- function getPageProperties() {
844
- var referrer = getReferrer();
845
- var url_domain = getCurrentDomain();
846
- var viewportPosition = Math.round(getScrollTop());
847
- var props = {
848
- H_referrer: referrer,
849
- H_referrer_host: referrer ? getHostname(referrer) : '',
850
- H_url: window.location.href,
851
- H_url_host: getHostname(window.location.href, 'url_host取值异常'),
852
- H_url_domain: url_domain,
853
- H_url_path: window.location.pathname,
854
- H_url_hash: window.location.hash,
855
- H_title: document.title,
856
- H_viewport_position: viewportPosition
857
- };
858
- return stripEmptyProperties(props);
859
- }
860
-
861
- var SearchKeyword = /** @class */ (function () {
862
- function SearchKeyword() {
863
- }
864
- SearchKeyword.getSourceFromReferrer = function () {
865
- var getMatchStrFromArr = function (arr, str) {
866
- for (var i = 0; i < arr.length; i++) {
867
- if (str.split('?')[0].indexOf(arr[i]) !== -1) {
868
- return true;
869
- }
870
- }
871
- };
872
- var utm_reg = "(".concat(utmTypes.join('|'), ")\\=[^&]+");
873
- var referrer = document.referrer || '';
874
- var url = window.location.href;
875
- if (url) {
876
- var utm_match = url.match(new RegExp(utm_reg));
877
- if (utm_match && utm_match[0]) {
878
- return '付费广告流量';
879
- }
880
- if (getMatchStrFromArr(searchTypes, referrer)) {
881
- return '自然搜索流量';
882
- }
883
- if (getMatchStrFromArr(socialTypes, referrer)) {
884
- return '社交网站流量';
885
- }
886
- if (referrer === '') {
887
- return '直接流量';
888
- }
889
- return '引荐流量';
890
- }
891
- return '获取url异常';
892
- };
893
- SearchKeyword.getReferSearchEngine = function (referrerUrl) {
894
- var e_1, _a;
895
- var hostname = getHostname(referrerUrl);
896
- if (!hostname || hostname === 'hostname解析异常') {
897
- return '';
898
- }
899
- var regexps = {
900
- baidu: [/^.*\.baidu\.com$/],
901
- bing: [/^.*\.bing\.com$/],
902
- google: [
903
- /^www\.google\.com$/,
904
- /^www\.google\.com\.[a-z]{2}$/,
905
- /^www\.google\.[a-z]{2}$/
906
- ],
907
- sm: [/^m\.sm\.cn$/],
908
- so: [/^.+\.so\.com$/],
909
- sogou: [/^.*\.sogou\.com$/],
910
- yahoo: [/^.*\.yahoo\.com$/]
911
- };
912
- for (var regexp in regexps) {
913
- var regexList = regexps[regexp];
914
- try {
915
- for (var regexList_1 = (e_1 = void 0, __values(regexList)), regexList_1_1 = regexList_1.next(); !regexList_1_1.done; regexList_1_1 = regexList_1.next()) {
916
- var regex = regexList_1_1.value;
917
- if (regex.test(hostname)) {
918
- return regexp;
919
- }
920
- }
921
- }
922
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
923
- finally {
924
- try {
925
- if (regexList_1_1 && !regexList_1_1.done && (_a = regexList_1.return)) _a.call(regexList_1);
926
- }
927
- finally { if (e_1) throw e_1.error; }
928
- }
929
- }
930
- return '未知搜索引擎';
931
- };
932
- SearchKeyword.getKeywordFromReferrer = function () {
933
- var referrerUrl = document.referrer || '';
934
- if (referrerUrl.indexOf('http') === 0) {
935
- var searchEngine = this.getReferSearchEngine(referrerUrl);
936
- var query = getURLSearchParams(getURL(referrerUrl).search);
937
- if (isEmptyObject(query)) {
938
- return '未取到值';
939
- }
940
- for (var key in searchKeywords) {
941
- var value = searchKeywords[key];
942
- if (key === searchEngine) {
943
- if (isArray(value)) {
944
- for (var i = 0; i < value.length; i++) {
945
- var val = query[value[i]];
946
- if (val) {
947
- return val;
948
- }
949
- }
950
- }
951
- else if (query[value]) {
952
- return query[value];
953
- }
954
- }
955
- }
956
- return '未取到值';
957
- }
958
- if (referrerUrl === '') {
959
- return '未取到值_直接打开';
960
- }
961
- return '未取到值_非http的url';
962
- };
963
- return SearchKeyword;
964
- }());
965
- /**
966
- * 广告参数
967
- * @param prefix
968
- */
969
- function getUmtsParams(prefix) {
970
- if (prefix === void 0) { prefix = ''; }
971
- var utms = getUtm();
972
- var allUtms = {};
973
- Object.keys(utms).forEach(function (key) {
974
- allUtms[prefix + key] = utms[key];
975
- });
976
- return allUtms;
977
- }
978
- function getUtm() {
979
- var params = {};
980
- utmTypes.forEach(function (key) {
981
- var result = getQueryParam(window.location.href, key);
982
- if (result.length) {
983
- params[key] = result;
984
- }
985
- });
986
- return params;
987
- }
988
-
989
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
990
-
991
- function getDefaultExportFromCjs (x) {
992
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
993
- }
994
-
995
- var uaParser = {exports: {}};
996
-
997
- (function (module, exports) {
998
- /////////////////////////////////////////////////////////////////////////////////
999
- /* UAParser.js v1.0.38
1000
- Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
1001
- MIT License *//*
1002
- Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
1003
- Supports browser & node.js environment.
1004
- Demo : https://faisalman.github.io/ua-parser-js
1005
- Source : https://github.com/faisalman/ua-parser-js */
1006
- /////////////////////////////////////////////////////////////////////////////////
1007
-
1008
- (function (window, undefined$1) {
1009
-
1010
- //////////////
1011
- // Constants
1012
- /////////////
1013
-
1014
-
1015
- var LIBVERSION = '1.0.38',
1016
- EMPTY = '',
1017
- UNKNOWN = '?',
1018
- FUNC_TYPE = 'function',
1019
- UNDEF_TYPE = 'undefined',
1020
- OBJ_TYPE = 'object',
1021
- STR_TYPE = 'string',
1022
- MAJOR = 'major',
1023
- MODEL = 'model',
1024
- NAME = 'name',
1025
- TYPE = 'type',
1026
- VENDOR = 'vendor',
1027
- VERSION = 'version',
1028
- ARCHITECTURE= 'architecture',
1029
- CONSOLE = 'console',
1030
- MOBILE = 'mobile',
1031
- TABLET = 'tablet',
1032
- SMARTTV = 'smarttv',
1033
- WEARABLE = 'wearable',
1034
- EMBEDDED = 'embedded',
1035
- UA_MAX_LENGTH = 500;
1036
-
1037
- var AMAZON = 'Amazon',
1038
- APPLE = 'Apple',
1039
- ASUS = 'ASUS',
1040
- BLACKBERRY = 'BlackBerry',
1041
- BROWSER = 'Browser',
1042
- CHROME = 'Chrome',
1043
- EDGE = 'Edge',
1044
- FIREFOX = 'Firefox',
1045
- GOOGLE = 'Google',
1046
- HUAWEI = 'Huawei',
1047
- LG = 'LG',
1048
- MICROSOFT = 'Microsoft',
1049
- MOTOROLA = 'Motorola',
1050
- OPERA = 'Opera',
1051
- SAMSUNG = 'Samsung',
1052
- SHARP = 'Sharp',
1053
- SONY = 'Sony',
1054
- XIAOMI = 'Xiaomi',
1055
- ZEBRA = 'Zebra',
1056
- FACEBOOK = 'Facebook',
1057
- CHROMIUM_OS = 'Chromium OS',
1058
- MAC_OS = 'Mac OS';
1059
-
1060
- ///////////
1061
- // Helper
1062
- //////////
1063
-
1064
- var extend = function (regexes, extensions) {
1065
- var mergedRegexes = {};
1066
- for (var i in regexes) {
1067
- if (extensions[i] && extensions[i].length % 2 === 0) {
1068
- mergedRegexes[i] = extensions[i].concat(regexes[i]);
1069
- } else {
1070
- mergedRegexes[i] = regexes[i];
1071
- }
1072
- }
1073
- return mergedRegexes;
1074
- },
1075
- enumerize = function (arr) {
1076
- var enums = {};
1077
- for (var i=0; i<arr.length; i++) {
1078
- enums[arr[i].toUpperCase()] = arr[i];
1079
- }
1080
- return enums;
1081
- },
1082
- has = function (str1, str2) {
1083
- return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
1084
- },
1085
- lowerize = function (str) {
1086
- return str.toLowerCase();
1087
- },
1088
- majorize = function (version) {
1089
- return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split('.')[0] : undefined$1;
1090
- },
1091
- trim = function (str, len) {
1092
- if (typeof(str) === STR_TYPE) {
1093
- str = str.replace(/^\s\s*/, EMPTY);
1094
- return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
1095
- }
1096
- };
1097
-
1098
- ///////////////
1099
- // Map helper
1100
- //////////////
1101
-
1102
- var rgxMapper = function (ua, arrays) {
1103
-
1104
- var i = 0, j, k, p, q, matches, match;
1105
-
1106
- // loop through all regexes maps
1107
- while (i < arrays.length && !matches) {
1108
-
1109
- var regex = arrays[i], // even sequence (0,2,4,..)
1110
- props = arrays[i + 1]; // odd sequence (1,3,5,..)
1111
- j = k = 0;
1112
-
1113
- // try matching uastring with regexes
1114
- while (j < regex.length && !matches) {
1115
-
1116
- if (!regex[j]) { break; }
1117
- matches = regex[j++].exec(ua);
1118
-
1119
- if (!!matches) {
1120
- for (p = 0; p < props.length; p++) {
1121
- match = matches[++k];
1122
- q = props[p];
1123
- // check if given property is actually array
1124
- if (typeof q === OBJ_TYPE && q.length > 0) {
1125
- if (q.length === 2) {
1126
- if (typeof q[1] == FUNC_TYPE) {
1127
- // assign modified match
1128
- this[q[0]] = q[1].call(this, match);
1129
- } else {
1130
- // assign given value, ignore regex match
1131
- this[q[0]] = q[1];
1132
- }
1133
- } else if (q.length === 3) {
1134
- // check whether function or regex
1135
- if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
1136
- // call function (usually string mapper)
1137
- this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined$1;
1138
- } else {
1139
- // sanitize match using given regex
1140
- this[q[0]] = match ? match.replace(q[1], q[2]) : undefined$1;
1141
- }
1142
- } else if (q.length === 4) {
1143
- this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined$1;
1144
- }
1145
- } else {
1146
- this[q] = match ? match : undefined$1;
1147
- }
1148
- }
1149
- }
1150
- }
1151
- i += 2;
1152
- }
1153
- },
1154
-
1155
- strMapper = function (str, map) {
1156
-
1157
- for (var i in map) {
1158
- // check if current value is array
1159
- if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
1160
- for (var j = 0; j < map[i].length; j++) {
1161
- if (has(map[i][j], str)) {
1162
- return (i === UNKNOWN) ? undefined$1 : i;
1163
- }
1164
- }
1165
- } else if (has(map[i], str)) {
1166
- return (i === UNKNOWN) ? undefined$1 : i;
1167
- }
1168
- }
1169
- return str;
1170
- };
1171
-
1172
- ///////////////
1173
- // String map
1174
- //////////////
1175
-
1176
- // Safari < 3.0
1177
- var oldSafariMap = {
1178
- '1.0' : '/8',
1179
- '1.2' : '/1',
1180
- '1.3' : '/3',
1181
- '2.0' : '/412',
1182
- '2.0.2' : '/416',
1183
- '2.0.3' : '/417',
1184
- '2.0.4' : '/419',
1185
- '?' : '/'
1186
- },
1187
- windowsVersionMap = {
1188
- 'ME' : '4.90',
1189
- 'NT 3.11' : 'NT3.51',
1190
- 'NT 4.0' : 'NT4.0',
1191
- '2000' : 'NT 5.0',
1192
- 'XP' : ['NT 5.1', 'NT 5.2'],
1193
- 'Vista' : 'NT 6.0',
1194
- '7' : 'NT 6.1',
1195
- '8' : 'NT 6.2',
1196
- '8.1' : 'NT 6.3',
1197
- '10' : ['NT 6.4', 'NT 10.0'],
1198
- 'RT' : 'ARM'
1199
- };
1200
-
1201
- //////////////
1202
- // Regex map
1203
- /////////////
1204
-
1205
- var regexes = {
1206
-
1207
- browser : [[
1208
-
1209
- /\b(?:crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
1210
- ], [VERSION, [NAME, 'Chrome']], [
1211
- /edg(?:e|ios|a)?\/([\w\.]+)/i // Microsoft Edge
1212
- ], [VERSION, [NAME, 'Edge']], [
1213
-
1214
- // Presto based
1215
- /(opera mini)\/([-\w\.]+)/i, // Opera Mini
1216
- /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i, // Opera Mobi/Tablet
1217
- /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i // Opera
1218
- ], [NAME, VERSION], [
1219
- /opios[\/ ]+([\w\.]+)/i // Opera mini on iphone >= 8.0
1220
- ], [VERSION, [NAME, OPERA+' Mini']], [
1221
- /\bop(?:rg)?x\/([\w\.]+)/i // Opera GX
1222
- ], [VERSION, [NAME, OPERA+' GX']], [
1223
- /\bopr\/([\w\.]+)/i // Opera Webkit
1224
- ], [VERSION, [NAME, OPERA]], [
1225
-
1226
- // Mixed
1227
- /\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i // Baidu
1228
- ], [VERSION, [NAME, 'Baidu']], [
1229
- /(kindle)\/([\w\.]+)/i, // Kindle
1230
- /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i, // Lunascape/Maxthon/Netfront/Jasmine/Blazer
1231
- // Trident based
1232
- /(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i, // Avant/IEMobile/SlimBrowser
1233
- /(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer
1234
-
1235
- // Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
1236
- /(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
1237
- // Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ, aka ShouQ
1238
- /(heytap|ovi)browser\/([\d\.]+)/i, // Heytap/Ovi
1239
- /(weibo)__([\d\.]+)/i // Weibo
1240
- ], [NAME, VERSION], [
1241
- /\bddg\/([\w\.]+)/i // DuckDuckGo
1242
- ], [VERSION, [NAME, 'DuckDuckGo']], [
1243
- /(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
1244
- ], [VERSION, [NAME, 'UC'+BROWSER]], [
1245
- /microm.+\bqbcore\/([\w\.]+)/i, // WeChat Desktop for Windows Built-in Browser
1246
- /\bqbcore\/([\w\.]+).+microm/i,
1247
- /micromessenger\/([\w\.]+)/i // WeChat
1248
- ], [VERSION, [NAME, 'WeChat']], [
1249
- /konqueror\/([\w\.]+)/i // Konqueror
1250
- ], [VERSION, [NAME, 'Konqueror']], [
1251
- /trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i // IE11
1252
- ], [VERSION, [NAME, 'IE']], [
1253
- /ya(?:search)?browser\/([\w\.]+)/i // Yandex
1254
- ], [VERSION, [NAME, 'Yandex']], [
1255
- /slbrowser\/([\w\.]+)/i // Smart Lenovo Browser
1256
- ], [VERSION, [NAME, 'Smart Lenovo '+BROWSER]], [
1257
- /(avast|avg)\/([\w\.]+)/i // Avast/AVG Secure Browser
1258
- ], [[NAME, /(.+)/, '$1 Secure '+BROWSER], VERSION], [
1259
- /\bfocus\/([\w\.]+)/i // Firefox Focus
1260
- ], [VERSION, [NAME, FIREFOX+' Focus']], [
1261
- /\bopt\/([\w\.]+)/i // Opera Touch
1262
- ], [VERSION, [NAME, OPERA+' Touch']], [
1263
- /coc_coc\w+\/([\w\.]+)/i // Coc Coc Browser
1264
- ], [VERSION, [NAME, 'Coc Coc']], [
1265
- /dolfin\/([\w\.]+)/i // Dolphin
1266
- ], [VERSION, [NAME, 'Dolphin']], [
1267
- /coast\/([\w\.]+)/i // Opera Coast
1268
- ], [VERSION, [NAME, OPERA+' Coast']], [
1269
- /miuibrowser\/([\w\.]+)/i // MIUI Browser
1270
- ], [VERSION, [NAME, 'MIUI '+BROWSER]], [
1271
- /fxios\/([-\w\.]+)/i // Firefox for iOS
1272
- ], [VERSION, [NAME, FIREFOX]], [
1273
- /\bqihu|(qi?ho?o?|360)browser/i // 360
1274
- ], [[NAME, '360 ' + BROWSER]], [
1275
- /(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i
1276
- ], [[NAME, /(.+)/, '$1 ' + BROWSER], VERSION], [ // Oculus/Sailfish/HuaweiBrowser/VivoBrowser
1277
- /samsungbrowser\/([\w\.]+)/i // Samsung Internet
1278
- ], [VERSION, [NAME, SAMSUNG + ' Internet']], [
1279
- /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
1280
- ], [[NAME, /_/g, ' '], VERSION], [
1281
- /metasr[\/ ]?([\d\.]+)/i // Sogou Explorer
1282
- ], [VERSION, [NAME, 'Sogou Explorer']], [
1283
- /(sogou)mo\w+\/([\d\.]+)/i // Sogou Mobile
1284
- ], [[NAME, 'Sogou Mobile'], VERSION], [
1285
- /(electron)\/([\w\.]+) safari/i, // Electron-based App
1286
- /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, // Tesla
1287
- /m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/2345 Browser
1288
- ], [NAME, VERSION], [
1289
- /(lbbrowser)/i, // LieBao Browser
1290
- /\[(linkedin)app\]/i // LinkedIn App for iOS & Android
1291
- ], [NAME], [
1292
-
1293
- // WebView
1294
- /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
1295
- ], [[NAME, FACEBOOK], VERSION], [
1296
- /(Klarna)\/([\w\.]+)/i, // Klarna Shopping Browser for iOS & Android
1297
- /(kakao(?:talk|story))[\/ ]([\w\.]+)/i, // Kakao App
1298
- /(naver)\(.*?(\d+\.[\w\.]+).*\)/i, // Naver InApp
1299
- /safari (line)\/([\w\.]+)/i, // Line App for iOS
1300
- /\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
1301
- /(alipay)client\/([\w\.]+)/i, // Alipay
1302
- /(twitter)(?:and| f.+e\/([\w\.]+))/i, // Twitter
1303
- /(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i // Chromium/Instagram/Snapchat
1304
- ], [NAME, VERSION], [
1305
- /\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
1306
- ], [VERSION, [NAME, 'GSA']], [
1307
- /musical_ly(?:.+app_?version\/|_)([\w\.]+)/i // TikTok
1308
- ], [VERSION, [NAME, 'TikTok']], [
1309
-
1310
- /headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
1311
- ], [VERSION, [NAME, CHROME+' Headless']], [
1312
-
1313
- / wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
1314
- ], [[NAME, CHROME+' WebView'], VERSION], [
1315
-
1316
- /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
1317
- ], [VERSION, [NAME, 'Android '+BROWSER]], [
1318
-
1319
- /(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i // Chrome/OmniWeb/Arora/Tizen/Nokia
1320
- ], [NAME, VERSION], [
1321
-
1322
- /version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i // Mobile Safari
1323
- ], [VERSION, [NAME, 'Mobile Safari']], [
1324
- /version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
1325
- ], [VERSION, NAME], [
1326
- /webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
1327
- ], [NAME, [VERSION, strMapper, oldSafariMap]], [
1328
-
1329
- /(webkit|khtml)\/([\w\.]+)/i
1330
- ], [NAME, VERSION], [
1331
-
1332
- // Gecko based
1333
- /(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
1334
- ], [[NAME, 'Netscape'], VERSION], [
1335
- /mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
1336
- ], [VERSION, [NAME, FIREFOX+' Reality']], [
1337
- /ekiohf.+(flow)\/([\w\.]+)/i, // Flow
1338
- /(swiftfox)/i, // Swiftfox
1339
- /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
1340
- // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror/Klar
1341
- /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
1342
- // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
1343
- /(firefox)\/([\w\.]+)/i, // Other Firefox-based
1344
- /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i, // Mozilla
1345
-
1346
- // Other
1347
- /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
1348
- // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser
1349
- /(links) \(([\w\.]+)/i, // Links
1350
- /panasonic;(viera)/i // Panasonic Viera
1351
- ], [NAME, VERSION], [
1352
-
1353
- /(cobalt)\/([\w\.]+)/i // Cobalt
1354
- ], [NAME, [VERSION, /master.|lts./, ""]]
1355
- ],
1356
-
1357
- cpu : [[
1358
-
1359
- /(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i // AMD64 (x64)
1360
- ], [[ARCHITECTURE, 'amd64']], [
1361
-
1362
- /(ia32(?=;))/i // IA32 (quicktime)
1363
- ], [[ARCHITECTURE, lowerize]], [
1364
-
1365
- /((?:i[346]|x)86)[;\)]/i // IA32 (x86)
1366
- ], [[ARCHITECTURE, 'ia32']], [
1367
-
1368
- /\b(aarch64|arm(v?8e?l?|_?64))\b/i // ARM64
1369
- ], [[ARCHITECTURE, 'arm64']], [
1370
-
1371
- /\b(arm(?:v[67])?ht?n?[fl]p?)\b/i // ARMHF
1372
- ], [[ARCHITECTURE, 'armhf']], [
1373
-
1374
- // PocketPC mistakenly identified as PowerPC
1375
- /windows (ce|mobile); ppc;/i
1376
- ], [[ARCHITECTURE, 'arm']], [
1377
-
1378
- /((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i // PowerPC
1379
- ], [[ARCHITECTURE, /ower/, EMPTY, lowerize]], [
1380
-
1381
- /(sun4\w)[;\)]/i // SPARC
1382
- ], [[ARCHITECTURE, 'sparc']], [
1383
-
1384
- /((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
1385
- // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
1386
- ], [[ARCHITECTURE, lowerize]]
1387
- ],
1388
-
1389
- device : [[
1390
-
1391
- //////////////////////////
1392
- // MOBILES & TABLETS
1393
- /////////////////////////
1394
-
1395
- // Samsung
1396
- /\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
1397
- ], [MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]], [
1398
- /\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
1399
- /samsung[- ]([-\w]+)/i,
1400
- /sec-(sgh\w+)/i
1401
- ], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
1402
-
1403
- // Apple
1404
- /(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i // iPod/iPhone
1405
- ], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [
1406
- /\((ipad);[-\w\),; ]+apple/i, // iPad
1407
- /applecoremedia\/[\w\.]+ \((ipad)/i,
1408
- /\b(ipad)\d\d?,\d\d?[;\]].+ios/i
1409
- ], [MODEL, [VENDOR, APPLE], [TYPE, TABLET]], [
1410
- /(macintosh);/i
1411
- ], [MODEL, [VENDOR, APPLE]], [
1412
-
1413
- // Sharp
1414
- /\b(sh-?[altvz]?\d\d[a-ekm]?)/i
1415
- ], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [
1416
-
1417
- // Huawei
1418
- /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
1419
- ], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
1420
- /(?:huawei|honor)([-\w ]+)[;\)]/i,
1421
- /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
1422
- ], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [
1423
-
1424
- // Xiaomi
1425
- /\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i, // Xiaomi POCO
1426
- /\b; (\w+) build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
1427
- /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, // Xiaomi Hongmi
1428
- /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, // Xiaomi Redmi
1429
- /oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i, // Xiaomi Redmi 'numeric' models
1430
- /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i // Xiaomi Mi
1431
- ], [[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, MOBILE]], [
1432
- /oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i, // Redmi Pad
1433
- /\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i // Mi Pad tablets
1434
- ],[[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, TABLET]], [
1435
-
1436
- // OPPO
1437
- /; (\w+) bui.+ oppo/i,
1438
- /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
1439
- ], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [
1440
- /\b(opd2\d{3}a?) bui/i
1441
- ], [MODEL, [VENDOR, 'OPPO'], [TYPE, TABLET]], [
1442
-
1443
- // Vivo
1444
- /vivo (\w+)(?: bui|\))/i,
1445
- /\b(v[12]\d{3}\w?[at])(?: bui|;)/i
1446
- ], [MODEL, [VENDOR, 'Vivo'], [TYPE, MOBILE]], [
1447
-
1448
- // Realme
1449
- /\b(rmx[1-3]\d{3})(?: bui|;|\))/i
1450
- ], [MODEL, [VENDOR, 'Realme'], [TYPE, MOBILE]], [
1451
-
1452
- // Motorola
1453
- /\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
1454
- /\bmot(?:orola)?[- ](\w*)/i,
1455
- /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
1456
- ], [MODEL, [VENDOR, MOTOROLA], [TYPE, MOBILE]], [
1457
- /\b(mz60\d|xoom[2 ]{0,2}) build\//i
1458
- ], [MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]], [
1459
-
1460
- // LG
1461
- /((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
1462
- ], [MODEL, [VENDOR, LG], [TYPE, TABLET]], [
1463
- /(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
1464
- /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
1465
- /\blg-?([\d\w]+) bui/i
1466
- ], [MODEL, [VENDOR, LG], [TYPE, MOBILE]], [
1467
-
1468
- // Lenovo
1469
- /(ideatab[-\w ]+)/i,
1470
- /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
1471
- ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
1472
-
1473
- // Nokia
1474
- /(?:maemo|nokia).*(n900|lumia \d+)/i,
1475
- /nokia[-_ ]?([-\w\.]*)/i
1476
- ], [[MODEL, /_/g, ' '], [VENDOR, 'Nokia'], [TYPE, MOBILE]], [
1477
-
1478
- // Google
1479
- /(pixel c)\b/i // Google Pixel C
1480
- ], [MODEL, [VENDOR, GOOGLE], [TYPE, TABLET]], [
1481
- /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i // Google Pixel
1482
- ], [MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]], [
1483
-
1484
- // Sony
1485
- /droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
1486
- ], [MODEL, [VENDOR, SONY], [TYPE, MOBILE]], [
1487
- /sony tablet [ps]/i,
1488
- /\b(?:sony)?sgp\w+(?: bui|\))/i
1489
- ], [[MODEL, 'Xperia Tablet'], [VENDOR, SONY], [TYPE, TABLET]], [
1490
-
1491
- // OnePlus
1492
- / (kb2005|in20[12]5|be20[12][59])\b/i,
1493
- /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
1494
- ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
1495
-
1496
- // Amazon
1497
- /(alexa)webm/i,
1498
- /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i, // Kindle Fire without Silk / Echo Show
1499
- /(kf[a-z]+)( bui|\)).+silk\//i // Kindle Fire HD
1500
- ], [MODEL, [VENDOR, AMAZON], [TYPE, TABLET]], [
1501
- /((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i // Fire Phone
1502
- ], [[MODEL, /(.+)/g, 'Fire Phone $1'], [VENDOR, AMAZON], [TYPE, MOBILE]], [
1503
-
1504
- // BlackBerry
1505
- /(playbook);[-\w\),; ]+(rim)/i // BlackBerry PlayBook
1506
- ], [MODEL, VENDOR, [TYPE, TABLET]], [
1507
- /\b((?:bb[a-f]|st[hv])100-\d)/i,
1508
- /\(bb10; (\w+)/i // BlackBerry 10
1509
- ], [MODEL, [VENDOR, BLACKBERRY], [TYPE, MOBILE]], [
1510
-
1511
- // Asus
1512
- /(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
1513
- ], [MODEL, [VENDOR, ASUS], [TYPE, TABLET]], [
1514
- / (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
1515
- ], [MODEL, [VENDOR, ASUS], [TYPE, MOBILE]], [
1516
-
1517
- // HTC
1518
- /(nexus 9)/i // HTC Nexus 9
1519
- ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
1520
- /(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i, // HTC
1521
-
1522
- // ZTE
1523
- /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
1524
- /(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
1525
- ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
1526
-
1527
- // Acer
1528
- /droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
1529
- ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
1530
-
1531
- // Meizu
1532
- /droid.+; (m[1-5] note) bui/i,
1533
- /\bmz-([-\w]{2,})/i
1534
- ], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
1535
-
1536
- // Ulefone
1537
- /; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i
1538
- ], [MODEL, [VENDOR, 'Ulefone'], [TYPE, MOBILE]], [
1539
-
1540
- // MIXED
1541
- /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,
1542
- // BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
1543
- /(hp) ([\w ]+\w)/i, // HP iPAQ
1544
- /(asus)-?(\w+)/i, // Asus
1545
- /(microsoft); (lumia[\w ]+)/i, // Microsoft Lumia
1546
- /(lenovo)[-_ ]?([-\w]+)/i, // Lenovo
1547
- /(jolla)/i, // Jolla
1548
- /(oppo) ?([\w ]+) bui/i // OPPO
1549
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
1550
-
1551
- /(kobo)\s(ereader|touch)/i, // Kobo
1552
- /(archos) (gamepad2?)/i, // Archos
1553
- /(hp).+(touchpad(?!.+tablet)|tablet)/i, // HP TouchPad
1554
- /(kindle)\/([\w\.]+)/i, // Kindle
1555
- /(nook)[\w ]+build\/(\w+)/i, // Nook
1556
- /(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
1557
- /(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
1558
- /(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
1559
- /(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
1560
- /(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
1561
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
1562
-
1563
- /(surface duo)/i // Surface Duo
1564
- ], [MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]], [
1565
- /droid [\d\.]+; (fp\du?)(?: b|\))/i // Fairphone
1566
- ], [MODEL, [VENDOR, 'Fairphone'], [TYPE, MOBILE]], [
1567
- /(u304aa)/i // AT&T
1568
- ], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
1569
- /\bsie-(\w*)/i // Siemens
1570
- ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
1571
- /\b(rct\w+) b/i // RCA Tablets
1572
- ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
1573
- /\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
1574
- ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
1575
- /\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
1576
- ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
1577
- /\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
1578
- ], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
1579
- /\b(tm\d{3}\w+) b/i
1580
- ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
1581
- /\b(k88) b/i // ZTE K Series Tablet
1582
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
1583
- /\b(nx\d{3}j) b/i // ZTE Nubia
1584
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
1585
- /\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
1586
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
1587
- /\b(zur\d{3}) b/i // Swiss ZUR Tablet
1588
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
1589
- /\b((zeki)?tb.*\b) b/i // Zeki Tablets
1590
- ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
1591
- /\b([yr]\d{2}) b/i,
1592
- /\b(dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
1593
- ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
1594
- /\b(ns-?\w{0,9}) b/i // Insignia Tablets
1595
- ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
1596
- /\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
1597
- ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
1598
- /\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
1599
- ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
1600
- /\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
1601
- ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
1602
- /\b(ph-1) /i // Essential PH-1
1603
- ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
1604
- /\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
1605
- ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
1606
- /\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
1607
- ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
1608
- /\btu_(1491) b/i // Rotor Tablets
1609
- ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
1610
- /(shield[\w ]+) b/i // Nvidia Shield Tablets
1611
- ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, TABLET]], [
1612
- /(sprint) (\w+)/i // Sprint Phones
1613
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
1614
- /(kin\.[onetw]{3})/i // Microsoft Kin
1615
- ], [[MODEL, /\./g, ' '], [VENDOR, MICROSOFT], [TYPE, MOBILE]], [
1616
- /droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i // Zebra
1617
- ], [MODEL, [VENDOR, ZEBRA], [TYPE, TABLET]], [
1618
- /droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
1619
- ], [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]], [
1620
-
1621
- ///////////////////
1622
- // SMARTTVS
1623
- ///////////////////
1624
-
1625
- /smart-tv.+(samsung)/i // Samsung
1626
- ], [VENDOR, [TYPE, SMARTTV]], [
1627
- /hbbtv.+maple;(\d+)/i
1628
- ], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
1629
- /(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
1630
- ], [[VENDOR, LG], [TYPE, SMARTTV]], [
1631
- /(apple) ?tv/i // Apple TV
1632
- ], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
1633
- /crkey/i // Google Chromecast
1634
- ], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
1635
- /droid.+aft(\w+)( bui|\))/i // Fire TV
1636
- ], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
1637
- /\(dtv[\);].+(aquos)/i,
1638
- /(aquos-tv[\w ]+)\)/i // Sharp
1639
- ], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
1640
- /(bravia[\w ]+)( bui|\))/i // Sony
1641
- ], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
1642
- /(mitv-\w{5}) bui/i // Xiaomi
1643
- ], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
1644
- /Hbbtv.*(technisat) (.*);/i // TechniSAT
1645
- ], [VENDOR, MODEL, [TYPE, SMARTTV]], [
1646
- /\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
1647
- /hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
1648
- ], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
1649
- /\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
1650
- ], [[TYPE, SMARTTV]], [
1651
-
1652
- ///////////////////
1653
- // CONSOLES
1654
- ///////////////////
1655
-
1656
- /(ouya)/i, // Ouya
1657
- /(nintendo) ([wids3utch]+)/i // Nintendo
1658
- ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
1659
- /droid.+; (shield) bui/i // Nvidia
1660
- ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
1661
- /(playstation [345portablevi]+)/i // Playstation
1662
- ], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
1663
- /\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
1664
- ], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [
1665
-
1666
- ///////////////////
1667
- // WEARABLES
1668
- ///////////////////
1669
-
1670
- /((pebble))app/i // Pebble
1671
- ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
1672
- /(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i // Apple Watch
1673
- ], [MODEL, [VENDOR, APPLE], [TYPE, WEARABLE]], [
1674
- /droid.+; (glass) \d/i // Google Glass
1675
- ], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [
1676
- /droid.+; (wt63?0{2,3})\)/i
1677
- ], [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]], [
1678
- /(quest( \d| pro)?)/i // Oculus Quest
1679
- ], [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]], [
1680
-
1681
- ///////////////////
1682
- // EMBEDDED
1683
- ///////////////////
1684
-
1685
- /(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i // Tesla
1686
- ], [VENDOR, [TYPE, EMBEDDED]], [
1687
- /(aeobc)\b/i // Echo Dot
1688
- ], [MODEL, [VENDOR, AMAZON], [TYPE, EMBEDDED]], [
1689
-
1690
- ////////////////////
1691
- // MIXED (GENERIC)
1692
- ///////////////////
1693
-
1694
- /droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i // Android Phones from Unidentified Vendors
1695
- ], [MODEL, [TYPE, MOBILE]], [
1696
- /droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i // Android Tablets from Unidentified Vendors
1697
- ], [MODEL, [TYPE, TABLET]], [
1698
- /\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i // Unidentifiable Tablet
1699
- ], [[TYPE, TABLET]], [
1700
- /(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i // Unidentifiable Mobile
1701
- ], [[TYPE, MOBILE]], [
1702
- /(android[-\w\. ]{0,9});.+buil/i // Generic Android Device
1703
- ], [MODEL, [VENDOR, 'Generic']]
1704
- ],
1705
-
1706
- engine : [[
1707
-
1708
- /windows.+ edge\/([\w\.]+)/i // EdgeHTML
1709
- ], [VERSION, [NAME, EDGE+'HTML']], [
1710
-
1711
- /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
1712
- ], [VERSION, [NAME, 'Blink']], [
1713
-
1714
- /(presto)\/([\w\.]+)/i, // Presto
1715
- /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
1716
- /ekioh(flow)\/([\w\.]+)/i, // Flow
1717
- /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, // KHTML/Tasman/Links
1718
- /(icab)[\/ ]([23]\.[\d\.]+)/i, // iCab
1719
- /\b(libweb)/i
1720
- ], [NAME, VERSION], [
1721
-
1722
- /rv\:([\w\.]{1,9})\b.+(gecko)/i // Gecko
1723
- ], [VERSION, NAME]
1724
- ],
1725
-
1726
- os : [[
1727
-
1728
- // Windows
1729
- /microsoft (windows) (vista|xp)/i // Windows (iTunes)
1730
- ], [NAME, VERSION], [
1731
- /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i // Windows Phone
1732
- ], [NAME, [VERSION, strMapper, windowsVersionMap]], [
1733
- /windows nt 6\.2; (arm)/i, // Windows RT
1734
- /windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,
1735
- /(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i
1736
- ], [[VERSION, strMapper, windowsVersionMap], [NAME, 'Windows']], [
1737
-
1738
- // iOS/macOS
1739
- /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
1740
- /(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,
1741
- /cfnetwork\/.+darwin/i
1742
- ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
1743
- /(mac os x) ?([\w\. ]*)/i,
1744
- /(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
1745
- ], [[NAME, MAC_OS], [VERSION, /_/g, '.']], [
1746
-
1747
- // Mobile OSes
1748
- /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
1749
- ], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS
1750
- /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
1751
- /(blackberry)\w*\/([\w\.]*)/i, // Blackberry
1752
- /(tizen|kaios)[\/ ]([\w\.]+)/i, // Tizen/KaiOS
1753
- /\((series40);/i // Series 40
1754
- ], [NAME, VERSION], [
1755
- /\(bb(10);/i // BlackBerry 10
1756
- ], [VERSION, [NAME, BLACKBERRY]], [
1757
- /(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i // Symbian
1758
- ], [VERSION, [NAME, 'Symbian']], [
1759
- /mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i // Firefox OS
1760
- ], [VERSION, [NAME, FIREFOX+' OS']], [
1761
- /web0s;.+rt(tv)/i,
1762
- /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS
1763
- ], [VERSION, [NAME, 'webOS']], [
1764
- /watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i // watchOS
1765
- ], [VERSION, [NAME, 'watchOS']], [
1766
-
1767
- // Google Chromecast
1768
- /crkey\/([\d\.]+)/i // Google Chromecast
1769
- ], [VERSION, [NAME, CHROME+'cast']], [
1770
- /(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
1771
- ], [[NAME, CHROMIUM_OS], VERSION],[
1772
-
1773
- // Smart TVs
1774
- /panasonic;(viera)/i, // Panasonic Viera
1775
- /(netrange)mmh/i, // Netrange
1776
- /(nettv)\/(\d+\.[\w\.]+)/i, // NetTV
1777
-
1778
- // Console
1779
- /(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
1780
- /(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
1781
-
1782
- // Other
1783
- /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
1784
- /(mint)[\/\(\) ]?(\w*)/i, // Mint
1785
- /(mageia|vectorlinux)[; ]/i, // Mageia/VectorLinux
1786
- /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
1787
- // Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware/Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus/Raspbian/Plan9/Minix/RISCOS/Contiki/Deepin/Manjaro/elementary/Sabayon/Linspire
1788
- /(hurd|linux) ?([\w\.]*)/i, // Hurd/Linux
1789
- /(gnu) ?([\w\.]*)/i, // GNU
1790
- /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, // FreeBSD/NetBSD/OpenBSD/PC-BSD/GhostBSD/DragonFly
1791
- /(haiku) (\w+)/i // Haiku
1792
- ], [NAME, VERSION], [
1793
- /(sunos) ?([\w\.\d]*)/i // Solaris
1794
- ], [[NAME, 'Solaris'], VERSION], [
1795
- /((?:open)?solaris)[-\/ ]?([\w\.]*)/i, // Solaris
1796
- /(aix) ((\d)(?=\.|\)| )[\w\.])*/i, // AIX
1797
- /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i, // BeOS/OS2/AmigaOS/MorphOS/OpenVMS/Fuchsia/HP-UX/SerenityOS
1798
- /(unix) ?([\w\.]*)/i // UNIX
1799
- ], [NAME, VERSION]
1800
- ]
1801
- };
1802
-
1803
- /////////////////
1804
- // Constructor
1805
- ////////////////
1806
-
1807
- var UAParser = function (ua, extensions) {
1808
-
1809
- if (typeof ua === OBJ_TYPE) {
1810
- extensions = ua;
1811
- ua = undefined$1;
1812
- }
1813
-
1814
- if (!(this instanceof UAParser)) {
1815
- return new UAParser(ua, extensions).getResult();
1816
- }
1817
-
1818
- var _navigator = (typeof window !== UNDEF_TYPE && window.navigator) ? window.navigator : undefined$1;
1819
- var _ua = ua || ((_navigator && _navigator.userAgent) ? _navigator.userAgent : EMPTY);
1820
- var _uach = (_navigator && _navigator.userAgentData) ? _navigator.userAgentData : undefined$1;
1821
- var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
1822
- var _isSelfNav = _navigator && _navigator.userAgent == _ua;
1823
-
1824
- this.getBrowser = function () {
1825
- var _browser = {};
1826
- _browser[NAME] = undefined$1;
1827
- _browser[VERSION] = undefined$1;
1828
- rgxMapper.call(_browser, _ua, _rgxmap.browser);
1829
- _browser[MAJOR] = majorize(_browser[VERSION]);
1830
- // Brave-specific detection
1831
- if (_isSelfNav && _navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) {
1832
- _browser[NAME] = 'Brave';
1833
- }
1834
- return _browser;
1835
- };
1836
- this.getCPU = function () {
1837
- var _cpu = {};
1838
- _cpu[ARCHITECTURE] = undefined$1;
1839
- rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
1840
- return _cpu;
1841
- };
1842
- this.getDevice = function () {
1843
- var _device = {};
1844
- _device[VENDOR] = undefined$1;
1845
- _device[MODEL] = undefined$1;
1846
- _device[TYPE] = undefined$1;
1847
- rgxMapper.call(_device, _ua, _rgxmap.device);
1848
- if (_isSelfNav && !_device[TYPE] && _uach && _uach.mobile) {
1849
- _device[TYPE] = MOBILE;
1850
- }
1851
- // iPadOS-specific detection: identified as Mac, but has some iOS-only properties
1852
- if (_isSelfNav && _device[MODEL] == 'Macintosh' && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
1853
- _device[MODEL] = 'iPad';
1854
- _device[TYPE] = TABLET;
1855
- }
1856
- return _device;
1857
- };
1858
- this.getEngine = function () {
1859
- var _engine = {};
1860
- _engine[NAME] = undefined$1;
1861
- _engine[VERSION] = undefined$1;
1862
- rgxMapper.call(_engine, _ua, _rgxmap.engine);
1863
- return _engine;
1864
- };
1865
- this.getOS = function () {
1866
- var _os = {};
1867
- _os[NAME] = undefined$1;
1868
- _os[VERSION] = undefined$1;
1869
- rgxMapper.call(_os, _ua, _rgxmap.os);
1870
- if (_isSelfNav && !_os[NAME] && _uach && _uach.platform && _uach.platform != 'Unknown') {
1871
- _os[NAME] = _uach.platform
1872
- .replace(/chrome os/i, CHROMIUM_OS)
1873
- .replace(/macos/i, MAC_OS); // backward compatibility
1874
- }
1875
- return _os;
1876
- };
1877
- this.getResult = function () {
1878
- return {
1879
- ua : this.getUA(),
1880
- browser : this.getBrowser(),
1881
- engine : this.getEngine(),
1882
- os : this.getOS(),
1883
- device : this.getDevice(),
1884
- cpu : this.getCPU()
1885
- };
1886
- };
1887
- this.getUA = function () {
1888
- return _ua;
1889
- };
1890
- this.setUA = function (ua) {
1891
- _ua = (typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH) ? trim(ua, UA_MAX_LENGTH) : ua;
1892
- return this;
1893
- };
1894
- this.setUA(_ua);
1895
- return this;
1896
- };
1897
-
1898
- UAParser.VERSION = LIBVERSION;
1899
- UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR]);
1900
- UAParser.CPU = enumerize([ARCHITECTURE]);
1901
- UAParser.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
1902
- UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);
1903
-
1904
- ///////////
1905
- // Export
1906
- //////////
1907
-
1908
- // check js environment
1909
- {
1910
- // nodejs env
1911
- if (module.exports) {
1912
- exports = module.exports = UAParser;
1913
- }
1914
- exports.UAParser = UAParser;
1915
- }
1916
-
1917
- // jQuery/Zepto specific (optional)
1918
- // Note:
1919
- // In AMD env the global scope should be kept clean, but jQuery is an exception.
1920
- // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
1921
- // and we should catch that.
1922
- var $ = typeof window !== UNDEF_TYPE && (window.jQuery || window.Zepto);
1923
- if ($ && !$.ua) {
1924
- var parser = new UAParser();
1925
- $.ua = parser.getResult();
1926
- $.ua.get = function () {
1927
- return parser.getUA();
1928
- };
1929
- $.ua.set = function (ua) {
1930
- parser.setUA(ua);
1931
- var result = parser.getResult();
1932
- for (var prop in result) {
1933
- $.ua[prop] = result[prop];
1934
- }
1935
- };
1936
- }
1937
-
1938
- })(typeof window === 'object' ? window : commonjsGlobal);
1939
- } (uaParser, uaParser.exports));
1940
-
1941
- var uaParserExports = uaParser.exports;
1942
- var UAParser = /*@__PURE__*/getDefaultExportFromCjs(uaParserExports);
1943
-
1944
- function getBrowserInfo() {
1945
- var _a = new UAParser().getResult(), browser = _a.browser, device = _a.device, os = _a.os;
1946
- var data = {
1947
- H_timezone_offset: new Date().getTimezoneOffset(),
1948
- H_viewport_width: getScreenWidth(),
1949
- H_viewport_height: getScreenHeight(),
1950
- H_screen_width: window.screen.width,
1951
- H_screen_height: window.screen.height,
1952
- H_lib_version: PV_LIB_VERSION,
1953
- H_lib: 'js',
1954
- H_lib_method: 'code',
1955
- H_browser: browser.name.toLowerCase(),
1956
- H_browser_version: browser.version,
1957
- H_os: os.name,
1958
- H_os_version: os.version,
1959
- H_language: isString(navigator.language)
1960
- ? navigator.language.toLowerCase()
1961
- : '取值异常',
1962
- H_network_type: networkType()
1963
- };
1964
- if (device.type === 'mobile') {
1965
- data.H_model = device.vendor ? device.model : 'UnknownPhone';
1966
- }
1967
- else {
1968
- data.H_model = device.model;
1969
- }
1970
- return data;
1971
- }
1972
-
1973
- var Request = /** @class */ (function () {
1974
- function Request(options) {
1975
- this.options = options;
1976
- }
1977
- return Request;
1978
- }());
1979
- /**
1980
- * 图片请求
1981
- */
1982
- var ImageRequest = /** @class */ (function (_super) {
1983
- __extends(ImageRequest, _super);
1984
- function ImageRequest(options) {
1985
- var _this = _super.call(this, options) || this;
1986
- _this.options = options;
1987
- return _this;
1988
- }
1989
- ImageRequest.prototype.run = function () {
1990
- var _this = this;
1991
- return new Promise(function (resolve) {
1992
- var _a = _this.options, imgUseCrossOrigin = _a.imgUseCrossOrigin, url = _a.url, data = _a.data;
1993
- var img = new Image();
1994
- if (imgUseCrossOrigin) {
1995
- img.crossOrigin = 'anonymous';
1996
- }
1997
- var spliceStr = url.indexOf('?') === -1 ? '?' : '&';
1998
- img.src = "".concat(url).concat(spliceStr, "data=").concat(data);
1999
- var callback = function (type) {
2000
- img.src = null;
2001
- img = null;
2002
- resolve({ type: type });
2003
- };
2004
- img.onload = function () {
2005
- callback('success');
2006
- };
2007
- img.onerror = function () {
2008
- callback('error');
2009
- };
2010
- img.onabort = function () {
2011
- callback('abort');
2012
- };
2013
- });
2014
- };
2015
- return ImageRequest;
2016
- }(Request));
2017
- /**
2018
- * ajax请求
2019
- */
2020
- var AjaxRequest = /** @class */ (function (_super) {
2021
- __extends(AjaxRequest, _super);
2022
- function AjaxRequest(options) {
2023
- var _this = _super.call(this, options) || this;
2024
- _this.options = options;
2025
- return _this;
2026
- }
2027
- AjaxRequest.prototype.run = function () {
2028
- var _this = this;
2029
- return new Promise(function (resolve) {
2030
- var _a = _this.options, url = _a.url, data = _a.data, timeout = _a.timeout;
2031
- var xhr = new XMLHttpRequest();
2032
- xhr.open('POST', url, true);
2033
- xhr.timeout = timeout || 20000;
2034
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2035
- xhr.send(data || null);
2036
- xhr.onreadystatechange = function () {
2037
- if (xhr.readyState === 4) {
2038
- if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
2039
- resolve({
2040
- type: 'success'
2041
- });
2042
- }
2043
- else {
2044
- resolve({
2045
- type: 'error',
2046
- msg: "\u7F51\u7EDC\u5F02\u5E38, \u8BF7\u6C42\u5931\u8D25".concat(xhr.status)
2047
- });
2048
- }
2049
- }
2050
- };
2051
- });
2052
- };
2053
- return AjaxRequest;
2054
- }(Request));
2055
- /**
2056
- * beacon请求
2057
- */
2058
- var BeaconRequest = /** @class */ (function (_super) {
2059
- __extends(BeaconRequest, _super);
2060
- function BeaconRequest(options) {
2061
- var _this = _super.call(this, options) || this;
2062
- _this.options = options;
2063
- return _this;
2064
- }
2065
- BeaconRequest.prototype.run = function () {
2066
- var _this = this;
2067
- return new Promise(function (resolve) {
2068
- var _a = _this.options, url = _a.url, data = _a.data;
2069
- if (navigator.sendBeacon) {
2070
- var isSuccess = navigator.sendBeacon(url, data);
2071
- if (isSuccess) {
2072
- resolve({
2073
- type: 'success'
2074
- });
2075
- }
2076
- else {
2077
- resolve({
2078
- type: 'error',
2079
- msg: 'sendBeacon 请求失败'
2080
- });
2081
- }
2082
- }
2083
- });
2084
- };
2085
- return BeaconRequest;
2086
- }(Request));
2087
-
2088
- var callbacks = [];
2089
- var pending = false;
2090
- var timerFunc;
2091
- function flushCallbacks() {
2092
- var e_1, _a;
2093
- pending = false;
2094
- try {
2095
- for (var callbacks_1 = __values(callbacks), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) {
2096
- var func = callbacks_1_1.value;
2097
- func();
2098
- }
2099
- }
2100
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2101
- finally {
2102
- try {
2103
- if (callbacks_1_1 && !callbacks_1_1.done && (_a = callbacks_1.return)) _a.call(callbacks_1);
2104
- }
2105
- finally { if (e_1) throw e_1.error; }
2106
- }
2107
- callbacks.length = 0;
2108
- }
2109
- if (window && window.requestIdleCallback) {
2110
- timerFunc = function () {
2111
- window.requestIdleCallback(flushCallbacks);
2112
- };
2113
- }
2114
- else if (typeof Promise !== 'undefined') {
2115
- timerFunc = function () {
2116
- Promise.resolve().then(flushCallbacks);
2117
- };
2118
- }
2119
- else {
2120
- timerFunc = function () {
2121
- setTimeout(flushCallbacks, 0);
2122
- };
2123
- }
2124
- function nextTick(callback, ctx) {
2125
- var args = [];
2126
- for (var _i = 2; _i < arguments.length; _i++) {
2127
- args[_i - 2] = arguments[_i];
2128
- }
2129
- var _resolve;
2130
- callbacks.push(function () {
2131
- if (callback) {
2132
- try {
2133
- callback.apply(ctx, args);
2134
- }
2135
- catch (e) { }
2136
- }
2137
- else {
2138
- _resolve(args);
2139
- }
2140
- });
2141
- if (!pending) {
2142
- pending = true;
2143
- timerFunc();
2144
- }
2145
- if (!callback && typeof Promise !== 'undefined') {
2146
- return new Promise(function (resolve) {
2147
- _resolve = resolve;
2148
- });
2149
- }
2150
- }
2151
-
2152
- var Mitt = /** @class */ (function () {
2153
- function Mitt() {
2154
- this.all = new Map();
2155
- }
2156
- Mitt.prototype.on = function (type, handler) {
2157
- var handlers = this.all.get(type);
2158
- if (handlers) {
2159
- handlers.push(handler);
2160
- }
2161
- else {
2162
- this.all.set(type, [handler]);
2163
- }
2164
- };
2165
- Mitt.prototype.emit = function (type) {
2166
- var args = [];
2167
- for (var _i = 1; _i < arguments.length; _i++) {
2168
- args[_i - 1] = arguments[_i];
2169
- }
2170
- var handlers = this.all.get(type);
2171
- if (handlers) {
2172
- handlers.forEach(function (handler) {
2173
- handler.apply(void 0, __spreadArray([], __read(args), false));
2174
- });
2175
- }
2176
- };
2177
- Mitt.prototype.off = function (type, handler) {
2178
- var handlers = this.all.get(type);
2179
- if (handlers) {
2180
- if (handler) {
2181
- var index = handlers.indexOf(handler);
2182
- if (index >= 0) {
2183
- handlers.splice(index, 1);
2184
- }
2185
- }
2186
- else {
2187
- this.all.set(type, []);
2188
- }
2189
- }
2190
- };
2191
- return Mitt;
2192
- }());
2193
- var mitt = new Mitt();
2194
-
2195
- var ConsoleTypes;
2196
- (function (ConsoleTypes) {
2197
- ConsoleTypes["LOG"] = "log";
2198
- ConsoleTypes["INFO"] = "info";
2199
- ConsoleTypes["WARN"] = "warn";
2200
- ConsoleTypes["ERROR"] = "error";
2201
- ConsoleTypes["ASSERT"] = "assert";
2202
- })(ConsoleTypes || (ConsoleTypes = {}));
2203
- var ReportType;
2204
- (function (ReportType) {
2205
- ReportType["BEACON"] = "beacon";
2206
- ReportType["IMAGE"] = "image";
2207
- ReportType["AJAX"] = "ajax";
2208
- })(ReportType || (ReportType = {}));
2209
-
2210
- /**
2211
- * 是否支持console
2212
- */
2213
- function supportConsole() {
2214
- return typeof console !== 'undefined';
2215
- }
2216
- /**
2217
- * 打印日志
2218
- * @param message
2219
- * @param type
2220
- */
2221
- function log(message, type) {
2222
- if (type === void 0) { type = ConsoleTypes.LOG; }
2223
- var func = console[type] || console.log;
2224
- if (typeof func === 'function') {
2225
- func(message);
2226
- }
2227
- }
2228
-
2229
- var IS_NEW_USER_KEY = 'hinasdk_isNewUser';
2230
- var State = /** @class */ (function () {
2231
- function State(options) {
2232
- this.options = options;
2233
- this.storeName = 'hinasdk_crossdata';
2234
- /**
2235
- * 存储对象
2236
- */
2237
- this.state = {
2238
- accountId: null,
2239
- deviceId: null,
2240
- anonymousId: null,
2241
- firstVisitTime: nowStamp(),
2242
- props: {}
2243
- };
2244
- /**
2245
- * 首次触发事件
2246
- */
2247
- this.isFirstTime = false;
2248
- /**
2249
- * 首日触发事件
2250
- */
2251
- this.isFirstDay = false;
2252
- /**
2253
- * 是否设置第一次访问属性
2254
- */
2255
- this.isSetFirstVisit = true;
2256
- }
2257
- State.prototype.log = function (message, type) {
2258
- if (type === void 0) { type = ConsoleTypes.LOG; }
2259
- var showLog = this.options.showLog;
2260
- if (!supportConsole() || !showLog)
2261
- return;
2262
- log(message, type);
2263
- };
2264
- /**
2265
- * 初始化存储
2266
- */
2267
- State.prototype.init = function () {
2268
- var cookieStorage = new CookieStorage();
2269
- var memoryStorage = new MemoryStorage();
2270
- var localStorage = new LocalStorage();
2271
- if (cookieStorage.isSupport()) {
2272
- this.storage = cookieStorage;
2273
- }
2274
- else {
2275
- this.log('Cookie storage is not supported, SDK internal cache has been enabled', ConsoleTypes.WARN);
2276
- this.storage = memoryStorage;
2277
- }
2278
- if (localStorage.isSupport()) {
2279
- this.localStorage = localStorage;
2280
- }
2281
- else {
2282
- this.log('localStorage is not supported, SDK internal cache has been enabled', ConsoleTypes.WARN);
2283
- }
2284
- var oldState;
2285
- oldState = this.storage.get(this.storeName);
2286
- if (!oldState && this.localStorage) {
2287
- oldState = this.localStorage.get(this.storeName);
2288
- }
2289
- if (oldState && isJSONString(oldState)) {
2290
- try {
2291
- oldState = JSON.parse(oldState);
2292
- this.state = merge(this.state, oldState);
2293
- }
2294
- catch (e) {
2295
- this.log(e, ConsoleTypes.ERROR);
2296
- }
2297
- }
2298
- // 如果不存在hinasdk_crossdata的存储数据,则说明是第一次访问sdk
2299
- if (oldState) {
2300
- this.isSetFirstVisit = false;
2301
- this.save();
2302
- }
2303
- else {
2304
- this.isFirstDay = true;
2305
- this.isFirstTime = true;
2306
- var date = new Date();
2307
- var dateObj = {
2308
- h: 23 - date.getHours(),
2309
- m: 59 - date.getMinutes(),
2310
- s: 59 - date.getSeconds()
2311
- };
2312
- var second = dateObj.h * 3600 + dateObj.m * 60 + dateObj.s;
2313
- // todo 设置这个值似乎没有什么用
2314
- this.storage.set(IS_NEW_USER_KEY, 'true', second);
2315
- }
2316
- // 第一次需要生成匿名ID和设备ID,此时这两个ID是一致的,其中设备ID可以修改,但是匿名ID设置了之后 就不能再改变了
2317
- var uuid = generatorUUID();
2318
- if (!this.getAnonymousId()) {
2319
- this.setAnonymousId(uuid);
2320
- }
2321
- if (!this.getDeviceId()) {
2322
- this.setDeviceId(uuid);
2323
- }
2324
- };
2325
- /**
2326
- * 清空state数据
2327
- */
2328
- State.prototype.clear = function () {
2329
- this.state = {};
2330
- this.save();
2331
- };
2332
- /**
2333
- * 缓存state数据
2334
- */
2335
- State.prototype.save = function () {
2336
- // cookie存于子域名中,用于跨站共享
2337
- this.storage.setDomain(this.storeName, JSON.stringify(this.state));
2338
- if (this.localStorage) {
2339
- this.localStorage.set(this.storeName, JSON.stringify(this.state));
2340
- }
2341
- };
2342
- /**
2343
- * 设置共享数据
2344
- * @param name
2345
- * @param value
2346
- */
2347
- State.prototype.set = function (name, value) {
2348
- this.state[name] = value;
2349
- this.save();
2350
- };
2351
- /**
2352
- * 检查设置值是否合法
2353
- * @param name
2354
- * @param value
2355
- */
2356
- State.prototype.checkSetValue = function (name, value) {
2357
- value = value !== null && value !== void 0 ? value : '';
2358
- if (isNumber(value) || isString(value)) {
2359
- return true;
2360
- }
2361
- this.log("".concat(name, ": id must be string or number"), ConsoleTypes.WARN);
2362
- return false;
2363
- };
2364
- /**
2365
- * 设置deviceId
2366
- * @param id
2367
- */
2368
- State.prototype.setDeviceId = function (id) {
2369
- if (id === void 0) { id = ''; }
2370
- if (this.checkSetValue('deviceId', id)) {
2371
- this.set('deviceId', id);
2372
- }
2373
- };
2374
- /**
2375
- * 设置账号id
2376
- * @param id
2377
- */
2378
- State.prototype.setAccountId = function (id) {
2379
- if (id === void 0) { id = ''; }
2380
- if (this.checkSetValue('accountId', id)) {
2381
- this.set('accountId', id);
2382
- }
2383
- };
2384
- /**
2385
- * 设置匿名id
2386
- * @param id
2387
- */
2388
- State.prototype.setAnonymousId = function (id) {
2389
- if (this.state.anonymousId) {
2390
- this.log("Current anonymousId is ".concat(this.getAnonymousId(), ", it has been set"), ConsoleTypes.WARN);
2391
- return;
2392
- }
2393
- if (this.checkSetValue('anonymousId', id)) {
2394
- this.set('anonymousId', id);
2395
- }
2396
- };
2397
- /**
2398
- * 设置广告参数
2399
- * @param props
2400
- */
2401
- State.prototype.setProps = function (props) {
2402
- var newProps = merge(this.state.props || {}, props);
2403
- for (var key in newProps) {
2404
- if (typeof newProps[key] === 'string') {
2405
- newProps[key] = newProps[key].slice(0, MAX_REFERRER_STRING_LENGTH);
2406
- }
2407
- }
2408
- this.set('props', newProps);
2409
- };
2410
- /**
2411
- * 获取匿名ID
2412
- */
2413
- State.prototype.getAnonymousId = function () {
2414
- return this.state.anonymousId;
2415
- };
2416
- /**
2417
- * 获取设备ID
2418
- */
2419
- State.prototype.getDeviceId = function () {
2420
- return this.state.deviceId;
2421
- };
2422
- /**
2423
- * 获取账户ID
2424
- */
2425
- State.prototype.getAccountId = function () {
2426
- return this.state.accountId;
2427
- };
2428
- /**
2429
- * 获取cookie值
2430
- */
2431
- State.prototype.getCookie = function () {
2432
- return this.storage.get(this.storeName);
2433
- };
2434
- return State;
2435
- }());
2436
-
2437
- exports.AjaxRequest = AjaxRequest;
2438
- exports.BeaconRequest = BeaconRequest;
2439
- exports.COOKIE_TEST_NAME = COOKIE_TEST_NAME;
2440
- exports.CookieStorage = CookieStorage;
2441
- exports.EPM_LIB_VERSION = EPM_LIB_VERSION;
2442
- exports.ImageRequest = ImageRequest;
2443
- exports.ListenPageState = ListenPageState;
2444
- exports.LocalStorage = LocalStorage;
2445
- exports.MAX_REFERRER_STRING_LENGTH = MAX_REFERRER_STRING_LENGTH;
2446
- exports.MAX_STRING_LENGTH = MAX_STRING_LENGTH;
2447
- exports.MemoryStorage = MemoryStorage;
2448
- exports.PV_LIB_VERSION = PV_LIB_VERSION;
2449
- exports.Request = Request;
2450
- exports.SearchKeyword = SearchKeyword;
2451
- exports.State = State;
2452
- exports.base64Decode = base64Decode;
2453
- exports.base64Encode = base64Encode;
2454
- exports.formatDecimal = formatDecimal;
2455
- exports.generatorUUID = generatorUUID;
2456
- exports.getBrowserInfo = getBrowserInfo;
2457
- exports.getCookieTopLevelDomain = getCookieTopLevelDomain;
2458
- exports.getCurrentDomain = getCurrentDomain;
2459
- exports.getElementParents = getElementParents;
2460
- exports.getElementProperties = getElementProperties;
2461
- exports.getHostname = getHostname;
2462
- exports.getInputElementContent = getInputElementContent;
2463
- exports.getPageProperties = getPageProperties;
2464
- exports.getQueryParam = getQueryParam;
2465
- exports.getRandom = getRandom;
2466
- exports.getReferrer = getReferrer;
2467
- exports.getScreenHeight = getScreenHeight;
2468
- exports.getScreenWidth = getScreenWidth;
2469
- exports.getScrollLeft = getScrollLeft;
2470
- exports.getScrollTop = getScrollTop;
2471
- exports.getURL = getURL;
2472
- exports.getURLSearchParams = getURLSearchParams;
2473
- exports.getUmtsParams = getUmtsParams;
2474
- exports.getUtm = getUtm;
2475
- exports.handleDecodeURLComponent = handleDecodeURLComponent;
2476
- exports.handleEncodeURLComponent = handleEncodeURLComponent;
2477
- exports.isArray = isArray;
2478
- exports.isBoolean = isBoolean;
2479
- exports.isDate = isDate;
2480
- exports.isElement = isElement;
2481
- exports.isEmptyObject = isEmptyObject;
2482
- exports.isFunction = isFunction;
2483
- exports.isJSONString = isJSONString;
2484
- exports.isNumber = isNumber;
2485
- exports.isObject = isObject;
2486
- exports.isReferralTraffic = isReferralTraffic;
2487
- exports.isString = isString;
2488
- exports.isUndefined = isUndefined;
2489
- exports.isValid = isValid;
2490
- exports.log = log;
2491
- exports.merge = merge;
2492
- exports.mitt = mitt;
2493
- exports.networkType = networkType;
2494
- exports.nextTick = nextTick;
2495
- exports.noop = noop;
2496
- exports.nowStamp = nowStamp;
2497
- exports.replaceOld = replaceOld;
2498
- exports.safeJSONParse = safeJSONParse;
2499
- exports.searchKeywords = searchKeywords;
2500
- exports.searchTypes = searchTypes;
2501
- exports.socialTypes = socialTypes;
2502
- exports.stripEmptyProperties = stripEmptyProperties;
2503
- exports.supportConsole = supportConsole;
2504
- exports.supportHistory = supportHistory;
2505
- exports.utmTypes = utmTypes;
2506
-
2507
- }));
2508
- //# sourceMappingURL=index.js.map