@gudhub/core 1.2.4-beta.45 → 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 (39) hide show
  1. package/.parcel-cache/83e7562660f7cc15-BundleGraph +0 -0
  2. package/.parcel-cache/d3a1b9507cb44047-AssetGraph +0 -0
  3. package/.parcel-cache/data.mdb +0 -0
  4. package/.parcel-cache/dc1da35000e13623-RequestGraph +0 -0
  5. package/.parcel-cache/lock.mdb +0 -0
  6. package/.parcel-cache/snapshot-dc1da35000e13623.txt +160 -163
  7. package/GUDHUB/AppProcessor/AppProcessor.js +6 -20
  8. package/GUDHUB/ChunksManager/ChunksManager.test.js +3 -0
  9. package/GUDHUB/DataService/AppDataService.js +1 -200
  10. package/GUDHUB/DataService/ChunkDataService.js +0 -4
  11. package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +224 -263
  12. package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +3 -227
  13. package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +124 -302
  14. package/GUDHUB/DataService/IndexedDB/StoreManager/BaseStoreManager.js +9 -36
  15. package/GUDHUB/DataService/IndexedDB/StoreManager/managers.js +4 -40
  16. package/GUDHUB/DataService/IndexedDB/appRequestWorker.js +23 -88
  17. package/GUDHUB/DataService/IndexedDB/consts.js +1 -3
  18. package/GUDHUB/DataService/IndexedDB/init.js +1 -1
  19. package/GUDHUB/DataService/IndexedDB/storeManagerConf/init.js +1 -1
  20. package/GUDHUB/DataService/export.js +73 -13
  21. package/GUDHUB/DataService/httpService/AppHttpService.js +5 -15
  22. package/GUDHUB/DataService/httpService/ChunkHttpService.js +35 -37
  23. package/GUDHUB/DataService/utils.js +24 -127
  24. package/GUDHUB/GHConstructor/createAngularModuleInstance.js +7 -4
  25. package/GUDHUB/GHConstructor/createClassInstance.js +8 -3
  26. package/GUDHUB/ItemProcessor/ItemProcessor.js +0 -18
  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/dist/gudhub.es.js +8 -1
  36. package/dist/gudhub.umd.js +2 -2
  37. package/package.json +4 -2
  38. package/GUDHUB/ChunksManager/ChunksManager.js +0 -68
  39. package/indextest.html +0 -35
@@ -1,56 +1,26 @@
1
- import { ChunkDataService } from "../ChunkDataService.js"; // removed "ChunkCacheDataService" from imported because it was causing an error "{ ChunkCacheDataService } not found in exported names" in "gudhub-node-server"
1
+ import { ChunkDataService } from "../ChunkDataService.js";
2
2
  import { ChunkHttpService } from "../httpService/ChunkHttpService.js";
3
- import { objectAssignWithOverride } from "../utils.js";
4
- import { IndexedDBService } from "./IndexedDBService.js";
5
3
  import { ChunksStoreManager, MergedChunksStoreManager } from "./StoreManager/managers.js";
6
4
 
7
5
 
8
- //this should be global in project
9
- // class IndexedDBFacade extends CacheService {
10
-
11
- // }
12
-
13
-
14
-
15
- // class ChunkCachedDataService extends ChunkDataService {
16
- // dataService;
17
- // }
18
-
19
-
20
6
  export class IndexedDBChunkService extends ChunkDataService {
21
7
  constructor(req, conf, gudhub) {
22
8
  super(req, conf);
23
9
 
24
10
  this.dataService = new ChunkHttpService(req);
25
11
 
26
- // let indexDBService = new IndexedDBService(conf);
27
-
28
- this.requestCache = new Map; // id -> promise ///TODO seems irrelevant to class IndexedDBManager (could be renamed to Facade already)
12
+ this.requestCache = new Map;
29
13
 
30
14
 
31
15
  this.gudhub = gudhub;
32
16
 
33
-
34
- // this.storeManager = new ChunksStoreManager;
35
17
  this.storeManager = new MergedChunksStoreManager;
36
-
37
-
38
- // this.storeManager = new ChunksStoreManager;
39
-
40
-
41
- // objectAssignWithOverride(this, indexDBService);
42
- // objectAssignWithOverride(this, new ChunksStoreManager);
43
18
  }
44
19
 
45
- //TODO use IndexedDBFacade here
46
- // indexDBAccess = new IndexedDBFacade;
47
-
48
-
49
-
50
20
  static [Symbol.hasInstance](instance) {
51
21
  try {
52
22
  if (instance instanceof IndexedDBChunkService) return true;
53
- if (instance instanceof IndexedDBService) return true; //TODO requires multiple inheritance, thhink how to overcome it
23
+ // if (instance instanceof IndexedDBService) return true; //TODO requires multiple inheritance, thhink how to overcome it
54
24
  return false;
55
25
  } catch (error) {
56
26
  return false;
@@ -63,9 +33,6 @@ export class IndexedDBChunkService extends ChunkDataService {
63
33
 
64
34
  return cachedData.mergedData;
65
35
  } catch (error) {
66
- // let newHashes = chunkHashesList.filter(c => !cachedData.hashes.includes(c));
67
-
68
-
69
36
  const requests = chunkHashesList.map(hash => this.dataService.getChunk(id, hash));
70
37
 
71
38
  const newChunks = await Promise.all(requests);
@@ -92,13 +59,6 @@ export class IndexedDBChunkService extends ChunkDataService {
92
59
 
93
60
  //here // TODO replace this with getMergedChunkForApp in future
94
61
  async getMergedChunkForIDList(id, chunkHashesList) {
95
-
96
-
97
- //TODO promise cache
98
-
99
- // TODO also try catch maybe
100
-
101
-
102
62
  try {
103
63
 
104
64
 
@@ -185,8 +145,6 @@ export class IndexedDBChunkService extends ChunkDataService {
185
145
 
186
146
  return {items_list: mergedData};
187
147
  } catch (error) {
188
- // let newHashes = chunkHashesList.filter(c => !cachedData.hashes.includes(c));
189
-
190
148
 
191
149
  const requests = chunkHashesList.map(hash => this.dataService.getChunk(id, hash));
192
150
 
@@ -201,189 +159,7 @@ export class IndexedDBChunkService extends ChunkDataService {
201
159
  }
202
160
  }
203
161
 
204
-
205
-
206
- // async function fetchAndMergeArrays(urls) {
207
- // try {
208
- // // Create an array of fetch promises
209
- // const requests = urls.map(url => fetch(url).then(response => response.json()));
210
-
211
- // // Wait for all requests to complete
212
- // const results = await Promise.all(requests);
213
-
214
- // // Merge all arrays
215
- // const mergedArray = results.flat(); // or use reduce: results.reduce((acc, arr) => acc.concat(arr), []);
216
-
217
- // return mergedArray;
218
- // } catch (error) {
219
- // console.error('Error fetching data:', error);
220
- // throw error;
221
- // }
222
- // }
223
-
224
- // // Example usage:
225
- // const urls = ['https://api.example.com/data1', 'https://api.example.com/data2'];
226
- // fetchAndMergeArrays(urls)
227
- // .then(mergedArray => console.log(mergedArray))
228
- // .catch(error => console.error('Error:', error));
229
-
230
-
231
- //todo also optimize chunks transactions etc
232
-
233
-
234
-
235
162
  async putMergedChunks(id, data) {
236
163
  return this.storeManager.put(id, data);
237
164
  }
238
-
239
-
240
- // async getMergedChunks(id, data) {
241
- // return this.storeManager.get(id, data);
242
- // }
243
-
244
-
245
- async putChunk(id, data) {
246
- return this.storeManager.putChunk(id, data);
247
-
248
- // try {
249
- // const db = await this.openDatabase(); //here
250
-
251
- // const transaction = db.transaction(this.store, "readwrite");
252
- // const store = transaction.objectStore(this.store);
253
-
254
- // store.put(data, id);
255
- // } catch (error) {
256
-
257
- // }
258
- }
259
-
260
-
261
- // async getApp(id) {
262
- // if (this.requestCache.has(id)) return this.requestCache.get(id);
263
-
264
- // let self = this;
265
-
266
- // let dataServiceRequest = this.dataService.getApp(id);
267
-
268
- // let pr = new Promise(async (resolve, reject) => {
269
- // try {
270
- // const db = await self.openDatabase();
271
- // const transaction = db.transaction(self.store, "readonly");
272
- // const store = transaction.objectStore(self.store);
273
-
274
- // const storeRequest = store.get(id);
275
-
276
- // storeRequest.onsuccess = (e) => {
277
-
278
- // let cachedData = e.target.result;
279
-
280
- // if (
281
- // !cachedData
282
- // ) {
283
- // dataServiceRequest.then(resolve, reject);
284
- // dataServiceRequest.then(data => self.putApp(id, data));
285
- // }
286
-
287
- // if (
288
- // cachedData
289
- // ) {
290
- // resolve(cachedData);
291
-
292
- // dataServiceRequest.then(async (data) => {
293
- // // self.gudhub.processAppUpd(data, cachedData);//
294
- // await self.putApp(id, data);
295
- // self.gudhub.triggerAppUpdate(id, prevVersion, newVersion);
296
- // });
297
- // }
298
- // };
299
-
300
- // storeRequest.onerror = () => {
301
- // dataServiceRequest.then(resolve, reject);
302
- // dataServiceRequest.then(data => self.putApp(id, data));
303
- // }
304
- // } catch (error) {
305
- // dataServiceRequest.then(resolve, reject);
306
- // dataServiceRequest.then(data => self.putApp(id, data));
307
- // }
308
- // });
309
-
310
- // self.requestCache.set(id, pr);
311
-
312
- // return pr;
313
- // }
314
-
315
-
316
- async getChunk(app_id, id) {
317
- if (this.requestCache.has(id)) return this.requestCache.get(id);
318
-
319
- try {
320
-
321
- let pr = this.storeManager.getChunk(id);
322
-
323
- // let self = this;
324
-
325
- // let pr = new Promise(async (resolve, reject) => {
326
- // try {
327
- // const db = await self.openDatabase();
328
- // const transaction = db.transaction(self.store, "readonly");
329
- // const store = transaction.objectStore(self.store);
330
-
331
- // const storeRequest = store.get(id);
332
-
333
- // storeRequest.onsuccess = (e) => {
334
-
335
- // let cachedData = e.target.result;
336
-
337
- // if (
338
- // !cachedData
339
- // ) {
340
- // reject();
341
- // }
342
-
343
- // if (
344
- // cachedData
345
- // ) {
346
-
347
- // resolve(cachedData);
348
- // }
349
- // };
350
-
351
- // storeRequest.onerror = reject
352
- // } catch (error) {
353
- // reject();
354
- // }
355
- // });
356
-
357
- self.requestCache.set(id, pr);
358
-
359
- await pr;
360
-
361
- return pr;
362
-
363
- } catch(e) {
364
- let reqPrms = this.dataService.getChunk(app_id, id);
365
-
366
- this.requestCache.set(id, reqPrms);
367
-
368
- let res = await reqPrms;
369
-
370
- this.putChunk(id, res);
371
- // putPrms.then(() => self.gudhub.triggerAppUpdate(id));
372
-
373
- return reqPrms;
374
- }
375
- }
376
-
377
- // async openDatabase() {
378
- // return new Promise((resolve, reject) => {
379
- // const request = indexedDB.open(this.dbName, this.dbVersion);
380
-
381
- // request.onsuccess = event => {
382
- // resolve(event.target.result);
383
- // };
384
- // request.onerror = event => {
385
- // reject(event.target.error);
386
- // };
387
- // });
388
- // }
389
165
  }