senza-sdk 4.2.65-d2761c0.0 → 4.3.1-4a01fcf.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.
Files changed (26) hide show
  1. package/dist/bundle.js +1 -1
  2. package/package.json +17 -8
  3. package/src/api.js +248 -329
  4. package/src/{alarmManager.js → implementation/alarmManager.js} +15 -52
  5. package/src/implementation/api.js +367 -0
  6. package/src/{deviceManager.js → implementation/deviceManager.js} +6 -78
  7. package/src/{lifecycle.js → implementation/lifecycle.js} +28 -215
  8. package/src/{messageManager.js → implementation/messageManager.js} +6 -6
  9. package/src/{platformManager.js → implementation/platformManager.js} +5 -4
  10. package/src/{remotePlayer.js → implementation/remotePlayer.js} +34 -28
  11. package/src/{senzaShakaPlayer.js → implementation/senzaShakaPlayer.js} +91 -16
  12. package/src/{utils.js → implementation/utils.js} +15 -6
  13. package/src/interface/alarmManager.js +69 -0
  14. package/src/interface/api.js +8 -0
  15. package/src/{devSequence.js → interface/devSequence.js} +35 -0
  16. package/src/interface/deviceManager.js +133 -0
  17. package/src/interface/lifecycle.js +278 -0
  18. package/src/interface/messageManager.js +46 -0
  19. package/src/interface/platformManager.js +35 -0
  20. package/src/interface/remotePlayer.js +441 -0
  21. package/src/interface/senzaShakaPlayer.js +171 -0
  22. package/src/interface/utils.js +45 -0
  23. /package/src/{SessionInfo.js → implementation/SessionInfo.js} +0 -0
  24. /package/src/{devHelper.js → implementation/devHelper.js} +0 -0
  25. /package/src/{eventListenersManager.js → implementation/eventListenersManager.js} +0 -0
  26. /package/src/{subtitlesUtils.js → implementation/subtitlesUtils.js} +0 -0
@@ -1,4 +1,6 @@
1
- import { alarmManager, getPlatformInfo } from "./api";
1
+ import { Lifecycle as LifecycleInterface } from "../interface/lifecycle";
2
+ import { getPlatformInfo } from "./api";
3
+ import { alarmManager } from "./alarmManager";
2
4
  import {
3
5
  getFCID,
4
6
  isAudioSyncConfigured,
@@ -24,76 +26,7 @@ const DEFAULT_AUTO_BACKGROUND_ENABLED = false;
24
26
  * @fires userinactivity
25
27
  * @fires userdisconnected
26
28
  */
27
- class Lifecycle extends EventTarget {
28
-
29
- /**
30
- * @typedef {Object} ConnectReason - The reason the ui app has been loaded
31
- * @property {string} UNKNOWN
32
- * @property {string} INITIAL_CONNECTION - Indicates that ui app has been loaded for the first time
33
- * @property {string} APPLICATION_RELOAD - Indicates that ui app has been reloaded (e.g. after HOME keypress)
34
- * @property {string} UI_RELEASE - Indicates that ui app has been reloaded after ui release
35
- * @property {string} UI_TERMINATION - Indicates that ui app has been reloaded due to ui termination
36
- * @property {string} WEBRTC_ERROR - Indicates that ui app has been reloaded due to webrtc error
37
- * @property {string} UI_WATCHDOG - Indicates that ui app has been reloaded due to ui watchdog not receiving ui frames
38
- */
39
- ConnectReason = Object.freeze({
40
- UNKNOWN: "unknown",
41
- INITIAL_CONNECTION: "initial_connection",
42
- APPLICATION_RELOAD: "reload_app",
43
- UI_RELEASE: "ui_release",
44
- UI_TERMINATION: "ui_termination",
45
- WEBRTC_ERROR: "webrtc_error",
46
- UI_WATCHDOG: "ui_watchdog"
47
- });
48
-
49
- /**
50
- * @typedef {Object} UiState - The ui lifecycle state
51
- * @property {string} UNKNOWN - state is unknown at this time
52
- * @property {string} FOREGROUND - ui is displayed
53
- * @property {string} IN_TRANSITION_TO_FOREGROUND - ui is about to be displayed
54
- * @property {string} BACKGROUND - remote player is playing (full screen playback is displayed)
55
- * @property {string} IN_TRANSITION_TO_BACKGROUND - remote player is about to be playing
56
- */
57
- UiState = Object.freeze({
58
- UNKNOWN: "unknown",
59
- FOREGROUND: "foreground",
60
- IN_TRANSITION_TO_FOREGROUND: "inTransitionToForeground",
61
- BACKGROUND: "background",
62
- IN_TRANSITION_TO_BACKGROUND: "inTransitionToBackground"
63
- });
64
-
65
- /**
66
- * @event Lifecycle#onstatechange
67
- * @description Fired after transition from one state to another.<br>
68
- * The flow is: foreground --> inTransitionToBackground --> background --> inTransitionToForeground --> foreground
69
- * @property {UiState} state - Indicates the new state.
70
- * @example
71
- * lifecycle.addEventListener("onstatechange", (e) => {
72
- * console.log("new state is", e.state);
73
- * });
74
- */
75
-
76
- /**
77
- * @event Lifecycle#userinactivity
78
- * @description Fired after the ui has been inactive (i.e. no key presses) for a configurable number of seconds.<br>
79
- * @property {number} timeout - the number of seconds after which the application will be unloaded.
80
- * @example
81
- * lifecycle.addEventListener("userinactivity", (e) => {
82
- * console.log(`Application will be unloaded in ${e.timeout} seconds`);
83
- * });
84
- * @alpha API has not yet been released
85
- */
86
-
87
- /**
88
- * @event Lifecycle#userdisconnected
89
- * @description Fired when the user session ends .
90
- * This event is useful for cleaning up application state or saving data before the application closes. Event callback should return promise to ensure that the event is handled before the application is terminated
91
- * @example
92
- * lifecycle.addEventListener("userdisconnected", () => {
93
- * console.log("User session ended, cleaning up application state");
94
- * // Perform any necessary cleanup here
95
- * });
96
- */
29
+ class Lifecycle extends LifecycleInterface {
97
30
  constructor() {
98
31
  super();
99
32
 
@@ -102,9 +35,7 @@ class Lifecycle extends EventTarget {
102
35
  * @private
103
36
  */
104
37
  this._isInitialized = false;
105
- this._inTransitionToForeground = false;
106
- this._inTransitionToBackground = false;
107
- this._inTransitionToStandby = false;
38
+ this._inTransition = false;
108
39
 
109
40
  /**
110
41
  * Event listeners manager for the userdisconnected event
@@ -307,15 +238,6 @@ class Lifecycle extends EventTarget {
307
238
  return this._autoBackgroundOnUIDelay;
308
239
  }
309
240
 
310
- /**
311
- * Configure lifecycle settings
312
- * @param {Object} config - Configuration object
313
- * @param {Object} [config.autoBackground] - Auto background settings
314
- * @param {boolean} [config.autoBackground.enabled] - Enable/disable auto background
315
- * @param {Object} [config.autoBackground.timeout] - Timeout settings
316
- * @param {number|false} [config.autoBackground.timeout.playing=30] - Timeout in seconds when video is playing, false to disable
317
- * @param {number|false} [config.autoBackground.timeout.idle=false] - Timeout in seconds when in UI mode, false to disable
318
- */
319
241
  configure(config) {
320
242
  if (config?.autoBackground) {
321
243
  const { enabled, timeout } = config.autoBackground;
@@ -355,15 +277,6 @@ class Lifecycle extends EventTarget {
355
277
  }
356
278
  }
357
279
 
358
- /**
359
- * Get the current configuration settings
360
- * @returns {Object} The current configuration object
361
- * @example
362
- * const config = lifecycle.getConfiguration();
363
- * console.log(config.autoBackground.enabled); // true/false
364
- * console.log(config.autoBackground.timeout.playing); // 30
365
- * console.log(config.autoBackground.timeout.idle); // false
366
- */
367
280
  getConfiguration() {
368
281
  return {
369
282
  autoBackground: {
@@ -386,7 +299,7 @@ class Lifecycle extends EventTarget {
386
299
  // This api is part of epic HSDEV-713
387
300
  _moveToUiStandby() {
388
301
  if (window.cefQuery) {
389
- this._inTransitionToStandby = true;
302
+ this._inTransition = true;
390
303
  return new Promise((resolve, reject) => {
391
304
  const FCID = getFCID();
392
305
  const request = { target: "TC", waitForResponse: false, internalAction: "uiExit", message: JSON.stringify({ type: "uiStandbyRequest", fcid: FCID }) };
@@ -397,12 +310,12 @@ class Lifecycle extends EventTarget {
397
310
  persistent: false,
398
311
  onSuccess: () => {
399
312
  logger.log("[ moveToUiStandby ] moveToUiStandby successfully sent");
400
- this._inTransitionToStandby = false;
313
+ this._inTransition = false;
401
314
  resolve(true);
402
315
  },
403
316
  onFailure: (code, msg) => {
404
317
  logger.error(`[ moveToUiStandby ] moveToUiStandby failed: ${code} ${msg}`);
405
- this._inTransitionToStandby = false;
318
+ this._inTransition = false;
406
319
  reject(`moveToUiStandby failed: ${code} ${msg}`);
407
320
  }
408
321
  });
@@ -412,10 +325,6 @@ class Lifecycle extends EventTarget {
412
325
  return Promise.resolve(true);
413
326
  }
414
327
 
415
- /**
416
- * Getter for returning the ui lifecycle state
417
- * @returns {UiState} the current application lifecycle state
418
- */
419
328
  get state() {
420
329
  if (!this._isInitialized) {
421
330
  this._state = this.UiState.UNKNOWN;
@@ -423,10 +332,6 @@ class Lifecycle extends EventTarget {
423
332
  return this._state;
424
333
  }
425
334
 
426
- /**
427
- * Getter for returning the application connection reason
428
- * @returns {ConnectReason} the application connection reason
429
- */
430
335
  get connectReason() {
431
336
  if (!this._isInitialized) {
432
337
  this._connectReason = this.ConnectReason.UNKNOWN;
@@ -434,11 +339,6 @@ class Lifecycle extends EventTarget {
434
339
  return this._connectReason;
435
340
  }
436
341
 
437
- /**
438
- * Getter for returning the event that triggered the reloading of the ui after ui has been released
439
- * @returns {Object} trigger event
440
- * @property {string} type - the type of the trigger event (e.g. keyPressEvent, videoPlaybackEvent)
441
- * @property {object} data - data of the event, dependent on its type (e.g. keyPressEvent has data of keyValue) */
442
342
  get triggerEvent() {
443
343
  if (!this._isInitialized) {
444
344
  this._triggerEvent = {};
@@ -446,14 +346,6 @@ class Lifecycle extends EventTarget {
446
346
  return this._triggerEvent;
447
347
  }
448
348
 
449
- /**
450
- * @deprecated Use `lifecycle.configure()` instead.
451
- * Controls the autoBackground feature.<br>
452
- * When enabled, the application will automatically move to the background state after a configurable
453
- * period of inactivity. Use the `configure` method to set timeouts for video playback and UI states.
454
- * @type {boolean}
455
- * @see {@link Lifecycle#configure}
456
- */
457
349
  set autoBackground(enabled) {
458
350
  this._autoBackground = enabled;
459
351
  if (this._isAutoBackgroundEnabled()) {
@@ -467,14 +359,6 @@ class Lifecycle extends EventTarget {
467
359
  return this._autoBackground;
468
360
  }
469
361
 
470
- /**
471
- * @deprecated Use `lifecycle.configure()` instead.
472
- * The number of seconds of user inactivity before the application moves to the background state while playing video.
473
- * Use the `configure` method to set this timeout.
474
- * @type {integer}
475
- * @default 30
476
- * @see {@link Lifecycle#configure}
477
- */
478
362
  set autoBackgroundDelay(delay) {
479
363
  this._autoBackgroundOnVideoDelay = delay;
480
364
  if (this._isAutoBackgroundEnabled() && remotePlayer._isPlaying) {
@@ -486,14 +370,6 @@ class Lifecycle extends EventTarget {
486
370
  return this._autoBackgroundOnVideoDelay;
487
371
  }
488
372
 
489
- /**
490
- * @deprecated Use `lifecycle.configure()` instead.
491
- * The number of seconds of user inactivity before the application moves to the background state while in the UI (not playing).
492
- * Use the `configure` method to set this timeout.
493
- * @type {integer}
494
- * @default -1
495
- * @see {@link Lifecycle#configure}
496
- */
497
373
  set autoBackgroundOnUIDelay(delay) {
498
374
  this._autoBackgroundOnUIDelay = delay;
499
375
  if (this._isAutoBackgroundEnabled() && !remotePlayer._isPlaying) {
@@ -536,26 +412,6 @@ class Lifecycle extends EventTarget {
536
412
  this._countdown = null;
537
413
  }
538
414
 
539
- /**
540
- * @private
541
- */
542
- _isInTransition() {
543
- return this._inTransitionToForeground || this._inTransitionToBackground || this._inTransitionToStandby;
544
- }
545
-
546
-
547
- /**
548
- * @deprecated use lifecycle.state instead.
549
- * Async function that returns the ui lifecycle state
550
- * @returns {UiState} the current application lifecycle state
551
- * @example
552
- * try {
553
- * const state = await lifecycle.getState();
554
- * console.log("current state is", state);
555
- * } catch (e) {
556
- * console.error("getState failed", e);
557
- * }
558
- */
559
415
  getState() {
560
416
  if (window.cefQuery) {
561
417
  return new Promise((resolve, reject) => {
@@ -576,29 +432,16 @@ class Lifecycle extends EventTarget {
576
432
  sdkLogger.warn("lifecycle getState is not supported if NOT running e2e");
577
433
  }
578
434
 
579
- /**
580
- * Once playback starts on the remote player,
581
- * the application is moved from foreground to inTransitionToBackground and eventually to background.
582
- * The application will need to call moveToForeground when it receives an event that needs the UI to be displayed again,
583
- * for example a key press, a playback end-of-file or a playback error.
584
- * @return {Promise} Promise which is resolved when the moveToForeground command has been successfully processed.
585
- * Failure to process the moveToForeground command will result in the promise being rejected.
586
- */
587
435
  moveToForeground() {
588
436
  if (window.cefQuery) {
589
- const inTransition = this._isInTransition();
590
- if (inTransition || this._state === this.UiState.FOREGROUND || this._state === this.UiState.IN_TRANSITION_TO_FOREGROUND) {
591
- sdkLogger.warn(`lifecycle moveToForeground: No need to transition to foreground, state: ${this._state} transition: ${inTransition}`);
437
+ if (this._inTransition || this._state === this.UiState.FOREGROUND || this._state === this.UiState.IN_TRANSITION_TO_FOREGROUND) {
438
+ sdkLogger.warn(`lifecycle moveToForeground: No need to transition to foreground, state: ${this._state} transition: ${this._inTransition}`);
592
439
  return Promise.resolve(false);
593
440
  }
594
- this._inTransitionToForeground = true;
441
+ this._inTransition = true;
595
442
  alarmManager._moveToForegroundCalled();
596
443
  const FCID = getFCID();
597
444
  if (this._remotePlayerApiVersion >= 2) {
598
- // Only update to playing UI if we started seeking in ABR. But, if we are seeking while already paused, keep the target seek state as is.
599
- if (remotePlayer._isSeekingByApplication && remotePlayer._targetSeekPlayingState === TargetPlayingState.PLAYING_ABR) {
600
- remotePlayer._targetSeekPlayingState = TargetPlayingState.PLAYING_UI;
601
- }
602
445
  return new Promise((resolve, reject) => {
603
446
  const FCID = getFCID();
604
447
  const logger = sdkLogger.withFields({ FCID });
@@ -618,14 +461,14 @@ class Lifecycle extends EventTarget {
618
461
  onSuccess: () => {
619
462
  const duration = Date.now() - timeBeforeSendingRequest;
620
463
  logger.withFields({ duration }).log(`stop completed successfully after ${duration} ms`);
621
- this._inTransitionToForeground = false;
464
+ this._inTransition = false;
622
465
  timerId = clearTimer(timerId);
623
466
  resolve(true);
624
467
  },
625
468
  onFailure: (code, msg) => {
626
469
  const duration = Date.now() - timeBeforeSendingRequest;
627
470
  logger.withFields({ duration }).log(`stop failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
628
- this._inTransitionToForeground = false;
471
+ this._inTransition = false;
629
472
  timerId = clearTimer(timerId);
630
473
  reject(new SenzaError(code, msg));
631
474
  }
@@ -634,7 +477,7 @@ class Lifecycle extends EventTarget {
634
477
  const timeout = this._remotePlayerConfirmationTimeout + 1000;
635
478
  timerId = setTimeout(() => {
636
479
  logger.log(`stop reached timeout of ${timeout} ms, canceling query id ${queryId}`);
637
- this._inTransitionToForeground = false;
480
+ this._inTransition = false;
638
481
  window.cefQueryCancel(queryId);
639
482
  reject(new SenzaError(6000, `stop reached timeout of ${timeout} ms`));
640
483
  }, timeout, queryId);
@@ -649,11 +492,11 @@ class Lifecycle extends EventTarget {
649
492
  persistent: false,
650
493
  onSuccess: () => {
651
494
  logger.log("uiActiveRequest successfully sent");
652
- this._inTransitionToForeground = false;
495
+ this._inTransition = false;
653
496
  resolve(true);
654
497
  },
655
498
  onFailure: (code, msg) => {
656
- this._inTransitionToForeground = false;
499
+ this._inTransition = false;
657
500
  logger.error(`uiActiveRequest failed: ${code} ${msg}`);
658
501
  reject(`uiActiveRequest failed: ${code} ${msg}`);
659
502
  }
@@ -666,6 +509,10 @@ class Lifecycle extends EventTarget {
666
509
 
667
510
  _moveToBackground() {
668
511
  if (window.cefQuery) {
512
+ if (this._inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
513
+ sdkLogger.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`);
514
+ return Promise.resolve(false);
515
+ }
669
516
  // If audio sync is disabled, we only need to sync before remote player starts playing
670
517
  if (!isAudioSyncConfigured()) {
671
518
  remotePlayer._syncRemotePlayerWithLocalPlayer();
@@ -677,7 +524,7 @@ class Lifecycle extends EventTarget {
677
524
  return this._moveToUiStandby();
678
525
  }
679
526
 
680
- this._inTransitionToBackground = true;
527
+ this._inTransition = true;
681
528
  return new Promise((resolve, reject) => {
682
529
  const FCID = getFCID();
683
530
  const logger = sdkLogger.withFields({ FCID });
@@ -718,14 +565,14 @@ class Lifecycle extends EventTarget {
718
565
  onSuccess: () => {
719
566
  const duration = Date.now() - timeBeforeSendingRequest;
720
567
  logger.withFields({ duration }).log(`play completed successfully after ${duration} ms`);
721
- this._inTransitionToBackground = false;
568
+ this._inTransition = false;
722
569
  timerId = clearTimer(timerId);
723
570
  resolve();
724
571
  },
725
572
  onFailure: (code, msg) => {
726
573
  const duration = Date.now() - timeBeforeSendingRequest;
727
574
  logger.withFields({ duration }).log(`play failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
728
- this._inTransitionToBackground = false;
575
+ this._inTransition = false;
729
576
  timerId = clearTimer(timerId);
730
577
  reject(new SenzaError(code, msg));
731
578
  }
@@ -735,7 +582,7 @@ class Lifecycle extends EventTarget {
735
582
  const timeout = this._remotePlayerConfirmationTimeout + 1000;
736
583
  timerId = setTimeout(() => {
737
584
  logger.log(`play reached timeout of ${timeout} ms, canceling query id ${queryId}`);
738
- this._inTransitionToBackground = false;
585
+ this._inTransition = false;
739
586
  window.cefQueryCancel(queryId);
740
587
  reject(new SenzaError(6000, `play reached timeout of ${timeout} ms`));
741
588
  }, timeout, queryId);
@@ -746,24 +593,13 @@ class Lifecycle extends EventTarget {
746
593
  return Promise.resolve(false);
747
594
  }
748
595
 
749
- /**
750
- * This method moves the application to the background.
751
- * It should be called after remotePlayer.play().
752
- * As a consequence, remote player playback will be displayed in full screen.
753
- * @example
754
- * remotePlayer.load("https://example.com/video.mp4", 0);
755
- * remotePlayer.play();
756
- * lifecycle.moveToBackground();
757
- * @return {Promise} Promise which is resolved when the moveToBackground command has been successfully processed.
758
- * Failure to process the moveToBackground command will result in the promise being rejected.
759
- */
760
596
  moveToBackground() {
761
597
  if (window.cefQuery) {
762
- const inTransition = this._isInTransition();
763
- if (inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
764
- sdkLogger.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${inTransition}`);
598
+ if (this._inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
599
+ sdkLogger.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`);
765
600
  return Promise.resolve(false);
766
601
  }
602
+
767
603
  if (remotePlayer._isSeekingByApplication) {
768
604
  remotePlayer._targetSeekPlayingState = TargetPlayingState.PLAYING_ABR;
769
605
  return Promise.resolve(true);
@@ -780,13 +616,6 @@ class Lifecycle extends EventTarget {
780
616
  return this._moveToBackground();
781
617
  }
782
618
 
783
- /**
784
- * Use this api to switch to another tenant (other than the home tenant) which will launch the application associated with the tenantId. The tenantId must be configured in the
785
- * Senza platform. Switching to the home tenant should use the exitApplication().
786
- * @param {string} tenantId The tenantId to switch
787
- * @return {Promise} Promise which is resolved when the switchTenant command has been successfully processed.
788
- * Failure to process the switchTenant command will result in the promise being rejected.
789
- */
790
619
  switchTenant(tenantId) {
791
620
  if (tenantId && tenantId.length > 0) {
792
621
  if (tenantId === getPlatformInfo().sessionInfo?.tenantId) {
@@ -832,11 +661,6 @@ class Lifecycle extends EventTarget {
832
661
  return Promise.reject("SwitchTenant requires a valid tenantId string parameter");
833
662
  }
834
663
 
835
- /**
836
- * Use this api to exit the application which will redirect the browser to the home tenant application.
837
- * @return {Promise} Promise which is resolved when the exitApplication command has been successfully processed.
838
- * Failure to process the exitApplication command will result in the promise being rejected.
839
- */
840
664
  exitApplication() {
841
665
  if (window.cefQuery) {
842
666
  return new Promise((resolve, reject) => {
@@ -885,12 +709,6 @@ class Lifecycle extends EventTarget {
885
709
  return Promise.reject("exitApplication is not supported if NOT running e2e");
886
710
  }
887
711
 
888
- /**
889
- * Add event listener for lifecycle events
890
- * @param {string} type - The event type to listen for
891
- * @param {Function} listener - The callback function. Listeners for 'userdisconnected' events should return a promise to ensure the event is processed before the application exits.
892
- * @param {Object} options - Event listener options
893
- */
894
712
  addEventListener(type, listener, options) {
895
713
  if (type === "userdisconnected") {
896
714
  // Use the event manager for userdisconnected events
@@ -901,12 +719,7 @@ class Lifecycle extends EventTarget {
901
719
  }
902
720
  }
903
721
 
904
- /**
905
- * Remove event listener
906
- * @param {string} type - The event type
907
- * @param {Function} listener - The callback function to remove
908
- * @param {Object} options - Event listener options
909
- */
722
+
910
723
  removeEventListener(type, listener, options) {
911
724
  if (type === "userdisconnected") {
912
725
  // Use the event manager for userdisconnected events
@@ -1,12 +1,12 @@
1
-
2
- import {getFCID, sdkLogger} from "./utils";
1
+ import { MessageManager as MessageManagerInterface } from "../interface/messageManager";
2
+ import { getFCID, sdkLogger } from "./utils";
3
3
 
4
4
  /**
5
5
  * MessageManager is a singleton class that manages the external messages received by the application. It fires custom events as "message" with the payload as the content
6
6
  * @fires MessageManager#message
7
7
  */
8
8
 
9
- class MessageManager extends EventTarget {
9
+ class MessageManager extends MessageManagerInterface {
10
10
 
11
11
  /**
12
12
  * @typedef {object} MessageDetails - object which contains the content of the message
@@ -34,7 +34,7 @@ class MessageManager extends EventTarget {
34
34
  super();
35
35
  typeof document !== "undefined" && document.addEventListener("hs/externalEvent", (e) => {
36
36
  sdkLogger.log("Got hs/externalEvent", JSON.stringify(e.detail));
37
- this.dispatchEvent(new CustomEvent("message", {detail: {eventName: e.detail.eventName, payload: e.detail.payload, fcid: e.detail.fcid } }));
37
+ this.dispatchEvent(new CustomEvent("message", { detail: { eventName: e.detail.eventName, payload: e.detail.payload, fcid: e.detail.fcid } }));
38
38
  });
39
39
  }
40
40
 
@@ -49,13 +49,13 @@ class MessageManager extends EventTarget {
49
49
  return new Promise((resolve, reject) => {
50
50
  if (window.cefQuery) {
51
51
  const FCID = getFCID();
52
- const logger = sdkLogger.withFields({FCID});
52
+ const logger = sdkLogger.withFields({ FCID });
53
53
  const message = {
54
54
  type: "registerGroupEvent",
55
55
  fcid: FCID,
56
56
  groups
57
57
  };
58
- const request = {target: "UI-Streamer", waitForResponse: false, message: JSON.stringify(message)};
58
+ const request = { target: "UI-Streamer", waitForResponse: false, message: JSON.stringify(message) };
59
59
  window.cefQuery({
60
60
  request: JSON.stringify(request),
61
61
  persistent: false,
@@ -1,11 +1,12 @@
1
+ import { PlatformManager as PlatformManagerInterface } from "../interface/platformManager";
1
2
  import { sdkLogger } from "./utils";
2
- import {sessionInfo} from "./SessionInfo";
3
+ import { sessionInfo } from "./SessionInfo";
3
4
 
4
5
 
5
6
  /**
6
7
  * PlatformManager is a singleton class that manages the platform
7
8
  */
8
- class PlatformManager extends EventTarget {
9
+ class PlatformManager extends PlatformManagerInterface {
9
10
 
10
11
  constructor() {
11
12
  super();
@@ -22,7 +23,7 @@ class PlatformManager extends EventTarget {
22
23
  get appConfig() {
23
24
  const sessionInfoObj = sessionInfo.sessionInfoObj;
24
25
  const appConfig = sessionInfoObj.homeSessionInfo?.["appConfig"] || {};
25
- sdkLogger.info("PlatformManager get appConfig: \n" + JSON.stringify(appConfig, null,2));
26
+ sdkLogger.info("PlatformManager get appConfig: \n" + JSON.stringify(appConfig, null, 2));
26
27
  return appConfig;
27
28
  }
28
29
 
@@ -35,7 +36,7 @@ class PlatformManager extends EventTarget {
35
36
  */
36
37
  setTimezone(timezone) {
37
38
  if (window.cefQuery) {
38
- const request = {message: JSON.stringify({type: "setTimeZone", timezone}), waitForResponse: false, target: "UI-Streamer"};
39
+ const request = { message: JSON.stringify({ type: "setTimeZone", timezone }), waitForResponse: false, target: "UI-Streamer" };
39
40
  window.cefQuery({
40
41
  request: JSON.stringify(request),
41
42
  persistent: false,