senza-sdk 4.2.46-b04e2a3.0 → 4.2.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "senza-sdk",
3
- "version": "4.2.46-b04e2a3.0",
3
+ "version": "4.2.46",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
@@ -45,9 +45,8 @@ class AlarmManager extends EventTarget {
45
45
  logger.log(`All callbacks for alarm '${e.detail.alarmName}' are finished within ${alarmHandlingDuration}ms`);
46
46
  // If this alarm triggered the application, and moveToForeground has not been called as a result of the alarm
47
47
  // (i.e. the application is still in the background), we want to intentionally terminate the ui in order to save resources.
48
- let isTriggering = false;
49
- if (lifecycle.triggerEvent.type === "alarmFiredEvent" && lifecycle._triggerEventFcid && lifecycle._triggerEventFcid === e.detail.fcid) {
50
- isTriggering = true;
48
+ const isTriggering = lifecycle.triggerEvent.type === "alarmFiredEvent" && lifecycle._triggerEventFcid && lifecycle._triggerEventFcid === e.detail.fcid;
49
+ if (isTriggering) {
51
50
  if (!this._moveToForegroundHasBeenCalled && window.cefQuery) {
52
51
  logger.log("Application is about to be terminated since didn't move to foreground");
53
52
  const message = { type: "terminating" };
package/src/lifecycle.js CHANGED
@@ -21,6 +21,7 @@ const DEFAULT_AUTO_BACKGROUND_ENABLED = false;
21
21
  * Lifecycle is a singleton class that manages the application lifecycle states.<br>
22
22
  * @fires onstatechange
23
23
  * @fires userinactivity
24
+ * @fires userdisconnected
24
25
  */
25
26
  class Lifecycle extends EventTarget {
26
27
 
@@ -81,6 +82,17 @@ class Lifecycle extends EventTarget {
81
82
  * });
82
83
  * @alpha API has not yet been released
83
84
  */
85
+
86
+ /**
87
+ * @event Lifecycle#userdisconnected
88
+ * @description Fired when the user session ends .
89
+ * This event is useful for cleaning up application state or saving data before the application closes.
90
+ * @example
91
+ * lifecycle.addEventListener("userdisconnected", () => {
92
+ * console.log("User session ended, cleaning up application state");
93
+ * // Perform any necessary cleanup here
94
+ * });
95
+ */
84
96
  constructor() {
85
97
  super();
86
98
 
@@ -127,6 +139,11 @@ class Lifecycle extends EventTarget {
127
139
  this.dispatchEvent(event);
128
140
  });
129
141
 
142
+ typeof document !== "undefined" && document.addEventListener("hs/endOfSession", () => {
143
+ const event = new Event("userdisconnected");
144
+ this.dispatchEvent(event);
145
+ });
146
+
130
147
  typeof document !== "undefined" && document.addEventListener("keydown", () => {
131
148
  if (this._autoBackground) {
132
149
  if (this.state === this.UiState.BACKGROUND ||