mftsccs-browser 1.1.36-beta → 1.1.38-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 +233 -168
- package/dist/main.bundle.js.map +1 -1
- package/dist/serviceWorker.bundle.js +284 -197
- package/dist/serviceWorker.bundle.js.map +1 -1
- package/dist/types/DataStructures/BaseUrl.d.ts +1 -1
- package/dist/types/Widgets/BuilderStatefulWidget.d.ts +0 -6
- package/dist/types/Widgets/StatefulWidget.d.ts +2 -1
- package/dist/types/app.d.ts +11 -0
- package/package.json +1 -1
package/dist/main.bundle.js
CHANGED
|
@@ -13501,7 +13501,11 @@ function GetConnectionBetweenTwoConceptsLinker(ofTheConcept_1, toTheConcept_1, l
|
|
|
13501
13501
|
if (fullLinker != "") {
|
|
13502
13502
|
typeConcept = yield (0,_app__WEBPACK_IMPORTED_MODULE_1__.MakeTheTypeConceptApi)(fullLinker, 999);
|
|
13503
13503
|
}
|
|
13504
|
-
let connections =
|
|
13504
|
+
let connections = [];
|
|
13505
|
+
if (!forward)
|
|
13506
|
+
connections = yield (0,_Api_GetCompositionConnectionsBetweenTwoConcepts__WEBPACK_IMPORTED_MODULE_0__.GetCompositionConnectionsBetweenTwoConcepts)(toTheConcept.id, ofTheConcept.id, typeConcept.id);
|
|
13507
|
+
else
|
|
13508
|
+
connections = yield (0,_Api_GetCompositionConnectionsBetweenTwoConcepts__WEBPACK_IMPORTED_MODULE_0__.GetCompositionConnectionsBetweenTwoConcepts)(ofTheConcept.id, toTheConcept.id, typeConcept.id);
|
|
13505
13509
|
return connections;
|
|
13506
13510
|
});
|
|
13507
13511
|
}
|
|
@@ -17987,11 +17991,9 @@ class Validator {
|
|
|
17987
17991
|
}
|
|
17988
17992
|
// 2. Validate using regex pattern for the data type
|
|
17989
17993
|
if (dataType && value) {
|
|
17990
|
-
console.log(`Comment on Data Type ${dataType} and Value ${value}`);
|
|
17991
17994
|
let pattern = _constant__WEBPACK_IMPORTED_MODULE_1__.DATA_TYPES_RULES[dataType];
|
|
17992
|
-
console.log("Find Pattern : ", pattern);
|
|
17993
17995
|
if (pattern && value !== '' && !pattern.test(value)) {
|
|
17994
|
-
errors['dataType'] = `Invalid
|
|
17996
|
+
errors['dataType'] = `Invalid value for ${dataType}`;
|
|
17995
17997
|
}
|
|
17996
17998
|
}
|
|
17997
17999
|
// 3. Check if the provided pattern match with the value or not
|
|
@@ -18235,8 +18237,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18235
18237
|
/* harmony export */ });
|
|
18236
18238
|
/* harmony import */ var _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./StatefulWidget */ "./src/Widgets/StatefulWidget.ts");
|
|
18237
18239
|
/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../app */ "./src/app.ts");
|
|
18238
|
-
/* harmony import */ var
|
|
18239
|
-
/* harmony import */ var _BuilderSpeceficFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./BuilderSpeceficFunctions */ "./src/Widgets/BuilderSpeceficFunctions.ts");
|
|
18240
|
+
/* harmony import */ var _BuilderSpeceficFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BuilderSpeceficFunctions */ "./src/Widgets/BuilderSpeceficFunctions.ts");
|
|
18240
18241
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18241
18242
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18242
18243
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18250,73 +18251,64 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
18250
18251
|
|
|
18251
18252
|
|
|
18252
18253
|
|
|
18253
|
-
|
|
18254
18254
|
class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__.StatefulWidget {
|
|
18255
18255
|
constructor() {
|
|
18256
18256
|
super(...arguments);
|
|
18257
18257
|
this.childComponents = [];
|
|
18258
|
-
this.elementIdentifier = 0;
|
|
18259
18258
|
this.componentMounted = false;
|
|
18260
|
-
this.parentElement = "";
|
|
18261
18259
|
this.oldHtml = null;
|
|
18262
|
-
// subscribers: any = [];
|
|
18263
|
-
this.element = null;
|
|
18264
18260
|
this.phonebooks = [];
|
|
18265
18261
|
this.childrenData = {};
|
|
18266
|
-
this.html = "";
|
|
18267
18262
|
this.childWidgets = [];
|
|
18268
18263
|
this.typeValueList = [];
|
|
18269
18264
|
this.widgetType = "the_element_name";
|
|
18270
18265
|
this.parentConceptList = [];
|
|
18271
18266
|
}
|
|
18272
|
-
getWidgetCodeFromId(widgetId, token) {
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
|
|
18302
|
-
|
|
18303
|
-
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
}));
|
|
18318
|
-
});
|
|
18319
|
-
}
|
|
18267
|
+
// async getWidgetCodeFromId(widgetId: number, token: string) {
|
|
18268
|
+
// //console.log("getWidgetCodeFromId", widgetId, token);
|
|
18269
|
+
// return new Promise(async (resolve: any, reject: any) => {
|
|
18270
|
+
// try {
|
|
18271
|
+
// let searchFirst = new SearchQuery();
|
|
18272
|
+
// searchFirst.composition = widgetId;
|
|
18273
|
+
// searchFirst.fullLinkers = [
|
|
18274
|
+
// "the_widgetcode",
|
|
18275
|
+
// "the_widgetcode_widget",
|
|
18276
|
+
// "the_widgetcode_name",
|
|
18277
|
+
// "the_widgetcode_html",
|
|
18278
|
+
// "the_widgetcode_css",
|
|
18279
|
+
// "the_widgetcode_js",
|
|
18280
|
+
// "the_widgetcode_timestamp",
|
|
18281
|
+
// "the_widgetcode_typevalue",
|
|
18282
|
+
// "the_widgetcode_addevent",
|
|
18283
|
+
// "the_widgetcode_onmount",
|
|
18284
|
+
// "the_widgetcode_onupdate",
|
|
18285
|
+
// "the_widgetcode_mountChildWidgets",
|
|
18286
|
+
// "the_widgetcode_cleanhtml",
|
|
18287
|
+
// "the_widgetcode_s_child",
|
|
18288
|
+
// ];
|
|
18289
|
+
// searchFirst.inpage = 100;
|
|
18290
|
+
// let searchSecond = new SearchQuery();
|
|
18291
|
+
// searchSecond.fullLinkers = [
|
|
18292
|
+
// "the_childwidget",
|
|
18293
|
+
// "the_childwidget_typevalue",
|
|
18294
|
+
// "the_childwidget_widget",
|
|
18295
|
+
// "the_childwidget_wrapperId",
|
|
18296
|
+
// ];
|
|
18297
|
+
// searchSecond.inpage = 100;
|
|
18298
|
+
// const queryParams = [searchFirst, searchSecond];
|
|
18299
|
+
// const output = await SearchLinkMultipleAll(queryParams, token);
|
|
18300
|
+
// //console.log("getWidgetCodeFromId output ->", output);
|
|
18301
|
+
// resolve(output);
|
|
18302
|
+
// return output;
|
|
18303
|
+
// } catch (error: any) {
|
|
18304
|
+
// console.error("error", error);
|
|
18305
|
+
// if (error?.status === 401) {
|
|
18306
|
+
// HandleHttpError(error?.response)
|
|
18307
|
+
// }
|
|
18308
|
+
// reject(error);
|
|
18309
|
+
// }
|
|
18310
|
+
// });
|
|
18311
|
+
// }
|
|
18320
18312
|
// async CreateConceptConnections(){
|
|
18321
18313
|
// let mainConcept = await
|
|
18322
18314
|
// for(let i=0; i<this.childrenData.length; i++){
|
|
@@ -18428,7 +18420,7 @@ class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__
|
|
|
18428
18420
|
});
|
|
18429
18421
|
}
|
|
18430
18422
|
createTypeEditor(event) {
|
|
18431
|
-
(0,
|
|
18423
|
+
(0,_BuilderSpeceficFunctions__WEBPACK_IMPORTED_MODULE_2__.TypeEditor)(event, this);
|
|
18432
18424
|
}
|
|
18433
18425
|
/**
|
|
18434
18426
|
*
|
|
@@ -18450,7 +18442,6 @@ class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__
|
|
|
18450
18442
|
this.element.innerHTML = this.getHtml();
|
|
18451
18443
|
parent === null || parent === void 0 ? void 0 : parent.setAttribute("data-type-value", that.widgetType);
|
|
18452
18444
|
parent.appendChild(this.element);
|
|
18453
|
-
this.childWidgetElement = this.getElementByClassName("added-widget-container");
|
|
18454
18445
|
this.parentElement = parent.id;
|
|
18455
18446
|
if (this.componentMounted == false || this.widgetMounted == false) {
|
|
18456
18447
|
// Simulate componentDidMount by calling it after the component is inserted into the DOM
|
|
@@ -18462,6 +18453,7 @@ class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__
|
|
|
18462
18453
|
else {
|
|
18463
18454
|
this.render();
|
|
18464
18455
|
}
|
|
18456
|
+
this.childWidgetElement = this.getElementByClassName("added-widget-container");
|
|
18465
18457
|
}
|
|
18466
18458
|
});
|
|
18467
18459
|
}
|
|
@@ -18499,55 +18491,57 @@ class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__
|
|
|
18499
18491
|
// const renderOnmount = AsyncFunction("tsccs", this.addEventFunction);
|
|
18500
18492
|
// renderOnmount.call(this, tsccs);
|
|
18501
18493
|
}
|
|
18502
|
-
getWidgetClassFunction(widgetId) {
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18514
|
-
|
|
18515
|
-
|
|
18516
|
-
|
|
18517
|
-
|
|
18518
|
-
|
|
18519
|
-
|
|
18520
|
-
|
|
18521
|
-
|
|
18522
|
-
|
|
18523
|
-
|
|
18524
|
-
|
|
18525
|
-
|
|
18526
|
-
|
|
18527
|
-
|
|
18528
|
-
|
|
18529
|
-
|
|
18530
|
-
|
|
18531
|
-
|
|
18532
|
-
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18494
|
+
// async getWidgetClassFunction(widgetId: number) {
|
|
18495
|
+
// return new Promise(async (resolve: any) => {
|
|
18496
|
+
// const profileData: any = await new Promise((resolve2: any) => {
|
|
18497
|
+
// let dataFromLocalStorage: string = localStorage?.getItem("profile") || "";
|
|
18498
|
+
// if (dataFromLocalStorage) {
|
|
18499
|
+
// const profileData = JSON.parse(dataFromLocalStorage);
|
|
18500
|
+
// resolve2(profileData)
|
|
18501
|
+
// } else {
|
|
18502
|
+
// resolve2()
|
|
18503
|
+
// }
|
|
18504
|
+
// });
|
|
18505
|
+
// const token = profileData?.token;
|
|
18506
|
+
// let output: any = await this.getWidgetCodeFromId(widgetId, token);
|
|
18507
|
+
// const widgetInfo = output?.data?.the_widgetcode;
|
|
18508
|
+
// const widgetName = widgetInfo?.the_widgetcode_name?.[0]?.data?.the_name;
|
|
18509
|
+
// const widgetHTML = widgetInfo?.the_widgetcode_html?.[0]?.data?.the_html;
|
|
18510
|
+
// const widgetCSS = widgetInfo?.the_widgetcode_css?.[0]?.data?.the_css;
|
|
18511
|
+
// const widgetJS = widgetInfo?.the_widgetcode_js?.[0]?.data?.the_js;
|
|
18512
|
+
// const widgetTimestamp =
|
|
18513
|
+
// widgetInfo?.the_widgetcode_timestamp?.[0]?.data?.the_timestamp;
|
|
18514
|
+
// const widgetPackageId = widgetInfo?.the_widgetcode_widget?.[0].id;
|
|
18515
|
+
// const widgetAddEvent =
|
|
18516
|
+
// widgetInfo?.the_widgetcode_addevent?.[0]?.data?.the_addevent;
|
|
18517
|
+
// const widgetOnmount =
|
|
18518
|
+
// widgetInfo?.the_widgetcode_onmount?.[0]?.data?.the_onmount;
|
|
18519
|
+
// const widgetOnupdate =
|
|
18520
|
+
// widgetInfo?.the_widgetcode_onupdate?.[0]?.data?.the_onupdate;
|
|
18521
|
+
// const widgetMountChildWidgets =
|
|
18522
|
+
// widgetInfo?.the_widgetcode_mountChildWidgets?.[0]?.data
|
|
18523
|
+
// ?.the_mountChildWidgets;
|
|
18524
|
+
// const widgetData = {
|
|
18525
|
+
// id: output?.id,
|
|
18526
|
+
// name: widgetName,
|
|
18527
|
+
// html: widgetHTML,
|
|
18528
|
+
// css: widgetCSS,
|
|
18529
|
+
// js: widgetJS,
|
|
18530
|
+
// timestamp: widgetTimestamp,
|
|
18531
|
+
// widgetId: widgetPackageId,
|
|
18532
|
+
// addevent: widgetAddEvent,
|
|
18533
|
+
// onmount: widgetOnmount,
|
|
18534
|
+
// onupdate: widgetOnupdate,
|
|
18535
|
+
// mountChildWidgets: widgetMountChildWidgets,
|
|
18536
|
+
// };
|
|
18537
|
+
// const widgetInstance = new BuilderStatefulWidget();
|
|
18538
|
+
// widgetInstance.html = widgetData?.html;
|
|
18539
|
+
// widgetInstance.componentDidMountFunction = widgetData?.onmount;
|
|
18540
|
+
// widgetInstance.addEventFunction = widgetData?.addevent;
|
|
18541
|
+
// widgetInstance.mountChildWidgetsFunction = widgetData?.mountChildWidgets;
|
|
18542
|
+
// resolve(widgetInstance);
|
|
18543
|
+
// });
|
|
18544
|
+
// }
|
|
18551
18545
|
CreateConnectionBetweenEntityLocal(concept1Data, concept2Data, linker) {
|
|
18552
18546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18553
18547
|
var _a;
|
|
@@ -18595,6 +18589,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
18595
18589
|
class StatefulWidget extends _BaseWidget__WEBPACK_IMPORTED_MODULE_0__.BaseWidget {
|
|
18596
18590
|
constructor() {
|
|
18597
18591
|
super(...arguments);
|
|
18592
|
+
this.html = "";
|
|
18598
18593
|
/**
|
|
18599
18594
|
* These are the child widgets that need to be added to this widget
|
|
18600
18595
|
*/
|
|
@@ -18620,7 +18615,7 @@ class StatefulWidget extends _BaseWidget__WEBPACK_IMPORTED_MODULE_0__.BaseWidget
|
|
|
18620
18615
|
* @returns the html string that needs to be mounted to the DOM.
|
|
18621
18616
|
*/
|
|
18622
18617
|
getHtml() {
|
|
18623
|
-
return
|
|
18618
|
+
return this.html;
|
|
18624
18619
|
}
|
|
18625
18620
|
/**
|
|
18626
18621
|
* This will help us update the data of the child widget. This will also call another function inside of the child widget
|
|
@@ -20183,6 +20178,8 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
20183
20178
|
var serviceWorker;
|
|
20184
20179
|
const TABID = Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
20185
20180
|
let subscribedListeners = [];
|
|
20181
|
+
let serviceWorkerReady = false;
|
|
20182
|
+
let messageQueue = [];
|
|
20186
20183
|
/**
|
|
20187
20184
|
* This function lets you update the access token that the package uses. If this is not passed you cannot create, update, view or delete
|
|
20188
20185
|
* Your concepts using this package.
|
|
@@ -20283,16 +20280,6 @@ function init() {
|
|
|
20283
20280
|
// console.log("Status: No active worker", registration);
|
|
20284
20281
|
// }
|
|
20285
20282
|
// });
|
|
20286
|
-
// // // for now asuming its other
|
|
20287
|
-
// // await initConceptConnection(
|
|
20288
|
-
// // url,
|
|
20289
|
-
// // aiurl,
|
|
20290
|
-
// // accessToken,
|
|
20291
|
-
// // nodeUrl,
|
|
20292
|
-
// // enableAi,
|
|
20293
|
-
// // applicationName,
|
|
20294
|
-
// // isTest
|
|
20295
|
-
// // );
|
|
20296
20283
|
// } else {
|
|
20297
20284
|
// let serviceWorkerPath = enableSW.path ? enableSW.path : './serviceWorker.bundle.js'
|
|
20298
20285
|
// if (enableSW.path && enableSW.path.slice(-1) == '/') serviceWorkerPath = enableSW.path + 'serviceWorker.bundle.js'
|
|
@@ -20328,6 +20315,25 @@ function init() {
|
|
|
20328
20315
|
reject("Not Completed Initialization");
|
|
20329
20316
|
}, 5000);
|
|
20330
20317
|
}
|
|
20318
|
+
// state change
|
|
20319
|
+
if (registration.installing || registration.waiting || registration.active) {
|
|
20320
|
+
registration.addEventListener('statechange', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
20321
|
+
var _a;
|
|
20322
|
+
if (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.state) === 'activating') {
|
|
20323
|
+
serviceWorker = navigator.serviceWorker.controller;
|
|
20324
|
+
console.log('Service Worker is activating statechange');
|
|
20325
|
+
yield sendMessage("init", {
|
|
20326
|
+
url,
|
|
20327
|
+
aiurl,
|
|
20328
|
+
accessToken,
|
|
20329
|
+
nodeUrl,
|
|
20330
|
+
enableAi,
|
|
20331
|
+
applicationName,
|
|
20332
|
+
isTest,
|
|
20333
|
+
});
|
|
20334
|
+
}
|
|
20335
|
+
}));
|
|
20336
|
+
}
|
|
20331
20337
|
// Listen for updates to the service worker
|
|
20332
20338
|
console.log("update listen start");
|
|
20333
20339
|
registration.onupdatefound = () => {
|
|
@@ -20335,7 +20341,7 @@ function init() {
|
|
|
20335
20341
|
console.log("new worker", newWorker);
|
|
20336
20342
|
if (newWorker) {
|
|
20337
20343
|
newWorker.onstatechange = () => __awaiter(this, void 0, void 0, function* () {
|
|
20338
|
-
console.log("on state change triggered");
|
|
20344
|
+
console.log("on state change triggered", (newWorker.state === "installed" || newWorker.state === "activated" || newWorker.state === 'redundant'), navigator.serviceWorker.controller);
|
|
20339
20345
|
// if (newWorker.state === 'activated' && navigator.serviceWorker.controller) {
|
|
20340
20346
|
if ((newWorker.state === "installed" || newWorker.state === "activated" || newWorker.state === 'redundant') && navigator.serviceWorker.controller) {
|
|
20341
20347
|
// && navigator.serviceWorker.controller) {
|
|
@@ -20353,6 +20359,8 @@ function init() {
|
|
|
20353
20359
|
isTest,
|
|
20354
20360
|
});
|
|
20355
20361
|
success = true;
|
|
20362
|
+
serviceWorkerReady = true;
|
|
20363
|
+
processMessageQueue();
|
|
20356
20364
|
resolve();
|
|
20357
20365
|
}
|
|
20358
20366
|
});
|
|
@@ -20361,6 +20369,7 @@ function init() {
|
|
|
20361
20369
|
// Listen for the activation of the new service worker
|
|
20362
20370
|
registration.addEventListener('controllerchange', () => __awaiter(this, void 0, void 0, function* () {
|
|
20363
20371
|
if (navigator.serviceWorker.controller) {
|
|
20372
|
+
serviceWorker = navigator.serviceWorker.controller;
|
|
20364
20373
|
console.log('Service worker has been activated');
|
|
20365
20374
|
yield sendMessage("init", {
|
|
20366
20375
|
url,
|
|
@@ -20375,6 +20384,12 @@ function init() {
|
|
|
20375
20384
|
// You can reload the page if necessary or handle the update process here
|
|
20376
20385
|
}
|
|
20377
20386
|
}));
|
|
20387
|
+
// If the service worker is already active, mark it as ready
|
|
20388
|
+
if (registration.active) {
|
|
20389
|
+
serviceWorkerReady = true;
|
|
20390
|
+
console.log('Service Worker is already active');
|
|
20391
|
+
processMessageQueue();
|
|
20392
|
+
}
|
|
20378
20393
|
}))
|
|
20379
20394
|
.catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
20380
20395
|
yield initConceptConnection();
|
|
@@ -20405,9 +20420,15 @@ function init() {
|
|
|
20405
20420
|
}
|
|
20406
20421
|
});
|
|
20407
20422
|
}
|
|
20423
|
+
/**
|
|
20424
|
+
* Method to send message to the service worker from main thread
|
|
20425
|
+
* @param type string
|
|
20426
|
+
* @param payload any
|
|
20427
|
+
* @returns Promise<any>
|
|
20428
|
+
*/
|
|
20408
20429
|
function sendMessage(type, payload) {
|
|
20409
20430
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20410
|
-
const messageId = Math.random().toString(36).substring(
|
|
20431
|
+
const messageId = Math.random().toString(36).substring(2); // Generate a unique message ID
|
|
20411
20432
|
payload.messageId = messageId;
|
|
20412
20433
|
payload.TABID = TABID;
|
|
20413
20434
|
// let actions = payload.actions
|
|
@@ -20415,61 +20436,61 @@ function sendMessage(type, payload) {
|
|
|
20415
20436
|
return new Promise((resolve, reject) => {
|
|
20416
20437
|
// navigator.serviceWorker.ready
|
|
20417
20438
|
// .then((registration) => {
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
if ((
|
|
20422
|
-
|
|
20439
|
+
if (navigator.serviceWorker.controller) {
|
|
20440
|
+
const responseHandler = (event) => {
|
|
20441
|
+
var _a, _b;
|
|
20442
|
+
if (((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.messageId) == messageId) { // Check if the message ID matches
|
|
20443
|
+
if ((_b = event.data) === null || _b === void 0 ? void 0 : _b.actions) {
|
|
20444
|
+
payload.actions = JSON.parse(JSON.stringify(event.data.actions));
|
|
20445
|
+
}
|
|
20446
|
+
resolve(event.data);
|
|
20447
|
+
navigator.serviceWorker.removeEventListener("message", responseHandler);
|
|
20423
20448
|
}
|
|
20424
|
-
|
|
20425
|
-
|
|
20449
|
+
};
|
|
20450
|
+
navigator.serviceWorker.addEventListener("message", responseHandler);
|
|
20451
|
+
// console.log("before sending message", type, 'new', newPayload);
|
|
20452
|
+
// serviceWorker?.postMessage({ type, payload });
|
|
20453
|
+
// Send the message to the service worker
|
|
20454
|
+
if (navigator.serviceWorker.controller) {
|
|
20455
|
+
try {
|
|
20456
|
+
navigator.serviceWorker.controller.postMessage({ type, payload: newPayload });
|
|
20457
|
+
}
|
|
20458
|
+
catch (err) {
|
|
20459
|
+
console.log(err);
|
|
20460
|
+
serviceWorker.postMessage({ type, payload: newPayload });
|
|
20461
|
+
}
|
|
20462
|
+
// navigator.serviceWorker.controller.postMessage({ type, payload });
|
|
20426
20463
|
}
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20434
|
-
|
|
20464
|
+
else {
|
|
20465
|
+
// wait one second before checking again
|
|
20466
|
+
setTimeout(() => {
|
|
20467
|
+
// if (navigator.serviceWorker.controller) {
|
|
20468
|
+
if (serviceWorker) {
|
|
20469
|
+
serviceWorker.postMessage({ type, payload });
|
|
20470
|
+
// navigator.serviceWorker.controller.postMessage({ type, payload });
|
|
20471
|
+
}
|
|
20472
|
+
else {
|
|
20473
|
+
console.log('not ready', type);
|
|
20474
|
+
reject("Service worker not ready");
|
|
20475
|
+
}
|
|
20476
|
+
}, 90000); // 90 seconds
|
|
20477
|
+
}
|
|
20478
|
+
// Timeout for waiting for the response (e.g., 5 seconds)
|
|
20479
|
+
setTimeout(() => {
|
|
20480
|
+
reject("No response from service worker after timeout");
|
|
20481
|
+
navigator.serviceWorker.removeEventListener("message", responseHandler);
|
|
20482
|
+
}, 90000); // 90 sec
|
|
20435
20483
|
}
|
|
20436
20484
|
else {
|
|
20437
|
-
|
|
20438
|
-
|
|
20439
|
-
// if (navigator.serviceWorker.controller) {
|
|
20440
|
-
if (serviceWorker) {
|
|
20441
|
-
serviceWorker.postMessage({ type, payload });
|
|
20442
|
-
// navigator.serviceWorker.controller.postMessage({ type, payload });
|
|
20443
|
-
}
|
|
20444
|
-
else {
|
|
20445
|
-
console.log('not ready', type);
|
|
20446
|
-
reject("Service worker not ready");
|
|
20447
|
-
}
|
|
20448
|
-
}, 60000); // 60 seconds
|
|
20485
|
+
messageQueue.push({ message: { type, payload: newPayload } });
|
|
20486
|
+
console.log('Message Queued', type, payload);
|
|
20449
20487
|
}
|
|
20450
|
-
// Timeout for waiting for the response (e.g., 5 seconds)
|
|
20451
|
-
setTimeout(() => {
|
|
20452
|
-
reject("No response from service worker after timeout");
|
|
20453
|
-
navigator.serviceWorker.removeEventListener("message", responseHandler);
|
|
20454
|
-
}, 60000); // 60 sec
|
|
20455
20488
|
// })
|
|
20456
20489
|
// .catch(err => reject(err))
|
|
20457
20490
|
// .finally(() => console.log('finally'))
|
|
20458
20491
|
});
|
|
20459
20492
|
});
|
|
20460
20493
|
}
|
|
20461
|
-
function dispatchIdEvent(id, data = {}) {
|
|
20462
|
-
// console.log('id event dispatched', id)
|
|
20463
|
-
if (serviceWorker) {
|
|
20464
|
-
// let event = new Event(`${id}`);
|
|
20465
|
-
let event = new CustomEvent(`${id}`, data);
|
|
20466
|
-
console.log("event fired from", event);
|
|
20467
|
-
dispatchEvent(event);
|
|
20468
|
-
}
|
|
20469
|
-
else {
|
|
20470
|
-
_Constants_general_const__WEBPACK_IMPORTED_MODULE_100__.broadcastChannel.postMessage({ type: 'dispatchEvent', payload: { id } });
|
|
20471
|
-
}
|
|
20472
|
-
}
|
|
20473
20494
|
// export function sendMessage(type: string, payload: any) {
|
|
20474
20495
|
// return new Promise((resolve) => {
|
|
20475
20496
|
// const responseHandler = (event: any) => {
|
|
@@ -20498,8 +20519,27 @@ const broadcastActions = {
|
|
|
20498
20519
|
// });
|
|
20499
20520
|
// });
|
|
20500
20521
|
return { success: true };
|
|
20522
|
+
}),
|
|
20523
|
+
checkInit: (payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20524
|
+
console.log('service worker init 0');
|
|
20525
|
+
if (navigator.serviceWorker.controller) {
|
|
20526
|
+
console.log('service worker init 1');
|
|
20527
|
+
serviceWorker = navigator.serviceWorker.controller;
|
|
20528
|
+
}
|
|
20529
|
+
yield sendMessage("init", {
|
|
20530
|
+
url: _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.BASE_URL,
|
|
20531
|
+
aiurl: _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.AI_URL,
|
|
20532
|
+
accessToken: _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_99__.TokenStorage.BearerAccessToken,
|
|
20533
|
+
nodeUrl: _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.NODE_URL,
|
|
20534
|
+
enableAi: false,
|
|
20535
|
+
applicationName: _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.BASE_APPLICATION
|
|
20536
|
+
});
|
|
20537
|
+
return { success: true };
|
|
20501
20538
|
})
|
|
20502
20539
|
};
|
|
20540
|
+
/**
|
|
20541
|
+
* Method to trigger broadcast message listener
|
|
20542
|
+
*/
|
|
20503
20543
|
function listenBroadCastMessages() {
|
|
20504
20544
|
// broadcast event can be listened through both the service worker and other tabs
|
|
20505
20545
|
_Constants_general_const__WEBPACK_IMPORTED_MODULE_100__.broadcastChannel.addEventListener('message', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -20613,6 +20653,31 @@ function initConceptConnection() {
|
|
|
20613
20653
|
});
|
|
20614
20654
|
});
|
|
20615
20655
|
}
|
|
20656
|
+
/**
|
|
20657
|
+
* Method to dispatch Event received from SW
|
|
20658
|
+
* @param id number|string
|
|
20659
|
+
* @param data any
|
|
20660
|
+
*/
|
|
20661
|
+
function dispatchIdEvent(id, data = {}) {
|
|
20662
|
+
// console.log('id event dispatched', id)
|
|
20663
|
+
if (serviceWorker) {
|
|
20664
|
+
// let event = new Event(`${id}`);
|
|
20665
|
+
let event = new CustomEvent(`${id}`, data);
|
|
20666
|
+
console.log("event fired from", event);
|
|
20667
|
+
dispatchEvent(event);
|
|
20668
|
+
}
|
|
20669
|
+
else {
|
|
20670
|
+
_Constants_general_const__WEBPACK_IMPORTED_MODULE_100__.broadcastChannel.postMessage({ type: 'dispatchEvent', payload: { id } });
|
|
20671
|
+
}
|
|
20672
|
+
}
|
|
20673
|
+
function processMessageQueue() {
|
|
20674
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20675
|
+
while (messageQueue.length > 0) {
|
|
20676
|
+
const { message, resolve, reject } = messageQueue.shift();
|
|
20677
|
+
yield sendMessage(message.type, message.payload);
|
|
20678
|
+
}
|
|
20679
|
+
});
|
|
20680
|
+
}
|
|
20616
20681
|
|
|
20617
20682
|
|
|
20618
20683
|
/***/ })
|