@gudhub/core 1.2.4-beta.7 → 1.2.5-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/GUDHUB/AppProcessor/AppProcessor.js +51 -46
- package/GUDHUB/ChunksManager/ChunksManager.js +31 -17
- package/GUDHUB/FileManager/FileManager.js +7 -3
- package/GUDHUB/ItemProcessor/ItemProcessor.js +0 -7
- package/GUDHUB/Storage/ModulesList.js +1 -1
- package/GUDHUB/config.js +0 -3
- package/GUDHUB/gudhub.js +6 -12
- package/package.json +10 -20
- package/umd/library.min.js +264 -2
- package/umd/library.min.js.map +1 -1
- package/GUDHUB/DataService/AppDataService.js +0 -5
- package/GUDHUB/DataService/CacheAPI/index.js +0 -1
- package/GUDHUB/DataService/ChunkDataService.js +0 -5
- package/GUDHUB/DataService/DataService.js +0 -1
- package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +0 -119
- package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +0 -132
- package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +0 -9
- package/GUDHUB/DataService/IndexedDB/appDataConf.js +0 -7
- package/GUDHUB/DataService/IndexedDB/chunkDataConf.js +0 -7
- package/GUDHUB/DataService/IndexedDB/consts.js +0 -2
- package/GUDHUB/DataService/IndexedDB/init.js +0 -21
- package/GUDHUB/DataService/export.js +0 -48
- package/GUDHUB/DataService/httpService/AppHttpService.js +0 -35
- package/GUDHUB/DataService/httpService/ChunkHttpService.js +0 -36
- package/GUDHUB/DataService/httpService/HttpService.js +0 -1
- package/GUDHUB/DataService/utils.js +0 -34
- package/GUDHUB/api/AppApi.js +0 -14
- package/GUDHUB/api/ChunkApi.js +0 -19
- package/webpack.config.js +0 -33
|
@@ -8,8 +8,7 @@ export class AppProcessor {
|
|
|
8
8
|
websocket,
|
|
9
9
|
chunksManager,
|
|
10
10
|
util,
|
|
11
|
-
activateSW
|
|
12
|
-
dataService,
|
|
11
|
+
activateSW
|
|
13
12
|
) {
|
|
14
13
|
this.storage = storage;
|
|
15
14
|
this.pipeService = pipeService;
|
|
@@ -20,9 +19,6 @@ export class AppProcessor {
|
|
|
20
19
|
this.chunksManager = chunksManager;
|
|
21
20
|
this.util = util;
|
|
22
21
|
this.appListeners();
|
|
23
|
-
this.dataService = dataService;
|
|
24
|
-
|
|
25
|
-
this.appRequestCache = new Map;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
async createNewAppApi(app) {
|
|
@@ -80,6 +76,21 @@ export class AppProcessor {
|
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
|
|
79
|
+
async getAppApi(app_id) {
|
|
80
|
+
try {
|
|
81
|
+
const response = await this.req.get({
|
|
82
|
+
url: "/api/app/get",
|
|
83
|
+
params: {
|
|
84
|
+
app_id: app_id,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return response;
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.log(err);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
83
94
|
getAppListFromStorage() {
|
|
84
95
|
return this.storage.getAppsList();
|
|
85
96
|
}
|
|
@@ -184,7 +195,7 @@ export class AppProcessor {
|
|
|
184
195
|
for (const app_id of apps_id) {
|
|
185
196
|
if (app_id != undefined) {
|
|
186
197
|
try {
|
|
187
|
-
const app = await this.
|
|
198
|
+
const app = await this.getAppApi(app_id);
|
|
188
199
|
if (app) {
|
|
189
200
|
app.items_object = {};
|
|
190
201
|
|
|
@@ -255,44 +266,42 @@ export class AppProcessor {
|
|
|
255
266
|
if (!app_id) return null;
|
|
256
267
|
|
|
257
268
|
let app = this.getAppFromStorage(app_id);
|
|
258
|
-
if (app)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
269
|
+
if (!app) {
|
|
270
|
+
let receivedApp = await this.getAppApi(app_id);
|
|
271
|
+
if (!receivedApp) return null;
|
|
272
|
+
|
|
273
|
+
//!!! temporary check !!!! if app has chanks property then we start getting it
|
|
274
|
+
if (receivedApp.chunks && receivedApp.chunks.length) {
|
|
275
|
+
this.chunksManager
|
|
276
|
+
.getChunks(app_id, receivedApp.chunks)
|
|
277
|
+
.then((chunks) => {
|
|
278
|
+
receivedApp.items_list = this.util.mergeChunks([
|
|
279
|
+
...chunks,
|
|
280
|
+
receivedApp,
|
|
281
|
+
]);
|
|
282
|
+
this.saveAppInStorage(receivedApp);
|
|
283
|
+
this.pipeService.emit(
|
|
284
|
+
"gh_items_update",
|
|
285
|
+
{ app_id },
|
|
286
|
+
receivedApp.items_list
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
app = receivedApp
|
|
290
|
+
this.saveAppInStorage(receivedApp);
|
|
291
|
+
} else {
|
|
292
|
+
app = this.getAppFromStorage(app_id);
|
|
293
|
+
// for oprimization purpose: we check if app was already received in case when there was severals calls at same moment of the getApp one call will overwrite the App from another call with the same App,
|
|
294
|
+
if (!app) {
|
|
295
|
+
app = receivedApp;
|
|
296
|
+
this.saveAppInStorage(receivedApp); //!!! will be saved over several times for each app request
|
|
297
|
+
this.ws.addSubscription(app_id);
|
|
279
298
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// This code for trash must be changed
|
|
283
|
-
// return trash ? app : {...app, items_list: app.items_list.filter(item => !item.trash)};
|
|
284
|
-
resolve(receivedApp);
|
|
285
|
-
|
|
286
|
-
self.saveAppInStorage(receivedApp);
|
|
287
|
-
self.ws.addSubscription(app_id);
|
|
288
|
-
} catch (error) {
|
|
289
|
-
reject();
|
|
290
299
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// This code for trash must be changed
|
|
303
|
+
// return trash ? app : {...app, items_list: app.items_list.filter(item => !item.trash)};
|
|
304
|
+
return app;
|
|
296
305
|
}
|
|
297
306
|
|
|
298
307
|
async updateApp(app) {
|
|
@@ -336,10 +345,6 @@ export class AppProcessor {
|
|
|
336
345
|
}
|
|
337
346
|
}
|
|
338
347
|
|
|
339
|
-
handleAppChange(v1, v2) {
|
|
340
|
-
// generate required events etc, do job
|
|
341
|
-
}
|
|
342
|
-
|
|
343
348
|
clearAppProcessor() {
|
|
344
349
|
this.getAppListPromises = null;
|
|
345
350
|
this.getAppPromises = {};
|
|
@@ -1,48 +1,60 @@
|
|
|
1
|
-
import { ChunkAPI } from "../api/ChunkApi.js";
|
|
2
1
|
|
|
3
2
|
|
|
4
3
|
export class ChunksManager {
|
|
5
|
-
constructor(
|
|
6
|
-
storage,
|
|
7
|
-
pipeService,
|
|
8
|
-
req,
|
|
9
|
-
util,
|
|
10
|
-
dataService,
|
|
11
|
-
) {
|
|
4
|
+
constructor(storage, pipeService, req, util) {
|
|
12
5
|
this.storage = storage;
|
|
13
6
|
this.pipeService = pipeService;
|
|
14
7
|
this.req = req;
|
|
15
8
|
this.util = util;
|
|
16
|
-
this.dataService = dataService;
|
|
17
|
-
this.chunkApi = new ChunkAPI(req);
|
|
18
9
|
this.itemListeners();
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
async
|
|
12
|
+
async getChunkApi(app_id, chunk_id) {
|
|
22
13
|
try {
|
|
23
|
-
|
|
14
|
+
const response = await this.req.axiosRequest({
|
|
15
|
+
url: `${this.req.root}/api/get-items-chunk/${app_id}/${chunk_id}`,
|
|
16
|
+
method: 'GET'
|
|
17
|
+
});
|
|
18
|
+
return response;
|
|
24
19
|
} catch (err) {
|
|
25
20
|
console.log(err);
|
|
26
21
|
return null;
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
async
|
|
25
|
+
async getLastChunkApi(app_id) {
|
|
31
26
|
try {
|
|
32
|
-
|
|
27
|
+
const response = await this.req.axiosRequest({
|
|
28
|
+
url: `${this.req.root}/api/get-last-items-chunk/${app_id}`,
|
|
29
|
+
method: 'GET'
|
|
30
|
+
});
|
|
31
|
+
return response;
|
|
33
32
|
} catch (err) {
|
|
34
33
|
console.log(err);
|
|
35
34
|
return null;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
38
|
+
|
|
39
|
+
getChunk(app_id, chunk_id) {
|
|
40
|
+
return this.getChunkApi(app_id, chunk_id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
39
44
|
async getChunks(app_id, chunk_ids) {
|
|
40
45
|
let chunks = [];
|
|
41
46
|
if(chunk_ids){
|
|
42
|
-
chunks = await Promise.all(chunk_ids.map((chunk_id) => this.
|
|
47
|
+
chunks = await Promise.all(chunk_ids.map((chunk_id) => this.getChunkApi(app_id, chunk_id)));
|
|
43
48
|
}
|
|
44
49
|
return chunks;
|
|
45
50
|
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async getLastChunk(app_id) {
|
|
54
|
+
let chunk = await this.getLastChunkApi(app_id);
|
|
55
|
+
return chunk;
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
|
|
47
59
|
itemListeners() {
|
|
48
60
|
}
|
|
@@ -64,5 +76,7 @@ export class ChunksManager {
|
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
78
|
return app;
|
|
67
|
-
}
|
|
68
|
-
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
}
|
|
@@ -39,7 +39,7 @@ export class FileManager {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async updateFileFromStringApi(data, file_id, file_name, extension, format) {
|
|
42
|
+
async updateFileFromStringApi(data, file_id, file_name, extension, format, alt, title) {
|
|
43
43
|
try {
|
|
44
44
|
const fileObj = {
|
|
45
45
|
file_name,
|
|
@@ -47,6 +47,8 @@ export class FileManager {
|
|
|
47
47
|
file_id,
|
|
48
48
|
format,
|
|
49
49
|
source: data,
|
|
50
|
+
alt,
|
|
51
|
+
title
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
const file = await this.req.post({
|
|
@@ -198,13 +200,15 @@ async getFiles(app_id, filesId = []) {
|
|
|
198
200
|
return file;
|
|
199
201
|
}
|
|
200
202
|
|
|
201
|
-
async updateFileFromString(data, file_id, file_name, extension, format) {
|
|
203
|
+
async updateFileFromString(data, file_id, file_name, extension, format, alt, title) {
|
|
202
204
|
const file = await this.updateFileFromStringApi(
|
|
203
205
|
data,
|
|
204
206
|
file_id,
|
|
205
207
|
file_name,
|
|
206
208
|
extension,
|
|
207
|
-
format
|
|
209
|
+
format,
|
|
210
|
+
alt,
|
|
211
|
+
title
|
|
208
212
|
);
|
|
209
213
|
this.updateFileInStorage(file_id, file.app_id, file);
|
|
210
214
|
return file;
|
|
@@ -118,13 +118,6 @@ export class ItemProcessor {
|
|
|
118
118
|
return items;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
handleItemsChange(v1, v2) {
|
|
122
|
-
let compareRes = this.util.compareItems(v1.items_list, v2.items_list);
|
|
123
|
-
|
|
124
|
-
this.updateItemsInStorage(v1.app_id, compareRes.diff_src_items);
|
|
125
|
-
this.addItemsToStorage(v1.app_id, compareRes.new_src_items);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
121
|
async deleteItemsFromStorage(app_id, itemsForDelete = []) {
|
|
129
122
|
const app = await this.appProcessor.getApp(app_id);
|
|
130
123
|
if (app) {
|
|
@@ -958,7 +958,7 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
958
958
|
data_type: "text_area",
|
|
959
959
|
name: "Text Area",
|
|
960
960
|
icon: "text_icon",
|
|
961
|
-
js: "https://gudhub.com/modules/text-area-ghe/dist/main.js?t=
|
|
961
|
+
js: "https://gudhub.com/modules/text-area-ghe/dist/main.js?t=3",
|
|
962
962
|
css: "https://gudhub.com/modules/text-area-ghe/dist/style.css",
|
|
963
963
|
type: "gh_element",
|
|
964
964
|
technology: "class",
|
package/GUDHUB/config.js
CHANGED
|
@@ -8,8 +8,5 @@ export const async_modules_path = 'build/latest/async_modules_node/';
|
|
|
8
8
|
export const automation_modules_path = 'build/latest/automation_modules/'
|
|
9
9
|
export const file_server_url = 'https://gudhub.com'
|
|
10
10
|
|
|
11
|
-
export const cache_chunk_requests = true;
|
|
12
|
-
export const cache_app_requests = true;
|
|
13
|
-
|
|
14
11
|
// FOR TESTS
|
|
15
12
|
export const port = 9000;
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -18,7 +18,6 @@ import { WebsocketHandler } from './WebSocket/WebsocketHandler.js';
|
|
|
18
18
|
import { GroupSharing } from './Utils/sharing/GroupSharing.js';
|
|
19
19
|
import { Sharing } from './Utils/sharing/Sharing.js';
|
|
20
20
|
import { WebSocketEmitter } from './WebSocket/WebSocketEmitter.js';
|
|
21
|
-
import { AppDataService, ChunkDataService, appDataServiceConf, chunkDataServiceConf } from "./DataService/export.js";
|
|
22
21
|
|
|
23
22
|
export class GudHub {
|
|
24
23
|
constructor(
|
|
@@ -63,8 +62,7 @@ export class GudHub {
|
|
|
63
62
|
this.storage,
|
|
64
63
|
this.pipeService,
|
|
65
64
|
this.req,
|
|
66
|
-
this.util
|
|
67
|
-
new ChunkDataService(this.req, chunkDataServiceConf),
|
|
65
|
+
this.util
|
|
68
66
|
);
|
|
69
67
|
this.appProcessor = new AppProcessor(
|
|
70
68
|
this.storage,
|
|
@@ -73,8 +71,7 @@ export class GudHub {
|
|
|
73
71
|
this.ws,
|
|
74
72
|
this.chunksManager,
|
|
75
73
|
this.util,
|
|
76
|
-
options.activateSW
|
|
77
|
-
new AppDataService(this.req, appDataServiceConf, this),
|
|
74
|
+
options.activateSW
|
|
78
75
|
);
|
|
79
76
|
this.itemProcessor = new ItemProcessor(
|
|
80
77
|
this.storage,
|
|
@@ -234,11 +231,6 @@ export class GudHub {
|
|
|
234
231
|
return this.util.sortItems(items, options);
|
|
235
232
|
}
|
|
236
233
|
|
|
237
|
-
processAppUpd(v1, v2) {
|
|
238
|
-
this.itemProcessor.handleItemsChange(v1, v2);
|
|
239
|
-
this.appProcessor.handleAppChange(v1, v2);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
234
|
jsonToItems(json, map) {
|
|
243
235
|
return this.util.jsonToItems(json, map);
|
|
244
236
|
}
|
|
@@ -418,13 +410,15 @@ export class GudHub {
|
|
|
418
410
|
);
|
|
419
411
|
}
|
|
420
412
|
|
|
421
|
-
updateFileFromString(data, file_id, file_name, extension, format) {
|
|
413
|
+
updateFileFromString(data, file_id, file_name, extension, format, alt, title) {
|
|
422
414
|
return this.fileManager.updateFileFromString(
|
|
423
415
|
data,
|
|
424
416
|
file_id,
|
|
425
417
|
file_name,
|
|
426
418
|
extension,
|
|
427
|
-
format
|
|
419
|
+
format,
|
|
420
|
+
alt,
|
|
421
|
+
title
|
|
428
422
|
);
|
|
429
423
|
}
|
|
430
424
|
|
package/package.json
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gudhub/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "NODE_ENV=test mocha $(find ./GUDHUB -print | grep -i test.js)",
|
|
8
|
-
"prepublishOnly": "
|
|
8
|
+
"prepublishOnly": "parcel build ./indexUMD.js --target browser --bundle-node-modules --out-file library.min.js --global GudHubLibrary -d umd",
|
|
9
9
|
"publishPublicly": "npm publish --access public"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
[
|
|
14
|
-
"@babel/preset-env",
|
|
15
|
-
{
|
|
16
|
-
"targets": {
|
|
17
|
-
"esmodules": true
|
|
18
|
-
},
|
|
19
|
-
"exclude": [
|
|
20
|
-
"babel-plugin-transform-classes"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
]
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": "16.13.1"
|
|
25
13
|
},
|
|
14
|
+
"browserslist": [
|
|
15
|
+
"last 3 versions",
|
|
16
|
+
"> 0.5%"
|
|
17
|
+
],
|
|
26
18
|
"repository": {
|
|
27
19
|
"type": "git",
|
|
28
20
|
"url": "git+ssh://git@bitbucket.org/AAtlas/gudhub.git"
|
|
@@ -41,15 +33,13 @@
|
|
|
41
33
|
"ws": "^7.3.1"
|
|
42
34
|
},
|
|
43
35
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.24.7",
|
|
45
|
-
"@babel/preset-env": "^7.24.7",
|
|
46
36
|
"canvas": "^2.9.3",
|
|
47
37
|
"express": "^4.17.1",
|
|
48
38
|
"jsdom": "^20.0.0",
|
|
49
39
|
"mocha": "^8.1.2",
|
|
40
|
+
"parcel-bundler": "^1.12.5",
|
|
50
41
|
"should": "^13.2.3",
|
|
51
|
-
"sinon": "^14.0.0"
|
|
52
|
-
"webpack": "^5.91.0"
|
|
42
|
+
"sinon": "^14.0.0"
|
|
53
43
|
},
|
|
54
44
|
"type": "module",
|
|
55
45
|
"publishConfig": {
|