@shopify/browser
Advanced tools
Comparing version 1.1.4 to 2.0.0
@@ -1,124 +0,93 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.asPlainObject = asPlainObject; | ||
exports.Browser = void 0; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _uaParserJs = require("ua-parser-js"); | ||
var uaParserJs = require('ua-parser-js'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
const MOBILE_DEVICE_TYPES = ['mobile', 'tablet']; | ||
class Browser { | ||
get name() { | ||
return this.ua.getBrowser().name || ''; | ||
} | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
get version() { | ||
return this.ua.getBrowser().version || ''; | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
get majorVersion() { | ||
const { | ||
version | ||
} = this; | ||
var MOBILE_DEVICE_TYPES = ['mobile', 'tablet']; | ||
var Browser = /*#__PURE__*/function () { | ||
_createClass(Browser, [{ | ||
key: "name", | ||
get: function get() { | ||
return this.ua.getBrowser().name || ''; | ||
if (version === '') { | ||
return undefined; | ||
} | ||
}, { | ||
key: "version", | ||
get: function get() { | ||
return this.ua.getBrowser().version || ''; | ||
} | ||
}, { | ||
key: "majorVersion", | ||
get: function get() { | ||
var version = this.version; | ||
if (version === '') { | ||
return undefined; | ||
} | ||
const majorVersion = parseInt(version.split('.')[0], 10); | ||
return Number.isNaN(majorVersion) ? undefined : majorVersion; | ||
} | ||
var majorVersion = parseInt(version.split('.')[0], 10); | ||
return Number.isNaN(majorVersion) ? undefined : majorVersion; | ||
} | ||
}, { | ||
key: "unknown", | ||
get: function get() { | ||
return this.name === ''; | ||
} | ||
}, { | ||
key: "isMobile", | ||
get: function get() { | ||
return MOBILE_DEVICE_TYPES.includes(this.ua.getDevice().type); | ||
} | ||
}, { | ||
key: "isDesktop", | ||
get: function get() { | ||
return !this.isMobile; | ||
} | ||
}, { | ||
key: "isNativeApp", | ||
get: function get() { | ||
return this.ua.getUA().includes('Shopify Mobile/', 0); | ||
} | ||
}, { | ||
key: "os", | ||
get: function get() { | ||
return this.ua.getOS().name || ''; | ||
} | ||
}, { | ||
key: "isWindows", | ||
get: function get() { | ||
return this.os.includes('Windows'); | ||
} | ||
}, { | ||
key: "isMac", | ||
get: function get() { | ||
return this.os.includes('Mac OS'); | ||
} | ||
}, { | ||
key: "isSafari", | ||
get: function get() { | ||
return this.name.includes('Safari'); | ||
} | ||
}, { | ||
key: "isChrome", | ||
get: function get() { | ||
return this.name.includes('Chrome'); | ||
} | ||
}, { | ||
key: "isAndroidChrome", | ||
get: function get() { | ||
return this.ua.getUA().includes('Android') && this.name.includes('Chrome'); | ||
} | ||
}, { | ||
key: "isFirefox", | ||
get: function get() { | ||
return this.name === 'Firefox'; | ||
} | ||
}, { | ||
key: "isIE", | ||
get: function get() { | ||
return this.name.includes('IE'); | ||
} | ||
}, { | ||
key: "isEdge", | ||
get: function get() { | ||
return this.name === 'Edge'; | ||
} | ||
}, { | ||
key: "isIOS", | ||
get: function get() { | ||
var os = this.ua.getOS(); | ||
var isStandardiOS = os.name && os.name.includes('iOS'); | ||
var isShopifyiOS = /Shopify Mobile|Shopify POS|Shopify Ping/.test(this.userAgent) && this.userAgent.includes('iOS'); | ||
return isStandardiOS || isShopifyiOS; | ||
} | ||
}]); | ||
get unknown() { | ||
return this.name === ''; | ||
} | ||
function Browser(_ref) { | ||
var userAgent = _ref.userAgent, | ||
_ref$supported = _ref.supported, | ||
supported = _ref$supported === void 0 ? true : _ref$supported; | ||
get isMobile() { | ||
return MOBILE_DEVICE_TYPES.includes(this.ua.getDevice().type); | ||
} | ||
_classCallCheck(this, Browser); | ||
get isDesktop() { | ||
return !this.isMobile; | ||
} | ||
get isNativeApp() { | ||
return this.ua.getUA().includes('Shopify Mobile/', 0); | ||
} | ||
get os() { | ||
return this.ua.getOS().name || ''; | ||
} | ||
get isWindows() { | ||
return this.os.includes('Windows'); | ||
} | ||
get isMac() { | ||
return this.os.includes('Mac OS'); | ||
} | ||
get isSafari() { | ||
return this.name.includes('Safari'); | ||
} | ||
get isChrome() { | ||
return this.name.includes('Chrome'); | ||
} | ||
get isAndroidChrome() { | ||
return this.ua.getUA().includes('Android') && this.name.includes('Chrome'); | ||
} | ||
get isFirefox() { | ||
return this.name === 'Firefox'; | ||
} | ||
get isIE() { | ||
return this.name.includes('IE'); | ||
} | ||
get isEdge() { | ||
return this.name === 'Edge'; | ||
} | ||
get isIOS() { | ||
const os = this.ua.getOS(); | ||
const isStandardiOS = os.name && os.name.includes('iOS'); | ||
const isShopifyiOS = /Shopify Mobile|Shopify POS|Shopify Ping/.test(this.userAgent) && this.userAgent.includes('iOS'); | ||
return isStandardiOS || isShopifyiOS; | ||
} | ||
constructor({ | ||
userAgent, | ||
supported = true | ||
}) { | ||
this.userAgent = void 0; | ||
@@ -129,10 +98,6 @@ this.supported = void 0; | ||
this.supported = supported; | ||
this.ua = new _uaParserJs.UAParser(userAgent); | ||
this.ua = new uaParserJs.UAParser(userAgent); | ||
} | ||
return Browser; | ||
}(); | ||
exports.Browser = Browser; | ||
} | ||
function asPlainObject(browser) { | ||
@@ -150,2 +115,5 @@ if (browser == null) { | ||
}; | ||
} | ||
} | ||
exports.Browser = Browser; | ||
exports.asPlainObject = asPlainObject; |
@@ -1,19 +0,10 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "Browser", { | ||
enumerable: true, | ||
get: function get() { | ||
return _browser.Browser; | ||
} | ||
}); | ||
Object.defineProperty(exports, "asPlainObject", { | ||
enumerable: true, | ||
get: function get() { | ||
return _browser.asPlainObject; | ||
} | ||
}); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _browser = require("./browser.js"); | ||
var browser = require('./browser.js'); | ||
exports.Browser = browser.Browser; | ||
exports.asPlainObject = browser.asPlainObject; |
@@ -10,2 +10,8 @@ # Changelog | ||
## 2.0.0 - 2021-05-21 | ||
### Breaking Change | ||
- Update minimum supported node version to 12.14.0. Add engines field to help enforce usage of this version. [#1906](https://github.com/Shopify/quilt/pull/1906) | ||
## 1.1.4 - 2021-04-13 | ||
@@ -12,0 +18,0 @@ |
{ | ||
"name": "@shopify/browser", | ||
"version": "1.1.4", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -23,2 +23,5 @@ "description": "Utilities for extracting browser information from user-agents", | ||
"homepage": "https://github.com/Shopify/quilt/blob/main/packages/browser/README.md", | ||
"engines": { | ||
"node": ">=12.14.0" | ||
}, | ||
"files": [ | ||
@@ -44,3 +47,4 @@ "build/*", | ||
} | ||
} | ||
}, | ||
"gitHead": "40de4af181104f298cbab42d2d3d68e228a9a31a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24373
23
316