@enact/webos 4.0.6

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.
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _util = require("@enact/core/util");
9
+
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+
12
+ 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); } }
13
+
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15
+
16
+ var refs = {};
17
+
18
+ var adjustPath = function adjustPath(path) {
19
+ if (!/^(luna|palm):\/\//.test(path)) path = 'luna://' + path;
20
+ if (path.slice(-1) !== '/') path += '/';
21
+ return path;
22
+ }; // default handlers
23
+
24
+
25
+ var failureHandler = function failureHandler(_ref) {
26
+ var errorText = _ref.errorText;
27
+ return console.error("LS2Request: ".concat(errorText));
28
+ };
29
+
30
+ var timeoutHandler = function timeoutHandler(_ref2) {
31
+ var errorText = _ref2.errorText;
32
+ return console.warn("LS2Request: ".concat(errorText));
33
+ };
34
+ /**
35
+ * A class for managing LS2 Requests.
36
+ *
37
+ * @memberof webos/LS2Request
38
+ * @class
39
+ */
40
+
41
+
42
+ var LS2Request = /*#__PURE__*/function () {
43
+ /**
44
+ * Create a new LS2 request
45
+ *
46
+ * @memberof webos/LS2Request.LS2Request
47
+ * @constructor
48
+ */
49
+ function LS2Request() {
50
+ var _this = this;
51
+
52
+ _classCallCheck(this, LS2Request);
53
+
54
+ this.timeoutJob = new _util.Job(function (_ref3) {
55
+ var onTimeout = _ref3.onTimeout,
56
+ timeout = _ref3.timeout;
57
+ onTimeout({
58
+ errorCode: -2,
59
+ errorText: "Request timed out after ".concat(timeout, " ms."),
60
+ returnValue: false
61
+ }); // cancel the request
62
+
63
+ _this.cancel();
64
+ });
65
+ this.bridge = null;
66
+ this.subscribe = false;
67
+ }
68
+ /**
69
+ * Send a request to an LS2 service method.
70
+ *
71
+ * @method
72
+ * @memberof webos/LS2Request.LS2Request.prototype
73
+ * @param {Object} options Options for the LS2 Request call
74
+ * @param {String} options.service The name of the LS2 service.
75
+ * @param {String} options.method The name of the method.
76
+ * @param {Object} options.parameters Any parameters required by the service method.
77
+ * @param {Function} options.onSuccess The success handler for the request.
78
+ * @param {Function} options.onFailure The failure handler for the request.
79
+ * @param {Function} options.onComplete The handler to run when the request
80
+ * is completed, regardless of return status.
81
+ * @param {Function} options.onTimeout The handler to run when the request
82
+ * times out. Used in conjunction with `timeout`.
83
+ * @param {Boolean} options.subscribe Subscribe to service methods that support subscription.
84
+ * @param {Number} options.timeout The delay in milliseconds to wait for the request to return.
85
+ * @returns {webos/LS2Request}
86
+ * @public
87
+ */
88
+
89
+
90
+ _createClass(LS2Request, [{
91
+ key: "send",
92
+ value: function send(_ref4) {
93
+ var _ref4$service = _ref4.service,
94
+ service = _ref4$service === void 0 ? '' : _ref4$service,
95
+ _ref4$method = _ref4.method,
96
+ method = _ref4$method === void 0 ? '' : _ref4$method,
97
+ _ref4$parameters = _ref4.parameters,
98
+ parameters = _ref4$parameters === void 0 ? {} : _ref4$parameters,
99
+ _ref4$onSuccess = _ref4.onSuccess,
100
+ onSuccess = _ref4$onSuccess === void 0 ? null : _ref4$onSuccess,
101
+ _ref4$onFailure = _ref4.onFailure,
102
+ onFailure = _ref4$onFailure === void 0 ? null : _ref4$onFailure,
103
+ _ref4$onComplete = _ref4.onComplete,
104
+ onComplete = _ref4$onComplete === void 0 ? null : _ref4$onComplete,
105
+ _ref4$onTimeout = _ref4.onTimeout,
106
+ onTimeout = _ref4$onTimeout === void 0 ? timeoutHandler : _ref4$onTimeout,
107
+ _ref4$subscribe = _ref4.subscribe,
108
+ subscribe = _ref4$subscribe === void 0 ? false : _ref4$subscribe,
109
+ _ref4$timeout = _ref4.timeout,
110
+ timeout = _ref4$timeout === void 0 ? 0 : _ref4$timeout;
111
+ this.cancelled = false;
112
+
113
+ if (!onFailure && !onComplete) {
114
+ onFailure = failureHandler;
115
+ }
116
+
117
+ if (typeof window !== 'object' || !window.PalmServiceBridge) {
118
+ /* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
119
+ if (onFailure) onFailure({
120
+ errorCode: -1,
121
+ errorText: 'PalmServiceBridge not found.',
122
+ returnValue: false
123
+ });
124
+ if (onComplete) onComplete({
125
+ errorCode: -1,
126
+ errorText: 'PalmServiceBridge not found.',
127
+ returnValue: false
128
+ });
129
+ console.error('PalmServiceBridge not found.');
130
+ return;
131
+ }
132
+
133
+ if (this.ts && refs[this.ts]) {
134
+ delete refs[this.ts];
135
+ }
136
+
137
+ this.subscribe = subscribe;
138
+
139
+ if (this.subscribe) {
140
+ parameters.subscribe = this.subscribe;
141
+ }
142
+
143
+ if (parameters.subscribe) {
144
+ this.subscribe = parameters.subscribe;
145
+ } // eslint-disable-next-line no-undef
146
+
147
+
148
+ this.ts = performance.now();
149
+ refs[this.ts] = this; // eslint-disable-next-line no-undef
150
+
151
+ this.bridge = new PalmServiceBridge();
152
+ this.bridge.onservicecallback = this.callback.bind(this, onSuccess, onFailure, onComplete);
153
+
154
+ if (timeout) {
155
+ this.timeoutJob.startAfter(timeout, {
156
+ onTimeout: onTimeout,
157
+ timeout: timeout
158
+ });
159
+ }
160
+
161
+ this.bridge.call(adjustPath(service) + method, JSON.stringify(parameters));
162
+ return this;
163
+ }
164
+ }, {
165
+ key: "callback",
166
+ value: function callback(onSuccess, onFailure, onComplete, msg) {
167
+ if (this.cancelled) {
168
+ return;
169
+ } // remove timeout job
170
+
171
+
172
+ this.timeoutJob.stop();
173
+ var parsedMsg;
174
+
175
+ if (msg == null) {
176
+ parsedMsg = {
177
+ errorCode: -1,
178
+ errorText: "Invalid response: ".concat(msg),
179
+ returnValue: false
180
+ };
181
+ } else {
182
+ try {
183
+ parsedMsg = JSON.parse(msg);
184
+ } catch (e) {
185
+ parsedMsg = {
186
+ errorCode: -1,
187
+ errorText: msg,
188
+ returnValue: false
189
+ };
190
+ }
191
+ }
192
+
193
+ if (parsedMsg.errorCode || parsedMsg.returnValue === false) {
194
+ if (onFailure) {
195
+ onFailure(parsedMsg);
196
+ }
197
+ } else if (onSuccess) {
198
+ onSuccess(parsedMsg);
199
+ }
200
+
201
+ if (onComplete) {
202
+ onComplete(parsedMsg);
203
+ }
204
+
205
+ if (!this.subscribe) {
206
+ this.cancel();
207
+ }
208
+ }
209
+ /**
210
+ * Cancel the current LS2 request.
211
+ *
212
+ * @method
213
+ * @memberof webos/LS2Request.LS2Request.prototype
214
+ * @returns {undefined}
215
+ * @public
216
+ */
217
+
218
+ }, {
219
+ key: "cancel",
220
+ value: function cancel() {
221
+ // remove timeout job
222
+ this.timeoutJob.stop();
223
+ this.cancelled = true;
224
+
225
+ if (this.bridge) {
226
+ this.bridge.cancel();
227
+ this.bridge = null;
228
+ }
229
+
230
+ if (this.ts && refs[this.ts]) {
231
+ delete refs[this.ts];
232
+ }
233
+ }
234
+ }]);
235
+
236
+ return LS2Request;
237
+ }();
238
+
239
+ exports["default"] = LS2Request;
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "LS2Request.js"
3
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ var _LS2Request = _interopRequireDefault(require("../LS2Request"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
+
7
+ describe('LS2Request', function () {
8
+ var nop = function nop() {};
9
+
10
+ describe('callback', function () {
11
+ var invalidResponse = '{invalid: json';
12
+ var failedResponse = '{"errorCode": 101}';
13
+ var successfulResponse = '{"returnValue": true}';
14
+ it('should return an error for a null msg', function () {
15
+ var request = new _LS2Request["default"]();
16
+ var onFailure = jest.fn();
17
+ request.callback(nop, onFailure, nop, null);
18
+ var expected = {
19
+ errorCode: -1
20
+ };
21
+ var actual = onFailure.mock.calls[0][0];
22
+ expect(actual).toMatchObject(expected);
23
+ });
24
+ it('should return an error for invalid JSON', function () {
25
+ var request = new _LS2Request["default"]();
26
+ var onFailure = jest.fn();
27
+ request.callback(nop, onFailure, nop);
28
+ var expected = {
29
+ errorCode: -1
30
+ };
31
+ var actual = onFailure.mock.calls[0][0];
32
+ expect(actual).toMatchObject(expected);
33
+ });
34
+ it('should invoke onFailure for a valid, failed request', function () {
35
+ var request = new _LS2Request["default"]();
36
+ var onFailure = jest.fn();
37
+ request.callback(nop, onFailure, nop, failedResponse);
38
+ var expected = {
39
+ errorCode: 101
40
+ };
41
+ var actual = onFailure.mock.calls[0][0];
42
+ expect(actual).toMatchObject(expected);
43
+ });
44
+ it('should invoke onSuccess for a valid request', function () {
45
+ var request = new _LS2Request["default"]();
46
+ var onSuccess = jest.fn();
47
+ request.callback(onSuccess, nop, nop, successfulResponse);
48
+ var expected = {
49
+ returnValue: true
50
+ };
51
+ var actual = onSuccess.mock.calls[0][0];
52
+ expect(actual).toMatchObject(expected);
53
+ });
54
+ it('should invoke onComplete for a valid request', function () {
55
+ var request = new _LS2Request["default"]();
56
+ var onComplete = jest.fn();
57
+ request.callback(nop, nop, onComplete, successfulResponse);
58
+ var expected = {
59
+ returnValue: true
60
+ };
61
+ var actual = onComplete.mock.calls[0][0];
62
+ expect(actual).toMatchObject(expected);
63
+ });
64
+ it('should invoke onComplete for an invalid request', function () {
65
+ var request = new _LS2Request["default"]();
66
+ var onComplete = jest.fn();
67
+ request.callback(nop, nop, onComplete, invalidResponse);
68
+ var expected = {
69
+ errorCode: -1
70
+ };
71
+ var actual = onComplete.mock.calls[0][0];
72
+ expect(actual).toMatchObject(expected);
73
+ });
74
+ it('should invoke onComplete for a valid, failed request', function () {
75
+ var request = new _LS2Request["default"]();
76
+ var onComplete = jest.fn();
77
+ request.callback(nop, nop, onComplete, failedResponse);
78
+ var expected = {
79
+ errorCode: 101
80
+ };
81
+ var actual = onComplete.mock.calls[0][0];
82
+ expect(actual).toMatchObject(expected);
83
+ });
84
+ });
85
+ });
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @enact/webos [![npm (scoped)](https://img.shields.io/npm/v/@enact/webos.svg?style=flat-square)](https://www.npmjs.com/package/@enact/webos)
2
+
3
+ > Utility functions for working with webOS devices.
4
+
5
+ ## Install
6
+
7
+ ```
8
+ npm install --save @enact/webos
9
+ ```
10
+
11
+ ## Copyright and License Information
12
+
13
+ Unless otherwise specified, all content, including all source code files and documentation files in this repository are:
14
+
15
+ Copyright (c) 2012-2021 LG Electronics
16
+
17
+ Unless otherwise specified or set forth in the NOTICE file, all content, including all source code files and documentation files in this repository are: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this content except in compliance with the License. You may obtain a copy of the License at
18
+
19
+ http://www.apache.org/licenses/LICENSE-2.0
20
+
21
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
22
+
@@ -0,0 +1,32 @@
1
+ // Type definitions for webos/application
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
+ /**
7
+ * Fetches the appID of the caller app.
8
+ */
9
+ export function fetchAppId(): string;
10
+ /**
11
+ * The callback signature for `fetchAppInfo`
12
+ */
13
+ export interface appInfoCallback {
14
+ (
15
+ /**
16
+ * JSON data object read from the app's _appinfo.json_ file. `undefined` if not found.
17
+ */
18
+ info: any
19
+ ): void;
20
+ }
21
+ /**
22
+ * Fetches the _appinfo.json_ data of the caller app.
23
+ */
24
+ export function fetchAppInfo(callback: appInfoCallback, path?: string): void;
25
+ /**
26
+ * Fetches the full root URI (path) of the caller app.
27
+ */
28
+ export function fetchAppRootPath(): string;
29
+ /**
30
+ * Emulate the remote _back_ key.
31
+ */
32
+ export function platformBack(): void;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.platformBack = exports.fetchAppRootPath = exports.fetchAppInfo = exports.fetchAppId = void 0;
7
+
8
+ /* eslint-disable no-console */
9
+
10
+ /**
11
+ * Provides a collection of functions for fetching application metadata.
12
+ *
13
+ * @module webos/application
14
+ * @exports fetchAppId,
15
+ * @exports fetchAppInfo,
16
+ * @exports fetchAppRootPath,
17
+ * @exports platformBack
18
+ */
19
+ var appInfo = {};
20
+ /**
21
+ * Fetches the appID of the caller app.
22
+ *
23
+ * @function
24
+ * @returns {String} AppID of the app
25
+ * @memberof webos/application
26
+ * @public
27
+ */
28
+
29
+ var fetchAppId = function fetchAppId() {
30
+ if (window.PalmSystem && window.PalmSystem.identifier) {
31
+ // PalmSystem.identifier: <appid> <processid>
32
+ return window.PalmSystem.identifier.split(' ')[0];
33
+ }
34
+ };
35
+ /**
36
+ * The callback signature for `fetchAppInfo`
37
+ *
38
+ * @callback appInfoCallback
39
+ * @param {?object} info - JSON data object read from the app's *appinfo.json* file. `undefined` if not found.
40
+ * @memberof webos/application
41
+ */
42
+
43
+ /**
44
+ * Fetches the *appinfo.json* data of the caller app.
45
+ *
46
+ * @function
47
+ * @param {webos/application~appInfoCallback} callback - Called upon completion
48
+ * @param {String} [path] - Optional relative filepath to a specific *appinfo.json* to read
49
+ * @returns {undefined}
50
+ * @memberof webos/application
51
+ * @public
52
+ */
53
+
54
+
55
+ exports.fetchAppId = fetchAppId;
56
+
57
+ var fetchAppInfo = function fetchAppInfo(callback, path) {
58
+ if (Object.keys(appInfo).length === 0) {
59
+ var parseInfo = function parseInfo(err, info) {
60
+ if (!err && info) {
61
+ try {
62
+ appInfo = JSON.parse(info);
63
+ if (callback) callback(appInfo);
64
+ } catch (e) {
65
+ console.error('Unable to parse appinfo.json file for ' + fetchAppId);
66
+ if (callback) callback();
67
+ }
68
+ } else if (callback) {
69
+ callback();
70
+ }
71
+ };
72
+
73
+ var req = new window.XMLHttpRequest();
74
+
75
+ req.onreadystatechange = function () {
76
+ if (req.readyState === 4) {
77
+ if (req.status >= 200 && req.status < 300 || req.status === 0) {
78
+ parseInfo(null, req.responseText);
79
+ } else {
80
+ parseInfo({
81
+ status: 404
82
+ });
83
+ }
84
+ }
85
+ };
86
+
87
+ try {
88
+ req.open('GET', path || 'appinfo.json', true);
89
+ req.send(null);
90
+ } catch (e) {
91
+ parseInfo({
92
+ status: 404
93
+ });
94
+ }
95
+ } else if (callback) {
96
+ callback(appInfo);
97
+ }
98
+ };
99
+ /**
100
+ * Fetches the full root URI (path) of the caller app.
101
+ *
102
+ * @function
103
+ * @returns {String} App's URI (application install path)
104
+ * @memberof webos/application
105
+ * @public
106
+ */
107
+
108
+
109
+ exports.fetchAppInfo = fetchAppInfo;
110
+
111
+ var fetchAppRootPath = function fetchAppRootPath() {
112
+ var base = window.location.href;
113
+
114
+ if ('baseURI' in window.document) {
115
+ base = window.document.baseURI;
116
+ } else {
117
+ var baseTags = window.document.getElementsByTagName('base');
118
+
119
+ if (baseTags.length > 0) {
120
+ base = baseTags[0].href;
121
+ }
122
+ }
123
+
124
+ var match = base.match(new RegExp('.*://[^#]*/'));
125
+
126
+ if (match) {
127
+ return match[0];
128
+ }
129
+
130
+ return '';
131
+ };
132
+ /**
133
+ * Emulate the remote *back* key.
134
+ *
135
+ * @function
136
+ * @returns {undefined}
137
+ * @memberof webos/application
138
+ * @public
139
+ */
140
+
141
+
142
+ exports.fetchAppRootPath = fetchAppRootPath;
143
+
144
+ var platformBack = function platformBack() {
145
+ if (window.PalmSystem && window.PalmSystem.platformBack) {
146
+ return window.PalmSystem.platformBack();
147
+ }
148
+ };
149
+
150
+ exports.platformBack = platformBack;
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "application.js"
3
+ }
@@ -0,0 +1,22 @@
1
+ // Type definitions for webos/deviceinfo
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
+ /**
7
+ * Callback signature for `deviceinfo`
8
+ */
9
+ export interface deviceCallback {
10
+ (
11
+ /**
12
+ * JSON object containing the device information details
13
+ */
14
+ info: object
15
+ ): void;
16
+ }
17
+ /**
18
+ * Gets the device-specific information regarding model, OS version, specifications, etc.
19
+ */
20
+ export function deviceinfo(callback: deviceCallback): void;
21
+
22
+ export default deviceinfo;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deviceinfo = exports["default"] = void 0;
7
+
8
+ var _LS2Request = _interopRequireDefault(require("../LS2Request"));
9
+
10
+ var _platform = require("../platform");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
14
+ /**
15
+ * Provides a function to get the device-specific information.
16
+ *
17
+ * @module webos/deviceinfo
18
+ * @exports deviceinfo
19
+ */
20
+ var device = {};
21
+ /**
22
+ * Callback signature for `deviceinfo`
23
+ *
24
+ * @callback deviceCallback
25
+ * @param {Object} info - JSON object containing the device information details
26
+ * @param {String} info.modelName Model name of device in UTF-8 format
27
+ * @param {String} info.modelNameAscii Model name of device in ASCII format
28
+ * @param {String} info.version Full OS firmware version string
29
+ * @param {Number} info.versionMajor Subset of OS version string: Major version number
30
+ * @param {Number} info.versionMinor Subset of OS version string: Minor version number
31
+ * @param {Number} info.versionDot Subset of OS version string: Dot version number
32
+ * @param {String} info.sdkVersion webOS SDK version
33
+ * @param {Number} info.screenWidth Width in pixels
34
+ * @param {Number} info.screenHeight Height in pixels
35
+ * @param {Boolean} [info.uhd] Whether supports Ultra HD resolution.
36
+ * @memberof webos/deviceinfo
37
+ */
38
+
39
+ /**
40
+ * Gets the device-specific information regarding model, OS version, specifications, etc.
41
+ *
42
+ * @function
43
+ * @param {webos/deviceinfo~deviceCallback} callback - Called once the information is collected
44
+ * @returns {undefined}
45
+ * @memberof webos/deviceinfo
46
+ * @public
47
+ */
48
+
49
+ var deviceinfo = function deviceinfo(callback) {
50
+ if (Object.keys(device).length === 0) {
51
+ try {
52
+ var info = JSON.parse(window.PalmSystem.deviceInfo);
53
+ device.modelName = info.modelName;
54
+ device.modelNameAscii = info.modelNameAscii;
55
+ device.version = info.platformVersion;
56
+ device.versionMajor = info.platformVersionMajor;
57
+ device.versionMinor = info.platformVersionMinor;
58
+ device.versionDot = info.platformVersionDot;
59
+ device.sdkVersion = info.platformVersion;
60
+ device.screenWidth = info.screenWidth;
61
+ device.screenHeight = info.screenHeight;
62
+ } catch (e) {
63
+ device.modelName = device.modelNameAscii = 'webOS Device';
64
+ }
65
+
66
+ device.screenHeight = device.screenHeight || window.screen.height;
67
+ device.screenWidth = device.screenWidth || window.screen.width;
68
+
69
+ if (_platform.platform.tv) {
70
+ new _LS2Request["default"]().send({
71
+ service: 'luna://com.webos.service.tv.systemproperty',
72
+ method: 'getSystemInfo',
73
+ parameters: {
74
+ 'keys': ['firmwareVersion', 'modelName', 'sdkVersion', 'UHD']
75
+ },
76
+ onSuccess: function onSuccess(response) {
77
+ device.modelName = response.modelName || device.modelName;
78
+ device.modelNameAscii = response.modelName || device.modelNameAscii;
79
+ device.sdkVersion = response.sdkVersion || device.sdkVersion;
80
+ device.uhd = response.UHD === 'true';
81
+
82
+ if (!response.firmwareVersion || response.firmwareVersion === '0.0.0') {
83
+ response.firmwareVersion = response.sdkVersion;
84
+ }
85
+
86
+ if (response.firmwareVersion) {
87
+ device.version = response.firmwareVersion;
88
+ var segments = device.version.split('.');
89
+ var keys = ['versionMajor', 'versionMinor', 'versionDot'];
90
+
91
+ for (var i = 0; i < keys.length; i++) {
92
+ try {
93
+ device[keys[i]] = parseInt(segments[i]);
94
+ } catch (e) {
95
+ device[keys[i]] = segments[i];
96
+ }
97
+ }
98
+ }
99
+
100
+ callback(device);
101
+ },
102
+ onFailure: function onFailure() {
103
+ callback(device);
104
+ }
105
+ });
106
+ }
107
+ } else {
108
+ callback(device);
109
+ }
110
+ };
111
+
112
+ exports.deviceinfo = deviceinfo;
113
+ var _default = deviceinfo;
114
+ exports["default"] = _default;
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "deviceinfo.js"
3
+ }
package/index.d.ts ADDED
File without changes
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // This space intentionally left blank
2
+ "use strict";
@@ -0,0 +1,9 @@
1
+ // Type definitions for webos/keyboard
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
+ /**
7
+ * Checks if the virtual keyboard is visible (only works on SmartTV platform).
8
+ */
9
+ export function isShowing(): boolean;