@enact/webos 3.4.9-experimental-3 → 3.4.9-experimental-7

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/{build/LS2Request → LS2Request}/LS2Request.d.ts +0 -0
  3. package/LS2Request/LS2Request.js +228 -173
  4. package/LS2Request/tests/LS2Request-specs.js +85 -95
  5. package/{build/application → application}/application.d.ts +0 -0
  6. package/application/application.js +92 -70
  7. package/{build/deviceinfo → deviceinfo}/deviceinfo.d.ts +0 -0
  8. package/deviceinfo/deviceinfo.js +78 -62
  9. package/{build/index.d.ts → index.d.ts} +0 -0
  10. package/index.js +1 -0
  11. package/{build/keyboard → keyboard}/keyboard.d.ts +0 -0
  12. package/keyboard/keyboard.js +11 -4
  13. package/package.json +2 -2
  14. package/{build/platform → platform}/platform.d.ts +0 -0
  15. package/platform/platform.js +67 -65
  16. package/{build/pmloglib → pmloglib}/pmloglib.d.ts +0 -0
  17. package/pmloglib/pmloglib.js +116 -86
  18. package/speech/VoiceControlDecorator.js +99 -42
  19. package/{build/speech → speech}/index.d.ts +0 -0
  20. package/speech/index.js +23 -15
  21. package/speech/readAlert.js +78 -60
  22. package/build/CHANGELOG.md +0 -603
  23. package/build/LS2Request/LS2Request.js +0 -239
  24. package/build/LS2Request/package.json +0 -3
  25. package/build/LS2Request/tests/LS2Request-specs.js +0 -85
  26. package/build/README.md +0 -22
  27. package/build/application/application.js +0 -150
  28. package/build/application/package.json +0 -3
  29. package/build/deviceinfo/deviceinfo.js +0 -114
  30. package/build/deviceinfo/package.json +0 -3
  31. package/build/index.js +0 -2
  32. package/build/keyboard/keyboard.js +0 -27
  33. package/build/keyboard/package.json +0 -3
  34. package/build/package-lock.json +0 -221
  35. package/build/package.json +0 -33
  36. package/build/platform/package.json +0 -3
  37. package/build/platform/platform.js +0 -105
  38. package/build/pmloglib/package.json +0 -3
  39. package/build/pmloglib/pmloglib.js +0 -241
  40. package/build/speech/VoiceControlDecorator.js +0 -152
  41. package/build/speech/index.js +0 -23
  42. package/build/speech/package.json +0 -3
  43. package/build/speech/readAlert.js +0 -96
  44. package/docs/index.md +0 -8
  45. package/docs/luna-service-api.md +0 -35
  46. package/docs/webos-features.md +0 -37
@@ -1,4 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.perfLog = exports.debug = exports.info = exports.notice = exports.warning = exports.error = exports.critical = exports.alert = exports.emergency = void 0;
7
+
1
8
  /* eslint-disable no-console */
9
+
2
10
  /**
3
11
  * Provides a wrapper around PmLogLib logging API
4
12
  *
@@ -13,47 +21,53 @@
13
21
  * @exports debug
14
22
  * @exports perfLog
15
23
  */
16
-
17
24
  // Log level constants
18
- const levelEmergency = 0;
19
- const levelAlert = 1;
20
- const levelCritical = 2;
21
- const levelError = 3;
22
- const levelWarning = 4;
23
- const levelNotice = 5;
24
- const levelInfo = 6;
25
- const levelDebug = 7;
26
-
27
- const isObject = (obj) => !!obj && (typeof obj === 'object') && (Object.prototype.toString.call(obj) !== '[object Array]');
28
-
29
- // Log function stringifies and escapes keyVals, and passes to PmLogString
30
- const log = (level, messageId, keyVals, freeText) => {
31
- if (typeof window !== 'undefined' && window.PalmSystem) {
32
- if (keyVals && !isObject(keyVals)) {
33
- level = levelError;
34
- keyVals = {msgid: messageId};
35
- messageId = 'MISMATCHED_FMT';
36
- freeText = null;
37
- console.warn('webOSLog called with invalid format: keyVals must be an object');
38
- }
39
- if (!messageId && level !== levelDebug) {
40
- console.warn('webOSLog called with invalid format: messageId was empty');
41
- }
42
- if (keyVals) {
43
- keyVals = JSON.stringify(keyVals);
44
- }
45
- if (window.PalmSystem.PmLogString) {
46
- if (level === levelDebug) { // debug only accepts 2 arguments
47
- window.PalmSystem.PmLogString(level, null, null, freeText);
48
- } else {
49
- window.PalmSystem.PmLogString(level, messageId, keyVals, freeText);
50
- }
51
- } else {
52
- console.error('Unable to send log: PmLogString not found in this version of PalmSystem');
53
- }
54
- }
55
- };
25
+ var levelEmergency = 0;
26
+ var levelAlert = 1;
27
+ var levelCritical = 2;
28
+ var levelError = 3;
29
+ var levelWarning = 4;
30
+ var levelNotice = 5;
31
+ var levelInfo = 6;
32
+ var levelDebug = 7;
33
+
34
+ var isObject = function isObject(obj) {
35
+ return !!obj && typeof obj === 'object' && Object.prototype.toString.call(obj) !== '[object Array]';
36
+ }; // Log function stringifies and escapes keyVals, and passes to PmLogString
56
37
 
38
+
39
+ var log = function log(level, messageId, keyVals, freeText) {
40
+ if (typeof window !== 'undefined' && window.PalmSystem) {
41
+ if (keyVals && !isObject(keyVals)) {
42
+ level = levelError;
43
+ keyVals = {
44
+ msgid: messageId
45
+ };
46
+ messageId = 'MISMATCHED_FMT';
47
+ freeText = null;
48
+ console.warn('webOSLog called with invalid format: keyVals must be an object');
49
+ }
50
+
51
+ if (!messageId && level !== levelDebug) {
52
+ console.warn('webOSLog called with invalid format: messageId was empty');
53
+ }
54
+
55
+ if (keyVals) {
56
+ keyVals = JSON.stringify(keyVals);
57
+ }
58
+
59
+ if (window.PalmSystem.PmLogString) {
60
+ if (level === levelDebug) {
61
+ // debug only accepts 2 arguments
62
+ window.PalmSystem.PmLogString(level, null, null, freeText);
63
+ } else {
64
+ window.PalmSystem.PmLogString(level, messageId, keyVals, freeText);
65
+ }
66
+ } else {
67
+ console.error('Unable to send log: PmLogString not found in this version of PalmSystem');
68
+ }
69
+ }
70
+ };
57
71
  /**
58
72
  * Logs with PmLogLib at the "emergency" level.
59
73
  *
@@ -65,10 +79,11 @@ const log = (level, messageId, keyVals, freeText) => {
65
79
  * @memberof webos/pmloglib
66
80
  * @public
67
81
  */
68
- const emergency = (messageId, keyVals, freeText) => {
69
- log(levelEmergency, messageId, keyVals, freeText);
70
- };
71
82
 
83
+
84
+ var emergency = function emergency(messageId, keyVals, freeText) {
85
+ log(levelEmergency, messageId, keyVals, freeText);
86
+ };
72
87
  /**
73
88
  * Logs with PmLogLib at the "alert" level.
74
89
  *
@@ -80,10 +95,13 @@ const emergency = (messageId, keyVals, freeText) => {
80
95
  * @memberof webos/pmloglib
81
96
  * @public
82
97
  */
83
- const alert = (messageId, keyVals, freeText) => {
84
- log(levelAlert, messageId, keyVals, freeText);
85
- };
86
98
 
99
+
100
+ exports.emergency = emergency;
101
+
102
+ var alert = function alert(messageId, keyVals, freeText) {
103
+ log(levelAlert, messageId, keyVals, freeText);
104
+ };
87
105
  /**
88
106
  * Logs with PmLogLib at the "critical" level.
89
107
  *
@@ -95,10 +113,13 @@ const alert = (messageId, keyVals, freeText) => {
95
113
  * @memberof webos/pmloglib
96
114
  * @public
97
115
  */
98
- const critical = (messageId, keyVals, freeText) => {
99
- log(levelCritical, messageId, keyVals, freeText);
100
- };
101
116
 
117
+
118
+ exports.alert = alert;
119
+
120
+ var critical = function critical(messageId, keyVals, freeText) {
121
+ log(levelCritical, messageId, keyVals, freeText);
122
+ };
102
123
  /**
103
124
  * Logs with PmLogLib at the "error" level.
104
125
  *
@@ -110,10 +131,13 @@ const critical = (messageId, keyVals, freeText) => {
110
131
  * @memberof webos/pmloglib
111
132
  * @public
112
133
  */
113
- const error = (messageId, keyVals, freeText) => {
114
- log(levelError, messageId, keyVals, freeText);
115
- };
116
134
 
135
+
136
+ exports.critical = critical;
137
+
138
+ var error = function error(messageId, keyVals, freeText) {
139
+ log(levelError, messageId, keyVals, freeText);
140
+ };
117
141
  /**
118
142
  * Logs with PmLogLib at the "warning" level.
119
143
  *
@@ -125,10 +149,13 @@ const error = (messageId, keyVals, freeText) => {
125
149
  * @memberof webos/pmloglib
126
150
  * @public
127
151
  */
128
- const warning = (messageId, keyVals, freeText) => {
129
- log(levelWarning, messageId, keyVals, freeText);
130
- };
131
152
 
153
+
154
+ exports.error = error;
155
+
156
+ var warning = function warning(messageId, keyVals, freeText) {
157
+ log(levelWarning, messageId, keyVals, freeText);
158
+ };
132
159
  /**
133
160
  * Logs with PmLogLib at the "notice" level.
134
161
  *
@@ -140,10 +167,13 @@ const warning = (messageId, keyVals, freeText) => {
140
167
  * @memberof webos/pmloglib
141
168
  * @public
142
169
  */
143
- const notice = (messageId, keyVals, freeText) => {
144
- log(levelNotice, messageId, keyVals, freeText);
145
- };
146
170
 
171
+
172
+ exports.warning = warning;
173
+
174
+ var notice = function notice(messageId, keyVals, freeText) {
175
+ log(levelNotice, messageId, keyVals, freeText);
176
+ };
147
177
  /**
148
178
  * Logs with PmLogLib at the "info" level.
149
179
  *
@@ -155,10 +185,13 @@ const notice = (messageId, keyVals, freeText) => {
155
185
  * @memberof webos/pmloglib
156
186
  * @public
157
187
  */
158
- const info = (messageId, keyVals, freeText) => {
159
- log(levelInfo, messageId, keyVals, freeText);
160
- };
161
188
 
189
+
190
+ exports.notice = notice;
191
+
192
+ var info = function info(messageId, keyVals, freeText) {
193
+ log(levelInfo, messageId, keyVals, freeText);
194
+ };
162
195
  /**
163
196
  * Logs with PmLogLib at the "debug" level.
164
197
  *
@@ -168,10 +201,13 @@ const info = (messageId, keyVals, freeText) => {
168
201
  * @memberof webos/pmloglib
169
202
  * @public
170
203
  */
171
- const debug = (freeText) => {
172
- log(levelDebug, '', '', freeText);
173
- };
174
204
 
205
+
206
+ exports.info = info;
207
+
208
+ var debug = function debug(freeText) {
209
+ log(levelDebug, '', '', freeText);
210
+ };
175
211
  /**
176
212
  * Places a time-stamped performance log entry into the system log using the `PmLogInfoWithClock()`
177
213
  * method.
@@ -184,28 +220,22 @@ const debug = (freeText) => {
184
220
  * @memberof webos/pmloglib
185
221
  * @public
186
222
  */
187
- const perfLog = (messageId, perfType, perfGroup) => {
188
- if (typeof window !== 'undefined' && window.PalmSystem) {
189
- if (!messageId) {
190
- console.warn('PmLogInfoWithClock called with invalid format: messageId was empty');
191
- }
192
- if (window.PalmSystem.PmLogInfoWithClock) {
193
- window.PalmSystem.PmLogInfoWithClock(messageId, perfType ? perfType : '',
194
- perfGroup ? perfGroup : '');
195
- } else {
196
- console.error('Unable to send log: PmLogInfoWithClock not found in this version of PalmSystem');
197
- }
198
- }
199
- };
200
223
 
201
- export {
202
- emergency,
203
- alert,
204
- critical,
205
- error,
206
- warning,
207
- notice,
208
- info,
209
- debug,
210
- perfLog
224
+
225
+ exports.debug = debug;
226
+
227
+ var perfLog = function perfLog(messageId, perfType, perfGroup) {
228
+ if (typeof window !== 'undefined' && window.PalmSystem) {
229
+ if (!messageId) {
230
+ console.warn('PmLogInfoWithClock called with invalid format: messageId was empty');
231
+ }
232
+
233
+ if (window.PalmSystem.PmLogInfoWithClock) {
234
+ window.PalmSystem.PmLogInfoWithClock(messageId, perfType ? perfType : '', perfGroup ? perfGroup : '');
235
+ } else {
236
+ console.error('Unable to send log: PmLogInfoWithClock not found in this version of PalmSystem');
237
+ }
238
+ }
211
239
  };
240
+
241
+ exports.perfLog = perfLog;
@@ -1,7 +1,45 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import {findDOMNode} from 'react-dom';
4
- import hoc from '@enact/core/hoc';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VoiceControlDecorator = exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _reactDom = require("react-dom");
13
+
14
+ var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
+
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
+
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
+
22
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+
24
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
+
26
+ 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); } }
27
+
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
+
30
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
+
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
+
34
+ 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); }; }
35
+
36
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
37
+
38
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
+
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
5
43
 
6
44
  /**
7
45
  * VoiceControlDecorator is a higher-order component that adds a callback for voice event
@@ -54,42 +92,61 @@ import hoc from '@enact/core/hoc';
54
92
  * @hoc
55
93
  * @public
56
94
  */
57
- const VoiceControlDecorator = hoc((config, Wrapped) => { // eslint-disable-line no-unused-vars
58
- return class extends React.Component {
59
- static displayName = 'VoiceControlDecorator';
60
-
61
- static propTypes = /** @lends webos/speech.VoiceControlDecorator.prototype */ {
62
- /**
63
- * Callback to be executed when a wrapped element's `data-webos-voice-intent` is activated.
64
- *
65
- * @type {Function}
66
- * @required
67
- * @public
68
- */
69
- onVoice: PropTypes.func.isRequired
70
- };
71
-
72
- componentDidMount () {
73
- this.node = findDOMNode(this); // eslint-disable-line
74
- if (this.node && !(this.node.hasAttribute('data-webos-voice-event-target') || this.node.hasAttribute('data-webos-voice-intent'))) {
75
- this.node = this.node.querySelector('[data-webos-voice-event-target]') || this.node.querySelector('[data-webos-voice-intent]');
76
- }
77
- if (this.node) this.node.addEventListener('webOSVoice', this.props.onVoice);
78
- }
79
-
80
- componentWillUnmount () {
81
- if (this.node) this.node.removeEventListener('webOSVoice', this.props.onVoice);
82
- }
83
-
84
- render () {
85
- const props = {...this.props};
86
- delete props.onVoice;
87
- return (<Wrapped {...props} />);
88
- }
89
- };
90
- });
95
+ var VoiceControlDecorator = (0, _hoc["default"])(function (config, Wrapped) {
96
+ var _class, _temp;
97
+
98
+ // eslint-disable-line no-unused-vars
99
+ return _temp = _class = /*#__PURE__*/function (_React$Component) {
100
+ _inherits(_class, _React$Component);
101
+
102
+ var _super = _createSuper(_class);
91
103
 
92
- export default VoiceControlDecorator;
93
- export {
94
- VoiceControlDecorator
95
- };
104
+ function _class() {
105
+ _classCallCheck(this, _class);
106
+
107
+ return _super.apply(this, arguments);
108
+ }
109
+
110
+ _createClass(_class, [{
111
+ key: "componentDidMount",
112
+ value: function componentDidMount() {
113
+ this.node = (0, _reactDom.findDOMNode)(this); // eslint-disable-line
114
+
115
+ if (this.node && !(this.node.hasAttribute('data-webos-voice-event-target') || this.node.hasAttribute('data-webos-voice-intent'))) {
116
+ this.node = this.node.querySelector('[data-webos-voice-event-target]') || this.node.querySelector('[data-webos-voice-intent]');
117
+ }
118
+
119
+ if (this.node) this.node.addEventListener('webOSVoice', this.props.onVoice);
120
+ }
121
+ }, {
122
+ key: "componentWillUnmount",
123
+ value: function componentWillUnmount() {
124
+ if (this.node) this.node.removeEventListener('webOSVoice', this.props.onVoice);
125
+ }
126
+ }, {
127
+ key: "render",
128
+ value: function render() {
129
+ var props = _objectSpread({}, this.props);
130
+
131
+ delete props.onVoice;
132
+ return /*#__PURE__*/_react["default"].createElement(Wrapped, props);
133
+ }
134
+ }]);
135
+
136
+ return _class;
137
+ }(_react["default"].Component), _class.displayName = 'VoiceControlDecorator', _class.propTypes =
138
+ /** @lends webos/speech.VoiceControlDecorator.prototype */
139
+ {
140
+ /**
141
+ * Callback to be executed when a wrapped element's `data-webos-voice-intent` is activated.
142
+ *
143
+ * @type {Function}
144
+ * @required
145
+ * @public
146
+ */
147
+ onVoice: _propTypes["default"].func.isRequired
148
+ }, _temp;
149
+ });
150
+ exports.VoiceControlDecorator = VoiceControlDecorator;
151
+ var _default = VoiceControlDecorator;
152
+ exports["default"] = _default;
File without changes
package/speech/index.js CHANGED
@@ -1,15 +1,23 @@
1
- /**
2
- * Provides utility functions and higher-order components for working with webOS speech APIs.
3
- *
4
- * @module webos/speech
5
- * @exports readAlert
6
- * @exports VoiceControlDecorator
7
- */
8
-
9
- import readAlert from './readAlert';
10
- import VoiceControlDecorator from './VoiceControlDecorator';
11
-
12
- export {
13
- readAlert,
14
- VoiceControlDecorator
15
- };
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "readAlert", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _readAlert["default"];
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "VoiceControlDecorator", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _VoiceControlDecorator["default"];
16
+ }
17
+ });
18
+
19
+ var _readAlert = _interopRequireDefault(require("./readAlert"));
20
+
21
+ var _VoiceControlDecorator = _interopRequireDefault(require("./VoiceControlDecorator"));
22
+
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -1,53 +1,70 @@
1
- /* eslint-disable no-console */
1
+ "use strict";
2
2
 
3
- import LS2Request from '../LS2Request';
4
- import {platform} from '../platform';
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.readAlert = exports["default"] = void 0;
5
7
 
6
- let audioGuidanceEnabled = null;
8
+ var _LS2Request = _interopRequireDefault(require("../LS2Request"));
7
9
 
8
- const checkAudioGuidance = () => new Promise((resolve, reject) => {
9
- if (audioGuidanceEnabled === null) {
10
- new LS2Request().send({
11
- service: 'luna://com.webos.settingsservice',
12
- method: 'getSystemSettings',
13
- subscribe: true,
14
- parameters: {
15
- 'keys': ['audioGuidance'],
16
- 'category': 'option'
17
- },
18
- onSuccess: function (res) {
19
- if (res && res.settings.audioGuidance === 'on') {
20
- audioGuidanceEnabled = true;
21
- resolve();
22
- return;
23
- }
10
+ var _platform = require("../platform");
24
11
 
25
- audioGuidanceEnabled = false;
26
- reject();
27
- },
28
- onFailure: function (err) {
29
- reject('Failed to get system AudioGuidance settings: ' + JSON.stringify(err));
30
- }
31
- });
32
- } else if (audioGuidanceEnabled) {
33
- resolve();
34
- } else {
35
- reject();
36
- }
37
- });
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
38
13
 
39
- const readAlertMessage = (string, clear) => () => new Promise((resolve, reject) => {
40
- new LS2Request().send({
41
- service: 'luna://com.webos.service.tts',
42
- method: 'speak',
43
- parameters: {'text': string, 'clear': clear},
44
- onSuccess: resolve,
45
- onFailure: (err) => {
46
- reject('Failed to readAlertMessage: ' + JSON.stringify(err));
47
- }
48
- });
49
- });
14
+ /* eslint-disable no-console */
15
+ var audioGuidanceEnabled = null;
16
+
17
+ var checkAudioGuidance = function checkAudioGuidance() {
18
+ return new Promise(function (resolve, reject) {
19
+ if (audioGuidanceEnabled === null) {
20
+ new _LS2Request["default"]().send({
21
+ service: 'luna://com.webos.settingsservice',
22
+ method: 'getSystemSettings',
23
+ subscribe: true,
24
+ parameters: {
25
+ 'keys': ['audioGuidance'],
26
+ 'category': 'option'
27
+ },
28
+ onSuccess: function onSuccess(res) {
29
+ if (res && res.settings.audioGuidance === 'on') {
30
+ audioGuidanceEnabled = true;
31
+ resolve();
32
+ return;
33
+ }
50
34
 
35
+ audioGuidanceEnabled = false;
36
+ reject();
37
+ },
38
+ onFailure: function onFailure(err) {
39
+ reject('Failed to get system AudioGuidance settings: ' + JSON.stringify(err));
40
+ }
41
+ });
42
+ } else if (audioGuidanceEnabled) {
43
+ resolve();
44
+ } else {
45
+ reject();
46
+ }
47
+ });
48
+ };
49
+
50
+ var readAlertMessage = function readAlertMessage(string, clear) {
51
+ return function () {
52
+ return new Promise(function (resolve, reject) {
53
+ new _LS2Request["default"]().send({
54
+ service: 'luna://com.webos.service.tts',
55
+ method: 'speak',
56
+ parameters: {
57
+ 'text': string,
58
+ 'clear': clear
59
+ },
60
+ onSuccess: resolve,
61
+ onFailure: function onFailure(err) {
62
+ reject('Failed to readAlertMessage: ' + JSON.stringify(err));
63
+ }
64
+ });
65
+ });
66
+ };
67
+ };
51
68
  /**
52
69
  * Read alert text when accessibility audio guidance is enabled.
53
70
  *
@@ -58,21 +75,22 @@ const readAlertMessage = (string, clear) => () => new Promise((resolve, reject)
58
75
  * @memberof webos/speech
59
76
  * @public
60
77
  */
61
- const readAlert = (string, clear = true) => {
62
- if (platform.tv) {
63
- checkAudioGuidance()
64
- .then(readAlertMessage(string, clear))
65
- .catch(message => {
66
- if (message) {
67
- console.error(`Failed to readAlert: ${message}`);
68
- }
69
- });
70
- } else {
71
- console.warn('Platform doesn\'t support TTS api.');
72
- }
73
- };
74
78
 
75
- export default readAlert;
76
- export {
77
- readAlert
79
+
80
+ var readAlert = function readAlert(string) {
81
+ var clear = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
82
+
83
+ if (_platform.platform.tv) {
84
+ checkAudioGuidance().then(readAlertMessage(string, clear))["catch"](function (message) {
85
+ if (message) {
86
+ console.error("Failed to readAlert: ".concat(message));
87
+ }
88
+ });
89
+ } else {
90
+ console.warn('Platform doesn\'t support TTS api.');
91
+ }
78
92
  };
93
+
94
+ exports.readAlert = readAlert;
95
+ var _default = readAlert;
96
+ exports["default"] = _default;