1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Merge branch 'release/2.0.0-alpha.2'

This commit is contained in:
Denis Demchenko 2018-07-17 21:27:00 +03:00
commit 2ae6ce1820
11 changed files with 43 additions and 26 deletions

View File

@ -1 +0,0 @@
src/bowser.js

4
.gitignore vendored
View File

@ -1,8 +1,6 @@
node_modules/ node_modules/
.idea/ .idea/
/bowser.js
/bowser.min.js
/lib/
.nyc_output .nyc_output
coverage coverage
dist dist
compiled.js

View File

@ -1,5 +1,5 @@
make test
src/useragents.js
Makefile
.nyc_output .nyc_output
coverage coverage
**/.*
node_modules

1
.npmrc Normal file
View File

@ -0,0 +1 @@
registry=https://registry.npmjs.org

View File

@ -1,5 +1,11 @@
# Bowser Changelog # 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) ### 2.0.0-alpha.1 (July 9, 2018)
- [ADD] `Bowser.getParser()` - [ADD] `Bowser.getParser()`
- [ADD] `Bowser.parse` - [ADD] `Bowser.parse`

View File

@ -22,7 +22,7 @@ The upcoming 2.0 version has drastically changed API. All available methods can
First of all, require the library: First of all, require the library:
``` ```javascript
const bowser = require('bowser'); 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: 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); const browser = bowser.getParser(window.navigator.userAgent);
console.log(`The current browser name is "${browser.getBrowserName()}"`); console.log(`The current browser name is "${browser.getBrowserName()}"`);
@ -39,7 +39,7 @@ console.log(`The current browser name is "${browser.getBrowserName()}"`);
or or
``` ```javascript
const impression = new Impression(); const impression = new Impression();
const browser = bowser.getParser(window.navigator.userAgent); const browser = bowser.getParser(window.navigator.userAgent);
@ -50,7 +50,7 @@ impression.brVer = browserInfo.version;
or or
``` ```javascript
const browser = bowser.getParser(window.navigator.userAgent); const browser = bowser.getParser(window.navigator.userAgent);
impression.userTechData = browser.parse(); impression.userTechData = browser.parse();
console.log(impression.userTechData); 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. You could want to filter some particular browsers to provide any special support for them or make any workarounds.
It could look like this: It could look like this:
``` ```javascript
const browser = bowser.getParsers(window.navigator.userAgent); const browser = bowser.getParsers(window.navigator.userAgent);
const isValidBrowser = browser.satisfies({ const isValidBrowser = browser.satisfies({
// declare browsers per OS // declare browsers per OS
@ -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. More of API and possibilities you will find in the `docs` folder.
# Advanced Usage # Advanced Usage
By default, `require('bowser')` requires the pre-compiled file, which can By default, `require('bowser')` requires the *ES6 version of files*, which
include useless for you polyfills. In case you don't need that, you can choose **don't** include any polyfills. In case if you don't use your own `babel-polyfill`
using source file requiring bowser like that: `require('bowser/src/bowser`); you may need to have pre-built bundle with all needed polyfills.
Then you get ES2015 file, which is not precompiled and can be easier to debug. It's possible requiring bowser like that: `require('bowser/compiled');`
As result you get a ES5 file with `babel-polyfill` bundled in it.
# Contributing # 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): 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):

View File

@ -1,6 +1,6 @@
{ {
"name": "bowser", "name": "bowser",
"version": "2.0.0-alpha.1", "version": "2.0.0-alpha.2",
"description": "Lightweight browser detector", "description": "Lightweight browser detector",
"keywords": [ "keywords": [
"browser", "browser",
@ -20,8 +20,7 @@
"url": "http://twitter.com/lancedikson" "url": "http://twitter.com/lancedikson"
} }
], ],
"main": "./dist/bowser.compiled.js", "main": "src/bowser.js",
"typings": "./typings.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/lancedikson/bowser.git" "url": "git+https://github.com/lancedikson/bowser.git"

View File

@ -14,7 +14,7 @@ const TYPES_LABELS = {
export default [ export default [
/* Nexus Tablet */ /* Nexus Tablet */
{ {
test: [/nexus\s*[0-9]+/i], test: [/nexus\s*(?:7|8|9|10).*/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.tablet, type: TYPES_LABELS.tablet,
@ -87,7 +87,7 @@ export default [
/* Nexus Mobile */ /* Nexus Mobile */
{ {
test: [/nexus\s*[0-6]\s*/i, /galaxy nexus/i], test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
describe() { describe() {
return { return {
type: TYPES_LABELS.mobile, type: TYPES_LABELS.mobile,

View File

@ -254,7 +254,21 @@
type: "tablet" type: "tablet"
engine: engine:
name: "Blink" 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" 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: spec:
@ -607,7 +621,7 @@
name: "Android" name: "Android"
version: "5.1.1" version: "5.1.1"
platform: platform:
type: "tablet" type: "mobile"
vendor: "Nexus" vendor: "Nexus"
engine: engine:
name: "Blink" name: "Blink"

1
typings.d.ts vendored
View File

@ -1 +0,0 @@
// to be defined in stable version

View File

@ -9,10 +9,10 @@ module.exports = {
// and webpack starts bundling // and webpack starts bundling
output: { output: {
// options related to how webpack emits results // 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 // the target directory for all output files
// must be an absolute path (use the Node.js path module) // 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 // the filename template for entry chunks
library: 'bowser', library: 'bowser',
libraryTarget: 'umd', // universal module definition libraryTarget: 'umd', // universal module definition