From 2dc858e033c1f57de2e835398c0b2d2439a698de Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 22 Jul 2018 19:38:52 +0300 Subject: [PATCH] Generate docs --- docs/Bowser.html | 2 +- docs/Parser.html | 2 +- docs/bowser.js.html | 2 +- docs/global.html | 2 +- docs/index.html | 152 +++++++++----------------------------------- docs/parser.js.html | 2 +- docs/utils.js.html | 2 +- 7 files changed, 36 insertions(+), 128 deletions(-) diff --git a/docs/Bowser.html b/docs/Bowser.html index 3ea379b..0fabca9 100644 --- a/docs/Bowser.html +++ b/docs/Bowser.html @@ -559,7 +559,7 @@ bowser.getResult()
diff --git a/docs/Parser.html b/docs/Parser.html index e3aa923..6ac3630 100644 --- a/docs/Parser.html +++ b/docs/Parser.html @@ -2528,7 +2528,7 @@ Returns undefined when the browser is no described in the checkTree
diff --git a/docs/bowser.js.html b/docs/bowser.js.html index dd826b2..d8021e4 100644 --- a/docs/bowser.js.html +++ b/docs/bowser.js.html @@ -96,7 +96,7 @@ export default Bowser;
diff --git a/docs/global.html b/docs/global.html index 4f08f8c..2454d0d 100644 --- a/docs/global.html +++ b/docs/global.html @@ -758,7 +758,7 @@ like "iPhone" or "Kindle Fire HD 7" diff --git a/docs/index.html b/docs/index.html index 782952a..9f5fbcd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -47,29 +47,37 @@

Bowser

A Browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.

-

bowser ci

+

Build Status

Contents

-

Overview

The library is made to help to detect what browser your user has and gives you a convenient API -to filter the users somehow depending on their browsers.

+

Overview

The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.

+

Please, note that this is an alpha version. Check out the 1.x branch for a stable version.

+

Changes of the 2.0 +The upcoming 2.0 version has drastically changed API. All available methods can be found in the docs folder from now on and on a webpage soon.

Use cases

First of all, require the library:

-
const Bowser = require('bowser');

Browser props detection

Often we need to pick users' browser properties such as the name, -the version, the rendering engine and so on. Here is an example how to make it with Bowser:

-
const browser = new Bowser(window.navigator.userAgent);
+
const bowser = require('bowser');

By default, require('bowser') requires the ES6 version of files, which +do not include any polyfills.

+

In case if you don't use your own babel-polyfill you may need to have pre-built bundle with all needed polyfills. +So, for you it's suitable to require bowser like this: require('bowser/bundled'). +As the result, you get a ES5 version of bowser with babel-polyfill bundled together.

+

If you use bowser for Node.js, you'd better use require('bowser/es5'), +since source files have import statements, which are not compatible with Node.js yet.

+

Browser props detection

Often we need to pick users' browser properties such as the name, the version, the rendering engine and so on. Here is an example how to make it with Bowser:

+
const browser = bowser.getParser(window.navigator.userAgent);
 
 console.log(`The current browser name is "${browser.getBrowserName()}"`);
 // The current browser name is "Internet Explorer"

or

-
const impression = new Impression();
+
const impression = new Impression();
 
-const browser = new Bowser(window.navigator.userAgent);
+const browser = bowser.getParser(window.navigator.userAgent);
 const browserInfo = browser.getBrowser();
 impression.brName = browserInfo.name;
 impression.brVer = browserInfo.version;

or

-
const browser = new Bowser(window.navigator.userAgent);
+
const browser = bowser.getParser(window.navigator.userAgent);
 impression.userTechData = browser.parse();
 console.log(impression.userTechData);
 // outputs
@@ -90,11 +98,10 @@ console.log(impression.userTechData);
     name: "Trident"
     version: "7.0"
   }
-}

Filtering browsers

You could want to filter some particular browsers to provide any special -support for them or make any workarounds. +}

Filtering browsers

You could want to filter some particular browsers to provide any special support for them or make any workarounds. It could look like this:

-
const browser = new Bowser(window.navigator.userAgent);
-const isValidBrowser = bowser.compare({
+
const browser = bowser.getParsers(window.navigator.userAgent);
+const isValidBrowser = browser.satisfies({
   // declare browsers per OS
   windows: {
     "internet explorer": ">10",
@@ -113,111 +120,12 @@ const isValidBrowser = bowser.compare({
   chrome: ">20.1.1432",
   firefox: ">31",
   opera: ">22"
-});

Settings for any particular OS has more priority and redefines settings of standalone browsers.

-

new Bowser(:Object)

Use it to get object with detected flags of your current browser.

-

bowser._detect(ua :String):Object

Use it to get object with detected flags from User Agent string.

-

bowser.check(minVersions:Object, strictMode:Boolean, [ua]:String):Boolean

Use it to check if browser is supported. In default non-strict mode any browser family not present in minVersions will pass the check (like Chrome in the third call in the sample bellow). When strict mode is enabled then any not specified browser family in minVersions will cause check to return false (in the sample it is the fourth call, the last one).

-
/**
- * in case of using IE10
- */
-bowser.check({msie: "11"});  // true
-bowser.check({msie: "9.0"}); // false
-
-/**
- * specific user agent
- */ 
-bowser.check({chrome: "45"}, window.navigator.userAgent); // true
-
-/**
- * but false in strict mode
- */
-bowser.check({chrome: "45"}, true, window.navigator.userAgent); // false

bowser.compareVersions(versions:Array<String>):Number

Use it to compare two versions.

-
bowser.compareVersions(['9.0', '10']);
-// -1

bowser.isUnsupportedBrowser(minVersions:Object, [strictMode]:Boolean, [ua]:string):Boolean

Use it to check if browser is unsupported.

-
bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent);
-// true / false

See more examples in tests.

-
-

Bowser Flags

Your mileage may vary, but these flags should be set. See Contributing below.

-
alert('Hello ' + bowser.name + ' ' + bowser.version);

All detected browsers

These flags are set for all detected browsers:

-
    -
  • name - A human readable name for this browser. E.g. 'Chrome', ''
  • -
  • version - Version number for the browser. E.g. '32.0'
  • -
-

For unknown browsers, Bowser makes a best guess from the UA string. So, these may not be set.

-

Rendering engine flags

If detected, one of these flags may be set to true:

-

Safari, Chrome and some other minor browsers will report that they have webkit engines. -Firefox and Seamonkey will report that they have gecko engines.

-
if (bowser.webkit) {
-  // do stuff with safari & chrome & opera & android & blackberry & webos & silk
-}

Device flags

If detected, one of these flags may be set to true:

-
    -
  • mobile - All detected mobile OSes are additionally flagged mobile, unless it's a tablet
  • -
  • tablet - If a tablet device is detected, the flag tablet is set instead of mobile.
  • -
-

Browser flags

If detected, one of these flags may be set to true. The rendering engine flag is shown in []'s:

-
    -
  • chrome - [webkit|blink]
  • -
  • firefox - [gecko]
  • -
  • msie
  • -
  • msedge
  • -
  • safari - [webkit]
  • -
  • android - native browser - [webkit|blink]
  • -
  • ios - native browser - [webkit]
  • -
  • opera - [blink if >=15]
  • -
  • samsungBrowser - [blink]
  • -
  • phantom - [webkit]
  • -
  • blackberry - native browser - [webkit]
  • -
  • webos - native browser - [webkit]
  • -
  • silk - Amazon Kindle browser - [webkit]
  • -
  • bada - [webkit]
  • -
  • tizen - [webkit]
  • -
  • seamonkey - [gecko]
  • -
  • sailfish - [gecko]
  • -
  • ucbrowser — [webkit]
  • -
  • qupzilla — [webkit]
  • -
  • vivaldi — [blink]
  • -
  • sleipnir — [blink]
  • -
  • kMeleon — [gecko]
  • -
-

For all detected browsers the browser version is set in the version field.

-

OS Flags

If detected, one of these flags may be set to true:

-
    -
  • mac
  • -
  • windows - other than Windows Phone
  • -
  • windowsphone
  • -
  • linux - other than android, chromeos, webos, tizen, and sailfish
  • -
  • chromeos
  • -
  • android
  • -
  • ios - also sets one of iphone/ipad/ipod
  • -
  • blackberry
  • -
  • firefoxos
  • -
  • webos - may also set touchpad
  • -
  • bada
  • -
  • tizen
  • -
  • sailfish
  • -
-

osversion may also be set:

-
    -
  • osversion - for Android, iOS, MacOS, Windows, Windows Phone, WebOS, Bada, and Tizen. If included in UA string.
  • -
-

iOS is always reported as ios and additionally as iphone/ipad/ipod, whichever one matches best. -If WebOS device is an HP TouchPad the flag touchpad is additionally set.

-

Browser capability grading

One of these flags may be set:

-
    -
  • a - This browser has full capabilities
  • -
  • c - This browser has degraded capabilities. Serve simpler version
  • -
  • x - This browser has minimal capabilities and is probably not well detected.
  • -
-

There is no b. For unknown browsers, none of these flags may be set.

-

Ender Support

package.json

-
"dependencies": {
-  "bowser": "x.x.x"
-}
if (require('bowser').chrome) {
-  alert('Hello Silicon Valley')
-}

Contributing

If you'd like to contribute a change to bowser, modify the files in src/, then run the following (you'll need node + npm installed):

+});

Settings for any particular OS or platform has more priority and redefines settings of standalone browsers. +Thus, you can define OS or platform specific rules and they will have more priority in the end.

+

More of API and possibilities you will find in the docs folder.

+

Contributing

If you'd like to contribute a change to bowser, modify the files in src/, then run the following (you'll need node + npm installed):

$ npm install
-$ make test

Please do not check-in the built files bowser.js and bowser.min.js in pull requests.

-

Adding tests

See the list in src/useragents.js with example user agents and their expected bowser object.

+$ npm test

Adding tests

See the list in test/acceptance/useragentstrings.yml with example user agents and their expected bowser object.

Whenever you add support for new browsers or notice a bug / mismatch, please update the list and check if all tests are still passing.

Similar Projects

    @@ -236,7 +144,7 @@ check if all tests are still passing.


    - Documentation generated by JSDoc 3.5.5 on Sun Jul 08 2018 12:30:49 GMT+0300 (EEST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Sun Jul 22 2018 19:38:05 GMT+0300 (EEST) using the docdash theme.
    diff --git a/docs/parser.js.html b/docs/parser.js.html index beb24a5..ef3ce83 100644 --- a/docs/parser.js.html +++ b/docs/parser.js.html @@ -481,7 +481,7 @@ export default Parser;
    - Documentation generated by JSDoc 3.5.5 on Sun Jul 08 2018 12:30:48 GMT+0300 (EEST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Sun Jul 22 2018 19:38:05 GMT+0300 (EEST) using the docdash theme.
    diff --git a/docs/utils.js.html b/docs/utils.js.html index 04d2e11..03959e1 100644 --- a/docs/utils.js.html +++ b/docs/utils.js.html @@ -186,7 +186,7 @@ module.exports = Utils;
    - Documentation generated by JSDoc 3.5.5 on Sun Jul 08 2018 12:30:48 GMT+0300 (EEST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Sun Jul 22 2018 19:38:05 GMT+0300 (EEST) using the docdash theme.