mftsccs-browser 1.1.69-beta → 1.1.70-beta
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/main.bundle.js +200 -169
- package/dist/main.bundle.js.map +1 -1
- package/dist/serviceWorker.bundle.js +216 -170
- package/dist/serviceWorker.bundle.js.map +1 -1
- package/dist/types/AccessTracker/accessTracker.d.ts +1 -1
- package/dist/types/DataStructures/Count/CountInfo.d.ts +6 -0
- package/dist/types/Middleware/logger.service.d.ts +2 -0
- package/dist/types/Services/Common/DecodeCountInfo.d.ts +3 -0
- package/dist/types/Services/Search/JustIdFormat.d.ts +3 -2
- package/dist/types/app.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.bundle.js
CHANGED
|
@@ -93,10 +93,7 @@ class AccessTracker {
|
|
|
93
93
|
static sendToServer() {
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
try {
|
|
96
|
-
|
|
97
|
-
if (!accessToken)
|
|
98
|
-
return;
|
|
99
|
-
yield this.syncToServer(accessToken);
|
|
96
|
+
yield this.syncToServer();
|
|
100
97
|
}
|
|
101
98
|
catch (error) {
|
|
102
99
|
console.error("Failed to process Access Tracker Sync with Server");
|
|
@@ -106,16 +103,18 @@ class AccessTracker {
|
|
|
106
103
|
/**
|
|
107
104
|
* Syncs the concept and connection data with the server.
|
|
108
105
|
*/
|
|
109
|
-
static syncToServer(
|
|
106
|
+
static syncToServer() {
|
|
110
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
108
|
try {
|
|
112
109
|
if (!Object.keys(this.conceptsData).length && !Object.keys(this.connectionsData).length) {
|
|
113
110
|
return;
|
|
114
111
|
}
|
|
112
|
+
const accessToken = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
113
|
+
if (!accessToken)
|
|
114
|
+
return;
|
|
115
115
|
// Ensure conceptsData and connectionsData are not undefined or null
|
|
116
116
|
const conceptsToSend = this.conceptsData && Object.keys(this.conceptsData).length > 0 ? this.conceptsData : {};
|
|
117
117
|
const connectionsToSend = this.connectionsData && Object.keys(this.connectionsData).length > 0 ? this.connectionsData : {};
|
|
118
|
-
console.log("Access Tracker Sent to SERVER..", conceptsToSend, connectionsToSend);
|
|
119
118
|
const response = yield fetch(_app__WEBPACK_IMPORTED_MODULE_0__.BaseUrl.PostPrefetchConceptConnections(), {
|
|
120
119
|
method: 'POST',
|
|
121
120
|
headers: {
|
|
@@ -130,7 +129,7 @@ class AccessTracker {
|
|
|
130
129
|
if (!response.ok) {
|
|
131
130
|
throw new Error('Failed to sync data to the server.');
|
|
132
131
|
}
|
|
133
|
-
|
|
132
|
+
yield response.json();
|
|
134
133
|
this.conceptsData = {};
|
|
135
134
|
this.connectionsData = {};
|
|
136
135
|
this.setNextSyncTime();
|
|
@@ -154,13 +153,10 @@ class AccessTracker {
|
|
|
154
153
|
* This will automatically call `syncToServer` every 5 minutes
|
|
155
154
|
*/
|
|
156
155
|
static startAutoSync() {
|
|
157
|
-
const tokenString = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
158
|
-
if (tokenString) {
|
|
159
|
-
this.syncNow().catch(console.error);
|
|
160
|
-
}
|
|
161
156
|
setInterval(() => {
|
|
162
157
|
const currentTime = Date.now();
|
|
163
158
|
// console.log(`[CHECK] Current Time: ${new Date(currentTime).toISOString()}`);
|
|
159
|
+
// console.log(`Update Time: ${this.nextSyncTime}`);
|
|
164
160
|
if (this.nextSyncTime && currentTime >= this.nextSyncTime) {
|
|
165
161
|
// console.log(`[SYNC TRIGGER] Time to sync! Triggering sync at: ${new Date(currentTime).toISOString()}`);
|
|
166
162
|
this.syncNow().catch(console.error);
|
|
@@ -172,12 +168,17 @@ class AccessTracker {
|
|
|
172
168
|
*/
|
|
173
169
|
static syncNow() {
|
|
174
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
try {
|
|
172
|
+
// console.log("Status of Access Tracker is : ", this.activateStatus);
|
|
173
|
+
if (this.activateStatus) {
|
|
174
|
+
yield this.syncToServer();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
console.warn("Access Tracker inactive.");
|
|
178
|
+
}
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
-
console.
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error("Error on sync access tracker");
|
|
181
182
|
}
|
|
182
183
|
});
|
|
183
184
|
}
|
|
@@ -11378,7 +11379,6 @@ class ApplicationMonitor {
|
|
|
11378
11379
|
};
|
|
11379
11380
|
_logger_service__WEBPACK_IMPORTED_MODULE_1__.Logger.logApplication("INFO", "Network Request", networkDetails);
|
|
11380
11381
|
return originalFetch(...args);
|
|
11381
|
-
// return new Response(null, { status: 200 });
|
|
11382
11382
|
}
|
|
11383
11383
|
let networkDetails = {
|
|
11384
11384
|
"request": {
|
|
@@ -11653,6 +11653,8 @@ class Logger {
|
|
|
11653
11653
|
// this.saveLogToLocalStorage(this.mftsccsBrowser, logEntry)
|
|
11654
11654
|
}
|
|
11655
11655
|
static log(level, message, data) {
|
|
11656
|
+
if (!this.logPackageActivationStatus)
|
|
11657
|
+
return;
|
|
11656
11658
|
try {
|
|
11657
11659
|
Logger.formatLogData(level, message, data || null);
|
|
11658
11660
|
}
|
|
@@ -11661,87 +11663,109 @@ class Logger {
|
|
|
11661
11663
|
}
|
|
11662
11664
|
}
|
|
11663
11665
|
static logInfo(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11666
|
+
try {
|
|
11667
|
+
const sessionId = getCookie("SessionId");
|
|
11668
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11669
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11670
|
+
const logData = {
|
|
11671
|
+
userId,
|
|
11672
|
+
operationType,
|
|
11673
|
+
requestFrom,
|
|
11674
|
+
requestIP,
|
|
11675
|
+
responseStatus,
|
|
11676
|
+
responseTime,
|
|
11677
|
+
responseSize,
|
|
11678
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11679
|
+
functionName,
|
|
11680
|
+
functionParameters,
|
|
11681
|
+
userAgent,
|
|
11682
|
+
conceptsUsed,
|
|
11683
|
+
};
|
|
11684
|
+
Logger.log("INFO", `Information logged for ${functionName}`, logData);
|
|
11685
|
+
}
|
|
11686
|
+
catch (error) {
|
|
11687
|
+
console.error("Error on logInfo");
|
|
11688
|
+
}
|
|
11682
11689
|
}
|
|
11683
11690
|
static logError(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11691
|
+
try {
|
|
11692
|
+
const sessionId = getCookie("SessionId");
|
|
11693
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11694
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11695
|
+
const logData = {
|
|
11696
|
+
userId,
|
|
11697
|
+
operationType,
|
|
11698
|
+
requestFrom,
|
|
11699
|
+
requestIP,
|
|
11700
|
+
responseStatus,
|
|
11701
|
+
responseTime,
|
|
11702
|
+
responseSize,
|
|
11703
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11704
|
+
functionName,
|
|
11705
|
+
functionParameters,
|
|
11706
|
+
userAgent,
|
|
11707
|
+
conceptsUsed,
|
|
11708
|
+
};
|
|
11709
|
+
Logger.formatLogData("ERROR", `Information logged for ${functionName}`, logData);
|
|
11710
|
+
}
|
|
11711
|
+
catch (error) {
|
|
11712
|
+
console.error("Error on logError");
|
|
11713
|
+
}
|
|
11702
11714
|
}
|
|
11703
11715
|
static logWarning(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11716
|
+
try {
|
|
11717
|
+
const sessionId = getCookie("SessionId");
|
|
11718
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11719
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11720
|
+
const logData = {
|
|
11721
|
+
userId,
|
|
11722
|
+
operationType,
|
|
11723
|
+
requestFrom,
|
|
11724
|
+
requestIP,
|
|
11725
|
+
responseStatus,
|
|
11726
|
+
responseTime,
|
|
11727
|
+
responseSize,
|
|
11728
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11729
|
+
functionName,
|
|
11730
|
+
functionParameters,
|
|
11731
|
+
userAgent,
|
|
11732
|
+
conceptsUsed,
|
|
11733
|
+
};
|
|
11734
|
+
Logger.formatLogData("WARNING", `Information logged for ${functionName}`, logData);
|
|
11735
|
+
}
|
|
11736
|
+
catch (error) {
|
|
11737
|
+
console.error("Error on logWarning");
|
|
11738
|
+
}
|
|
11722
11739
|
}
|
|
11723
11740
|
static logDebug(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11741
|
+
try {
|
|
11742
|
+
const sessionId = getCookie("SessionId");
|
|
11743
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11744
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11745
|
+
const logData = {
|
|
11746
|
+
userId,
|
|
11747
|
+
operationType,
|
|
11748
|
+
requestFrom,
|
|
11749
|
+
requestIP,
|
|
11750
|
+
responseStatus,
|
|
11751
|
+
responseTime,
|
|
11752
|
+
responseSize,
|
|
11753
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11754
|
+
functionName,
|
|
11755
|
+
functionParameters,
|
|
11756
|
+
userAgent,
|
|
11757
|
+
conceptsUsed,
|
|
11758
|
+
};
|
|
11759
|
+
Logger.formatLogData("DEBUG", `Information logged for ${functionName}`, logData);
|
|
11760
|
+
}
|
|
11761
|
+
catch (error) {
|
|
11762
|
+
console.error("Error on logDebug");
|
|
11763
|
+
}
|
|
11742
11764
|
}
|
|
11743
11765
|
// Log Application Activity
|
|
11744
11766
|
static logApplication(type, message, data) {
|
|
11767
|
+
if (!this.logApplicationActivationStatus)
|
|
11768
|
+
return;
|
|
11745
11769
|
try {
|
|
11746
11770
|
const timestamp = new Date().toLocaleString();
|
|
11747
11771
|
const logEntry = {
|
|
@@ -11763,18 +11787,13 @@ class Logger {
|
|
|
11763
11787
|
static sendApplicationLogsToServer() {
|
|
11764
11788
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11765
11789
|
try {
|
|
11766
|
-
|
|
11767
|
-
// console.log("Log To Server : \n", this.applicationLogsData);
|
|
11768
|
-
if (this.applicationLogsData.length < 0) {
|
|
11790
|
+
if (this.applicationLogsData.length === 0) {
|
|
11769
11791
|
return;
|
|
11770
11792
|
}
|
|
11771
11793
|
const accessToken = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
11772
|
-
const storedLogs = this.applicationLogsData;
|
|
11773
|
-
console.log("Application Logs of AppLog : ", storedLogs);
|
|
11774
11794
|
if (!accessToken)
|
|
11775
11795
|
return;
|
|
11776
|
-
|
|
11777
|
-
return;
|
|
11796
|
+
const storedLogs = this.applicationLogsData;
|
|
11778
11797
|
const chunkSize = 50;
|
|
11779
11798
|
for (let i = 0; i < storedLogs.length; i += chunkSize) {
|
|
11780
11799
|
const chunk = storedLogs.slice(i, i + chunkSize);
|
|
@@ -11797,8 +11816,6 @@ class Logger {
|
|
|
11797
11816
|
}
|
|
11798
11817
|
// clear application log from memory
|
|
11799
11818
|
this.applicationLogsData = [];
|
|
11800
|
-
// this.clearLogsFromLocalStorage(this.appLogs)
|
|
11801
|
-
// Logger.log("INFO", "Sync Application Logs to server")
|
|
11802
11819
|
}
|
|
11803
11820
|
catch (error) {
|
|
11804
11821
|
console.error("Error while sending logs to server:", error);
|
|
@@ -11808,18 +11825,15 @@ class Logger {
|
|
|
11808
11825
|
static sendLogsToServer() {
|
|
11809
11826
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11810
11827
|
try {
|
|
11811
|
-
console.warn("Log sending to server...");
|
|
11812
|
-
// console.log("Log To Server : \n", this.logsData);
|
|
11813
11828
|
if (this.logsData.length === 0)
|
|
11814
11829
|
return;
|
|
11830
|
+
if (this.logsData.length === 0) {
|
|
11831
|
+
return;
|
|
11832
|
+
}
|
|
11815
11833
|
const accessToken = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
11816
|
-
const storedLogs = this.logsData;
|
|
11817
|
-
console.log("Package Logs for syncing... ", storedLogs);
|
|
11818
11834
|
if (!accessToken)
|
|
11819
11835
|
return;
|
|
11820
|
-
|
|
11821
|
-
if (storedLogs.length === 0)
|
|
11822
|
-
return;
|
|
11836
|
+
const storedLogs = this.logsData;
|
|
11823
11837
|
const chunkSize = 50;
|
|
11824
11838
|
for (let i = 0; i < storedLogs.length; i += chunkSize) {
|
|
11825
11839
|
const chunk = storedLogs.slice(i, i + chunkSize);
|
|
@@ -11842,8 +11856,6 @@ class Logger {
|
|
|
11842
11856
|
}
|
|
11843
11857
|
// clear mftsccs log from memory
|
|
11844
11858
|
this.logsData = [];
|
|
11845
|
-
// this.clearLogsFromLocalStorage(this.mftsccsBrowser)
|
|
11846
|
-
// Logger.log("INFO", "Sync Application Logs to server")
|
|
11847
11859
|
}
|
|
11848
11860
|
catch (error) {
|
|
11849
11861
|
console.error("Error while sending logs to server:", error);
|
|
@@ -11889,6 +11901,8 @@ Logger.SYNC_INTERVAL_MS = 120 * 1000; // 120 Sec
|
|
|
11889
11901
|
Logger.nextSyncTime = null;
|
|
11890
11902
|
Logger.appLogs = "app";
|
|
11891
11903
|
Logger.mftsccsBrowser = "mftsccs";
|
|
11904
|
+
Logger.logApplicationActivationStatus = false;
|
|
11905
|
+
Logger.logPackageActivationStatus = false;
|
|
11892
11906
|
// Private auto-sync interval management
|
|
11893
11907
|
Logger.autoSyncInterval = null;
|
|
11894
11908
|
// Ensure logs are managed automatically
|
|
@@ -11901,19 +11915,25 @@ Logger.autoSyncInterval = null;
|
|
|
11901
11915
|
* @returns Cookie value
|
|
11902
11916
|
*/
|
|
11903
11917
|
function getCookie(cname) {
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
let
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11918
|
+
try {
|
|
11919
|
+
let name = cname + "=";
|
|
11920
|
+
let decodedCookie = decodeURIComponent(document.cookie);
|
|
11921
|
+
let ca = decodedCookie.split(';');
|
|
11922
|
+
for (let i = 0; i < ca.length; i++) {
|
|
11923
|
+
let c = ca[i];
|
|
11924
|
+
while (c.charAt(0) == ' ') {
|
|
11925
|
+
c = c.substring(1);
|
|
11926
|
+
}
|
|
11927
|
+
if (c.indexOf(name) == 0) {
|
|
11928
|
+
return c.substring(name.length, c.length);
|
|
11929
|
+
}
|
|
11914
11930
|
}
|
|
11931
|
+
return "";
|
|
11932
|
+
}
|
|
11933
|
+
catch (error) {
|
|
11934
|
+
console.error("Error on getcookie");
|
|
11935
|
+
return "";
|
|
11915
11936
|
}
|
|
11916
|
-
return "";
|
|
11917
11937
|
}
|
|
11918
11938
|
|
|
11919
11939
|
|
|
@@ -22572,6 +22592,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
22572
22592
|
|
|
22573
22593
|
|
|
22574
22594
|
|
|
22595
|
+
|
|
22575
22596
|
|
|
22576
22597
|
|
|
22577
22598
|
var serviceWorker;
|
|
@@ -22601,7 +22622,7 @@ function updateAccessToken(accessToken = "") {
|
|
|
22601
22622
|
* @param enableSW {activate: boolean, scope?: string, pathToSW?: string, manual?: boolean} | undefined - This is for enabling service worker with its scope
|
|
22602
22623
|
*/
|
|
22603
22624
|
function init() {
|
|
22604
|
-
return __awaiter(this, arguments, void 0, function* (url = "", aiurl = "", accessToken = "", nodeUrl = "", enableAi = true, applicationName = "", enableSW = undefined, flag = { logApplication: false, accessTracker: false, isTest: false }) {
|
|
22625
|
+
return __awaiter(this, arguments, void 0, function* (url = "", aiurl = "", accessToken = "", nodeUrl = "", enableAi = true, applicationName = "", enableSW = undefined, flag = { logApplication: false, logPackage: false, accessTracker: false, isTest: false }) {
|
|
22605
22626
|
try {
|
|
22606
22627
|
_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.BASE_URL = url;
|
|
22607
22628
|
_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.AI_URL = aiurl;
|
|
@@ -22624,13 +22645,24 @@ function init() {
|
|
|
22624
22645
|
_DataStructures_IdentifierFlags__WEBPACK_IMPORTED_MODULE_1__.IdentifierFlags.isLocalConnectionLoaded = true;
|
|
22625
22646
|
return true;
|
|
22626
22647
|
}
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22648
|
+
// Flag setup
|
|
22649
|
+
try {
|
|
22650
|
+
if (flag.logApplication) {
|
|
22651
|
+
_Middleware_ApplicationMonitor__WEBPACK_IMPORTED_MODULE_103__.ApplicationMonitor.initialize();
|
|
22652
|
+
_app__WEBPACK_IMPORTED_MODULE_105__.Logger.logApplicationActivationStatus = true;
|
|
22653
|
+
console.warn("Application log started...");
|
|
22654
|
+
}
|
|
22655
|
+
if (flag.logPackage) {
|
|
22656
|
+
_app__WEBPACK_IMPORTED_MODULE_105__.Logger.logPackageActivationStatus = true;
|
|
22657
|
+
console.warn("Package log started...");
|
|
22658
|
+
}
|
|
22659
|
+
if (flag.accessTracker) {
|
|
22660
|
+
_app__WEBPACK_IMPORTED_MODULE_105__.AccessTracker.activateStatus = true;
|
|
22661
|
+
console.warn("Access Tracker Activated...");
|
|
22662
|
+
}
|
|
22630
22663
|
}
|
|
22631
|
-
|
|
22632
|
-
|
|
22633
|
-
console.warn("Access Tracker Activated...");
|
|
22664
|
+
catch (error) {
|
|
22665
|
+
console.error("Flag setup failed in init");
|
|
22634
22666
|
}
|
|
22635
22667
|
if (!("serviceWorker" in navigator)) {
|
|
22636
22668
|
yield initConceptConnection();
|
|
@@ -22702,48 +22734,45 @@ function init() {
|
|
|
22702
22734
|
.then((registration) => __awaiter(this, void 0, void 0, function* () {
|
|
22703
22735
|
console.log("Service Worker registered:", registration);
|
|
22704
22736
|
// If the service worker is already active, mark it as ready
|
|
22705
|
-
if (registration.active) {
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
}
|
|
22721
|
-
|
|
22722
|
-
|
|
22723
|
-
|
|
22724
|
-
|
|
22725
|
-
|
|
22726
|
-
}, 5000);
|
|
22727
|
-
}
|
|
22737
|
+
// if (registration.active) {
|
|
22738
|
+
// serviceWorkerReady = true;
|
|
22739
|
+
// console.log("active sw");
|
|
22740
|
+
// serviceWorker = registration.active;
|
|
22741
|
+
// await sendMessage("init", {
|
|
22742
|
+
// url,
|
|
22743
|
+
// aiurl,
|
|
22744
|
+
// accessToken,
|
|
22745
|
+
// nodeUrl,
|
|
22746
|
+
// enableAi,
|
|
22747
|
+
// applicationName,
|
|
22748
|
+
// flag
|
|
22749
|
+
// });
|
|
22750
|
+
// processMessageQueue();
|
|
22751
|
+
// resolve();
|
|
22752
|
+
// } else {
|
|
22753
|
+
// // Handle if on state change didn't trigger
|
|
22754
|
+
// setTimeout(() => {
|
|
22755
|
+
// if (!success) reject("Not Completed Initialization");
|
|
22756
|
+
// }, 5000);
|
|
22757
|
+
// }
|
|
22728
22758
|
// state change
|
|
22729
|
-
if (registration.installing || registration.waiting || registration.active) {
|
|
22730
|
-
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
}
|
|
22759
|
+
// if (registration.installing || registration.waiting || registration.active) {
|
|
22760
|
+
// registration.addEventListener('statechange', async (event: any) => {
|
|
22761
|
+
// if (event?.target?.state === 'activating') {
|
|
22762
|
+
// serviceWorker = navigator.serviceWorker.controller
|
|
22763
|
+
// console.log('Service Worker is activating statechange');
|
|
22764
|
+
// await sendMessage("init", {
|
|
22765
|
+
// url,
|
|
22766
|
+
// aiurl,
|
|
22767
|
+
// accessToken,
|
|
22768
|
+
// nodeUrl,
|
|
22769
|
+
// enableAi,
|
|
22770
|
+
// applicationName,
|
|
22771
|
+
// flag
|
|
22772
|
+
// });
|
|
22773
|
+
// }
|
|
22774
|
+
// });
|
|
22775
|
+
// }
|
|
22747
22776
|
// Add Listeners before initializing the service worker
|
|
22748
22777
|
// Listen for updates to the service worker
|
|
22749
22778
|
console.log("update listen start");
|
|
@@ -22842,7 +22871,7 @@ function init() {
|
|
|
22842
22871
|
setTimeout(() => {
|
|
22843
22872
|
if (!success)
|
|
22844
22873
|
reject("Not Completed Initialization");
|
|
22845
|
-
},
|
|
22874
|
+
}, 10000);
|
|
22846
22875
|
}
|
|
22847
22876
|
}))
|
|
22848
22877
|
.catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -22890,6 +22919,7 @@ function sendMessage(type, payload) {
|
|
|
22890
22919
|
return new Promise((resolve, reject) => {
|
|
22891
22920
|
// navigator.serviceWorker.ready
|
|
22892
22921
|
// .then((registration) => {
|
|
22922
|
+
console.debug('debug', navigator.serviceWorker.controller, serviceWorker, serviceWorkerReady, type == 'init');
|
|
22893
22923
|
if ((navigator.serviceWorker.controller || serviceWorker) && (serviceWorkerReady || type == 'init')) {
|
|
22894
22924
|
const responseHandler = (event) => {
|
|
22895
22925
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -22928,7 +22958,7 @@ function sendMessage(type, payload) {
|
|
|
22928
22958
|
serviceWorker.postMessage({ type, payload: newPayload });
|
|
22929
22959
|
}
|
|
22930
22960
|
catch (err) {
|
|
22931
|
-
console.log(err);
|
|
22961
|
+
console.log('Retrying again on catch service worker', err);
|
|
22932
22962
|
// serviceWorker.postMessage({ type, payload: newPayload });
|
|
22933
22963
|
serviceWorker.postMessage({ type, payload: newPayload });
|
|
22934
22964
|
}
|
|
@@ -22938,6 +22968,7 @@ function sendMessage(type, payload) {
|
|
|
22938
22968
|
console.warn(`Service Worker hasn't loaded yet. messageId: ${messageId}, type: ${type}`);
|
|
22939
22969
|
if (serviceWorkerReady)
|
|
22940
22970
|
console.warn('service worker was registered already but is not available NOW!!!');
|
|
22971
|
+
console.info('ready', navigator.serviceWorker.ready);
|
|
22941
22972
|
// wait one second before checking again
|
|
22942
22973
|
setTimeout(() => {
|
|
22943
22974
|
console.warn(`Re-Trying after certain time. messageId: ${messageId}, type: ${type}`);
|
|
@@ -22957,7 +22988,7 @@ function sendMessage(type, payload) {
|
|
|
22957
22988
|
setTimeout(() => {
|
|
22958
22989
|
reject(`No response from service worker after timeout: ${type}`);
|
|
22959
22990
|
navigator.serviceWorker.removeEventListener("message", responseHandler);
|
|
22960
|
-
},
|
|
22991
|
+
}, 210000); // 3.5 minutes
|
|
22961
22992
|
}
|
|
22962
22993
|
else {
|
|
22963
22994
|
messageQueue.push({ message: { type, payload: newPayload } });
|