From ee51caf422b157bb93e88cc091c4aa403df437f2 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Wed, 13 Nov 2024 10:44:38 +0700 Subject: [PATCH] Update version to `2.0.0-rc.3` --- CHANGELOG.md | 39 +++++++----- README.md | 62 ++++++++++-------- dist/ua-parser.min.js | 4 +- dist/ua-parser.pack.js | 4 +- package-lock.json | 28 ++++----- package.json | 8 +-- src/enums/ua-parser-enums.js | 2 +- src/enums/ua-parser-enums.mjs | 12 +++- src/extensions/ua-parser-extensions.d.ts | 2 +- src/extensions/ua-parser-extensions.js | 2 +- src/extensions/ua-parser-extensions.mjs | 80 +++++++++++++++++------- src/helpers/ua-parser-helpers.d.ts | 2 +- src/helpers/ua-parser-helpers.js | 2 +- src/helpers/ua-parser-helpers.mjs | 26 ++++---- src/main/ua-parser.d.ts | 6 +- src/main/ua-parser.js | 4 +- src/main/ua-parser.mjs | 44 ++++++++++--- 17 files changed, 208 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52575f009..3a16881fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # UAParser.js Changelog +# Version 2.0 ## Migrating from v1 to v2 - What's breaking: @@ -8,28 +9,38 @@ - OS detection: `"Mac OS" => "macOS"`, `"Chromium OS" => "Chrome OS"` - What's new: - New device type: `xr`, to identify AR/VR devices - - New browser property: `browser.type`, to identify the type of the browser: `crawler`, `cli`, `email`, `fetcher`, `inapp`, `mediaplayer`, `module` + - New browser property: `browser.type`, to identify the type of the browser: `crawler`, `cli`, `email`, `fetcher`, `inapp`, `library`, `mediaplayer` - New methods in result object (all of `get*()` return value): - - Support for client hints: `withClientHints()` - - Support for feature detection: `withFeatureCheck()` + - Enhance detection using client hints: `withClientHints()` + - Enhance detection using feature check: `withFeatureCheck()` - Utility for easy comparison: `is()` - Utility to print full-name: `toString()` - - Parse directly from command line using `npx ua-parser-js` + - Parse user-agent directly from command line using `npx ua-parser-js "[User-Agent]"` - Extensions can be passed as a list to `UAParser()` - Support for ES module & TypeScript `import { UAParser } from 'ua-parser-js'` - Provided Enums submodule `'ua-parser-js/enums'` - Provided Extensions submodule `'ua-parser-js/extensions'` - Provided Helpers submodule `'ua-parser-js/helpers'`: - - `getDeviceVendor()` to guess for a device vendor based on its model name - - `isAppleSilicon()` to check if the device has Apple Silicon Mac device properties - - `isBot()` to check if the browser is identified as a bot - - `isChromeFamily()` to check if the browser is Chrome-based / has Blink engine (i.e: New Opera, New Edge, Vivaldi, Brave, Arc, etc.) - - `isElectron()` to check if current window is running inside Electron - - `isFromEU()` to check if current window is from an EU (European Union) country - - `isFrozenUA()` to check if a user-agent string match with the reduced/frozen user-agent pattern - - `isStandalonePWA()` to check if current window is a standalone PWA + - `getDeviceVendor()`: guess for a device vendor based on its model name + - `isAppleSilicon()`: check if the device has Apple Silicon Mac device properties + - `isBot()`: check if the browser is identified as a bot + - `isChromeFamily()`: check if the browser is Chrome-based (has Blink engine, i.e: New Opera, New Edge, Vivaldi, Brave, Arc, etc.) + - `isElectron()`: check if current window is running inside Electron + - `isFromEU()`: check if current window is from an EU (European Union) country + - `isFrozenUA()`: check if a user-agent string match with the reduced/frozen user-agent pattern + - `isStandalonePWA()`: check if current window is a standalone PWA + +--- --- +## Version 2.0.0-rc.3 + +- Add support for Headers object +- Add new device: Advan, Cat, Energizer, Honor, IMO, Micromax, Smartfren +- Add new engine: Servo +- `ua-parser-js/extensions` submodule: + - Breaking change: rename `module` to `library` + - Add new email clients: Evolution, KMail, Kontact + - Add new bots: 360Spider, Archive.org Bots, CCBot, DataForSeoBot, DuckAssistBot, Exabot, Google Bots, Meta Bots, MojeekBot, PerplexityBot, PetalBot, TurnitinBot, Yeti, YisouSpider ## Version 2.0.0-rc.2 @@ -59,7 +70,7 @@ - Rename `isChromiumBased()` to `isChromeFamily()` - Update `isAppleSilicon()` to also checks for WebGL renderer info - `ua-parser-js/extensions` submodule: - - Restore `bots` as a compilation of all these browser types: `clis`, `crawlers`, `fetchers`, and `modules` + - Restore `Bots` as a compilation of all these browser types: `cli`, `crawler`, `fetcher`, and `library` ## Version 2.0.0-beta.3 diff --git a/README.md b/README.md index 701add0cd..7b0aa5fa8 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,15 @@ see what's new & breaking. License options - MIT (v1.x) - AGPL (v2.x) + MIT (v0.7~v1.0) + AGPL (>=v2.0) PRO Personal PRO Business PRO Enterprise Browser detection - ⚠️ + ⚠️ ✅ ✅ ✅ @@ -60,7 +60,7 @@ see what's new & breaking. CPU detection - ⚠️ + ⚠️ ✅ ✅ ✅ @@ -68,7 +68,7 @@ see what's new & breaking. Device detection - ⚠️ + ⚠️ ✅ ✅ ✅ @@ -76,7 +76,7 @@ see what's new & breaking. Engine detection - ⚠️ + ⚠️ ✅ ✅ ✅ @@ -84,31 +84,39 @@ see what's new & breaking. OS detection - ⚠️ + ⚠️ ✅ ✅ ✅ ✅ - Enhanced detection - ⛔️ + Bot detection + ❌ ✅ ✅ ✅ ✅ - Client Hints support - ⛔️ + Extras (Apps, Libs, Emails, Media Players, etc) + ❌ + ✅ + ✅ + ✅ + ✅ + + + Enhanced detection result + ❌ ✅ ✅ ✅ ✅ - Extras (Apps, Bots, Libs, Emails, Media Players, etc) - ⛔️ + Client Hints support + ❌ ✅ ✅ ✅ @@ -124,14 +132,14 @@ see what's new & breaking. ES modules support - ⛔️ + ❌ ✅ ✅ ✅ ✅ - npm module available + npm module ✅ ✅ ✅ @@ -139,25 +147,25 @@ see what's new & breaking. ✅ - TypeScript declarations available - ⚠️ + TypeScript declarations + ⚠️ ✅ ✅ ✅ ✅ - Allowed for commercial use + Allows commercial use ✅ ✅ - ⛔️ + ❌ ✅ ✅ Permissive (non-copyleft) license ✅ - ⛔️ + ✅ ✅ ✅ @@ -167,13 +175,13 @@ see what's new & breaking. ✅ ✅ ✅ - ⛔️ + ✅ - 1-year support - ⛔️ - ⛔️ + 1-year product support + ❌ + ❌ ✅ ✅ ✅ @@ -192,13 +200,13 @@ see what's new & breaking. FREE (License) $14 (License) $29 (License) - $588 (License) + $599 (License) - GET THE PRO PACKAGES 📥 +

GET THE PRO PACKAGES 📥

@@ -221,4 +229,4 @@ Made with [contributors-img](https://contrib.rocks). -Support the open-source versions of UAParser.js on [OpenCollective](https://opencollective.com/ua-parser-js) or [GitHub Sponsors](https://github.com/sponsors/faisalman). +Support the open-source editions of UAParser.js on [OpenCollective](https://opencollective.com/ua-parser-js) or [GitHub Sponsors](https://github.com/sponsors/faisalman). diff --git a/dist/ua-parser.min.js b/dist/ua-parser.min.js index 18512030c..bfc76aa6f 100644 --- a/dist/ua-parser.min.js +++ b/dist/ua-parser.min.js @@ -1,4 +1,4 @@ -/* UAParser.js v2.0.0-rc.2 +/* UAParser.js v2.0.0-rc.3 Copyright © 2012-2024 Faisal Salman AGPLv3 License */ -(function(window,undefined){"use strict";var LIBVERSION="2.0.0-rc.2",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",STR_TYPE="string",MAJOR="major",MODEL="model",NAME="name",TYPE="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",XR="xr",EMBEDDED="embedded",INAPP="inapp",USER_AGENT="user-agent",UA_MAX_LENGTH=500,BRANDS="brands",FORMFACTORS="formFactors",FULLVERLIST="fullVersionList",PLATFORM="platform",PLATFORMVER="platformVersion",BITNESS="bitness",CH_HEADER="sec-ch-ua",CH_HEADER_FULL_VER_LIST=CH_HEADER+"-full-version-list",CH_HEADER_ARCH=CH_HEADER+"-arch",CH_HEADER_BITNESS=CH_HEADER+"-"+BITNESS,CH_HEADER_FORM_FACTORS=CH_HEADER+"-form-factors",CH_HEADER_MOBILE=CH_HEADER+"-"+MOBILE,CH_HEADER_MODEL=CH_HEADER+"-"+MODEL,CH_HEADER_PLATFORM=CH_HEADER+"-"+PLATFORM,CH_HEADER_PLATFORM_VER=CH_HEADER_PLATFORM+"-version",CH_ALL_VALUES=[BRANDS,FULLVERLIST,MOBILE,MODEL,PLATFORM,PLATFORMVER,ARCHITECTURE,FORMFACTORS,BITNESS],UA_BROWSER="browser",UA_CPU="cpu",UA_DEVICE="device",UA_ENGINE="engine",UA_OS="os",UA_RESULT="result",AMAZON="Amazon",APPLE="Apple",ASUS="ASUS",BLACKBERRY="BlackBerry",GOOGLE="Google",HUAWEI="Huawei",LENOVO="Lenovo",LG="LG",MICROSOFT="Microsoft",MOTOROLA="Motorola",SAMSUNG="Samsung",SHARP="Sharp",SONY="Sony",XIAOMI="Xiaomi",ZEBRA="Zebra",PREFIX_MOBILE="Mobile ",SUFFIX_BROWSER=" Browser",CHROME="Chrome",CHROMECAST="Chromecast",EDGE="Edge",FIREFOX="Firefox",OPERA="Opera",FACEBOOK="Facebook",SOGOU="Sogou",WINDOWS="Windows";var isWindow=typeof window!==UNDEF_TYPE,NAVIGATOR=isWindow&&window.navigator?window.navigator:undefined,NAVIGATOR_UADATA=NAVIGATOR&&NAVIGATOR.userAgentData?NAVIGATOR.userAgentData:undefined;var extend=function(defaultRgx,extensions){var mergedRgx={};var extraRgx=extensions;if(!isExtensions(extensions)){extraRgx={};for(var i in extensions){for(var j in extensions[i]){extraRgx[j]=extensions[i][j].concat(extraRgx[j]?extraRgx[j]:[])}}}for(var k in defaultRgx){mergedRgx[k]=extraRgx[k]&&extraRgx[k].length%2===0?extraRgx[k].concat(defaultRgx[k]):defaultRgx[k]}return mergedRgx},enumerize=function(arr){var enums={};for(var i=0;i0){for(var i in str1){if(lowerize(str1[i])==lowerize(str2))return true}return false}return isString(str1)?lowerize(str2).indexOf(lowerize(str1))!==-1:false},isExtensions=function(obj,deep){for(var prop in obj){return/^(browser|cpu|device|engine|os)$/.test(prop)||(deep?isExtensions(obj[prop]):false)}},isString=function(val){return typeof val===STR_TYPE},itemListToArray=function(header){if(!header)return undefined;var arr=[];var tokens=strip(/\\?\"/g,header).split(",");for(var i=0;i-1){var token=trim(tokens[i]).split(";v=");arr[i]={brand:token[0],version:token[1]}}else{arr[i]=trim(tokens[i])}}return arr},lowerize=function(str){return isString(str)?str.toLowerCase():str},majorize=function(version){return isString(version)?strip(/[^\d\.]/g,version).split(".")[0]:undefined},setProps=function(arr){for(var i in arr){var propName=arr[i];if(typeof propName==OBJ_TYPE&&propName.length==2){this[propName[0]]=propName[1]}else{this[propName]=undefined}}return this},strip=function(pattern,str){return isString(str)?str.replace(pattern,EMPTY):str},stripQuotes=function(str){return strip(/\\?\"/g,str)},trim=function(str,len){if(isString(str)){str=strip(/^\s\s*/,str);return typeof len===UNDEF_TYPE?str:str.substring(0,UA_MAX_LENGTH)}};var rgxMapper=function(ua,arrays){if(!ua||!arrays)return;var i=0,j,k,p,q,matches,match;while(i0){if(q.length===2){if(typeof q[1]==FUNC_TYPE){this[q[0]]=q[1].call(this,match)}else{this[q[0]]=q[1]}}else if(q.length===3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){this[q[0]]=match?q[1].call(this,match,q[2]):undefined}else{this[q[0]]=match?match.replace(q[1],q[2]):undefined}}else if(q.length===4){this[q[0]]=match?q[3].call(this,match.replace(q[1],q[2])):undefined}}else{this[q]=match?match:undefined}}}}i+=2}},strMapper=function(str,map){for(var i in map){if(typeof map[i]===OBJ_TYPE&&map[i].length>0){for(var j=0;j2){this.set(MODEL,"iPad").set(TYPE,TABLET)}break;case UA_OS:if(!this.get(NAME)&&NAVIGATOR_UADATA&&NAVIGATOR_UADATA[PLATFORM]){this.set(NAME,NAVIGATOR_UADATA[PLATFORM])}break;case UA_RESULT:var data=this.data;var detect=function(itemType){return data[itemType].getItem().detectFeature().get()};this.set(UA_BROWSER,detect(UA_BROWSER)).set(UA_CPU,detect(UA_CPU)).set(UA_DEVICE,detect(UA_DEVICE)).set(UA_ENGINE,detect(UA_ENGINE)).set(UA_OS,detect(UA_OS))}}return this};this.parseUA=function(){if(this.itemType!=UA_RESULT){rgxMapper.call(this.data,this.ua,this.rgxMap)}if(this.itemType==UA_BROWSER){this.set(MAJOR,majorize(this.get(VERSION)))}return this};this.parseCH=function(){var uaCH=this.uaCH,rgxMap=this.rgxMap;switch(this.itemType){case UA_BROWSER:var brands=uaCH[FULLVERLIST]||uaCH[BRANDS],prevName;if(brands){for(var i in brands){var brandName=strip(/(Google|Microsoft) /,brands[i].brand||brands[i]),brandVersion=brands[i].version;if(!/not.a.brand/i.test(brandName)&&(!prevName||/chrom/i.test(prevName)&&!/chromi/i.test(brandName))){this.set(NAME,brandName).set(VERSION,brandVersion).set(MAJOR,majorize(brandVersion));prevName=brandName}}}break;case UA_CPU:var archName=uaCH[ARCHITECTURE];if(archName){if(archName&&uaCH[BITNESS]=="64")archName+="64";rgxMapper.call(this.data,archName+";",rgxMap)}break;case UA_DEVICE:if(uaCH[MOBILE]){this.set(TYPE,MOBILE)}if(uaCH[MODEL]){this.set(MODEL,uaCH[MODEL])}if(uaCH[MODEL]=="Xbox"){this.set(TYPE,CONSOLE).set(VENDOR,MICROSOFT)}if(uaCH[FORMFACTORS]){var ff;if(typeof uaCH[FORMFACTORS]!=="string"){var idx=0;while(!ff&&idx=13?"11":"10";this.set(NAME,osName).set(VERSION,osVersion)}if(this.get(NAME)==WINDOWS&&uaCH[MODEL]=="Xbox"){this.set(NAME,"Xbox").set(VERSION,undefined)}break;case UA_RESULT:var data=this.data;var parse=function(itemType){return data[itemType].getItem().setCH(uaCH).parseCH().get()};this.set(UA_BROWSER,parse(UA_BROWSER)).set(UA_CPU,parse(UA_CPU)).set(UA_DEVICE,parse(UA_DEVICE)).set(UA_ENGINE,parse(UA_ENGINE)).set(UA_OS,parse(UA_OS))}return this};setProps.call(this,[["itemType",itemType],["ua",ua],["uaCH",uaCH],["rgxMap",rgxMap],["data",createIData(this,itemType)]]);return this}function UAParser(ua,extensions,headers){if(typeof ua===OBJ_TYPE){if(isExtensions(ua,true)){if(typeof extensions===OBJ_TYPE){headers=extensions}extensions=ua}else{headers=ua;extensions=undefined}ua=undefined}else if(typeof ua===STR_TYPE&&!isExtensions(extensions,true)){headers=extensions;extensions=undefined}if(!(this instanceof UAParser)){return new UAParser(ua,extensions,headers).getResult()}var userAgent=typeof ua===STR_TYPE?ua:NAVIGATOR&&NAVIGATOR.userAgent?NAVIGATOR.userAgent:headers&&headers[USER_AGENT]?headers[USER_AGENT]:EMPTY,httpUACH=new UACHData(headers,true),regexMap=extensions?extend(defaultRegexes,extensions):defaultRegexes,createItemFunc=function(itemType){if(itemType==UA_RESULT){return function(){return new UAItem(itemType,userAgent,regexMap,httpUACH).set("ua",userAgent).set(UA_BROWSER,this.getBrowser()).set(UA_CPU,this.getCPU()).set(UA_DEVICE,this.getDevice()).set(UA_ENGINE,this.getEngine()).set(UA_OS,this.getOS()).get()}}else{return function(){return new UAItem(itemType,userAgent,regexMap[itemType],httpUACH).parseUA().get()}}};setProps.call(this,[["getBrowser",createItemFunc(UA_BROWSER)],["getCPU",createItemFunc(UA_CPU)],["getDevice",createItemFunc(UA_DEVICE)],["getEngine",createItemFunc(UA_ENGINE)],["getOS",createItemFunc(UA_OS)],["getResult",createItemFunc(UA_RESULT)],["getUA",function(){return userAgent}],["setUA",function(ua){if(isString(ua))userAgent=ua.length>UA_MAX_LENGTH?trim(ua,UA_MAX_LENGTH):ua;return this}]]).setUA(userAgent);return this}UAParser.VERSION=LIBVERSION;UAParser.BROWSER=enumerize([NAME,VERSION,MAJOR,TYPE]);UAParser.CPU=enumerize([ARCHITECTURE]);UAParser.DEVICE=enumerize([MODEL,VENDOR,TYPE,CONSOLE,MOBILE,SMARTTV,TABLET,WEARABLE,EMBEDDED]);UAParser.ENGINE=UAParser.OS=enumerize([NAME,VERSION]);if(typeof exports!==UNDEF_TYPE){if(typeof module!==UNDEF_TYPE&&module.exports){exports=module.exports=UAParser}exports.UAParser=UAParser}else{if(typeof define===FUNC_TYPE&&define.amd){define(function(){return UAParser})}else if(isWindow){window.UAParser=UAParser}}var $=isWindow&&(window.jQuery||window.Zepto);if($&&!$.ua){var parser=new UAParser;$.ua=parser.getResult();$.ua.get=function(){return parser.getUA()};$.ua.set=function(ua){parser.setUA(ua);var result=parser.getResult();for(var prop in result){$.ua[prop]=result[prop]}}}})(typeof window==="object"?window:this); \ No newline at end of file +(function(window,undefined){"use strict";var LIBVERSION="2.0.0-rc.3",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",STR_TYPE="string",MAJOR="major",MODEL="model",NAME="name",TYPE="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",XR="xr",EMBEDDED="embedded",INAPP="inapp",USER_AGENT="user-agent",UA_MAX_LENGTH=500,BRANDS="brands",FORMFACTORS="formFactors",FULLVERLIST="fullVersionList",PLATFORM="platform",PLATFORMVER="platformVersion",BITNESS="bitness",CH_HEADER="sec-ch-ua",CH_HEADER_FULL_VER_LIST=CH_HEADER+"-full-version-list",CH_HEADER_ARCH=CH_HEADER+"-arch",CH_HEADER_BITNESS=CH_HEADER+"-"+BITNESS,CH_HEADER_FORM_FACTORS=CH_HEADER+"-form-factors",CH_HEADER_MOBILE=CH_HEADER+"-"+MOBILE,CH_HEADER_MODEL=CH_HEADER+"-"+MODEL,CH_HEADER_PLATFORM=CH_HEADER+"-"+PLATFORM,CH_HEADER_PLATFORM_VER=CH_HEADER_PLATFORM+"-version",CH_ALL_VALUES=[BRANDS,FULLVERLIST,MOBILE,MODEL,PLATFORM,PLATFORMVER,ARCHITECTURE,FORMFACTORS,BITNESS],UA_BROWSER="browser",UA_CPU="cpu",UA_DEVICE="device",UA_ENGINE="engine",UA_OS="os",UA_RESULT="result",AMAZON="Amazon",APPLE="Apple",ASUS="ASUS",BLACKBERRY="BlackBerry",GOOGLE="Google",HUAWEI="Huawei",LENOVO="Lenovo",HONOR="Honor",LG="LG",MICROSOFT="Microsoft",MOTOROLA="Motorola",SAMSUNG="Samsung",SHARP="Sharp",SONY="Sony",XIAOMI="Xiaomi",ZEBRA="Zebra",PREFIX_MOBILE="Mobile ",SUFFIX_BROWSER=" Browser",CHROME="Chrome",CHROMECAST="Chromecast",EDGE="Edge",FIREFOX="Firefox",OPERA="Opera",FACEBOOK="Facebook",SOGOU="Sogou",WINDOWS="Windows";var isWindow=typeof window!==UNDEF_TYPE,NAVIGATOR=isWindow&&window.navigator?window.navigator:undefined,NAVIGATOR_UADATA=NAVIGATOR&&NAVIGATOR.userAgentData?NAVIGATOR.userAgentData:undefined;var extend=function(defaultRgx,extensions){var mergedRgx={};var extraRgx=extensions;if(!isExtensions(extensions)){extraRgx={};for(var i in extensions){for(var j in extensions[i]){extraRgx[j]=extensions[i][j].concat(extraRgx[j]?extraRgx[j]:[])}}}for(var k in defaultRgx){mergedRgx[k]=extraRgx[k]&&extraRgx[k].length%2===0?extraRgx[k].concat(defaultRgx[k]):defaultRgx[k]}return mergedRgx},enumerize=function(arr){var enums={};for(var i=0;i0){for(var i in str1){if(lowerize(str1[i])==lowerize(str2))return true}return false}return isString(str1)?lowerize(str2).indexOf(lowerize(str1))!==-1:false},isExtensions=function(obj,deep){for(var prop in obj){return/^(browser|cpu|device|engine|os)$/.test(prop)||(deep?isExtensions(obj[prop]):false)}},isString=function(val){return typeof val===STR_TYPE},itemListToArray=function(header){if(!header)return undefined;var arr=[];var tokens=strip(/\\?\"/g,header).split(",");for(var i=0;i-1){var token=trim(tokens[i]).split(";v=");arr[i]={brand:token[0],version:token[1]}}else{arr[i]=trim(tokens[i])}}return arr},lowerize=function(str){return isString(str)?str.toLowerCase():str},majorize=function(version){return isString(version)?strip(/[^\d\.]/g,version).split(".")[0]:undefined},setProps=function(arr){for(var i in arr){var propName=arr[i];if(typeof propName==OBJ_TYPE&&propName.length==2){this[propName[0]]=propName[1]}else{this[propName]=undefined}}return this},strip=function(pattern,str){return isString(str)?str.replace(pattern,EMPTY):str},stripQuotes=function(str){return strip(/\\?\"/g,str)},trim=function(str,len){if(isString(str)){str=strip(/^\s\s*/,str);return typeof len===UNDEF_TYPE?str:str.substring(0,UA_MAX_LENGTH)}};var rgxMapper=function(ua,arrays){if(!ua||!arrays)return;var i=0,j,k,p,q,matches,match;while(i0){if(q.length===2){if(typeof q[1]==FUNC_TYPE){this[q[0]]=q[1].call(this,match)}else{this[q[0]]=q[1]}}else if(q.length===3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){this[q[0]]=match?q[1].call(this,match,q[2]):undefined}else{this[q[0]]=match?match.replace(q[1],q[2]):undefined}}else if(q.length===4){this[q[0]]=match?q[3].call(this,match.replace(q[1],q[2])):undefined}}else{this[q]=match?match:undefined}}}}i+=2}},strMapper=function(str,map){for(var i in map){if(typeof map[i]===OBJ_TYPE&&map[i].length>0){for(var j=0;j2){this.set(MODEL,"iPad").set(TYPE,TABLET)}break;case UA_OS:if(!this.get(NAME)&&NAVIGATOR_UADATA&&NAVIGATOR_UADATA[PLATFORM]){this.set(NAME,NAVIGATOR_UADATA[PLATFORM])}break;case UA_RESULT:var data=this.data;var detect=function(itemType){return data[itemType].getItem().detectFeature().get()};this.set(UA_BROWSER,detect(UA_BROWSER)).set(UA_CPU,detect(UA_CPU)).set(UA_DEVICE,detect(UA_DEVICE)).set(UA_ENGINE,detect(UA_ENGINE)).set(UA_OS,detect(UA_OS))}}return this};this.parseUA=function(){if(this.itemType!=UA_RESULT){rgxMapper.call(this.data,this.ua,this.rgxMap)}if(this.itemType==UA_BROWSER){this.set(MAJOR,majorize(this.get(VERSION)))}return this};this.parseCH=function(){var uaCH=this.uaCH,rgxMap=this.rgxMap;switch(this.itemType){case UA_BROWSER:var brands=uaCH[FULLVERLIST]||uaCH[BRANDS],prevName;if(brands){for(var i in brands){var brandName=strip(/(Google|Microsoft) /,brands[i].brand||brands[i]),brandVersion=brands[i].version;if(!/not.a.brand/i.test(brandName)&&(!prevName||/chrom/i.test(prevName)&&!/chromi/i.test(brandName))){this.set(NAME,brandName).set(VERSION,brandVersion).set(MAJOR,majorize(brandVersion));prevName=brandName}}}break;case UA_CPU:var archName=uaCH[ARCHITECTURE];if(archName){if(archName&&uaCH[BITNESS]=="64")archName+="64";rgxMapper.call(this.data,archName+";",rgxMap)}break;case UA_DEVICE:if(uaCH[MOBILE]){this.set(TYPE,MOBILE)}if(uaCH[MODEL]){this.set(MODEL,uaCH[MODEL])}if(uaCH[MODEL]=="Xbox"){this.set(TYPE,CONSOLE).set(VENDOR,MICROSOFT)}if(uaCH[FORMFACTORS]){var ff;if(typeof uaCH[FORMFACTORS]!=="string"){var idx=0;while(!ff&&idx=13?"11":"10";this.set(NAME,osName).set(VERSION,osVersion)}if(this.get(NAME)==WINDOWS&&uaCH[MODEL]=="Xbox"){this.set(NAME,"Xbox").set(VERSION,undefined)}break;case UA_RESULT:var data=this.data;var parse=function(itemType){return data[itemType].getItem().setCH(uaCH).parseCH().get()};this.set(UA_BROWSER,parse(UA_BROWSER)).set(UA_CPU,parse(UA_CPU)).set(UA_DEVICE,parse(UA_DEVICE)).set(UA_ENGINE,parse(UA_ENGINE)).set(UA_OS,parse(UA_OS))}return this};setProps.call(this,[["itemType",itemType],["ua",ua],["uaCH",uaCH],["rgxMap",rgxMap],["data",createIData(this,itemType)]]);return this}function UAParser(ua,extensions,headers){if(typeof ua===OBJ_TYPE){if(isExtensions(ua,true)){if(typeof extensions===OBJ_TYPE){headers=extensions}extensions=ua}else{headers=ua;extensions=undefined}ua=undefined}else if(typeof ua===STR_TYPE&&!isExtensions(extensions,true)){headers=extensions;extensions=undefined}if(headers&&typeof headers.append===FUNC_TYPE){var kv={};headers.forEach(function(v,k){kv[k]=v});headers=kv}if(!(this instanceof UAParser)){return new UAParser(ua,extensions,headers).getResult()}var userAgent=typeof ua===STR_TYPE?ua:headers&&headers[USER_AGENT]?headers[USER_AGENT]:NAVIGATOR&&NAVIGATOR.userAgent?NAVIGATOR.userAgent:EMPTY,httpUACH=new UACHData(headers,true),regexMap=extensions?extend(defaultRegexes,extensions):defaultRegexes,createItemFunc=function(itemType){if(itemType==UA_RESULT){return function(){return new UAItem(itemType,userAgent,regexMap,httpUACH).set("ua",userAgent).set(UA_BROWSER,this.getBrowser()).set(UA_CPU,this.getCPU()).set(UA_DEVICE,this.getDevice()).set(UA_ENGINE,this.getEngine()).set(UA_OS,this.getOS()).get()}}else{return function(){return new UAItem(itemType,userAgent,regexMap[itemType],httpUACH).parseUA().get()}}};setProps.call(this,[["getBrowser",createItemFunc(UA_BROWSER)],["getCPU",createItemFunc(UA_CPU)],["getDevice",createItemFunc(UA_DEVICE)],["getEngine",createItemFunc(UA_ENGINE)],["getOS",createItemFunc(UA_OS)],["getResult",createItemFunc(UA_RESULT)],["getUA",function(){return userAgent}],["setUA",function(ua){if(isString(ua))userAgent=ua.length>UA_MAX_LENGTH?trim(ua,UA_MAX_LENGTH):ua;return this}]]).setUA(userAgent);return this}UAParser.VERSION=LIBVERSION;UAParser.BROWSER=enumerize([NAME,VERSION,MAJOR,TYPE]);UAParser.CPU=enumerize([ARCHITECTURE]);UAParser.DEVICE=enumerize([MODEL,VENDOR,TYPE,CONSOLE,MOBILE,SMARTTV,TABLET,WEARABLE,EMBEDDED]);UAParser.ENGINE=UAParser.OS=enumerize([NAME,VERSION]);if(typeof exports!==UNDEF_TYPE){if(typeof module!==UNDEF_TYPE&&module.exports){exports=module.exports=UAParser}exports.UAParser=UAParser}else{if(typeof define===FUNC_TYPE&&define.amd){define(function(){return UAParser})}else if(isWindow){window.UAParser=UAParser}}var $=isWindow&&(window.jQuery||window.Zepto);if($&&!$.ua){var parser=new UAParser;$.ua=parser.getResult();$.ua.get=function(){return parser.getUA()};$.ua.set=function(ua){parser.setUA(ua);var result=parser.getResult();for(var prop in result){$.ua[prop]=result[prop]}}}})(typeof window==="object"?window:this); \ No newline at end of file diff --git a/dist/ua-parser.pack.js b/dist/ua-parser.pack.js index 0f145e7e3..55b1df175 100644 --- a/dist/ua-parser.pack.js +++ b/dist/ua-parser.pack.js @@ -1,4 +1,4 @@ -/* UAParser.js v2.0.0-rc.2 +/* UAParser.js v2.0.0-rc.3 Copyright © 2012-2024 Faisal Salman AGPLv3 License */ -!function(i,c){"use strict";function e(i){for(var e={},t=0;tT?Ti(i,T):i),this}]]).setUA(o),this}Ui.VERSION="2.0.0-rc.2",Ui.BROWSER=e([m,v,h,f]),Ui.CPU=e([k]),Ui.DEVICE=e([p,g,f,x,y,t,r,o,d]),Ui.ENGINE=Ui.OS=e([m,v]),typeof exports!==b?(typeof module!==b&&module.exports&&(exports=module.exports=Ui),exports.UAParser=Ui):typeof define===l&&define.amd?define(function(){return Ui}):ui&&(i.UAParser=Ui);var ji,Mi=ui&&(i.jQuery||i.Zepto);Mi&&!Mi.ua&&(ji=new Ui,Mi.ua=ji.getResult(),Mi.ua.get=function(){return ji.getUA()},Mi.ua.set=function(i){ji.setUA(i);var e,t=ji.getResult();for(e in t)Mi.ua[e]=t[e]})}("object"==typeof window?window:this); \ No newline at end of file +!function(i,d){"use strict";function e(i){for(var e={},t=0;tC?Ci(i,C):i),this}]]).setUA(r),this}Ui.VERSION="2.0.0-rc.3",Ui.BROWSER=e([m,v,p,f]),Ui.CPU=e([k]),Ui.DEVICE=e([h,g,f,x,y,t,r,o,s]),Ui.ENGINE=Ui.OS=e([m,v]),typeof exports!==b?(typeof module!==b&&module.exports&&(exports=module.exports=Ui),exports.UAParser=Ui):typeof define===u&&define.amd?define(function(){return Ui}):li&&(i.UAParser=Ui);var ji,Ei=li&&(i.jQuery||i.Zepto);Ei&&!Ei.ua&&(ji=new Ui,Ei.ua=ji.getResult(),Ei.ua.get=function(){return ji.getUA()},Ei.ua.set=function(i){ji.setUA(i);var e,t=ji.getResult();for(e in t)Ei.ua[e]=t[e]})}("object"==typeof window?window:this); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8d8b2bc24..42acf6be8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ua-parser-js", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ua-parser-js", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.3", "funding": [ { "type": "opencollective", @@ -23,9 +23,9 @@ ], "license": "AGPL-3.0-or-later", "dependencies": { - "detect-europe-js": "^0.1.1", - "is-standalone-pwa": "^0.1.0", - "ua-is-frozen": "^0.1.1" + "detect-europe-js": "^0.1.2", + "is-standalone-pwa": "^0.1.1", + "ua-is-frozen": "^0.1.2" }, "bin": { "ua-parser-js": "script/cli.js" @@ -1670,9 +1670,9 @@ "dev": true }, "node_modules/detect-europe-js": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/detect-europe-js/-/detect-europe-js-0.1.1.tgz", - "integrity": "sha512-+bUXDf+tI3L4dcEuRdAFa44Amx9aEaJzoZssx7Xis4H1bXWc5fAcOP850BOj0wJPRzOdovOuOVEvrg6T+GflZA==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/detect-europe-js/-/detect-europe-js-0.1.2.tgz", + "integrity": "sha512-lgdERlL3u0aUdHocoouzT10d9I89VVhk0qNRmll7mXdGfJT1/wqZ2ZLA4oJAjeACPY5fT1wsbq2AT+GkuInsow==", "funding": [ { "type": "github", @@ -2612,9 +2612,9 @@ } }, "node_modules/is-standalone-pwa": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-standalone-pwa/-/is-standalone-pwa-0.1.0.tgz", - "integrity": "sha512-n5SQqXd0/JEkrKYEB7ZUndwuS7NKskZvk6rZZt6kTE1jiPxtPfPvVhXkfteIKpUfcEP07qsja/Wjz9NDjiZ5gg==", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-standalone-pwa/-/is-standalone-pwa-0.1.1.tgz", + "integrity": "sha512-9Cbovsa52vNQCjdXOzeQq5CnCbAcRk05aU62K20WO372NrTv0NxibLFCK6lQ4/iZEFdEA3p3t2VNOn8AJ53F5g==", "funding": [ { "type": "github", @@ -4619,9 +4619,9 @@ } }, "node_modules/ua-is-frozen": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ua-is-frozen/-/ua-is-frozen-0.1.1.tgz", - "integrity": "sha512-TxhyfblPzcDJXRXu/j+73OI6s1jG6PUZBF/8hjTHoAsjZYKl9IhZzLQlnZHFLe5U2mvL1lMOOmcy647KpUq25A==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ua-is-frozen/-/ua-is-frozen-0.1.2.tgz", + "integrity": "sha512-RwKDW2p3iyWn4UbaxpP2+VxwqXh0jpvdxsYpZ5j/MLLiQOfbsV5shpgQiw93+KMYQPcteeMQ289MaAFzs3G9pw==", "funding": [ { "type": "github", diff --git a/package.json b/package.json index 1beaf501a..73f74c852 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "title": "UAParser.js", "name": "ua-parser-js", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.3", "author": "Faisal Salman (http://faisalman.com)", "description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent & Client Hints data. Supports browser & node.js environment", "keywords": [ @@ -211,9 +211,9 @@ "test:playwright": "playwright test" }, "dependencies": { - "detect-europe-js": "^0.1.1", - "is-standalone-pwa": "^0.1.0", - "ua-is-frozen": "^0.1.1" + "detect-europe-js": "^0.1.2", + "is-standalone-pwa": "^0.1.1", + "ua-is-frozen": "^0.1.2" }, "devDependencies": { "@babel/parser": "7.15.8", diff --git a/src/enums/ua-parser-enums.js b/src/enums/ua-parser-enums.js index 74218fc14..ff0156d90 100644 --- a/src/enums/ua-parser-enums.js +++ b/src/enums/ua-parser-enums.js @@ -1,5 +1,5 @@ /////////////////////////////////////////////// -/* Enums for UAParser.js v2.0.0-rc.2 +/* Enums for UAParser.js v2.0.0-rc.3 https://github.com/faisalman/ua-parser-js Author: Faisal Salman AGPLv3 License */ diff --git a/src/enums/ua-parser-enums.mjs b/src/enums/ua-parser-enums.mjs index 6af7ef755..dff46cb72 100644 --- a/src/enums/ua-parser-enums.mjs +++ b/src/enums/ua-parser-enums.mjs @@ -3,7 +3,7 @@ // Source: /src/enums/ua-parser-enums.js /////////////////////////////////////////////// -/* Enums for UAParser.js v2.0.0-rc.2 +/* Enums for UAParser.js v2.0.0-rc.3 https://github.com/faisalman/ua-parser-js Author: Faisal Salman AGPLv3 License */ @@ -59,6 +59,7 @@ const Browser = Object.freeze({ GOOGLE_SEARCH: 'GSA', HELIO: 'Helio', HEYTAP: 'HeyTap', + HONOR: 'Honor', HUAWEI: 'Huawei Browser', ICAB: 'iCab', ICE: 'ICE Browser', @@ -162,7 +163,7 @@ const BrowserType = Object.freeze({ FETCHER: 'fetcher', INAPP: 'inapp', MEDIAPLAYER: 'mediaplayer', - MODULE: 'module' + LIBRARY: 'library' }); const CPU = Object.freeze({ @@ -198,6 +199,7 @@ const Device = Object.freeze({ const Vendor = Object.freeze({ ACER: 'Acer', + ADVAN: 'Advan', ALCATEL: 'Alcatel', APPLE: 'Apple', AMAZON: 'Amazon', @@ -206,7 +208,9 @@ const Vendor = Object.freeze({ ATT: 'AT&T', BENQ: 'BenQ', BLACKBERRY: 'BlackBerry', + CAT: 'Cat', DELL: 'Dell', + ENERGIZER: 'Energizer', ESSENTIAL: 'Essential', FACEBOOK: 'Facebook', FAIRPHONE: 'Fairphone', @@ -216,6 +220,7 @@ const Vendor = Object.freeze({ HP: 'HP', HTC: 'HTC', HUAWEI: 'Huawei', + IMO: 'IMO', INFINIX: 'Infinix', ITEL: 'itel', JOLLA: 'Jolla', @@ -223,6 +228,7 @@ const Vendor = Object.freeze({ LENOVO: 'Lenovo', LG: 'LG', MEIZU: 'Meizu', + MICROMAX: 'Micromax', MICROSOFT: 'Microsoft', MOTOROLA: 'Motorola', NEXIAN: 'Nexian', @@ -244,6 +250,7 @@ const Vendor = Object.freeze({ SAMSUNG: 'Samsung', SHARP: 'Sharp', SIEMENS: 'Siemens', + SMARTFREN: 'Smartfren', SONY: 'Sony', SPRINT: 'Sprint', TCL: 'TCL', @@ -277,6 +284,7 @@ const Engine = Object.freeze({ NETFRONT: 'NetFront', NETSURF: 'NetSurf', PRESTO: 'Presto', + SERVO: 'Servo', TASMAN: 'Tasman', TRIDENT: 'Trident', W3M: 'w3m', diff --git a/src/extensions/ua-parser-extensions.d.ts b/src/extensions/ua-parser-extensions.d.ts index 013a3d75b..b4da5499b 100644 --- a/src/extensions/ua-parser-extensions.d.ts +++ b/src/extensions/ua-parser-extensions.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Helpers submodule of UAParser.js v2.0.0-rc.2 +// Type definitions for Helpers submodule of UAParser.js v2.0.0-rc.3 // Project: https://github.com/faisalman/ua-parser-js // Definitions by: Faisal Salman diff --git a/src/extensions/ua-parser-extensions.js b/src/extensions/ua-parser-extensions.js index 936c90bd2..a6774ad8b 100644 --- a/src/extensions/ua-parser-extensions.js +++ b/src/extensions/ua-parser-extensions.js @@ -1,5 +1,5 @@ /////////////////////////////////////////////// -/* Extensions for UAParser.js v2.0.0-rc.2 +/* Extensions for UAParser.js v2.0.0-rc.3 https://github.com/faisalman/ua-parser-js Author: Faisal Salman AGPLv3 License */ diff --git a/src/extensions/ua-parser-extensions.mjs b/src/extensions/ua-parser-extensions.mjs index 21c2dcb9a..5fc374d5d 100644 --- a/src/extensions/ua-parser-extensions.mjs +++ b/src/extensions/ua-parser-extensions.mjs @@ -3,7 +3,7 @@ // Source: /src/extensions/ua-parser-extensions.js /////////////////////////////////////////////// -/* Extensions for UAParser.js v2.0.0-rc.2 +/* Extensions for UAParser.js v2.0.0-rc.3 https://github.com/faisalman/ua-parser-js Author: Faisal Salman AGPLv3 License */ @@ -24,7 +24,7 @@ const EMAIL = 'email'; const FETCHER = 'fetcher'; const INAPP = 'inapp'; const MEDIAPLAYER = 'mediaplayer'; -const MODULE = 'module'; +const LIBRARY = 'library'; ////////////////////// // COMMAND LINE APPS @@ -48,26 +48,36 @@ const Crawlers = Object.freeze({ // Amazonbot - https://developer.amazon.com/amazonbot // Applebot - http://apple.com/go/applebot // Bingbot - http://www.bing.com/bingbot.htm + // CCBot - https://commoncrawl.org/faq // Dotbot - https://moz.com/help/moz-procedures/crawlers/dotbot // DuckDuckBot - http://duckduckgo.com/duckduckbot.html // FacebookBot - https://developers.facebook.com/docs/sharing/bot/ // GPTBot - https://platform.openai.com/docs/gptbot // MJ12bot - https://mj12bot.com/ - // OpenAI Search - https://platform.openai.com/docs/bots + // MojeekBot - https://www.mojeek.com/bot.html + // OpenAI's SearchGPT - https://platform.openai.com/docs/bots + // PerplexityBot - https://perplexity.ai/perplexitybot // SemrushBot - http://www.semrush.com/bot.html - /((?:ahrefs|amazon|apple|bing|dot|duckduck|facebook|gpt|mj12|oai-search|semrush)bot)\/([\w\.]+)/i, + /((?:ahrefs|amazon|apple|bing|cc|dot|duckduck|exa|facebook|gpt|mj12|mojeek|oai-search|perplexity|semrush)bot)\/([\w\.]+)/i, // Baiduspider https://help.baidu.com/question?prod_id=99&class=0&id=3001 /(baiduspider)[-imagevdonsfcpr]{0,6}\/([\w\.]+)/i, - // ClaudeBot + // ClaudeBot (Anthropic) /(claude(?:bot|-web))\/([\w\.]+)/i, // Coc Coc Bot - https://help.coccoc.com/en/search-engine /(coccocbot-(?:image|web))\/([\w\.]+)/i, + // Facebook / Meta + // https://developers.facebook.com/docs/sharing/webmasters/web-crawlers + /(facebook(?:externalhit|catalog)|meta-externalagent)\/([\w\.]+)/i, + // Googlebot - http://www.google.com/bot.html - /(google(?:bot|other)(?:-image|-video|-news|-extended)?|(?:storebot-)?google(?:-inspectiontool)?)\/?([\w\.]*)/i, + /(google(?:bot|other|-inspectiontool)(?:-image|-video|-news)?|storebot-google)\/?([\w\.]*)/i, + + // Internet Archive (archive.org) + /(ia_archiver|archive\.org_bot)\/?([\w\.]*)/i, // Sogou Spider /(sogou (?:pic|head|web|orion|news) spider)\/([\w\.]+)/i, @@ -76,14 +86,29 @@ const Crawlers = Object.freeze({ /(y!?j-(?:asr|br[uw]|dscv|mmp|vsidx|wsc))\/([\w\.]+)/i, // Yandex Bots - https://yandex.com/bots - /(yandex(?:(?:mobile)?(?:accessibility|additional|renderresources|screenshot|sprav)?bot|image(?:s|resizer)|video(?:parser)?|blogs|adnet|favicons|fordomain|market|media|metrika|news|ontodb(?:api)?|pagechecker|partner|rca|tracker|turbo|vertis|webmaster|antivirus))\/([\w\.]+)/i + /(yandex(?:(?:mobile)?(?:accessibility|additional|renderresources|screenshot|sprav)?bot|image(?:s|resizer)|video(?:parser)?|blogs|adnet|favicons|fordomain|market|media|metrika|news|ontodb(?:api)?|pagechecker|partner|rca|tracker|turbo|vertis|webmaster|antivirus))\/([\w\.]+)/i, + + // Yeti (Naver) + /(yeti)\/([\w\.]+)/i, + + // YisouSpider + /(yisouspider)\/?([\w\.]*)/i ], [NAME, VERSION, [TYPE, CRAWLER]], - // Bytespider - // Yahoo! Slurp - http://help.yahoo.com/help/us/ysearch/slurp - [/((?:bytespider|(?=yahoo! )slurp))/i], + [ + // Google Bots + /((?:adsbot|apis|mediapartners)-google(?:-mobile)?|google-?(?:other|cloudvertexbot|extended|safety))/i, + + // Bytespider + // DataForSeoBot - https://dataforseo.com/dataforseo-bot + // Huawei AspiegelBot / PetalBot https://aspiegel.com/petalbot + // Qihoo 360Spider + // TurnitinBot - https://www.turnitin.com/robot/crawlerinfo.html + // Yahoo! Slurp - http://help.yahoo.com/help/us/ysearch/slurp + /(360spider-?(?:image|video)?|bytespider|(?:aspiegel|dataforseo|petal|turnitin)bot|(?=yahoo! )slurp)/i + ], [NAME, [TYPE, CRAWLER]] ] }); @@ -174,8 +199,8 @@ const ExtraDevices = Object.freeze({ const Emails = Object.freeze({ browser : [ - // Microsoft Outlook / Thunderbird - [/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, EMAIL]] + // Evolution / Kontact/KMail / [Microsoft/Mac] Outlook / Thunderbird + [/(evolution|kmail2?|kontact|(?:microsoft |mac)outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, EMAIL]] ] }); @@ -188,8 +213,15 @@ const Fetchers = Object.freeze({ [ // AhrefsSiteAudit - https://ahrefs.com/robot/site-audit // ChatGPT-User - https://platform.openai.com/docs/plugins/bot + // DuckAssistBot - https://duckduckgo.com/duckassistbot/ // BingPreview / Mastodon / Pinterestbot / Redditbot / Rogerbot / Telegrambot / Twitterbot / UptimeRobot - /(ahrefssiteaudit|bingpreview|chatgpt-user|mastodon|(?:discord|linkedin|pinterest|reddit|roger|telegram|twitter|uptimero)bot)\/([\w\.]+)/i, + /(ahrefssiteaudit|bingpreview|chatgpt-user|mastodon|(?:discord|duckassist|linkedin|pinterest|reddit|roger|telegram|twitter|uptimero)bot)\/([\w\.]+)/i, + + // Google Site Verifier + /(google-site-verification)\/([\w\.]+)/i, + + // Meta + /(meta-externalfetcher)\/([\w\.]+)/i, // Slackbot - https://api.slack.com/robots /(slack(?:bot)?(?:-imgproxy|-linkexpanding)?) ([\w\.]+)/i, @@ -207,7 +239,7 @@ const Fetchers = Object.freeze({ [NAME, VERSION, [TYPE, FETCHER]], // Google Bots / Snapchat - [/(feedfetcher-google|google-read-aloud|(?=bot; )snapchat)/i], + [/(feedfetcher-google|google(?:-read-aloud|producer)|(?=bot; )snapchat)/i], [NAME, [TYPE, FETCHER]], ] }); @@ -256,8 +288,8 @@ const MediaPlayers = Object.freeze({ /(flrp)\/([\w\.-]+)/i // Flip Player ], [[NAME, 'Flip Player'], VERSION, [TYPE, MEDIAPLAYER]], [ - /(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i - // FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit + /(fstream|nativehost|queryseekspider)/i + // FStream/NativeHost/QuerySeekSpider ], [NAME, [TYPE, MEDIAPLAYER]], [ /(gstreamer) souphttpsrc.+libsoup\/([\w\.-]+)/i @@ -336,14 +368,14 @@ const MediaPlayers = Object.freeze({ ] }); -//////////////////////// -// MODULES / LIBRARIES -/////////////////////// +///////////// +// LIBRARIES +////////////// -const Modules = Object.freeze({ +const Libraries = Object.freeze({ browser : [ // Axios/jsdom/Scrapy - [/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, MODULE]] + [/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, LIBRARY]] ] }); @@ -356,7 +388,7 @@ const Bots = Object.freeze({ ...CLIs.browser, ...Crawlers.browser, ...Fetchers.browser, - ...Modules.browser + ...Libraries.browser ] }); @@ -368,6 +400,6 @@ export { Emails, Fetchers, InApps, - MediaPlayers, - Modules + Libraries, + MediaPlayers }; \ No newline at end of file diff --git a/src/helpers/ua-parser-helpers.d.ts b/src/helpers/ua-parser-helpers.d.ts index 0f46125a4..10398d60d 100644 --- a/src/helpers/ua-parser-helpers.d.ts +++ b/src/helpers/ua-parser-helpers.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Helpers submodule of UAParser.js v2.0.0-rc.2 +// Type definitions for Helpers submodule of UAParser.js v2.0.0-rc.3 // Project: https://github.com/faisalman/ua-parser-js // Definitions by: Faisal Salman diff --git a/src/helpers/ua-parser-helpers.js b/src/helpers/ua-parser-helpers.js index cd63a79ff..abd580379 100644 --- a/src/helpers/ua-parser-helpers.js +++ b/src/helpers/ua-parser-helpers.js @@ -1,5 +1,5 @@ /////////////////////////////////////////////// -/* Helpers for UAParser.js v2.0.0-rc.2 +/* Helpers for UAParser.js v2.0.0-rc.3 https://github.com/faisalman/ua-parser-js Author: Faisal Salman AGPLv3 License */ diff --git a/src/helpers/ua-parser-helpers.mjs b/src/helpers/ua-parser-helpers.mjs index 7c6fd0eff..5e28bf6bb 100644 --- a/src/helpers/ua-parser-helpers.mjs +++ b/src/helpers/ua-parser-helpers.mjs @@ -3,7 +3,7 @@ // Source: /src/helpers/ua-parser-helpers.js /////////////////////////////////////////////// -/* Helpers for UAParser.js v2.0.0-rc.2 +/* Helpers for UAParser.js v2.0.0-rc.3 https://github.com/faisalman/ua-parser-js Author: Faisal Salman AGPLv3 License */ @@ -19,27 +19,29 @@ import { isStandalonePWA } from 'is-standalone-pwa'; const getDeviceVendor = (model) => UAParser(`Mozilla/5.0 (Linux; Android 10; ${model}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36`).device.vendor; -const isAppleSilicon = (res) => { +const isAppleSilicon = (res, useFeatureDetection) => { if (res.os.is(OS.MACOS)) { if (res.cpu.is(CPU.ARM)) { return true; } - try { - const canvas = document.createElement('canvas'); - const webgl = canvas.getContext('webgl2') || canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); - const debug = webgl.getExtension('WEBGL_debug_renderer_info'); - const renderer = webgl.getParameter(debug.UNMASKED_RENDERER_WEBGL); - if (renderer.match(/apple m\d/i)) { - return true; + if (useFeatureDetection) { + try { + const canvas = document.createElement('canvas'); + const webgl = canvas.getContext('webgl2') || canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + const debug = webgl.getExtension('WEBGL_debug_renderer_info'); + const renderer = webgl.getParameter(debug.UNMASKED_RENDERER_WEBGL); + if (renderer.match(/apple m\d/i)) { + return true; + } + } catch { + return false; } - } catch { - return false; } } return false; } -const isBot = (res) => ['cli', 'crawler', 'fetcher', 'module'].includes(res.browser.type); +const isBot = (res) => ['cli', 'crawler', 'fetcher', 'library'].includes(res.browser.type); const isChromeFamily = (res) => res.engine.is(Engine.BLINK); diff --git a/src/main/ua-parser.d.ts b/src/main/ua-parser.d.ts index cbf583717..4e64bf44c 100644 --- a/src/main/ua-parser.d.ts +++ b/src/main/ua-parser.d.ts @@ -1,4 +1,4 @@ -// Type definitions for UAParser.js v2.0.0-rc.2 +// Type definitions for UAParser.js v2.0.0-rc.3 // Project: https://github.com/faisalman/ua-parser-js // Definitions by: Faisal Salman @@ -19,7 +19,7 @@ declare namespace UAParser { } interface ICPU extends IData { - architecture?: 'ia32' | 'ia64' | 'amd64' | 'arm' | 'arm64' | 'armhf' | 'avr' | 'irix' | 'irix64' | 'mips' | 'mips64' | '68k' | 'ppc' | 'sparc' | 'sparc64'; + architecture?: 'ia32' | 'ia64' | 'amd64' | 'arm' | 'arm64' | 'armhf' | 'avr' | 'avr32' | 'irix' | 'irix64' | 'mips' | 'mips64' | '68k' | 'pa-risc' | 'ppc' | 'sparc' | 'sparc64'; } interface IDevice extends IData { @@ -29,7 +29,7 @@ declare namespace UAParser { } interface IEngine extends IData { - name?: 'Amaya' | 'Blink' | 'EdgeHTML' | 'Flow' | 'Gecko' | 'Goanna' | 'iCab' | 'KHTML' | 'LibWeb' | 'Links' | 'Lynx' | 'NetFront' | 'NetSurf' | 'Presto' | 'Tasman' | 'Trident' | 'w3m' | 'WebKit'; + name?: 'Amaya' | 'ArkWeb' | 'Blink' | 'EdgeHTML' | 'Flow' | 'Gecko' | 'Goanna' | 'iCab' | 'KHTML' | 'LibWeb' | 'Links' | 'Lynx' | 'NetFront' | 'NetSurf' | 'Presto' | 'Servo' | 'Tasman' | 'Trident' | 'w3m' | 'WebKit'; version?: string; } diff --git a/src/main/ua-parser.js b/src/main/ua-parser.js index 3615efd46..c1f07cb6c 100755 --- a/src/main/ua-parser.js +++ b/src/main/ua-parser.js @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////////// -/* UAParser.js v2.0.0-rc.2 +/* UAParser.js v2.0.0-rc.3 Copyright © 2012-2024 Faisal Salman AGPLv3 License *//* Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. @@ -19,7 +19,7 @@ // Constants ///////////// - var LIBVERSION = '2.0.0-rc.2', + var LIBVERSION = '2.0.0-rc.3', EMPTY = '', UNKNOWN = '?', FUNC_TYPE = 'function', diff --git a/src/main/ua-parser.mjs b/src/main/ua-parser.mjs index 130f21649..80e1770ce 100644 --- a/src/main/ua-parser.mjs +++ b/src/main/ua-parser.mjs @@ -3,7 +3,7 @@ // Source: /src/main/ua-parser.js ///////////////////////////////////////////////////////////////////////////////// -/* UAParser.js v2.0.0-rc.2 +/* UAParser.js v2.0.0-rc.3 Copyright © 2012-2024 Faisal Salman AGPLv3 License *//* Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. @@ -21,7 +21,7 @@ // Constants ///////////// - var LIBVERSION = '2.0.0-rc.2', + var LIBVERSION = '2.0.0-rc.3', EMPTY = '', UNKNOWN = '?', FUNC_TYPE = 'function', @@ -74,6 +74,7 @@ GOOGLE = 'Google', HUAWEI = 'Huawei', LENOVO = 'Lenovo', + HONOR = 'Honor', LG = 'LG', MICROSOFT = 'Microsoft', MOTOROLA = 'Motorola', @@ -529,10 +530,14 @@ /\b(sh-?[altvz]?\d\d[a-ekm]?)/i ], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [ + // Honor + /(?:honor)([-\w ]+)[;\)]/i + ], [MODEL, [VENDOR, HONOR], [TYPE, MOBILE]], [ + // Huawei /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i ], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [ - /(?:huawei|honor)([-\w ]+)[;\)]/i, + /(?:huawei)([-\w ]+)[;\)]/i, /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i ], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [ @@ -597,7 +602,7 @@ ], [MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]], [ // Sony - /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 + /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 ], [MODEL, [VENDOR, SONY], [TYPE, MOBILE]], [ /sony tablet [ps]/i, /\b(?:sony)?sgp\w+(?: bui|\))/i @@ -663,13 +668,28 @@ /; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i ], [MODEL, [VENDOR, 'Ulefone'], [TYPE, MOBILE]], [ + // Energizer + /; (energy ?\w+)(?: bui|\))/i, + /; energizer ([\w ]+)(?: bui|\))/i + ], [MODEL, [VENDOR, 'Energizer'], [TYPE, MOBILE]], [ + + // Cat + /; cat (b35);/i, + /; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i + ], [MODEL, [VENDOR, 'Cat'], [TYPE, MOBILE]], [ + + // Smartfren + /((?:new )?andromax[\w- ]+)(?: bui|\))/i + ], [MODEL, [VENDOR, 'Smartfren'], [TYPE, MOBILE]], [ + // Nothing /droid.+; (a(?:015|06[35]|142p?))/i ], [MODEL, [VENDOR, 'Nothing'], [TYPE, MOBILE]], [ // MIXED - /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i, - // BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron + /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i, + // BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron/Infinix/Tecno/Micromax/Advan + /; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i, // IMO /(hp) ([\w ]+\w)/i, // HP iPAQ /(asus)-?(\w+)/i, // Asus /(microsoft); (lumia[\w ]+)/i, // Microsoft Lumia @@ -678,6 +698,7 @@ /(oppo) ?([\w ]+) bui/i // OPPO ], [VENDOR, MODEL, [TYPE, MOBILE]], [ + /(imo) (tab \w+)/i, // IMO /(kobo)\s(ereader|touch)/i, // Kobo /(archos) (gamepad2?)/i, // Archos /(hp).+(touchpad(?!.+tablet)|tablet)/i, // HP TouchPad @@ -811,7 +832,7 @@ ], [VERSION, [NAME, 'Blink']], [ /(presto)\/([\w\.]+)/i, // Presto - /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna + /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna/Servo /ekioh(flow)\/([\w\.]+)/i, // Flow /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, // KHTML/Tasman/Links /(icab)[\/ ]([23]\.[\d\.]+)/i, // iCab @@ -1238,14 +1259,21 @@ headers = extensions; // case UAParser(ua, headers) extensions = undefined; } + + // Convert Headers object into a plain object + if (headers && typeof headers.append === FUNC_TYPE) { + var kv = {}; + headers.forEach(function (v, k) { kv[k] = v; }); + headers = kv; + } if (!(this instanceof UAParser)) { return new UAParser(ua, extensions, headers).getResult(); } var userAgent = typeof ua === STR_TYPE ? ua : // Passed user-agent string - ((NAVIGATOR && NAVIGATOR.userAgent) ? NAVIGATOR.userAgent : // navigator.userAgent (headers && headers[USER_AGENT] ? headers[USER_AGENT] : // User-Agent from passed headers + ((NAVIGATOR && NAVIGATOR.userAgent) ? NAVIGATOR.userAgent : // navigator.userAgent EMPTY)), // empty string httpUACH = new UACHData(headers, true),