2019-02-14 16:06:14 +00:00
|
|
|
import Utils from './utils.js';
|
2019-05-20 07:33:10 +00:00
|
|
|
import { OS_MAP } from './constants.js';
|
2017-05-18 20:14:31 +00:00
|
|
|
|
2017-04-15 19:46:18 +00:00
|
|
|
export default [
|
2019-07-07 09:55:53 +00:00
|
|
|
/* Roku */
|
|
|
|
{
|
|
|
|
test: [/Roku\/DVP/],
|
|
|
|
describe(ua) {
|
|
|
|
const version = Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i, ua);
|
|
|
|
return {
|
|
|
|
name: OS_MAP.Roku,
|
|
|
|
version,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2017-05-18 20:56:26 +00:00
|
|
|
/* Windows Phone */
|
2017-04-15 19:46:18 +00:00
|
|
|
{
|
|
|
|
test: [/windows phone/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
|
2017-04-15 19:46:18 +00:00
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.WindowsPhone,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
|
|
|
};
|
|
|
|
},
|
2017-04-15 19:46:18 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
|
|
|
|
/* Windows */
|
2017-05-18 20:14:31 +00:00
|
|
|
{
|
2019-12-17 08:24:04 +00:00
|
|
|
test: [/windows /i],
|
2017-05-18 20:14:31 +00:00
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i, ua);
|
|
|
|
const versionName = Utils.getWindowsVersionName(version);
|
2017-05-18 20:14:31 +00:00
|
|
|
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.Windows,
|
2017-05-18 20:14:31 +00:00
|
|
|
version,
|
2017-12-20 21:29:06 +00:00
|
|
|
versionName,
|
2017-05-18 20:14:31 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:14:31 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
|
2019-12-13 22:36:53 +00:00
|
|
|
/* Firefox on iPad */
|
|
|
|
{
|
|
|
|
test: [/Macintosh(.*?) FxiOS(.*?) Version\//],
|
|
|
|
describe(ua) {
|
|
|
|
const version = Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/, ua);
|
|
|
|
return {
|
|
|
|
name: OS_MAP.iOS,
|
|
|
|
version,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2017-05-18 20:56:26 +00:00
|
|
|
/* macOS */
|
2017-04-15 19:46:18 +00:00
|
|
|
{
|
|
|
|
test: [/macintosh/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.');
|
2019-07-17 11:14:23 +00:00
|
|
|
const versionName = Utils.getMacOSVersionName(version);
|
|
|
|
|
|
|
|
const os = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.MacOS,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2019-07-17 11:14:23 +00:00
|
|
|
if (versionName) {
|
|
|
|
os.versionName = versionName;
|
|
|
|
}
|
|
|
|
return os;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* iOS */
|
|
|
|
{
|
|
|
|
test: [/(ipod|iphone|ipad)/i],
|
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, '.');
|
2017-05-18 20:56:26 +00:00
|
|
|
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.iOS,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Android */
|
|
|
|
{
|
|
|
|
test(parser) {
|
2017-06-08 20:32:11 +00:00
|
|
|
const notLikeAndroid = !parser.test(/like android/i);
|
2017-05-18 20:56:26 +00:00
|
|
|
const butAndroid = parser.test(/android/i);
|
|
|
|
return notLikeAndroid && butAndroid;
|
|
|
|
},
|
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
|
|
|
|
const versionName = Utils.getAndroidVersionName(version);
|
2018-12-30 07:03:08 +00:00
|
|
|
const os = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.Android,
|
2018-12-30 08:18:58 +00:00
|
|
|
version,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2018-12-30 07:03:08 +00:00
|
|
|
if (versionName) {
|
2018-12-30 08:10:33 +00:00
|
|
|
os.versionName = versionName;
|
2018-12-30 07:03:08 +00:00
|
|
|
}
|
|
|
|
return os;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* WebOS */
|
|
|
|
{
|
2018-07-09 18:26:43 +00:00
|
|
|
test: [/(web|hpw)[o0]s/i],
|
2017-05-18 20:56:26 +00:00
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
|
2018-07-09 18:26:43 +00:00
|
|
|
const os = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.WebOS,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2018-07-09 18:26:43 +00:00
|
|
|
|
|
|
|
if (version && version.length) {
|
|
|
|
os.version = version;
|
|
|
|
}
|
|
|
|
return os;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* BlackBerry */
|
|
|
|
{
|
|
|
|
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i, ua)
|
|
|
|
|| Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i, ua)
|
|
|
|
|| Utils.getFirstMatch(/\bbb(\d+)/i, ua);
|
2017-05-18 20:56:26 +00:00
|
|
|
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.BlackBerry,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Bada */
|
|
|
|
{
|
|
|
|
test: [/bada/i],
|
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
|
2017-05-18 20:56:26 +00:00
|
|
|
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.Bada,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-05-18 20:56:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Tizen */
|
|
|
|
{
|
|
|
|
test: [/tizen/i],
|
|
|
|
describe(ua) {
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
|
2017-05-18 20:56:26 +00:00
|
|
|
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.Tizen,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
2017-05-18 20:56:26 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-06-08 20:35:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Linux */
|
|
|
|
{
|
|
|
|
test: [/linux/i],
|
|
|
|
describe() {
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.Linux,
|
2017-12-20 21:29:06 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
2019-01-24 13:37:59 +00:00
|
|
|
|
|
|
|
/* Chrome OS */
|
|
|
|
{
|
|
|
|
test: [/CrOS/],
|
|
|
|
describe() {
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.ChromeOS,
|
2019-01-24 13:37:59 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
2019-02-06 08:47:28 +00:00
|
|
|
|
|
|
|
/* Playstation 4 */
|
|
|
|
{
|
|
|
|
test: [/PlayStation 4/],
|
|
|
|
describe(ua) {
|
2019-03-06 12:27:35 +00:00
|
|
|
const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
|
2019-02-06 08:47:28 +00:00
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: OS_MAP.PlayStation4,
|
2019-02-06 08:47:28 +00:00
|
|
|
version,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
2017-12-20 21:29:06 +00:00
|
|
|
];
|