senza-sdk 4.2.64-70c0747.0 → 4.2.65-4527e57.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/dist/bundle.js.LICENSE.txt +4 -0
- package/package.json +9 -16
- package/src/{implementation/alarmManager.js → alarmManager.js} +52 -15
- package/src/api.js +350 -183
- package/src/{interface/devSequence.js → devSequence.js} +35 -0
- package/src/{implementation/deviceManager.js → deviceManager.js} +65 -4
- package/src/{implementation/lifecycle.js → lifecycle.js} +182 -5
- 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} +139 -7
- package/src/{implementation/senzaShakaPlayer.js → senzaShakaPlayer.js} +114 -25
- 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/{implementation/eventListenersManager.js → eventListenersManager.js} +0 -0
- /package/src/{implementation/subtitlesUtils.js → subtitlesUtils.js} +0 -0
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { getFCID, sdkLogger, getVersion } from "./utils.js";
|
|
2
|
-
import { sessionInfo } from "./SessionInfo.js";
|
|
3
|
-
import { lifecycle } from "./lifecycle.js";
|
|
4
|
-
import { alarmManager } from "./alarmManager.js";
|
|
5
|
-
|
|
6
|
-
let authToken;
|
|
7
|
-
|
|
8
|
-
const API_VERSION = "1.0";
|
|
9
|
-
let interfaceVersion;
|
|
10
|
-
|
|
11
|
-
typeof document !== "undefined" && document.addEventListener("keydown", (event) => {
|
|
12
|
-
sdkLogger.log(`Got ${event.key} key`);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/** @namespace auth
|
|
16
|
-
*@example
|
|
17
|
-
* import { auth } from "senza-sdk";
|
|
18
|
-
**/
|
|
19
|
-
export const auth = {
|
|
20
|
-
|
|
21
|
-
/** Should be called upon startup and be embedded in future requests */
|
|
22
|
-
getToken,
|
|
23
|
-
|
|
24
|
-
/** Should be called upon '401' event (unauthorized) */
|
|
25
|
-
forceTokenUpdate,
|
|
26
|
-
|
|
27
|
-
getClientAssertion
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
import { remotePlayer } from "./remotePlayer.js";
|
|
32
|
-
export { remotePlayer };
|
|
33
|
-
|
|
34
|
-
/** Should be called once to init the library
|
|
35
|
-
*@example
|
|
36
|
-
* import { init } from "senza-sdk";
|
|
37
|
-
* await init();
|
|
38
|
-
**/
|
|
39
|
-
export async function init(interfaceApiVersion, showSequenceFunc, initSequenceFunc) {
|
|
40
|
-
interfaceVersion = interfaceApiVersion;
|
|
41
|
-
sdkLogger.addfields({ interfaceVersion });
|
|
42
|
-
sdkLogger.log(`init. Interface version: ${interfaceVersion}. Implementation version: ${getVersion()}`);
|
|
43
|
-
|
|
44
|
-
if (!window.diagnostics) {
|
|
45
|
-
// ------------------------------------------------------------------------------------------------
|
|
46
|
-
// -- Do NOT change this log, as ui-streamer is checking this string to detect abnormal behavior --
|
|
47
|
-
// ------------------------------------------------------------------------------------------------
|
|
48
|
-
sdkLogger.error("[ init ] window.diagnostics is undefined");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (window.cefQuery) {
|
|
52
|
-
|
|
53
|
-
// First, check compatability with ui-streamer api version
|
|
54
|
-
await new Promise((resolve, reject) => {
|
|
55
|
-
window.cefQuery({
|
|
56
|
-
request: "apiVersion " + API_VERSION,
|
|
57
|
-
persistent: false,
|
|
58
|
-
onSuccess: () => {
|
|
59
|
-
sdkLogger.log("api version compatability check succeeded");
|
|
60
|
-
resolve();
|
|
61
|
-
},
|
|
62
|
-
onFailure: (code, msg) => {
|
|
63
|
-
sdkLogger.error("api version compatability check failed: " + msg);
|
|
64
|
-
reject(msg);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const sessionInfoStr = await new Promise((resolve) => {
|
|
70
|
-
window.cefQuery({
|
|
71
|
-
request: "sessionInfo",
|
|
72
|
-
persistent: false,
|
|
73
|
-
onSuccess: (response) => {
|
|
74
|
-
sdkLogger.log("sessionInfo request successfully returned " + response);
|
|
75
|
-
resolve(response);
|
|
76
|
-
},
|
|
77
|
-
onFailure: (code, msg) => {
|
|
78
|
-
sdkLogger.error(`sessionInfo request failed: ${code} ${msg}`);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
sessionInfo.setSessionInfoStr(sessionInfoStr);
|
|
84
|
-
const sessionInfoObj = JSON.parse(sessionInfoStr);
|
|
85
|
-
authToken = sessionInfoObj?.settings?.webUI?.backendHeaders?.Authorization;
|
|
86
|
-
sdkLogger.log(`authToken: token = ${authToken}`);
|
|
87
|
-
// Listen to updateSession event to set the new token
|
|
88
|
-
document.addEventListener("updateSession", (e) => {
|
|
89
|
-
authToken = e.detail?.updateObj;
|
|
90
|
-
sdkLogger.log(`onUpdateSessionEvent: token = ${authToken}`);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Set default alarm timeout using UI-Streamer settings
|
|
94
|
-
const alarmTimeout = sessionInfoObj?.settings?.["ui-streamer"]?.alarmTimeout;
|
|
95
|
-
if (alarmTimeout) {
|
|
96
|
-
alarmManager._setDefaultTimeout(alarmTimeout);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Get trigger event
|
|
100
|
-
const triggerEventStr = await new Promise((resolve) => {
|
|
101
|
-
const FCID = getFCID();
|
|
102
|
-
const logger = sdkLogger.withFields({ FCID });
|
|
103
|
-
const message = { type: "triggerEvent", fcid: FCID };
|
|
104
|
-
const request = { target: "UI-Streamer", waitForResponse: false, message: JSON.stringify(message) };
|
|
105
|
-
window.cefQuery({
|
|
106
|
-
request: JSON.stringify(request),
|
|
107
|
-
persistent: false,
|
|
108
|
-
onSuccess: (response) => {
|
|
109
|
-
logger.log(`triggerEvent request successfully returned '${response}'`);
|
|
110
|
-
resolve(response);
|
|
111
|
-
},
|
|
112
|
-
onFailure: (code, msg) => {
|
|
113
|
-
logger.error(`triggerEvent request failed: ${code} ${msg}`);
|
|
114
|
-
resolve("");
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
let triggerEvent = {};
|
|
119
|
-
if (triggerEventStr) {
|
|
120
|
-
try {
|
|
121
|
-
triggerEvent = JSON.parse(triggerEventStr);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
sdkLogger.error(`failed to parse trigger event string ${triggerEventStr}: ${e.message}`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Initialize lifecycle first to make sure the state is updated.
|
|
128
|
-
await lifecycle._init(sessionInfoObj?.settings?.["ui-streamer"], triggerEvent);
|
|
129
|
-
await remotePlayer._init(sessionInfoObj?.settings?.["ui-streamer"], triggerEvent);
|
|
130
|
-
|
|
131
|
-
const devSequence = sessionInfoObj?.settings?.["ui-streamer"]?.devSequence;
|
|
132
|
-
if (devSequence) {
|
|
133
|
-
initSequenceFunc({ lifecycle, remotePlayer });
|
|
134
|
-
showSequenceFunc(true);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
} else {
|
|
138
|
-
authToken = getPlatformInfo().sessionInfo?.settings?.webUI?.backendHeaders?.Authorization;
|
|
139
|
-
sdkLogger.log(`authToken dummy: token = ${authToken}`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// override window.close() since it's not allowed to close the application this way
|
|
143
|
-
window.close = () => {
|
|
144
|
-
sdkLogger.warn("window.close is disabled on Senza platform. Use lifecycle.exitApplication() instead.");
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Returns the platform information, including version, pod, pod ip and session info.
|
|
151
|
-
export function getPlatformInfo() {
|
|
152
|
-
if (typeof window !== "undefined" && window.diagnostics) {
|
|
153
|
-
try {
|
|
154
|
-
const platformInfo = window.diagnostics() || {};
|
|
155
|
-
platformInfo.sessionInfo = sessionInfo.sessionInfoObj;
|
|
156
|
-
return platformInfo;
|
|
157
|
-
} catch (e) {
|
|
158
|
-
sdkLogger.error("Could not get platform info", e.stack);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
} else {
|
|
162
|
-
if (typeof window !== "undefined" && !window.diagnostics) {
|
|
163
|
-
sdkLogger.error("[ getPlatformInfo ] window.diagnostics is undefined");
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
version: "X.X.XX-X",
|
|
167
|
-
pod: "ui-streamer-X.X.XX-X-QWERT-ASDFG-XXX-XXXXXX-XXXXX",
|
|
168
|
-
podIP: "0.0.0.0",
|
|
169
|
-
sessionInfo: {
|
|
170
|
-
userAgent: "SynamediaSenza/XX.YY.ZZ",
|
|
171
|
-
connectionId: "dummy",
|
|
172
|
-
deviceId: "123456789",
|
|
173
|
-
community: "LocalDev",
|
|
174
|
-
tenant: "XXXXXX",
|
|
175
|
-
tenantId: "XXXXXX",
|
|
176
|
-
manifest: {
|
|
177
|
-
transcontainer: "X.X.XX-X"
|
|
178
|
-
},
|
|
179
|
-
settings: {
|
|
180
|
-
webUI: {
|
|
181
|
-
backendHeaders: {
|
|
182
|
-
Authorization: "Bearer dummytoken"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
homeSessionInfo: {
|
|
187
|
-
tenantId: "XXXXXX",
|
|
188
|
-
community: "LocalDev"
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
async function getToken() {
|
|
196
|
-
if (!authToken) {
|
|
197
|
-
sdkLogger.log("getToken wait for promise updateSession event");
|
|
198
|
-
return new Promise((resolve) => {
|
|
199
|
-
// Listen to updateSession event to set the new token
|
|
200
|
-
document.addEventListener("updateSession", (e) => {
|
|
201
|
-
authToken = e.detail?.updateObj;
|
|
202
|
-
sdkLogger.log(`onUpdateSessionEvent: token= ${authToken}`);
|
|
203
|
-
resolve(authToken);
|
|
204
|
-
}, { once: true });
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
return Promise.resolve(authToken);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function forceTokenUpdate() {
|
|
211
|
-
authToken = null;
|
|
212
|
-
|
|
213
|
-
if (window.cefQuery) {
|
|
214
|
-
const FCID = getFCID();
|
|
215
|
-
const logger = sdkLogger.withFields({ FCID });
|
|
216
|
-
logger.log("forceTokenUpdate: sending updateSessionRequest");
|
|
217
|
-
const message = {
|
|
218
|
-
type: "updateSessionRequest",
|
|
219
|
-
updateKey: "authorization",
|
|
220
|
-
parentPath: "settings.webUI.backendHeaders.Authorization",
|
|
221
|
-
fcid: FCID
|
|
222
|
-
};
|
|
223
|
-
const request = { target: "TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
224
|
-
window.cefQuery({
|
|
225
|
-
request: JSON.stringify(request),
|
|
226
|
-
persistent: false,
|
|
227
|
-
onSuccess: () => {
|
|
228
|
-
logger.log("updateSessionRequest successfully sent");
|
|
229
|
-
},
|
|
230
|
-
onFailure: (code, msg) => {
|
|
231
|
-
logger.error(`updateSessionRequest failed: ${code} ${msg}`);
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
} else {
|
|
235
|
-
sdkLogger.error("forceTokenUpdate: window.cefQuery is undefined");
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** Returns a boolean that indicates whether we are running in an e2e environment, or on local browser */
|
|
240
|
-
export function isRunningE2E() {
|
|
241
|
-
return !!(typeof window !== "undefined" && window.cefQuery);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/** Call this API once after application startup, when the ui is ready to accept keys/events */
|
|
245
|
-
export function uiReady() {
|
|
246
|
-
if (window.cefQuery) {
|
|
247
|
-
window.cefQuery({
|
|
248
|
-
request: "uiReady",
|
|
249
|
-
persistent: false,
|
|
250
|
-
onSuccess: () => {
|
|
251
|
-
sdkLogger.log("uiReady request successfully sent");
|
|
252
|
-
},
|
|
253
|
-
onFailure: (code, msg) => {
|
|
254
|
-
sdkLogger.error(`uiReady request failed: ${code} ${msg}`);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
} else {
|
|
258
|
-
sdkLogger.error("uiReady: window.cefQuery is undefined");
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export { lifecycle } from "./lifecycle.js";
|
|
263
|
-
export { deviceManager } from "./deviceManager.js";
|
|
264
|
-
export { platformManager } from "./platformManager.js";
|
|
265
|
-
export { alarmManager };
|
|
266
|
-
export { messageManager } from "./messageManager.js";
|
|
267
|
-
export { SenzaShakaPlayer as ShakaPlayer, shaka } from "./senzaShakaPlayer.js";
|
|
268
|
-
|
|
269
|
-
import "./devHelper.js";
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* The function receives a license response and passes it to platform.
|
|
273
|
-
* @param {number} statusCode status code that was received from the license server
|
|
274
|
-
* @param {ArrayBuffer|string} licenseResponse a license response that was received from the license server to be passed to platform.
|
|
275
|
-
* @param {string} fcid a fcid received with the license request
|
|
276
|
-
* @param {string} sessionId a sessionId received with the license request
|
|
277
|
-
* In case of success licenceResponse is of type @type {ArrayBuffer}
|
|
278
|
-
* In case of error licenseResponse is of type @type {string}
|
|
279
|
-
*/
|
|
280
|
-
export function writeLicenseResponse(statusCode, licenseResponse, fcid, sessionId) {
|
|
281
|
-
|
|
282
|
-
if (statusCode >= 200 && statusCode < 300) {
|
|
283
|
-
licenseResponse = window.btoa(String.fromCharCode.apply(null, new Uint8Array(licenseResponse))); // to base64
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (window.cefQuery) {
|
|
287
|
-
const message = {
|
|
288
|
-
type: "updateLicense",
|
|
289
|
-
sessionId,
|
|
290
|
-
fcid
|
|
291
|
-
};
|
|
292
|
-
message[statusCode >= 200 && statusCode < 300 ? "response" : "error"] = licenseResponse;
|
|
293
|
-
const request = { target: "TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
294
|
-
window.cefQuery({
|
|
295
|
-
request: JSON.stringify(request),
|
|
296
|
-
persistent: false,
|
|
297
|
-
onSuccess: () => {
|
|
298
|
-
sdkLogger.log("updateLicense request successfully sent");
|
|
299
|
-
},
|
|
300
|
-
onFailure: (code, msg) => {
|
|
301
|
-
sdkLogger.error(`updateLicense request failed: ${code} ${msg}`);
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export class ClientAssertionError extends Error {
|
|
309
|
-
constructor(code, message) {
|
|
310
|
-
super(message);
|
|
311
|
-
this.code = code;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* @typedef Token
|
|
317
|
-
* @property {string} hostplatform_assertion The client assertion token.
|
|
318
|
-
*/
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Async function that returns the client assertion
|
|
322
|
-
* @return {Promise<Token>} Promise which is resolved to a client assertion object when getClientAssertion has been successfully performed. * client assertion object contains hostplatform_assertion property which holds the client assertion token.
|
|
323
|
-
* Failure to getClientAssertion for any reason, result in the promise being rejected.
|
|
324
|
-
* Error status codes:
|
|
325
|
-
* Status code 400 - Tenant configuration is missing
|
|
326
|
-
* Status code 0 - General error
|
|
327
|
-
* @example
|
|
328
|
-
* try {
|
|
329
|
-
* const client_assertion = await auth.getClientAssertion();
|
|
330
|
-
* console.log("Client assertion token is", client_assertion.hostplatform_assertion);
|
|
331
|
-
* } catch (e) {
|
|
332
|
-
* console.error("getClientAssertion failed", e);
|
|
333
|
-
* }
|
|
334
|
-
*/
|
|
335
|
-
export function getClientAssertion() {
|
|
336
|
-
if (window.cefQuery) {
|
|
337
|
-
sdkLogger.log("getClientAssertion is called");
|
|
338
|
-
|
|
339
|
-
return new Promise((resolve, reject) => {
|
|
340
|
-
window.cefQuery({
|
|
341
|
-
request: "client_assertion",
|
|
342
|
-
persistent: false,
|
|
343
|
-
onSuccess: (response) => {
|
|
344
|
-
try {
|
|
345
|
-
const json_response = JSON.parse(response);
|
|
346
|
-
sdkLogger.log(`client_assertion request successfully returned ${response}`);
|
|
347
|
-
resolve(json_response);
|
|
348
|
-
} catch (e) {
|
|
349
|
-
sdkLogger.error(`Failed to parse client assertion ${response}: ${e.message}`);
|
|
350
|
-
reject(new ClientAssertionError(0, "Failed to parse client assertion"));
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
},
|
|
354
|
-
onFailure: (code, msg) => {
|
|
355
|
-
sdkLogger.log(`client_assertion request failed: ${code} ${msg}`);
|
|
356
|
-
reject(new ClientAssertionError(code, msg));
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
sdkLogger.warn("getClientAssertion is not supported if NOT running e2e");
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
import * as senzaSDK from "./api.js";
|
|
365
|
-
if (typeof window !== "undefined") {
|
|
366
|
-
window.senzaSDKImplementation = window.senzaSDKImplementation || senzaSDK; // this is only for testing purposes which allows us to use and test senza APIs in pipeline tests
|
|
367
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { noop } from "./utils";
|
|
2
|
-
/**
|
|
3
|
-
* @class AlarmManager
|
|
4
|
-
* AlarmManager is a singleton class that manages the alarms in the application. It fires events whose types are the names of the alarms.
|
|
5
|
-
* @fires MyAlarm
|
|
6
|
-
*/
|
|
7
|
-
export class AlarmManager extends EventTarget {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* alarm event
|
|
11
|
-
*
|
|
12
|
-
* @event AlarmManager#MyAlarm
|
|
13
|
-
* @description Fired when time of 'MyAlarm' arrives. If this alarm triggers the application load and the application doesn't call
|
|
14
|
-
* lifecycle.moveToForeground() in the alarm callback (i.e. the application remains in the background after the callback is completed),
|
|
15
|
-
* the application will be unloaded.
|
|
16
|
-
* NOTE: If you perform async operations in the callback (without moving to foreground), you must wait for the async
|
|
17
|
-
* operation to finish before returning from the callback, otherwise the application will be unloaded before the async operation is finished.<br>
|
|
18
|
-
* @example
|
|
19
|
-
* alarmManager.addEventListener("MyAlarm", async (e) => {
|
|
20
|
-
* console.log("alarm MyAlarm arrived with data", e.detail);
|
|
21
|
-
* await fetch("http://www.example.com");
|
|
22
|
-
* });
|
|
23
|
-
* alarmManager.addAlarm("MyAlarm", Date.now() + 60*60*1000, "MyData");
|
|
24
|
-
*/
|
|
25
|
-
constructor() {
|
|
26
|
-
super();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
addEventListener(type, callback) {
|
|
30
|
-
noop("AlarmManager.addEventListener", type, callback);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
removeEventListener(type, callback) {
|
|
34
|
-
noop("AlarmManager.removeEventListener", type, callback);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Set alarm to be fired at the specified time, event when ui is released
|
|
38
|
-
* @param {string} alarmName unique name for the alarm
|
|
39
|
-
* @param {number} alarmTime target time for the alarm to be fired, represented by the number of milliseconds elapsed since the epoch
|
|
40
|
-
* @param {string} [data] data to be passed back when the alarm is fired
|
|
41
|
-
* */
|
|
42
|
-
addAlarm(alarmName, alarmTime, data = "", toleranceBefore = 0, toleranceAfter = 0) {
|
|
43
|
-
noop("AlarmManager.addAlarm", alarmName, alarmTime, data, toleranceBefore, toleranceAfter);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Delete the specified alarm
|
|
47
|
-
* @param {string} alarmName name of alarm to be deleted
|
|
48
|
-
*
|
|
49
|
-
* */
|
|
50
|
-
deleteAlarm(alarmName) {
|
|
51
|
-
noop("AlarmManager.deleteAlarm", alarmName);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Delete all alarms
|
|
55
|
-
*
|
|
56
|
-
* */
|
|
57
|
-
deleteAllAlarms() {
|
|
58
|
-
noop("AlarmManager.deleteAllAlarms");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Async function that asks for all active alarms
|
|
62
|
-
* @returns {Promise} when resolved, returns an array of objects containing alarmName and alarmTime fields
|
|
63
|
-
* @throws {string} error string in case of an error
|
|
64
|
-
*
|
|
65
|
-
* */
|
|
66
|
-
getActiveAlarms() {
|
|
67
|
-
return noop("AlarmManager.getActiveAlarms");
|
|
68
|
-
}
|
|
69
|
-
}
|
package/src/interface/api.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { Lifecycle } from "./lifecycle.js";
|
|
2
|
-
export { DeviceManager } from "./deviceManager.js";
|
|
3
|
-
export { PlatformManager } from "./platformManager.js";
|
|
4
|
-
export { AlarmManager } from "./alarmManager.js";
|
|
5
|
-
export { MessageManager } from "./messageManager.js";
|
|
6
|
-
export { RemotePlayer } from "./remotePlayer.js";
|
|
7
|
-
export { SenzaShakaPlayer as ShakaPlayer, shaka } from "./senzaShakaPlayer.js";
|
|
8
|
-
export { showSequence, initSequence } from "./devSequence.js";
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { sdkLogger, noop } from "./utils.js";
|
|
2
|
-
|
|
3
|
-
const wifiInfo = {};
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @class DeviceManager
|
|
7
|
-
* DeviceManager is a singleton class that manages the device
|
|
8
|
-
*/
|
|
9
|
-
export class DeviceManager extends EventTarget {
|
|
10
|
-
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
wifiInfo.level = 0;
|
|
14
|
-
wifiInfo.quality = 0;
|
|
15
|
-
wifiInfo.ssid = "unknown";
|
|
16
|
-
wifiInfo.bssid = "unknown";
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Instead, call deviceManager.getWifiInfo() periodically
|
|
19
|
-
* @event DeviceManager#wifiInfoUpdated
|
|
20
|
-
* @example
|
|
21
|
-
* deviceManager.addEventListener("wifiInfoUpdated", () => {
|
|
22
|
-
* console.info("Wifi info has been updated to", deviceManager.wifiInfo);
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @property {object} DeviceInfo
|
|
30
|
-
* @property {string} DeviceInfo.deviceId
|
|
31
|
-
* @property {string} DeviceInfo.modelNumber
|
|
32
|
-
* @property {string} DeviceInfo.connectionId
|
|
33
|
-
* @property {string} DeviceInfo.community
|
|
34
|
-
* @property {string} DeviceInfo.tenant
|
|
35
|
-
* @property {string} DeviceInfo.clientIp
|
|
36
|
-
* @property {string} DeviceInfo.countryCode A 2-letter code as defined in ISO_3166-1
|
|
37
|
-
* @property {string} DeviceInfo.connectionType The type of device used during the current connection. Possible values are "device" which mean real device, "simulator" - simulated device - that used during development.
|
|
38
|
-
*/
|
|
39
|
-
get deviceInfo() {
|
|
40
|
-
sdkLogger.log("getDeviceInfo running locally, returning dummy info");
|
|
41
|
-
return {
|
|
42
|
-
deviceId: "123456789",
|
|
43
|
-
modelNumber: "ABC",
|
|
44
|
-
connectionId: "dummy",
|
|
45
|
-
community: "LocalDev",
|
|
46
|
-
tenant: "XXXXXX",
|
|
47
|
-
clientIp: "0.0.0.0",
|
|
48
|
-
countryCode: "XX",
|
|
49
|
-
connectionType: "simulator"
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated use deviceManager.getWifiInfo() instead
|
|
56
|
-
* @property {object} WifiInfo
|
|
57
|
-
* @property {number} WifiInfo.level
|
|
58
|
-
* @property {number} WifiInfo.quality
|
|
59
|
-
* @property {string} WifiInfo.ssid
|
|
60
|
-
* @property {string} WifiInfo.bssid
|
|
61
|
-
*/
|
|
62
|
-
get wifiInfo() {
|
|
63
|
-
return wifiInfo;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Reboot the device
|
|
68
|
-
* @return {Promise} Promise which is resolved when the reboot command has been successfully processed.
|
|
69
|
-
* Failure to process the reboot command will result in the promise being rejected.
|
|
70
|
-
*/
|
|
71
|
-
reboot() {
|
|
72
|
-
return noop("DeviceManager.reboot");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Delete current wifi configuration and forget network
|
|
77
|
-
* @return {Promise} Promise which is resolved when the clearWifi command has been successfully processed.
|
|
78
|
-
* Failure to process the clearWifi command will result in the promise being rejected.
|
|
79
|
-
*/
|
|
80
|
-
clearWifi() {
|
|
81
|
-
return noop("DeviceManager.clearWifi");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Send raw data directly to a customer's device via the USB serial connection of a Senza device.
|
|
86
|
-
* This function is specifically designed for customers who have their devices connected to a Senza device.
|
|
87
|
-
* Using this API, these customers can transmit messages or data directly to their connected devices.
|
|
88
|
-
* The transmission occurs through the Senza device's USB serial interface, facilitating direct communication
|
|
89
|
-
* between the customer's web application and their device.
|
|
90
|
-
* @param {String} data raw data to be passed to the device
|
|
91
|
-
* @return {Promise} Promise which is resolved when the command has been successfully processed.
|
|
92
|
-
* Failure to process the command will result in the promise being rejected.
|
|
93
|
-
*/
|
|
94
|
-
sendDataToDevice(data) {
|
|
95
|
-
return noop("DeviceManager.sendDataToDevice", data);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Perform device factory reset.
|
|
100
|
-
* @param {Boolean} [reboot=true] a flag that is passed to the device to indicate whether it should reboot after the factory reset. defaults to true.
|
|
101
|
-
* @return {Promise} Promise which is resolved when factoryReset has been successfully performed
|
|
102
|
-
* Failure to factoryReset for any reason, result in the promise being rejected.
|
|
103
|
-
*/
|
|
104
|
-
async factoryReset(reboot = true) {
|
|
105
|
-
return noop("DeviceManager.factoryReset", reboot);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @typedef {Object} WiFiInfo
|
|
110
|
-
* @property {string} ssid the name of the Wi-Fi network that the device is connected to
|
|
111
|
-
* @property {string} bssid the unique identifier of the Wi-Fi access point
|
|
112
|
-
* @property {string} standard the Wi-Fi standard in use, such as 802.11a/b/g/n/ac/ax
|
|
113
|
-
* @property {string} security the type of security protocol used by the Wi-Fi network, such as WEP, WPA, WPA2, or WPA3
|
|
114
|
-
* @property {string} device-mac the MAC address of the device
|
|
115
|
-
* @property {string} device-ip4 the IPv4 address assigned to the device on the Wi-Fi network
|
|
116
|
-
* @property {string} dhcp-server the IP address of the DHCP server that assigned the device's network configuration
|
|
117
|
-
* @property {string[]} dns-server array of IP addresses of the DNS servers the device uses to resolve domain names
|
|
118
|
-
* @property {number} channel the number of the Wi-Fi channel currently being used
|
|
119
|
-
* @property {number} width width of the Wi-Fi channel in megahertz, e.g. 20MHz or 40 MHz channel
|
|
120
|
-
* @property {number} level a measure of the received signal strength, in the range 0 to 100 (the higher, the better). The level value is 100+RSSI (RSSI is the signal strength, measured in decibels)
|
|
121
|
-
* @property {number} quality a measure of the signal quality, in the range 0 to 100 (the higher, the better). The quality value is derived from the signal EVM.
|
|
122
|
-
* */
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Get Wi-Fi info - access point data and status (the status is cached for 5 seconds)
|
|
126
|
-
* @returns {WiFiInfo} An object containing the Wi-Fi info
|
|
127
|
-
* @alpha API has not yet been released
|
|
128
|
-
* */
|
|
129
|
-
// This api is part of epic HSDEV-4185
|
|
130
|
-
async getWifiInfo() {
|
|
131
|
-
return Promise.resolve({});
|
|
132
|
-
}
|
|
133
|
-
}
|