@gudhub/core 1.2.3 → 1.2.4-beta.1
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/.vscode/launch.json +31 -0
- package/GUDHUB/AppProcessor/AppProcessor.js +2 -6
- package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +46 -26
- package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +53 -31
- package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +2 -0
- package/GUDHUB/DataService/httpService/AppHttpService.js +7 -3
- package/GUDHUB/DataService/httpService/ChunkHttpService.js +7 -3
- package/GUDHUB/api/AppApi.js +1 -1
- package/package.json +1 -1
- package/umd/library.min.js +69 -53
- package/umd/library.min.js.map +1 -1
- package/GUDHUB/ChunksManager/ChunkApi.js +0 -19
- package/GUDHUB/ChunksManager/DataService/IndexedDBCacheService.js +0 -101
- package/GUDHUB/ChunksManager/DataService/export.js +0 -13
- package/GUDHUB/ChunksManager/DataService/httpDataService.js +0 -21
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Launch Program",
|
|
6
|
+
"program": "${workspaceFolder}/app.js",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"skipFiles": [
|
|
9
|
+
"<node_internals>/**"
|
|
10
|
+
],
|
|
11
|
+
"type": "node"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"type": "node",
|
|
15
|
+
"request": "launch",
|
|
16
|
+
"runtimeVersion": "16",
|
|
17
|
+
"name": "Launch Program",
|
|
18
|
+
"skipFiles": [
|
|
19
|
+
"<node_internals>/**"
|
|
20
|
+
],
|
|
21
|
+
"program": "${workspaceFolder}/index.js"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "node-terminal",
|
|
25
|
+
"name": "Run Script: test",
|
|
26
|
+
"request": "launch",
|
|
27
|
+
"command": "npm run test",
|
|
28
|
+
"cwd": "${workspaceFolder}"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -78,10 +78,6 @@ export class AppProcessor {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
async getAppApi(app_id) {
|
|
82
|
-
return this.dataService.getApp(app_id);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
81
|
getAppListFromStorage() {
|
|
86
82
|
return this.storage.getAppsList();
|
|
87
83
|
}
|
|
@@ -186,7 +182,7 @@ export class AppProcessor {
|
|
|
186
182
|
for (const app_id of apps_id) {
|
|
187
183
|
if (app_id != undefined) {
|
|
188
184
|
try {
|
|
189
|
-
const app = await this.
|
|
185
|
+
const app = await this.dataService.getApp(app_id);
|
|
190
186
|
if (app) {
|
|
191
187
|
app.items_object = {};
|
|
192
188
|
|
|
@@ -259,7 +255,7 @@ export class AppProcessor {
|
|
|
259
255
|
let app = this.getAppFromStorage(app_id);
|
|
260
256
|
if (app) return app;
|
|
261
257
|
|
|
262
|
-
let receivedApp = await this.
|
|
258
|
+
let receivedApp = await this.dataService.getApp(app_id);
|
|
263
259
|
if (!receivedApp) return;
|
|
264
260
|
|
|
265
261
|
//!!! temporary check !!!! if app has chanks property then we start getting it
|
|
@@ -23,9 +23,13 @@ export class IndexedDBAppService extends AppDataService {
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
static [Symbol.hasInstance](instance) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
try {
|
|
27
|
+
if (instance instanceof IndexedDBAppService) return true;
|
|
28
|
+
if (instance instanceof IndexedDBService) return true; //TODO requires multiple inheritance, thhink how to overcome it
|
|
29
|
+
return false;
|
|
30
|
+
} catch (error) {
|
|
28
31
|
return false;
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
//TODO use IndexedDBFacade here
|
|
@@ -33,39 +37,55 @@ export class IndexedDBAppService extends AppDataService {
|
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
async getApp(id) {
|
|
40
|
+
if (this.requestCache.has(id)) return this.requestCache.get(id);
|
|
41
|
+
|
|
36
42
|
let dataServiceRequest = this.dataService.getApp(id);
|
|
37
43
|
|
|
38
44
|
dataServiceRequest.then(data => this.putApp(id, data));
|
|
39
45
|
|
|
40
46
|
try {
|
|
41
|
-
|
|
42
|
-
const transaction = db.transaction(this.store, "readonly");
|
|
43
|
-
const store = transaction.objectStore(this.store);
|
|
44
|
-
|
|
45
|
-
const storeRequest = store.get(id);
|
|
46
|
-
|
|
47
|
-
return await new Promise((resolve, reject) => {
|
|
48
|
-
storeRequest.onsuccess = (e) => {
|
|
49
|
-
|
|
50
|
-
let cachedData = e.target.result;
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
!cachedData
|
|
54
|
-
) {
|
|
55
|
-
reject();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
cachedData
|
|
60
|
-
) {
|
|
47
|
+
let self = this;
|
|
61
48
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
let pr = new Promise(async (resolve, reject) => {
|
|
50
|
+
try {
|
|
51
|
+
const db = await self.openDatabase();
|
|
52
|
+
const transaction = db.transaction(self.store, "readonly");
|
|
53
|
+
const store = transaction.objectStore(self.store);
|
|
54
|
+
|
|
55
|
+
const storeRequest = store.get(id);
|
|
56
|
+
|
|
57
|
+
storeRequest.onsuccess = (e) => {
|
|
65
58
|
|
|
66
|
-
|
|
59
|
+
let cachedData = e.target.result;
|
|
60
|
+
|
|
61
|
+
if (
|
|
62
|
+
!cachedData
|
|
63
|
+
) {
|
|
64
|
+
reject();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (
|
|
68
|
+
cachedData
|
|
69
|
+
) {
|
|
70
|
+
resolve(cachedData);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
storeRequest.onerror = reject
|
|
75
|
+
} catch (error) {
|
|
76
|
+
reject();
|
|
77
|
+
}
|
|
67
78
|
});
|
|
79
|
+
|
|
80
|
+
self.requestCache.set(id, pr);
|
|
81
|
+
|
|
82
|
+
await pr;
|
|
83
|
+
|
|
84
|
+
return pr;
|
|
85
|
+
|
|
68
86
|
} catch(e) {
|
|
87
|
+
this.requestCache.set(id, dataServiceRequest);
|
|
88
|
+
|
|
69
89
|
return dataServiceRequest;
|
|
70
90
|
}
|
|
71
91
|
}
|
|
@@ -34,9 +34,13 @@ export class IndexedDBChunkService extends ChunkDataService {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
static [Symbol.hasInstance](instance) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
try {
|
|
38
|
+
if (instance instanceof IndexedDBChunkService) return true;
|
|
39
|
+
if (instance instanceof IndexedDBService) return true; //TODO requires multiple inheritance, thhink how to overcome it
|
|
40
|
+
return false;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
|
|
@@ -57,41 +61,59 @@ export class IndexedDBChunkService extends ChunkDataService {
|
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
async getChunk(app_id, id) {
|
|
64
|
+
if (this.requestCache.has(id)) return this.requestCache.get(id);
|
|
65
|
+
|
|
60
66
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let cachedData = e.target.result;
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
!cachedData
|
|
74
|
-
) {
|
|
75
|
-
reject();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
cachedData
|
|
80
|
-
) {
|
|
67
|
+
let self = this;
|
|
68
|
+
|
|
69
|
+
let pr = new Promise(async (resolve, reject) => {
|
|
70
|
+
try {
|
|
71
|
+
const db = await self.openDatabase();
|
|
72
|
+
const transaction = db.transaction(self.store, "readonly");
|
|
73
|
+
const store = transaction.objectStore(self.store);
|
|
74
|
+
|
|
75
|
+
const storeRequest = store.get(id);
|
|
81
76
|
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
};
|
|
77
|
+
storeRequest.onsuccess = (e) => {
|
|
85
78
|
|
|
86
|
-
|
|
79
|
+
let cachedData = e.target.result;
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
!cachedData
|
|
83
|
+
) {
|
|
84
|
+
reject();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (
|
|
88
|
+
cachedData
|
|
89
|
+
) {
|
|
90
|
+
|
|
91
|
+
resolve(cachedData);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
storeRequest.onerror = reject
|
|
96
|
+
} catch (error) {
|
|
97
|
+
reject();
|
|
98
|
+
}
|
|
87
99
|
});
|
|
100
|
+
|
|
101
|
+
self.requestCache.set(id, pr);
|
|
102
|
+
|
|
103
|
+
await pr;
|
|
104
|
+
|
|
105
|
+
return pr;
|
|
106
|
+
|
|
88
107
|
} catch(e) {
|
|
89
|
-
let
|
|
108
|
+
let reqPrms = this.dataService.getChunk(app_id, id);
|
|
90
109
|
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
this.requestCache.set(id, reqPrms);
|
|
111
|
+
|
|
112
|
+
let res = await reqPrms;
|
|
113
|
+
|
|
114
|
+
this.putChunk(id, res);
|
|
93
115
|
|
|
94
|
-
return
|
|
116
|
+
return reqPrms;
|
|
95
117
|
}
|
|
96
118
|
}
|
|
97
119
|
|
|
@@ -24,8 +24,12 @@ export class AppHttpService extends AppDataService {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
static [Symbol.hasInstance](instance) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
try {
|
|
28
|
+
if (instance instanceof AppHttpService) return true;
|
|
29
|
+
if (instance instanceof HttpService) return true; //TODO requires multiple inheritance, thhink how to overcome it
|
|
30
|
+
return false;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
}
|
|
@@ -25,8 +25,12 @@ export class ChunkHttpService extends ChunkDataService {
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
static [Symbol.hasInstance](instance) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
try {
|
|
29
|
+
if (instance instanceof ChunkHttpService) return true;
|
|
30
|
+
if (instance instanceof HttpService) return true; //TODO requires multiple inheritance, thhink how to overcome it
|
|
31
|
+
return false;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
}
|
package/GUDHUB/api/AppApi.js
CHANGED