https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
### 2.11.0 (Sep 12, 2020)
- [ADD] Added support for aliases in `Parser#is` method (#437)
- [ADD] Added more typings (#438, #427)
- [ADD] Added support for MIUI Browserr (#436)
- [ADD] Added support for MIUI Browser (#436)
### 2.10.0 (Jul 9, 2020)
- [FIX] Fix for Firefox detection on iOS 13 [#415]
+2 -4
View File
@@ -11,8 +11,6 @@ Don't hesitate to support the project on Github or [OpenCollective](https://open
# Contents
- [Overview](#overview)
- [Use cases](#use-cases)
- [Advanced usage](#advanced-usage)
- [How can I help?](#contributing)
# Overview
@@ -20,7 +18,7 @@ The library is made to help to detect what browser your user has and gives you a
### ⚠️ Version 2.0 breaking changes ⚠️
Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://lancedikson.github.io/bowser/docs).
Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://bowser-js.github.io/bowser/docs/).
_For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._
@@ -149,7 +147,7 @@ list of aliases can be found in [the file](src/constants.js).
### Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
This project exists thanks to all the people who contribute. [[Contribute](.github/CONTRIBUTING.md)].
<a href="https://github.com/lancedikson/bowser/graphs/contributors"><img src="https://opencollective.com/bowser/contributors.svg?width=890&button=false" /></a>
### Financial Contributors
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+72 -7
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/lancedikson/bowser
// Definitions by: Alexander P. Cerutti <https://github.com/alexandercerutti>,
export = Bowser;
export default Bowser;
export as namespace Bowser;
declare namespace Bowser {
@@ -34,6 +34,14 @@ declare namespace Bowser {
interface Parser {
constructor(UA: string, skipParsing?: boolean): Parser.Parser;
/**
* Check if the version is equals the browser version
* @param version The string to compare with the browser version
* @returns {boolean}
*/
compareVersion(version: string): boolean;
/**
* Get parsed browser object
* @return {BrowserDetails} Browser's details
@@ -54,7 +62,7 @@ declare namespace Bowser {
* @return {String} version of browser
*/
getBrowserVersion(): string;
getBrowserVersion(): string | undefined;
/**
* Get OS
@@ -130,10 +138,44 @@ declare namespace Bowser {
* Is anything? Check if the browser is called "anything",
* the OS called "anything" or the platform called "anything"
* @param {String} anything
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {Boolean}
*/
is(anything: any): boolean;
is(anything: any, includingAlias?: boolean): boolean;
/**
* Check if the browser name equals the passed string
* @param browserName The string to compare with the browser name
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {boolean}
*/
isBrowser(browserName: string, includingAlias?: boolean): boolean;
/**
* Check if the engine name equals the passed string
* @param engineName The string to compare with the engine name
* @returns {boolean}
*/
isEngine(engineName: string): boolean;
/**
* Check if the OS name equals the passed string
* @param OSName The string to compare with the OS name
* @returns {boolean}
*/
isOS(OSName: string): boolean;
/**
* Check if the platform name equals the passed string
* @param platformName The string to compare with the platform name
* @returns {boolean}
*/
isPlatform(platformName: string): boolean;
/**
* Parse full information about the browser
@@ -191,18 +233,41 @@ declare namespace Bowser {
satisfies(checkTree: checkTree): boolean | undefined;
/**
/**
* Check if the browser name equals the passed string
* @param browserName The string to compare with the browser name
* @param {string} browserName The string to compare with the browser name
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {boolean}
*/
isBrowser(browserName: string, includingAlias?: boolean): boolean;
/**
* Check if any of the given values satifies `.is(anything)`
* Check if the engine name equals the passed string
* @param {string} engineName The string to compare with the engine name
* @returns {boolean}
*/
isEngine(engineName: string): boolean;
/**
* Check if the platform type equals the passed string
* @param {string} platformType The string to compare with the platform type
* @returns {boolean}
*/
isPlatform(platformType: string): boolean;
/**
* Check if the OS name equals the passed string
* @param {string} osName The string to compare with the OS name
* @returns {boolean}
*/
isOS(osName: string): boolean;
/**
* Check if any of the given values satisfies `.is(anything)`
* @param {string[]} anythings
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
*/
+4 -3
View File
@@ -1,6 +1,5 @@
{
"name": "bowser",
"version": "2.11.0",
"description": "Lightweight browser detector",
"keywords": [
"browser",
@@ -72,12 +71,14 @@
"generate-and-deploy-docs": "npm run generate-docs && gh-pages --dist docs --dest docs",
"watch": "webpack --watch --config webpack.config.js",
"prepublishOnly": "npm run build",
"lint": "eslint ./src",
"lint:check": "eslint ./src",
"lint:fix": "eslint --fix ./src",
"testem": "testem",
"test": "nyc --reporter=html --reporter=text ava",
"test:watch": "ava --watch",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"generate-docs": "jsdoc -c jsdoc.json"
},
"license": "MIT"
"license": "MIT",
"version": "2.12.0"
}
+3
View File
@@ -22,6 +22,7 @@ export const BROWSER_ALIASES_MAP = {
'NAVER Whale Browser': 'naver',
Opera: 'opera',
'Opera Coast': 'opera_coast',
'Pale Moon': 'pale_moon',
PhantomJS: 'phantomjs',
Puffin: 'puffin',
QupZilla: 'qupzilla',
@@ -64,6 +65,7 @@ export const BROWSER_MAP = {
naver: 'NAVER Whale Browser',
opera: 'Opera',
opera_coast: 'Opera Coast',
pale_moon: 'Pale Moon',
phantomjs: 'PhantomJS',
puffin: 'Puffin',
qupzilla: 'QupZilla',
@@ -88,6 +90,7 @@ export const PLATFORMS_MAP = {
mobile: 'mobile',
desktop: 'desktop',
tv: 'tv',
bot: 'bot',
};
export const OS_MAP = {
+15
View File
@@ -108,6 +108,21 @@ const browsersList = [
return browser;
},
},
{
test: [/PaleMoon/i],
describe(ua) {
const browser = {
name: 'Pale Moon',
};
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i, ua);
if (version) {
browser.version = version;
}
return browser;
},
},
{
test: [/MZBrowser/i],
describe(ua) {
+17 -1
View File
@@ -12,7 +12,7 @@ export default [
test: [/googlebot/i],
describe() {
return {
type: 'bot',
type: PLATFORMS_MAP.bot,
vendor: 'Google',
};
},
@@ -130,6 +130,22 @@ export default [
},
},
/* Nokia */
{
test: [/Nokia/i],
describe(ua) {
const model = Utils.getFirstMatch(/Nokia\s+([0-9]+(\.[0-9]+)?)/i, ua);
const platform = {
type: PLATFORMS_MAP.mobile,
vendor: 'Nokia',
};
if (model) {
platform.model = model;
}
return platform;
},
},
/* Mobile */
{
test: [/[^-]mobi/i],
+20 -5
View File
@@ -87,7 +87,7 @@ class Parser {
return _browser.test(this);
}
if (_browser.test instanceof Array) {
if (Array.isArray(_browser.test)) {
return _browser.test.some(condition => this.test(condition));
}
@@ -170,7 +170,7 @@ class Parser {
return _os.test(this);
}
if (_os.test instanceof Array) {
if (Array.isArray(_os.test)) {
return _os.test.some(condition => this.test(condition));
}
@@ -246,7 +246,7 @@ class Parser {
return _platform.test(this);
}
if (_platform.test instanceof Array) {
if (Array.isArray(_platform.test)) {
return _platform.test.some(condition => this.test(condition));
}
@@ -297,7 +297,7 @@ class Parser {
return _engine.test(this);
}
if (_engine.test instanceof Array) {
if (Array.isArray(_engine.test)) {
return _engine.test.some(condition => this.test(condition));
}
@@ -408,7 +408,7 @@ class Parser {
/**
* Check if the browser name equals the passed string
* @param browserName The string to compare with the browser name
* @param {string} browserName The string to compare with the browser name
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {boolean}
*/
@@ -459,14 +459,29 @@ class Parser {
) > -1;
}
/**
* Check if the OS name equals the passed string
* @param {string} osName The string to compare with the OS name
* @returns {boolean}
*/
isOS(osName) {
return this.getOSName(true) === String(osName).toLowerCase();
}
/**
* Check if the platform type equals the passed string
* @param {string} platformType The string to compare with the platform type
* @returns {boolean}
*/
isPlatform(platformType) {
return this.getPlatformType(true) === String(platformType).toLowerCase();
}
/**
* Check if the engine name equals the passed string
* @param {string} engineName The string to compare with the engine name
* @returns {boolean}
*/
isEngine(engineName) {
return this.getEngineName(true) === String(engineName).toLowerCase();
}
+2 -2
View File
@@ -295,10 +295,10 @@ export default class Utils {
}
/**
* Get short version/alias for a browser name
* Get browser name for a short version/alias
*
* @example
* getBrowserAlias('edge') // Microsoft Edge
* getBrowserTypeByAlias('edge') // Microsoft Edge
*
* @param {string} browserAlias
* @return {string}