@enact/core
Advanced tools
Comparing version 4.8.0 to 4.9.0-alpha.1
@@ -5,2 +5,16 @@ # Change Log | ||
## [4.9.0-alpha.1] - 2024-04-09 | ||
### Deprecated | ||
- `core/platform` member `windowsPhone`, `edge`, `androidChrome`, `android`, `ie`, `ios`, `webos`, `androidFirefox`, `firefoxOS`, `blackberry`, and `tizen`, to be removed in 5.0.0 | ||
- `core/platform` member `gesture`, `node`, `platformName`, and `unknown`, to be removed in 5.0.0 | ||
- `core/platform` member `touch` and `touchscreen`, to be removed in 5.0.0 | ||
### Added | ||
- `core/platform` member `type` to detect a platform like 'desktop', 'mobile', 'webos', and 'node' | ||
- `core/platform` member `browserName` and `browserVersion` to detect the compatible major browser name and version | ||
- `core/platform` member `touchEvent` and `touchScreen` replacing legacy `touch` and `touchscreen` respectively | ||
## [4.8.0] - 2024-02-08 | ||
@@ -7,0 +21,0 @@ |
@@ -17,3 +17,3 @@ "use strict"; | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -20,0 +20,0 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } |
@@ -25,3 +25,3 @@ "use strict"; | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /** | ||
@@ -28,0 +28,0 @@ * Provides the `ApiDecorator` higher-order component |
@@ -18,3 +18,3 @@ "use strict"; | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -21,0 +21,0 @@ describe('ApiDecorator', function () { |
@@ -19,3 +19,3 @@ "use strict"; | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -22,0 +22,0 @@ describe('prop-types', function () { |
@@ -25,3 +25,3 @@ "use strict"; | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -28,0 +28,0 @@ var SomeContext = /*#__PURE__*/(0, _react.createContext)(); |
@@ -21,3 +21,3 @@ "use strict"; | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -24,0 +24,0 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } |
{ | ||
"name": "@enact/core", | ||
"version": "4.8.0", | ||
"version": "4.9.0-alpha.1", | ||
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -8,22 +8,46 @@ // Type definitions for core/platform | ||
/** | ||
* Additional information about the detected platform | ||
* The name of the detected browser | ||
*/ | ||
browserName: string /** | ||
* The version of the detected browser | ||
*/; | ||
browserVersion: number /** | ||
* The version of the detected browser, if chrome browser is detected | ||
*/; | ||
chrome: number /** | ||
* Additional information about the detected platform. Deprecated: will be removed in 5.0.0. | ||
*/; | ||
extra?: object /** | ||
* `true` if the platform has native double-finger events | ||
* The version of the detected browser, if firefox browser is detected | ||
*/; | ||
firefox: number /** | ||
* `true` if the platform has native double-finger events. Deprecated: will be removed in 5.0.0. | ||
*/; | ||
gesture: boolean /** | ||
* `true` only if `window` is `undefined` | ||
* `true` only if `window` is `undefined` . Deprecated: will be removed in 5.0.0. Use `type` instead. | ||
*/; | ||
node: boolean /** | ||
* The name of the platform, if detected | ||
* The name of the platform, if detected. Deprecated: will be removed in 5.0.0. Use `browserName` instead for browser names. | ||
*/; | ||
platformName?: string /** | ||
* `true` if the platform has native single-finger events | ||
* The version of the detected browser, if safari browser is detected | ||
*/; | ||
safari: number /** | ||
* `true` if the platform has native single-finger events. Deprecated: will be removed in 5.0.0. Use `touchEvent` instead. | ||
*/; | ||
touch: boolean /** | ||
* `true` if the platform has a touch screen | ||
* `true` if the browser has native touch events | ||
*/; | ||
touchEvent: boolean /** | ||
* `true` if the platform has a touch screen. Deprecated: will be removed in 5.0.0. Use `touchScreen` instead. | ||
*/; | ||
touchscreen: boolean /** | ||
* `true` for any unknown system | ||
* `true` if the platform has a touch screen | ||
*/; | ||
touchScreen: boolean /** | ||
* The type of the detected platform. One of 'desktop', 'mobile', 'webos', 'node', or 'unknown' | ||
*/; | ||
type: string /** | ||
* `true` for any unknown system. Deprecated: will be removed in 5.0.0. Use `type` instead. | ||
*/; | ||
unknown: boolean; | ||
@@ -30,0 +54,0 @@ } |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.platform = exports.parseUserAgent = exports.detect = exports["default"] = void 0; | ||
var _uniq = _interopRequireDefault(require("ramda/src/uniq")); | ||
var _deprecate = _interopRequireDefault(require("../internal/deprecate")); | ||
@@ -21,3 +20,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } | ||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** | ||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* global globalThis */ /** | ||
* Utilities for detecting basic platform capabilities. | ||
@@ -30,18 +29,39 @@ * | ||
*/ | ||
// Refer the following for more details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis | ||
var browserEnvironment = function browserEnvironment() { | ||
return !!globalThis.window; | ||
}; | ||
// Note: Always true for Chrome v70 or higher: https://chromestatus.com/feature/4764225348042752 | ||
var featureTouchEvent = function featureTouchEvent() { | ||
return browserEnvironment() && 'TouchEvent' in globalThis; | ||
}; | ||
// Refer https://patrickhlauke.github.io/touch/touchscreen-detection/ | ||
var deviceTouchScreen = function deviceTouchScreen() { | ||
var _globalThis$navigator, _globalThis$matchMedi; | ||
return browserEnvironment() && ( | ||
// check if maxTouchPoints is greater than 0 first | ||
((_globalThis$navigator = globalThis.navigator) === null || _globalThis$navigator === void 0 ? void 0 : _globalThis$navigator.maxTouchPoints) > 0 || ( // check for any-pointer: coarse which mostly means touchscreen | ||
(_globalThis$matchMedi = globalThis.matchMedia) === null || _globalThis$matchMedi === void 0 || (_globalThis$matchMedi = _globalThis$matchMedi.call(globalThis, "(any-pointer: coarse)")) === null || _globalThis$matchMedi === void 0 ? void 0 : _globalThis$matchMedi.matches)); | ||
}; | ||
/* | ||
* Legacy Code to be removed in the next major release | ||
*/ | ||
var hasGesture = function hasGesture() { | ||
return Boolean('ongesturestart' in window || 'onmsgesturestart' in window && (window.navigator.msMaxTouchPoints > 1 || window.navigator.maxTouchPoints > 1)); | ||
return Boolean('ongesturestart' in window || | ||
// non-standard and no major browser supports gesture events | ||
'onmsgesturestart' in window && ( | ||
// Internet Explorer 10 only | ||
window.navigator.msMaxTouchPoints > 1 || | ||
// Internet Explorer 10 only | ||
window.navigator.maxTouchPoints > 1)); | ||
}; | ||
var hasTouch = function hasTouch() { | ||
return Boolean('TouchEvent' in window || 'ontouchstart' in window || window.navigator.msMaxTouchPoints || window.navigator.msManipulationViewsEnabled && window.navigator.maxTouchPoints); | ||
}; | ||
// Adapted from https://patrickhlauke.github.io/touch/touchscreen-detection/ | ||
// I've omitted the touch event fallback since that is covered by hasTouch and we're less concerned | ||
// with legacy browsers used in touchscreen environments. | ||
var hasTouchScreen = function hasTouchScreen() { | ||
return ( | ||
// if Pointer Events are supported, just check maxTouchPoints | ||
window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints > 0 || | ||
// check for any-pointer:coarse which mostly means touchscreen | ||
window.matchMedia && window.matchMedia('(any-pointer:coarse)').matches | ||
return Boolean(featureTouchEvent() || 'ontouchstart' in window || | ||
// featureTouchEvent covers recent Firefox and Safari also, so no need when we deprecate old browsers | ||
window.navigator.msMaxTouchPoints || | ||
// Internet Explorer 10 only | ||
window.navigator.msManipulationViewsEnabled && window.navigator.maxTouchPoints // Internet Explorer only | ||
); | ||
@@ -135,3 +155,3 @@ }; | ||
}, | ||
// LG webOS of indeterminate versionre | ||
// LG webOS indeterminate versions | ||
{ | ||
@@ -222,7 +242,3 @@ platform: 'webos', | ||
}]; | ||
var ua = function ua() { | ||
return window.navigator ? window.navigator.userAgent : ''; | ||
}; | ||
var _platform; | ||
var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent) { | ||
var parseUserAgentLegacy = function parseUserAgentLegacy(userAgent) { | ||
var plat = { | ||
@@ -232,3 +248,3 @@ gesture: hasGesture(), | ||
touch: hasTouch(), | ||
touchscreen: hasTouchScreen(), | ||
touchscreen: deviceTouchScreen(), | ||
unknown: true | ||
@@ -261,7 +277,13 @@ }; | ||
} | ||
if (plat.platformName === 'windowsPhone') { | ||
if ('webos' === plat.platformName) { | ||
(0, _deprecate["default"])({ | ||
name: 'Windows Phone platform', | ||
name: plat.platformName, | ||
message: 'Refer `@enact/webos`\'s `platform` for webOS specific information.', | ||
until: '5.0.0' | ||
}); | ||
} else if (!['chrome', 'safari', 'firefox'].includes(plat.platformName)) { | ||
(0, _deprecate["default"])({ | ||
name: plat.platformName, | ||
until: '5.0.0' | ||
}); | ||
} | ||
@@ -271,11 +293,88 @@ return plat; | ||
/* | ||
* The end of Legacy Code to be removed in the next major release | ||
*/ | ||
// Refer https://www.whatismybrowser.com/guides/the-latest-user-agent/ for latest user agents of major browsers | ||
var userAgentPatterns = [ | ||
// Normal cases except iOS | ||
{ | ||
browserName: 'safari', | ||
regex: /\s+Version\/(\d+)(?:\.(\d+))?\s+Safari/ | ||
}, { | ||
browserName: 'chrome', | ||
regex: /\s+Chrome\/(\d+)[.\d]+/ | ||
}, { | ||
browserName: 'firefox', | ||
regex: /\s+Firefox\/(\d+)[.\d]+/ | ||
}, | ||
// iOS | ||
{ | ||
browserName: 'safari', | ||
regex: /\((?:iPhone|iPad);.+\sOS\s(\d+)_(\d+)/ | ||
}]; | ||
// The base supported versions: Used in DEPRECATED warning | ||
var supportedVersions = { | ||
safari: 15.6, | ||
chrome: 94, | ||
firefox: 115 | ||
}; | ||
var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent) { | ||
var detectedInfo = { | ||
type: 'unknown', | ||
browserName: 'unknown', | ||
browserVersion: 0 | ||
}; | ||
var index; | ||
for (index = 0; index < userAgentPatterns.length; index++) { | ||
var testPlatform = userAgentPatterns[index]; | ||
var match = testPlatform.regex.exec(userAgent); | ||
if (match) { | ||
detectedInfo.browserName = testPlatform.browserName; | ||
detectedInfo.browserVersion = Number("".concat(match[1], ".").concat(match[2] || 0)); | ||
break; | ||
} | ||
} | ||
if (index < userAgentPatterns.length) { | ||
if (userAgent.includes('Web0S;')) { | ||
detectedInfo.type = 'webos'; | ||
} else if (userAgent.includes(' Mobile')) { | ||
// Note that we don't catch 'Tablet' of Firefox as it can't be normalized with other browsers | ||
detectedInfo.type = 'mobile'; | ||
} else { | ||
detectedInfo.type = 'desktop'; | ||
} | ||
detectedInfo[detectedInfo.browserName] = detectedInfo.browserVersion; | ||
} | ||
// deprecation warning for browser versions older than our support policy | ||
if (supportedVersions[detectedInfo.browserName] > detectedInfo.browserVersion) { | ||
(0, _deprecate["default"])({ | ||
name: "supporting ".concat(detectedInfo.browserName, " version before ").concat(supportedVersions[detectedInfo.browserName]), | ||
until: '5.0.0' | ||
}); | ||
} | ||
// Merge legacy platform info | ||
return _objectSpread(_objectSpread({}, parseUserAgentLegacy(userAgent)), detectedInfo); | ||
}; | ||
/** | ||
* @typedef {Object} PlatformDescription | ||
* @property {Object} [extra] - Additional information about the detected platform | ||
* @property {Boolean} gesture - `true` if the platform has native double-finger events | ||
* @property {Boolean} node - `true` only if `window` is `undefined` | ||
* @property {String} [platformName] - The name of the platform, if detected | ||
* @property {Boolean} touch - `true` if the platform has native single-finger events | ||
* @property {Boolean} touchscreen - `true` if the platform has a touch screen | ||
* @property {Boolean} unknown - `true` for any unknown system | ||
* @property {String} browserName - The name of the detected browser | ||
* @property {Number} browserVersion - The version of the detected browser | ||
* @property {Number} chrome - The version of the detected browser, if chrome browser is detected | ||
* @property {Object} [extra] - Additional information about the detected platform. Deprecated: will be removed in 5.0.0. | ||
* @property {Number} firefox - The version of the detected browser, if firefox browser is detected | ||
* @property {Boolean} gesture - `true` if the platform has native double-finger events. Deprecated: will be removed in 5.0.0. | ||
* @property {Boolean} node - `true` only if `window` is `undefined`. Deprecated: will be removed in 5.0.0. Use `type` instead. | ||
* @property {String} [platformName] - The name of the platform, if detected. Deprecated: will be removed in 5.0.0. Use `browserName` instead for browser names. | ||
* @property {Number} safari - The version of the detected browser, if safari browser is detected | ||
* @property {Boolean} touch - `true` if the platform has native single-finger events. Deprecated: will be removed in 5.0.0. Use `touchEvent` instead. | ||
* @property {Boolean} touchEvent - `true` if the browser has native touch events | ||
* @property {Boolean} touchscreen - `true` if the platform has a touch screen. Deprecated: will be removed in 5.0.0. Use `touchScreen` instead. | ||
* @property {Boolean} touchScreen - `true` if the platform has a touch screen | ||
* @property {String} type - The type of the detected platform. One of 'desktop', 'mobile', 'webos', 'node', or 'unknown' | ||
* @property {Boolean} unknown - `true` for any unknown system. Deprecated: will be removed in 5.0.0. Use `type` instead. | ||
* | ||
@@ -285,2 +384,3 @@ * @memberof core/platform | ||
*/ | ||
var detectedPlatform = null; | ||
@@ -296,15 +396,32 @@ /** | ||
var detect = exports.detect = function detect() { | ||
if (_platform) { | ||
// if we've already determined the platform, we'll use that determination | ||
return _platform; | ||
} else if (typeof window === 'undefined') { | ||
return { | ||
if (detectedPlatform !== null) { | ||
// once detected, don't bother detecting again | ||
return detectedPlatform; | ||
} | ||
// Parse User Agent string first | ||
if (browserEnvironment()) { | ||
var _globalThis$navigator2; | ||
detectedPlatform = parseUserAgent(((_globalThis$navigator2 = globalThis.navigator) === null || _globalThis$navigator2 === void 0 ? void 0 : _globalThis$navigator2.userAgent) || ''); | ||
} else { | ||
// node or compatible environment (e.g. prerendering or snapshot runs) | ||
detectedPlatform = { | ||
// the following properties are deprecated and will be removed in the next major release | ||
gesture: false, | ||
node: true, | ||
touch: false, | ||
unknown: true | ||
unknown: true, | ||
// the following properties are new and will be available in the next major release | ||
type: 'node', | ||
browserName: 'unknown', | ||
browserVersion: 0 /* magic number for unknown */ | ||
}; | ||
} | ||
var userAgent = ua(); | ||
return _platform = parseUserAgent(userAgent); | ||
// Detect features | ||
detectedPlatform.touchEvent = featureTouchEvent(); | ||
// Detect devices | ||
detectedPlatform.touchScreen = deviceTouchScreen(); | ||
return detectedPlatform; | ||
}; | ||
@@ -320,3 +437,7 @@ | ||
var platform = exports.platform = {}; | ||
['gesture', 'node', 'platformName', 'touch', 'touchscreen', 'unknown'].concat(_toConsumableArray((0, _uniq["default"])(platforms.map(function (p) { | ||
[ | ||
// the following properties are deprecated and will be removed in the next major release | ||
'gesture', 'node', 'platformName', 'touch', 'touchscreen', 'unknown', | ||
// the following properties are new and will be available in the next major release | ||
'browserName', 'browserVersion', 'touchEvent', 'touchScreen', 'type'].concat(_toConsumableArray(new Set(platforms.map(function (p) { | ||
return p.platform; | ||
@@ -327,2 +448,36 @@ })))).forEach(function (name) { | ||
get: function get() { | ||
if (name === 'gesture' || name === 'unknown') { | ||
(0, _deprecate["default"])({ | ||
name: name, | ||
until: '5.0.0' | ||
}); | ||
} | ||
if (name === 'node') { | ||
(0, _deprecate["default"])({ | ||
name: name, | ||
until: '5.0.0', | ||
replacedBy: 'type' | ||
}); | ||
} | ||
if (name === 'platformName') { | ||
(0, _deprecate["default"])({ | ||
name: name, | ||
until: '5.0.0', | ||
replacedBy: 'browserName' | ||
}); | ||
} | ||
if (name === 'touch') { | ||
(0, _deprecate["default"])({ | ||
name: name, | ||
until: '5.0.0', | ||
replacedBy: 'touchEvent' | ||
}); | ||
} | ||
if (name === 'touchscreen') { | ||
(0, _deprecate["default"])({ | ||
name: name, | ||
until: '5.0.0', | ||
replacedBy: 'touchScreen' | ||
}); | ||
} | ||
var p = detect(); | ||
@@ -329,0 +484,0 @@ return p[name]; |
@@ -200,9 +200,150 @@ "use strict"; | ||
}); | ||
describe('parseUserAgent for Safari', function () { | ||
test('should detect Safari browsers', function () { | ||
var knownUserAgents = { | ||
userAgentList: [ | ||
// Safari on macOS | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15'], | ||
expected: { | ||
type: 'desktop', | ||
browserName: 'safari', | ||
browserVersion: 17.3, | ||
safari: 17.3 | ||
} | ||
}; | ||
for (var i = 0; i < knownUserAgents.userAgentList.length; i++) { | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]); | ||
expect(actual).toMatchObject(knownUserAgents.expected); | ||
} | ||
}); | ||
test('should detect mobile Safari browsers', function () { | ||
var knownUserAgents = { | ||
// | ||
userAgentList: [ | ||
// Safari on iPhone, iPad | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Mobile/15E148 Safari/604.1', 'Mozilla/5.0 (iPad; CPU OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Mobile/15E148 Safari/604.1', | ||
// Chrome on iPhone, iPad | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/121.0.6167.138 Mobile/15E148 Safari/604.1', 'Mozilla/5.0 (iPad; CPU OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/121.0.6167.138 Mobile/15E148 Safari/604.1', | ||
// Edge on iPhone | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 EdgiOS/121.2277.99 Mobile/15E148 Safari/605.1.15', | ||
// Firefox on iPhone, iPad | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/122.0 Mobile/15E148 Safari/605.1.15', 'Mozilla/5.0 (iPad; CPU OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/122.0 Mobile/15E148 Safari/605.1.15'], | ||
expected: { | ||
type: 'mobile', | ||
browserName: 'safari', | ||
browserVersion: 17.3, | ||
safari: 17.3 | ||
} | ||
}; | ||
for (var i = 0; i < knownUserAgents.userAgentList.length; i++) { | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]); | ||
expect(actual).toMatchObject(knownUserAgents.expected); | ||
} | ||
}); | ||
}); | ||
describe('parseUserAgent for Chrome', function () { | ||
test('should detect Chrome browsers', function () { | ||
var knownUserAgents = { | ||
// Chrome on Windows, macOS, Linux, Edge on Windows, macOS, respectively | ||
userAgentList: [ | ||
// Chrome on Windows, macOS, Linux | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', | ||
// Edge on Windows, macOS | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.2277.98', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.2277.98'], | ||
expected: { | ||
type: 'desktop', | ||
browserName: 'chrome', | ||
browserVersion: 121, | ||
chrome: 121 | ||
} | ||
}; | ||
for (var i = 0; i < knownUserAgents.userAgentList.length; i++) { | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]); | ||
expect(actual).toMatchObject(knownUserAgents.expected); | ||
} | ||
}); | ||
test('should detect mobile Chrome browsers', function () { | ||
var knownUserAgents = { | ||
userAgentList: [ | ||
// Chrome on Android | ||
'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.143 Mobile Safari/537.36', | ||
// Edge on Android | ||
'Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.143 Mobile Safari/537.36 EdgA/120.0.2210.157'], | ||
expected: { | ||
type: 'mobile', | ||
browserName: 'chrome', | ||
browserVersion: 121, | ||
chrome: 121 | ||
} | ||
}; | ||
for (var i = 0; i < knownUserAgents.userAgentList.length; i++) { | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]); | ||
expect(actual).toMatchObject(knownUserAgents.expected); | ||
} | ||
}); | ||
}); | ||
describe('parseUserAgent for Firefox', function () { | ||
test('should detect Firefox browsers', function () { | ||
var knownUserAgents = { | ||
userAgentList: [ | ||
// Firefox on Windows, macOS, Linux | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.3; rv:122.0) Gecko/20100101 Firefox/122.0', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0'], | ||
expected: { | ||
type: 'desktop', | ||
browserName: 'firefox', | ||
browserVersion: 122, | ||
firefox: 122 | ||
} | ||
}; | ||
for (var i = 0; i < knownUserAgents.userAgentList.length; i++) { | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]); | ||
expect(actual).toMatchObject(knownUserAgents.expected); | ||
} | ||
}); | ||
test('should detect mobile Firefox browsers', function () { | ||
var knownUserAgents = { | ||
userAgentList: [ | ||
// Firefox on Android | ||
'Mozilla/5.0 (Android 14; Mobile; rv:122.0) Gecko/122.0 Firefox/122.0'], | ||
expected: { | ||
type: 'mobile', | ||
browserName: 'firefox', | ||
browserVersion: 122, | ||
firefox: 122 | ||
} | ||
}; | ||
for (var i = 0; i < knownUserAgents.userAgentList.length; i++) { | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]); | ||
expect(actual).toMatchObject(knownUserAgents.expected); | ||
} | ||
}); | ||
}); | ||
describe('parseUserAgent for Chrome on webOS', function () { | ||
test('should detect Chrome browsers on webOS', function () { | ||
var knownUserAgent = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 WebAppManager'; | ||
var expected = { | ||
type: 'webos', | ||
browserName: 'chrome', | ||
browserVersion: 108, | ||
chrome: 108 | ||
}; | ||
var actual = (0, _platform.parseUserAgent)(knownUserAgent); | ||
expect(actual).toMatchObject(expected); | ||
}); | ||
}); | ||
describe('platform', function () { | ||
test('should return `true` for `node` if window does not exist', function () { | ||
test('should detect node environment if \'window\' does not exist', function () { | ||
var windowSpy = jest.spyOn(window, 'window', 'get').mockImplementation(function () {}); | ||
expect(_platform.platform['node']).toBe(true); | ||
var expected = { | ||
node: true, | ||
// Deprecated: will be removed in 5.0.0. | ||
type: 'node', | ||
browserName: 'unknown', | ||
browserVersion: 0 | ||
}; | ||
expect(_platform.platform).toMatchObject(expected); | ||
windowSpy.mockRestore(); | ||
}); | ||
test('should return `true` for `unknown` in the testing environment', function () { | ||
// Deprecated: will be removed in 5.0.0 | ||
// The first access invokes detecting based on user agent value | ||
@@ -209,0 +350,0 @@ expect(_platform.platform['unknown']).toBe(true); |
@@ -9,4 +9,4 @@ "use strict"; | ||
var _react = require("react"); | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; } | ||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
@@ -13,0 +13,0 @@ /** |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
320151
7687
1