@gudhub/core 1.1.20 → 1.1.22

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.
@@ -309,6 +309,13 @@ export class AppProcessor {
309
309
  return newApp;
310
310
  }
311
311
 
312
+ async getAppViews(app_id) {
313
+ if(app_id) {
314
+ const app = await this.getApp(app_id);
315
+ return app.views_list;
316
+ }
317
+ }
318
+
312
319
  clearAppProcessor() {
313
320
  this.getAppListPromises = null;
314
321
  this.getAppPromises = {};
@@ -379,13 +386,6 @@ export class AppProcessor {
379
386
  }
380
387
  });
381
388
 
382
- this.pipeService.onRoot("gh_app_views_get", {}, async (event, data) => {
383
- if (data && data.app_id) {
384
- const app = await this.getApp(data.app_id);
385
- this.pipeService.emit("gh_app_views_get", data, app.views_list);
386
- }
387
- });
388
-
389
389
  // Return app_name, app_id, app_icon
390
390
  this.pipeService.onRoot("gh_app_info_get", {}, async (event, data) => {
391
391
  const appInfo = await this.getAppInfo(data.app_id);
@@ -17,7 +17,6 @@
17
17
  |
18
18
  | ---------------------------- VIEW EVENTS -----------------------------------
19
19
  | 'gh_app_views_update' -
20
- | 'gh_app_views_get' -
21
20
  | 'gh_app_view_get' -
22
21
  | -------------------------- ITEM EVENTS ------------------------------------
23
22
  |
@@ -110,12 +109,13 @@ export class PipeService {
110
109
  emit(types, destination, value, params) {
111
110
  types.split(" ").forEach((type) => {
112
111
  const listenerName = type + ":" + createId(destination);
112
+ let toBeRemovedState = false;
113
113
 
114
114
  if (this.subscribers[listenerName]) {
115
115
 
116
116
  // if subscribers list is empty we put message to messageBox
117
117
  if (this.subscribers[listenerName].size == 0){
118
- this.messageBox[listenerName] = [types, destination, value, params];
118
+ this.messageBox[listenerName] = [types, destination, value, params, toBeRemovedState];
119
119
  return this;
120
120
  }
121
121
 
@@ -126,7 +126,7 @@ export class PipeService {
126
126
 
127
127
  }else {
128
128
  // if there no subscribers list we put message to messageBox
129
- this.messageBox[listenerName] = [types, destination, value, params];
129
+ this.messageBox[listenerName] = [types, destination, value, params, toBeRemovedState];
130
130
  }
131
131
  });
132
132
  return this;
@@ -182,6 +182,7 @@ export class PipeService {
182
182
  }
183
183
 
184
184
 
185
+
185
186
  //============================== MESSAGE BOX ====================================//
186
187
  /*---------------------------------------------------------------------------------
187
188
  | If emitting event started erlier then subscriber apears then we save it to the MessageBox
@@ -189,14 +190,34 @@ export class PipeService {
189
190
  |
190
191
  |---------------------------------------------------------------------------------*/
191
192
 
192
- checkMessageBox(listenerName) {
193
+ checkMessageBox(listenerName) {
194
+
195
+ //Here we delete all messages those are marked as "to be removed"
196
+ this.cleanMesssageBox();
197
+
193
198
  if (this.messageBox[listenerName]) {
199
+
200
+ //-- Emiting messages from the MessageBox
201
+ //We use timeout to emit message after subscriber is created
194
202
  setTimeout(() => {
195
203
  this.emit(...this.messageBox[listenerName]);
196
204
 
197
- //we delete message after it was readed
198
- //delete this.messageBox[listenerName];
205
+ //we mark message after it was readed as "to be removed" to remove it in next itration
206
+ this.messageBox[listenerName][4] = true;
199
207
  }, 0);
200
208
  }
201
209
  }
210
+
211
+
212
+ /*-------- CLEAN MESSAGE BOX -----------*/
213
+ // This method delete all messages those are marked as "to be deleted"
214
+ // The thing is that we can't remove message in the same iteration that is wy we mark them as "to be removed
215
+ // and then will remove them in the second iteration just before checking the MessageBox
216
+ cleanMesssageBox(){
217
+ for (let listenerName in this.messageBox) {
218
+ if(this.messageBox[listenerName][4]){
219
+ delete this.messageBox[listenerName];
220
+ }
221
+ }
222
+ }
202
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -102,7 +102,7 @@ var t="function"==typeof Map&&Map.prototype,e=Object.getOwnPropertyDescriptor&&t
102
102
  },{"axios":"O4Aa","./utils.js":"EgeI","qs":"hIRQ"}],"Lc8J":[function(require,module,exports) {
103
103
  "use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o})(e)}function e(o){var e="";for(var t in o)o.hasOwnProperty(t)&&o[t]&&(e+="."+o[t]);return e?e.substring(1):"any"}function t(e,t,n){return null==e||"string"!=typeof e?(console.log("Listener type is \"undefined\" or not have actual 'type' for subscribe"),!1):null==t||"object"!==o(t)?(console.log("Listener destination is \"undefined\" or not have actual 'type' for subscribe"),!1):"function"==typeof n||(console.log("Listener is not a function for subscribe!"),!1)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkParams=t,exports.createId=e;
104
104
  },{}],"E3xI":[function(require,module,exports) {
105
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PipeService=void 0;var e=require("./utils.js");function r(e){return s(e)||i(e)||n(e)||t()}function t(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}function i(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function s(e){if(Array.isArray(e))return o(e)}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function u(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,r,t){return r&&u(e.prototype,r),t&&u(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var f=function(){function t(){a(this,t),this.subscribers={},this.messageBox={}}return c(t,[{key:"on",value:function(r,t,n){var i=this;return(0,e.checkParams)(r,t,n)&&r.split(" ").map(function(r){return r+":"+(0,e.createId)(t)}).forEach(function(e){i.subscribers[e]||(i.subscribers[e]=new Set),i.subscribers[e].add(n),i.checkMessageBox(e)}),this}},{key:"emit",value:function(r,t,n,i){var s=this;return r.split(" ").forEach(function(o){var a=o+":"+(0,e.createId)(t);if(s.subscribers[a]){if(0==s.subscribers[a].size)return s.messageBox[a]=[r,t,n,i],s;s.subscribers[a].forEach(function(e){e(null,n,i)})}else s.messageBox[a]=[r,t,n,i]}),this}},{key:"onRoot",value:function(e,r,t){return this.on(e,r,t)}},{key:"destroy",value:function(r,t,n){var i=this;return r.split(" ").forEach(function(r){var s=r+":"+(0,e.createId)(t);i.subscribers[s]&&n&&i.subscribers[s].delete(n),i.subscribers[s]&&!n&&delete i.subscribers[s]}),this}},{key:"checkMessageBox",value:function(e){var t=this;this.messageBox[e]&&setTimeout(function(){t.emit.apply(t,r(t.messageBox[e]))},0)}}]),t}();exports.PipeService=f;
105
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PipeService=void 0;var e=require("./utils.js");function r(e){return i(e)||s(e)||n(e)||t()}function t(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}function s(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return o(e)}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function u(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,r,t){return r&&u(e.prototype,r),t&&u(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var l=function(){function t(){a(this,t),this.subscribers={},this.messageBox={}}return c(t,[{key:"on",value:function(r,t,n){var s=this;return(0,e.checkParams)(r,t,n)&&r.split(" ").map(function(r){return r+":"+(0,e.createId)(t)}).forEach(function(e){s.subscribers[e]||(s.subscribers[e]=new Set),s.subscribers[e].add(n),s.checkMessageBox(e)}),this}},{key:"emit",value:function(r,t,n,s){var i=this;return r.split(" ").forEach(function(o){var a=o+":"+(0,e.createId)(t);if(i.subscribers[a]){if(0==i.subscribers[a].size)return i.messageBox[a]=[r,t,n,s,!1],i;i.subscribers[a].forEach(function(e){e(null,n,s)})}else i.messageBox[a]=[r,t,n,s,!1]}),this}},{key:"onRoot",value:function(e,r,t){return this.on(e,r,t)}},{key:"destroy",value:function(r,t,n){var s=this;return r.split(" ").forEach(function(r){var i=r+":"+(0,e.createId)(t);s.subscribers[i]&&n&&s.subscribers[i].delete(n),s.subscribers[i]&&!n&&delete s.subscribers[i]}),this}},{key:"checkMessageBox",value:function(e){var t=this;this.cleanMesssageBox(),this.messageBox[e]&&setTimeout(function(){t.emit.apply(t,r(t.messageBox[e])),t.messageBox[e][4]=!0},0)}},{key:"cleanMesssageBox",value:function(){for(var e in this.messageBox)this.messageBox[e][4]&&delete this.messageBox[e]}}]),t}();exports.PipeService=l;
106
106
  },{"./utils.js":"Lc8J"}],"FJWL":[function(require,module,exports) {
107
107
  "use strict";function a(a,e){return[{name:"text",url:e+"/"+a+"text_data.js",type:"angular"},{name:"text_opt",url:e+"/"+a+"text_options_data.js",type:"angular"},{name:"number",url:e+"/"+a+"number_data.js",type:"angular"},{name:"task_board",url:e+"/"+a+"task_board_data.js",type:"angular"},{name:"visualizer",url:e+"/"+a+"visualizer_data.js",type:"angular"},{name:"enterprice_visualizer",url:e+"/"+a+"enterprice_visualizer_data.js",type:"angular"},{name:"email",url:e+"/"+a+"email_data.js",type:"angular"},{name:"date",url:e+"/"+a+"date_data.js",type:"angular"},{name:"radio_button",url:e+"/"+a+"radio_button_data.js",type:"angular"},{name:"radio_icon",url:e+"/"+a+"radio_icon_data.js",type:"angular"},{name:"twilio_phone",url:e+"/"+a+"twilio_phone_data.js",type:"angular"},{name:"twilio_autodialer",url:e+"/"+a+"twillio_autodialer_data.js",type:"angular"},{name:"color",url:e+"/"+a+"color_data.js",type:"angular"},{name:"charts",url:e+"/"+a+"charts_data.js",type:"angular"},{name:"funnel_chart",url:e+"/"+a+"funnel_chart_data.js",type:"angular"},{name:"add_items_from_template",url:e+"/"+a+"add_items_from_template_data.js",type:"angular"},{name:"item_ref",url:e+"/"+a+"itemRef_data.js",type:"angular"},{name:"calendar",js:"https://gudhub.com/modules/FullCalendar-Gh-Element/dist/main.js",css:"https://gudhub.com/modules/FullCalendar-Gh-Element/dist/style.css",type:"class"},{name:"data_ref",url:e+"/"+a+"data_ref_data.js",type:"angular"},{name:"table",url:e+"/"+a+"table_data.js",type:"angular"},{name:"tile",url:e+"/"+a+"tile_data.js",type:"angular"},{name:"file",url:e+"/"+a+"file_data.js",type:"angular"},{name:"image",url:e+"/"+a+"image_data.js",type:"angular"},{name:"text_editor",url:e+"/"+a+"text_editor_data.js",type:"angular"},{name:"tinymse",url:e+"/"+a+"tinymse_data.js",type:"angular"},{name:"duration",url:e+"/"+a+"duration_data.js",type:"angular"},{name:"user",url:e+"/"+a+"user_data.js",type:"angular"},{name:"app",url:e+"/"+a+"application_data.js",type:"angular"},{name:"field",url:e+"/"+a+"field_data.js",type:"angular"},{name:"available",url:e+"/"+a+"available_data.js",type:"angular"},{name:"view_list",url:e+"/"+a+"view_list_data.js",type:"angular"},{name:"calculator",url:e+"/"+a+"calculator_data.js",type:"angular"},{name:"string_join",url:e+"/"+a+"string_joiner_data.js",type:"angular"},{name:"signature",url:e+"/"+a+"signature_data.js",type:"angular"},{name:"sendEmail",url:e+"/"+a+"send_email_data.js",type:"angular"},{name:"boolean",url:e+"/"+a+"boolean_data.js",type:"angular"},{name:"product_gallery",url:e+"/"+a+"product_gallery_data.js",type:"angular"},{name:"online_inventory",url:e+"/"+a+"online_inventory_data.js",type:"angular"},{name:"3d_edges",url:e+"/"+a+"3d_edges_data.js",type:"angular"},{name:"color_list",url:e+"/"+a+"color_list_data.js",type:"angular"},{name:"go_to_link",url:e+"/"+a+"go_to_link_data.js",type:"angular"},{name:"go_to_view",url:e+"/"+a+"go_to_view_data.js",type:"angular"},{name:"range",url:e+"/"+a+"range_data.js",type:"angular"},{name:"barcode",url:e+"/"+a+"barcode_data.js",type:"angular"},{name:"item_remote_add",url:e+"/"+a+"item_remote_add_data.js",type:"angular"},{name:"item_remote_update",url:e+"/"+a+"item_remote_update_data.js",type:"angular"},{name:"timeline",url:e+"/"+a+"timeline_data.js",type:"angular"},{name:"delete_item",url:e+"/"+a+"delete_action.js",type:"angular"},{name:"print_doc",url:e+"/"+a+"print_doc_action.js",type:"angular"},{name:"open_item",url:e+"/"+a+"open_item_action.js",type:"angular"},{name:"edit_template",url:e+"/"+a+"edit_template_action.js",type:"angular"},{name:"open_app",url:e+"/"+a+"open_app_action.js",type:"angular"},{name:"user_settings",url:e+"/"+a+"user_settings_action.js",type:"angular"},{name:"app_sharing",url:e+"/"+a+"sharing_action.js",type:"angular"},{name:"app_constructor",url:e+"/"+a+"app_constructor_action.js",type:"angular"},{name:"export_csv",url:e+"/"+a+"export_csv.js",type:"angular"},{name:"import_csv",url:e+"/"+a+"import_csv.js",type:"angular"},{name:"add_items",url:e+"/"+a+"add_items_action.js",type:"angular"},{name:"update_items",url:e+"/"+a+"update_items_action.js",type:"angular"},{name:"install_app",url:e+"/"+a+"install_app_action.js",type:"angular"},{name:"search_action",url:e+"/"+a+"search_action.js",type:"angular"},{name:"filter_table",url:e+"/"+a+"filter_table_action.js",type:"angular"},{name:"slider",url:e+"/"+a+"slider_data.js",type:"angular"},{name:"clone_item",url:e+"/"+a+"clone_item_action.js",type:"angular"},{name:"close",url:e+"/"+a+"close_action.js",type:"angular"},{name:"phone",url:e+"/"+a+"phone_data.js",type:"angular"},{name:"link",url:e+"/"+a+"link_data.js",type:"angular"},{name:"sheduling",url:e+"/"+a+"sheduling_data.js",type:"angular"},{name:"qrcode",url:e+"/"+a+"qrcode_data.js",type:"angular"},{name:"graph2d",url:e+"/"+a+"graph2d_data.js",type:"angular"},{name:"quote_tool",url:e+"/"+a+"quote_tool_data.js",type:"angular"},{name:"cards",url:e+"/"+a+"cards_data.js",type:"angular"},{name:"jsonConstructor",url:e+"/"+a+"json_constructor_data.js",type:"angular"},{name:"button",js:"https://gudhub.com/modules/button_action/button_action.js",type:"class"},{name:"editorjs",js:"https://gudhub.com/modules/Editor-Js/dist/main.js",css:"https://gudhub.com/modules/Editor-Js/dist/style.css",type:"class"},{name:"filter_advanced",url:e+"/"+a+"filter_advanced_data.js",type:"angular"},{name:"code_editor",url:e+"/"+a+"code_editor_data.js",type:"angular"},{name:"icon",url:e+"/"+a+"icon_data.js",type:"angular"},{name:"quoteRequest",url:e+"/"+a+"quote_request_data.js",type:"angular"},{name:"view_container",url:e+"/"+a+"view_container_data.js",type:"angular"},{name:"element_ref",url:e+"/"+a+"element_ref_data.js",type:"angular"},{name:"quote_tool_objects_renderer",url:e+"/"+a+"quote_tool_objects_renderer_data.js",type:"angular"},{name:"quote_tool_objects_renderer_generator",url:e+"/"+a+"quote_tool_objects_renderer_generator_data.js",type:"angular"},{name:"trigger",url:e+"/"+a+"trigger_data.js",type:"angular"},{name:"voting",url:e+"/"+a+"voting_data.js",type:"angular"},{name:"view_tabs",url:e+"/"+a+"view_tabs.js",type:"angular"},{name:"filter_tabs",url:e+"/"+a+"filter_tabs.js",type:"angular"},{name:"gps_coords",url:e+"/"+a+"gps_coords.js",type:"angular"},{name:"google_map",url:e+"/"+a+"google_map_data.js",type:"angular"},{name:"data_migrations",url:e+"/"+a+"data_migrations.js",type:"angular"},{name:"additional_settings",url:e+"/"+a+"gh_additional_settings_data.js",type:"angular"},{name:"send_request",url:e+"/"+a+"send_request_data.js",type:"angular"},{name:"webcam",url:e+"/"+a+"webcam_data.js",type:"angular"},{name:"json_viewer",url:e+"/"+a+"json_viewer_data.js",type:"angular"},{name:"notifications",url:e+"/"+a+"notifications_data.js",type:"angular"},{name:"api",url:e+"/"+a+"api_data.js",type:"angular"},{name:"smart_input",url:e+"/"+a+"smart_input_data.js",type:"angular"},{name:"json_editor",url:e+"/"+a+"json_editor_data.js",type:"angular"},{name:"grapes_html_editor",url:e+"/"+a+"grapes_html_editor_data.js",type:"angular"},{name:"quiz",url:e+"/"+a+"quiz_data.js",type:"angular"},{name:"markdown_viewer",url:e+"/"+a+"markdown_viewer_data.js",type:"angular"},{name:"password_input",url:e+"/"+a+"password_input_data.js",type:"angular"},{name:"vs_code",url:e+"/"+a+"vs_code_data.js",type:"angular"},{name:"nested_list",js:"https://gudhub.com/modules/Nested-List/dist/main.js",css:"https://gudhub.com/modules/Nested-List/dist/style.css",type:"class"},{name:"fullcalendar",js:"https://gudhub.com/modules/FullCalendar-Gh-Element/dist/main.js",css:"https://gudhub.com/modules/FullCalendar-Gh-Element/dist/style.css",type:"class"},{name:"countertop_smart_quote",url:e+"/"+a+"countertop_smart_quote_data.js",type:"angular"},{name:"markdown_viewer_web_component",js:"https://gudhub.com/modules/markdown-it-gh-element/dist/main.js",css:"https://gudhub.com/modules/markdown-it-gh-element/dist/style.css",type:"class"}]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=a;
108
108
  },{}],"CSHe":[function(require,module,exports) {
@@ -187,7 +187,7 @@ var e=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),export
187
187
  },{"axios":"O4Aa","./../consts.js":"UV2u"}],"Htuh":[function(require,module,exports) {
188
188
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GHConstructor=void 0;var e=t(require("./createAngularModuleInstance.js")),n=t(require("./createClassInstance.js"));function t(e){return e&&e.__esModule?e:{default:e}}function r(e,n,t,r,u,a,o){try{var i=e[a](o),c=i.value}catch(s){return void t(s)}i.done?n(c):Promise.resolve(c).then(r,u)}function u(e){return function(){var n=this,t=arguments;return new Promise(function(u,a){var o=e.apply(n,t);function i(e){r(o,u,a,i,c,"next",e)}function c(e){r(o,u,a,i,c,"throw",e)}i(void 0)})}}function a(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,n,t){return n&&o(e.prototype,n),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var c=function(){function t(e){a(this,t),this.gudhub=e,this.cache=[],this.modulesQueue={},this.angularInjector,this.nodeWindow}return i(t,[{key:"getInstance",value:function(){var e=u(regeneratorRuntime.mark(function e(n){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=u(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.modulesQueue[n]){e.next=4;break}return e.abrupt("return",t.modulesQueue[n].then(function(){r(t.getCached(n))}));case 4:t.cache.find(function(e){return e.type===n})?r(t.getCached(n)):(t.modulesQueue[n]=t.createInstance(n),t.modulesQueue[n].then(function(){r(t.getCached(n))}));case 5:case"end":return e.stop()}},e)}));return function(n){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e)}));return function(n){return e.apply(this,arguments)}}()},{key:"pupToCache",value:function(e){this.cache.push(e)}},{key:"getCached",value:function(e){return this.cache.find(function(n){return n.type===e})}},{key:"initAngularInjector",value:function(e){this.angularInjector=e}},{key:"initJsdomWindow",value:function(e){this.nodeWindow=e}},{key:"createInstance",value:function(){var t=u(regeneratorRuntime.mark(function t(r){var u,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(u=this.gudhub.storage.getModuleUrl(r)){t.next=4;break}return console.log("Cannot find module: ".concat(r)),t.abrupt("return");case 4:if("angular"!==u.type){t.next=10;break}return t.next=7,(0,e.default)(this.gudhub,r,u.url,this.angularInjector,this.nodeWindow);case 7:a=t.sent,t.next=14;break;case 10:if("class"!==u.type){t.next=14;break}return t.next=13,(0,n.default)(this.gudhub,r,u.js,u.css,this.nodeWindow);case 13:a=t.sent;case 14:return a&&this.pupToCache(a),t.abrupt("return",a);case 16:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()}]),t}();exports.GHConstructor=c;
189
189
  },{"./createAngularModuleInstance.js":"osSN","./createClassInstance.js":"DsUm"}],"q0my":[function(require,module,exports) {
190
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppProcessor=void 0;var e=require("../consts.js");function t(e){return i(e)||n(e)||o(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return c(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=o(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,p=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return p=e.done,e},e:function(e){s=!0,a=e},f:function(){try{p||null==r.return||r.return()}finally{if(s)throw a}}}}function o(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,i,a,p){try{var s=e[a](p),u=s.value}catch(o){return void r(o)}s.done?t(u):Promise.resolve(u).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function p(e){f(a,n,i,p,s,"next",e)}function s(e){f(a,n,i,p,s,"throw",e)}p(void 0)})}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(e,t,r){return t&&v(e.prototype,t),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var g=function(){function r(e,t,n,i,a,p,s){h(this,r),this.storage=e,this.pipeService=t,this.req=n,this.ws=i,this.applistReceived=!1,this.activateSW=s,this.chunksManager=a,this.util=p,this.appListeners()}return d(r,[{key:"createNewAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/create",form:{app:JSON.stringify(t)}});case 3:return(r=e.sent).from_apps_list=!0,e.abrupt("return",r);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/update",form:{app:JSON.stringify(t)}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/delete",form:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListApi",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/applist/get"});case 3:return t=e.sent,e.abrupt("return",t.apps_list.map(function(e){return e.from_apps_list=!0,e}));case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(){return e.apply(this,arguments)}}()},{key:"getAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/app/get",params:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListFromStorage",value:function(){return this.storage.getAppsList()}},{key:"getAppFromStorage",value:function(e){var t=this.storage.getApp(e);return t&&t.field_list.length?t:null}},{key:"addNewAppToStorage",value:function(e){return this.storage.getAppsList().push(e)}},{key:"saveAppInStorage",value:function(e){e.items_object={};for(var t=0;t<e.items_list.length;t++){e.items_object[e.items_list[t].item_id]={};for(var r=0;r<e.items_list[t].fields.length;r++)e.items_object[e.items_list[t].item_id][e.items_list[t].fields[r].field_id]=e.items_list[t].fields[r]}var n=this.storage.getApp(e.app_id);return n?(e.from_apps_list=n.from_apps_list,e.permission=n.permission,this.storage.updateApp(e)):(e.from_apps_list=!1,this.addNewAppToStorage(e)),this.getAppFromStorage(e.app_id)}},{key:"updatingAppInStorage",value:function(e){var t=this,r=this.getAppFromStorage(e.app_id);e.items_list=r.items_list,e.file_list=r.file_list,e.from_apps_list=r.from_apps_list,e.items_object=r.items_object,this.storage.updateApp(e),this.pipeService.emit("gh_app_views_update",{app_id:e.app_id},e.views_list),e.field_list.forEach(function(r){t.pipeService.emit("gh_model_update",{app_id:e.app_id,field_id:r.field_id},r)})}},{key:"deletingAppFromStorage",value:function(e){var t=this.storage.getAppsList();return t.forEach(function(r,n){r.app_id==e&&t.splice(n)}),t}},{key:"updateAppsListInStorage",value:function(){var e,t=u(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]);try{for(t.s();!(e=t.n()).done;){var r=e.value,n=this.storage.getApp(r.app_id);n?(n.from_apps_list=r.from_apps_list,n.permission=r.permission):this.addNewAppToStorage(r)}}catch(i){t.e(i)}finally{t.f()}}},{key:"refreshApps",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n,i,a,p,s,o=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=o.length>0&&void 0!==o[0]?o[0]:[],r=u(t),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=19;break}if(null==(i=n.value)||!this.storage.getApp(i)){e.next=17;break}return e.prev=7,e.next=10,this.getAppApi(i);case 10:if(a=e.sent){for(a.items_object={},p=0;p<a.items_list.length;p++)for(a.items_object[a.items_list[p].item_id]={},s=0;s<a.items_list[p].fields.length;s++)a.items_object[a.items_list[p].item_id][a.items_list[p].fields[s].field_id]=a.items_list[p].fields[s];this.storage.updateApp(a)}e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.log(e.t0);case 17:e.next=4;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(2),r.e(e.t1);case 24:return e.prev=24,r.f(),e.finish(24);case 27:console.log("Apps refreshed: ",JSON.stringify(t));case 28:case"end":return e.stop()}},e,this,[[2,21,24,27],[7,14]])}));return function(){return e.apply(this,arguments)}}()},{key:"refreshAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getAppListFromStorage(),e.next=3,this.getAppListApi();case 3:r=e.sent,n=r.map(function(e){return p(p({},e),t.find(function(t){return t.app_id===e.app_id}))}),this.updateAppsListInStorage(n),this.pipeService.emit("gh_apps_list_refreshed",{});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getAppListFromStorage(),this.applistReceived){e.next=10;break}return e.next=4,this.getAppListApi();case 4:if(r=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:this.updateAppsListInStorage(r),this.applistReceived=!0,t=r;case 10:return e.abrupt("return",t);case 11:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getAppsList();case 2:return r=e.sent,e.abrupt("return",r?r.find(function(e){return e.app_id==t}):null);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteAppApi(t);case 2:return e.abrupt("return",this.deletingAppFromStorage(t));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getApp",value:function(){var e=l(regeneratorRuntime.mark(function e(r){var n,i,a=this,p=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(p.length>1&&void 0!==p[1]&&p[1],r){e.next=3;break}return e.abrupt("return",null);case 3:if(n=this.getAppFromStorage(r)){e.next=11;break}return e.next=7,this.getAppApi(r);case 7:if(i=e.sent){e.next=10;break}return e.abrupt("return",null);case 10:i.chunks&&i.chunks.length?(this.chunksManager.getChunks(r,i.chunks).then(function(e){i.items_list=a.util.mergeChunks([].concat(t(e),[i])),a.saveAppInStorage(i),a.pipeService.emit("gh_items_update",{app_id:r},i.items_list)}),n=i,this.saveAppInStorage(i)):(n=this.getAppFromStorage(r))||(n=i,this.saveAppInStorage(i),this.ws.addSubscription(r));case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.views_list&&t.views_list.length&&t.show){e.next=6;break}return e.next=3,this.getApp(t.app_id);case 3:r=e.sent,t.views_list&&t.views_list.length||(t.views_list=r.views_list),void 0===t.show&&(t.show=r.show);case 6:return e.next=8,this.updateAppApi(t);case 8:return n=e.sent,this.updatingAppInStorage(n),e.abrupt("return",n);case 11:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=this.getAppFromStorage(t.app_id),e.abrupt("return",this.updateApp(p(p({},r),t)));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"createNewApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createNewAppApi(t);case 2:return(r=e.sent).items_object={},this.addNewAppToStorage(r),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"clearAppProcessor",value:function(){this.getAppListPromises=null,this.getAppPromises={},this.applistReceived=!1}},{key:"appListeners",value:function(){var t=this;this.pipeService.onRoot("gh_app_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_get",n,i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_apps_list_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppsList();case 2:i=e.sent,t.pipeService.emit("gh_apps_list_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_delete_app",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.deleteApp(n.app_id);case 2:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.app.items_list=[],n.app.file_list=[],e.next=4,t.updateApp(n.app);case 4:return i=e.sent,t.pipeService.emit("gh_app_views_update",{app_id:i.app_id},i.views_list),e.next=8,t.getAppsList();case 8:a=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},a),i.field_list.forEach(function(e){t.pipeService.emit("gh_model_update",{app_id:i.app_id,field_id:e.field_id},e)});case 11:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_view_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:(i=e.sent).views_list.forEach(function(e,r){e.view_id==n.view_id&&t.pipeService.emit("gh_app_view_get",n,i.views_list[r])});case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_views_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_views_get",n,i.views_list);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppInfo(n.app_id);case 2:(i=e.sent)&&t.pipeService.emit("gh_app_info_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app){e.next=5;break}return e.next=3,t.updateAppInfo(n.app);case 3:i=e.sent,t.pipeService.emit("gh_app_info_update",{app_id:n.app.app_id},i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_create",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.createNewApp(n.app);case 2:return e.next=4,t.getAppsList();case 4:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 6:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),e.IS_WEB&&this.activateSW&&navigator.serviceWorker.addEventListener("message",function(){var e=l(regeneratorRuntime.mark(function e(r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("refresh app"!==r.data.type){e.next=7;break}return e.next=3,t.getApp(r.data.payload.app_id);case 3:(n=e.sent)&&t.util.compareAppsItemsLists(n.items_list,r.data.payload.items_list.filter(function(e){return!e.trash}),function(e){var n=e.diff_fields_items,i=e.diff_fields_items_Ids,a=e.diff_items,p=e.newItems,s=e.deletedItems;(a.length||p.length||s.length)&&(t.pipeService.emit("gh_items_update",{app_id:r.data.payload.app_id},r.data.payload.items_list.filter(function(e){return!e.trash})),a.forEach(function(e){return t.pipeService.emit("gh_item_update",{app_id:r.data.payload.app_id,item_id:e.item_id},e)})),i.forEach(function(e){var i=n[e];i&&i.forEach(function(n){t.pipeService.emit("gh_value_update",{app_id:r.data.payload.app_id,item_id:e,field_id:n.field_id},n.field_value)})})}),r.data.payload.items_list=t.util.mergeChunks([n,r.data.payload]),t.saveAppInStorage(r.data.payload);case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}}]),r}();exports.AppProcessor=g;
190
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppProcessor=void 0;var e=require("../consts.js");function t(e){return i(e)||n(e)||o(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){if(Array.isArray(e))return c(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=o(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,p=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return p=e.done,e},e:function(e){s=!0,a=e},f:function(){try{p||null==r.return||r.return()}finally{if(s)throw a}}}}function o(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,i,a,p){try{var s=e[a](p),u=s.value}catch(o){return void r(o)}s.done?t(u):Promise.resolve(u).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function p(e){f(a,n,i,p,s,"next",e)}function s(e){f(a,n,i,p,s,"throw",e)}p(void 0)})}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(e,t,r){return t&&v(e.prototype,t),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var g=function(){function r(e,t,n,i,a,p,s){h(this,r),this.storage=e,this.pipeService=t,this.req=n,this.ws=i,this.applistReceived=!1,this.activateSW=s,this.chunksManager=a,this.util=p,this.appListeners()}return d(r,[{key:"createNewAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/create",form:{app:JSON.stringify(t)}});case 3:return(r=e.sent).from_apps_list=!0,e.abrupt("return",r);case 8:return e.prev=8,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 12:case"end":return e.stop()}},e,this,[[0,8]])}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/update",form:{app:JSON.stringify(t)}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/app/delete",form:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListApi",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/applist/get"});case 3:return t=e.sent,e.abrupt("return",t.apps_list.map(function(e){return e.from_apps_list=!0,e}));case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(){return e.apply(this,arguments)}}()},{key:"getAppApi",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.get({url:"/api/app/get",params:{app_id:t}});case 3:return r=e.sent,e.abrupt("return",r);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppListFromStorage",value:function(){return this.storage.getAppsList()}},{key:"getAppFromStorage",value:function(e){var t=this.storage.getApp(e);return t&&t.field_list.length?t:null}},{key:"addNewAppToStorage",value:function(e){return this.storage.getAppsList().push(e)}},{key:"saveAppInStorage",value:function(e){e.items_object={};for(var t=0;t<e.items_list.length;t++){e.items_object[e.items_list[t].item_id]={};for(var r=0;r<e.items_list[t].fields.length;r++)e.items_object[e.items_list[t].item_id][e.items_list[t].fields[r].field_id]=e.items_list[t].fields[r]}var n=this.storage.getApp(e.app_id);return n?(e.from_apps_list=n.from_apps_list,e.permission=n.permission,this.storage.updateApp(e)):(e.from_apps_list=!1,this.addNewAppToStorage(e)),this.getAppFromStorage(e.app_id)}},{key:"updatingAppInStorage",value:function(e){var t=this,r=this.getAppFromStorage(e.app_id);e.items_list=r.items_list,e.file_list=r.file_list,e.from_apps_list=r.from_apps_list,e.items_object=r.items_object,this.storage.updateApp(e),this.pipeService.emit("gh_app_views_update",{app_id:e.app_id},e.views_list),e.field_list.forEach(function(r){t.pipeService.emit("gh_model_update",{app_id:e.app_id,field_id:r.field_id},r)})}},{key:"deletingAppFromStorage",value:function(e){var t=this.storage.getAppsList();return t.forEach(function(r,n){r.app_id==e&&t.splice(n)}),t}},{key:"updateAppsListInStorage",value:function(){var e,t=u(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]);try{for(t.s();!(e=t.n()).done;){var r=e.value,n=this.storage.getApp(r.app_id);n?(n.from_apps_list=r.from_apps_list,n.permission=r.permission):this.addNewAppToStorage(r)}}catch(i){t.e(i)}finally{t.f()}}},{key:"refreshApps",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n,i,a,p,s,o=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=o.length>0&&void 0!==o[0]?o[0]:[],r=u(t),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=19;break}if(null==(i=n.value)||!this.storage.getApp(i)){e.next=17;break}return e.prev=7,e.next=10,this.getAppApi(i);case 10:if(a=e.sent){for(a.items_object={},p=0;p<a.items_list.length;p++)for(a.items_object[a.items_list[p].item_id]={},s=0;s<a.items_list[p].fields.length;s++)a.items_object[a.items_list[p].item_id][a.items_list[p].fields[s].field_id]=a.items_list[p].fields[s];this.storage.updateApp(a)}e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.log(e.t0);case 17:e.next=4;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(2),r.e(e.t1);case 24:return e.prev=24,r.f(),e.finish(24);case 27:console.log("Apps refreshed: ",JSON.stringify(t));case 28:case"end":return e.stop()}},e,this,[[2,21,24,27],[7,14]])}));return function(){return e.apply(this,arguments)}}()},{key:"refreshAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getAppListFromStorage(),e.next=3,this.getAppListApi();case 3:r=e.sent,n=r.map(function(e){return p(p({},e),t.find(function(t){return t.app_id===e.app_id}))}),this.updateAppsListInStorage(n),this.pipeService.emit("gh_apps_list_refreshed",{});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppsList",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getAppListFromStorage(),this.applistReceived){e.next=10;break}return e.next=4,this.getAppListApi();case 4:if(r=e.sent){e.next=7;break}return e.abrupt("return",null);case 7:this.updateAppsListInStorage(r),this.applistReceived=!0,t=r;case 10:return e.abrupt("return",t);case 11:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getAppsList();case 2:return r=e.sent,e.abrupt("return",r?r.find(function(e){return e.app_id==t}):null);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"deleteApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deleteAppApi(t);case 2:return e.abrupt("return",this.deletingAppFromStorage(t));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getApp",value:function(){var e=l(regeneratorRuntime.mark(function e(r){var n,i,a=this,p=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(p.length>1&&void 0!==p[1]&&p[1],r){e.next=3;break}return e.abrupt("return",null);case 3:if(n=this.getAppFromStorage(r)){e.next=11;break}return e.next=7,this.getAppApi(r);case 7:if(i=e.sent){e.next=10;break}return e.abrupt("return",null);case 10:i.chunks&&i.chunks.length?(this.chunksManager.getChunks(r,i.chunks).then(function(e){i.items_list=a.util.mergeChunks([].concat(t(e),[i])),a.saveAppInStorage(i),a.pipeService.emit("gh_items_update",{app_id:r},i.items_list)}),n=i,this.saveAppInStorage(i)):(n=this.getAppFromStorage(r))||(n=i,this.saveAppInStorage(i),this.ws.addSubscription(r));case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.views_list&&t.views_list.length&&t.show){e.next=6;break}return e.next=3,this.getApp(t.app_id);case 3:r=e.sent,t.views_list&&t.views_list.length||(t.views_list=r.views_list),void 0===t.show&&(t.show=r.show);case 6:return e.next=8,this.updateAppApi(t);case 8:return n=e.sent,this.updatingAppInStorage(n),e.abrupt("return",n);case 11:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAppInfo",value:function(){var e=l(regeneratorRuntime.mark(function e(){var t,r,n=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=this.getAppFromStorage(t.app_id),e.abrupt("return",this.updateApp(p(p({},r),t)));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"createNewApp",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createNewAppApi(t);case 2:return(r=e.sent).items_object={},this.addNewAppToStorage(r),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getAppViews",value:function(){var e=l(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.getApp(t);case 3:return r=e.sent,e.abrupt("return",r.views_list);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"clearAppProcessor",value:function(){this.getAppListPromises=null,this.getAppPromises={},this.applistReceived=!1}},{key:"appListeners",value:function(){var t=this;this.pipeService.onRoot("gh_app_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:i=e.sent,t.pipeService.emit("gh_app_get",n,i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_apps_list_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppsList();case 2:i=e.sent,t.pipeService.emit("gh_apps_list_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_delete_app",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.deleteApp(n.app_id);case 2:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.app.items_list=[],n.app.file_list=[],e.next=4,t.updateApp(n.app);case 4:return i=e.sent,t.pipeService.emit("gh_app_views_update",{app_id:i.app_id},i.views_list),e.next=8,t.getAppsList();case 8:a=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},a),i.field_list.forEach(function(e){t.pipeService.emit("gh_model_update",{app_id:i.app_id,field_id:e.field_id},e)});case 11:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_view_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app_id){e.next=5;break}return e.next=3,t.getApp(n.app_id);case 3:(i=e.sent).views_list.forEach(function(e,r){e.view_id==n.view_id&&t.pipeService.emit("gh_app_view_get",n,i.views_list[r])});case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_get",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getAppInfo(n.app_id);case 2:(i=e.sent)&&t.pipeService.emit("gh_app_info_get",n,i);case 4:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_update",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n||!n.app){e.next=5;break}return e.next=3,t.updateAppInfo(n.app);case 3:i=e.sent,t.pipeService.emit("gh_app_info_update",{app_id:n.app.app_id},i);case 5:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_create",{},function(){var e=l(regeneratorRuntime.mark(function e(r,n){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.createNewApp(n.app);case 2:return e.next=4,t.getAppsList();case 4:i=e.sent,t.pipeService.emit("gh_apps_list_update",{recipient:"all"},i);case 6:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()),e.IS_WEB&&this.activateSW&&navigator.serviceWorker.addEventListener("message",function(){var e=l(regeneratorRuntime.mark(function e(r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("refresh app"!==r.data.type){e.next=7;break}return e.next=3,t.getApp(r.data.payload.app_id);case 3:(n=e.sent)&&t.util.compareAppsItemsLists(n.items_list,r.data.payload.items_list.filter(function(e){return!e.trash}),function(e){var n=e.diff_fields_items,i=e.diff_fields_items_Ids,a=e.diff_items,p=e.newItems,s=e.deletedItems;(a.length||p.length||s.length)&&(t.pipeService.emit("gh_items_update",{app_id:r.data.payload.app_id},r.data.payload.items_list.filter(function(e){return!e.trash})),a.forEach(function(e){return t.pipeService.emit("gh_item_update",{app_id:r.data.payload.app_id,item_id:e.item_id},e)})),i.forEach(function(e){var i=n[e];i&&i.forEach(function(n){t.pipeService.emit("gh_value_update",{app_id:r.data.payload.app_id,item_id:e,field_id:n.field_id},n.field_value)})})}),r.data.payload.items_list=t.util.mergeChunks([n,r.data.payload]),t.saveAppInStorage(r.data.payload);case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}}]),r}();exports.AppProcessor=g;
191
191
  },{"../consts.js":"UV2u"}],"UUd3":[function(require,module,exports) {
192
192
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ItemProcessor=void 0;var e=require("../utils.js");function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t,r,n,i,a,s){try{var u=e[a](s),p=u.value}catch(o){return void r(o)}u.done?t(p):Promise.resolve(p).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var s=e.apply(t,r);function u(e){i(s,n,a,u,p,"next",e)}function p(e){i(s,n,a,u,p,"throw",e)}u(void 0)})}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var o=function(){function t(e,r,n,i,a){s(this,t),this.storage=e,this.pipeService=r,this.req=n,this.appProcessor=i,this.util=a,this.itemListeners()}return p(t,[{key:"addItemsApi",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/items/add",form:{items:JSON.stringify(r),app_id:t}});case 3:return n=e.sent,e.abrupt("return",n);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsApi",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.req.post({url:"/api/items/update",form:{items:JSON.stringify(r),app_id:t}});case 3:return n=e.sent,e.abrupt("return",n);case 7:return e.prev=7,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}},e,this,[[0,7]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsApi",value:function(e){try{var t=this.req.post({url:"/api/items/delete",form:{items_ids:JSON.stringify(e)}});return t.from_apps_list=!0,t}catch(r){return console.log(r),null}}},{key:"addItemsToStorage",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var n,i=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.appProcessor.getApp(t);case 2:return(n=e.sent)&&(r.forEach(function(e){n.items_list.push(e),n.items_object[e.item_id]={};for(var r=0;r<e.fields.length;r++)n.items_object[e.item_id][e.fields[r].field_id]=e.fields[r];i.pipeService.emit("gh_item_update",{app_id:t},[e])}),this.pipeService.emit("gh_items_update",{app_id:t},n.items_list),this.storage.updateApp(n)),e.abrupt("return",n);case 5:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsInStorage",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var n,i=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.pipeService.emit("gh_items_update",{app_id:t},r),e.next=3,this.appProcessor.getApp(t);case 3:return(n=e.sent)&&r&&r.forEach(function(e){var r={app_id:t};i.pipeService.emit("gh_item_update",r,[e]),r.item_id=e.item_id,i.pipeService.emit("gh_item_update",r,e);var a=n.items_list.find(function(t){return t.item_id==e.item_id});a&&e.fields.forEach(function(e){var t=a.fields.find(function(t){return t.field_id==e.field_id});r.field_id=e.field_id,t?t.field_value!=e.field_value&&(t.field_value=e.field_value,n.items_object[a.item_id][t.field_id]=t,i.pipeService.emit("gh_value_update",r,e.field_value)):(a.fields.push(e),i.pipeService.emit("gh_value_update",r,e.field_value))})}),e.abrupt("return",r);case 6:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsFromStorage",value:function(){var e=a(regeneratorRuntime.mark(function e(t){var r,n,i=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:[],e.next=3,this.appProcessor.getApp(t);case 3:(n=e.sent)&&(n.items_list=n.items_list.filter(function(e){return!r.find(function(t){return e.item_id==t.item_id})||(delete n.items_object[e.item_id],!1)}),this.pipeService.emit("gh_items_update",{app_id:t},n.items_list),this.storage.updateApp(n));case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=a(regeneratorRuntime.mark(function e(t){var r,n,i=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>1&&void 0!==i[1]&&i[1],e.next=3,this.appProcessor.getApp(t,r);case 3:if(n=e.sent){e.next=6;break}return e.abrupt("return",null);case 6:return e.abrupt("return",n.items_list);case 7:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(){var t=a(regeneratorRuntime.mark(function t(n,i){var a,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=i.map(function(t){return r(r({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.next=3,this.addItemsApi(n,a);case 3:return s=t.sent,t.next=6,this.addItemsToStorage(n,s);case 6:return this.pipeService.emit("gh_items_add",{app_id:n},s),t.abrupt("return",s);case 8:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"updateItems",value:function(){var t=a(regeneratorRuntime.mark(function t(n,i){var a,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=i.map(function(t){return r(r({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.next=3,this.updateItemsApi(n,a);case 3:return s=t.sent,t.next=6,this.updateItemsInStorage(n,s);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"deleteItems",value:function(){var e=a(regeneratorRuntime.mark(function e(t,r){var n=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deleteItemsApi(r).then(function(){var e=a(regeneratorRuntime.mark(function e(r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.deleteItemsFromStorage(t,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){var e=this;this.pipeService.onRoot("gh_items_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n||!n.app_id){t.next=5;break}return t.next=3,e.getItems(n.app_id);case 3:(i=t.sent)?e.pipeService.emit("gh_items_get",n,i):e.pipeService.emit("gh_items_get",n,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_add",{},function(){var t=a(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n&&n.app_id&&n.items)){t.next=5;break}return t.next=3,e.addNewItems(n.app_id,n.items);case 3:(i=t.sent)?e.pipeService.emit("gh_items_add",n,i):e.pipeService.emit("gh_items_add",n,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_update",{},function(){var t=a(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n&&n.app_id&&n.items)){t.next=5;break}return t.next=3,e.updateItems(n.app_id,n.items);case 3:(i=t.sent)?e.pipeService.emit("gh_items_update",n,i):e.pipeService.emit("gh_items_update",n,[]);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_item_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,n){var i,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n||!n.app_id){t.next=6;break}return t.next=3,e.getItems(n.app_id);case 3:i=t.sent,a=i.find(function(e){return e.item_id==n.item_id}),e.pipeService.emit("gh_item_get",n,a);case 6:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filtered_items_get",{},function(){var t=a(regeneratorRuntime.mark(function t(r,n){var i,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n||!n.element_app_id){t.next=8;break}return t.next=3,e.getItems(n.element_app_id);case 3:return i=t.sent,t.next=6,e.util.getFilteredItems(i,n.filters_list,n.element_app_id,n.app_id,n.item_id,n.field_groupe,n.search,n.search_params);case 6:a=t.sent,e.pipeService.emit("gh_filtered_items_get",n,a);case 8:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filter_items",{},function(){var t=a(regeneratorRuntime.mark(function t(r,n){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n||!n.items){t.next=5;break}return t.next=3,e.util.getFilteredItems(n.items,n.filters_list,n.element_app_id,n.app_id,n.item_id,n.field_groupe,n.search,n.search_params);case 3:i=t.sent,e.pipeService.emit("gh_filter_items",n,i);case 5:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}())}}]),t}();exports.ItemProcessor=o;
193
193
  },{"../utils.js":"EgeI"}],"PoPF":[function(require,module,exports) {