ua-browser 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +206 -204
- package/dist/index.cjs.js +10 -64
- package/dist/index.d.ts +140 -140
- package/dist/index.esm.mjs +10 -64
- package/dist/index.min.js +1 -1
- package/index.js +6 -6
- package/package.json +64 -63
package/dist/index.esm.mjs
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function _defineProperties(
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
3
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
4
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
var version = "0.1.7";
|
|
8
8
|
var NAVIGATOR = {};
|
|
9
|
-
|
|
10
9
|
if (typeof navigator !== 'undefined') {
|
|
11
10
|
NAVIGATOR = navigator;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
var UA = NAVIGATOR.userAgent || '';
|
|
15
13
|
var mimeTypes = NAVIGATOR.mimeTypes;
|
|
16
14
|
var platfrom = NAVIGATOR.platform;
|
|
17
15
|
/** 内核 */
|
|
18
|
-
|
|
19
16
|
var engineRegExp = {
|
|
20
17
|
Trident: /(Trident|NET CLR)/,
|
|
21
18
|
Presto: /Presto/,
|
|
@@ -24,7 +21,6 @@ var engineRegExp = {
|
|
|
24
21
|
KHTML: /KHTML\//
|
|
25
22
|
};
|
|
26
23
|
/** 浏览器 */
|
|
27
|
-
|
|
28
24
|
var browserRegExp = {
|
|
29
25
|
Safari: /Safari/,
|
|
30
26
|
Chrome: /(Chrome|CriOS)/,
|
|
@@ -77,7 +73,6 @@ var browserRegExp = {
|
|
|
77
73
|
Douyin: /aweme/
|
|
78
74
|
};
|
|
79
75
|
/** 系统或平台 */
|
|
80
|
-
|
|
81
76
|
var osRegExp = {
|
|
82
77
|
Windows: /Windows/,
|
|
83
78
|
Linux: /(Linux|X11)/,
|
|
@@ -96,13 +91,11 @@ var osRegExp = {
|
|
|
96
91
|
WebOS: /hpwOS/
|
|
97
92
|
};
|
|
98
93
|
/** 设备 */
|
|
99
|
-
|
|
100
94
|
var deviceRegExp = {
|
|
101
95
|
Mobile: /(Mobi|iPh|480)/,
|
|
102
96
|
Tablet: /(Tablet|Pad|Nexus 7)/
|
|
103
97
|
};
|
|
104
98
|
/** 环境 */
|
|
105
|
-
|
|
106
99
|
var envRegExp = {
|
|
107
100
|
isWebview: /; wv/
|
|
108
101
|
};
|
|
@@ -112,7 +105,6 @@ var hash = {
|
|
|
112
105
|
engine: Object.keys(engineRegExp),
|
|
113
106
|
browser: Object.keys(browserRegExp)
|
|
114
107
|
};
|
|
115
|
-
|
|
116
108
|
var getMimeType = function getMimeType(value) {
|
|
117
109
|
try {
|
|
118
110
|
return !!mimeTypes.namedItem(value);
|
|
@@ -120,26 +112,20 @@ var getMimeType = function getMimeType(value) {
|
|
|
120
112
|
return false;
|
|
121
113
|
}
|
|
122
114
|
};
|
|
123
|
-
|
|
124
115
|
var getValueOf = function getValueOf(values, reg) {
|
|
125
116
|
var ua = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : UA;
|
|
126
117
|
var i = values.length;
|
|
127
|
-
|
|
128
118
|
while (i--) {
|
|
129
119
|
var value = values[i];
|
|
130
120
|
if (reg[value].test(ua)) return value;
|
|
131
121
|
}
|
|
132
|
-
|
|
133
122
|
return 'unknown';
|
|
134
123
|
};
|
|
135
|
-
|
|
136
124
|
var _windowVersion;
|
|
137
|
-
|
|
138
125
|
if (NAVIGATOR === null || NAVIGATOR === void 0 ? void 0 : NAVIGATOR.userAgentData) {
|
|
139
126
|
NAVIGATOR.userAgentData.getHighEntropyValues(['platformVersion']).then(function (ua) {
|
|
140
127
|
if (NAVIGATOR.userAgentData.platform === 'Windows') {
|
|
141
128
|
var majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
|
|
142
|
-
|
|
143
129
|
if (majorPlatformVersion >= 13) {
|
|
144
130
|
_windowVersion = '11';
|
|
145
131
|
} else {
|
|
@@ -148,29 +134,22 @@ if (NAVIGATOR === null || NAVIGATOR === void 0 ? void 0 : NAVIGATOR.userAgentDat
|
|
|
148
134
|
}
|
|
149
135
|
});
|
|
150
136
|
}
|
|
151
|
-
|
|
152
137
|
var getLanguage = function getLanguage() {
|
|
153
138
|
var _a;
|
|
154
|
-
|
|
155
139
|
return (_a = NAVIGATOR.browserLanguage || NAVIGATOR.language) === null || _a === void 0 ? void 0 : _a.replace(/-\w+/g, function (word) {
|
|
156
140
|
return word.toUpperCase();
|
|
157
141
|
});
|
|
158
142
|
};
|
|
159
|
-
|
|
160
143
|
var isWechatMiniapp = function isWechatMiniapp() {
|
|
161
144
|
return typeof __wxjs_environment !== 'undefined' && __wxjs_environment === 'miniprogram';
|
|
162
145
|
};
|
|
163
|
-
|
|
164
146
|
var isWebview = function isWebview(ua) {
|
|
165
147
|
return envRegExp.isWebview.test(ua);
|
|
166
148
|
};
|
|
167
|
-
|
|
168
149
|
var UaBrowser = /*#__PURE__*/function () {
|
|
169
150
|
function UaBrowser(ua) {
|
|
170
151
|
var _this = this;
|
|
171
|
-
|
|
172
152
|
_classCallCheck(this, UaBrowser);
|
|
173
|
-
|
|
174
153
|
this.ua = UA;
|
|
175
154
|
this.version = {
|
|
176
155
|
Safari: function Safari() {
|
|
@@ -188,7 +167,7 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
188
167
|
Firefox: function Firefox() {
|
|
189
168
|
return _this.ua.replace(/^.*Firefox\/([\d.]+).*$/, '$1').replace(/^.*FxiOS\/([\d.]+).*$/, '$1');
|
|
190
169
|
},
|
|
191
|
-
'Firefox Focus': function
|
|
170
|
+
'Firefox Focus': function Firefox_Focus() {
|
|
192
171
|
return _this.ua.replace(/^.*Focus\/([\d.]+).*$/, '$1');
|
|
193
172
|
},
|
|
194
173
|
Chromium: function Chromium() {
|
|
@@ -212,7 +191,7 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
212
191
|
QupZilla: function QupZilla() {
|
|
213
192
|
return _this.ua.replace(/^.*QupZilla[\s]([\d.]+).*$/, '$1');
|
|
214
193
|
},
|
|
215
|
-
'Coc Coc': function
|
|
194
|
+
'Coc Coc': function Coc_Coc() {
|
|
216
195
|
return _this.ua.replace(/^.*coc_coc_browser\/([\d.]+).*$/, '$1');
|
|
217
196
|
},
|
|
218
197
|
Kindle: function Kindle() {
|
|
@@ -310,7 +289,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
310
289
|
},
|
|
311
290
|
'360SE': function SE() {
|
|
312
291
|
var vers = _this.getChromeVars();
|
|
313
|
-
|
|
314
292
|
var hash = {
|
|
315
293
|
'108': '14.0',
|
|
316
294
|
'86': '13.0',
|
|
@@ -327,7 +305,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
327
305
|
},
|
|
328
306
|
'360EE': function EE() {
|
|
329
307
|
var vers = _this.getChromeVars();
|
|
330
|
-
|
|
331
308
|
var hash = {
|
|
332
309
|
'86': '13.0',
|
|
333
310
|
'78': '12.0',
|
|
@@ -341,7 +318,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
341
318
|
},
|
|
342
319
|
'2345Explorer': function Explorer() {
|
|
343
320
|
var vers = _this.getChromeVars();
|
|
344
|
-
|
|
345
321
|
var hash = {
|
|
346
322
|
'69': '10.0',
|
|
347
323
|
'55': '9.9'
|
|
@@ -350,13 +326,10 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
350
326
|
},
|
|
351
327
|
Liebao: function Liebao() {
|
|
352
328
|
var _version = '';
|
|
353
|
-
|
|
354
329
|
if (/LieBaoFast/.test(_this.ua)) {
|
|
355
330
|
_version = _this.ua.replace(/^.*LieBaoFast\/([\d.]+).*$/, '$1');
|
|
356
331
|
}
|
|
357
|
-
|
|
358
332
|
var vers = _this.getChromeVars();
|
|
359
|
-
|
|
360
333
|
var hash = {
|
|
361
334
|
'57': '6.5',
|
|
362
335
|
'49': '6.0',
|
|
@@ -380,7 +353,7 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
380
353
|
Debian: function Debian() {
|
|
381
354
|
return _this.ua.replace(/^.*Debian\/([\d.]+).*$/, '$1');
|
|
382
355
|
},
|
|
383
|
-
'Windows Phone': function
|
|
356
|
+
'Windows Phone': function Windows_Phone() {
|
|
384
357
|
return _this.ua.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, '$2');
|
|
385
358
|
},
|
|
386
359
|
MacOS: function MacOS() {
|
|
@@ -391,7 +364,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
391
364
|
},
|
|
392
365
|
HarmonyOS: function HarmonyOS() {
|
|
393
366
|
var vers = _this.ua.replace(/^Mozilla.*Android ([\d.]+)[;)].*$/, '$1');
|
|
394
|
-
|
|
395
367
|
var hash = {
|
|
396
368
|
'10': '2'
|
|
397
369
|
};
|
|
@@ -399,7 +371,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
399
371
|
},
|
|
400
372
|
Windows: function Windows() {
|
|
401
373
|
var vers = _this.ua.replace(/^Mozilla\/\d.0 \(Windows NT ([\d.]+);.*$/, '$1');
|
|
402
|
-
|
|
403
374
|
var hash = {
|
|
404
375
|
'10': '10',
|
|
405
376
|
'6.4': '10',
|
|
@@ -414,15 +385,12 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
414
385
|
return hash[vers] || parseInt(vers).toString();
|
|
415
386
|
}
|
|
416
387
|
};
|
|
417
|
-
|
|
418
388
|
this.getChromeVars = function () {
|
|
419
389
|
return _this.ua.replace(/^.*Chrome\/([\d]+).*$/, '$1');
|
|
420
390
|
};
|
|
421
|
-
|
|
422
391
|
this.setUA(ua);
|
|
423
392
|
}
|
|
424
|
-
|
|
425
|
-
_createClass(UaBrowser, [{
|
|
393
|
+
return _createClass(UaBrowser, [{
|
|
426
394
|
key: "getOs",
|
|
427
395
|
value: function getOs() {
|
|
428
396
|
return getValueOf(hash.os, osRegExp, this.ua);
|
|
@@ -443,7 +411,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
443
411
|
if (platfrom === 'MacIntel' && NAVIGATOR.maxTouchPoints > 1) {
|
|
444
412
|
return 'Tablet';
|
|
445
413
|
}
|
|
446
|
-
|
|
447
414
|
var device = getValueOf(hash.device, deviceRegExp, this.ua);
|
|
448
415
|
return device === 'unknown' ? 'PC' : device;
|
|
449
416
|
}
|
|
@@ -456,7 +423,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
456
423
|
if (typeof ua !== 'undefined') {
|
|
457
424
|
console.warn('`ua` must be of type string.');
|
|
458
425
|
}
|
|
459
|
-
|
|
460
426
|
this.ua = UA;
|
|
461
427
|
}
|
|
462
428
|
}
|
|
@@ -464,7 +430,6 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
464
430
|
key: "getEnv",
|
|
465
431
|
value: function getEnv(ua) {
|
|
466
432
|
var _a, _b;
|
|
467
|
-
|
|
468
433
|
this.setUA(ua);
|
|
469
434
|
var env = {
|
|
470
435
|
version: 'unknown',
|
|
@@ -479,23 +444,19 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
479
444
|
};
|
|
480
445
|
var browser = env.browser;
|
|
481
446
|
var is360 = false;
|
|
482
|
-
|
|
483
447
|
if (typeof chrome !== 'undefined') {
|
|
484
448
|
var vers = this.getChromeVars();
|
|
485
|
-
|
|
486
449
|
if (chrome.adblock2345 || chrome.common2345) {
|
|
487
450
|
env.browser = '2345Explorer';
|
|
488
451
|
} else if (getMimeType('application/360softmgrplugin') || getMimeType('application/mozilla-npqihooquicklogin') || vers > '36' && typeof showModalDialog !== 'undefined') {
|
|
489
452
|
is360 = true;
|
|
490
453
|
} else if (vers > '45') {
|
|
491
454
|
is360 = getMimeType('application/vnd.chromium.remoting-viewer');
|
|
492
|
-
|
|
493
455
|
if (!is360 && vers >= '69') {
|
|
494
456
|
is360 = getMimeType('application/hwepass2001.installepass2001') || getMimeType('application/asx');
|
|
495
457
|
}
|
|
496
458
|
}
|
|
497
459
|
}
|
|
498
|
-
|
|
499
460
|
if (env.device === 'Mobile' && /iPad/.test(this.ua)) {
|
|
500
461
|
env.device = 'Tablet';
|
|
501
462
|
} else if (is360) {
|
|
@@ -505,35 +466,27 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
505
466
|
browser = '360EE';
|
|
506
467
|
}
|
|
507
468
|
}
|
|
508
|
-
|
|
509
469
|
if (hash.browser.indexOf(browser) >= hash.browser.indexOf(env.browser)) {
|
|
510
470
|
env.browser = browser;
|
|
511
471
|
}
|
|
512
|
-
|
|
513
472
|
if (env.browser === 'Baidu' && browserRegExp.Opera.test(this.ua)) {
|
|
514
473
|
env.browser = 'Opera';
|
|
515
474
|
}
|
|
516
|
-
|
|
517
475
|
if (env.os in this.osVersion) {
|
|
518
476
|
env.osVersion = this.osVersion[env.os]();
|
|
519
|
-
|
|
520
477
|
if (env.osVersion === this.ua) {
|
|
521
478
|
env.osVersion = 'unknown';
|
|
522
479
|
}
|
|
523
480
|
}
|
|
524
|
-
|
|
525
481
|
if (env.os === 'Windows' && _windowVersion) {
|
|
526
482
|
env.osVersion = _windowVersion;
|
|
527
483
|
}
|
|
528
|
-
|
|
529
484
|
if (env.browser in this.version) {
|
|
530
485
|
env.version = this.version[env.browser]();
|
|
531
|
-
|
|
532
486
|
if (env.version === this.ua) {
|
|
533
487
|
env.version = 'unknown';
|
|
534
488
|
}
|
|
535
489
|
}
|
|
536
|
-
|
|
537
490
|
if (env.browser === 'Chrome' && this.ua.match(/\S+Browser/)) {
|
|
538
491
|
env.browser = this.ua.match(/\S+Browser/)[0];
|
|
539
492
|
env.version = this.ua.replace(/^.*Browser\/([\d.]+).*$/, '$1');
|
|
@@ -542,26 +495,19 @@ var UaBrowser = /*#__PURE__*/function () {
|
|
|
542
495
|
} else if (env.browser === 'Wechat' && isWechatMiniapp()) {
|
|
543
496
|
env.browser = 'Wechat Miniapp';
|
|
544
497
|
}
|
|
545
|
-
|
|
546
498
|
if (env.browser === 'Edge') {
|
|
547
499
|
env.engine = parseInt(env.version) > 75 ? 'Blink' : 'EdgeHTML';
|
|
548
500
|
} else if (browserRegExp.Chrome.test(this.ua) && env.engine === 'WebKit' && parseInt(this.version.Chrome()) > 27 || env.browser === 'Opera' && parseInt(env.version) > 12 || env.browser === 'Yandex') {
|
|
549
501
|
env.engine = 'Blink';
|
|
550
502
|
}
|
|
551
|
-
|
|
552
503
|
return env;
|
|
553
504
|
}
|
|
554
505
|
}]);
|
|
555
|
-
|
|
556
|
-
return UaBrowser;
|
|
557
506
|
}();
|
|
558
|
-
|
|
559
507
|
var instance = new UaBrowser();
|
|
560
|
-
|
|
561
508
|
function Wrap(ua) {
|
|
562
509
|
return instance.getEnv(ua);
|
|
563
510
|
}
|
|
564
|
-
|
|
565
511
|
Wrap.isWebview = isWebview;
|
|
566
512
|
Wrap.isWechatMiniapp = isWechatMiniapp;
|
|
567
513
|
Wrap.getLanguage = getLanguage;
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,r,n){return r&&_defineProperties(e.prototype,r),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e,r){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).uaBrowser=r()}(this,(function(){"use strict";var e={};"undefined"!=typeof navigator&&(e=navigator);var r,n=e.userAgent||"",o=e.mimeTypes,i=e.platform,a={Trident:/(Trident|NET CLR)/,Presto:/Presto/,WebKit:/AppleWebKit/,Gecko:/Gecko\//,KHTML:/KHTML\//},t={Safari:/Safari/,Chrome:/(Chrome|CriOS)/,IE:/(MSIE|Trident)/,Edge:/(Edge|Edg\/|EdgA|EdgiOS)/,Firefox:/(Firefox|FxiOS)/,"Firefox Focus":/Focus/,Chromium:/Chromium/,Opera:/(Opera|OPR|OPT)/,Vivaldi:/Vivaldi/,Yandex:/YaBrowser/,Arora:/Arora/,Lunascape:/Lunascape/,QupZilla:/QupZilla/,"Coc Coc":/coc_coc_browser/,Kindle:/(Kindle|Silk\/)/,Iceweasel:/Iceweasel/,Konqueror:/Konqueror/,Iceape:/Iceape/,SeaMonkey:/SeaMonkey/,Epiphany:/Epiphany/,360:/(QihooBrowser|QHBrowser)/,"360EE":/360EE/,"360SE":/360SE/,UC:/(UCBrowser|UBrowser|UCWEB)/,QQBrowser:/QQBrowser/,QQ:/QQ\//,Baidu:/(Baidu|BIDUBrowser|baidubrowser|baiduboxapp|BaiduHD)/,Maxthon:/Maxthon/,Sogou:/(MetaSr|Sogou)/,Liebao:/(LBBROWSER|LieBaoFast)/,"2345Explorer":/2345Explorer/,"115Browser":/115Browser/,TheWorld:/TheWorld/,XiaoMi:/MiuiBrowser/,Vivo:/VivoBrowser/,Huawei:/HuaweiBrowser/,OPPO:/HeyTapBrowser/,Quark:/Quark/,Qiyu:/Qiyu/,Wechat:/MicroMessenger/,WechatWork:/wxwork\//,Taobao:/AliApp\(TB/,Alipay:/AliApp\(AP/,Weibo:/Weibo/,Douban:/com\.douban\.frodo/,Suning:/SNEBUY-APP/,iQiYi:/IqiyiApp/,DingTalk:/DingTalk/,Douyin:/aweme/},u={Windows:/Windows/,Linux:/(Linux|X11)/,MacOS:/Macintosh/,Android:/(Android|Adr)/,HarmonyOS:/HarmonyOS/,Ubuntu:/Ubuntu/,FreeBSD:/FreeBSD/,Debian:/Debian/,"Windows Phone":/(IEMobile|Windows Phone)/,BlackBerry:/(BlackBerry|RIM)/,MeeGo:/MeeGo/,Symbian:/Symbian/,iOS:/like Mac OS X/,"Chrome OS":/CrOS/,WebOS:/hpwOS/},c={Mobile:/(Mobi|iPh|480)/,Tablet:/(Tablet|Pad|Nexus 7)/},s={isWebview:/; wv/},l={os:Object.keys(u),device:Object.keys(c),engine:Object.keys(a),browser:Object.keys(t)},p=function(e){try{return!!o.namedItem(e)}catch(e){return!1}},d=function(e,r){for(var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,i=e.length;i--;){var a=e[i];if(r[a].test(o))return a}return"unknown"};(null==e?void 0:e.userAgentData)&&e.userAgentData.getHighEntropyValues(["platformVersion"]).then((function(n){if("Windows"===e.userAgentData.platform){var o=parseInt(n.platformVersion.split(".")[0]);r=o>=13?"11":"10"}}));var f=function(){var r;return null===(r=e.browserLanguage||e.language)||void 0===r?void 0:r.replace(/-\w+/g,(function(e){return e.toUpperCase()}))},$=function(){return"undefined"!=typeof __wxjs_environment&&"miniprogram"===__wxjs_environment},w=function(e){return s.isWebview.test(e)},h=new(function(){function o(e){var r=this;_classCallCheck(this,o),this.ua=n,this.version={Safari:function(){return r.ua.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){return r.ua.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){return r.ua.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return r.ua.replace(/^.*Edge\/([\d.]+).*$/,"$1").replace(/^.*Edg\/([\d.]+).*$/,"$1").replace(/^.*EdgA\/([\d.]+).*$/,"$1").replace(/^.*EdgiOS\/([\d.]+).*$/,"$1")},Firefox:function(){return r.ua.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return r.ua.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return r.ua.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){return r.ua.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1").replace(/^.*OPT\/([\d.]+).*$/,"$1")},Vivaldi:function(){return r.ua.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return r.ua.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Arora:function(){return r.ua.replace(/^.*Arora\/([\d.]+).*$/,"$1")},Lunascape:function(){return r.ua.replace(/^.*Lunascape[\s]([\d.]+).*$/,"$1")},QupZilla:function(){return r.ua.replace(/^.*QupZilla[\s]([\d.]+).*$/,"$1")},"Coc Coc":function(){return r.ua.replace(/^.*coc_coc_browser\/([\d.]+).*$/,"$1")},Kindle:function(){return r.ua.replace(/^.*Version\/([\d.]+).*$/,"$1")},Iceweasel:function(){return r.ua.replace(/^.*Iceweasel\/([\d.]+).*$/,"$1")},Konqueror:function(){return r.ua.replace(/^.*Konqueror\/([\d.]+).*$/,"$1")},Iceape:function(){return r.ua.replace(/^.*Iceape\/([\d.]+).*$/,"$1")},SeaMonkey:function(){return r.ua.replace(/^.*SeaMonkey\/([\d.]+).*$/,"$1")},Epiphany:function(){return r.ua.replace(/^.*Epiphany\/([\d.]+).*$/,"$1")},Maxthon:function(){return r.ua.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return r.ua.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return r.ua.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return r.ua.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1").replace(/^.*baiduboxapp\/([\d.]+).*$/,"$1")},UC:function(){return r.ua.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){return r.ua.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},TheWorld:function(){return r.ua.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return r.ua.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Vivo:function(){return r.ua.replace(/^.*VivoBrowser\/([\d.]+).*$/,"$1")},OPPO:function(){return r.ua.replace(/^.*HeyTapBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return r.ua.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return r.ua.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return r.ua.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},WechatWork:function(){return r.ua.replace(/^.*wxwork\/([\d.]+).*$/,"$1")},Taobao:function(){return r.ua.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return r.ua.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return r.ua.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return r.ua.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return r.ua.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return r.ua.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")},DingTalk:function(){return r.ua.replace(/^.*DingTalk\/([\d.]+).*$/,"$1")},Huawei:function(){return r.ua.replace(/^.*Version\/([\d.]+).*$/,"$1").replace(/^.*HuaweiBrowser\/([\d.]+).*$/,"$1")},Douyin:function(){return r.ua.replace(/^.*app_version\/([\d.]+).*$/,"$1")},"115Browser":function(){return r.ua.replace(/^.*115Browser\/([\d.]+).*$/,"$1")},360:function(){return r.ua.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{108:"14.0",86:"13.0",78:"12.0",69:"11.0",63:"10.0",55:"9.1",45:"8.1",42:"8.0",31:"7.0",21:"6.3"}[r.getChromeVars()]||""},"360EE":function(){return{86:"13.0",78:"12.0",69:"11.0",63:"9.5",55:"9.0",50:"8.7",30:"7.5"}[r.getChromeVars()]||""},"2345Explorer":function(){return{69:"10.0",55:"9.9"}[r.getChromeVars()]||r.ua.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1").replace(/^.*Mb2345Browser\/([\d.]+).*$/,"$1")},Liebao:function(){var e="";/LieBaoFast/.test(r.ua)&&(e=r.ua.replace(/^.*LieBaoFast\/([\d.]+).*$/,"$1"));var n=r.getChromeVars();return e||{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[n]||""}},this.osVersion={Android:function(){return r.ua.replace(/^.*Android ([\d.]+);.*$/,"$1")},iOS:function(){return r.ua.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,".")},Debian:function(){return r.ua.replace(/^.*Debian\/([\d.]+).*$/,"$1")},"Windows Phone":function(){return r.ua.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2")},MacOS:function(){return r.ua.replace(/^.*Mac OS X -?([\d_]+).*$/,"$1").replace(/_/g,".")},WebOS:function(){return r.ua.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")},HarmonyOS:function(){return{10:"2"}[r.ua.replace(/^Mozilla.*Android ([\d.]+)[;)].*$/,"$1")]||""},Windows:function(){var e=r.ua.replace(/^Mozilla\/\d.0 \(Windows NT ([\d.]+);.*$/,"$1");return{10:"10",6.4:"10",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP",5.1:"XP","5.0":"2000"}[e]||parseInt(e).toString()}},this.getChromeVars=function(){return r.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")},this.setUA(e)}return _createClass(o,[{key:"getOs",value:function(){return d(l.os,u,this.ua)}},{key:"getEngine",value:function(){return d(l.engine,a,this.ua)}},{key:"getBrowser",value:function(){return d(l.browser,t,this.ua)}},{key:"getDevice",value:function(){if("MacIntel"===i&&e.maxTouchPoints>1)return"Tablet";var r=d(l.device,c,this.ua);return"unknown"===r?"PC":r}},{key:"setUA",value:function(e){"string"==typeof e?this.ua=e:(void 0!==e&&console.warn("`ua` must be of type string."),this.ua=n)}},{key:"getEnv",value:function(n){var o,a;this.setUA(n);var u={version:"unknown",osVersion:"unknown",engine:this.getEngine(),browser:this.getBrowser(),os:this.getOs(),device:this.getDevice(),isWebview:w(this.ua),language:null!==(o=f())&&void 0!==o?o:"unknown",platfrom:null!=i?i:"unknown"},c=u.browser,s=!1;if("undefined"!=typeof chrome){var d=this.getChromeVars();chrome.adblock2345||chrome.common2345?u.browser="2345Explorer":p("application/360softmgrplugin")||p("application/mozilla-npqihooquicklogin")||d>"36"&&"undefined"!=typeof showModalDialog?s=!0:d>"45"&&!(s=p("application/vnd.chromium.remoting-viewer"))&&d>="69"&&(s=p("application/hwepass2001.installepass2001")||p("application/asx"))}return"Mobile"===u.device&&/iPad/.test(this.ua)?u.device="Tablet":s&&(c=p("application/gameplugin")||!(null===(a=null==e?void 0:e.connection)||void 0===a?void 0:a.saveData)?"360SE":"360EE"),l.browser.indexOf(c)>=l.browser.indexOf(u.browser)&&(u.browser=c),"Baidu"===u.browser&&t.Opera.test(this.ua)&&(u.browser="Opera"),u.os in this.osVersion&&(u.osVersion=this.osVersion[u.os](),u.osVersion===this.ua&&(u.osVersion="unknown")),"Windows"===u.os&&r&&(u.osVersion=r),u.browser in this.version&&(u.version=this.version[u.browser](),u.version===this.ua&&(u.version="unknown")),"Chrome"===u.browser&&this.ua.match(/\S+Browser/)?(u.browser=this.ua.match(/\S+Browser/)[0],u.version=this.ua.replace(/^.*Browser\/([\d.]+).*$/,"$1")):"Firefox"!==u.browser||"undefined"==typeof clientInformation&&"undefined"!=typeof u2f?"Wechat"===u.browser&&$()&&(u.browser="Wechat Miniapp"):u.browser="".concat(u.browser," Nightly"),"Edge"===u.browser?u.engine=parseInt(u.version)>75?"Blink":"EdgeHTML":(t.Chrome.test(this.ua)&&"WebKit"===u.engine&&parseInt(this.version.Chrome())>27||"Opera"===u.browser&&parseInt(u.version)>12||"Yandex"===u.browser)&&(u.engine="Blink"),u}}]),o}());function b(e){return h.getEnv(e)}return b.isWebview=w,b.isWechatMiniapp=$,b.getLanguage=f,b.VERSION="0.1.7",b}));
|
|
1
|
+
function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,n){return r&&_defineProperties(e.prototype,r),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"==_typeof(r)?r:r+""}function _toPrimitive(e,r){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e,r){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).uaBrowser=r()}(this,(function(){"use strict";var e={};"undefined"!=typeof navigator&&(e=navigator);var r,n=e.userAgent||"",o=e.mimeTypes,i=e.platform,a={Trident:/(Trident|NET CLR)/,Presto:/Presto/,WebKit:/AppleWebKit/,Gecko:/Gecko\//,KHTML:/KHTML\//},t={Safari:/Safari/,Chrome:/(Chrome|CriOS)/,IE:/(MSIE|Trident)/,Edge:/(Edge|Edg\/|EdgA|EdgiOS)/,Firefox:/(Firefox|FxiOS)/,"Firefox Focus":/Focus/,Chromium:/Chromium/,Opera:/(Opera|OPR|OPT)/,Vivaldi:/Vivaldi/,Yandex:/YaBrowser/,Arora:/Arora/,Lunascape:/Lunascape/,QupZilla:/QupZilla/,"Coc Coc":/coc_coc_browser/,Kindle:/(Kindle|Silk\/)/,Iceweasel:/Iceweasel/,Konqueror:/Konqueror/,Iceape:/Iceape/,SeaMonkey:/SeaMonkey/,Epiphany:/Epiphany/,360:/(QihooBrowser|QHBrowser)/,"360EE":/360EE/,"360SE":/360SE/,UC:/(UCBrowser|UBrowser|UCWEB)/,QQBrowser:/QQBrowser/,QQ:/QQ\//,Baidu:/(Baidu|BIDUBrowser|baidubrowser|baiduboxapp|BaiduHD)/,Maxthon:/Maxthon/,Sogou:/(MetaSr|Sogou)/,Liebao:/(LBBROWSER|LieBaoFast)/,"2345Explorer":/2345Explorer/,"115Browser":/115Browser/,TheWorld:/TheWorld/,XiaoMi:/MiuiBrowser/,Vivo:/VivoBrowser/,Huawei:/HuaweiBrowser/,OPPO:/HeyTapBrowser/,Quark:/Quark/,Qiyu:/Qiyu/,Wechat:/MicroMessenger/,WechatWork:/wxwork\//,Taobao:/AliApp\(TB/,Alipay:/AliApp\(AP/,Weibo:/Weibo/,Douban:/com\.douban\.frodo/,Suning:/SNEBUY-APP/,iQiYi:/IqiyiApp/,DingTalk:/DingTalk/,Douyin:/aweme/},u={Windows:/Windows/,Linux:/(Linux|X11)/,MacOS:/Macintosh/,Android:/(Android|Adr)/,HarmonyOS:/HarmonyOS/,Ubuntu:/Ubuntu/,FreeBSD:/FreeBSD/,Debian:/Debian/,"Windows Phone":/(IEMobile|Windows Phone)/,BlackBerry:/(BlackBerry|RIM)/,MeeGo:/MeeGo/,Symbian:/Symbian/,iOS:/like Mac OS X/,"Chrome OS":/CrOS/,WebOS:/hpwOS/},c={Mobile:/(Mobi|iPh|480)/,Tablet:/(Tablet|Pad|Nexus 7)/},s={isWebview:/; wv/},l={os:Object.keys(u),device:Object.keys(c),engine:Object.keys(a),browser:Object.keys(t)},p=function(e){try{return!!o.namedItem(e)}catch(e){return!1}},d=function(e,r){for(var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,i=e.length;i--;){var a=e[i];if(r[a].test(o))return a}return"unknown"};(null==e?void 0:e.userAgentData)&&e.userAgentData.getHighEntropyValues(["platformVersion"]).then((function(n){if("Windows"===e.userAgentData.platform){var o=parseInt(n.platformVersion.split(".")[0]);r=o>=13?"11":"10"}}));var f=function(){var r;return null===(r=e.browserLanguage||e.language)||void 0===r?void 0:r.replace(/-\w+/g,(function(e){return e.toUpperCase()}))},$=function(){return"undefined"!=typeof __wxjs_environment&&"miniprogram"===__wxjs_environment},w=function(e){return s.isWebview.test(e)},h=new(function(){return _createClass((function e(r){var o=this;_classCallCheck(this,e),this.ua=n,this.version={Safari:function(){return o.ua.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){return o.ua.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){return o.ua.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return o.ua.replace(/^.*Edge\/([\d.]+).*$/,"$1").replace(/^.*Edg\/([\d.]+).*$/,"$1").replace(/^.*EdgA\/([\d.]+).*$/,"$1").replace(/^.*EdgiOS\/([\d.]+).*$/,"$1")},Firefox:function(){return o.ua.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return o.ua.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return o.ua.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){return o.ua.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1").replace(/^.*OPT\/([\d.]+).*$/,"$1")},Vivaldi:function(){return o.ua.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return o.ua.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Arora:function(){return o.ua.replace(/^.*Arora\/([\d.]+).*$/,"$1")},Lunascape:function(){return o.ua.replace(/^.*Lunascape[\s]([\d.]+).*$/,"$1")},QupZilla:function(){return o.ua.replace(/^.*QupZilla[\s]([\d.]+).*$/,"$1")},"Coc Coc":function(){return o.ua.replace(/^.*coc_coc_browser\/([\d.]+).*$/,"$1")},Kindle:function(){return o.ua.replace(/^.*Version\/([\d.]+).*$/,"$1")},Iceweasel:function(){return o.ua.replace(/^.*Iceweasel\/([\d.]+).*$/,"$1")},Konqueror:function(){return o.ua.replace(/^.*Konqueror\/([\d.]+).*$/,"$1")},Iceape:function(){return o.ua.replace(/^.*Iceape\/([\d.]+).*$/,"$1")},SeaMonkey:function(){return o.ua.replace(/^.*SeaMonkey\/([\d.]+).*$/,"$1")},Epiphany:function(){return o.ua.replace(/^.*Epiphany\/([\d.]+).*$/,"$1")},Maxthon:function(){return o.ua.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return o.ua.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return o.ua.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return o.ua.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1").replace(/^.*baiduboxapp\/([\d.]+).*$/,"$1")},UC:function(){return o.ua.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){return o.ua.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},TheWorld:function(){return o.ua.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return o.ua.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Vivo:function(){return o.ua.replace(/^.*VivoBrowser\/([\d.]+).*$/,"$1")},OPPO:function(){return o.ua.replace(/^.*HeyTapBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return o.ua.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return o.ua.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return o.ua.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},WechatWork:function(){return o.ua.replace(/^.*wxwork\/([\d.]+).*$/,"$1")},Taobao:function(){return o.ua.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return o.ua.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return o.ua.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return o.ua.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return o.ua.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return o.ua.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")},DingTalk:function(){return o.ua.replace(/^.*DingTalk\/([\d.]+).*$/,"$1")},Huawei:function(){return o.ua.replace(/^.*Version\/([\d.]+).*$/,"$1").replace(/^.*HuaweiBrowser\/([\d.]+).*$/,"$1")},Douyin:function(){return o.ua.replace(/^.*app_version\/([\d.]+).*$/,"$1")},"115Browser":function(){return o.ua.replace(/^.*115Browser\/([\d.]+).*$/,"$1")},360:function(){return o.ua.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{108:"14.0",86:"13.0",78:"12.0",69:"11.0",63:"10.0",55:"9.1",45:"8.1",42:"8.0",31:"7.0",21:"6.3"}[o.getChromeVars()]||""},"360EE":function(){return{86:"13.0",78:"12.0",69:"11.0",63:"9.5",55:"9.0",50:"8.7",30:"7.5"}[o.getChromeVars()]||""},"2345Explorer":function(){return{69:"10.0",55:"9.9"}[o.getChromeVars()]||o.ua.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1").replace(/^.*Mb2345Browser\/([\d.]+).*$/,"$1")},Liebao:function(){var e="";/LieBaoFast/.test(o.ua)&&(e=o.ua.replace(/^.*LieBaoFast\/([\d.]+).*$/,"$1"));var r=o.getChromeVars();return e||{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[r]||""}},this.osVersion={Android:function(){return o.ua.replace(/^.*Android ([\d.]+);.*$/,"$1")},iOS:function(){return o.ua.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,".")},Debian:function(){return o.ua.replace(/^.*Debian\/([\d.]+).*$/,"$1")},"Windows Phone":function(){return o.ua.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2")},MacOS:function(){return o.ua.replace(/^.*Mac OS X -?([\d_]+).*$/,"$1").replace(/_/g,".")},WebOS:function(){return o.ua.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")},HarmonyOS:function(){return{10:"2"}[o.ua.replace(/^Mozilla.*Android ([\d.]+)[;)].*$/,"$1")]||""},Windows:function(){var e=o.ua.replace(/^Mozilla\/\d.0 \(Windows NT ([\d.]+);.*$/,"$1");return{10:"10",6.4:"10",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP",5.1:"XP","5.0":"2000"}[e]||parseInt(e).toString()}},this.getChromeVars=function(){return o.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")},this.setUA(r)}),[{key:"getOs",value:function(){return d(l.os,u,this.ua)}},{key:"getEngine",value:function(){return d(l.engine,a,this.ua)}},{key:"getBrowser",value:function(){return d(l.browser,t,this.ua)}},{key:"getDevice",value:function(){if("MacIntel"===i&&e.maxTouchPoints>1)return"Tablet";var r=d(l.device,c,this.ua);return"unknown"===r?"PC":r}},{key:"setUA",value:function(e){"string"==typeof e?this.ua=e:(void 0!==e&&console.warn("`ua` must be of type string."),this.ua=n)}},{key:"getEnv",value:function(n){var o,a;this.setUA(n);var u={version:"unknown",osVersion:"unknown",engine:this.getEngine(),browser:this.getBrowser(),os:this.getOs(),device:this.getDevice(),isWebview:w(this.ua),language:null!==(o=f())&&void 0!==o?o:"unknown",platfrom:null!=i?i:"unknown"},c=u.browser,s=!1;if("undefined"!=typeof chrome){var d=this.getChromeVars();chrome.adblock2345||chrome.common2345?u.browser="2345Explorer":p("application/360softmgrplugin")||p("application/mozilla-npqihooquicklogin")||d>"36"&&"undefined"!=typeof showModalDialog?s=!0:d>"45"&&!(s=p("application/vnd.chromium.remoting-viewer"))&&d>="69"&&(s=p("application/hwepass2001.installepass2001")||p("application/asx"))}return"Mobile"===u.device&&/iPad/.test(this.ua)?u.device="Tablet":s&&(c=p("application/gameplugin")||!(null===(a=null==e?void 0:e.connection)||void 0===a?void 0:a.saveData)?"360SE":"360EE"),l.browser.indexOf(c)>=l.browser.indexOf(u.browser)&&(u.browser=c),"Baidu"===u.browser&&t.Opera.test(this.ua)&&(u.browser="Opera"),u.os in this.osVersion&&(u.osVersion=this.osVersion[u.os](),u.osVersion===this.ua&&(u.osVersion="unknown")),"Windows"===u.os&&r&&(u.osVersion=r),u.browser in this.version&&(u.version=this.version[u.browser](),u.version===this.ua&&(u.version="unknown")),"Chrome"===u.browser&&this.ua.match(/\S+Browser/)?(u.browser=this.ua.match(/\S+Browser/)[0],u.version=this.ua.replace(/^.*Browser\/([\d.]+).*$/,"$1")):"Firefox"!==u.browser||"undefined"==typeof clientInformation&&"undefined"!=typeof u2f?"Wechat"===u.browser&&$()&&(u.browser="Wechat Miniapp"):u.browser="".concat(u.browser," Nightly"),"Edge"===u.browser?u.engine=parseInt(u.version)>75?"Blink":"EdgeHTML":(t.Chrome.test(this.ua)&&"WebKit"===u.engine&&parseInt(this.version.Chrome())>27||"Opera"===u.browser&&parseInt(u.version)>12||"Yandex"===u.browser)&&(u.engine="Blink"),u}}])}());function b(e){return h.getEnv(e)}return b.isWebview=w,b.isWechatMiniapp=$,b.getLanguage=f,b.VERSION="0.1.7",b}));
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
if (process.env.ENV_NODE === 'production') {
|
|
4
|
-
module.exports = require('./dist/index.min.js')
|
|
5
|
-
} else {
|
|
6
|
-
module.exports = require('./dist/index.cjs.js')
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
if (process.env.ENV_NODE === 'production') {
|
|
4
|
+
module.exports = require('./dist/index.min.js')
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require('./dist/index.cjs.js')
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ua-browser",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "uaBrowser - 通过useragent和浏览器环境变量检测浏览器、系统及设备类型工具,支持node环境使用",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"module": "./dist/index.esm.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"require": "./dist/index.cjs.js",
|
|
11
|
-
"import": "./dist/index.esm.mjs",
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "node build.js",
|
|
20
|
-
"dev": "node build.js --watch",
|
|
21
|
-
"test": "node example/index.js"
|
|
22
|
-
},
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/yangtianxia/ua-browser.git"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"uaBrowser",
|
|
29
|
-
"userAgent",
|
|
30
|
-
"javascript",
|
|
31
|
-
"typescript"
|
|
32
|
-
],
|
|
33
|
-
"author": "yangtianxia",
|
|
34
|
-
"license": "MIT",
|
|
35
|
-
"bugs": {
|
|
36
|
-
"url": "https://github.com/yangtianxia/ua-browser/issues"
|
|
37
|
-
},
|
|
38
|
-
"homepage": "https://github.com/yangtianxia/ua-browser#readme",
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@babel/core": "^7.14.6",
|
|
41
|
-
"@babel/polyfill": "^7.12.1",
|
|
42
|
-
"@babel/preset-env": "^7.14.7",
|
|
43
|
-
"@
|
|
44
|
-
"@rollup/plugin-
|
|
45
|
-
"@rollup/plugin-
|
|
46
|
-
"@rollup/plugin-
|
|
47
|
-
"@rollup/plugin-
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@typescript-eslint/
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"eslint
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"rollup
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ua-browser",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "uaBrowser - 通过useragent和浏览器环境变量检测浏览器、系统及设备类型工具,支持node环境使用",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "./dist/index.esm.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.cjs.js",
|
|
11
|
+
"import": "./dist/index.esm.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "node build.js",
|
|
20
|
+
"dev": "node build.js --watch",
|
|
21
|
+
"test": "node example/index.js"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/yangtianxia/ua-browser.git"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"uaBrowser",
|
|
29
|
+
"userAgent",
|
|
30
|
+
"javascript",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"author": "yangtianxia",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/yangtianxia/ua-browser/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/yangtianxia/ua-browser#readme",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.14.6",
|
|
41
|
+
"@babel/polyfill": "^7.12.1",
|
|
42
|
+
"@babel/preset-env": "^7.14.7",
|
|
43
|
+
"@changesets/cli": "^2.29.4",
|
|
44
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
45
|
+
"@rollup/plugin-commonjs": "^21.1.0",
|
|
46
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
47
|
+
"@rollup/plugin-node-resolve": "^13.2.1",
|
|
48
|
+
"@rollup/plugin-typescript": "^8.3.2",
|
|
49
|
+
"@types/node": "^17.0.25",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
51
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
52
|
+
"babel-preset-env": "^1.7.0",
|
|
53
|
+
"core-js": "^3.22.2",
|
|
54
|
+
"eslint": "^8.13.0",
|
|
55
|
+
"eslint-plugin-import": "^2.26.0",
|
|
56
|
+
"minimist": "^1.2.8",
|
|
57
|
+
"rollup": "^2.70.2",
|
|
58
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
59
|
+
"shelljs": "^0.8.5",
|
|
60
|
+
"shx": "^0.3.4",
|
|
61
|
+
"tslib": "^2.3.1",
|
|
62
|
+
"typescript": "^4.6.3"
|
|
63
|
+
}
|
|
64
|
+
}
|