@gudhub/core 1.2.4-beta.3 → 1.2.4-beta.32

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 (43) hide show
  1. package/GUDHUB/AppProcessor/AppProcessor.js +62 -24
  2. package/GUDHUB/ChunksManager/ChunksManager.js +61 -61
  3. package/GUDHUB/ChunksManager/ChunksManager.test.js +8 -4
  4. package/GUDHUB/DataService/AppDataService.js +232 -0
  5. package/GUDHUB/DataService/ChunkDataService.js +10 -0
  6. package/GUDHUB/DataService/IndexedDB/IndexedDBAppService.js +799 -63
  7. package/GUDHUB/DataService/IndexedDB/IndexedDBChunkService.js +303 -46
  8. package/GUDHUB/DataService/IndexedDB/IndexedDBService.js +342 -2
  9. package/GUDHUB/DataService/IndexedDB/StoreManager/BaseStoreManager.js +124 -0
  10. package/GUDHUB/DataService/IndexedDB/StoreManager/managers.js +113 -0
  11. package/GUDHUB/DataService/IndexedDB/appDataConf.js +6 -3
  12. package/GUDHUB/DataService/IndexedDB/appRequestWorker.js +225 -0
  13. package/GUDHUB/DataService/IndexedDB/chunkDataConf.js +3 -3
  14. package/GUDHUB/DataService/IndexedDB/consts.js +3 -1
  15. package/GUDHUB/DataService/IndexedDB/init.js +15 -14
  16. package/GUDHUB/DataService/IndexedDB/storeManagerConf/chunkCacheStoreManagerConf.js +11 -0
  17. package/GUDHUB/DataService/IndexedDB/storeManagerConf/init.js +1 -0
  18. package/GUDHUB/DataService/export.js +8 -5
  19. package/GUDHUB/DataService/httpService/AppHttpService.js +22 -4
  20. package/GUDHUB/DataService/httpService/ChunkHttpService.js +19 -2
  21. package/GUDHUB/DataService/utils.js +104 -1
  22. package/GUDHUB/FileManager/FileManager.js +7 -3
  23. package/GUDHUB/GHConstructor/createAngularModuleInstance.js +3 -3
  24. package/GUDHUB/GHConstructor/createClassInstance.js +3 -3
  25. package/GUDHUB/ItemProcessor/ItemProcessor.js +24 -0
  26. package/GUDHUB/Storage/ModulesList.js +18 -2
  27. package/GUDHUB/Utils/AppsTemplateService/AppsTemplateService.js +37 -1
  28. package/GUDHUB/Utils/Utils.js +29 -1
  29. package/GUDHUB/Utils/merge_chunks/merge_chunks.js +36 -28
  30. package/GUDHUB/Utils/merge_chunks/merge_chunks.worker.js +78 -0
  31. package/GUDHUB/Utils/merge_compare_items/merge_compare_items.js +40 -9
  32. package/GUDHUB/WebSocket/WebSocket.js +2 -1
  33. package/GUDHUB/consts.js +21 -1
  34. package/GUDHUB/gudhub.js +39 -14
  35. package/appRequestWorker.js +1 -0
  36. package/appRequestWorker.js.LICENSE.txt +13 -0
  37. package/appRequestWorker.js.map +1 -0
  38. package/package.json +17 -6
  39. package/umd/appRequestWorker.js +1 -0
  40. package/umd/library.min.js +1 -300
  41. package/webpack.config.js +154 -0
  42. package/.vscode/launch.json +0 -31
  43. package/umd/library.min.js.map +0 -1
@@ -0,0 +1,225 @@
1
+
2
+ import { appDataServiceConf } from "../export.js";
3
+ import { GudHub } from "../../gudhub.js";
4
+ import { IndexedDBAppServiceForWorker } from "../IndexedDB/IndexedDBAppService.js";
5
+ import { appsConf } from "../IndexedDB/appDataConf.js";
6
+ import { IndexedDBChunkService } from "./IndexedDBChunkService.js";
7
+ import { chunksConf } from "./chunkDataConf.js";
8
+ import { chunksMergeConf } from "./storeManagerConf/chunkCacheStoreManagerConf.js";
9
+
10
+
11
+
12
+ let gudhub = {};
13
+ let appDataService = {};
14
+ let chunkDataService = {};
15
+
16
+
17
+
18
+ //TODO also ChunkDataService !!!!!!!!!!!!!!!!!!!!!!!
19
+
20
+
21
+ self.onmessage = async function(e) {
22
+ if (e.data.type === 'init') {
23
+
24
+
25
+ e.data.gudhubSerialized.options.initWebsocket = false;
26
+
27
+ gudhub = new GudHub(e.data.gudhubSerialized.authKey, e.data.gudhubSerialized.options);
28
+ appDataService = new IndexedDBAppServiceForWorker(gudhub.req, appsConf, gudhub);
29
+ chunkDataService = new IndexedDBChunkService(gudhub.req, chunksMergeConf, gudhub);
30
+
31
+
32
+ }
33
+
34
+ if (e.data.type === 'processData') {
35
+
36
+
37
+
38
+ //todo cached could not exist !!!!!!!!!!!!!!!!!!!
39
+
40
+ let cached = await appDataService.getCached(e.data.id); // merge ?
41
+
42
+
43
+ let cachedChunksList = cached.chunks;
44
+
45
+
46
+ let nextVersion = await appDataService.getAppWithoutProcessing(e.data.id);
47
+
48
+
49
+ let isMergedChunkUpdated = true;
50
+
51
+
52
+ if (
53
+ cachedChunksList.length != nextVersion.chunks.length
54
+ ) isMergedChunkUpdated = false;
55
+
56
+
57
+ //TODO here old chunks should be exactly with ids that came from app get request
58
+ if (
59
+ nextVersion.chunks.some(entry => !cachedChunksList.includes(entry))
60
+ ) isMergedChunkUpdated = false;
61
+
62
+
63
+ if (
64
+ !isMergedChunkUpdated
65
+ ) {
66
+
67
+ // TODO this is repetitive operation for getCached, maybe put all code in process or in getCached
68
+
69
+ let res = await chunkDataService.getCachedMergedChunk(e.data.id, cached.chunks);
70
+
71
+ // if (!res) res = [];
72
+
73
+
74
+ // // TODO check that res always exists
75
+
76
+
77
+ if (
78
+ res
79
+ ) {
80
+ cached.items_list = await gudhub.util.mergeChunks([
81
+ // cachedApp,
82
+ res,
83
+ cached,
84
+ ]);
85
+ } else {
86
+ // sentData.items_list = await this.gudhub.util.mergeChunks([
87
+ // cachedApp,
88
+ // sentData,
89
+ // ]);
90
+ }
91
+
92
+ // nextVersion = await appDataService.getAppWithSpecificChunksList(e.data.id, newChunksList); //todo check that here most recent always
93
+ nextVersion = await appDataService.getApp(e.data.id); //todo check that here most recent always
94
+
95
+
96
+ //TODO тут достаточно сравнить новые чанки+апп и закешированный апп, тогда будет сгенерирована вся инфа о новых данных
97
+
98
+
99
+ // return;
100
+ }
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ // let comparison = gudhub.compareItems(cached.items_list, newVersion.items_list);
110
+ let comparison = gudhub.compareItems(nextVersion.items_list, cached.items_list);
111
+
112
+
113
+ // async handleAppChange(id, prevVersion, nextVersion) {
114
+ let flag1 = gudhub.util.areViewListsEqual(cached.views_list, nextVersion.views_list);
115
+ let flag2 = gudhub.util.areFieldListsEqual(cached.field_list, nextVersion.field_list);
116
+
117
+ // if (
118
+ // res1 ||
119
+ // res2
120
+ // ) {
121
+ // this.updateAppFieldsAndViews({id, views_list: nextVersion.views_list, field_list: nextVersion.field_list});
122
+ // }
123
+ // }
124
+
125
+
126
+
127
+ this.postMessage({
128
+ id: e.data.id,
129
+ compareRes: comparison,
130
+ newVersion: nextVersion,
131
+ type: e.data.type,
132
+ viewListChanged: flag1,
133
+ fieldListChanged: flag2,
134
+ });
135
+
136
+
137
+
138
+
139
+ /// todo process data merge and then call merge and compare and then return from here for example event to update
140
+
141
+
142
+
143
+ // also dont forget that main thread also uses AppDataService !!!!!!!!!!!!!!!!!! make temporarile a separate class for it maybe
144
+
145
+ }
146
+
147
+
148
+ if (
149
+ e.data.type === 'requestApp'
150
+ ) {
151
+
152
+ // //todo cached could not exist !!!!!!!!!!!!!!!!!!!
153
+
154
+ // let cached = await appDataService.getCached(e.data.id); // merge ?
155
+
156
+
157
+ // let cachedChunksList = cached.chunks;
158
+
159
+
160
+ // let nextVersion = await appDataService.getAppWithoutProcessing(e.data.id);
161
+
162
+
163
+ // let isMergedChunkUpdated = true;
164
+
165
+
166
+ // if (
167
+ // cachedChunksList.length != nextVersion.chunks.length
168
+ // ) isMergedChunkUpdated = false;
169
+
170
+
171
+ // //TODO here old chunks should be exactly with ids that came from app get request
172
+ // if (
173
+ // nextVersion.chunks.some(entry => !cachedChunksList.includes(entry))
174
+ // ) isMergedChunkUpdated = false;
175
+
176
+
177
+ // if (
178
+ // !isMergedChunkUpdated
179
+ // ) {
180
+
181
+ // // TODO this is repetitive operation for getCached, maybe put all code in process or in getCached
182
+
183
+ // let res = await chunkDataService.getCachedMergedChunk(e.data.id, cached.chunks);
184
+
185
+ // // if (!res) res = [];
186
+
187
+
188
+ // // // TODO check that res always exists
189
+
190
+
191
+ // if (
192
+ // res
193
+ // ) {
194
+ // cached.items_list = await gudhub.util.mergeChunks([
195
+ // // cachedApp,
196
+ // res,
197
+ // cached,
198
+ // ]);
199
+ // } else {
200
+ // // sentData.items_list = await this.gudhub.util.mergeChunks([
201
+ // // cachedApp,
202
+ // // sentData,
203
+ // // ]);
204
+ // }
205
+
206
+ // // nextVersion = await appDataService.getAppWithSpecificChunksList(e.data.id, newChunksList); //todo check that here most recent always
207
+ // nextVersion = await appDataService.getApp(e.data.id); //todo check that here most recent always
208
+
209
+
210
+ // //TODO тут достаточно сравнить новые чанки+апп и закешированный апп, тогда будет сгенерирована вся инфа о новых данных
211
+
212
+
213
+ // // return;
214
+ // }
215
+
216
+ let data = await appDataService.getApp(e.data.id); //todo check process request method seems there i return cahced version not most recent data from server
217
+
218
+
219
+ this.postMessage({id: e.data.id, type: e.data.type, data});
220
+
221
+ }
222
+
223
+
224
+ // this.appRequestAndProcessWorker.postMessage({ type: 'requestApp', id: id });
225
+ };
@@ -1,7 +1,7 @@
1
- import { dbName, dbVersion } from "./consts.js";
1
+ // import { dbName, dbVersion } from "./consts.js";
2
2
 
3
3
  export const chunksConf = {
4
- dbName,
5
- dbVersion,
4
+ // dbName,
5
+ // dbVersion,
6
6
  store: 'chunks',
7
7
  };
@@ -1,2 +1,4 @@
1
1
  export const dbName = "gudhub";
2
- export const dbVersion = 7;
2
+ // export const dbVersion = 7;
3
+
4
+ //todo dynamic version change chatgpt used, maybe isnt good to use static version
@@ -1,21 +1,22 @@
1
- import { IS_WEB } from "../../consts.js";
1
+ import { IS_BROWSER, IS_WEB } from "../../consts.js";
2
2
  import { appsConf } from "./appDataConf.js";
3
3
  import { chunksConf } from "./chunkDataConf.js";
4
4
  import { dbName, dbVersion } from "./consts.js";
5
5
 
6
6
 
7
- if (
8
- IS_WEB
9
- ) {
10
- const request = indexedDB.open(dbName, dbVersion);
7
+ // //TODO move to indexeddbmanager
8
+ // if (
9
+ // IS_BROWSER
10
+ // ) {
11
+ // const request = indexedDB.open(dbName, dbVersion);
11
12
 
12
- request.onupgradeneeded = event => {
13
- const db = event.target.result;
13
+ // request.onupgradeneeded = event => {
14
+ // const db = event.target.result;
14
15
 
15
- for (let store of [appsConf.store, chunksConf.store]) {
16
- if (!db.objectStoreNames.contains(store)) {
17
- db.createObjectStore(store);
18
- }
19
- }
20
- };
21
- }
16
+ // for (let store of [appsConf.store, chunksConf.store]) {
17
+ // if (!db.objectStoreNames.contains(store)) {
18
+ // db.createObjectStore(store);
19
+ // }
20
+ // }
21
+ // };
22
+ // }
@@ -0,0 +1,11 @@
1
+ // import { dbName, dbVersion } from "./consts.js";
2
+
3
+ export const chunksMergeConf = {
4
+ // dbName,
5
+ // dbVersion,
6
+ store: 'chunksMergeCache',
7
+ };
8
+
9
+
10
+
11
+ //seems dbname and dbversion arent required here
@@ -0,0 +1 @@
1
+ //move appsdbcons chunksdbconf and chunkcacheconf to here
@@ -1,5 +1,5 @@
1
1
  import { cache_app_requests, cache_chunk_requests } from "../config.js";
2
- import { IS_WEB } from "../consts.js";
2
+ import { IS_BROWSER, IS_WEB } from "../consts.js";
3
3
  import { IndexedDBAppService } from "./IndexedDB/IndexedDBAppService.js";
4
4
  import { IndexedDBChunkService } from "./IndexedDB/IndexedDBChunkService.js";
5
5
  import { appsConf } from "./IndexedDB/appDataConf.js";
@@ -10,6 +10,9 @@ import { ChunkHttpService } from "./httpService/ChunkHttpService.js";
10
10
 
11
11
  import "./IndexedDB/init.js";
12
12
 
13
+
14
+ //TODO confs should be used only for appropriate classes therefore it doesnt make sense to export them here
15
+
13
16
  let AppDataService;
14
17
  let ChunkDataService;
15
18
 
@@ -18,7 +21,7 @@ let chunkDataServiceConf;
18
21
 
19
22
 
20
23
  if (
21
- IS_WEB &&
24
+ IS_BROWSER &&
22
25
  cache_chunk_requests
23
26
  ) {
24
27
  ChunkDataService = IndexedDBChunkService;
@@ -30,10 +33,10 @@ if (
30
33
 
31
34
 
32
35
  if (
33
- IS_WEB &&
34
- cache_app_requests
36
+ IS_BROWSER &&
37
+ cache_app_requests // todo here outdated approach
35
38
  ) {
36
- AppDataService = IndexedDBAppService;
39
+ AppDataService = IndexedDBAppService; // here will be AppHttpService for browser too, check compatability. Checked. seems different code. IndexedDBAppService uses worker
37
40
  appDataServiceConf = appsConf;
38
41
  } else {
39
42
  AppDataService = AppHttpService;
@@ -1,26 +1,44 @@
1
1
  import { AppAPI } from "../../api/AppApi.js";
2
2
  import { AppDataService } from "../AppDataService.js";
3
+ import { ChunkDataService } from "../export.js";
3
4
  import { objectAssignWithOverride } from "../utils.js";
4
5
  import { HttpService } from "./HttpService.js";
5
6
 
6
7
  export class AppHttpService extends AppDataService {
7
- constructor(req, conf) {
8
- super();
8
+ constructor(req, conf, gudhub) {
9
+ super(req, conf, gudhub);
9
10
 
10
11
  this.appApi = new AppAPI(req);
11
12
 
12
13
  let indexDBService = new HttpService(conf);
14
+
15
+
16
+ // this.chunkDataService = new ChunkDataService; //TODO move to
13
17
 
14
18
  objectAssignWithOverride(this, indexDBService);
15
19
  }
16
20
 
17
21
 
18
22
  async getApp(id) {
23
+ let sentData = await this.appApi.getApp(id);
24
+ return this.processRequestedApp(id, sentData); //TODO check is it ok to trigger change isnide method for AppHttpService
25
+ }
26
+
27
+ //TODO should be getApp and getAppAndProcessData - refactor whole code to use them
28
+
29
+
30
+
31
+
32
+ //TODO андрей говорил про то что там надо фильтровать айтемы удаленные, я так и не доделал
33
+
34
+
35
+
36
+ async getAppWithoutProcessing(id) {
19
37
  return this.appApi.getApp(id);
20
38
  }
21
39
 
22
40
  async putApp(id, app) {
23
-
41
+ // do nothing
24
42
  }
25
43
 
26
44
  static [Symbol.hasInstance](instance) {
@@ -32,4 +50,4 @@ export class AppHttpService extends AppDataService {
32
50
  return false;
33
51
  }
34
52
  }
35
- }
53
+ };
@@ -9,14 +9,31 @@ export class ChunkHttpService extends ChunkDataService {
9
9
 
10
10
  this.chunkApi = new ChunkAPI(req);
11
11
 
12
- let indexDBService = new HttpService(conf);
12
+ let httpService = new HttpService(conf);
13
13
 
14
- objectAssignWithOverride(this, indexDBService);
14
+ objectAssignWithOverride(this, httpService);
15
15
  }
16
16
 
17
17
  async getChunk(app_id, id) {
18
18
  return this.chunkApi.getChunk(app_id, id);
19
19
  }
20
+
21
+ async getChunksForId(app_id) {
22
+ // maybe use app get api for now and return app.chunks from there
23
+
24
+ return []; // list of chunks
25
+ }
26
+
27
+
28
+ getCachedMergedChunk(id, chunkHashesList) {
29
+
30
+ }
31
+
32
+
33
+ //here
34
+ getMergedChunkForIDList(id, chunkHashesList) {
35
+
36
+ }
20
37
 
21
38
 
22
39
  putChunk() {
@@ -31,4 +31,107 @@ export let objectAssignWithoutOverride = (target, ...sourceList) => {
31
31
  if (desc.enumerable) Object.defineProperty(target, key, desc);
32
32
  }
33
33
  }
34
- };
34
+ };
35
+
36
+
37
+
38
+ // // Base classes
39
+ // class IndexedDBMixin {
40
+ // constructor(dbName, version) {
41
+ // this.dbName = dbName;
42
+ // this.version = version;
43
+ // this.dbPromise = this.openConnection();
44
+ // }
45
+
46
+ // openConnection() {
47
+ // return new Promise((resolve, reject) => {
48
+ // const request = indexedDB.open(this.dbName, this.version);
49
+
50
+ // request.onupgradeneeded = (event) => {
51
+ // const db = event.target.result;
52
+ // if (!db.objectStoreNames.contains('storeName')) {
53
+ // db.createObjectStore('storeName', { keyPath: 'id' });
54
+ // }
55
+ // };
56
+
57
+ // request.onsuccess = (event) => resolve(event.target.result);
58
+ // request.onerror = (event) => reject(event.target.error);
59
+ // });
60
+ // }
61
+
62
+ // async getDB() {
63
+ // return await this.dbPromise;
64
+ // }
65
+
66
+ // async addRecord(storeName, record) {
67
+ // const db = await this.getDB();
68
+ // return new Promise((resolve, reject) => {
69
+ // const transaction = db.transaction(storeName, 'readwrite');
70
+ // const store = transaction.objectStore(storeName);
71
+ // const request = store.add(record);
72
+
73
+ // request.onsuccess = () => resolve(request.result);
74
+ // request.onerror = () => reject(request.error);
75
+ // });
76
+ // }
77
+
78
+ // async getRecord(storeName, key) {
79
+ // const db = await this.getDB();
80
+ // return new Promise((resolve, reject) => {
81
+ // const transaction = db.transaction(storeName, 'readonly');
82
+ // const store = transaction.objectStore(storeName);
83
+ // const request = store.get(key);
84
+
85
+ // request.onsuccess = () => resolve(request.result);
86
+ // request.onerror = () => reject(request.error);
87
+ // });
88
+ // }
89
+ // }
90
+
91
+ // class LoggingMixin {
92
+ // log(message) {
93
+ // console.log(message);
94
+ // }
95
+
96
+ // error(message) {
97
+ // console.error(message);
98
+ // }
99
+ // }
100
+
101
+ // // Mixin function
102
+ // function applyMixins(targetClass, baseClasses) {
103
+ // baseClasses.forEach(baseClass => {
104
+ // Object.getOwnPropertyDescriptors(baseClass.prototype).forEach(descriptor => {
105
+ // Object.defineProperty(targetClass.prototype, descriptor[0], descriptor[1]);
106
+ // });
107
+ // });
108
+ // }
109
+
110
+ // // Combined class
111
+ // class EnhancedIndexedDB extends IndexedDBMixin {
112
+ // constructor(dbName, version) {
113
+ // super(dbName, version);
114
+ // }
115
+ // }
116
+
117
+ // // Apply mixins
118
+ // applyMixins(EnhancedIndexedDB, [LoggingMixin]);
119
+
120
+ // // Usage example
121
+ // const dbFacade = new EnhancedIndexedDB('myDatabase', 1);
122
+
123
+ // dbFacade.addRecord('storeName', { id: 1, name: 'Sample' })
124
+ // .then((id) => {
125
+ // dbFacade.log('Record added with id: ' + id);
126
+ // })
127
+ // .catch((error) => {
128
+ // dbFacade.error('Error adding record: ' + error);
129
+ // });
130
+
131
+ // dbFacade.getRecord('storeName', 1)
132
+ // .then((record) => {
133
+ // dbFacade.log('Record retrieved: ' + JSON.stringify(record));
134
+ // })
135
+ // .catch((error) => {
136
+ // dbFacade.error('Error retrieving record: ' + error);
137
+ // });
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { IS_WEB } from './../consts.js';
2
+ import { IS_BROWSER_MAIN_THREAD, IS_WEB } from './../consts.js';
3
3
 
4
4
  /*************** FAKE ANGULAR $Q ***************/
5
5
  // It's needed when we import angular code.
@@ -80,7 +80,7 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
80
80
  let angularModule;
81
81
  let importedClass;
82
82
 
83
- if (IS_WEB) {
83
+ if (IS_BROWSER_MAIN_THREAD) {
84
84
 
85
85
  if(window.angular) {
86
86
 
@@ -290,7 +290,7 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
290
290
 
291
291
  // We need these methods in browser environment only
292
292
 
293
- if (IS_WEB) {
293
+ if (IS_BROWSER_MAIN_THREAD) {
294
294
 
295
295
  //*************** EXTEND CONTROLLER ****************//
296
296
 
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { IS_WEB } from './../consts.js';
2
+ import { IS_BROWSER_MAIN_THREAD, IS_WEB } from './../consts.js';
3
3
 
4
4
  export default async function createClassInstance(gudhub, module_id, js_url, css_url, nodeWindow) {
5
5
 
@@ -14,7 +14,7 @@ export default async function createClassInstance(gudhub, module_id, js_url, css
14
14
  // Import module using dynamic import
15
15
 
16
16
  let downloadModule = (url) => {
17
- if (!IS_WEB && !global.hasOwnProperty('window')) {
17
+ if (!IS_BROWSER_MAIN_THREAD && !global.hasOwnProperty('window')) {
18
18
  global.window = proxy;
19
19
  global.document = nodeWindow.document;
20
20
  global.Element = nodeWindow.Element;
@@ -67,7 +67,7 @@ export default async function createClassInstance(gudhub, module_id, js_url, css
67
67
  // Check if there is url to css file of module
68
68
  // If true, and there is no css for this data type, than create link tag to this css in head
69
69
 
70
- if (css_url && IS_WEB) {
70
+ if (css_url && IS_BROWSER_MAIN_THREAD) {
71
71
  const linkTag = document.createElement('link');
72
72
  linkTag.href = css_url;
73
73
  linkTag.setAttribute('data-module', module_id);
@@ -118,6 +118,30 @@ export class ItemProcessor {
118
118
  return items;
119
119
  }
120
120
 
121
+ //here
122
+
123
+ /////
124
+ handleItemsChange(id, prevVersion, nextVersion) {
125
+ let compareRes = this.util.compareItems(prevVersion.items_list, nextVersion.items_list);
126
+
127
+ this.updateItemsInStorage(id, compareRes.diff_src_items);
128
+ this.addItemsToStorage(id, compareRes.new_src_items);
129
+ }
130
+
131
+
132
+ //
133
+ triggerItemsChange(id, compareRes) {
134
+ this.updateItemsInStorage(id, compareRes.diff_src_items);
135
+ this.addItemsToStorage(id, compareRes.new_src_items);
136
+ }
137
+
138
+ //
139
+ handleDiff(id, compare) {
140
+ this.updateItemsInStorage(id, compare.diff_src_items);
141
+ this.addItemsToStorage(id, compare.new_src_items);
142
+ this.deleteItemsFromStorage(id, compare.trash_src_items);
143
+ }
144
+
121
145
  async deleteItemsFromStorage(app_id, itemsForDelete = []) {
122
146
  const app = await this.appProcessor.getApp(app_id);
123
147
  if (app) {