@enact/webos 4.8.0 → 4.9.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact webos module, newest changes on the top.
4
4
 
5
+ ## [4.9.0-alpha.1] - 2024-04-09
6
+
7
+ ### Deprecated
8
+
9
+ - `webos/platform` member `watch` and `legacy`, to be removed in 5.0.0
10
+
11
+ ### Added
12
+
13
+ - `webos/platform` member `webos` to detect if a webOS platform
14
+ - `webos/platform` member `version` for the detected webOS version
15
+ - `webos/platform` member `chrome` for the detected chrome version
16
+
5
17
  ## [4.8.0] - 2024-02-08
6
18
 
7
19
  No significant changes.
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.requestLastInputType = exports["default"] = void 0;
7
+ var _LS2Request = _interopRequireDefault(require("../LS2Request"));
8
+ var _platform = _interopRequireDefault(require("../platform"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ /**
11
+ * Exports a method for calling `surfacemanager` service through LS2Request and returns `lastInputType`
12
+ *
13
+ * @module webos/lastInputType
14
+ * @private
15
+ */
16
+
17
+ var requestLastInputType = exports.requestLastInputType = function requestLastInputType(_ref) {
18
+ var onSuccess = _ref.onSuccess,
19
+ onFailure = _ref.onFailure;
20
+ if (_platform["default"].tv) {
21
+ return new _LS2Request["default"]().send({
22
+ service: 'luna://com.webos.surfacemanager',
23
+ method: 'getLastInputType',
24
+ subscribe: true,
25
+ onSuccess: onSuccess,
26
+ onFailure: onFailure
27
+ });
28
+ }
29
+ return null;
30
+ };
31
+ var _default = exports["default"] = requestLastInputType;
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "lastInputType.js"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/webos",
3
- "version": "4.8.0",
3
+ "version": "4.9.0-alpha.1",
4
4
  "description": "webOS support library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "@enact/core": "^4.8.0",
35
+ "@enact/core": "^4.9.0-alpha.1",
36
36
  "prop-types": "^15.8.1",
37
37
  "react": "^18.2.0",
38
38
  "react-dom": "^18.2.0"
@@ -5,19 +5,132 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.detect = detect;
8
- exports.platform = void 0;
9
- /**
8
+ exports.platform = exports.parseUserAgent = void 0;
9
+ var _deprecate = _interopRequireDefault(require("@enact/core/internal/deprecate"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /**
10
17
  * Utilities for webOS platform detection.
11
18
  *
12
19
  * @module webos/platform
13
20
  * @exports detect
14
21
  * @exports platform
15
22
  */
16
-
17
- function is(type) {
18
- return window.navigator.userAgent.indexOf(type) > -1;
19
- }
20
- var _platform;
23
+ var webOSVersion = [
24
+ // Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.2.1 Chrome/38.0.2125.122 Safari/537.36 WebAppManager
25
+ {
26
+ chrome: 38,
27
+ version: 3
28
+ },
29
+ // Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.34 Safari/537.36 WebAppManager
30
+ {
31
+ chrome: 53,
32
+ version: 4
33
+ },
34
+ // Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager
35
+ {
36
+ chrome: 68,
37
+ version: 5
38
+ },
39
+ // Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 WebAppManager
40
+ {
41
+ chrome: 79,
42
+ version: 6
43
+ },
44
+ // Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 WebAppManager
45
+ {
46
+ chrome: 87,
47
+ version: 22
48
+ },
49
+ // Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.128 Safari/537.36 WebAppManager
50
+ {
51
+ chrome: 94,
52
+ version: 23
53
+ }];
54
+ var platforms = [
55
+ // LG webOS before adapting Chrome
56
+ {
57
+ regex: /Web0S;.*Safari\/537.41/,
58
+ version: 1
59
+ },
60
+ // using WebKit 537.41 for WebAppManager, using Chrome 26 for the browser app
61
+ {
62
+ regex: /Web0S;.*Safari\/538.2/,
63
+ version: 2
64
+ }].concat(_toConsumableArray(webOSVersion.map(function (_ref) {
65
+ var chrome = _ref.chrome,
66
+ version = _ref.version;
67
+ return {
68
+ regex: new RegExp("Web0S;.*Chrome/".concat(chrome)),
69
+ version: version,
70
+ chrome: chrome
71
+ };
72
+ })), [{
73
+ regex: /Web0S;.*Chrome\/(\d+)/
74
+ },
75
+ // Fallback
76
+ {
77
+ regex: /Web0S;/
78
+ }]);
79
+ var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent) {
80
+ // build out our cached platform determination for future usage
81
+ var platformInfo = {
82
+ webos: false
83
+ };
84
+ if (userAgent.indexOf('SmartWatch') > -1) {
85
+ platformInfo.watch = true;
86
+ } else if (userAgent.indexOf('SmartTV') > -1) {
87
+ platformInfo.tv = true;
88
+ } else if (userAgent.indexOf('Large Screen') > -1) {
89
+ (0, _deprecate["default"])({
90
+ name: 'Detecting webOS TV by "Large Screen" from the user agent string',
91
+ until: '5.0.0'
92
+ });
93
+ platformInfo.tv = true;
94
+ } else {
95
+ var _window$webOSSystem, _webOSSystem$stageRea;
96
+ var webOSSystem = (_window$webOSSystem = window.webOSSystem) !== null && _window$webOSSystem !== void 0 ? _window$webOSSystem : window.PalmSystem;
97
+ try {
98
+ var legacyInfo = JSON.parse(webOSSystem.deviceInfo || '{}');
99
+ if (legacyInfo.platformVersionMajor && legacyInfo.platformVersionMinor) {
100
+ var major = parseInt(legacyInfo.platformVersionMajor);
101
+ var minor = parseInt(legacyInfo.platformVersionMinor);
102
+ if (major < 3 || major === 3 && minor <= 0) {
103
+ platformInfo.legacy = true;
104
+ } else {
105
+ platformInfo.open = true;
106
+ }
107
+ } else {
108
+ platformInfo.unknown = true;
109
+ }
110
+ } catch (e) {
111
+ platformInfo.open = true;
112
+ }
113
+ webOSSystem === null || webOSSystem === void 0 || (_webOSSystem$stageRea = webOSSystem.stageReady) === null || _webOSSystem$stageRea === void 0 || _webOSSystem$stageRea.call(webOSSystem);
114
+ }
115
+ for (var index = 0, p, match; p = platforms[index]; index++) {
116
+ match = p.regex.exec(userAgent);
117
+ if (match) {
118
+ platformInfo.webos = true;
119
+ if (p.version) {
120
+ platformInfo.version = p.version;
121
+ }
122
+ if (p.chrome) {
123
+ platformInfo.chrome = p.chrome;
124
+ } else if (match[1]) {
125
+ // if a chrome version is detected
126
+ platformInfo.chrome = Number(match[1]);
127
+ }
128
+ break;
129
+ }
130
+ }
131
+ return platformInfo;
132
+ };
133
+ var _platform = null;
21
134
 
22
135
  /**
23
136
  * Returns the {@link webos/platform.platform} object.
@@ -37,39 +150,7 @@ function detect() {
37
150
  unknown: true
38
151
  };
39
152
  }
40
-
41
- // build out our cached platform determination for future usage
42
- _platform = {};
43
- if (is('SmartWatch')) {
44
- _platform.watch = true;
45
- } else if (is('SmartTV') || is('Large Screen')) {
46
- _platform.tv = true;
47
- } else {
48
- var _window$webOSSystem;
49
- var webOSSystem = (_window$webOSSystem = window.webOSSystem) !== null && _window$webOSSystem !== void 0 ? _window$webOSSystem : window.PalmSystem;
50
- try {
51
- var legacyInfo = JSON.parse(webOSSystem.deviceInfo || '{}');
52
- if (legacyInfo.platformVersionMajor && legacyInfo.platformVersionMinor) {
53
- var major = parseInt(legacyInfo.platformVersionMajor);
54
- var minor = parseInt(legacyInfo.platformVersionMinor);
55
- if (major < 3 || major === 3 && minor <= 0) {
56
- _platform.legacy = true;
57
- } else {
58
- _platform.open = true;
59
- }
60
- } else {
61
- _platform.unknown = true;
62
- }
63
- } catch (e) {
64
- _platform.open = true;
65
- }
66
-
67
- // TODO: clean these up. They shouldn't be here
68
- window.Mojo = window.Mojo || {
69
- relaunch: function relaunch() {}
70
- };
71
- if (webOSSystem.stageReady) webOSSystem.stageReady();
72
- }
153
+ _platform = parseUserAgent(window.navigator.userAgent || '');
73
154
  return _platform;
74
155
  }
75
156
 
@@ -78,19 +159,28 @@ function detect() {
78
159
  *
79
160
  * @readonly
80
161
  * @type {Object}
162
+ * @property {Boolean} webos `true` for webOS
81
163
  * @property {Boolean} [tv] `true` for LG webOS SmartTV
82
- * @property {Boolean} [watch] `true` for LG webOS SmartWatch
164
+ * @property {Boolean} [watch] `true` for LG webOS SmartWatch. Deprecated: will be removed in 5.0.0.
83
165
  * @property {Boolean} [open] `true` for Open webOS
84
- * @property {Boolean} [legacy] `true` for legacy webOS (Palm and HP hardware)
166
+ * @property {Boolean} [legacy] `true` for legacy webOS (Palm and HP hardware). Deprecated: will be removed in 5.0.0.
85
167
  * @property {Boolean} [unknown] `true` for any unknown system
168
+ * @property {Number} [version] The version of the platform if detected
169
+ * @property {Number} [chrome] The version of Chrome if detected
86
170
  * @memberof webos/platform
87
171
  * @public
88
172
  */
89
173
  var platform = exports.platform = {};
90
- ['tv', 'watch', 'open', 'legacy', 'unknown'].forEach(function (name) {
174
+ ['tv', 'watch', 'open', 'legacy', 'unknown', 'version', 'chrome'].forEach(function (name) {
91
175
  Object.defineProperty(platform, name, {
92
176
  enumerable: true,
93
177
  get: function get() {
178
+ if (name === 'watch' || name === 'legacy') {
179
+ (0, _deprecate["default"])({
180
+ name: name,
181
+ until: '5.0.0'
182
+ });
183
+ }
94
184
  var p = detect();
95
185
  return p[name];
96
186
  }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ var _platform = require("../platform");
4
+ describe('platform', function () {
5
+ describe('parseUserAgent for webOS', function () {
6
+ // From http://webostv.developer.lge.com/discover/specifications/web-engine/
7
+ var webOSTV1 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.41 (KHTML, like Gecko) Large Screen WebAppManager Safari/537.41';
8
+ var webOSTV2 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen WebAppManager Safari/538.2';
9
+ var webOSTV3 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.2.1 Chrome/38.0.2125.122 Safari/537.36 WebAppManager';
10
+ var webOSTV4 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.34 Safari/537.36 WebAppManager';
11
+ var webOSTV5 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager';
12
+ var webOSTV6 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 WebAppManager';
13
+ var webOSTV22 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 WebAppManager';
14
+ var webOSTV23 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.128 Safari/537.36 WebAppManager';
15
+ var webOSTVChrome = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 WebAppManager';
16
+ var webOSOther = 'Mozilla/5.0 (Web0S; Linux) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36 WebAppManager';
17
+ test('should detect webOS 1', function () {
18
+ var expected = {
19
+ version: 1
20
+ };
21
+ var actual = (0, _platform.parseUserAgent)(webOSTV1);
22
+ expect(actual).toMatchObject(expected);
23
+ });
24
+ test('should detect webOS 2', function () {
25
+ var expected = {
26
+ version: 2
27
+ };
28
+ var actual = (0, _platform.parseUserAgent)(webOSTV2);
29
+ expect(actual).toMatchObject(expected);
30
+ });
31
+ test('should detect webOS 3', function () {
32
+ var expected = {
33
+ version: 3
34
+ };
35
+ var actual = (0, _platform.parseUserAgent)(webOSTV3);
36
+ expect(actual).toMatchObject(expected);
37
+ });
38
+ test('should detect webOS 4', function () {
39
+ var expected = {
40
+ version: 4
41
+ };
42
+ var actual = (0, _platform.parseUserAgent)(webOSTV4);
43
+ expect(actual).toMatchObject(expected);
44
+ });
45
+ test('should detect webOS 5', function () {
46
+ var expected = {
47
+ version: 5
48
+ };
49
+ var actual = (0, _platform.parseUserAgent)(webOSTV5);
50
+ expect(actual).toMatchObject(expected);
51
+ });
52
+ test('should detect webOS 6', function () {
53
+ var expected = {
54
+ version: 6
55
+ };
56
+ var actual = (0, _platform.parseUserAgent)(webOSTV6);
57
+ expect(actual).toMatchObject(expected);
58
+ });
59
+ test('should detect webOS 22', function () {
60
+ var expected = {
61
+ version: 22,
62
+ chrome: 87
63
+ };
64
+ var actual = (0, _platform.parseUserAgent)(webOSTV22);
65
+ expect(actual).toMatchObject(expected);
66
+ });
67
+ test('should detect webOS 23', function () {
68
+ var expected = {
69
+ version: 23,
70
+ chrome: 94
71
+ };
72
+ var actual = (0, _platform.parseUserAgent)(webOSTV23);
73
+ expect(actual).toMatchObject(expected);
74
+ });
75
+ test('should detect webOS with Chrome', function () {
76
+ var expected = {
77
+ chrome: 108
78
+ };
79
+ var actual = (0, _platform.parseUserAgent)(webOSTVChrome);
80
+ expect(actual).toMatchObject(expected);
81
+ });
82
+ test('should detect webOS without Chrome', function () {
83
+ var expected = {
84
+ open: true
85
+ };
86
+ var actual = (0, _platform.parseUserAgent)(webOSOther);
87
+ expect(actual).toMatchObject(expected);
88
+ });
89
+ });
90
+ });
@@ -23,7 +23,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
23
23
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
24
24
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
25
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
- 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; } }
26
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
27
27
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
28
28
  * VoiceControlDecorator is a higher-order component that adds a callback for voice event
29
29
  * to its wrapped component.