ua-browser 0.1.3 → 0.1.4

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/dist/browser.js CHANGED
@@ -11,7 +11,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
11
11
  })(this, function () {
12
12
  'use strict';
13
13
 
14
- var version = "0.1.2";
14
+ var version = "0.1.4";
15
15
  var NAVIGATOR = {};
16
16
 
17
17
  if (typeof navigator !== 'undefined') {
@@ -61,7 +61,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
61
61
  QQ: /QQ\//,
62
62
  Baidu: /(Baidu|BIDUBrowser|baidubrowser|baiduboxapp|BaiduHD)/,
63
63
  Maxthon: /Maxthon/,
64
- Sogou: /(Metasr|Sogou)/,
64
+ Sogou: /(MetaSr|Sogou)/,
65
65
  Liebao: /(LBBROWSER|LieBaoFast)/,
66
66
  '2345Explorer': /2345Explorer/,
67
67
  '115Browser': /115Browser/,
@@ -449,6 +449,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
449
449
  language: (_a = getLanguage()) !== null && _a !== void 0 ? _a : 'unknown',
450
450
  platfrom: platfrom !== null && platfrom !== void 0 ? platfrom : 'unknown'
451
451
  };
452
+ var browser = env.browser;
452
453
  var is360 = false;
453
454
 
454
455
  if (typeof chrome !== 'undefined') {
@@ -471,12 +472,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
471
472
  env.device = 'Tablet';
472
473
  } else if (is360) {
473
474
  if (getMimeType('application/gameplugin') || !((_b = NAVIGATOR === null || NAVIGATOR === void 0 ? void 0 : NAVIGATOR.connection) === null || _b === void 0 ? void 0 : _b.saveData)) {
474
- env.browser = '360SE';
475
+ browser = '360SE';
475
476
  } else {
476
- env.browser = '360EE';
477
+ browser = '360EE';
477
478
  }
478
479
  }
479
480
 
481
+ if (hash.browser.indexOf(browser) >= hash.browser.indexOf(env.browser)) {
482
+ env.browser = browser;
483
+ }
484
+
480
485
  if (env.browser === 'Baidu' && browserRegExp.Opera.test(this.ua)) {
481
486
  env.browser = 'Opera';
482
487
  }
@@ -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=e.userAgent,n=e.mimeTypes,o=e.platform,i={Trident:/(Trident|NET CLR)/,Presto:/Presto/,WebKit:/AppleWebKit/,Gecko:/Gecko\//,KHTML:/KHTML\//},a={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/,Quark:/Quark/,Qiyu:/Qiyu/,Wechat:/MicroMessenger/,WechatWork:/wxwork\//,Taobao:/AliApp\(TB/,Alipay:/AliApp\(AP/,Weibo:/Weibo/,Douban:/com\.douban\.frodo/,Suning:/SNEBUY-APP/,iQiYi:/IqiyiAp/,DingTalk:/DingTalk/,Huawei:/(HuaweiBrowser|HUAWEI\/|HONOR)/,Vivo:/VivoBrowser/},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/},t={Mobile:/(Mobi|iPh|480)/,Tablet:/(Tablet|Pad|Nexus 7)/},c={isWebview:/; wv/},s=["Mobile","Tablet"],l=["Windows","Linux","MacOS","Android","HarmonyOS","Ubuntu","FreeBSD","Debian","Windows Phone","BlackBerry","MeeGo","Symbian","iOS","Chrome OS","WebOS"],p=["Trident","Presto","WebKit","Gecko","KHTML"],d=["Safari","Chrome","IE","Edge","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Arora","Lunascape","QupZilla","Coc Coc","Kindle","Iceweasel","Konqueror","Iceape","SeaMonkey","Epiphany","360","360EE","360SE","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","Liebao","2345Explorer","115Browser","TheWorld","XiaoMi","Quark","Qiyu","Wechat","WechatWork","Taobao","Alipay","Weibo","Douban","Suning","iQiYi","DingTalk","Huawei","Vivo"],f=function(e){try{return!!n.namedItem(e)}catch(e){return!1}},$=function(e,n){for(var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,i=e.length;i--;){var a=e[i];if(n[a].test(o))return a}return"unknown"},w=function(){var r;return null===(r=e.browserLanguage||e.language)||void 0===r?void 0:r.replace(/-\w+/g,(function(e){return e.toUpperCase()}))},h=function(){return"undefined"!=typeof __wxjs_environment&&"miniprogram"===__wxjs_environment},b=function(e){return c.isWebview.test(e)},g=new(function(){function n(e){var o=this;_classCallCheck(this,n),this.ua=r,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")},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")},"115Browser":function(){return o.ua.replace(/^.*115Browser\/([\d.]+).*$/,"$1")},360:function(){return o.ua.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{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.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"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.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"2345Explorer":function(){return{69:"10.0",55:"9.9"}[o.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||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.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1");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]||e}},e&&(this.ua=e)}return _createClass(n,[{key:"getOs",value:function(){return $(l,u,this.ua)}},{key:"getEngine",value:function(){return $(p,i,this.ua)}},{key:"getBrowser",value:function(){return $(d,a,this.ua)}},{key:"getDevice",value:function(){if("MacIntel"===o&&e.maxTouchPoints>1)return"Tablet";var r=$(s,t,this.ua);return"unknown"===r?"PC":r}},{key:"getEnv",value:function(n){var i,u;this.ua=n||r;var t={version:"unknown",osVersion:"unknown",engine:this.getEngine(),browser:this.getBrowser(),os:this.getOs(),device:this.getDevice(),isWebview:b(this.ua),language:null!==(i=w())&&void 0!==i?i:"unknown",platfrom:null!=o?o:"unknown"},c=!1;if("undefined"!=typeof chrome){var s=this.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1");chrome.adblock2345||chrome.common2345?t.browser="2345Explorer":f("application/360softmgrplugin")||f("application/mozilla-npqihooquicklogin")||s>"36"&&"undefined"!=typeof showModalDialog?c=!0:s>"45"&&!(c=f("application/vnd.chromium.remoting-viewer"))&&s>="69"&&(c=f("application/hwepass2001.installepass2001")||f("application/asx"))}return"Mobile"===t.device&&/iPad/.test(this.ua)?t.device="Tablet":c&&(f("application/gameplugin")||!(null===(u=null==e?void 0:e.connection)||void 0===u?void 0:u.saveData)?t.browser="360SE":t.browser="360EE"),"Baidu"===t.browser&&a.Opera.test(this.ua)&&(t.browser="Opera"),t.os in this.osVersion&&(t.osVersion=this.osVersion[t.os](),t.osVersion===this.ua&&(t.osVersion="unknown")),t.browser in this.version&&(t.version=this.version[t.browser](),t.version===this.ua&&(t.version="unknown")),"Chrome"===t.browser&&this.ua.match(/\S+Browser/)?(t.browser=this.ua.match(/\S+Browser/)[0],t.version=this.ua.replace(/^.*Browser\/([\d.]+).*$/,"$1")):"Firefox"!==t.browser||"undefined"==typeof clientInformation&&"undefined"!=typeof u2f?"Wechat"===t.browser&&h()&&(t.browser="Wechat Miniapp"):t.browser="".concat(t.browser," Nightly"),"Edge"===t.browser?t.engine=parseInt(t.version)>75?"Blink":"EdgeHTML":(a.Chrome.test(this.ua)&&"WebKit"===t.engine&&parseInt(this.version.Chrome())>27||"Opera"===t.browser&&parseInt(t.version)>12||"Yandex"===t.browser)&&(t.engine="Blink"),t}}]),n}());function m(e){return g.getEnv(e)}return m.isWebview=b,m.isWechatMiniapp=h,m.getLanguage=w,m.VERSION="0.1.2",m}));
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=e.userAgent,n=e.mimeTypes,o=e.platform,i={Trident:/(Trident|NET CLR)/,Presto:/Presto/,WebKit:/AppleWebKit/,Gecko:/Gecko\//,KHTML:/KHTML\//},a={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/,Quark:/Quark/,Qiyu:/Qiyu/,Wechat:/MicroMessenger/,WechatWork:/wxwork\//,Taobao:/AliApp\(TB/,Alipay:/AliApp\(AP/,Weibo:/Weibo/,Douban:/com\.douban\.frodo/,Suning:/SNEBUY-APP/,iQiYi:/IqiyiAp/,DingTalk:/DingTalk/,Huawei:/(HuaweiBrowser|HUAWEI\/|HONOR)/,Vivo:/VivoBrowser/},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/},t={Mobile:/(Mobi|iPh|480)/,Tablet:/(Tablet|Pad|Nexus 7)/},c={isWebview:/; wv/},s={device:["Mobile","Tablet"],os:["Windows","Linux","MacOS","Android","HarmonyOS","Ubuntu","FreeBSD","Debian","Windows Phone","BlackBerry","MeeGo","Symbian","iOS","Chrome OS","WebOS"],engine:["Trident","Presto","WebKit","Gecko","KHTML"],browser:["Safari","Chrome","IE","Edge","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Arora","Lunascape","QupZilla","Coc Coc","Kindle","Iceweasel","Konqueror","Iceape","SeaMonkey","Epiphany","360","360EE","360SE","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","Liebao","2345Explorer","115Browser","TheWorld","XiaoMi","Quark","Qiyu","Wechat","WechatWork","Taobao","Alipay","Weibo","Douban","Suning","iQiYi","DingTalk","Huawei","Vivo"]},l=function(e){try{return!!n.namedItem(e)}catch(e){return!1}},p=function(e,n){for(var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,i=e.length;i--;){var a=e[i];if(n[a].test(o))return a}return"unknown"},d=function(){var r;return null===(r=e.browserLanguage||e.language)||void 0===r?void 0:r.replace(/-\w+/g,(function(e){return e.toUpperCase()}))},f=function(){return"undefined"!=typeof __wxjs_environment&&"miniprogram"===__wxjs_environment},$=function(e){return c.isWebview.test(e)},w=new(function(){function n(e){var o=this;_classCallCheck(this,n),this.ua=r,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")},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")},"115Browser":function(){return o.ua.replace(/^.*115Browser\/([\d.]+).*$/,"$1")},360:function(){return o.ua.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{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.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"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.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"2345Explorer":function(){return{69:"10.0",55:"9.9"}[o.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||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.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1");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]||e}},e&&(this.ua=e)}return _createClass(n,[{key:"getOs",value:function(){return p(s.os,u,this.ua)}},{key:"getEngine",value:function(){return p(s.engine,i,this.ua)}},{key:"getBrowser",value:function(){return p(s.browser,a,this.ua)}},{key:"getDevice",value:function(){if("MacIntel"===o&&e.maxTouchPoints>1)return"Tablet";var r=p(s.device,t,this.ua);return"unknown"===r?"PC":r}},{key:"getEnv",value:function(n){var i,u;this.ua=n||r;var t={version:"unknown",osVersion:"unknown",engine:this.getEngine(),browser:this.getBrowser(),os:this.getOs(),device:this.getDevice(),isWebview:$(this.ua),language:null!==(i=d())&&void 0!==i?i:"unknown",platfrom:null!=o?o:"unknown"},c=t.browser,p=!1;if("undefined"!=typeof chrome){var w=this.ua.replace(/^.*Chrome\/([\d]+).*$/,"$1");chrome.adblock2345||chrome.common2345?t.browser="2345Explorer":l("application/360softmgrplugin")||l("application/mozilla-npqihooquicklogin")||w>"36"&&"undefined"!=typeof showModalDialog?p=!0:w>"45"&&!(p=l("application/vnd.chromium.remoting-viewer"))&&w>="69"&&(p=l("application/hwepass2001.installepass2001")||l("application/asx"))}return"Mobile"===t.device&&/iPad/.test(this.ua)?t.device="Tablet":p&&(c=l("application/gameplugin")||!(null===(u=null==e?void 0:e.connection)||void 0===u?void 0:u.saveData)?"360SE":"360EE"),s.browser.indexOf(c)>=s.browser.indexOf(t.browser)&&(t.browser=c),"Baidu"===t.browser&&a.Opera.test(this.ua)&&(t.browser="Opera"),t.os in this.osVersion&&(t.osVersion=this.osVersion[t.os](),t.osVersion===this.ua&&(t.osVersion="unknown")),t.browser in this.version&&(t.version=this.version[t.browser](),t.version===this.ua&&(t.version="unknown")),"Chrome"===t.browser&&this.ua.match(/\S+Browser/)?(t.browser=this.ua.match(/\S+Browser/)[0],t.version=this.ua.replace(/^.*Browser\/([\d.]+).*$/,"$1")):"Firefox"!==t.browser||"undefined"==typeof clientInformation&&"undefined"!=typeof u2f?"Wechat"===t.browser&&f()&&(t.browser="Wechat Miniapp"):t.browser="".concat(t.browser," Nightly"),"Edge"===t.browser?t.engine=parseInt(t.version)>75?"Blink":"EdgeHTML":(a.Chrome.test(this.ua)&&"WebKit"===t.engine&&parseInt(this.version.Chrome())>27||"Opera"===t.browser&&parseInt(t.version)>12||"Yandex"===t.browser)&&(t.engine="Blink"),t}}]),n}());function h(e){return w.getEnv(e)}return h.isWebview=$,h.isWechatMiniapp=f,h.getLanguage=d,h.VERSION="0.1.4",h}));
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "ua-browser",
3
- "version": "0.1.3",
4
- "description": "uaBrowser - 通过 useragent和浏览器环境变量检测浏览器、系统及设备类型工具",
5
- "main": "index.js",
6
- "types": "./dist/index.d.ts",
7
- "files": [
8
- "dist"
9
- ],
10
- "scripts": {
11
- "build": "shx rm -rf dist && rollup --config rollup.config.ts --configPlugin typescript && shx cp src/types.d.ts dist/index.d.ts",
12
- "test": "node example/index.js"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/yangtianxia/ua-browser.git"
17
- },
18
- "keywords": [
19
- "uaBrowser",
20
- "userAgent",
21
- "typescript"
22
- ],
23
- "author": "yangtianxia",
24
- "license": "MIT",
25
- "bugs": {
26
- "url": "https://github.com/yangtianxia/ua-browser/issues"
27
- },
28
- "homepage": "https://github.com/yangtianxia/ua-browser#readme",
29
- "devDependencies": {
30
- "@babel/core": "^7.14.6",
31
- "@babel/polyfill": "^7.12.1",
32
- "@babel/preset-env": "^7.14.7",
33
- "@rollup/plugin-babel": "^5.3.1",
34
- "@rollup/plugin-commonjs": "^21.1.0",
35
- "@rollup/plugin-json": "^4.1.0",
36
- "@rollup/plugin-node-resolve": "^13.2.1",
37
- "@rollup/plugin-typescript": "^8.3.2",
38
- "@types/node": "^17.0.25",
39
- "@typescript-eslint/eslint-plugin": "^5.20.0",
40
- "@typescript-eslint/parser": "^5.20.0",
41
- "babel-preset-env": "^1.7.0",
42
- "core-js": "^3.22.2",
43
- "eslint": "^8.13.0",
44
- "eslint-plugin-import": "^2.26.0",
45
- "rollup": "^2.70.2",
46
- "rollup-plugin-dts": "^4.2.1",
47
- "rollup-plugin-terser": "^7.0.2",
48
- "shx": "^0.3.4",
49
- "tslib": "^2.3.1",
50
- "typescript": "^4.6.3"
51
- },
52
- "dependencies": {}
53
- }
1
+ {
2
+ "name": "ua-browser",
3
+ "version": "0.1.4",
4
+ "description": "uaBrowser - 通过 useragent和浏览器环境变量检测浏览器、系统及设备类型工具",
5
+ "main": "index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "shx rm -rf dist && rollup --config rollup.config.ts --configPlugin typescript && shx cp src/types.d.ts dist/index.d.ts",
12
+ "test": "node example/index.js"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/yangtianxia/ua-browser.git"
17
+ },
18
+ "keywords": [
19
+ "uaBrowser",
20
+ "userAgent",
21
+ "typescript"
22
+ ],
23
+ "author": "yangtianxia",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/yangtianxia/ua-browser/issues"
27
+ },
28
+ "homepage": "https://github.com/yangtianxia/ua-browser#readme",
29
+ "devDependencies": {
30
+ "@babel/core": "^7.14.6",
31
+ "@babel/polyfill": "^7.12.1",
32
+ "@babel/preset-env": "^7.14.7",
33
+ "@rollup/plugin-babel": "^5.3.1",
34
+ "@rollup/plugin-commonjs": "^21.1.0",
35
+ "@rollup/plugin-json": "^4.1.0",
36
+ "@rollup/plugin-node-resolve": "^13.2.1",
37
+ "@rollup/plugin-typescript": "^8.3.2",
38
+ "@types/node": "^17.0.25",
39
+ "@typescript-eslint/eslint-plugin": "^5.20.0",
40
+ "@typescript-eslint/parser": "^5.20.0",
41
+ "babel-preset-env": "^1.7.0",
42
+ "core-js": "^3.22.2",
43
+ "eslint": "^8.13.0",
44
+ "eslint-plugin-import": "^2.26.0",
45
+ "rollup": "^2.70.2",
46
+ "rollup-plugin-dts": "^4.2.1",
47
+ "rollup-plugin-terser": "^7.0.2",
48
+ "shx": "^0.3.4",
49
+ "tslib": "^2.3.1",
50
+ "typescript": "^4.6.3"
51
+ },
52
+ "dependencies": {}
53
+ }