Returns:
diff --git a/docs/Parser.html b/docs/Parser.html index a01f4f72..2ebd36b1 100644 --- a/docs/Parser.html +++ b/docs/Parser.html @@ -27,7 +27,7 @@
Returns:
diff --git a/docs/bowser.js.html b/docs/bowser.js.html index f8468916..7ba24410 100644 --- a/docs/bowser.js.html +++ b/docs/bowser.js.html @@ -27,7 +27,7 @@
bowser.js
diff --git a/docs/global.html b/docs/global.html index 169d3b67..106e27f3 100644 --- a/docs/global.html +++ b/docs/global.html @@ -27,7 +27,7 @@
Source:
@@ -191,7 +191,7 @@
6.x - Marshmallow
7.x - Nougat
8.x - Oreo
-9.x - ?
+9.x - Pie
getBro
Source:
@@ -473,7 +473,7 @@
Source:
@@ -809,6 +809,180 @@ Returns:
+ getMacOSVersionName(version) → {string}
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Get macOS version name
+10.5 - Leopard
+10.6 - Snow Leopard
+10.7 - Lion
+10.8 - Mountain Lion
+10.9 - Mavericks
+10.10 - Yosemite
+10.11 - El Capitan
+10.12 - Sierra
+10.13 - High Sierra
+10.14 - Mojave
+10.15 - Catalina
+
+
+
+
+
+
+
+
+
+
+ Example
+
+ getMacOSVersionName("10.14") // 'Mojave'
+
+
+
+
+ Parameters:
+
+
+
Returns:
+getMacOSVersionName(version) → {string}
+ + + + + + +-
+
+
+
- Source: +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Get macOS version name +10.5 - Leopard +10.6 - Snow Leopard +10.7 - Lion +10.8 - Mountain Lion +10.9 - Mavericks +10.10 - Yosemite +10.11 - El Capitan +10.12 - Sierra +10.13 - High Sierra +10.14 - Mojave +10.15 - Catalina
+Example
+ +getMacOSVersionName("10.14") // 'Mojave'
+
+
+
+
+ Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
version |
+
+
+ + + +string + + + + | + + + + + ++ |
Returns:
+ + +versionName
+-
+
- + Type + +
- + +string + + + +
getSecondMatch(regexp, ua) → {Array|Object|*|boolean|string}
@@ -1005,7 +1179,7 @@ge
Source:
@@ -1164,7 +1338,7 @@ mapSource:
@@ -2178,7 +2352,7 @@ Properties
diff --git a/docs/index.html b/docs/index.html
index f9d4778f..42fbb4b3 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -27,7 +27,7 @@
@@ -153,13 +153,13 @@ Filtering browsers
// or in general
chrome: "~20.1.1432",
firefox: ">31",
- opera: ">=22"
+ opera: ">=22",
// also supports equality operator
chrome: "=20.1.1432", // will match particular build only
// and loose-equality operator
- chrome: "~20" // will match any 20.* sub-version
+ chrome: "~20", // will match any 20.* sub-version
chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
});
@@ -190,7 +190,7 @@ License
diff --git a/docs/parser.js.html b/docs/parser.js.html
index d1381415..1f1b2e66 100644
--- a/docs/parser.js.html
+++ b/docs/parser.js.html
@@ -27,7 +27,7 @@
@@ -546,7 +546,7 @@ parser.js
diff --git a/docs/utils.js.html b/docs/utils.js.html
index 2e9353fa..c1656199 100644
--- a/docs/utils.js.html
+++ b/docs/utils.js.html
@@ -27,7 +27,7 @@
@@ -97,6 +97,46 @@ utils.js
}
}
+ /**
+ * Get macOS version name
+ * 10.5 - Leopard
+ * 10.6 - Snow Leopard
+ * 10.7 - Lion
+ * 10.8 - Mountain Lion
+ * 10.9 - Mavericks
+ * 10.10 - Yosemite
+ * 10.11 - El Capitan
+ * 10.12 - Sierra
+ * 10.13 - High Sierra
+ * 10.14 - Mojave
+ * 10.15 - Catalina
+ *
+ * @example
+ * getMacOSVersionName("10.14") // 'Mojave'
+ *
+ * @param {string} version
+ * @return {string} versionName
+ */
+ static getMacOSVersionName(version) {
+ const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
+ v.push(0);
+ if (v[0] !== 10) return undefined;
+ switch (v[1]) {
+ case 5: return 'Leopard';
+ case 6: return 'Snow Leopard';
+ case 7: return 'Lion';
+ case 8: return 'Mountain Lion';
+ case 9: return 'Mavericks';
+ case 10: return 'Yosemite';
+ case 11: return 'El Capitan';
+ case 12: return 'Sierra';
+ case 13: return 'High Sierra';
+ case 14: return 'Mojave';
+ case 15: return 'Catalina';
+ default: return undefined;
+ }
+ }
+
/**
* Get Android version name
* 1.5 - Cupcake
@@ -113,7 +153,7 @@ utils.js
* 6.x - Marshmallow
* 7.x - Nougat
* 8.x - Oreo
- * 9.x - ?
+ * 9.x - Pie
*
* @example
* getAndroidVersionName("7.0") // 'Nougat'
@@ -138,6 +178,7 @@ utils.js
if (v[0] === 6) return 'Marshmallow';
if (v[0] === 7) return 'Nougat';
if (v[0] === 8) return 'Oreo';
+ if (v[0] === 9) return 'Pie';
return undefined;
}
@@ -274,7 +315,7 @@ utils.js
diff --git a/package-lock.json b/package-lock.json
index 1b75b05f..95ee1bb1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "bowser",
- "version": "2.5.2",
+ "version": "2.5.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -2659,14 +2659,6 @@
"dev": true,
"requires": {
"lodash": "^4.17.14"
- },
- "dependencies": {
- "lodash": {
- "version": "4.17.14",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
- "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
- "dev": true
- }
}
},
"chalk": {
@@ -6028,12 +6020,6 @@
"pify": "^2.0.0",
"pinkie-promise": "^2.0.0"
}
- },
- "lodash": {
- "version": "4.17.11",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
- "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
- "dev": true
}
}
},
@@ -6668,6 +6654,12 @@
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
"dev": true
},
+ "infer-owner": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz",
+ "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==",
+ "dev": true
+ },
"inflight": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz",
@@ -6741,12 +6733,6 @@
"escape-string-regexp": "^1.0.5"
}
},
- "lodash": {
- "version": "4.17.14",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
- "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
- "dev": true
- },
"mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
@@ -7610,9 +7596,9 @@
}
},
"lodash": {
- "version": "4.17.11",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
- "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
+ "version": "4.17.15",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
+ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true
},
"lodash._baseflatten": {
@@ -9871,14 +9857,6 @@
"dev": true,
"requires": {
"lodash": "^4.17.14"
- },
- "dependencies": {
- "lodash": {
- "version": "4.17.14",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
- "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
- "dev": true
- }
}
},
"resolve": {
@@ -10895,12 +10873,6 @@
"integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
"dev": true
},
- "lodash": {
- "version": "4.17.14",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
- "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
- "dev": true
- },
"string-width": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
@@ -10966,28 +10938,110 @@
}
},
"terser-webpack-plugin": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.3.0.tgz",
- "integrity": "sha512-W2YWmxPjjkUcOWa4pBEv4OP4er1aeQJlSo2UhtCFQCuRXEHjOFscO8VyWHj9JLlA0RzQb8Y2/Ta78XZvT54uGg==",
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz",
+ "integrity": "sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==",
"dev": true,
"requires": {
- "cacache": "^11.3.2",
- "find-cache-dir": "^2.0.0",
+ "cacache": "^12.0.2",
+ "find-cache-dir": "^2.1.0",
"is-wsl": "^1.1.0",
- "loader-utils": "^1.2.3",
"schema-utils": "^1.0.0",
"serialize-javascript": "^1.7.0",
"source-map": "^0.6.1",
- "terser": "^4.0.0",
- "webpack-sources": "^1.3.0",
+ "terser": "^4.1.2",
+ "webpack-sources": "^1.4.0",
"worker-farm": "^1.7.0"
},
"dependencies": {
+ "bluebird": {
+ "version": "3.5.5",
+ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz",
+ "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==",
+ "dev": true
+ },
+ "cacache": {
+ "version": "12.0.2",
+ "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.2.tgz",
+ "integrity": "sha512-ifKgxH2CKhJEg6tNdAwziu6Q33EvuG26tYcda6PT3WKisZcYDXsnEdnRv67Po3yCzFfaSoMjGZzJyD2c3DT1dg==",
+ "dev": true,
+ "requires": {
+ "bluebird": "^3.5.5",
+ "chownr": "^1.1.1",
+ "figgy-pudding": "^3.5.1",
+ "glob": "^7.1.4",
+ "graceful-fs": "^4.1.15",
+ "infer-owner": "^1.0.3",
+ "lru-cache": "^5.1.1",
+ "mississippi": "^3.0.0",
+ "mkdirp": "^0.5.1",
+ "move-concurrently": "^1.0.1",
+ "promise-inflight": "^1.0.1",
+ "rimraf": "^2.6.3",
+ "ssri": "^6.0.1",
+ "unique-filename": "^1.1.1",
+ "y18n": "^4.0.0"
+ }
+ },
+ "glob": {
+ "version": "7.1.4",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
+ "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ }
+ },
+ "graceful-fs": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz",
+ "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==",
+ "dev": true
+ },
+ "lru-cache": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
+ "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
+ "dev": true,
+ "requires": {
+ "yallist": "^3.0.2"
+ }
+ },
+ "rimraf": {
+ "version": "2.6.3",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
+ "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
+ "dev": true,
+ "requires": {
+ "glob": "^7.1.3"
+ }
+ },
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
+ },
+ "webpack-sources": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.1.tgz",
+ "integrity": "sha512-XSz38193PTo/1csJabKaV4b53uRVotlMgqJXm3s3eje0Bu6gQTxYDqpD38CmQfDBA+gN+QqaGjasuC8I/7eW3Q==",
+ "dev": true,
+ "requires": {
+ "source-list-map": "^2.0.0",
+ "source-map": "~0.6.1"
+ }
+ },
+ "yallist": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
+ "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
+ "dev": true
}
}
},
@@ -11776,36 +11830,42 @@
}
},
"webpack": {
- "version": "4.35.3",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.35.3.tgz",
- "integrity": "sha512-xggQPwr9ILlXzz61lHzjvgoqGU08v5+Wnut19Uv3GaTtzN4xBTcwnobodrXE142EL1tOiS5WVEButooGzcQzTA==",
+ "version": "4.39.1",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.39.1.tgz",
+ "integrity": "sha512-/LAb2TJ2z+eVwisldp3dqTEoNhzp/TLCZlmZm3GGGAlnfIWDgOEE758j/9atklNLfRyhKbZTCOIoPqLJXeBLbQ==",
"dev": true,
"requires": {
"@webassemblyjs/ast": "1.8.5",
"@webassemblyjs/helper-module-context": "1.8.5",
"@webassemblyjs/wasm-edit": "1.8.5",
"@webassemblyjs/wasm-parser": "1.8.5",
- "acorn": "^6.2.0",
- "ajv": "^6.1.0",
- "ajv-keywords": "^3.1.0",
- "chrome-trace-event": "^1.0.0",
+ "acorn": "^6.2.1",
+ "ajv": "^6.10.2",
+ "ajv-keywords": "^3.4.1",
+ "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^4.1.0",
- "eslint-scope": "^4.0.0",
+ "eslint-scope": "^4.0.3",
"json-parse-better-errors": "^1.0.2",
- "loader-runner": "^2.3.0",
- "loader-utils": "^1.1.0",
- "memory-fs": "~0.4.1",
- "micromatch": "^3.1.8",
- "mkdirp": "~0.5.0",
- "neo-async": "^2.5.0",
- "node-libs-browser": "^2.0.0",
+ "loader-runner": "^2.4.0",
+ "loader-utils": "^1.2.3",
+ "memory-fs": "^0.4.1",
+ "micromatch": "^3.1.10",
+ "mkdirp": "^0.5.1",
+ "neo-async": "^2.6.1",
+ "node-libs-browser": "^2.2.1",
"schema-utils": "^1.0.0",
- "tapable": "^1.1.0",
- "terser-webpack-plugin": "^1.1.0",
- "watchpack": "^1.5.0",
- "webpack-sources": "^1.3.0"
+ "tapable": "^1.1.3",
+ "terser-webpack-plugin": "^1.4.1",
+ "watchpack": "^1.6.0",
+ "webpack-sources": "^1.4.1"
},
"dependencies": {
+ "acorn": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz",
+ "integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==",
+ "dev": true
+ },
"eslint-scope": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz",
@@ -11815,6 +11875,22 @@
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
}
+ },
+ "source-map": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+ "dev": true
+ },
+ "webpack-sources": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.1.tgz",
+ "integrity": "sha512-XSz38193PTo/1csJabKaV4b53uRVotlMgqJXm3s3eje0Bu6gQTxYDqpD38CmQfDBA+gN+QqaGjasuC8I/7eW3Q==",
+ "dev": true,
+ "requires": {
+ "source-list-map": "^2.0.0",
+ "source-map": "~0.6.1"
+ }
}
}
},
diff --git a/package.json b/package.json
index cde9fd39..8132de54 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "bowser",
- "version": "2.5.2",
+ "version": "2.5.3",
"description": "Lightweight browser detector",
"keywords": [
"browser",
@@ -21,6 +21,7 @@
}
],
"main": "es5.js",
+ "types": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/lancedikson/bowser.git"
@@ -48,7 +49,7 @@
"nyc": "^14.1.1",
"sinon": "^7.3.2",
"testem": "^2.17.0",
- "webpack": "^4.35.3",
+ "webpack": "^4.39.1",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.6",
"yamljs": "^0.3.0"
diff --git a/src/parser-os.js b/src/parser-os.js
index 939aa34a..a66a118c 100644
--- a/src/parser-os.js
+++ b/src/parser-os.js
@@ -46,10 +46,16 @@ export default [
test: [/macintosh/i],
describe(ua) {
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.');
- return {
+ const versionName = Utils.getMacOSVersionName(version);
+
+ const os = {
name: OS_MAP.MacOS,
version,
};
+ if (versionName) {
+ os.versionName = versionName;
+ }
+ return os;
},
},
diff --git a/src/utils.js b/src/utils.js
index 171dfae6..7e36f8fa 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -53,6 +53,46 @@ export default class Utils {
}
}
+ /**
+ * Get macOS version name
+ * 10.5 - Leopard
+ * 10.6 - Snow Leopard
+ * 10.7 - Lion
+ * 10.8 - Mountain Lion
+ * 10.9 - Mavericks
+ * 10.10 - Yosemite
+ * 10.11 - El Capitan
+ * 10.12 - Sierra
+ * 10.13 - High Sierra
+ * 10.14 - Mojave
+ * 10.15 - Catalina
+ *
+ * @example
+ * getMacOSVersionName("10.14") // 'Mojave'
+ *
+ * @param {string} version
+ * @return {string} versionName
+ */
+ static getMacOSVersionName(version) {
+ const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
+ v.push(0);
+ if (v[0] !== 10) return undefined;
+ switch (v[1]) {
+ case 5: return 'Leopard';
+ case 6: return 'Snow Leopard';
+ case 7: return 'Lion';
+ case 8: return 'Mountain Lion';
+ case 9: return 'Mavericks';
+ case 10: return 'Yosemite';
+ case 11: return 'El Capitan';
+ case 12: return 'Sierra';
+ case 13: return 'High Sierra';
+ case 14: return 'Mojave';
+ case 15: return 'Catalina';
+ default: return undefined;
+ }
+ }
+
/**
* Get Android version name
* 1.5 - Cupcake
@@ -69,7 +109,7 @@ export default class Utils {
* 6.x - Marshmallow
* 7.x - Nougat
* 8.x - Oreo
- * 9.x - ?
+ * 9.x - Pie
*
* @example
* getAndroidVersionName("7.0") // 'Nougat'
@@ -94,6 +134,7 @@ export default class Utils {
if (v[0] === 6) return 'Marshmallow';
if (v[0] === 7) return 'Nougat';
if (v[0] === 8) return 'Oreo';
+ if (v[0] === 9) return 'Pie';
return undefined;
}
diff --git a/test/acceptance/useragentstrings.yml b/test/acceptance/useragentstrings.yml
index 713d5771..403275a2 100644
--- a/test/acceptance/useragentstrings.yml
+++ b/test/acceptance/useragentstrings.yml
@@ -207,6 +207,21 @@
type: "desktop"
engine:
name: "Blink"
+ -
+ ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"
+ spec:
+ browser:
+ name: "Chrome"
+ version: "49.0.2623.112"
+ os:
+ name: "macOS"
+ version: "10.7.5"
+ versionName: "Lion"
+ platform:
+ type: "desktop"
+ vendor: "Apple"
+ engine:
+ name: "Blink"
-
ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24"
spec:
@@ -216,6 +231,7 @@
os:
name: "macOS"
version: "10.6.7"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -378,6 +394,7 @@
os:
name: "macOS"
version: "10.6.3"
+ versionName: "Snow Leopard"
platform:
type: "tablet"
vendor: "Amazon"
@@ -539,6 +556,7 @@
os:
name: "macOS"
version: "10.6.7"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -665,6 +683,7 @@
os:
name: "macOS"
version: "10.10.3"
+ versionName: "Yosemite"
platform:
type: "desktop"
vendor: "Apple"
@@ -711,6 +730,7 @@
os:
name: "macOS"
version: "10.6.8"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -726,6 +746,7 @@
os:
name: "macOS"
version: "10.6.7"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -784,12 +805,29 @@
os:
name: "macOS"
version: "10.6.1"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
engine:
name: "WebKit"
version: "531.21.10"
+ -
+ ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"
+ spec:
+ browser:
+ name: "Safari"
+ version: "7.0.3"
+ os:
+ name: "macOS"
+ version: "10.9.3"
+ versionName: "Mavericks"
+ platform:
+ type: "desktop"
+ vendor: "Apple"
+ engine:
+ name: "WebKit"
+ version: "537.75.14"
-
ua: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; de-de) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.28.3"
spec:
@@ -799,6 +837,7 @@
os:
name: "macOS"
version: "10.5.7"
+ versionName: "Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -868,6 +907,22 @@
engine:
name: "WebKit"
version: "532.9"
+ -
+ ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/604.1.31 (KHTML, like Gecko) Version/11.0 Safari/604.1.31"
+ spec:
+ browser:
+ name: "Safari"
+ version: "11.0"
+ os:
+ name: "macOS"
+ version: "10.13"
+ versionName: "High Sierra"
+ platform:
+ type: "desktop"
+ vendor: "Apple"
+ engine:
+ name: "WebKit"
+ version: "604.1.31"
-
ua: "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_2; en-gb) AppleWebKit/526+ (KHTML, like Gecko) Version/3.1 iPhone"
spec:
@@ -877,6 +932,7 @@
os:
name: "macOS"
version: "10.5.2"
+ versionName: "Leopard"
platform:
type: "mobile"
vendor: "Apple"
@@ -1540,6 +1596,7 @@
os:
name: "macOS"
version: "10.8"
+ versionName: "Mountain Lion"
platform:
type: "desktop"
vendor: "Apple"
@@ -1652,6 +1709,7 @@
os:
name: "macOS"
version: "10.6"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -1717,6 +1775,22 @@
engine:
name: "WebKit"
version: "601.1.46"
+ -
+ ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0"
+ spec:
+ browser:
+ name: "Firefox"
+ version: "68.0"
+ os:
+ name: "macOS"
+ version: "10.14"
+ versionName: "Mojave"
+ platform:
+ type: "desktop"
+ vendor: "Apple"
+ engine:
+ name: "Gecko"
+ version: "20100101"
SeaMonkey:
-
ua: "Mozilla/5.0 (Windows NT 5.2; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 SeaMonkey/2.7.1"
@@ -1742,6 +1816,7 @@
os:
name: "macOS"
version: "10.5"
+ versionName: "Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -2070,6 +2145,21 @@
engine:
name: "WebKit"
version: "533.1"
+ -
+ ua: "Mozilla/5.0 (Linux; U; Android 2.2; en-us; GT-I5800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
+ spec:
+ browser:
+ name: "Android Browser"
+ version: "4.0"
+ os:
+ name: "Android"
+ version: "2.2"
+ versionName: "Froyo"
+ platform:
+ type: "mobile"
+ engine:
+ name: "WebKit"
+ version: "533.1"
-
ua: "Mozilla/5.0 (Linux; U; Android 1.6; ar-us; SonyEricssonX10i Build/R2BA026) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"
spec:
@@ -2252,6 +2342,7 @@
os:
name: "macOS"
version: "10.11.1"
+ versionName: "El Capitan"
platform:
type: "desktop"
vendor: "Apple"
@@ -2290,6 +2381,7 @@
os:
name: "macOS"
version: "10.6.8"
+ versionName: "Snow Leopard"
platform:
type: "desktop"
vendor: "Apple"
@@ -2614,6 +2706,7 @@
os:
name: "macOS"
version: "10.12.6"
+ versionName: "Sierra"
platform:
type: "desktop"
vendor: "Apple"
diff --git a/test/unit/utils.js b/test/unit/utils.js
index ecbf85f3..b41843e9 100644
--- a/test/unit/utils.js
+++ b/test/unit/utils.js
@@ -3,6 +3,8 @@ import {
getBrowserAlias,
getFirstMatch,
getWindowsVersionName,
+ getMacOSVersionName,
+ getAndroidVersionName,
compareVersions,
} from '../../src/utils';
@@ -16,6 +18,20 @@ test('getWindowsVersionName', (t) => {
t.is(getWindowsVersionName('XXX'), void 0);
});
+test('getMacOSVersionName', (t) => {
+ t.is(getMacOSVersionName('10.14.5'), 'Mojave');
+ t.is(getMacOSVersionName('10.15'), 'Catalina');
+ t.is(getMacOSVersionName('10.999999'), void 0);
+ t.is(getMacOSVersionName('XXX'), void 0);
+});
+
+test('getAndroidVersionName', (t) => {
+ t.is(getAndroidVersionName('1.0'), void 0);
+ t.is(getAndroidVersionName('8.0'), 'Oreo');
+ t.is(getAndroidVersionName('9'), 'Pie');
+ t.is(getAndroidVersionName('XXX'), void 0);
+});
+
test('compareVersions', (t) => {
const comparisionsTasks = [
['9.0', '10', -1],
Properties
diff --git a/docs/index.html b/docs/index.html index f9d4778f..42fbb4b3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -27,7 +27,7 @@
Filtering browsers
// or in general chrome: "~20.1.1432", firefox: ">31", - opera: ">=22" + opera: ">=22", // also supports equality operator chrome: "=20.1.1432", // will match particular build only // and loose-equality operator - chrome: "~20" // will match any 20.* sub-version + chrome: "~20", // will match any 20.* sub-version chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1) }); @@ -190,7 +190,7 @@License
diff --git a/docs/parser.js.html b/docs/parser.js.html index d1381415..1f1b2e66 100644 --- a/docs/parser.js.html +++ b/docs/parser.js.html @@ -27,7 +27,7 @@
parser.js
diff --git a/docs/utils.js.html b/docs/utils.js.html index 2e9353fa..c1656199 100644 --- a/docs/utils.js.html +++ b/docs/utils.js.html @@ -27,7 +27,7 @@
utils.js
} } + /** + * Get macOS version name + * 10.5 - Leopard + * 10.6 - Snow Leopard + * 10.7 - Lion + * 10.8 - Mountain Lion + * 10.9 - Mavericks + * 10.10 - Yosemite + * 10.11 - El Capitan + * 10.12 - Sierra + * 10.13 - High Sierra + * 10.14 - Mojave + * 10.15 - Catalina + * + * @example + * getMacOSVersionName("10.14") // 'Mojave' + * + * @param {string} version + * @return {string} versionName + */ + static getMacOSVersionName(version) { + const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0); + v.push(0); + if (v[0] !== 10) return undefined; + switch (v[1]) { + case 5: return 'Leopard'; + case 6: return 'Snow Leopard'; + case 7: return 'Lion'; + case 8: return 'Mountain Lion'; + case 9: return 'Mavericks'; + case 10: return 'Yosemite'; + case 11: return 'El Capitan'; + case 12: return 'Sierra'; + case 13: return 'High Sierra'; + case 14: return 'Mojave'; + case 15: return 'Catalina'; + default: return undefined; + } + } + /** * Get Android version name * 1.5 - Cupcake @@ -113,7 +153,7 @@utils.js
* 6.x - Marshmallow * 7.x - Nougat * 8.x - Oreo - * 9.x - ? + * 9.x - Pie * * @example * getAndroidVersionName("7.0") // 'Nougat' @@ -138,6 +178,7 @@utils.js
if (v[0] === 6) return 'Marshmallow'; if (v[0] === 7) return 'Nougat'; if (v[0] === 8) return 'Oreo'; + if (v[0] === 9) return 'Pie'; return undefined; } @@ -274,7 +315,7 @@utils.js
diff --git a/package-lock.json b/package-lock.json index 1b75b05f..95ee1bb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bowser", - "version": "2.5.2", + "version": "2.5.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2659,14 +2659,6 @@ "dev": true, "requires": { "lodash": "^4.17.14" - }, - "dependencies": { - "lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", - "dev": true - } } }, "chalk": { @@ -6028,12 +6020,6 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0" } - }, - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true } } }, @@ -6668,6 +6654,12 @@ "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", "dev": true }, + "infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", + "dev": true + }, "inflight": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", @@ -6741,12 +6733,6 @@ "escape-string-regexp": "^1.0.5" } }, - "lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", - "dev": true - }, "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", @@ -7610,9 +7596,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, "lodash._baseflatten": { @@ -9871,14 +9857,6 @@ "dev": true, "requires": { "lodash": "^4.17.14" - }, - "dependencies": { - "lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", - "dev": true - } } }, "resolve": { @@ -10895,12 +10873,6 @@ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, - "lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", - "dev": true - }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -10966,28 +10938,110 @@ } }, "terser-webpack-plugin": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.3.0.tgz", - "integrity": "sha512-W2YWmxPjjkUcOWa4pBEv4OP4er1aeQJlSo2UhtCFQCuRXEHjOFscO8VyWHj9JLlA0RzQb8Y2/Ta78XZvT54uGg==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz", + "integrity": "sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==", "dev": true, "requires": { - "cacache": "^11.3.2", - "find-cache-dir": "^2.0.0", + "cacache": "^12.0.2", + "find-cache-dir": "^2.1.0", "is-wsl": "^1.1.0", - "loader-utils": "^1.2.3", "schema-utils": "^1.0.0", "serialize-javascript": "^1.7.0", "source-map": "^0.6.1", - "terser": "^4.0.0", - "webpack-sources": "^1.3.0", + "terser": "^4.1.2", + "webpack-sources": "^1.4.0", "worker-farm": "^1.7.0" }, "dependencies": { + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", + "dev": true + }, + "cacache": { + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.2.tgz", + "integrity": "sha512-ifKgxH2CKhJEg6tNdAwziu6Q33EvuG26tYcda6PT3WKisZcYDXsnEdnRv67Po3yCzFfaSoMjGZzJyD2c3DT1dg==", + "dev": true, + "requires": { + "bluebird": "^3.5.5", + "chownr": "^1.1.1", + "figgy-pudding": "^3.5.1", + "glob": "^7.1.4", + "graceful-fs": "^4.1.15", + "infer-owner": "^1.0.3", + "lru-cache": "^5.1.1", + "mississippi": "^3.0.0", + "mkdirp": "^0.5.1", + "move-concurrently": "^1.0.1", + "promise-inflight": "^1.0.1", + "rimraf": "^2.6.3", + "ssri": "^6.0.1", + "unique-filename": "^1.1.1", + "y18n": "^4.0.0" + } + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", + "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==", + "dev": true + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "requires": { + "yallist": "^3.0.2" + } + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true + }, + "webpack-sources": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.1.tgz", + "integrity": "sha512-XSz38193PTo/1csJabKaV4b53uRVotlMgqJXm3s3eje0Bu6gQTxYDqpD38CmQfDBA+gN+QqaGjasuC8I/7eW3Q==", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "dev": true } } }, @@ -11776,36 +11830,42 @@ } }, "webpack": { - "version": "4.35.3", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.35.3.tgz", - "integrity": "sha512-xggQPwr9ILlXzz61lHzjvgoqGU08v5+Wnut19Uv3GaTtzN4xBTcwnobodrXE142EL1tOiS5WVEButooGzcQzTA==", + "version": "4.39.1", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.39.1.tgz", + "integrity": "sha512-/LAb2TJ2z+eVwisldp3dqTEoNhzp/TLCZlmZm3GGGAlnfIWDgOEE758j/9atklNLfRyhKbZTCOIoPqLJXeBLbQ==", "dev": true, "requires": { "@webassemblyjs/ast": "1.8.5", "@webassemblyjs/helper-module-context": "1.8.5", "@webassemblyjs/wasm-edit": "1.8.5", "@webassemblyjs/wasm-parser": "1.8.5", - "acorn": "^6.2.0", - "ajv": "^6.1.0", - "ajv-keywords": "^3.1.0", - "chrome-trace-event": "^1.0.0", + "acorn": "^6.2.1", + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1", + "chrome-trace-event": "^1.0.2", "enhanced-resolve": "^4.1.0", - "eslint-scope": "^4.0.0", + "eslint-scope": "^4.0.3", "json-parse-better-errors": "^1.0.2", - "loader-runner": "^2.3.0", - "loader-utils": "^1.1.0", - "memory-fs": "~0.4.1", - "micromatch": "^3.1.8", - "mkdirp": "~0.5.0", - "neo-async": "^2.5.0", - "node-libs-browser": "^2.0.0", + "loader-runner": "^2.4.0", + "loader-utils": "^1.2.3", + "memory-fs": "^0.4.1", + "micromatch": "^3.1.10", + "mkdirp": "^0.5.1", + "neo-async": "^2.6.1", + "node-libs-browser": "^2.2.1", "schema-utils": "^1.0.0", - "tapable": "^1.1.0", - "terser-webpack-plugin": "^1.1.0", - "watchpack": "^1.5.0", - "webpack-sources": "^1.3.0" + "tapable": "^1.1.3", + "terser-webpack-plugin": "^1.4.1", + "watchpack": "^1.6.0", + "webpack-sources": "^1.4.1" }, "dependencies": { + "acorn": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz", + "integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==", + "dev": true + }, "eslint-scope": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", @@ -11815,6 +11875,22 @@ "esrecurse": "^4.1.0", "estraverse": "^4.1.1" } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "webpack-sources": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.1.tgz", + "integrity": "sha512-XSz38193PTo/1csJabKaV4b53uRVotlMgqJXm3s3eje0Bu6gQTxYDqpD38CmQfDBA+gN+QqaGjasuC8I/7eW3Q==", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } } } }, diff --git a/package.json b/package.json index cde9fd39..8132de54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bowser", - "version": "2.5.2", + "version": "2.5.3", "description": "Lightweight browser detector", "keywords": [ "browser", @@ -21,6 +21,7 @@ } ], "main": "es5.js", + "types": "index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/lancedikson/bowser.git" @@ -48,7 +49,7 @@ "nyc": "^14.1.1", "sinon": "^7.3.2", "testem": "^2.17.0", - "webpack": "^4.35.3", + "webpack": "^4.39.1", "webpack-bundle-analyzer": "^3.3.2", "webpack-cli": "^3.3.6", "yamljs": "^0.3.0" diff --git a/src/parser-os.js b/src/parser-os.js index 939aa34a..a66a118c 100644 --- a/src/parser-os.js +++ b/src/parser-os.js @@ -46,10 +46,16 @@ export default [ test: [/macintosh/i], describe(ua) { const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.'); - return { + const versionName = Utils.getMacOSVersionName(version); + + const os = { name: OS_MAP.MacOS, version, }; + if (versionName) { + os.versionName = versionName; + } + return os; }, }, diff --git a/src/utils.js b/src/utils.js index 171dfae6..7e36f8fa 100644 --- a/src/utils.js +++ b/src/utils.js @@ -53,6 +53,46 @@ export default class Utils { } } + /** + * Get macOS version name + * 10.5 - Leopard + * 10.6 - Snow Leopard + * 10.7 - Lion + * 10.8 - Mountain Lion + * 10.9 - Mavericks + * 10.10 - Yosemite + * 10.11 - El Capitan + * 10.12 - Sierra + * 10.13 - High Sierra + * 10.14 - Mojave + * 10.15 - Catalina + * + * @example + * getMacOSVersionName("10.14") // 'Mojave' + * + * @param {string} version + * @return {string} versionName + */ + static getMacOSVersionName(version) { + const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0); + v.push(0); + if (v[0] !== 10) return undefined; + switch (v[1]) { + case 5: return 'Leopard'; + case 6: return 'Snow Leopard'; + case 7: return 'Lion'; + case 8: return 'Mountain Lion'; + case 9: return 'Mavericks'; + case 10: return 'Yosemite'; + case 11: return 'El Capitan'; + case 12: return 'Sierra'; + case 13: return 'High Sierra'; + case 14: return 'Mojave'; + case 15: return 'Catalina'; + default: return undefined; + } + } + /** * Get Android version name * 1.5 - Cupcake @@ -69,7 +109,7 @@ export default class Utils { * 6.x - Marshmallow * 7.x - Nougat * 8.x - Oreo - * 9.x - ? + * 9.x - Pie * * @example * getAndroidVersionName("7.0") // 'Nougat' @@ -94,6 +134,7 @@ export default class Utils { if (v[0] === 6) return 'Marshmallow'; if (v[0] === 7) return 'Nougat'; if (v[0] === 8) return 'Oreo'; + if (v[0] === 9) return 'Pie'; return undefined; } diff --git a/test/acceptance/useragentstrings.yml b/test/acceptance/useragentstrings.yml index 713d5771..403275a2 100644 --- a/test/acceptance/useragentstrings.yml +++ b/test/acceptance/useragentstrings.yml @@ -207,6 +207,21 @@ type: "desktop" engine: name: "Blink" + - + ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36" + spec: + browser: + name: "Chrome" + version: "49.0.2623.112" + os: + name: "macOS" + version: "10.7.5" + versionName: "Lion" + platform: + type: "desktop" + vendor: "Apple" + engine: + name: "Blink" - ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24" spec: @@ -216,6 +231,7 @@ os: name: "macOS" version: "10.6.7" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" @@ -378,6 +394,7 @@ os: name: "macOS" version: "10.6.3" + versionName: "Snow Leopard" platform: type: "tablet" vendor: "Amazon" @@ -539,6 +556,7 @@ os: name: "macOS" version: "10.6.7" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" @@ -665,6 +683,7 @@ os: name: "macOS" version: "10.10.3" + versionName: "Yosemite" platform: type: "desktop" vendor: "Apple" @@ -711,6 +730,7 @@ os: name: "macOS" version: "10.6.8" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" @@ -726,6 +746,7 @@ os: name: "macOS" version: "10.6.7" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" @@ -784,12 +805,29 @@ os: name: "macOS" version: "10.6.1" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" engine: name: "WebKit" version: "531.21.10" + - + ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A" + spec: + browser: + name: "Safari" + version: "7.0.3" + os: + name: "macOS" + version: "10.9.3" + versionName: "Mavericks" + platform: + type: "desktop" + vendor: "Apple" + engine: + name: "WebKit" + version: "537.75.14" - ua: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; de-de) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.28.3" spec: @@ -799,6 +837,7 @@ os: name: "macOS" version: "10.5.7" + versionName: "Leopard" platform: type: "desktop" vendor: "Apple" @@ -868,6 +907,22 @@ engine: name: "WebKit" version: "532.9" + - + ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/604.1.31 (KHTML, like Gecko) Version/11.0 Safari/604.1.31" + spec: + browser: + name: "Safari" + version: "11.0" + os: + name: "macOS" + version: "10.13" + versionName: "High Sierra" + platform: + type: "desktop" + vendor: "Apple" + engine: + name: "WebKit" + version: "604.1.31" - ua: "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_2; en-gb) AppleWebKit/526+ (KHTML, like Gecko) Version/3.1 iPhone" spec: @@ -877,6 +932,7 @@ os: name: "macOS" version: "10.5.2" + versionName: "Leopard" platform: type: "mobile" vendor: "Apple" @@ -1540,6 +1596,7 @@ os: name: "macOS" version: "10.8" + versionName: "Mountain Lion" platform: type: "desktop" vendor: "Apple" @@ -1652,6 +1709,7 @@ os: name: "macOS" version: "10.6" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" @@ -1717,6 +1775,22 @@ engine: name: "WebKit" version: "601.1.46" + - + ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0" + spec: + browser: + name: "Firefox" + version: "68.0" + os: + name: "macOS" + version: "10.14" + versionName: "Mojave" + platform: + type: "desktop" + vendor: "Apple" + engine: + name: "Gecko" + version: "20100101" SeaMonkey: - ua: "Mozilla/5.0 (Windows NT 5.2; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 SeaMonkey/2.7.1" @@ -1742,6 +1816,7 @@ os: name: "macOS" version: "10.5" + versionName: "Leopard" platform: type: "desktop" vendor: "Apple" @@ -2070,6 +2145,21 @@ engine: name: "WebKit" version: "533.1" + - + ua: "Mozilla/5.0 (Linux; U; Android 2.2; en-us; GT-I5800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" + spec: + browser: + name: "Android Browser" + version: "4.0" + os: + name: "Android" + version: "2.2" + versionName: "Froyo" + platform: + type: "mobile" + engine: + name: "WebKit" + version: "533.1" - ua: "Mozilla/5.0 (Linux; U; Android 1.6; ar-us; SonyEricssonX10i Build/R2BA026) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1" spec: @@ -2252,6 +2342,7 @@ os: name: "macOS" version: "10.11.1" + versionName: "El Capitan" platform: type: "desktop" vendor: "Apple" @@ -2290,6 +2381,7 @@ os: name: "macOS" version: "10.6.8" + versionName: "Snow Leopard" platform: type: "desktop" vendor: "Apple" @@ -2614,6 +2706,7 @@ os: name: "macOS" version: "10.12.6" + versionName: "Sierra" platform: type: "desktop" vendor: "Apple" diff --git a/test/unit/utils.js b/test/unit/utils.js index ecbf85f3..b41843e9 100644 --- a/test/unit/utils.js +++ b/test/unit/utils.js @@ -3,6 +3,8 @@ import { getBrowserAlias, getFirstMatch, getWindowsVersionName, + getMacOSVersionName, + getAndroidVersionName, compareVersions, } from '../../src/utils'; @@ -16,6 +18,20 @@ test('getWindowsVersionName', (t) => { t.is(getWindowsVersionName('XXX'), void 0); }); +test('getMacOSVersionName', (t) => { + t.is(getMacOSVersionName('10.14.5'), 'Mojave'); + t.is(getMacOSVersionName('10.15'), 'Catalina'); + t.is(getMacOSVersionName('10.999999'), void 0); + t.is(getMacOSVersionName('XXX'), void 0); +}); + +test('getAndroidVersionName', (t) => { + t.is(getAndroidVersionName('1.0'), void 0); + t.is(getAndroidVersionName('8.0'), 'Oreo'); + t.is(getAndroidVersionName('9'), 'Pie'); + t.is(getAndroidVersionName('XXX'), void 0); +}); + test('compareVersions', (t) => { const comparisionsTasks = [ ['9.0', '10', -1],