@enact/webos
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -5,2 +5,6 @@ # Change Log | ||
## [1.4.0] - 2017-06-29 | ||
No significant changes. | ||
## [1.3.1] - 2017-06-14 | ||
@@ -7,0 +11,0 @@ |
{ | ||
"name": "@enact/webos", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "webOS support library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,5 +6,2 @@ 'use strict'; | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
/** | ||
@@ -18,23 +15,37 @@ * Exports the {@link webos/platform.platform} object that contains basic device | ||
function is(type) { | ||
return window.navigator.userAgent.indexOf(type) > -1; | ||
} | ||
var _platform = void 0; | ||
/** | ||
* {@link webos/platform.platform} provides identification of webOS variants. | ||
* {@link webos/platform.detect} returns the {@link webos/platform.platform} object. | ||
* | ||
* @readonly | ||
* @type {object} | ||
* @property {?boolean} tv - Set true for LG webOS SmartTV | ||
* @property {?boolean} watch - Set true for LG webOS SmartWatch | ||
* @property {?boolean} open - Set true for Open webOS | ||
* @property {?boolean} legacy - Set true for legacy webOS (Palm and HP hardware) | ||
* @property {?boolean} unknown - Set true for any unknown system | ||
* @type {Function} | ||
* @returns {Object} the {@link webos/platform.platform} object | ||
* | ||
* @method detect | ||
* @memberof webos/platform | ||
* @public | ||
*/ | ||
var platform = {}; | ||
if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && window.PalmSystem) { | ||
if (window.navigator.userAgent.indexOf('SmartWatch') > -1) { | ||
platform.watch = true; | ||
} else if (window.navigator.userAgent.indexOf('SmartTV') > -1 || window.navigator.userAgent.indexOf('Large Screen') > -1) { | ||
platform.tv = true; | ||
function detect() { | ||
if (_platform) { | ||
// if we've already determined the platform, we'll use that determination | ||
return _platform; | ||
} else if (typeof window === 'undefined' || !window.PalmSystem) { | ||
// if window isn't available (in prerendering or snapshot runs), bail out early | ||
return { | ||
unknown: true | ||
}; | ||
} | ||
// build out our cached platform determination for future usage | ||
_platform = {}; | ||
if (is('SmartWatch')) { | ||
_platform.watch = true; | ||
} else if (is('SmartTV') || is('Large Screen')) { | ||
_platform.tv = true; | ||
} else { | ||
@@ -47,18 +58,49 @@ try { | ||
if (major < 3 || major === 3 && minor <= 0) { | ||
platform.legacy = true; | ||
_platform.legacy = true; | ||
} else { | ||
platform.open = true; | ||
_platform.open = true; | ||
} | ||
} else { | ||
_platform.unknown = true; | ||
} | ||
} catch (e) { | ||
platform.open = true; | ||
_platform.open = true; | ||
} | ||
// TODO: clean these up. They shouldn't be here | ||
window.Mojo = window.Mojo || { relaunch: function relaunch() {} }; | ||
if (window.PalmSystem.stageReady) window.PalmSystem.stageReady(); | ||
} | ||
} else { | ||
platform.unknown = true; | ||
return _platform; | ||
} | ||
/** | ||
* {@link webos/platform.platform} provides identification of webOS variants. | ||
* | ||
* @readonly | ||
* @type {object} | ||
* @property {?boolean} tv - Set true for LG webOS SmartTV | ||
* @property {?boolean} watch - Set true for LG webOS SmartWatch | ||
* @property {?boolean} open - Set true for Open webOS | ||
* @property {?boolean} legacy - Set true for legacy webOS (Palm and HP hardware) | ||
* @property {?boolean} unknown - Set true for any unknown system | ||
* | ||
* @memberof webos/platform | ||
* @public | ||
*/ | ||
var platform = {}; | ||
['tv', 'watch', 'open', 'legacy', 'unknown'].forEach(function (name) { | ||
Object.defineProperty(platform, name, { | ||
enumerable: true, | ||
get: function get() { | ||
var p = detect(); | ||
return p[name]; | ||
} | ||
}); | ||
}); | ||
exports.default = platform; | ||
exports.detect = detect; | ||
exports.platform = platform; |
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
27672
597