Skip to content

Commit

Permalink
Merge pull request #22 from duskload/updates
Browse files Browse the repository at this point in the history
Types and constants updates
  • Loading branch information
duskload authored Sep 13, 2019
2 parents 80b914c + fed2c1f commit 072a5e0
Show file tree
Hide file tree
Showing 6 changed files with 868 additions and 577 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ For react example, you can look into separated package [react-device-detect](htt
| engineName | string | returns browser engine `name` (e.g `Gecko` for FF or `WebKit` for Chrome) |
| engineVersion | string | returns engine version |
| getUA | string | returns user agent |
| deviceType | string | returns device type (e.g `mobile` or `tablet`) |
| deviceDetect | function | return data object which includes all data about device (e.g version, engine, os etc.) |

## License
Expand Down
49 changes: 18 additions & 31 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ module.exports =
"use strict";


Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var UAParser = __webpack_require__(1);
Expand All @@ -88,7 +84,6 @@ var _require = __webpack_require__(3),
var UA = new UAParser();

var browser = UA.getBrowser();
var cpu = UA.getCPU();
var device = UA.getDevice();
var engine = UA.getEngine();
var os = UA.getOS();
Expand All @@ -113,7 +108,9 @@ var MOBILE = DEVICE_TYPES.MOBILE,
var ANDROID = OS_TYPES.ANDROID,
WINDOWS_PHONE = OS_TYPES.WINDOWS_PHONE,
IOS = OS_TYPES.IOS;
var checkType = exports.checkType = function checkType(type) {


var checkType = function checkType(type) {
switch (type) {
case MOBILE:
return { isMobile: true };
Expand All @@ -132,23 +129,7 @@ var checkType = exports.checkType = function checkType(type) {
}
};

var getCurrentBrowser = exports.getCurrentBrowser = function getCurrentBrowser(name) {
switch (name) {
case CHROME:
case FIREFOX:
case OPERA:
case YANDEX:
case SAFARI:
case IE:
case EDGE:
case CHROMIUM:
return true;
default:
return false;
}
};

var broPayload = exports.broPayload = function broPayload(isBrowser, browser, engine, os, ua) {
var broPayload = function broPayload(isBrowser, browser, engine, os, ua) {
return {
isBrowser: isBrowser,
browserMajorVersion: browser.major,
Expand All @@ -162,7 +143,7 @@ var broPayload = exports.broPayload = function broPayload(isBrowser, browser, en
};
};

var mobilePayload = exports.mobilePayload = function mobilePayload(type, device, os, ua) {
var mobilePayload = function mobilePayload(type, device, os, ua) {
return _extends({}, type, {
vendor: device.vendor,
model: device.model,
Expand All @@ -172,7 +153,7 @@ var mobilePayload = exports.mobilePayload = function mobilePayload(type, device,
});
};

var stvPayload = exports.stvPayload = function stvPayload(isSmartTV, engine, os, ua) {
var stvPayload = function stvPayload(isSmartTV, engine, os, ua) {
return {
isSmartTV: isSmartTV,
engineName: engine.name,
Expand All @@ -183,7 +164,7 @@ var stvPayload = exports.stvPayload = function stvPayload(isSmartTV, engine, os,
};
};

var consolePayload = exports.consolePayload = function consolePayload(isConsole, engine, os, ua) {
var consolePayload = function consolePayload(isConsole, engine, os, ua) {
return {
isConsole: isConsole,
engineName: engine.name,
Expand All @@ -194,7 +175,7 @@ var consolePayload = exports.consolePayload = function consolePayload(isConsole,
};
};

var wearPayload = exports.wearPayload = function wearPayload(isWearable, engine, os, ua) {
var wearPayload = function wearPayload(isWearable, engine, os, ua) {
return {
isWearable: isWearable,
engineName: engine.name,
Expand Down Expand Up @@ -302,6 +283,9 @@ var getEngineVersion = function getEngineVersion() {
var getUseragent = function getUseragent() {
return ua;
};
var getDeviceType = function getDeviceType() {
return device.type;
};

var isSmartTV = isSmartTVType();
var isConsole = isConsoleType();
Expand Down Expand Up @@ -332,10 +316,11 @@ var engineVersion = getEngineVersion();
var getUA = getUseragent();
var isEdge = isEdgeType();
var isYandex = isYandexType();
var deviceType = getDeviceType();

var type = checkType(device.type);

exports.default = function () {
function deviceDetect() {
var isBrowser = type.isBrowser,
isMobile = type.isMobile,
isTablet = type.isTablet,
Expand Down Expand Up @@ -369,6 +354,7 @@ exports.default = function () {
};

module.exports = {
deviceDetect: deviceDetect,
isSmartTV: isSmartTV,
isConsole: isConsole,
isWearable: isWearable,
Expand Down Expand Up @@ -397,7 +383,8 @@ module.exports = {
engineVersion: engineVersion,
getUA: getUA,
isEdge: isEdge,
isYandex: isYandex
isYandex: isYandex,
deviceType: deviceType
};

/***/ }),
Expand All @@ -419,8 +406,8 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*!
/* 2 */
/***/ (function(module, exports) {

/* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */
module.exports = __webpack_amd_options__;
/* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */
module.exports = __webpack_amd_options__;

/* WEBPACK VAR INJECTION */}.call(exports, {}))

Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ declare module "mobile-device-detect" {
export const engineName: string;
export const engineVersion: string;
export const getUA: string;
export const deviceType: string;
export function deviceDetect (): any;
}
Loading

0 comments on commit 072a5e0

Please sign in to comment.