Skip to content

Commit

Permalink
Merge branch 'release/2.0.0' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
lancedikson committed Jan 19, 2019
2 parents be6a7b2 + df6183f commit 4ec19a2
Show file tree
Hide file tree
Showing 27 changed files with 18,355 additions and 21,721 deletions.
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [["env", {
"useBuiltIns": true,
"presets": [["@babel/preset-env", {
"useBuiltIns": "entry",
"modules": "umd",
"targets": {
"ie": "8",
Expand All @@ -13,7 +13,7 @@
"env": {
"test": {
"plugins": [ "istanbul" ],
"presets": [["env", { "targets": { "node": "current" } }]]
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
}
}
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[{*.js,*.md}]
charset = utf-8
Expand Down
8 changes: 7 additions & 1 deletion .nycrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"sourceMap": false,
"instrument": false
"instrument": false,
"include": [
"src/**/*.js"
],
"exclude": [
"*.js"
]
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ node_js:
- "8.4.0"
script:
- npm run lint
- npm build
- npm run build
- npm test
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Bowser Changelog

### 2.0.0 (January 19, 2019)
- [ADD] Support a non strict equality in `Parser.satisfies()` (#275)
- [ADD] Add Android versions names (#276)
- [ADD] Add a typings file (#277)
- [ADD] Added support for Googlebot recognition (#278)
- [FIX] Update building tools, avoid security issues

### 2.0.0-beta.3 (September 15, 2018)
- [FIX] Fix Chrome Mobile detection (#253)
- [FIX] Use built bowser for CI (#252)
Expand Down Expand Up @@ -82,7 +89,7 @@

### 1.5.0 (October 31, 2016)
- [ADD] Throw an error when `minVersion` map has not a string as a version and fix readme (#165)
- [FIX] Fix truly detection of Windows Phones (#167)
- [FIX] Fix truly detection of Windows Phones (#167)

### 1.4.6 (September 19, 2016)
- [FIX] Fix mobile Opera's version detection on Android
Expand Down Expand Up @@ -120,4 +127,4 @@
- [FEATURE] Add `bowser.check` method
- [DOC] Changelog started
- [DOC] Add API section to README
- [FIX] Fix detection of browser type (A/C/X) for Chromium
- [FIX] Fix detection of browser type (A/C/X) for Chromium
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing

The project runs Git-flow, where the `master` branch is the production one and the `develop` is the developing one.
The project runs Git-flow, where the `master` branch is the development one and `production` is the production one.

In a nutshell, if you're about to propose a new feature with adding new functionality to bowser, it's better to branch from `develop` and make a PR pointing to `develop` as well.
If it's a small hotfix, fix a typo in the docs or you've added support for a new browser/OS/platform/etc, then it's better to branch from `master` and make a PR pointing to `master` as well.
In a nutshell, if you're about to propose a new feature with adding some totally new functionality to `bowser`, it's better to branch from `master` and make a PR pointing back to `master` as well.
If it's a small hotfix, fix a typo in the docs or you've added support for a new browser/OS/platform/etc, then it's better to branch from `production` and make a PR pointing back to `production`.
Following these simple rules will help to maintain the repo a lot! Thanks ❤️
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Bowser
A Browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.
A browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.

[![Build Status](https://travis-ci.org/lancedikson/bowser.svg?branch=master)](https://travis-ci.org/lancedikson/bowser/) [![Greenkeeper badge](https://badges.greenkeeper.io/lancedikson/bowser.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/lancedikson/bowser.svg?branch=master)](https://travis-ci.org/lancedikson/bowser/) [![Greenkeeper badge](https://badges.greenkeeper.io/lancedikson/bowser.svg)](https://greenkeeper.io/)[![Coverage Status](https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master)](https://coveralls.io/github/lancedikson/bowser?branch=master)

# Contents
- [Overview](#overview)
Expand All @@ -15,29 +15,30 @@ The library is made to help to detect what browser your user has and gives you a

_Please, note that this is an alpha version. Check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch for a stable version._

**Changes of the 2.0**
**Changes of version 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:
First of all, require the library. This is a UMD Module, so it will work for AMD, Typescript and CommonJS module systems.

```javascript
const bowser = require('bowser');
const Bowser = require("bowser"); // CommonJS

import * as Bowser from "bowser" // Typescript
```

By default, `require('bowser')` requires the *ES5 version of files*, which
**do not** include any polyfills.
By default, the exported version is the *ES5 transpiled version*, 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.
In case 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.

You may need to use the source files, so they will be available in the package as well.

## 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:
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 do it with Bowser:

```javascript
const browser = bowser.getParser(window.navigator.userAgent);
Expand All @@ -63,6 +64,7 @@ or
const browser = bowser.getParser(window.navigator.userAgent);
impression.userTechData = browser.parse();
console.log(impression.userTechData);

// outputs
{
browser: {
Expand Down Expand Up @@ -103,15 +105,15 @@ const isValidBrowser = browser.satisfies({

// per platform (mobile, desktop or tablet)
mobile: {
safari: '>9',
safari: '>=9',
'android browser': '>3.10'
},

// or in general
chrome: ">20.1.1432",
chrome: "~20.1.1432",
firefox: ">31",
opera: ">22"
opera: ">=22"

// also supports equality operator
chrome: "=20.1.1432", // will match particular build only

Expand All @@ -127,11 +129,16 @@ Thus, you can define OS or platform specific rules and they will have more prior
More of API and possibilities you will find in the `docs` folder.

# Contributing

We're always open to pull requests or code reviews. Everyone can become a permanent contributor. Just ping @lancedikson in the issues or on Twitter ❤️

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):

``` sh
$ npm install
$ npm test
$ npm run build #build
$ npm test #run tests
$ npm run lint #check lint rules
```

### Adding tests
Expand Down
13 changes: 9 additions & 4 deletions docs/Bowser.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ <h4 class="name" id=".getParser"><span class="type-signature">(static) </span>ge

<h5>Example</h5>

<pre class="prettyprint"><code>const bowser = new Bowser(window.navigator.userAgent);
bowser.getResult()</code></pre>
<pre class="prettyprint"><code>const parser = Bowser.getParser(window.navigator.userAgent);
const result = parser.getResult();</code></pre>



Expand Down Expand Up @@ -418,7 +418,7 @@ <h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line42">line 42</a>
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line45">line 45</a>
</li></ul></dd>


Expand Down Expand Up @@ -469,6 +469,11 @@ <h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<



<h5>Example</h5>

<pre class="prettyprint"><code>const result = Bowser.parse(window.navigator.userAgent);</code></pre>




<h5>Parameters:</h5>
Expand Down Expand Up @@ -567,7 +572,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Sep 09 2018 15:08:13 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
10 changes: 5 additions & 5 deletions docs/Parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ <h4 class="name" id="is"><span class="type-signature"></span>is<span class="sign

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line438">line 438</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line446">line 446</a>
</li></ul></dd>


Expand Down Expand Up @@ -2211,7 +2211,7 @@ <h4 class="name" id="satisfies"><span class="type-signature"></span>satisfies<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line340">line 340</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line339">line 339</a>
</li></ul></dd>


Expand Down Expand Up @@ -2382,7 +2382,7 @@ <h4 class="name" id="some"><span class="type-signature"></span>some<span class="

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line447">line 447</a>
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line455">line 455</a>
</li></ul></dd>


Expand Down Expand Up @@ -2422,7 +2422,7 @@ <h4 class="name" id="some"><span class="type-signature"></span>some<span class="


<div class="description">
<p>Check if any of the given values satifies this.is(anything)</p>
<p>Check if any of the given values satisfies this.is(anything)</p>
</div>


Expand Down Expand Up @@ -2687,7 +2687,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Sep 09 2018 15:08:13 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
9 changes: 6 additions & 3 deletions docs/bowser.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ <h1 class="page-title">bowser.js</h1>
* @throws {Error} when UA is not a String
*
* @example
* const bowser = new Bowser(window.navigator.userAgent);
* bowser.getResult()
* const parser = Bowser.getParser(window.navigator.userAgent);
* const result = parser.getResult();
*/
static getParser(UA, skipParsing = false) {
if (typeof UA !== 'string') {
Expand All @@ -81,6 +81,9 @@ <h1 class="page-title">bowser.js</h1>
*
* @param UA
* @return {ParsedResult}
*
* @example
* const result = Bowser.parse(window.navigator.userAgent);
*/
static parse(UA) {
return (new Parser(UA)).getResult();
Expand All @@ -102,7 +105,7 @@ <h1 class="page-title">bowser.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Sep 09 2018 15:08:13 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ <h6>Properties</h6>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Sep 09 2018 15:08:13 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
29 changes: 16 additions & 13 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.ht


<section class="readme">
<article><h2>Bowser</h2><p>A Browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.</p>
<article><h2>Bowser</h2><p>A browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.</p>
<p><a href="https://travis-ci.org/lancedikson/bowser/"><img src="https://travis-ci.org/lancedikson/bowser.svg?branch=master" alt="Build Status"></a> <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/lancedikson/bowser.svg" alt="Greenkeeper badge"></a></p>
<h1>Contents</h1><ul>
<li><a href="#overview">Overview</a></li>
Expand All @@ -60,16 +60,17 @@ <h1>Contents</h1><ul>
</ul>
<h1>Overview</h1><p>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.</p>
<p><em>Please, note that this is an alpha version. Check out the <a href="https://github.com/lancedikson/bowser/tree/v1.x">1.x</a> branch for a stable version.</em></p>
<p><strong>Changes of the 2.0</strong>
<p><strong>Changes of version 2.0</strong>
The upcoming 2.0 version has drastically changed API. All available methods can be found in the <code>docs</code> folder from now on and on a webpage soon.</p>
<h1>Use cases</h1><p>First of all, require the library:</p>
<pre class="prettyprint source lang-javascript"><code>const bowser = require('bowser');</code></pre><p>By default, <code>require('bowser')</code> requires the <em>ES5 version of files</em>, which
<strong>do not</strong> include any polyfills.</p>
<p>In case if you don't use your own <code>babel-polyfill</code> you may need to have pre-built bundle with all needed polyfills.
<h1>Use cases</h1><p>First of all, require the library. This is a UMD Module, so it will work for AMD, Typescript and CommonJS module systems.</p>
<pre class="prettyprint source lang-javascript"><code>const Bowser = require(&quot;bowser&quot;); // CommonJS

import * as Bowser from &quot;bowser&quot; // Typescript</code></pre><p>By default, the exported version is the <em>ES5 transpiled version</em>, which <strong>do not</strong> include any polyfills.</p>
<p>In case you don't use your own <code>babel-polyfill</code> you may need to have pre-built bundle with all needed polyfills.
So, for you it's suitable to require bowser like this: <code>require('bowser/bundled')</code>.
As the result, you get a ES5 version of bowser with <code>babel-polyfill</code> bundled together.</p>
<p>You may need to use the source files, so they will be available in the package as well.</p>
<h2>Browser props detection</h2><p>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:</p>
<h2>Browser props detection</h2><p>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 do it with Bowser:</p>
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParser(window.navigator.userAgent);

console.log(`The current browser name is &quot;${browser.getBrowserName()}&quot;`);
Expand All @@ -83,6 +84,7 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti
<pre class="prettyprint source lang-javascript"><code>const browser = bowser.getParser(window.navigator.userAgent);
impression.userTechData = browser.parse();
console.log(impression.userTechData);

// outputs
{
browser: {
Expand Down Expand Up @@ -115,14 +117,14 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti

// per platform (mobile, desktop or tablet)
mobile: {
safari: '>9',
safari: '>=9',
'android browser': '>3.10'
},

// or in general
chrome: &quot;>20.1.1432&quot;,
chrome: &quot;~20.1.1432&quot;,
firefox: &quot;>31&quot;,
opera: &quot;>22&quot;
opera: &quot;>=22&quot;

// also supports equality operator
chrome: &quot;=20.1.1432&quot;, // will match particular build only
Expand All @@ -134,8 +136,9 @@ <h2>Browser props detection</h2><p>Often we need to pick users' browser properti
Thus, you can define OS or platform specific rules and they will have more priority in the end.</p>
<p>More of API and possibilities you will find in the <code>docs</code> folder.</p>
<h1>Contributing</h1><p>If you'd like to contribute a change to bowser, modify the files in <code>src/</code>, then run the following (you'll need node + npm installed):</p>
<pre class="prettyprint source lang-sh"><code>$ npm install
$ npm test</code></pre><h3>Adding tests</h3><p>See the list in <code>test/acceptance/useragentstrings.yml</code> with example user agents and their expected bowser object.</p>
<pre class="prettyprint source lang-sh"><code>$ npm install #build
$ npm test #run tests
$ npm run lint #check lint rules</code></pre><h3>Adding tests</h3><p>See the list in <code>test/acceptance/useragentstrings.yml</code> with example user agents and their expected bowser object.</p>
<p>Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
check if all tests are still passing.</p>
<h3>Similar Projects</h3><ul>
Expand All @@ -156,7 +159,7 @@ <h3>License</h3><p>Licensed as MIT. All rights not explicitly granted in the MIT
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Sep 09 2018 15:08:13 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Jan 19 2019 15:43:45 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
Loading

0 comments on commit 4ec19a2

Please sign in to comment.