mftsccs-browser 1.1.29-beta → 1.1.30-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 +174 -68
- package/dist/main.bundle.js.map +1 -1
- package/dist/serviceWorker.bundle.js +176 -71
- package/dist/serviceWorker.bundle.js.map +1 -1
- package/dist/types/Api/Create/CreateTheGhostConceptApi.d.ts +1 -4
- package/dist/types/Widgets/BuilderStatefulWidget.d.ts +1 -1
- package/package.json +1 -1
package/dist/main.bundle.js
CHANGED
|
@@ -475,46 +475,128 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
475
475
|
|
|
476
476
|
function CreateTheGhostConceptApi(conceptData, connectionData) {
|
|
477
477
|
return __awaiter(this, void 0, void 0, function* () {
|
|
478
|
-
let result = {
|
|
479
|
-
"concepts": [],
|
|
480
|
-
"connections": []
|
|
481
|
-
};
|
|
482
478
|
try {
|
|
483
|
-
const
|
|
484
|
-
let
|
|
485
|
-
"concepts":
|
|
486
|
-
"connections":
|
|
479
|
+
const CHUNK_SIZE = 1000;
|
|
480
|
+
let result = {
|
|
481
|
+
"concepts": [],
|
|
482
|
+
"connections": []
|
|
487
483
|
};
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
//
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
484
|
+
// strip data
|
|
485
|
+
const stripedConcept = yield stripTypeFromConceptOrConnection(conceptData);
|
|
486
|
+
const stripedConnection = yield stripTypeFromConceptOrConnection(connectionData);
|
|
487
|
+
// sync all in one request if data is less
|
|
488
|
+
if (conceptData.length + connectionData.length <= (CHUNK_SIZE * 2)) {
|
|
489
|
+
const response = yield syncConceptConnection(stripedConcept, stripedConnection);
|
|
490
|
+
if (Array.isArray(response === null || response === void 0 ? void 0 : response.concepts))
|
|
491
|
+
result.concepts = [...result.concepts, ...response.concepts];
|
|
492
|
+
if (Array.isArray(response === null || response === void 0 ? void 0 : response.connections))
|
|
493
|
+
result.connections = [...result.connections, ...response.connections];
|
|
494
|
+
return result;
|
|
495
|
+
}
|
|
496
|
+
// split data
|
|
497
|
+
const splittedConcepts = chunkArrayByItemCount(stripedConcept, CHUNK_SIZE);
|
|
498
|
+
const splittedConnections = chunkArrayByItemCount(stripedConnection, CHUNK_SIZE);
|
|
499
|
+
const syncConceptPromises = [];
|
|
500
|
+
const syncConnectionPromises = [];
|
|
501
|
+
// sync concept
|
|
502
|
+
for (let i = 0; i < splittedConcepts.length; i++) {
|
|
503
|
+
const concepts = splittedConcepts[i];
|
|
504
|
+
syncConceptPromises.push(syncConceptConnection(concepts, []));
|
|
505
|
+
}
|
|
506
|
+
const conceptResponses = yield Promise.all(syncConceptPromises);
|
|
507
|
+
for (let i = 0; i < conceptResponses.length; i++) {
|
|
508
|
+
const conceptsRes = conceptResponses[i];
|
|
509
|
+
if (Array.isArray(conceptsRes === null || conceptsRes === void 0 ? void 0 : conceptsRes.concepts))
|
|
510
|
+
result.concepts = [...result.concepts, ...conceptsRes.concepts];
|
|
511
|
+
if (Array.isArray(conceptsRes === null || conceptsRes === void 0 ? void 0 : conceptsRes.connections))
|
|
512
|
+
result.connections = [...result.connections, ...conceptsRes.connections];
|
|
513
|
+
}
|
|
514
|
+
// sync connection
|
|
515
|
+
for (let i = 0; i < splittedConnections.length; i++) {
|
|
516
|
+
const connections = splittedConnections[i];
|
|
517
|
+
syncConnectionPromises.push(syncConceptConnection([], connections));
|
|
518
|
+
}
|
|
519
|
+
const connectionResponses = yield Promise.all(syncConnectionPromises);
|
|
520
|
+
for (let i = 0; i < connectionResponses.length; i++) {
|
|
521
|
+
const connectionsRes = connectionResponses[i];
|
|
522
|
+
if (Array.isArray(connectionsRes === null || connectionsRes === void 0 ? void 0 : connectionsRes.concepts))
|
|
523
|
+
result.concepts = [...result.concepts, ...connectionsRes.concepts];
|
|
524
|
+
if (Array.isArray(connectionsRes === null || connectionsRes === void 0 ? void 0 : connectionsRes.connections))
|
|
525
|
+
result.connections = [...result.connections, ...connectionsRes.connections];
|
|
501
526
|
}
|
|
502
|
-
const resultString = yield response.json();
|
|
503
|
-
result.concepts = resultString.concepts;
|
|
504
|
-
result.connections = resultString.connections;
|
|
505
527
|
return result;
|
|
506
528
|
}
|
|
507
529
|
catch (error) {
|
|
508
|
-
|
|
509
|
-
console.log('Create the concept api error message: ', error.message);
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
console.log('Create the concept api unexpected error: ', error);
|
|
513
|
-
}
|
|
530
|
+
console.log(error);
|
|
514
531
|
throw error;
|
|
515
532
|
}
|
|
516
533
|
});
|
|
517
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
*
|
|
537
|
+
* @param concepts Concept[]
|
|
538
|
+
* @param connections Connection[]
|
|
539
|
+
* @returns Promise<{concepts: [], connections: []}>
|
|
540
|
+
*/
|
|
541
|
+
const syncConceptConnection = (concepts, connections) => __awaiter(void 0, void 0, void 0, function* () {
|
|
542
|
+
let result = {
|
|
543
|
+
"concepts": [],
|
|
544
|
+
"connections": []
|
|
545
|
+
};
|
|
546
|
+
try {
|
|
547
|
+
const myHeaders = new Headers();
|
|
548
|
+
let myBody = {
|
|
549
|
+
"concepts": concepts,
|
|
550
|
+
"connections": connections
|
|
551
|
+
};
|
|
552
|
+
myHeaders.set("Content-Type", "application/json");
|
|
553
|
+
myHeaders.set('Authorization', "Bearer " + _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken);
|
|
554
|
+
myHeaders.set('Accept', 'application/json');
|
|
555
|
+
// myHeaders.set('Randomizer', BaseUrl.BASE_RANDOMIZER.toString());
|
|
556
|
+
myHeaders.set('Randomizer', _DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_0__.BaseUrl.getRandomizer().toString());
|
|
557
|
+
const response = yield fetch(_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_0__.BaseUrl.CreateGhostConceptApiUrl(), {
|
|
558
|
+
method: 'POST',
|
|
559
|
+
headers: myHeaders,
|
|
560
|
+
body: JSON.stringify(myBody),
|
|
561
|
+
});
|
|
562
|
+
if (!response.ok) {
|
|
563
|
+
(0,_Services_Common_ErrorPosting__WEBPACK_IMPORTED_MODULE_2__.HandleHttpError)(response);
|
|
564
|
+
throw new Error(`Error! status: ${response.status}`);
|
|
565
|
+
}
|
|
566
|
+
const resultString = yield response.json();
|
|
567
|
+
result.concepts = resultString.concepts;
|
|
568
|
+
result.connections = resultString.connections;
|
|
569
|
+
return result;
|
|
570
|
+
}
|
|
571
|
+
catch (error) {
|
|
572
|
+
if (error instanceof Error) {
|
|
573
|
+
console.log('Create the concept api error message: ', error.message);
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
console.log('Create the concept api unexpected error: ', error);
|
|
577
|
+
}
|
|
578
|
+
throw error;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
// Function to split an array into chunks of 1024 items (500KB per chunk)
|
|
582
|
+
function chunkArrayByItemCount(array, itemsPerChunk) {
|
|
583
|
+
const chunks = [];
|
|
584
|
+
for (let i = 0; i < array.length; i += itemsPerChunk) {
|
|
585
|
+
const chunk = array.slice(i, i + itemsPerChunk); // Slice the array into smaller chunks
|
|
586
|
+
chunks.push(chunk);
|
|
587
|
+
}
|
|
588
|
+
return chunks;
|
|
589
|
+
}
|
|
590
|
+
// method to strip type object from concept or connection
|
|
591
|
+
const stripTypeFromConceptOrConnection = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (items = []) {
|
|
592
|
+
return yield Promise.all(items.map(item => {
|
|
593
|
+
let newItem = JSON.parse(JSON.stringify(item));
|
|
594
|
+
delete newItem.type;
|
|
595
|
+
delete newItem.ofConcept;
|
|
596
|
+
delete newItem.toConcept;
|
|
597
|
+
return newItem;
|
|
598
|
+
}));
|
|
599
|
+
});
|
|
518
600
|
|
|
519
601
|
|
|
520
602
|
/***/ }),
|
|
@@ -9872,7 +9954,7 @@ function storeToDatabase(databaseName, object) {
|
|
|
9872
9954
|
*/
|
|
9873
9955
|
function UpdateToDatabase(databaseName, object) {
|
|
9874
9956
|
return new Promise(function (resolve, reject) {
|
|
9875
|
-
console.log("this is wriring to the database local", object);
|
|
9957
|
+
// console.log("this is wriring to the database local", object);
|
|
9876
9958
|
openDatabase(databaseName).then((db) => {
|
|
9877
9959
|
let transaction = db.transaction(databaseName, "readwrite");
|
|
9878
9960
|
let objStore = transaction.objectStore(databaseName);
|
|
@@ -10126,7 +10208,7 @@ function storeToDatabase(databaseName, object) {
|
|
|
10126
10208
|
*/
|
|
10127
10209
|
function UpdateToDatabase(databaseName, object) {
|
|
10128
10210
|
return new Promise(function (resolve, reject) {
|
|
10129
|
-
console.log("this is wriring to the database", object);
|
|
10211
|
+
// console.log("this is wriring to the database", object);
|
|
10130
10212
|
openDatabase(databaseName).then((db) => {
|
|
10131
10213
|
let transaction = db.transaction(databaseName, "readwrite");
|
|
10132
10214
|
let objStore = transaction.objectStore(databaseName);
|
|
@@ -14364,7 +14446,7 @@ function CreateTheConceptLocal(referent_1, typecharacter_1, userId_1, categoryId
|
|
|
14364
14446
|
}
|
|
14365
14447
|
//let id = -Math.floor(Math.random() * 100000000);
|
|
14366
14448
|
let id = yield _DataStructures_Local_LocalId__WEBPACK_IMPORTED_MODULE_3__.LocalId.getConceptId();
|
|
14367
|
-
console.log("this is the getting id type connection", id);
|
|
14449
|
+
// console.log("this is the getting id type connection", id);
|
|
14368
14450
|
let isNew = true;
|
|
14369
14451
|
let created_on = new Date();
|
|
14370
14452
|
let updated_on = new Date();
|
|
@@ -18390,7 +18472,7 @@ class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__
|
|
|
18390
18472
|
* This function will be called after the component mounts.
|
|
18391
18473
|
*/
|
|
18392
18474
|
componentDidMount() {
|
|
18393
|
-
return __awaiter(this,
|
|
18475
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18394
18476
|
//console.log("onmountVal", onmountVal);
|
|
18395
18477
|
const AsyncFunction = Object.getPrototypeOf(function () {
|
|
18396
18478
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
@@ -18404,6 +18486,13 @@ class BuilderStatefulWidget extends _StatefulWidget__WEBPACK_IMPORTED_MODULE_0__
|
|
|
18404
18486
|
const AsyncFunction = Object.getPrototypeOf(function () {
|
|
18405
18487
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
18406
18488
|
}).constructor;
|
|
18489
|
+
// const dynamicAsyncFunction = new Function("tsccs",`
|
|
18490
|
+
// return (async function() {
|
|
18491
|
+
// ${this.addEventFunction}
|
|
18492
|
+
// }).call(this);
|
|
18493
|
+
// `).bind(this);
|
|
18494
|
+
// console.log("This is the async function", dynamicAsyncFunction);
|
|
18495
|
+
// dynamicAsyncFunction(tsccs);
|
|
18407
18496
|
const renderOnmount = AsyncFunction("tsccs", this.addEventFunction);
|
|
18408
18497
|
renderOnmount.call(this, _app__WEBPACK_IMPORTED_MODULE_1__);
|
|
18409
18498
|
});
|
|
@@ -20171,6 +20260,7 @@ function init() {
|
|
|
20171
20260
|
// else if (enableSW.path && enableSW.path.length > 2 && !enableSW.path.includes('serviceWorker.bundle.js')) serviceWorkerPath = enableSW.path + './serviceWorker.bundle.js'
|
|
20172
20261
|
yield new Promise((resolve, reject) => {
|
|
20173
20262
|
var _a, _b;
|
|
20263
|
+
let success = false;
|
|
20174
20264
|
navigator.serviceWorker
|
|
20175
20265
|
.register((_a = enableSW.pathToSW) !== null && _a !== void 0 ? _a : "./serviceWorker.bundle.js", {
|
|
20176
20266
|
// type: "module",
|
|
@@ -20193,43 +20283,59 @@ function init() {
|
|
|
20193
20283
|
resolve();
|
|
20194
20284
|
}
|
|
20195
20285
|
else {
|
|
20196
|
-
let success = false;
|
|
20197
|
-
// Listen for updates to the service worker
|
|
20198
|
-
console.log("update listen start");
|
|
20199
|
-
registration.onupdatefound = () => {
|
|
20200
|
-
const newWorker = registration.installing;
|
|
20201
|
-
console.log("new worker", newWorker);
|
|
20202
|
-
if (newWorker) {
|
|
20203
|
-
newWorker.onstatechange = () => __awaiter(this, void 0, void 0, function* () {
|
|
20204
|
-
console.log("on state change triggered");
|
|
20205
|
-
// if (newWorker.state === 'activated' && navigator.serviceWorker.controller) {
|
|
20206
|
-
if (newWorker.state === "activated" || newWorker.state === 'redundant') {
|
|
20207
|
-
// && navigator.serviceWorker.controller) {
|
|
20208
|
-
console.log("New Service Worker is active", registration);
|
|
20209
|
-
serviceWorker = newWorker;
|
|
20210
|
-
// serviceWorker = registration.active;
|
|
20211
|
-
// Send init message now that it's active
|
|
20212
|
-
yield sendMessage("init", {
|
|
20213
|
-
url,
|
|
20214
|
-
aiurl,
|
|
20215
|
-
accessToken,
|
|
20216
|
-
nodeUrl,
|
|
20217
|
-
enableAi,
|
|
20218
|
-
applicationName,
|
|
20219
|
-
isTest,
|
|
20220
|
-
});
|
|
20221
|
-
success = true;
|
|
20222
|
-
resolve();
|
|
20223
|
-
}
|
|
20224
|
-
});
|
|
20225
|
-
}
|
|
20226
|
-
};
|
|
20227
20286
|
// Handle if on state change didn't trigger
|
|
20228
20287
|
setTimeout(() => {
|
|
20229
20288
|
if (!success)
|
|
20230
20289
|
reject("Not Completed Initialization");
|
|
20231
|
-
},
|
|
20290
|
+
}, 5000);
|
|
20232
20291
|
}
|
|
20292
|
+
// Listen for updates to the service worker
|
|
20293
|
+
console.log("update listen start");
|
|
20294
|
+
registration.onupdatefound = () => {
|
|
20295
|
+
const newWorker = registration.installing;
|
|
20296
|
+
console.log("new worker", newWorker);
|
|
20297
|
+
if (newWorker) {
|
|
20298
|
+
newWorker.onstatechange = () => __awaiter(this, void 0, void 0, function* () {
|
|
20299
|
+
console.log("on state change triggered");
|
|
20300
|
+
// if (newWorker.state === 'activated' && navigator.serviceWorker.controller) {
|
|
20301
|
+
if ((newWorker.state === "installed" || newWorker.state === "activated" || newWorker.state === 'redundant') && navigator.serviceWorker.controller) {
|
|
20302
|
+
// && navigator.serviceWorker.controller) {
|
|
20303
|
+
console.log("New Service Worker is active", registration);
|
|
20304
|
+
serviceWorker = newWorker;
|
|
20305
|
+
// serviceWorker = registration.active;
|
|
20306
|
+
// Send init message now that it's active
|
|
20307
|
+
yield sendMessage("init", {
|
|
20308
|
+
url,
|
|
20309
|
+
aiurl,
|
|
20310
|
+
accessToken,
|
|
20311
|
+
nodeUrl,
|
|
20312
|
+
enableAi,
|
|
20313
|
+
applicationName,
|
|
20314
|
+
isTest,
|
|
20315
|
+
});
|
|
20316
|
+
success = true;
|
|
20317
|
+
resolve();
|
|
20318
|
+
}
|
|
20319
|
+
});
|
|
20320
|
+
}
|
|
20321
|
+
};
|
|
20322
|
+
// Listen for the activation of the new service worker
|
|
20323
|
+
registration.addEventListener('controllerchange', () => __awaiter(this, void 0, void 0, function* () {
|
|
20324
|
+
if (navigator.serviceWorker.controller) {
|
|
20325
|
+
console.log('Service worker has been activated');
|
|
20326
|
+
yield sendMessage("init", {
|
|
20327
|
+
url,
|
|
20328
|
+
aiurl,
|
|
20329
|
+
accessToken,
|
|
20330
|
+
nodeUrl,
|
|
20331
|
+
enableAi,
|
|
20332
|
+
applicationName,
|
|
20333
|
+
isTest,
|
|
20334
|
+
});
|
|
20335
|
+
// The new service worker is now controlling the page
|
|
20336
|
+
// You can reload the page if necessary or handle the update process here
|
|
20337
|
+
}
|
|
20338
|
+
}));
|
|
20233
20339
|
}))
|
|
20234
20340
|
.catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
20235
20341
|
yield initConceptConnection();
|
|
@@ -20300,13 +20406,13 @@ function sendMessage(type, payload) {
|
|
|
20300
20406
|
console.log('not ready', type);
|
|
20301
20407
|
reject("Service worker not ready");
|
|
20302
20408
|
}
|
|
20303
|
-
},
|
|
20409
|
+
}, 60000); // 60 seconds
|
|
20304
20410
|
}
|
|
20305
20411
|
// Timeout for waiting for the response (e.g., 5 seconds)
|
|
20306
20412
|
setTimeout(() => {
|
|
20307
20413
|
reject("No response from service worker after timeout");
|
|
20308
20414
|
navigator.serviceWorker.removeEventListener("message", responseHandler);
|
|
20309
|
-
},
|
|
20415
|
+
}, 60000); // 60 sec
|
|
20310
20416
|
// })
|
|
20311
20417
|
// .catch(err => reject(err))
|
|
20312
20418
|
// .finally(() => console.log('finally'))
|