senza-sdk 4.2.64-70c0747.0 → 4.2.65-157c9bb.0
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/dist/bundle.js +1 -1
- package/package.json +7 -15
- package/src/{implementation/alarmManager.js → alarmManager.js} +52 -15
- package/src/api.js +350 -183
- package/src/{implementation/deviceManager.js → deviceManager.js} +65 -4
- package/src/{implementation/lifecycle.js → lifecycle.js} +216 -29
- package/src/{implementation/messageManager.js → messageManager.js} +6 -6
- package/src/{implementation/platformManager.js → platformManager.js} +4 -5
- package/src/{implementation/remotePlayer.js → remotePlayer.js} +23 -19
- package/src/{implementation/senzaShakaPlayer.js → senzaShakaPlayer.js} +28 -18
- package/src/{implementation/utils.js → utils.js} +6 -15
- package/src/implementation/api.js +0 -367
- package/src/interface/alarmManager.js +0 -69
- package/src/interface/api.js +0 -8
- package/src/interface/deviceManager.js +0 -133
- package/src/interface/lifecycle.js +0 -278
- package/src/interface/messageManager.js +0 -46
- package/src/interface/platformManager.js +0 -35
- package/src/interface/remotePlayer.js +0 -441
- package/src/interface/senzaShakaPlayer.js +0 -171
- package/src/interface/utils.js +0 -45
- /package/src/{implementation/SessionInfo.js → SessionInfo.js} +0 -0
- /package/src/{implementation/devHelper.js → devHelper.js} +0 -0
- /package/src/{interface/devSequence.js → devSequence.js} +0 -0
- /package/src/{implementation/eventListenersManager.js → eventListenersManager.js} +0 -0
- /package/src/{implementation/subtitlesUtils.js → subtitlesUtils.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senza-sdk",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.65-157c9bb.0",
|
|
4
4
|
"main": "./src/api.js",
|
|
5
5
|
"description": "API for Senza application",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,13 +11,11 @@
|
|
|
11
11
|
"homepage": "https://senza.synamedia.com",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"clean": "rm -rf dist",
|
|
14
|
-
"
|
|
14
|
+
"prepublish": "npm run build",
|
|
15
15
|
"eslint": "eslint --max-warnings 0 src test",
|
|
16
|
-
"build": "
|
|
17
|
-
"build:interface": "npx webpack --config interface.webpack.config.js",
|
|
18
|
-
"build:implementation": "npx webpack --config implementation.webpack.config.js",
|
|
16
|
+
"build": "npx webpack --config webpack.config.js",
|
|
19
17
|
"test": "jest --coverage --verbose",
|
|
20
|
-
"testall": "
|
|
18
|
+
"testall": "jest --coverage --verbose && npm run eslint --fix"
|
|
21
19
|
},
|
|
22
20
|
"devDependencies": {
|
|
23
21
|
"@babel/cli": "^7.13.16",
|
|
@@ -45,15 +43,9 @@
|
|
|
45
43
|
"coverageThreshold": {
|
|
46
44
|
"global": {
|
|
47
45
|
"branches": 88,
|
|
48
|
-
"functions":
|
|
49
|
-
"lines":
|
|
50
|
-
"statements":
|
|
51
|
-
},
|
|
52
|
-
"src/interface": {
|
|
53
|
-
"branches": 69.38,
|
|
54
|
-
"functions": 52.72,
|
|
55
|
-
"lines": 71.95,
|
|
56
|
-
"statements": 72.16
|
|
46
|
+
"functions": 93,
|
|
47
|
+
"lines": 94,
|
|
48
|
+
"statements": 94
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
51
|
},
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import { AlarmManager as AlarmManagerInterface } from "../interface/alarmManager";
|
|
2
1
|
import { getFCID, sdkLogger } from "./utils";
|
|
3
2
|
import { EventListenersManager } from "./eventListenersManager";
|
|
4
3
|
import { lifecycle } from "./lifecycle";
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* AlarmManager is a singleton class that manages the alarms in the application. It fires events whose types are the names of the alarms.
|
|
7
|
+
* @fires MyAlarm
|
|
8
|
+
*/
|
|
9
|
+
class AlarmManager extends EventTarget {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* alarm event
|
|
13
|
+
*
|
|
14
|
+
* @event AlarmManager#MyAlarm
|
|
15
|
+
* @description Fired when time of 'MyAlarm' arrives. If this alarm triggers the application load and the application doesn't call
|
|
16
|
+
* lifecycle.moveToForeground() in the alarm callback (i.e. the application remains in the background after the callback is completed),
|
|
17
|
+
* the application will be unloaded.
|
|
18
|
+
* NOTE: If you perform async operations in the callback (without moving to foreground), you must wait for the async
|
|
19
|
+
* operation to finish before returning from the callback, otherwise the application will be unloaded before the async operation is finished.<br>
|
|
20
|
+
* @example
|
|
21
|
+
* alarmManager.addEventListener("MyAlarm", async (e) => {
|
|
22
|
+
* console.log("alarm MyAlarm arrived with data", e.detail);
|
|
23
|
+
* await fetch("http://www.example.com");
|
|
24
|
+
* });
|
|
25
|
+
* alarmManager.addAlarm("MyAlarm", Date.now() + 60*60*1000, "MyData");
|
|
26
|
+
*/
|
|
7
27
|
constructor() {
|
|
8
28
|
super();
|
|
9
29
|
|
|
@@ -16,10 +36,10 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
16
36
|
timeoutMs: 15000 // Default timeout of 15 seconds, can be overridden by _setDefaultTimeout
|
|
17
37
|
});
|
|
18
38
|
|
|
19
|
-
typeof document !== "undefined" && document.addEventListener("hs/alarmFiredEvent",
|
|
39
|
+
typeof document !== "undefined" && document.addEventListener("hs/alarmFiredEvent",async (e) => {
|
|
20
40
|
|
|
21
41
|
if (e.detail?.alarmName) {
|
|
22
|
-
const logger = sdkLogger.withFields({
|
|
42
|
+
const logger = sdkLogger.withFields({alarmName: e.detail?.alarmName});
|
|
23
43
|
logger.log("Got hs/alarmFiredEvent", JSON.stringify(e.detail));
|
|
24
44
|
|
|
25
45
|
const timeBeforeAlarmHandling = Date.now();
|
|
@@ -33,7 +53,7 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
33
53
|
this._targetState = sourceState;
|
|
34
54
|
|
|
35
55
|
// Create the custom event with payload
|
|
36
|
-
const event = new CustomEvent(e.detail.alarmName, {
|
|
56
|
+
const event = new CustomEvent(e.detail.alarmName, {detail: e.detail.payload});
|
|
37
57
|
|
|
38
58
|
// Dispatch the event and wait for all listeners
|
|
39
59
|
await this._eventManager.dispatch(e.detail.alarmName, event);
|
|
@@ -47,7 +67,7 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
47
67
|
if (!this._moveToForegroundHasBeenCalled && window.cefQuery) {
|
|
48
68
|
logger.log("Application is about to be terminated since didn't move to foreground");
|
|
49
69
|
const message = { type: "terminating" };
|
|
50
|
-
const request = { target:
|
|
70
|
+
const request = { target:"TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
51
71
|
window.cefQuery({
|
|
52
72
|
request: JSON.stringify(request),
|
|
53
73
|
persistent: false,
|
|
@@ -93,7 +113,7 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
93
113
|
this._eventManager.addEventListener(type, callback);
|
|
94
114
|
}
|
|
95
115
|
|
|
96
|
-
removeEventListener(type, callback)
|
|
116
|
+
removeEventListener(type, callback){
|
|
97
117
|
this._eventManager.removeEventListener(type, callback);
|
|
98
118
|
}
|
|
99
119
|
|
|
@@ -106,12 +126,17 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
106
126
|
this._targetState = "background";
|
|
107
127
|
}
|
|
108
128
|
|
|
129
|
+
/** Set alarm to be fired at the specified time, event when ui is released
|
|
130
|
+
* @param {string} alarmName unique name for the alarm
|
|
131
|
+
* @param {number} alarmTime target time for the alarm to be fired, represented by the number of milliseconds elapsed since the epoch
|
|
132
|
+
* @param {string} [data] data to be passed back when the alarm is fired
|
|
133
|
+
* */
|
|
109
134
|
addAlarm(alarmName, alarmTime, data = "", toleranceBefore = 0, toleranceAfter = 0) {
|
|
110
135
|
if (typeof data !== "string") {
|
|
111
136
|
throw Error("data must be a string");
|
|
112
137
|
}
|
|
113
138
|
const FCID = getFCID();
|
|
114
|
-
const logger = sdkLogger.withFields({
|
|
139
|
+
const logger = sdkLogger.withFields({alarmName, FCID});
|
|
115
140
|
logger.log(`addAlarm called for ${alarmName} to be fired at ${alarmTime} with tolerance of ${toleranceBefore} minutes before and ${toleranceAfter} minutes after`);
|
|
116
141
|
if (window.cefQuery) {
|
|
117
142
|
const message = {
|
|
@@ -119,11 +144,11 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
119
144
|
fcid: FCID,
|
|
120
145
|
alarmName,
|
|
121
146
|
alarmTime,
|
|
122
|
-
toleranceBefore: Math.trunc(toleranceBefore
|
|
123
|
-
toleranceAfter: Math.trunc(toleranceAfter
|
|
147
|
+
toleranceBefore: Math.trunc(toleranceBefore*60*1000),
|
|
148
|
+
toleranceAfter: Math.trunc(toleranceAfter*60*1000),
|
|
124
149
|
payload: data
|
|
125
150
|
};
|
|
126
|
-
const request = { target:
|
|
151
|
+
const request = { target:"TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
127
152
|
window.cefQuery({
|
|
128
153
|
request: JSON.stringify(request),
|
|
129
154
|
persistent: false,
|
|
@@ -139,9 +164,13 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
139
164
|
}
|
|
140
165
|
}
|
|
141
166
|
|
|
167
|
+
/** Delete the specified alarm
|
|
168
|
+
* @param {string} alarmName name of alarm to be deleted
|
|
169
|
+
*
|
|
170
|
+
* */
|
|
142
171
|
deleteAlarm(alarmName) {
|
|
143
172
|
const FCID = getFCID();
|
|
144
|
-
const logger = sdkLogger.withFields({
|
|
173
|
+
const logger = sdkLogger.withFields({alarmName, FCID});
|
|
145
174
|
logger.log(`deleteAlarm called for ${alarmName}`);
|
|
146
175
|
if (window.cefQuery) {
|
|
147
176
|
const message = {
|
|
@@ -149,7 +178,7 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
149
178
|
fcid: FCID,
|
|
150
179
|
alarmName
|
|
151
180
|
};
|
|
152
|
-
const request = { target:
|
|
181
|
+
const request = { target:"TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
153
182
|
window.cefQuery({
|
|
154
183
|
request: JSON.stringify(request),
|
|
155
184
|
persistent: false,
|
|
@@ -165,15 +194,18 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
165
194
|
}
|
|
166
195
|
}
|
|
167
196
|
|
|
197
|
+
/** Delete all alarms
|
|
198
|
+
*
|
|
199
|
+
* */
|
|
168
200
|
deleteAllAlarms() {
|
|
169
201
|
if (window.cefQuery) {
|
|
170
202
|
const FCID = getFCID();
|
|
171
|
-
const logger = sdkLogger.withFields({
|
|
203
|
+
const logger = sdkLogger.withFields({FCID});
|
|
172
204
|
const message = {
|
|
173
205
|
type: "deleteAllAlarms",
|
|
174
206
|
fcid: FCID
|
|
175
207
|
};
|
|
176
|
-
const request = { target:
|
|
208
|
+
const request = { target:"TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
177
209
|
window.cefQuery({
|
|
178
210
|
request: JSON.stringify(request),
|
|
179
211
|
persistent: false,
|
|
@@ -189,6 +221,11 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
189
221
|
}
|
|
190
222
|
}
|
|
191
223
|
|
|
224
|
+
/** Async function that asks for all active alarms
|
|
225
|
+
* @returns {Promise} when resolved, returns an array of objects containing alarmName and alarmTime fields
|
|
226
|
+
* @throws {string} error string in case of an error
|
|
227
|
+
*
|
|
228
|
+
* */
|
|
192
229
|
getActiveAlarms() {
|
|
193
230
|
throw Error("NOT IMPLEMENTED");
|
|
194
231
|
// if (window.cefQuery) {
|