From 51da829e4cc51542afce7def64ede8750b6d6a62 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 Jul 2018 21:47:20 +0300 Subject: [PATCH 1/8] Fix dotfiles --- .eslintignore | 1 - .gitignore | 3 --- .npmignore | 6 +++--- 3 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 9fe9394..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -src/bowser.js diff --git a/.gitignore b/.gitignore index e11bfb0..965bda8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ node_modules/ .idea/ -/bowser.js -/bowser.min.js -/lib/ .nyc_output coverage dist diff --git a/.npmignore b/.npmignore index ff06ed2..2bd0fb1 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,5 @@ -make -src/useragents.js -Makefile +test .nyc_output coverage +**/.* +node_modules From 8ab0b442b689285233427219875ce95cf4ae2e63 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Tue, 17 Jul 2018 19:13:01 +0300 Subject: [PATCH 2/8] Remove typings until stable release fixes #232 --- typings.d.ts | 1 - 1 file changed, 1 deletion(-) delete mode 100644 typings.d.ts diff --git a/typings.d.ts b/typings.d.ts deleted file mode 100644 index c5e093d..0000000 --- a/typings.d.ts +++ /dev/null @@ -1 +0,0 @@ -// to be defined in stable version From b94587fdbcbea04dda438bbcb8febe233d7e4471 Mon Sep 17 00:00:00 2001 From: James Ross Date: Mon, 9 Jul 2018 22:04:37 +0100 Subject: [PATCH 3/8] Improve code formatting in README closes #230 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c5bfbe5..99e4d56 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The upcoming 2.0 version has drastically changed API. All available methods can First of all, require the library: -``` +```javascript const bowser = require('bowser'); ``` @@ -30,7 +30,7 @@ const bowser = require('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 make it with Bowser: -``` +```javascript const browser = bowser.getParser(window.navigator.userAgent); console.log(`The current browser name is "${browser.getBrowserName()}"`); @@ -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); @@ -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); @@ -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 From bdd75028e506a6ebd17c39a8b6364b6a35502ddb Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Tue, 17 Jul 2018 19:19:54 +0300 Subject: [PATCH 4/8] Change the way of compilation and requiring fixes #231 --- .gitignore | 1 + package.json | 3 +-- webpack.config.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 965bda8..1aae30a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ .nyc_output coverage dist +compiled.js diff --git a/package.json b/package.json index bdefb5c..c7309b0 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/webpack.config.js b/webpack.config.js index 271061f..a559df6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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 From 718bea001673b98fddbcb535828165beda6cee36 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Tue, 17 Jul 2018 19:27:21 +0300 Subject: [PATCH 5/8] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 99e4d56..a363d6d 100644 --- a/README.md +++ b/README.md @@ -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): From 8e900bc0a9c69da9da4b4f74a27fb2af82edda3b Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Tue, 17 Jul 2018 21:10:09 +0300 Subject: [PATCH 6/8] Add .npmrc --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..38f11c6 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org From 8d7ef744acca82964de4fff28c214579adc304b0 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Tue, 17 Jul 2018 21:21:56 +0300 Subject: [PATCH 7/8] Fix detection of Nexus devices fixes #233 --- src/parser-platforms.js | 4 ++-- test/acceptance/useragentstrings.yml | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/parser-platforms.js b/src/parser-platforms.js index 9a203eb..3280e26 100644 --- a/src/parser-platforms.js +++ b/src/parser-platforms.js @@ -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, @@ -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, diff --git a/test/acceptance/useragentstrings.yml b/test/acceptance/useragentstrings.yml index bd58f3f..56976aa 100644 --- a/test/acceptance/useragentstrings.yml +++ b/test/acceptance/useragentstrings.yml @@ -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: @@ -607,7 +621,7 @@ name: "Android" version: "5.1.1" platform: - type: "tablet" + type: "mobile" vendor: "Nexus" engine: name: "Blink" From dc15bf483ef1d4ad2a7f9e5ea31e499e91bcdd73 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Tue, 17 Jul 2018 21:26:45 +0300 Subject: [PATCH 8/8] Bump version, update the changelog --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a94a30..069384a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/package.json b/package.json index c7309b0..db904aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bowser", - "version": "2.0.0-alpha.1", + "version": "2.0.0-alpha.2", "description": "Lightweight browser detector", "keywords": [ "browser",