2019-02-14 16:06:14 +00:00
|
|
|
import Utils from './utils.js';
|
2019-05-20 07:33:10 +00:00
|
|
|
import { ENGINE_MAP } from './constants.js';
|
2017-06-09 20:04:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* More specific goes first
|
|
|
|
*/
|
|
|
|
export default [
|
|
|
|
/* EdgeHTML */
|
|
|
|
{
|
|
|
|
test(parser) {
|
|
|
|
return parser.getBrowserName(true) === 'microsoft edge';
|
|
|
|
},
|
|
|
|
describe(ua) {
|
2019-04-14 10:39:35 +00:00
|
|
|
const isBlinkBased = /\sedg\//i.test(ua);
|
|
|
|
|
|
|
|
// return blink if it's blink-based one
|
|
|
|
if (isBlinkBased) {
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.Blink,
|
2019-04-14 10:39:35 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise match the version and return EdgeHTML
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
|
2019-04-14 10:39:35 +00:00
|
|
|
|
2017-06-09 20:04:43 +00:00
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.EdgeHTML,
|
2017-12-20 21:29:06 +00:00
|
|
|
version,
|
2017-06-09 20:04:43 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-06-09 20:04:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Trident */
|
|
|
|
{
|
|
|
|
test: [/trident/i],
|
|
|
|
describe(ua) {
|
|
|
|
const engine = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.Trident,
|
2017-06-09 20:04:43 +00:00
|
|
|
};
|
|
|
|
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-06-09 20:04:43 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
engine.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return engine;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-06-09 20:04:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Presto */
|
|
|
|
{
|
|
|
|
test(parser) {
|
|
|
|
return parser.test(/presto/i);
|
|
|
|
},
|
|
|
|
describe(ua) {
|
|
|
|
const engine = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.Presto,
|
2017-06-09 20:04:43 +00:00
|
|
|
};
|
|
|
|
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-06-09 20:04:43 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
engine.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return engine;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-06-09 20:04:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Gecko */
|
|
|
|
{
|
|
|
|
test(parser) {
|
|
|
|
const isGecko = parser.test(/gecko/i);
|
|
|
|
const likeGecko = parser.test(/like gecko/i);
|
|
|
|
return isGecko && !likeGecko;
|
|
|
|
},
|
|
|
|
describe(ua) {
|
|
|
|
const engine = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.Gecko,
|
2017-06-09 20:04:43 +00:00
|
|
|
};
|
|
|
|
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-06-09 20:04:43 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
engine.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return engine;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-06-09 20:04:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Blink */
|
|
|
|
{
|
|
|
|
test: [/(apple)?webkit\/537\.36/i],
|
|
|
|
describe() {
|
|
|
|
return {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.Blink,
|
2017-06-09 20:04:43 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-06-09 20:04:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* WebKit */
|
|
|
|
{
|
|
|
|
test: [/(apple)?webkit/i],
|
|
|
|
describe(ua) {
|
|
|
|
const engine = {
|
2019-05-20 07:33:10 +00:00
|
|
|
name: ENGINE_MAP.WebKit,
|
2017-06-09 20:04:43 +00:00
|
|
|
};
|
|
|
|
|
2019-02-14 16:06:14 +00:00
|
|
|
const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-06-09 20:04:43 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
engine.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return engine;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
|
|
|
},
|
2017-06-09 20:04:43 +00:00
|
|
|
];
|