Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-alpha.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lancedikson committed Jul 17, 2018
2 parents 7fc8f3c + dc15bf4 commit 2ae6ce1
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 26 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
node_modules/
.idea/
/bowser.js
/bowser.min.js
/lib/
.nyc_output
coverage
dist
compiled.js
6 changes: 3 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
make
src/useragents.js
Makefile
test
.nyc_output
coverage
**/.*
node_modules
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Bowser Changelog

### 2.0.0-alpha.2 (July 17, 2018)
- [CHANGE] Make `src/bowser` main file instead of the bundled one
- [CHANGE] Move the bundled file to the root of the package to make it possible to `require('bowser/compiled')` (#231)
- [REMOVE] Remove `typings.d.ts` before stable release (#232)
- [FIX] Improve Nexus devices detection (#233)

### 2.0.0-alpha.1 (July 9, 2018)
- [ADD] `Bowser.getParser()`
- [ADD] `Bowser.parse`
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ The upcoming 2.0 version has drastically changed API. All available methods can

First of all, require the library:

```
```javascript
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:

```
```javascript
const browser = bowser.getParser(window.navigator.userAgent);

console.log(`The current browser name is "${browser.getBrowserName()}"`);
Expand All @@ -39,7 +39,7 @@ console.log(`The current browser name is "${browser.getBrowserName()}"`);

or

```
```javascript
const impression = new Impression();

const browser = bowser.getParser(window.navigator.userAgent);
Expand All @@ -50,7 +50,7 @@ impression.brVer = browserInfo.version;

or

```
```javascript
const browser = bowser.getParser(window.navigator.userAgent);
impression.userTechData = browser.parse();
console.log(impression.userTechData);
Expand Down Expand Up @@ -81,7 +81,7 @@ console.log(impression.userTechData);
You could want to filter some particular browsers to provide any special support for them or make any workarounds.
It could look like this:

```
```javascript
const browser = bowser.getParsers(window.navigator.userAgent);
const isValidBrowser = browser.satisfies({
// declare browsers per OS
Expand Down Expand Up @@ -111,10 +111,11 @@ 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.

# Advanced Usage
By default, `require('bowser')` requires the pre-compiled file, which can
include useless for you polyfills. In case you don't need that, you can choose
using source file requiring bowser like that: `require('bowser/src/bowser`);
Then you get ES2015 file, which is not precompiled and can be easier to debug.
By default, `require('bowser')` requires the *ES6 version of files*, which
**don't** 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.
It's possible requiring bowser like that: `require('bowser/compiled');`
As result you get a ES5 file with `babel-polyfill` bundled in it.

# 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):
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bowser",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"description": "Lightweight browser detector",
"keywords": [
"browser",
Expand All @@ -20,8 +20,7 @@
"url": "http://twitter.com/lancedikson"
}
],
"main": "./dist/bowser.compiled.js",
"typings": "./typings.d.ts",
"main": "src/bowser.js",
"repository": {
"type": "git",
"url": "git+https://github.com/lancedikson/bowser.git"
Expand Down
4 changes: 2 additions & 2 deletions src/parser-platforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TYPES_LABELS = {
export default [
/* Nexus Tablet */
{
test: [/nexus\s*[0-9]+/i],
test: [/nexus\s*(?:7|8|9|10).*/i],
describe() {
return {
type: TYPES_LABELS.tablet,
Expand Down Expand Up @@ -87,7 +87,7 @@ export default [

/* Nexus Mobile */
{
test: [/nexus\s*[0-6]\s*/i, /galaxy nexus/i],
test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
describe() {
return {
type: TYPES_LABELS.mobile,
Expand Down
18 changes: 16 additions & 2 deletions test/acceptance/useragentstrings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,21 @@
type: "tablet"
engine:
name: "Blink"
Amazon Silk:
-
ua: "Mozilla/5.0 (Linux; Android 7.0; Nexus 6P Build/NRD90T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.111 Mobile Safari/537.36"
spec:
browser:
name: "Chrome"
version: "63.0.3239.111"
os:
name: "Android"
version: "7.0"
platform:
type: "mobile"
vendor: "Nexus"
engine:
name: "Blink"
Amazon Silk:
-
ua: "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true"
spec:
Expand Down Expand Up @@ -607,7 +621,7 @@
name: "Android"
version: "5.1.1"
platform:
type: "tablet"
type: "mobile"
vendor: "Nexus"
engine:
name: "Blink"
Expand Down
1 change: 0 additions & 1 deletion typings.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module.exports = {
// and webpack starts bundling
output: {
// options related to how webpack emits results
path: path.resolve(__dirname, 'dist'), // string
path: path.resolve(__dirname, './'), // string
// the target directory for all output files
// must be an absolute path (use the Node.js path module)
filename: 'bowser.compiled.js', // string
filename: 'compiled.js', // string
// the filename template for entry chunks
library: 'bowser',
libraryTarget: 'umd', // universal module definition
Expand Down

0 comments on commit 2ae6ce1

Please sign in to comment.