@gudhub/core 1.2.4-beta.46 → 1.2.4-beta.47

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.
Files changed (37) hide show
  1. package/.parcel-cache/d3a1b9507cb44047-AssetGraph +0 -0
  2. package/.parcel-cache/data.mdb +0 -0
  3. package/.parcel-cache/dc1da35000e13623-RequestGraph +0 -0
  4. package/.parcel-cache/lock.mdb +0 -0
  5. package/.parcel-cache/snapshot-dc1da35000e13623.txt +129 -132
  6. package/GUDHUB/AppProcessor/AppProcessor.js +6 -20
  7. package/GUDHUB/ChunksManager/ChunksManager.test.js +3 -0
  8. package/GUDHUB/DataService/AppDataService.js +1 -200
  9. package/GUDHUB/DataService/ChunkDataService.js +0 -4
  10. package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +224 -263
  11. package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +3 -227
  12. package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +124 -302
  13. package/GUDHUB/DataService/IndexedDB/StoreManager/BaseStoreManager.js +9 -36
  14. package/GUDHUB/DataService/IndexedDB/StoreManager/managers.js +4 -40
  15. package/GUDHUB/DataService/IndexedDB/appRequestWorker.js +23 -88
  16. package/GUDHUB/DataService/IndexedDB/consts.js +1 -3
  17. package/GUDHUB/DataService/IndexedDB/init.js +1 -1
  18. package/GUDHUB/DataService/IndexedDB/storeManagerConf/init.js +1 -1
  19. package/GUDHUB/DataService/export.js +73 -13
  20. package/GUDHUB/DataService/httpService/AppHttpService.js +5 -15
  21. package/GUDHUB/DataService/httpService/ChunkHttpService.js +35 -37
  22. package/GUDHUB/DataService/utils.js +24 -127
  23. package/GUDHUB/GHConstructor/createAngularModuleInstance.js +7 -4
  24. package/GUDHUB/GHConstructor/createClassInstance.js +8 -3
  25. package/GUDHUB/ItemProcessor/ItemProcessor.js +0 -18
  26. package/GUDHUB/Storage/ModulesList.js +0 -7
  27. package/GUDHUB/Utils/Utils.js +0 -14
  28. package/GUDHUB/WebSocket/WebSocket.js +2 -2
  29. package/GUDHUB/api/AppApi.js +13 -13
  30. package/GUDHUB/api/ChunkApi.js +5 -5
  31. package/GUDHUB/config.js +11 -2
  32. package/GUDHUB/consts.js +6 -12
  33. package/GUDHUB/gudhub.js +7 -30
  34. package/GUDHUB/gudhubAppRequestWorker.js +1 -2
  35. package/package.json +4 -2
  36. package/GUDHUB/ChunksManager/ChunksManager.js +0 -68
  37. package/indextest.html +0 -35
@@ -1,4 +1,4 @@
1
- import { IS_BROWSER, IS_BROWSER_MAIN_THREAD, IS_WEB } from "../consts.js";
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,15 +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;
24
22
 
25
23
  this.appRequestCache = new Map;
26
-
27
-
28
- // this.dataServiceRequestedIdSet = new Set;
29
24
  }
30
25
 
31
26
  async createNewAppApi(app) {
@@ -345,18 +340,6 @@ export class AppProcessor {
345
340
  }
346
341
  }
347
342
 
348
- async handleAppChange(id, prevVersion, nextVersion) {
349
- let res1 = this.util.areViewListsEqual(prevVersion.views_list, nextVersion.views_list);
350
- let res2 = this.util.areFieldListsEqual(prevVersion.field_list, nextVersion.field_list);
351
-
352
- if (
353
- res1 ||
354
- res2
355
- ) {
356
- this.updateAppFieldsAndViews({id, views_list: nextVersion.views_list, field_list: nextVersion.field_list});
357
- }
358
- }
359
-
360
343
  clearAppProcessor() {
361
344
  this.getAppListPromises = null;
362
345
  this.getAppPromises = {};
@@ -453,7 +436,10 @@ export class AppProcessor {
453
436
  appsList
454
437
  );
455
438
  });
456
- if (IS_BROWSER_MAIN_THREAD && this.activateSW) {
439
+ if (
440
+ IS_BROWSER_MAIN_THREAD &&
441
+ this.activateSW
442
+ ) {
457
443
  navigator.serviceWorker.addEventListener("message", async (event) => {
458
444
  if (event.data.type === "refresh app") {
459
445
  const app = await this.getApp(event.data.payload.app_id);
@@ -495,7 +481,7 @@ export class AppProcessor {
495
481
  }
496
482
  );
497
483
  }
498
- event.data.payload.items_list = await this.util.mergeChunks([app, event.data.payload]) //here check Ask Andrew
484
+ event.data.payload.items_list = await this.util.mergeChunks([app, event.data.payload])
499
485
  this.saveAppInStorage(event.data.payload);
500
486
  }
501
487
  // if (event.data.type === "refresh appList") {
@@ -2,6 +2,9 @@ import should from "should";
2
2
  import {GudHub} from './../gudhub.js';
3
3
  import { ChunkDataService } from "../DataService/export.js";
4
4
 
5
+ throw new Error;
6
+ //TODO test is outdated, Chunks Manager removed, added ChunkDataService
7
+
5
8
  describe("CHUNKS MANAGER", async function() {
6
9
  const auth_key = 'Z/lxMHLenEaQTvPjW5U6c3jBDwWFYZrh2F9Kxa3fbt8drvabS2u2lXQ2zI+SRmic';
7
10
  const gudhub = new GudHub(auth_key);
@@ -2,12 +2,7 @@ import { DataService } from "./DataService.js";
2
2
  import { ChunkDataService, chunkDataServiceConf } from "./export.js";
3
3
 
4
4
 
5
-
6
- //TODO processRequestedApp should be checked that all code is ok !!!!!!!!!!!!!!!! Ive not ended checking
7
-
8
5
  export class AppDataService extends DataService {
9
- //interface for indexeddb and http services
10
-
11
6
  constructor(req, conf, gudhub) {
12
7
  super();
13
8
  this.chunkDataService = new ChunkDataService(req, chunkDataServiceConf, gudhub);
@@ -19,54 +14,13 @@ export class AppDataService extends DataService {
19
14
  return false;
20
15
  }
21
16
 
22
-
23
- //here
24
17
  async processRequestedApp(id, sentData) {
25
-
26
-
27
- // let
28
-
29
-
30
- // let chunksHashesToLoad = sentData.chunks;
31
-
32
- // let chunks = [];
33
-
34
-
35
- // if (
36
- // this.chunkDataService.isWithCache()
37
- // ) {
38
-
39
- // let cachedMergedChunkData = this.chunkDataService.getCached(id);
40
-
41
- // }
42
-
43
-
44
-
45
- // all implementations are without cache for now
46
18
  if (
47
19
  !this.isWithCache()
48
20
  ) {
49
21
 
50
-
51
- // let resultedMergedChunks = this.chunkDataService.getMergedChunk(id, sentData.chunks);
52
-
53
-
54
- ///TODO here chunks could be with cache too
55
-
56
- // async getChunks(app_id, chunk_ids) {
57
- // let chunks = [];
58
- // if(chunk_ids){
59
- // chunks = await Promise.all(chunk_ids.map((chunk_id) => this.getChunk(app_id, chunk_id)));
60
- // }
61
- // return chunks;
62
- // }
63
-
64
- // let res = await this.chunkDataService.getChunks(id, sentData.chunks);
65
- // let res = await Promise.all(sentData.chunks.map((chunk_id) => this.chunkDataService.getChunk(id, chunk_id)));
66
-
67
22
  let res = await this.chunkDataService.getMergedChunkForIDList(id, sentData.chunks);
68
23
 
69
-
70
24
  if (
71
25
  res
72
26
  ) {
@@ -76,162 +30,9 @@ export class AppDataService extends DataService {
76
30
  ]);
77
31
  }
78
32
 
79
- // if (!res) res = [];
80
-
81
-
82
-
83
- //TODO should be in new thread too even for Node.js becauses this will block loop
84
-
85
- // sentData.items_list = await this.gudhub.util.mergeChunks([
86
- // ...res,
87
- // sentData,
88
- // ]);
89
-
90
-
91
33
  return sentData;
92
-
93
- // this.dataService.putApp(id, nextVersion);
94
-
95
-
96
- // return this.mergeAndReturnStrategy.handle(sentData, chunks);
97
-
98
-
99
-
100
34
  }
101
35
 
102
-
103
-
104
- throw new Error;
105
-
106
-
107
-
108
-
109
-
110
-
111
- try {
112
-
113
- // я там собираюсь склеивать все данные в этом методе, надо посмотреть не будет ли проблем для ноды итп там тоже process вызывается
114
- let cachedApp = await this.getCached(id); // this should be merged chunk + app from db
115
-
116
-
117
- // if (
118
- // this.chunkDataService.isWithCache()
119
- // ) {
120
- // let cachedMergedChunk = this.chunkDataService.getCached();
121
- // }
122
-
123
-
124
- // let res = await this.chunkDataService.getMergedChunkForIDList(id, sentData.chunks);
125
-
126
-
127
-
128
- // let cachedMergedChunk = await this.chunkDataService.getCachedMergedChunk(id, cachedApp.chunks);
129
-
130
- if (
131
- !cachedApp
132
- // cachedMergedChunk ?
133
- ) {
134
-
135
- //TODO maybe dont wait for chunks at first load
136
-
137
- // let res = await this.chunkDataService.getChunks(id, sentData.chunks);
138
- // let res = await Promise.all(sentData.chunks.map((chunk_id) => this.chunkDataService.getChunk(id, chunk_id)));
139
- let res = await this.chunkDataService.getMergedChunkForIDList(id, sentData.chunks);
140
-
141
-
142
- if (
143
- res
144
- ) {
145
- sentData.items_list = await this.gudhub.util.mergeChunks([
146
- res,
147
- sentData,
148
- ]);
149
- }
150
-
151
- // this.putInCache(id, sentData);
152
-
153
-
154
- return sentData;
155
- }
156
-
157
-
158
- // let newHashesList = sentData.chunks.filter(c => !cachedApp.chunks.includes(c));
159
-
160
-
161
- // let self = this;
162
-
163
-
164
- // let res = await this.chunkDataService.getChunks(id, newHashesList);
165
- // let res = await Promise.all(newHashesList.map((chunk_id) => this.chunkDataService.getChunk(id, chunk_id)));
166
-
167
- let res = await this.chunkDataService.getCachedMergedChunk(id, cachedApp.chunks);
168
-
169
- // if (!res) res = [];
170
-
171
-
172
-
173
- if (
174
- res
175
- ) {
176
- sentData.items_list = await this.gudhub.util.mergeChunks([
177
- cachedApp,
178
- res,
179
- sentData,
180
- ]);
181
- } else {
182
- sentData.items_list = await this.gudhub.util.mergeChunks([
183
- cachedApp,
184
- sentData,
185
- ]);
186
- }
187
-
188
-
189
-
190
-
191
- // this.chunkDataService.getChunks(id, newHashesList).then((res) => {
192
-
193
-
194
-
195
-
196
-
197
- //TODO check this for AppHttpService, seems isnt necessary
198
- // this.gudhub.triggerAppChange(id, cachedVersion, sentData);
199
-
200
-
201
- // self.putInCache(id, sentData);
202
- // });
203
-
204
-
205
- return sentData;
206
-
207
-
208
-
209
- // return cachedVersion;
210
-
211
- } catch (error) {
212
-
213
- // seems try catch here isnt handling almost anything, almost identical code here
214
-
215
- // res = await this.chunkDataService.getChunks(id, sentData.chunks);
216
- // let res = await Promise.all(sentData.chunks.map((chunk_id) => this.chunkDataService.getChunk(id, chunk_id)));
217
- let res = await this.chunkDataService.getMergedChunkForIDList(sentData.chunks);
218
-
219
- // if (!res) res = [];
220
-
221
-
222
- if (
223
- res
224
- ) {
225
- sentData.items_list = await this.gudhub.util.mergeChunks([
226
- res,
227
- sentData,
228
- ]);
229
- }
230
-
231
- // this.putInCache(id, sentData);
232
-
233
-
234
- return sentData;
235
- }
36
+ // following code will work for cases with enabled cache
236
37
  }
237
38
  }
@@ -1,10 +1,6 @@
1
1
  import { DataService } from "./DataService.js";
2
2
 
3
3
  export class ChunkDataService extends DataService {
4
- //interface for indexeddb and http services
5
-
6
-
7
- //here
8
4
  getMergedChunkForIDList(idList) {
9
5
 
10
6
  }