@gudhub/core 1.2.4-beta.5 → 1.2.4-beta.51
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/.parcel-cache/61134f48017c9cc1-AssetGraph +0 -0
- package/.parcel-cache/72a0445d2e7372b4-BundleGraph +0 -0
- package/.parcel-cache/83e7562660f7cc15-BundleGraph +0 -0
- package/.parcel-cache/9a0d07555444f4da-AssetGraph +0 -0
- package/.parcel-cache/d3a1b9507cb44047-AssetGraph +0 -0
- package/.parcel-cache/d647b2950bce7da7-RequestGraph +0 -0
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/dc1da35000e13623-RequestGraph +0 -0
- package/.parcel-cache/lock.mdb +0 -0
- package/.parcel-cache/snapshot-d647b2950bce7da7.txt +28892 -0
- package/.parcel-cache/snapshot-dc1da35000e13623.txt +28770 -0
- package/.parcelrc.appRequestWorker +4 -0
- package/GUDHUB/AppProcessor/AppProcessor.js +60 -24
- package/GUDHUB/ChunksManager/ChunksManager.test.js +11 -4
- package/GUDHUB/DataService/AppDataService.js +36 -1
- package/GUDHUB/DataService/ChunkDataService.js +7 -1
- package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +799 -68
- package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +118 -85
- package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +171 -7
- package/GUDHUB/DataService/IndexedDB/StoreManager/BaseStoreManager.js +97 -0
- package/GUDHUB/DataService/IndexedDB/StoreManager/managers.js +77 -0
- package/GUDHUB/DataService/IndexedDB/appDataConf.js +6 -3
- package/GUDHUB/DataService/IndexedDB/appRequestWorker.js +164 -0
- package/GUDHUB/DataService/IndexedDB/chunkDataConf.js +3 -3
- package/GUDHUB/DataService/IndexedDB/consts.js +1 -1
- package/GUDHUB/DataService/IndexedDB/init.js +18 -17
- package/GUDHUB/DataService/IndexedDB/storeManagerConf/chunkCacheStoreManagerConf.js +11 -0
- package/GUDHUB/DataService/IndexedDB/storeManagerConf/init.js +1 -0
- package/GUDHUB/DataService/export.js +69 -14
- package/GUDHUB/DataService/httpService/AppHttpService.js +14 -6
- package/GUDHUB/DataService/httpService/ChunkHttpService.js +41 -26
- package/GUDHUB/DataService/utils.js +27 -27
- package/GUDHUB/FileManager/FileManager.js +7 -3
- package/GUDHUB/GHConstructor/createAngularModuleInstance.js +63 -42
- package/GUDHUB/GHConstructor/createClassInstance.js +8 -3
- package/GUDHUB/ItemProcessor/ItemProcessor.js +16 -1
- package/GUDHUB/Storage/ModulesList.js +42 -2
- package/GUDHUB/Utils/AppsTemplateService/AppsTemplateService.js +48 -5
- package/GUDHUB/Utils/Utils.js +29 -1
- package/GUDHUB/Utils/get_date/get_date.test.js +3 -12
- package/GUDHUB/Utils/merge_chunks/merge_chunks.js +36 -28
- package/GUDHUB/Utils/merge_chunks/merge_chunks.worker.js +78 -0
- package/GUDHUB/Utils/merge_compare_items/merge_compare_items.js +40 -9
- package/GUDHUB/Utils/nested_list/nested_list.js +53 -50
- package/GUDHUB/Utils/nested_list/nested_list.test.js +140 -2
- package/GUDHUB/WebSocket/WebSocket.js +2 -1
- package/GUDHUB/api/AppApi.js +13 -13
- package/GUDHUB/api/ChunkApi.js +5 -5
- package/GUDHUB/config.js +11 -2
- package/GUDHUB/consts.js +15 -1
- package/GUDHUB/gudhub.js +50 -23
- package/GUDHUB/gudhubAppRequestWorker.js +18 -0
- package/build.sh +91 -0
- package/dist/gudhub.es.js +15791 -0
- package/dist/gudhub.umd.js +195 -0
- package/index.js +3 -1
- package/indexUMD.js +0 -2
- package/indextest.html +35 -0
- package/package.json +38 -22
- package/vite.config.esm.js +67 -0
- package/vite.config.umd.js +66 -0
- package/GUDHUB/ChunksManager/ChunksManager.js +0 -68
- package/umd/library.min.js +0 -2
- package/umd/library.min.js.LICENSE.txt +0 -13
- package/umd/library.min.js.map +0 -1
- package/webpack.config.js +0 -33
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IS_BROWSER_MAIN_THREAD } from "../consts.js";
|
|
2
2
|
|
|
3
3
|
export class AppProcessor {
|
|
4
4
|
constructor(
|
|
@@ -6,7 +6,6 @@ export class AppProcessor {
|
|
|
6
6
|
pipeService,
|
|
7
7
|
req,
|
|
8
8
|
websocket,
|
|
9
|
-
chunksManager,
|
|
10
9
|
util,
|
|
11
10
|
activateSW,
|
|
12
11
|
dataService,
|
|
@@ -17,10 +16,11 @@ export class AppProcessor {
|
|
|
17
16
|
this.ws = websocket;
|
|
18
17
|
this.applistReceived = false;
|
|
19
18
|
this.activateSW = activateSW; // we use this flag to check if applist was received. The problem is that if you receive an app it also goes to app_list as a result you have the app_list with one app.
|
|
20
|
-
this.chunksManager = chunksManager;
|
|
21
19
|
this.util = util;
|
|
22
20
|
this.appListeners();
|
|
23
21
|
this.dataService = dataService;
|
|
22
|
+
|
|
23
|
+
this.appRequestCache = new Map;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async createNewAppApi(app) {
|
|
@@ -230,7 +230,7 @@ export class AppProcessor {
|
|
|
230
230
|
// Here we get default user's app
|
|
231
231
|
// We do it here to do it only once
|
|
232
232
|
// We do it because we need to initialize WebSockets, which we do in getApp method
|
|
233
|
-
this.getApp(this.storage.getUser().app_init);
|
|
233
|
+
// this.getApp(this.storage.getUser().app_init); // commented due to unfinished app_init development, its shape causes exceptions
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
return app_list;
|
|
@@ -255,27 +255,48 @@ export class AppProcessor {
|
|
|
255
255
|
let app = this.getAppFromStorage(app_id);
|
|
256
256
|
if (app) return app;
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
if (!receivedApp) return;
|
|
258
|
+
if (this.appRequestCache.has(app_id)) return this.appRequestCache.get(app_id);
|
|
260
259
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
260
|
+
let self = this;
|
|
261
|
+
|
|
262
|
+
let pr = new Promise(async (resolve, reject) => {
|
|
263
|
+
try {
|
|
264
|
+
let app = await self.dataService.getApp(app_id);
|
|
265
|
+
if (!app) reject();
|
|
266
|
+
|
|
267
|
+
//!!! temporary check !!!! if app has chanks property then we start getting it
|
|
268
|
+
// if (
|
|
269
|
+
// receivedApp.chunks &&
|
|
270
|
+
// receivedApp.chunks.length
|
|
271
|
+
// ) {
|
|
272
|
+
// // here should be checked is merge required
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
// let chunks = await self.chunksManager.getChunks(app_id, receivedApp.chunks);
|
|
276
|
+
// receivedApp.items_list = self.util.mergeChunks([
|
|
277
|
+
// ...chunks,
|
|
278
|
+
// receivedApp,
|
|
279
|
+
// ]);
|
|
280
|
+
// }
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
// This code for trash must be changed
|
|
284
|
+
// return trash ? app : {...app, items_list: app.items_list.filter(item => !item.trash)};
|
|
285
|
+
let filtered = trash ? app : {...app, items_list: app.items_list.filter(item => !item.trash)};
|
|
286
|
+
filtered = trash ? filtered : {...filtered, field_list: filtered.field_list.filter(f => !f.trash)};
|
|
272
287
|
|
|
273
|
-
|
|
274
|
-
|
|
288
|
+
resolve(filtered);
|
|
289
|
+
|
|
290
|
+
self.saveAppInStorage(filtered);
|
|
291
|
+
self.ws.addSubscription(app_id);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
reject();
|
|
294
|
+
}
|
|
295
|
+
});
|
|
275
296
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
297
|
+
self.appRequestCache.set(app_id, pr);
|
|
298
|
+
|
|
299
|
+
return pr;
|
|
279
300
|
}
|
|
280
301
|
|
|
281
302
|
async updateApp(app) {
|
|
@@ -319,6 +340,18 @@ export class AppProcessor {
|
|
|
319
340
|
}
|
|
320
341
|
}
|
|
321
342
|
|
|
343
|
+
async handleAppChange(id, prevVersion, nextVersion) {
|
|
344
|
+
let res1 = this.util.areViewListsEqual(prevVersion.views_list, nextVersion.views_list);
|
|
345
|
+
let res2 = this.util.areFieldListsEqual(prevVersion.field_list, nextVersion.field_list);
|
|
346
|
+
|
|
347
|
+
if (
|
|
348
|
+
res1 ||
|
|
349
|
+
res2
|
|
350
|
+
) {
|
|
351
|
+
this.updateAppFieldsAndViews({id, views_list: nextVersion.views_list, field_list: nextVersion.field_list});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
322
355
|
clearAppProcessor() {
|
|
323
356
|
this.getAppListPromises = null;
|
|
324
357
|
this.getAppPromises = {};
|
|
@@ -415,7 +448,10 @@ export class AppProcessor {
|
|
|
415
448
|
appsList
|
|
416
449
|
);
|
|
417
450
|
});
|
|
418
|
-
if (
|
|
451
|
+
if (
|
|
452
|
+
IS_BROWSER_MAIN_THREAD &&
|
|
453
|
+
this.activateSW
|
|
454
|
+
) {
|
|
419
455
|
navigator.serviceWorker.addEventListener("message", async (event) => {
|
|
420
456
|
if (event.data.type === "refresh app") {
|
|
421
457
|
const app = await this.getApp(event.data.payload.app_id);
|
|
@@ -457,7 +493,7 @@ export class AppProcessor {
|
|
|
457
493
|
}
|
|
458
494
|
);
|
|
459
495
|
}
|
|
460
|
-
event.data.payload.items_list = this.util.mergeChunks([app, event.data.payload])
|
|
496
|
+
event.data.payload.items_list = await this.util.mergeChunks([app, event.data.payload])
|
|
461
497
|
this.saveAppInStorage(event.data.payload);
|
|
462
498
|
}
|
|
463
499
|
// if (event.data.type === "refresh appList") {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import should from "should";
|
|
2
2
|
import {GudHub} from './../gudhub.js';
|
|
3
|
+
import { ChunkDataService } from "../DataService/export.js";
|
|
4
|
+
|
|
5
|
+
throw new Error;
|
|
6
|
+
//TODO test is outdated, Chunks Manager removed, added ChunkDataService
|
|
3
7
|
|
|
4
8
|
describe("CHUNKS MANAGER", async function() {
|
|
5
9
|
const auth_key = 'Z/lxMHLenEaQTvPjW5U6c3jBDwWFYZrh2F9Kxa3fbt8drvabS2u2lXQ2zI+SRmic';
|
|
@@ -9,7 +13,10 @@ describe("CHUNKS MANAGER", async function() {
|
|
|
9
13
|
it("GET CHUNK : here we get first chunk from App", async function () {
|
|
10
14
|
this.timeout(10000);
|
|
11
15
|
var app = await gudhub.getApp(8263);
|
|
12
|
-
|
|
16
|
+
|
|
17
|
+
let chunkDataService = new ChunkDataService(); //TODO args
|
|
18
|
+
|
|
19
|
+
let firstChunk = await gudhub.chunksManager.getChunk(8263, app.chunks[0]);// getapp - get firstChunk from it and then load via service or via api, maybe create here chunkDataService instance
|
|
13
20
|
firstChunk.should.have.property("chunk_number");
|
|
14
21
|
firstChunk.should.have.property("items_list");
|
|
15
22
|
firstChunk.items_list[0].fields[0].should.have.property("history");
|
|
@@ -18,7 +25,7 @@ describe("CHUNKS MANAGER", async function() {
|
|
|
18
25
|
|
|
19
26
|
it("GET LAST CHUNK : here we should get last chunk", async function () {
|
|
20
27
|
this.timeout(5000);
|
|
21
|
-
let firstChunk = await gudhub.chunksManager.getLastChunk(8263)
|
|
28
|
+
let firstChunk = await gudhub.chunksManager.getLastChunk(8263);//
|
|
22
29
|
|
|
23
30
|
firstChunk.should.have.property("chunk_number");
|
|
24
31
|
firstChunk.should.have.property("items_list");
|
|
@@ -27,7 +34,7 @@ describe("CHUNKS MANAGER", async function() {
|
|
|
27
34
|
|
|
28
35
|
|
|
29
36
|
it("GET CHUNKS : here we getting chanks from empty array []", async function () {
|
|
30
|
-
let chunkedItems = await gudhub.chunksManager.getChunks(8263, [])
|
|
37
|
+
let chunkedItems = await gudhub.chunksManager.getChunks(8263, []);//
|
|
31
38
|
chunkedItems.length.should.equal(0);
|
|
32
39
|
});
|
|
33
40
|
|
|
@@ -35,7 +42,7 @@ describe("CHUNKS MANAGER", async function() {
|
|
|
35
42
|
it("GET CHUNKS : here we should receive all chunks of app", async function () {
|
|
36
43
|
this.timeout(1000000);
|
|
37
44
|
var app = await gudhub.getApp(8263);
|
|
38
|
-
let chunkedItems = await gudhub.chunksManager.getChunks(8263, app.chunks)
|
|
45
|
+
let chunkedItems = await gudhub.chunksManager.getChunks(8263, app.chunks);//
|
|
39
46
|
|
|
40
47
|
chunkedItems[0].items_list[0].should.have.property("fields");
|
|
41
48
|
chunkedItems[0].items_list[0].should.have.property("item_id");
|
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
import { DataService } from "./DataService.js";
|
|
2
|
+
import { ChunkDataService, chunkDataServiceConf } from "./export.js";
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
export class AppDataService extends DataService {
|
|
4
|
-
|
|
6
|
+
constructor(req, conf, gudhub) {
|
|
7
|
+
super();
|
|
8
|
+
this.chunkDataService = new ChunkDataService(req, chunkDataServiceConf, gudhub);
|
|
9
|
+
this.gudhub = gudhub;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
isWithCache() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async processRequestedApp(id, sentData) {
|
|
18
|
+
if (
|
|
19
|
+
!this.isWithCache()
|
|
20
|
+
) {
|
|
21
|
+
|
|
22
|
+
let res = await this.chunkDataService.getMergedChunkForIDList(id, sentData.chunks);
|
|
23
|
+
|
|
24
|
+
if (
|
|
25
|
+
res
|
|
26
|
+
) {
|
|
27
|
+
sentData.items_list = await this.gudhub.util.mergeChunks([
|
|
28
|
+
res,
|
|
29
|
+
sentData,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return sentData;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return sentData;
|
|
37
|
+
|
|
38
|
+
// following code will work for cases with enabled cache
|
|
39
|
+
}
|
|
5
40
|
}
|