BREAKING CHANGE - Add new property to browser: type

This commit is contained in:
Faisal Salman
2024-06-02 23:04:25 +07:00
parent 1a22c6951f
commit 39590f112d
8 changed files with 25 additions and 14 deletions

View File

@@ -144,6 +144,14 @@ const Browser = Object.freeze({
// TODO : test!
});
const BrowserType = Object.freeze({
BOT: 'bot',
CLI: 'cli',
EMAIL: 'email',
INAPP: 'inapp',
MODULE: 'module'
});
const CPU = Object.freeze({
ARM : 'arm',
ARM_64: 'arm64',
@@ -341,7 +349,8 @@ const OS = Object.freeze({
});
module.exports = {
Browser,
Browser,
BrowserType,
CPU,
Device,
Vendor,

View File

@@ -15,12 +15,6 @@ const VERSION = 'version';
const MOBILE = 'mobile';
const TABLET = 'tablet';
const Apps = Object.freeze({
browser : [
[/chatlyio\/([\d\.]+)/i], [VERSION, 'Slack', [TYPE, 'app']]
]
});
const Bots = Object.freeze({
browser : [
// Googlebot / BingBot / MSNBot / FacebookBot
@@ -124,6 +118,12 @@ const Emails = Object.freeze({
]
});
const InApps = Object.freeze({
browser : [
[/chatlyio\/([\d\.]+)/i], [VERSION, 'Slack', [TYPE, 'inapp']]
]
});
const MediaPlayers = Object.freeze({
browser : [[
@@ -238,11 +238,11 @@ const Modules = Object.freeze({
});
module.exports = {
Apps,
Bots,
CLIs,
ExtraDevices,
Emails,
InApps,
MediaPlayers,
Modules
};

View File

@@ -62,6 +62,7 @@ declare namespace UAParser {
NAME: 'name';
VERSION: 'version';
MAJOR: 'major';
TYPE: 'type';
};
static readonly CPU: {
ARCHITECTURE: 'architecture';

View File

@@ -847,7 +847,7 @@
var defaultProps = (function () {
var props = { init : {}, isIgnore : {}, isIgnoreRgx : {}, toString : {}};
setProps.call(props.init, [
[UA_BROWSER, [NAME, VERSION, MAJOR]],
[UA_BROWSER, [NAME, VERSION, MAJOR, TYPE]],
[UA_CPU, [ARCHITECTURE]],
[UA_DEVICE, [TYPE, MODEL, VENDOR]],
[UA_ENGINE, [NAME, VERSION]],
@@ -1225,7 +1225,7 @@
}
UAParser.VERSION = LIBVERSION;
UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR]);
UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR, TYPE]);
UAParser.CPU = enumerize([ARCHITECTURE]);
UAParser.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);