@enact/webos 4.7.10 → 4.7.12

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,16 @@
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.7.12] - 2024-09-05
6
+
7
+ ### Added
8
+
9
+ - `webos/signLang` module with `startSignLang()`, `stopSignLang()` functions and `SignLangDecorator` Higher-order Component
10
+
11
+ ## [4.7.11] - 2024-05-13
12
+
13
+ No significant changes.
14
+
5
15
  ## [4.7.10] - 2024-03-05
6
16
 
7
17
  No significant changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/webos",
3
- "version": "4.7.10",
3
+ "version": "4.7.12",
4
4
  "description": "webOS support library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@enact/core": "^4.7.10",
34
+ "@enact/core": "^4.7.12",
35
35
  "prop-types": "^15.8.1",
36
36
  "react": "^18.2.0",
37
37
  "react-dom": "^18.2.0"
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.SignLangDecorator = void 0;
7
+ var _handle = require("@enact/core/handle");
8
+ var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _react = require("react");
11
+ var _signLang = require("./signLang");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ 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; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
19
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
21
+ 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); }
22
+ 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
23
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
+ 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); }; }
25
+ 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); }
26
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
+ 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; } }
28
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
29
+ * Default config for {@link webos/signLang.SignLangDecorator}
30
+ *
31
+ * @type {Object}
32
+ * @hocconfig
33
+ * @memberof webos/signLang.SignLangDecorator
34
+ */
35
+ var defaultConfig = {
36
+ /**
37
+ * Time to wait (in milliseconds) before calling Sign Language API.
38
+ *
39
+ * @type {Number}
40
+ * @default 0
41
+ * @memberof webos/signLang.SignLangDecorator.defaultConfig
42
+ * @public
43
+ */
44
+ signLangDelay: 0
45
+ };
46
+
47
+ /**
48
+ * Usage:
49
+ * ```
50
+ * import Button from '@enact/sandstone/Button';
51
+ * import {SignLangDecorator} from '@enact/webos/signLang';
52
+ * import {Component} from 'react';
53
+ *
54
+ * const SignLangButton = SignLangDecorator(Button);
55
+ *
56
+ * class Sample extends Component {
57
+ * render () {
58
+ * return(
59
+ * <div>
60
+ * <SignLangButton signLangId="settings_audioguide_1">Hello</SignLangButton>
61
+ * </div>
62
+ * );
63
+ * }
64
+ * }
65
+ * ```
66
+ *
67
+ * SignLangDecorator is a higher order component that adds feature for sign language
68
+ * to its wrapped component.
69
+ *
70
+ * @class SignLangDecorator
71
+ * @memberof webos/signLang
72
+ * @hoc
73
+ * @public
74
+ */
75
+ var SignLangDecorator = exports.SignLangDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
76
+ var _class;
77
+ var signLangDelay = config.signLangDelay;
78
+ var forwardBlur = (0, _handle.forward)('onBlur');
79
+ var forwardFocus = (0, _handle.forward)('onFocus');
80
+ return _class = /*#__PURE__*/function (_Component) {
81
+ _inherits(_class, _Component);
82
+ var _super = _createSuper(_class);
83
+ function _class(props) {
84
+ var _this;
85
+ _classCallCheck(this, _class);
86
+ _this = _super.call(this, props);
87
+ _this.requestSignLang = function (active) {
88
+ var _this$props = _this.props,
89
+ _this$props$signLangI = _this$props.signLangId,
90
+ signLangId = _this$props$signLangI === void 0 ? '' : _this$props$signLangI,
91
+ _this$props$signLangO = _this$props.signLangOption,
92
+ signLangOption = _this$props$signLangO === void 0 ? {} : _this$props$signLangO;
93
+ if (signLangId.length > 0) {
94
+ if (active) {
95
+ if (signLangDelay === 0) {
96
+ (0, _signLang.startSignLang)(signLangId, signLangOption);
97
+ } else {
98
+ clearTimeout(_this.signLangDelayId);
99
+ _this.signLangDelayId = setTimeout(function () {
100
+ (0, _signLang.startSignLang)(signLangId, signLangOption);
101
+ }, signLangDelay);
102
+ }
103
+ } else {
104
+ if (signLangDelay > 0) clearTimeout(_this.signLangDelayId);
105
+ (0, _signLang.stopSignLang)(signLangId, signLangOption);
106
+ }
107
+ }
108
+ };
109
+ _this.onFocus = function (ev) {
110
+ forwardFocus(ev, _this.props);
111
+ _this.requestSignLang(true);
112
+ };
113
+ _this.onBlur = function (ev) {
114
+ forwardBlur(ev, _this.props);
115
+ _this.requestSignLang(false);
116
+ };
117
+ _this.signLangDelayId = null;
118
+ return _this;
119
+ }
120
+ _createClass(_class, [{
121
+ key: "render",
122
+ value: function render() {
123
+ var props = Object.assign({}, this.props);
124
+ delete props.onBlur;
125
+ delete props.onFocus;
126
+ delete props.signLangId;
127
+ delete props.signLangOption;
128
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, props), {}, {
129
+ onBlur: this.onBlur,
130
+ onFocus: this.onFocus
131
+ }));
132
+ }
133
+ }]);
134
+ return _class;
135
+ }(_react.Component), _class.displayName = 'SignLangDecorator', _class.propTypes = /** @lends webos/signLang.SignLangDecorator.prototype */{
136
+ /**
137
+ * Unique ID for sign language.
138
+ *
139
+ * @type {String}
140
+ * @public
141
+ */
142
+ signLangId: _propTypes["default"].string,
143
+ /**
144
+ * Additional option for sign language.
145
+ *
146
+ * @type {Object}
147
+ * @public
148
+ */
149
+ signLangOption: _propTypes["default"].object
150
+ }, _class;
151
+ });
152
+ var _default = exports["default"] = SignLangDecorator;
@@ -0,0 +1,38 @@
1
+ // Type definitions for webos/signLang
2
+
3
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4
+ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
+
6
+ export interface SignLangDecoratorConfig extends Object {
7
+ /**
8
+ * Time to wait (in milliseconds) before calling Sign Language API.
9
+ */
10
+ signLangDelay?: number;
11
+ }
12
+ export interface SignLangDecoratorProps {
13
+ /**
14
+ * Unique ID for sign language.
15
+ */
16
+ signLangId?: string;
17
+ /**
18
+ * Additional option for sign language.
19
+ */
20
+ signLangOption?: object;
21
+ }
22
+ export function SignLangDecorator<P>(
23
+ config: SignLangDecoratorConfig,
24
+ Component: React.ComponentType<P> | string,
25
+ ): React.ComponentType<P & SignLangDecoratorProps>;
26
+
27
+ export function SignLangDecorator<P>(
28
+ Component: React.ComponentType<P> | string,
29
+ ): React.ComponentType<P & SignLangDecoratorProps>;
30
+
31
+ /**
32
+ * Activates sign language based on the singLangID.
33
+ */
34
+ export function startSignLang(signLangId: string, option: object): void;
35
+ /**
36
+ * Deactivates sign language based on the signLangID.
37
+ */
38
+ export function stopSignLang(signLangId: string, option: object): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "SignLangDecorator", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _SignLangDecorator["default"];
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "startSignLang", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _signLang.startSignLang;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "stopSignLang", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _signLang.stopSignLang;
22
+ }
23
+ });
24
+ var _signLang = require("./signLang");
25
+ var _SignLangDecorator = _interopRequireDefault(require("./SignLangDecorator"));
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "index.js"
3
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stopSignLang = exports.startSignLang = void 0;
7
+ var _pmloglib = require("@enact/webos/pmloglib");
8
+ var _LS2Request = _interopRequireDefault(require("../LS2Request"));
9
+ var _platform = require("../platform");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ 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; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
15
+ 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); } /* eslint-disable no-console */
16
+ var signLangEnabled = null;
17
+ var appId = '';
18
+ var checkSignLang = function checkSignLang() {
19
+ return new Promise(function (resolve, reject) {
20
+ if (signLangEnabled === null) {
21
+ new _LS2Request["default"]().send({
22
+ service: 'luna://com.webos.settingsservice',
23
+ method: 'getSystemSettings',
24
+ subscribe: true,
25
+ parameters: {
26
+ 'keys': ['signLanguageGuidance'],
27
+ 'category': 'option'
28
+ },
29
+ onSuccess: function onSuccess(res) {
30
+ (0, _pmloglib.info)('enact_signLang_checkSignLang', {
31
+ 'onSuccess': res
32
+ }, '');
33
+ if (res && res.settings.signLanguageGuidance === 'on') {
34
+ signLangEnabled = true;
35
+ appId = typeof window == 'object' && window.PalmSystem && window.PalmSystem.getIdentifier && window.PalmSystem.getIdentifier();
36
+ resolve();
37
+ return;
38
+ }
39
+ signLangEnabled = false;
40
+ reject();
41
+ },
42
+ onFailure: function onFailure(err) {
43
+ (0, _pmloglib.info)('enact_signLang_checkSignLang', {
44
+ 'onFailure': err
45
+ }, '');
46
+ reject('Failed to get sign language setting value: ' + JSON.stringify(err));
47
+ }
48
+ });
49
+ } else if (signLangEnabled) {
50
+ resolve();
51
+ } else {
52
+ reject();
53
+ }
54
+ });
55
+ };
56
+ var callSignLangAPI = function callSignLangAPI(signLangId, active, option) {
57
+ return function () {
58
+ return new Promise(function (resolve, reject) {
59
+ var parameters = _objectSpread({
60
+ appId: appId,
61
+ 'signGuidanceId': signLangId,
62
+ 'focusOut': !active
63
+ }, option);
64
+ (0, _pmloglib.info)('enact_signLang_callSignLangAPI', parameters, '');
65
+ new _LS2Request["default"]().send({
66
+ service: 'luna://com.webos.service.signlanguageavatar',
67
+ method: 'play',
68
+ parameters: parameters,
69
+ onSuccess: resolve,
70
+ onFailure: function onFailure(err) {
71
+ (0, _pmloglib.info)('enact_signLang_callSignLangAPI', {
72
+ 'onFailure': err
73
+ }, '');
74
+ reject('Failed to callSignLangAPI: ' + JSON.stringify(err));
75
+ }
76
+ });
77
+ });
78
+ };
79
+ };
80
+ var requestSignLang = function requestSignLang(signLangId, active) {
81
+ var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
82
+ if (_platform.platform.tv) {
83
+ checkSignLang().then(callSignLangAPI(signLangId, active, option))["catch"](function (message) {
84
+ if (message) {
85
+ console.error("Failed to requestSignLang: ".concat(message));
86
+ }
87
+ });
88
+ } else {
89
+ console.warn('Platform doesn\'t support sing language.');
90
+ }
91
+ };
92
+
93
+ /**
94
+ * Activates sign language based on the singLangID.
95
+ *
96
+ * @function
97
+ * @param {String} [signLangId=''] signLangId Unique ID used for sign language.
98
+ * @param {Object} [option={}] Additional option for sign language.
99
+ * @returns {undefined}
100
+ * @memberof webos/signLang
101
+ * @public
102
+ */
103
+ var startSignLang = exports.startSignLang = function startSignLang() {
104
+ var signLangId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
105
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
106
+ requestSignLang(signLangId, true, option);
107
+ };
108
+
109
+ /**
110
+ * Deactivates sign language based on the signLangID.
111
+ *
112
+ * @function
113
+ * @param {String} [signLangId=''] signLangId Unique ID used for sign language.
114
+ * @param {Object} [option={}] Additional option for sign language.
115
+ * @returns {undefined}
116
+ * @memberof webos/signLang
117
+ * @public
118
+ */
119
+ var stopSignLang = exports.stopSignLang = function stopSignLang() {
120
+ var signLangId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
121
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
122
+ requestSignLang(signLangId, false, option);
123
+ };