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