qcobjects 2.4.32-beta → 2.4.38

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/QCObjects.js CHANGED
@@ -190,7 +190,8 @@
190
190
  } else if (typeof global !== "undefined") {
191
191
  _top = global;
192
192
  }
193
- var basePath = (
193
+ var _domain_, _basePath_;
194
+ _basePath_ = (
194
195
  function () {
195
196
  var _basePath = "";
196
197
  if (isBrowser) {
@@ -238,7 +239,7 @@
238
239
  _top.console.prototype.log = function (message) {};
239
240
  }
240
241
 
241
- var domain = (
242
+ _domain_ = (
242
243
  function () {
243
244
  return (typeof document !== "undefined" && document.domain !== "") ? (document.domain) : ("localhost");
244
245
  }
@@ -264,7 +265,7 @@
264
265
  // This is only for code integrity purpose using non-browser implementations
265
266
  // like using node.js
266
267
  var _secretKey = "secret";
267
- var domain = "localhost";
268
+ _domain_ = "localhost";
268
269
  }
269
270
 
270
271
  _top._asyncLoad = [];
@@ -783,9 +784,9 @@
783
784
  var _ret_ = "";
784
785
  switch (true) {
785
786
  case typeof o_c === "object" &&
786
- !!o_c.constructor &&
787
- Object.hasOwnProperty.call(o_c.constructor, "name") &&
788
- o_c.constructor.name !== "":
787
+ (!!o_c.constructor &&
788
+ !!o_c.constructor.name)
789
+ && o_c.constructor.name !== "":
789
790
  _ret_ = o_c.constructor.name;
790
791
  break;
791
792
  case (!!o_c && !!o_c.__classType) && o_c.__classType !== "":
@@ -794,6 +795,9 @@
794
795
  case (!!o_c && !!o_c.__definition) && (!!o_c.__definition.__classType) && o_c.__definition.__classType !== "":
795
796
  _ret_ = o_c.__definition.__classType;
796
797
  break;
798
+ case typeof o_c === "function" && !!o_c.name:
799
+ _ret_ = o_c.name;
800
+ break;
797
801
  default:
798
802
  _ret_ = ObjectName(o_c);
799
803
  break;
@@ -831,15 +835,19 @@
831
835
 
832
836
  };
833
837
 
834
- var __register_class__ = function (_class_) {
835
- var name = _class_.name;
838
+ var __register_class__ = function (_class_, __namespace) {
839
+ var name = _class_.name || __getType__(_class_);
840
+ _class_.__definition.__classType = name;
841
+ if (typeof __namespace !== "undefined"){
842
+ _class_.__definition.__namespace = __namespace;
843
+ }
836
844
  _QC_CLASSES[name] = _class_;
837
845
  _top[name] = _QC_CLASSES[name];
838
846
  return _top[name];
839
847
  };
840
848
 
841
- var RegisterClass = function (_class_) {
842
- return __register_class__(_class_);
849
+ var RegisterClass = function (_class_, __namespace) {
850
+ return __register_class__(_class_, __namespace);
843
851
  };
844
852
  __make_global__(RegisterClass);
845
853
 
@@ -906,7 +914,6 @@
906
914
  __definition = {
907
915
  ...definition
908
916
  };
909
- body = null;
910
917
 
911
918
  static hierarchy(__class__) {
912
919
  var __classType = function (o_c) {
@@ -935,6 +942,7 @@
935
942
  _o_ = {};
936
943
  }
937
944
  super(_o_);
945
+
938
946
  let self = this;
939
947
  __instanceID = (typeof __instanceID === "undefined" || __instanceID === null) ? (0) : (__instanceID + 1);
940
948
  if (!self.__instanceID) {
@@ -1013,20 +1021,9 @@
1013
1021
  return this["body"]["style"];
1014
1022
  }
1015
1023
 
1016
- hierarchy(__instance__) {
1017
- var __hierarchy;
1018
- if (typeof __instance__ === "undefined" || __instance__ === null) {
1019
- __instance__ = this;
1020
- }
1021
- var __parent__ = Object.getPrototypeOf(__instance__.constructor);
1022
- if (__parent__.hierarchy) {
1023
- __hierarchy = __parent__.hierarchy.call(__parent__, __parent__);
1024
- } else {
1025
- __hierarchy = [];
1026
- }
1027
- return [__getType__(__instance__)].concat(__hierarchy).filter(function (value, index, self) {
1028
- return self.indexOf(value) === index;
1029
- });
1024
+ hierarchy() {
1025
+ var __instance__ = this;
1026
+ return this.getClass().hierarchy(__instance__);
1030
1027
  }
1031
1028
 
1032
1029
 
@@ -1072,7 +1069,6 @@
1072
1069
 
1073
1070
  _QC_CLASSES[name] = _CastProps(definition, _QC_CLASSES[name]);
1074
1071
  _QC_CLASSES[name]["__definition"] = definition;
1075
- _QC_CLASSES[name]["__definition"]["hierarchy"] = _QC_CLASSES[name]["hierarchy"].bind(_QC_CLASSES[name]["__definition"]);
1076
1072
  _QC_CLASSES[name]["__definition"]["__classType"] = name;
1077
1073
  _QC_CLASSES[name]["__definition"]["__new__"] = function __new__(_o_) {
1078
1074
  _CastProps(_o_, this);
@@ -1100,14 +1096,13 @@
1100
1096
  var _className = className.split(".").slice(-1).join("");
1101
1097
  var _package = Package(packageName);
1102
1098
  var packageClasses = (typeof _package !== "undefined") ? (_package.filter(classFactory => {
1103
- return typeof classFactory !== "undefined" &&
1104
- Object.hasOwnProperty.call(classFactory, "__definition") &&
1105
- isQCObjects_Class(classFactory) &&
1106
- classFactory.__definition.__classType === _className &&
1107
- !Object.hasOwnProperty.call(classFactory, "__instanceID");
1099
+ return isQCObjects_Class(classFactory) &&
1100
+ (classFactory.__definition.__classType === _className || (typeof classFactory === "function" && !!classFactory.name) ) ;
1108
1101
  }).reverse()) : ([]);
1109
1102
  if (packageClasses.length > 0) {
1110
1103
  _classFactory = packageClasses[0];
1104
+ } else {
1105
+ throw Error (`Class ${className} not found.`);
1111
1106
  }
1112
1107
  } else if (className !== null && Object.hasOwnProperty.call(_QC_CLASSES, className)) {
1113
1108
  _classFactory = _QC_CLASSES[className];
@@ -1383,7 +1378,7 @@
1383
1378
  "routingWay": "hash",
1384
1379
  "useSDK": true,
1385
1380
  "useLocalSDK": false,
1386
- "basePath": basePath
1381
+ "basePath": _basePath_
1387
1382
  };
1388
1383
  _config_settings._CONFIG_ENC = null;
1389
1384
  this._instance = _config_settings;
@@ -1412,7 +1407,7 @@
1412
1407
  logger.debug(`CONFIG.set ${name}: ${value}`);
1413
1408
  // hack to force update basePath from CONFIG
1414
1409
  if (name === "basePath") {
1415
- basePath = value;
1410
+ _basePath_ = value;
1416
1411
  }
1417
1412
  var _conf;
1418
1413
  try {
@@ -1532,7 +1527,7 @@
1532
1527
  }
1533
1528
  if (Object.hasOwnProperty.call(_QC_PACKAGES, namespace)) {
1534
1529
  _QC_PACKAGES[namespace].map(function (_class_) {
1535
- __register_class__(_class_);
1530
+ __register_class__(_class_, namespace);
1536
1531
  });
1537
1532
  }
1538
1533
  return (Object.hasOwnProperty.call(_QC_PACKAGES, namespace)) ? (_QC_PACKAGES[namespace]) : (undefined);
@@ -1644,7 +1639,7 @@
1644
1639
  "_package_name_": packagename
1645
1640
  });
1646
1641
  };
1647
- s1.src = (external) ? (_top.CONFIG.get("remoteImportsPath") + packagename + ".js") : (basePath + _top.CONFIG.get("relativeImportPath") + packagename + ".js");
1642
+ s1.src = (external) ? (_top.CONFIG.get("remoteImportsPath") + packagename + ".js") : (_basePath_ + _top.CONFIG.get("relativeImportPath") + packagename + ".js");
1648
1643
  document.getElementsByTagName("head")[0].appendChild(s1);
1649
1644
  }
1650
1645
  });
@@ -1665,7 +1660,7 @@
1665
1660
  if (jsNodePath !== null) {
1666
1661
  packageAbsoluteName = jsNodePath + "/" + packagename + ".js";
1667
1662
  } else {
1668
- packageAbsoluteName = basePath + _top.CONFIG.get("relativeImportPath") + packagename;
1663
+ packageAbsoluteName = _basePath_ + _top.CONFIG.get("relativeImportPath") + packagename;
1669
1664
  }
1670
1665
  }
1671
1666
  try {
@@ -2019,657 +2014,711 @@
2019
2014
  }
2020
2015
  }
2021
2016
  };
2022
- Class("Component", ClassFactory("InheritClass"), {
2023
- domain: domain,
2024
- basePath: basePath,
2025
- templateURI: "",
2026
- templateHandler: "DefaultTemplateHandler",
2027
- template: undefined,
2028
- processorHandler: null,
2029
- tplsource: "default",
2030
- url: "",
2031
- name: "",
2032
- method: "GET",
2033
- data: {},
2034
- reload: false,
2035
- shadowed: false,
2036
- cached: true,
2037
- done() {
2038
- //TODO: default done method
2039
- },
2040
- fail() {
2041
- //TODO: default fail method
2042
- },
2043
- set(name, value) {
2044
- this[name] = value;
2045
- },
2046
- get(name) {
2047
- return this[name];
2048
- },
2049
- __promise__: null,
2050
- feedComponent() {
2051
- var _component_ = this;
2052
- var _feedComponent_InBrowser = function (_component_) {
2053
- if (typeof _component_.container === "undefined" && typeof _component_.body === "undefined") {
2054
- logger.warn("COMPONENT {{NAME}} has an undefined container and body".replace("{{NAME}}", _component_.name));
2055
- return;
2017
+
2018
+ Package("com.qcobjects", [
2019
+ class Component extends ClassFactory("InheritClass") {
2020
+ validRoutingWays= ["pathname", "hash", "search"];
2021
+ basePath= _basePath_;
2022
+ domain= _domain_;
2023
+ templateHandler= "DefaultTemplateHandler";
2024
+ processorHandler= null;
2025
+ routingWay= null;
2026
+ routingNodes= [];
2027
+ routings= [];
2028
+ routingPath= "";
2029
+ _componentHelpers= [];
2030
+ splashScreenComponent=undefined;
2031
+
2032
+ constructor ({
2033
+ templateURI= "",
2034
+ template,
2035
+ tplsource= "default",
2036
+ url= "",
2037
+ name= "",
2038
+ method= "GET",
2039
+ data= {},
2040
+ reload= false,
2041
+ shadowed= false,
2042
+ cached= true,
2043
+ _body=_DOMCreateElement("div"),
2044
+ __promise__= null,
2045
+ __shadowRoot,
2046
+ body,
2047
+ shadowRoot,
2048
+ splashScreenComponent,
2049
+ }){
2050
+ super(...arguments);
2051
+ var self = this;
2052
+
2053
+ if (typeof self.name === "undefined") {
2054
+ logger.warn("A name is not defined for " + __getType__(self));
2056
2055
  }
2057
- var container = (typeof _component_.container === "undefined" || _component_.container === null) ? (_component_.body) : (_component_.container);
2058
- var parsedAssignmentText = _component_.parsedAssignmentText;
2059
- _component_.innerHTML = parsedAssignmentText;
2060
- if (_component_.shadowed) {
2061
- logger.debug("COMPONENT {{NAME}} is shadowed".replace("{{NAME}}", _component_.name));
2062
- logger.debug("Preparing slots for Shadowed COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2063
- var tmp_shadowContainer = _DOMCreateElement("div");
2064
- container.subelements("[slot]").map(
2065
- function (c) {
2066
- if (c.parentElement === container) {
2067
- tmp_shadowContainer.appendChild(c);
2068
- }
2069
- });
2070
- logger.debug("Creating shadowedContainer for COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2071
- var shadowContainer = _DOMCreateElement("div");
2072
- shadowContainer.classList.add("shadowHost");
2073
- try {
2074
- _component_.shadowRoot = shadowContainer.attachShadow({
2075
- mode: "open"
2076
- });
2077
- } catch (e) {
2078
- try {
2079
- logger.debug("Shadowed COMPONENT {{NAME}} is repeated".replace("{{NAME}}", _component_.name));
2080
- _component_.shadowRoot = shadowContainer.shadowRoot;
2081
- } catch (e) {
2082
- logger.warn("Shadowed COMPONENT {{NAME}} is not allowed on this browser".replace("{{NAME}}", _component_.name));
2083
- }
2084
- }
2085
- if (typeof _component_.shadowRoot !== "undefined" && _component_.shadowRoot !== null) {
2086
- if (_component_.reload) {
2087
- logger.debug("FORCED RELOADING OF CONTAINER FOR Shadowed COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2088
- shadowContainer.shadowRoot.innerHTML = _component_.innerHTML;
2089
- } else {
2090
- tmp_shadowContainer.innerHTML = _component_.parseTemplate(tmp_shadowContainer.innerHTML);
2091
- logger.debug("ADDING Shadowed COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
2092
- shadowContainer.shadowRoot.innerHTML += _component_.innerHTML;
2093
- }
2094
- logger.debug("ADDING Slots to Shadowed COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
2095
- shadowContainer.innerHTML += tmp_shadowContainer.innerHTML;
2096
- logger.debug("APPENDING Shadowed COMPONENT {{NAME}} to Container ".replace("{{NAME}}", _component_.name));
2097
- if (container.subelements(".shadowHost") < 1) {
2098
- container.appendChild(shadowContainer);
2099
- } else {
2100
- logger.debug("Shadowed Container for COMPONENT {{NAME}} is already present in the tree ".replace("{{NAME}}", _component_.name));
2101
- container.removeChild(container.subelements(".shadowHost").pop());
2102
- container.appendChild(shadowContainer);
2103
- }
2104
- } else {
2105
- logger.warn("Shadowed COMPONENT {{NAME}} is bad configured".replace("{{NAME}}", _component_.name));
2106
- }
2107
- } else {
2108
- if (_component_.reload) {
2109
- logger.debug("FORCED RELOADING OF CONTAINER FOR COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2110
- container.innerHTML = _component_.innerHTML;
2111
- } else if (container && _component_) {
2112
- logger.debug("ADDING COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
2113
- container.innerHTML += _component_.innerHTML;
2114
- } else {
2115
- logger.warn("COMPONENT {{NAME}} is not added to the DOM".replace("{{NAME}}", _component_.name));
2116
- }
2056
+
2057
+ self.routingWay = _top.CONFIG.get("routingWay");
2058
+
2059
+ self.processorHandler = New(ClassFactory("Processor"), {
2060
+ component: self
2061
+ });
2062
+
2063
+ if (typeof self.__new__ === "function") {
2064
+ self.__new__.call(self, self);
2117
2065
  }
2118
2066
 
2119
- };
2067
+ self._generateRoutingPaths(self.body)
2068
+ .then(function (){
2069
+ self._reroute_()
2070
+ .then(function () {
2071
+ return self.rebuild()
2072
+ .then(function () {
2073
+ logger.info(`Component._new_ The component ${self.name} was built successfully!`);
2074
+ }).catch(function (standardResponse) {
2075
+ logger.warn(`Component._new_ Something went wrong building the component ${self.name}`);
2076
+ console.error(standardResponse);
2077
+ });
2078
+ });
2079
+ });
2120
2080
 
2121
- var _feedComponent_InNode = function (_component_) {
2122
- var parsedAssignmentText = _component_.parsedAssignmentText;
2123
- _component_.innerHTML = parsedAssignmentText;
2124
- };
2081
+ }
2082
+
2083
+ set body(value) {
2084
+ var self = this;
2085
+ self._body = value;
2086
+ }
2087
+
2088
+ get body() {
2089
+ var self= this;
2090
+ return self._body;
2091
+ }
2092
+
2093
+ set cacheIndex(value) {
2094
+ // readonly
2095
+ logger.debug("[cacheIndex] This property is readonly");
2096
+ }
2097
+
2098
+ get cacheIndex() {
2099
+ var self= this;
2100
+ var __routing_path__ = _DataStringify(self.routingPath);
2101
+ return Base64.encode(self.name + __routing_path__);
2102
+ }
2103
+
2104
+ set parsedAssignmentText(value) {
2105
+ // readonly
2106
+ logger.debug("[parsedAssignmentText] This property is readonly");
2107
+ }
2108
+
2109
+ get parsedAssignmentText() {
2110
+ var self= this;
2111
+ self._parsedAssignmentText = self.parseTemplate(self.template);
2112
+ if (typeof self._parsedAssignmentText === "undefined"){
2113
+ throw Error (`[Component][${this.name}][parsedAssignmentText] Could not generate content!`);
2114
+ }
2115
+ return self._parsedAssignmentText;
2116
+ }
2117
+
2118
+
2119
+ set shadowRoot(value) {
2120
+ var self= this;
2121
+ if (typeof self.__shadowRoot == "undefined") {
2122
+ self.__shadowRoot = value;
2123
+ } else {
2124
+ logger.debug("[shadowRoot] This property can only be assigned once!");
2125
+ }
2126
+ }
2125
2127
 
2126
- var _ret_;
2127
- if (!is_a(_component_, "Component")) {
2128
- logger.warn("Trying to feed a non component object");
2129
- return;
2128
+ get shadowRoot() {
2129
+ var self= this;
2130
+ return self.__shadowRoot;
2130
2131
  }
2131
- if (isBrowser) {
2132
- _ret_ = _feedComponent_InBrowser(_component_);
2133
- } else {
2134
- _ret_ = _feedComponent_InNode(_component_);
2132
+
2133
+
2134
+ set routingSelected(value){
2135
+ logger.debug("[routingSelected] This is a read-only property of the component");
2135
2136
  }
2136
- return _ret_;
2137
- },
2138
- rebuild() {
2139
- var _component = this;
2140
- var _promise = new Promise(function (resolve, reject) {
2141
- if (typeof _component === "undefined" || _component === null) {
2142
- reject("Component is undefined");
2137
+
2138
+ get routingSelected (){
2139
+ var self= this;
2140
+ return __valid_routings__(self.routings, self.routingPath);
2141
+ }
2142
+
2143
+ set routingParams (value){
2144
+ logger.debug("[routingParams] This is a read-only property of the component");
2145
+ }
2146
+
2147
+ get routingParams (){
2148
+ var component = this;
2149
+ return [{}].concat(component.routingSelected.map(function (routing) {
2150
+ return __routing_params__(routing, component.routingPath);
2151
+ })).reduce(function (accumulator, colData, index) {
2152
+ return Object.assign(accumulator, colData);
2153
+ });
2154
+ }
2155
+
2156
+ done(standardResponse) {
2157
+ var _ret_;
2158
+ if (typeof standardResponse !== "undefined"){
2159
+ var {request, component} = standardResponse;
2160
+ _ret_ = Promise.resolve({request, component});
2143
2161
  }
2144
- if (isQCObjects_Object(_component) && is_a(_component, "Component")) {
2145
- switch (true) {
2146
- case (_component.get("tplsource") === "none"):
2147
- logger.debug("Component " + _component.name + " has specified template-source=none, so no template load was done");
2148
- var standardResponse = {
2149
- request: null,
2150
- component: _component
2151
- };
2152
- if (typeof _component.done === "function") {
2153
- _component.done.call(_component, standardResponse);
2162
+ return _ret_;
2163
+ }
2164
+
2165
+ fail(standardResponse) {
2166
+ var _ret_;
2167
+ if (typeof standardResponse !== "undefined"){
2168
+ var {error, component} = standardResponse;
2169
+ _ret_ = Promise.resolve({error, component});
2170
+ }
2171
+ return _ret_;
2172
+ }
2173
+
2174
+ set(name, value) {
2175
+ this[name] = value;
2176
+ }
2177
+
2178
+ get(name) {
2179
+ return this[name];
2180
+ }
2181
+
2182
+ feedComponent() {
2183
+ var _component_ = this;
2184
+ logger.debug(`[Component][${this.name}][feedComponent] start feeding component...`);
2185
+ var _feedComponent_InBrowser = function (_component_) {
2186
+ if (typeof _component_.container === "undefined" && typeof _component_.body === "undefined") {
2187
+ logger.warn("COMPONENT {{NAME}} has an undefined container and body".replace("{{NAME}}", _component_.name));
2188
+ return;
2189
+ }
2190
+ var container = (typeof _component_.container === "undefined" || _component_.container === null) ? (_component_.body) : (_component_.container);
2191
+ var parsedAssignmentText = _component_.parsedAssignmentText;
2192
+ _component_.innerHTML = parsedAssignmentText;
2193
+ if (_component_.shadowed) {
2194
+ logger.debug("COMPONENT {{NAME}} is shadowed".replace("{{NAME}}", _component_.name));
2195
+ logger.debug("Preparing slots for Shadowed COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2196
+ var tmp_shadowContainer = _DOMCreateElement("div");
2197
+ container.subelements("[slot]").map(
2198
+ function (c) {
2199
+ if (c.parentElement === container) {
2200
+ tmp_shadowContainer.appendChild(c);
2201
+ }
2202
+ });
2203
+ logger.debug("Creating shadowedContainer for COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2204
+ var shadowContainer = _DOMCreateElement("div");
2205
+ shadowContainer.classList.add("shadowHost");
2206
+ try {
2207
+ _component_.shadowRoot = shadowContainer.attachShadow({
2208
+ mode: "open"
2209
+ });
2210
+ } catch (e) {
2211
+ try {
2212
+ logger.debug("Shadowed COMPONENT {{NAME}} is repeated".replace("{{NAME}}", _component_.name));
2213
+ _component_.shadowRoot = shadowContainer.shadowRoot;
2214
+ } catch (e) {
2215
+ logger.warn("Shadowed COMPONENT {{NAME}} is not allowed on this browser".replace("{{NAME}}", _component_.name));
2154
2216
  }
2155
- resolve.call(_promise, standardResponse);
2156
- break;
2157
- case (_component.get("tplsource") === "inline"):
2158
- logger.debug("Component " + _component.name + " has specified template-source=inline, so it is assumed that template is already declared");
2159
- _component.feedComponent();
2160
- var standardResponse = {
2161
- request: null,
2162
- component: _component
2163
- };
2164
- if (typeof _component.done === "function") {
2165
- _component.done.call(_component, standardResponse);
2217
+ }
2218
+ if (typeof _component_.shadowRoot !== "undefined" && _component_.shadowRoot !== null) {
2219
+ if (_component_.reload) {
2220
+ logger.debug("FORCED RELOADING OF CONTAINER FOR Shadowed COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2221
+ shadowContainer.shadowRoot.innerHTML = _component_.innerHTML;
2222
+ } else {
2223
+ tmp_shadowContainer.innerHTML = _component_.parseTemplate(tmp_shadowContainer.innerHTML);
2224
+ logger.debug("ADDING Shadowed COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
2225
+ shadowContainer.shadowRoot.innerHTML += _component_.innerHTML;
2166
2226
  }
2167
- resolve.call(_promise, standardResponse);
2168
- break;
2169
- case (_component.get("tplsource") === "default" &&
2170
- _component.get("templateURI") !== ""):
2171
- _component.set("url", _component.get("basePath") + _component.get("templateURI"));
2172
- componentLoader(_component, false).then(
2173
- function (standardResponse) {
2174
- resolve.call(_promise, standardResponse);
2175
- },
2176
- function (standardResponse) {
2177
- reject.call(_promise, standardResponse);
2178
- });
2179
- break;
2180
- case (_component.get("tplsource") === "external" &&
2181
- _component.get("templateURI") !== ""):
2182
- _component.set("url", _component.get("templateURI"));
2183
- componentLoader(_component, false).then(
2184
- function (standardResponse) {
2185
- resolve.call(_promise, standardResponse);
2186
- },
2187
- function (standardResponse) {
2188
- reject.call(_promise, standardResponse);
2189
- });
2190
- break;
2191
- case _component.get("tplsource") === "default" && _component.get("templateURI", "") === "":
2192
- logger.debug(`Component ${_component.name} template-source is ${_component.get("tplsource")} and no templateURI is present`);
2193
- reject.call(_promise, `Component ${_component.name} template-source is ${_component.get("tplsource")} and no templateURI is present`);
2194
- break;
2195
- default:
2196
- logger.debug("Component " + _component.name + " will not be rebuilt because no templateURI is present");
2197
- reject.call(_promise, {
2198
- request: null,
2199
- component: _component
2200
- });
2201
- break;
2227
+ logger.debug("ADDING Slots to Shadowed COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
2228
+ shadowContainer.innerHTML += tmp_shadowContainer.innerHTML;
2229
+ logger.debug("APPENDING Shadowed COMPONENT {{NAME}} to Container ".replace("{{NAME}}", _component_.name));
2230
+ if (container.subelements(".shadowHost") < 1) {
2231
+ container.appendChild(shadowContainer);
2232
+ } else {
2233
+ logger.debug("Shadowed Container for COMPONENT {{NAME}} is already present in the tree ".replace("{{NAME}}", _component_.name));
2234
+ container.removeChild(container.subelements(".shadowHost").pop());
2235
+ container.appendChild(shadowContainer);
2236
+ }
2237
+ } else {
2238
+ logger.warn("Shadowed COMPONENT {{NAME}} is bad configured".replace("{{NAME}}", _component_.name));
2239
+ }
2240
+ } else {
2241
+ if (_component_.reload) {
2242
+ logger.debug("FORCED RELOADING OF CONTAINER FOR COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
2243
+ container.innerHTML = _component_.innerHTML;
2244
+ } else if (container && _component_) {
2245
+ logger.debug("ADDING COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
2246
+ container.innerHTML += _component_.innerHTML;
2247
+ } else {
2248
+ logger.warn("COMPONENT {{NAME}} is not added to the DOM".replace("{{NAME}}", _component_.name));
2249
+ }
2202
2250
  }
2203
-
2204
- }
2205
- });
2206
- return _promise;
2207
- },
2208
- Cast(oClass) {
2209
- /* Cast method for components has been deprecated. Don't use this method, it is available only for compatibility purposes */
2210
- let o = _methods_(oClass).map(m => m.name.replace(/bound /g, "")).map(m => {
2211
- return {
2212
- [m]: oClass[m].bind(this)
2251
+
2213
2252
  };
2214
- }).reduce((c, p) => Object.assign(c, p), {});
2215
- return _Cast(this, o);
2216
- },
2217
- routingWay: null,
2218
- validRoutingWays: ["pathname", "hash", "search"],
2219
- routingNodes: [],
2220
- routings: [],
2221
- routingPath: "",
2222
- route() {
2223
- var componentClass = this;
2224
- var isValidInstance = ((!!componentClass.__instanceID) &&
2225
- Object.hasOwnProperty.call(componentClass, "subcomponents")) ? (true) : (false);
2226
- var __route__ = function (componentList) {
2227
- var _componentNames_ = [];
2228
- var _promises_ = componentList.filter(function (rc) {
2229
- return typeof rc !== "undefined";
2230
- }).map(function (rc) {
2231
- if (typeof rc.name !== "undefined") {
2232
- _componentNames_.push(rc.name);
2233
- } else {
2234
- throw new Error(__getType__(rc) + " does not have a name");
2253
+
2254
+ var _feedComponent_InNode = function (_component_) {
2255
+ var parsedAssignmentText = _component_.parsedAssignmentText;
2256
+ _component_.innerHTML = parsedAssignmentText;
2257
+ };
2258
+
2259
+ var _ret_;
2260
+ if (!is_a(_component_, "Component")) {
2261
+ logger.warn("Trying to feed a non component object");
2262
+ return;
2263
+ }
2264
+ if (isBrowser) {
2265
+ _ret_ = _feedComponent_InBrowser(_component_);
2266
+ } else {
2267
+ _ret_ = _feedComponent_InNode(_component_);
2268
+ }
2269
+ return _ret_;
2270
+ }
2271
+
2272
+ rebuild() {
2273
+ var _component = this;
2274
+ var _promise = new Promise(function (resolve, reject) {
2275
+ if (typeof _component === "undefined" || _component === null) {
2276
+ reject("Component is undefined");
2235
2277
  }
2236
- return new Promise(function (resolve, reject) {
2237
- var _promise_;
2238
- if (typeof rc !== "undefined" &&
2239
- Object.hasOwnProperty.call(rc, "_reroute_")) {
2240
- _promise_ = rc._reroute_()
2241
- .then(function () {
2242
- rc.body.innerHTML = "";
2243
- rc.innerHTML = "";
2244
- return rc.rebuild();
2245
- })
2246
- .then(function (_rc_) {
2247
- if (Object.hasOwnProperty.call(_rc_, "subcomponents") &&
2248
- typeof _rc_.subcomponents !== "undefined" &&
2249
- _rc_.subcomponents.length > 0
2250
- ) {
2251
- logger.debug("LOOKING FOR ROUTINGS IN SUBCOMPONENTS FOR: " + _rc_.name);
2252
- return __route__.call(_rc_, _rc_.subcomponents);
2253
- } else {
2254
- resolve(_rc_);
2255
- }
2278
+ if (isQCObjects_Object(_component) && is_a(_component, "Component")) {
2279
+ switch (true) {
2280
+ case (_component.get("tplsource") === "none"):
2281
+ logger.debug("Component " + _component.name + " has specified template-source=none, so no template load was done");
2282
+ var standardResponse = {
2283
+ request: null,
2284
+ component: _component
2285
+ };
2286
+ if (typeof _component.done === "function") {
2287
+ _component.done.call(_component, standardResponse);
2288
+ }
2289
+ resolve.call(_promise, standardResponse);
2290
+ break;
2291
+ case (_component.get("tplsource") === "inline"):
2292
+ logger.debug("Component " + _component.name + " has specified template-source=inline, so it is assumed that template is already declared");
2293
+ _component.feedComponent();
2294
+ var standardResponse = {
2295
+ request: null,
2296
+ component: _component
2297
+ };
2298
+ if (typeof _component.done === "function") {
2299
+ _component.done.call(_component, standardResponse);
2300
+ }
2301
+ resolve.call(_promise, standardResponse);
2302
+ break;
2303
+ case (_component.get("tplsource") === "default" &&
2304
+ _component.get("templateURI") !== ""):
2305
+ _component.set("url", _component.get("basePath") + _component.get("templateURI"));
2306
+ componentLoader(_component, false).then(
2307
+ function (standardResponse) {
2308
+ resolve.call(_promise, standardResponse);
2309
+ },
2310
+ function (standardResponse) {
2311
+ reject.call(_promise, standardResponse);
2312
+ });
2313
+ break;
2314
+ case (_component.get("tplsource") === "external" &&
2315
+ _component.get("templateURI") !== ""):
2316
+ _component.set("url", _component.get("templateURI"));
2317
+ componentLoader(_component, false).then(
2318
+ function (standardResponse) {
2319
+ resolve.call(_promise, standardResponse);
2320
+ },
2321
+ function (standardResponse) {
2322
+ reject.call(_promise, standardResponse);
2323
+ });
2324
+ break;
2325
+ case _component.get("tplsource") === "default" && _component.get("templateURI", "") === "":
2326
+ logger.debug(`Component ${_component.name} template-source is ${_component.get("tplsource")} and no templateURI is present`);
2327
+ reject.call(_promise, `Component ${_component.name} template-source is ${_component.get("tplsource")} and no templateURI is present`);
2328
+ break;
2329
+ default:
2330
+ logger.debug("Component " + _component.name + " will not be rebuilt because no templateURI is present");
2331
+ reject.call(_promise, {
2332
+ request: null,
2333
+ component: _component
2256
2334
  });
2257
- } else if (typeof rc !== "undefined") {
2258
- reject("Component " + rc.name + " is not an instance of Component");
2335
+ break;
2259
2336
  }
2260
- return _promise_;
2261
- });
2337
+
2338
+ }
2262
2339
  });
2263
- return Promise.all(_promises_)
2264
- .then(function () {
2265
- logger.debug("ROUTING COMPLETED FOR " + _componentNames_.join(", "));
2266
- }).catch(function (err) {
2267
- logger.error("ROUTING FAILED FOR " + _componentNames_.join(", ") + ": " + err);
2268
- });
2269
- };
2270
- if (isValidInstance || Object.hasOwnProperty.call(global, "componentsStack")) {
2271
- if (isValidInstance && is_a(componentClass, "Component")) {
2272
- logger.debug("loading routings for instance " + componentClass.name);
2273
- }
2274
- __route__.call(componentClass, (isValidInstance) ? (componentClass.subcomponents) : (global.componentsStack));
2275
- } else {
2276
- logger.debug("An undetermined result expected if load routings. So will not be loaded this time.");
2277
- }
2278
- },
2279
- fullscreen() {
2280
- if (isBrowser) {
2281
- var elem = this.body;
2282
- if (elem.requestFullscreen) {
2283
- elem.requestFullscreen();
2284
- } else if (elem.mozRequestFullScreen) {
2285
- /* Firefox */
2286
- elem.mozRequestFullScreen();
2287
- } else if (elem.webkitRequestFullscreen) {
2288
- /* Chrome, Safari & Opera */
2289
- elem.webkitRequestFullscreen();
2290
- } else if (elem.msRequestFullscreen) {
2291
- /* IE/Edge */
2292
- elem.msRequestFullscreen();
2293
- }
2294
- } else {
2295
- // not yet implemented.
2340
+ return _promise;
2296
2341
  }
2297
- },
2298
- closefullscreen() {
2299
- if (isBrowser) {
2300
- if (document.exitFullscreen) {
2301
- document.exitFullscreen();
2302
- } else if (document.mozCancelFullScreen) {
2303
- document.mozCancelFullScreen();
2304
- } else if (document.webkitExitFullscreen) {
2305
- document.webkitExitFullscreen();
2306
- } else if (document.msExitFullscreen) {
2307
- document.msExitFullscreen();
2308
- }
2309
- } else {
2310
- // noy yet implemented.
2342
+
2343
+ Cast(oClass) {
2344
+ /* Cast method for components has been deprecated. Don't use this method, it is available only for compatibility purposes */
2345
+ let o = _methods_(oClass).map(m => m.name.replace(/bound /g, "")).map(m => {
2346
+ return {
2347
+ [m]: oClass[m].bind(this)
2348
+ };
2349
+ }).reduce((c, p) => Object.assign(c, p), {});
2350
+ return _Cast(this, o);
2311
2351
  }
2312
- },
2313
- _generateRoutingPaths(componentBody) {
2314
- var component = this;
2315
- if (isBrowser) {
2316
- if (__valid_routing_way__(component.validRoutingWays, component.routingWay)) {
2317
- if (typeof componentBody !== "undefined") {
2318
- component.innerHTML = componentBody.innerHTML;
2319
- component.routingNodes = componentBody.subelements("routing");
2320
- component.routings = [];
2321
- component.routingNodes.map(function (routingNode, r) {
2322
- var attributeNames = routingNode.getAttributeNames();
2323
- var routing = {};
2324
- attributeNames.map(function (attributeName, a) {
2325
- routing[attributeNames[a]] = routingNode.getAttribute(attributeNames[a]);
2326
- });
2327
- component.routings.push(routing);
2328
- if (!_top.global.get("routingPaths")) {
2329
- _top.global.set("routingPaths", []);
2330
- }
2331
- if (!_top.global.get("routingPaths").includes(routing.path)) {
2332
- _top.global.get("routingPaths").push(routing.path);
2352
+
2353
+ static route() {
2354
+ var componentClass = this;
2355
+ var _route_promise_;
2356
+ var isValidInstance = ((!!componentClass.__instanceID) &&
2357
+ Object.hasOwnProperty.call(componentClass, "subcomponents")) ? (true) : (false);
2358
+ var __route__ = function (componentList) {
2359
+ var _componentNames_ = [];
2360
+ var _promises_ = componentList.filter(function (rc) {
2361
+ return typeof rc !== "undefined";
2362
+ }).map(function (rc) {
2363
+ if (typeof rc.name !== "undefined") {
2364
+ _componentNames_.push(rc.name);
2365
+ } else {
2366
+ throw new Error(__getType__(rc) + " does not have a name");
2367
+ }
2368
+ return new Promise(function (resolve, reject) {
2369
+ var _promise_;
2370
+ if (typeof rc !== "undefined" && !!rc._reroute_) {
2371
+ _promise_ = rc._reroute_()
2372
+ .then(function () {
2373
+ rc.body.innerHTML = "";
2374
+ rc.innerHTML = "";
2375
+ return rc.rebuild();
2376
+ })
2377
+ .then(function (_rc_) {
2378
+ if (Object.hasOwnProperty.call(_rc_, "subcomponents") &&
2379
+ typeof _rc_.subcomponents !== "undefined" &&
2380
+ _rc_.subcomponents.length > 0
2381
+ ) {
2382
+ logger.debug("LOOKING FOR ROUTINGS IN SUBCOMPONENTS FOR: " + _rc_.name);
2383
+ return __route__.call(_rc_, _rc_.subcomponents);
2384
+ } else {
2385
+ resolve(_rc_);
2386
+ }
2387
+ });
2388
+ } else if (typeof rc !== "undefined") {
2389
+ reject("Component " + rc.name + " is not an instance of Component");
2333
2390
  }
2391
+ return _promise_;
2334
2392
  });
2393
+ });
2394
+ return Promise.all(_promises_)
2395
+ .then(function () {
2396
+ logger.debug("ROUTING COMPLETED FOR " + _componentNames_.join(", "));
2397
+ }).catch(function (err) {
2398
+ logger.warn("ROUTING FAILED FOR " + _componentNames_.join(", ") + ": " + err);
2399
+ });
2400
+ };
2401
+ if (isValidInstance || Object.hasOwnProperty.call(global, "componentsStack")) {
2402
+ if (isValidInstance && is_a(componentClass, "Component")) {
2403
+ logger.debug("loading routings for instance " + componentClass.name);
2335
2404
  }
2405
+ _route_promise_ = __route__.call(componentClass, (isValidInstance) ? (componentClass.subcomponents) : (global.componentsStack));
2406
+ } else {
2407
+ logger.debug("An undetermined result expected if load routings. So will not be loaded this time.");
2336
2408
  }
2337
- } else {
2338
- // not yet implemented.
2339
2409
  }
2340
- },
2341
- parseTemplate(template) {
2342
- var _self = this;
2343
- var _parsedAssignmentText;
2344
- if (Object.hasOwnProperty.call(_self, "templateHandler")) {
2345
- var value = template;
2346
- var templateHandlerName = _self.templateHandler;
2347
- var templateHandlerClass = ClassFactory(_self.templateHandler);
2348
- var templateInstance = New(templateHandlerClass, {
2349
- component: _self,
2350
- template: value
2351
- });
2352
- var selfData = _self.data;
2353
- if (Object.hasOwnProperty.call(_self, "assignRoutingParams") && _self.assignRoutingParams) {
2354
- try {
2355
- selfData = Object.assign(selfData, _self.routingParams);
2356
- } catch (e) {
2357
- logger.debug("[parseTemplate] it was not possible to assign the routing params to the template");
2410
+
2411
+ fullscreen() {
2412
+ if (isBrowser) {
2413
+ var elem = this.body;
2414
+ if (elem.requestFullscreen) {
2415
+ elem.requestFullscreen();
2416
+ } else if (elem.mozRequestFullScreen) {
2417
+ /* Firefox */
2418
+ elem.mozRequestFullScreen();
2419
+ } else if (elem.webkitRequestFullscreen) {
2420
+ /* Chrome, Safari & Opera */
2421
+ elem.webkitRequestFullscreen();
2422
+ } else if (elem.msRequestFullscreen) {
2423
+ /* IE/Edge */
2424
+ elem.msRequestFullscreen();
2358
2425
  }
2426
+ } else {
2427
+ // not yet implemented.
2359
2428
  }
2360
- _parsedAssignmentText = templateInstance.assign(selfData);
2361
- } else {
2362
- _parsedAssignmentText = value;
2363
2429
  }
2364
- return _parsedAssignmentText;
2365
- },
2366
- _new_(properties) {
2367
- var self = this;
2368
-
2369
- if (typeof self.name === "undefined") {
2370
- logger.warn("A name is not defined for " + __getType__(self));
2371
- }
2372
-
2373
- self.routingWay = _top.CONFIG.get("routingWay");
2374
-
2375
- self.processorHandler = New(ClassFactory("Processor"), {
2376
- component: self
2377
- });
2378
-
2379
- Object.defineProperty(self, "body", {
2380
- configurable: true,
2381
- set(value) {
2382
- self._body = value;
2383
- self._generateRoutingPaths(value);
2384
- },
2385
- get() {
2386
- return self._body;
2387
- }
2388
- });
2389
-
2390
- Object.defineProperty(self, "cacheIndex", {
2391
- configurable: true,
2392
- set(value) {
2393
- // readonly
2394
- logger.debug("[cacheIndex] This property is readonly");
2395
- },
2396
- get() {
2397
- var __routing_path__ = _DataStringify(self.routingPath);
2398
- return Base64.encode(self.name + __routing_path__);
2399
- }
2400
- });
2401
-
2402
- Object.defineProperty(self, "parsedAssignmentText", {
2403
- configurable: true,
2404
- set(value) {
2405
- // readonly
2406
- logger.debug("[parsedAssignmentText] This property is readonly");
2407
- },
2408
- get() {
2409
- self._parsedAssignmentText = self.parseTemplate(self.template);
2410
- return self._parsedAssignmentText;
2430
+
2431
+ closefullscreen() {
2432
+ if (isBrowser) {
2433
+ if (document.exitFullscreen) {
2434
+ document.exitFullscreen();
2435
+ } else if (document.mozCancelFullScreen) {
2436
+ document.mozCancelFullScreen();
2437
+ } else if (document.webkitExitFullscreen) {
2438
+ document.webkitExitFullscreen();
2439
+ } else if (document.msExitFullscreen) {
2440
+ document.msExitFullscreen();
2441
+ }
2442
+ } else {
2443
+ // noy yet implemented.
2411
2444
  }
2412
- });
2413
-
2414
- Object.defineProperty(self, "shadowRoot", {
2415
- configurable: true,
2416
- set(value) {
2417
- if (typeof self.__shadowRoot == "undefined") {
2418
- self.__shadowRoot = value;
2445
+ }
2446
+
2447
+ _generateRoutingPaths(componentBody) {
2448
+ var component = this;
2449
+ return new Promise(function (resolve, reject){
2450
+ if (isBrowser) {
2451
+ if (__valid_routing_way__(component.validRoutingWays, component.routingWay)) {
2452
+ if (typeof componentBody !== "undefined") {
2453
+ component.innerHTML = componentBody.innerHTML;
2454
+ component.routingNodes = componentBody.subelements("routing");
2455
+ component.routings = [];
2456
+ component.routingNodes.map(function (routingNode, r) {
2457
+ var attributeNames = routingNode.getAttributeNames();
2458
+ var routing = {};
2459
+ attributeNames.map(function (attributeName, a) {
2460
+ routing[attributeNames[a]] = routingNode.getAttribute(attributeNames[a]);
2461
+ });
2462
+ component.routings.push(routing);
2463
+ if (!_top.global.get("routingPaths")) {
2464
+ _top.global.set("routingPaths", []);
2465
+ }
2466
+ if (!_top.global.get("routingPaths").includes(routing.path)) {
2467
+ _top.global.get("routingPaths").push(routing.path);
2468
+ }
2469
+ });
2470
+ }
2471
+ }
2419
2472
  } else {
2420
- logger.debug("[shadowRoot] This property can only be assigned once!");
2473
+ // not yet implemented.
2421
2474
  }
2422
- },
2423
- get() {
2424
- return self.__shadowRoot;
2425
- }
2426
- });
2427
-
2428
- Object.defineProperty(self, "routingSelected", {
2429
- configurable: true,
2430
- set(value) {
2431
- logger.debug("[routingSelected] This is a read-only property of the component");
2432
- },
2433
- get() {
2434
- return __valid_routings__(this.routings, this.routingPath);
2435
- }
2436
- });
2437
-
2438
- Object.defineProperty(self, "routingParams", {
2439
- configurable: true,
2440
- set(value) {
2441
- logger.debug("[routingParams] This is a read-only property of the component");
2442
- },
2443
- get() {
2444
- var component = this;
2445
- return [{}].concat(component.routingSelected.map(function (routing) {
2446
- return __routing_params__(routing, component.routingPath);
2447
- })).reduce(function (accumulator, colData, index) {
2448
- return Object.assign(accumulator, colData);
2475
+ resolve();
2476
+
2477
+ });
2478
+ }
2479
+
2480
+ parseTemplate(template) {
2481
+ var _self = this;
2482
+ var _parsedAssignmentText;
2483
+ var value = template;
2484
+ if (Object.hasOwnProperty.call(_self, "templateHandler")) {
2485
+ var templateHandlerName = _self.templateHandler;
2486
+ logger.debug(`[Component][${this.name}][parseTemplate] Attempting to use ${templateHandlerName} ...`);
2487
+ var templateHandlerClass = ClassFactory(templateHandlerName);
2488
+ var templateInstance = New(templateHandlerClass, {
2489
+ component: _self,
2490
+ template: value
2449
2491
  });
2492
+ var selfData = _self.data;
2493
+ if (Object.hasOwnProperty.call(_self, "assignRoutingParams") && _self.assignRoutingParams) {
2494
+ try {
2495
+ selfData = Object.assign(selfData, _self.routingParams);
2496
+ } catch (e) {
2497
+ logger.debug("[parseTemplate] it was not possible to assign the routing params to the template");
2498
+ }
2499
+ }
2500
+ _parsedAssignmentText = templateInstance.assign(selfData);
2501
+ } else {
2502
+ logger.debug(`[Component][${this.name}][parseTemplate] No value for templateHandler. Using raw content...`);
2503
+ _parsedAssignmentText = value;
2450
2504
  }
2451
- });
2452
-
2453
- if (typeof self.__new__ === "function") {
2454
- self.__new__.call(self, properties);
2505
+ return _parsedAssignmentText;
2455
2506
  }
2456
-
2457
- self._reroute_()
2458
- .then(function () {
2459
- return self.rebuild()
2460
- .then(function () {
2461
- logger.info(`Component._new_ The component ${self.name} was built successfully!`);
2462
- }).catch(function (standardResponse) {
2463
- logger.warn(`Component._new_ Something went wrong building the component ${self.name}`);
2464
- console.error(standardResponse);
2465
- });
2507
+
2508
+ _reroute_() {
2509
+ /* This method set the selected routing and makes the switch to the templateURI */
2510
+ var rc = this;
2511
+ return new Promise(function (resolve, reject) {
2512
+ if (isBrowser) {
2513
+ if (__valid_routing_way__(rc.validRoutingWays, rc.routingWay)) {
2514
+ rc.routingPath = document.location[rc.routingWay];
2515
+ rc.routingSelected.map(function (routing, r) {
2516
+ var componentURI = ComponentURI({
2517
+ "COMPONENTS_BASE_PATH": _top.CONFIG.get("componentsBasePath"),
2518
+ "COMPONENT_NAME": routing.name.toString(),
2519
+ "TPLEXTENSION": (Object.hasOwnProperty.call(routing, "tplextension")) ? (routing.tplextension) : (rc.tplextension),
2520
+ "TPL_SOURCE": "default" /* here is always default in order to get the right uri */
2521
+ });
2522
+ rc.templateURI = componentURI;
2523
+ });
2524
+ if (rc.routingSelected.length > 0) {
2525
+ rc.template = "";
2526
+ rc.body.innerHTML = "";
2527
+ }
2528
+ }
2529
+ }
2530
+ resolve(rc);
2531
+
2466
2532
  });
2467
-
2468
- },
2469
- _reroute_() {
2470
- /* This method set the selected routing and makes the switch to the templateURI */
2471
- var rc = this;
2472
- return new Promise(function (resolve, reject) {
2533
+ }
2534
+
2535
+ lazyLoadImages() {
2473
2536
  if (isBrowser) {
2474
- if (__valid_routing_way__(rc.validRoutingWays, rc.routingWay)) {
2475
- rc.routingPath = document.location[rc.routingWay];
2476
- rc.routingSelected.map(function (routing, r) {
2477
- var componentURI = ComponentURI({
2478
- "COMPONENTS_BASE_PATH": _top.CONFIG.get("componentsBasePath"),
2479
- "COMPONENT_NAME": routing.name.toString(),
2480
- "TPLEXTENSION": (Object.hasOwnProperty.call(routing, "tplextension")) ? (routing.tplextension) : (rc.tplextension),
2481
- "TPL_SOURCE": "default" /* here is always default in order to get the right uri */
2537
+ var component = this;
2538
+ var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2539
+ var _imgLazyLoaded = [..._componentRoot.subelements("img[lazy-src]")];
2540
+ var _lazyLoadImages = function (image) {
2541
+ image.setAttribute("src", image.getAttribute("lazy-src"));
2542
+ image.onload = () => {
2543
+ image.removeAttribute("lazy-src");
2544
+ };
2545
+ };
2546
+ if ("IntersectionObserver" in window) {
2547
+ var observer = new IntersectionObserver((items, observer) => {
2548
+ items.forEach((item) => {
2549
+ if (item.isIntersecting) {
2550
+ _lazyLoadImages(item.target);
2551
+ observer.unobserve(item.target);
2552
+ }
2482
2553
  });
2483
- rc.templateURI = componentURI;
2484
2554
  });
2485
- if (rc.routingSelected.length > 0) {
2486
- rc.template = "";
2487
- rc.body.innerHTML = "";
2488
- }
2555
+ _imgLazyLoaded.map(function (img) {
2556
+ return observer.observe(img);
2557
+ });
2558
+ } else {
2559
+ _imgLazyLoaded.map(_lazyLoadImages);
2489
2560
  }
2561
+
2562
+ } else {
2563
+ // not yet implemented
2490
2564
  }
2491
- resolve(rc);
2492
-
2493
- });
2494
- },
2495
- lazyLoadImages() {
2496
- if (isBrowser) {
2497
- var component = this;
2498
- var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2499
- var _imgLazyLoaded = [..._componentRoot.subelements("img[lazy-src]")];
2500
- var _lazyLoadImages = function (image) {
2501
- image.setAttribute("src", image.getAttribute("lazy-src"));
2502
- image.onload = () => {
2503
- image.removeAttribute("lazy-src");
2504
- };
2505
- };
2506
- if ("IntersectionObserver" in window) {
2507
- var observer = new IntersectionObserver((items, observer) => {
2508
- items.forEach((item) => {
2509
- if (item.isIntersecting) {
2510
- _lazyLoadImages(item.target);
2511
- observer.unobserve(item.target);
2512
- }
2513
- });
2514
- });
2515
- _imgLazyLoaded.map(function (img) {
2516
- return observer.observe(img);
2565
+ return null;
2566
+ }
2567
+
2568
+ applyTransitionEffect(effectClassName) {
2569
+ var _Effect = ClassFactory(effectClassName);
2570
+ if (typeof _Effect !== "undefined" && is_a(_Effect, "TransitionEffect")) {
2571
+ this.effect = New(_Effect, {
2572
+ component: this
2517
2573
  });
2574
+ this.effect.apply(this.effect.defaultParams);
2518
2575
  } else {
2519
- _imgLazyLoaded.map(_lazyLoadImages);
2576
+ logger.debug(`${__getType__(_Effect)} is not a TransitionEffect`);
2520
2577
  }
2521
-
2522
- } else {
2523
- // not yet implemented
2524
2578
  }
2525
- return null;
2526
- },
2527
- applyTransitionEffect(effectClassName) {
2528
- var _Effect = ClassFactory(effectClassName);
2529
- if (typeof _Effect !== "undefined" && is_a(_Effect, "TransitionEffect")) {
2530
- this.effect = New(_Effect, {
2531
- component: this
2532
- });
2533
- this.effect.apply(this.effect.defaultParams);
2534
- } else {
2535
- logger.debug(`${__getType__(_Effect)} is not a TransitionEffect`);
2536
- }
2537
- },
2538
- applyObserveTransitionEffect(effectClassName) {
2539
- if (isBrowser) {
2540
- var component = this;
2541
- var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2542
- var _applyEffect_ = function (element) {
2543
- component.applyTransitionEffect(effectClassName);
2544
- };
2545
- if ("IntersectionObserver" in window) {
2546
- var observer = new IntersectionObserver((items, observer) => {
2547
- items.forEach((item) => {
2548
- if (item.isIntersecting) {
2549
- _applyEffect_(item.target);
2550
- observer.unobserve(item.target);
2551
- }
2579
+
2580
+ applyObserveTransitionEffect(effectClassName) {
2581
+ if (isBrowser) {
2582
+ var component = this;
2583
+ var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2584
+ var _applyEffect_ = function (element) {
2585
+ component.applyTransitionEffect(effectClassName);
2586
+ };
2587
+ if ("IntersectionObserver" in window) {
2588
+ var observer = new IntersectionObserver((items, observer) => {
2589
+ items.forEach((item) => {
2590
+ if (item.isIntersecting) {
2591
+ _applyEffect_(item.target);
2592
+ observer.unobserve(item.target);
2593
+ }
2594
+ });
2552
2595
  });
2553
- });
2554
- observer.observe(_componentRoot);
2596
+ observer.observe(_componentRoot);
2597
+ } else {
2598
+ _applyEffect_(_componentRoot);
2599
+ }
2555
2600
  } else {
2556
- _applyEffect_(_componentRoot);
2601
+ // not yet implemented
2557
2602
  }
2558
- } else {
2559
- // not yet implemented
2603
+ return null;
2560
2604
  }
2561
- return null;
2562
- },
2563
- scrollIntoHash() {
2564
- if (isBrowser) {
2565
- var component = this;
2566
- if (document.location.hash !== "") {
2567
- var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2568
- _componentRoot.subelements(document.location.hash).map(
2569
- function (element) {
2570
- if (typeof element.scrollIntoView === "function") {
2571
- element.scrollIntoView(
2572
- _top.CONFIG.get("scrollIntoHash", {
2573
- behavior: "auto",
2574
- block: "top",
2575
- inline: "top"
2576
- })
2577
- );
2605
+
2606
+ scrollIntoHash() {
2607
+ if (isBrowser) {
2608
+ var component = this;
2609
+ if (document.location.hash !== "") {
2610
+ var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2611
+ _componentRoot.subelements(document.location.hash).map(
2612
+ function (element) {
2613
+ if (typeof element.scrollIntoView === "function") {
2614
+ element.scrollIntoView(
2615
+ _top.CONFIG.get("scrollIntoHash", {
2616
+ behavior: "auto",
2617
+ block: "top",
2618
+ inline: "top"
2619
+ })
2620
+ );
2621
+ }
2578
2622
  }
2579
- }
2580
- );
2623
+ );
2624
+ }
2625
+ } else {
2626
+ // not yet implemented
2581
2627
  }
2582
- } else {
2583
- // not yet implemented
2584
2628
  }
2585
- },
2586
- i18n_translate() {
2587
- if (isBrowser) {
2588
- if (_top.CONFIG.get("use_i18n")) {
2589
- var component = this;
2590
- var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2591
- var lang1 = _top.CONFIG.get("lang", "en");
2592
- var lang2 = navigator.language.slice(0, 2);
2593
- var i18n = _top.global.get("i18n");
2594
- if ((lang1 !== lang2) && (typeof i18n === "object" && Object.hasOwnProperty.call(i18n, "messages"))) {
2595
- var callback_i18n = function () {
2596
- var component = this;
2597
- return new Promise(function (resolve, reject) {
2598
- var messages = i18n.messages.filter(function (message) {
2599
- return Object.hasOwnProperty.call(message, lang1) && Object.hasOwnProperty.call(message, lang2);
2600
- });
2601
- _componentRoot.subelements("ul,li,h1,h2,h3,a,b,p,input,textarea,summary,details,option,component")
2602
- .map(function (element) {
2603
- messages.map(function (message) {
2604
- var _innerHTML = element.innerHTML;
2605
- _innerHTML = _innerHTML.replace(new RegExp(`${message[lang1]}`, "g"), message[lang2]);
2606
- element.innerHTML = _innerHTML;
2607
- return null;
2608
- });
2609
- return element;
2629
+
2630
+ i18n_translate() {
2631
+ if (isBrowser) {
2632
+ if (_top.CONFIG.get("use_i18n")) {
2633
+ var component = this;
2634
+ var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
2635
+ var lang1 = _top.CONFIG.get("lang", "en");
2636
+ var lang2 = navigator.language.slice(0, 2);
2637
+ var i18n = _top.global.get("i18n");
2638
+ if ((lang1 !== lang2) && (typeof i18n === "object" && Object.hasOwnProperty.call(i18n, "messages"))) {
2639
+ var callback_i18n = function () {
2640
+ var component = this;
2641
+ return new Promise(function (resolve, reject) {
2642
+ var messages = i18n.messages.filter(function (message) {
2643
+ return Object.hasOwnProperty.call(message, lang1) && Object.hasOwnProperty.call(message, lang2);
2610
2644
  });
2611
- resolve();
2645
+ _componentRoot.subelements("ul,li,h1,h2,h3,a,b,p,input,textarea,summary,details,option,component")
2646
+ .map(function (element) {
2647
+ messages.map(function (message) {
2648
+ var _innerHTML = element.innerHTML;
2649
+ _innerHTML = _innerHTML.replace(new RegExp(`${message[lang1]}`, "g"), message[lang2]);
2650
+ element.innerHTML = _innerHTML;
2651
+ return null;
2652
+ });
2653
+ return element;
2654
+ });
2655
+ resolve();
2656
+ });
2657
+ };
2658
+ callback_i18n.call(component).then(function () {
2659
+ logger.debug("i18n loaded for component: " + component.name);
2612
2660
  });
2613
- };
2614
- callback_i18n.call(component).then(function () {
2615
- logger.debug("i18n loaded for component: " + component.name);
2616
- });
2617
-
2661
+
2662
+ }
2618
2663
  }
2664
+ } else {
2665
+ // not yet implemented
2619
2666
  }
2620
- } else {
2621
- // not yet implemented
2622
2667
  }
2623
- },
2624
- _componentHelpers: [],
2625
- addComponentHelper(componentHelper) {
2626
- var component = this;
2627
- component._componentHelpers.push(componentHelper);
2628
- },
2629
- runComponentHelpers() {
2630
- if (isBrowser) {
2668
+
2669
+ addComponentHelper(componentHelper) {
2631
2670
  var component = this;
2632
- var __component_helpers__ = [];
2633
- /*
2634
- * BEGIN use i18n translation
2635
- */
2636
- __component_helpers__.push(component.i18n_translate.bind(component));
2637
- /*
2638
- * END use i18n translation
2639
- */
2640
-
2641
- /*
2642
- * BEGIN component scrollIntoHash
2643
- */
2644
- __component_helpers__.push(component.scrollIntoHash.bind(component));
2645
- /*
2646
- * END component scrollIntoHash
2647
- */
2648
-
2649
- /*
2650
- * BEGIN component images lazy-load
2651
- */
2652
-
2653
- __component_helpers__.push(component.lazyLoadImages.bind(component));
2654
-
2655
- /*
2656
- * END component images lazy-load
2657
- */
2658
-
2659
- __component_helpers__ = __component_helpers__.concat(component._componentHelpers);
2660
-
2661
- __component_helpers__.map(
2662
- function (_component_helper_) {
2663
- _component_helper_();
2664
- }
2665
- );
2666
-
2667
- } else {
2668
- // not yet implemented
2671
+ component._componentHelpers.push(componentHelper);
2669
2672
  }
2670
-
2673
+
2674
+ runComponentHelpers() {
2675
+ if (isBrowser) {
2676
+ var component = this;
2677
+ var __component_helpers__ = [];
2678
+ /*
2679
+ * BEGIN use i18n translation
2680
+ */
2681
+ __component_helpers__.push(component.i18n_translate.bind(component));
2682
+ /*
2683
+ * END use i18n translation
2684
+ */
2685
+
2686
+ /*
2687
+ * BEGIN component scrollIntoHash
2688
+ */
2689
+ __component_helpers__.push(component.scrollIntoHash.bind(component));
2690
+ /*
2691
+ * END component scrollIntoHash
2692
+ */
2693
+
2694
+ /*
2695
+ * BEGIN component images lazy-load
2696
+ */
2697
+
2698
+ __component_helpers__.push(component.lazyLoadImages.bind(component));
2699
+
2700
+ /*
2701
+ * END component images lazy-load
2702
+ */
2703
+
2704
+ __component_helpers__ = __component_helpers__.concat(component._componentHelpers);
2705
+
2706
+ __component_helpers__.map(
2707
+ function (_component_helper_) {
2708
+ logger.debug(`Executing ${_component_helper_.name} as component helper for ${component.name}...`);
2709
+ _component_helper_();
2710
+ }
2711
+ );
2712
+
2713
+ } else {
2714
+ // not yet implemented
2715
+ }
2716
+
2717
+ }
2718
+
2671
2719
  }
2672
- });
2720
+
2721
+ ]);
2673
2722
 
2674
2723
  _top._bindroute_.__assigned = false;
2675
2724
 
@@ -2677,122 +2726,171 @@
2677
2726
  (_protected_code_)(__c__);
2678
2727
  });
2679
2728
 
2680
- Class("Controller", ClassFactory("InheritClass"), {
2681
- dependencies: [],
2682
- component: null,
2683
- routingSelectedAttr(attrName) {
2684
- return this.component.routingSelected.map(function (r) {
2685
- return r[attrName];
2686
- }).filter(function (v) {
2687
- return v;
2688
- }).pop();
2689
- },
2690
- isTouchable() {
2691
- return ("ontouchstart" in window) ||
2692
- (navigator.MaxTouchPoints > 0) ||
2693
- (navigator.msMaxTouchPoints > 0);
2694
- },
2695
- onpress(subelementSelector, handler) {
2696
- try {
2697
- if (this.isTouchable()) {
2698
- this.component.body.subelements(subelementSelector)[0].addEventListener("touchstart", handler, {
2699
- passive: true
2700
- });
2701
- } else {
2702
- this.component.body.subelements(subelementSelector)[0].addEventListener("click", handler, {
2703
- passive: true
2704
- });
2729
+ Package("com.qcobjects.controllers", [
2730
+ class Controller extends ClassFactory("InheritClass") {
2731
+ constructor ({
2732
+ component= null,
2733
+ dependencies = []
2734
+ }){
2735
+ super (...arguments);
2736
+ if (typeof this.component === "undefined" || this.component === "null"){
2737
+ throw Error (`${__getType__(this)} must be called with a component`);
2705
2738
  }
2706
- } catch (e) {
2707
- logger.debug("No button to assign press event");
2708
2739
  }
2709
- },
2710
- createRoutingController() {
2711
- var controller = this;
2712
- var component = controller.component;
2713
- var controllerName = controller.routingSelectedAttr("controllerclass");
2714
- if (typeof controllerName !== "undefined") {
2715
- var _Controller = ClassFactory(controllerName);
2716
- if (typeof _Controller !== "undefined") {
2717
- component.routingController = New(_Controller, {
2718
- component: component
2719
- }); // Initializes the main controller for the component
2720
- if (Object.hasOwnProperty.call(component.routingController, "done") && typeof component.routingController.done === "function") {
2721
- component.routingController.done.call(component.routingController);
2740
+
2741
+ routingSelectedAttr(attrName) {
2742
+ return this.component.routingSelected.map(function (r) {
2743
+ return r[attrName];
2744
+ }).filter(function (v) {
2745
+ return v;
2746
+ }).pop();
2747
+ }
2748
+
2749
+ isTouchable() {
2750
+ return ("ontouchstart" in window) ||
2751
+ (navigator.MaxTouchPoints > 0) ||
2752
+ (navigator.msMaxTouchPoints > 0);
2753
+ }
2754
+
2755
+ onpress(subelementSelector, handler) {
2756
+ try {
2757
+ if (this.isTouchable()) {
2758
+ this.component.body.subelements(subelementSelector)[0].addEventListener("touchstart", handler, {
2759
+ passive: true
2760
+ });
2761
+ } else {
2762
+ this.component.body.subelements(subelementSelector)[0].addEventListener("click", handler, {
2763
+ passive: true
2764
+ });
2722
2765
  }
2766
+ } catch (e) {
2767
+ logger.debug("No button to assign press event");
2723
2768
  }
2724
2769
  }
2725
- }
2726
- });
2727
2770
 
2728
- Class("View", ClassFactory("InheritClass"), {
2729
- dependencies: [],
2730
- component: null
2731
- });
2771
+ createRoutingController() {
2772
+ var controller = this;
2773
+ var component = controller.component;
2774
+ var controllerName = controller.routingSelectedAttr("controllerclass");
2775
+ if (typeof controllerName !== "undefined") {
2776
+ var _Controller = ClassFactory(controllerName);
2777
+ if (typeof _Controller !== "undefined") {
2778
+ component.routingController = New(_Controller, {
2779
+ component: component
2780
+ }); // Initializes the main controller for the component
2781
+ if (Object.hasOwnProperty.call(component.routingController, "done") && typeof component.routingController.done === "function") {
2782
+ component.routingController.done.call(component.routingController);
2783
+ }
2784
+ }
2785
+ }
2786
+ }
2732
2787
 
2733
- Class("Service", ClassFactory("InheritClass"), {
2734
- kind: "rest",
2735
- /* it can be rest, mockup, local */
2736
- domain: domain,
2737
- basePath: basePath,
2738
- url: "",
2739
- method: "GET",
2740
- data: {},
2741
- reload: false,
2742
- cached: false,
2743
- set(name, value) {
2744
- this[name] = value;
2745
- },
2746
- get(name) {
2747
- return this[name];
2788
+ done(){}
2748
2789
  }
2749
- });
2790
+ ]);
2791
+
2792
+ Package("com.qcobjects.views",[
2793
+ class View extends ClassFactory("InheritClass") {
2794
+ constructor ({component = undefined, dependencies = []}){
2795
+ super(...arguments);
2796
+ if (typeof this.component === "undefined" || this.component === "null"){
2797
+ throw Error (`${__getType__(this)} must be called with a component`);
2798
+ }
2750
2799
 
2751
- Class("JSONService", ClassFactory("Service"), {
2752
- method: "GET",
2753
- cached: false,
2754
- headers: {
2755
- "Content-Type": "application/json",
2756
- "charset": "utf-8"
2757
- },
2758
- JSONresponse: null,
2759
- done(result) {
2760
- logger.debug("***** RECEIVED RESPONSE:");
2761
- logger.debug(result.service.template);
2762
- this.JSONresponse = JSON.parse(result.service.template);
2800
+ }
2763
2801
  }
2764
- });
2802
+ ]);
2803
+
2804
+ Package("com.qcobjects.api", [
2805
+ class Service extends ClassFactory("InheritClass") {
2806
+ kind= "rest";
2807
+ /* it can be rest, mockup, local */
2808
+ domain= _domain_;
2809
+ basePath= _basePath_;
2810
+ url= "";
2811
+ method= "GET";
2812
+ data= {};
2813
+ reload= false;
2814
+ cached= false;
2815
+
2816
+ constructor () {
2817
+ super(...arguments);
2818
+ }
2765
2819
 
2766
- Class("ConfigService", ClassFactory("JSONService"), {
2767
- method: "GET",
2768
- cached: false,
2769
- configFileName: "config.json",
2770
- headers: {
2771
- "Content-Type": "application/json",
2772
- "charset": "utf-8"
2773
- },
2774
- JSONresponse: null,
2775
- done(result) {
2776
- logger.debug("***** CONFIG LOADED:");
2777
- logger.debug(result.service.template);
2778
- this.JSONresponse = JSON.parse(result.service.template);
2779
- if (Object.hasOwnProperty.call(this.JSONresponse, "__encoded__")) {
2780
- this.JSONresponse = JSON.parse(ClassFactory("_Crypt").decrypt(this.JSONresponse.__encoded__, _secretKey));
2820
+ set(name, value) {
2821
+ this[name] = value;
2781
2822
  }
2782
- for (var k in this.JSONresponse) {
2783
- _top.CONFIG.set(k, this.JSONresponse[k]);
2823
+
2824
+ get(name) {
2825
+ return this[name];
2784
2826
  }
2785
- this.configLoaded.call(this);
2786
- },
2787
- fail(result) {
2788
- this.configLoaded.call(this);
2789
- },
2790
- _new_(o) {
2791
- this.set("url", this.get("basePath") + this.get("configFileName"));
2827
+
2792
2828
  }
2793
- });
2794
2829
 
2795
- Class("VO", ClassFactory("InheritClass"), {});
2830
+ ]);
2831
+
2832
+ Package("com.qcobjects.api.services", [
2833
+ class JSONService extends ClassFactory("Service") {
2834
+ method= "GET";
2835
+ cached= false;
2836
+ headers= {
2837
+ "Content-Type": "application/json",
2838
+ "charset": "utf-8"
2839
+ };
2840
+ JSONresponse= null;
2841
+ done(result) {
2842
+ logger.debug("***** RECEIVED RESPONSE:");
2843
+ logger.debug(result.service.template);
2844
+ this.JSONresponse = JSON.parse(result.service.template);
2845
+ }
2846
+
2847
+ constructor (){
2848
+ super(...arguments);
2849
+ }
2850
+
2851
+ }
2852
+ ]);
2853
+
2854
+ Package("com.qcobjects.api.config", [
2855
+ class ConfigService extends ClassFactory("JSONService"){
2856
+ method= "GET";
2857
+ cached= false;
2858
+ configFileName= "config.json";
2859
+ headers= {
2860
+ "Content-Type": "application/json",
2861
+ "charset": "utf-8"
2862
+ };
2863
+ JSONresponse= null;
2864
+ done(result) {
2865
+ logger.debug("***** CONFIG LOADED:");
2866
+ logger.debug(result.service.template);
2867
+ this.JSONresponse = JSON.parse(result.service.template);
2868
+ if (Object.hasOwnProperty.call(this.JSONresponse, "__encoded__")) {
2869
+ this.JSONresponse = JSON.parse(ClassFactory("_Crypt").decrypt(this.JSONresponse.__encoded__, _secretKey));
2870
+ }
2871
+ for (var k in this.JSONresponse) {
2872
+ _top.CONFIG.set(k, this.JSONresponse[k]);
2873
+ }
2874
+ this.configLoaded.call(this);
2875
+ }
2876
+ fail(result) {
2877
+ this.configLoaded.call(this);
2878
+ }
2879
+
2880
+ constructor (){
2881
+ super(...arguments);
2882
+ this.set("url", this.get("basePath") + this.get("configFileName"));
2883
+ }
2884
+ }
2885
+ ]);
2886
+
2887
+ Package("com.qcobjects.valueObjects", [
2888
+ class VO extends ClassFactory("InheritClass") {
2889
+ constructor (){
2890
+ super(...arguments);
2891
+ }
2892
+ }
2893
+ ]);
2796
2894
 
2797
2895
  /**
2798
2896
  * Returns a standarized uri for a component
@@ -2820,8 +2918,9 @@
2820
2918
  * @param component a Component object
2821
2919
  */
2822
2920
  var componentLoader = function (component, _async) {
2921
+ var __promise__;
2823
2922
  var _componentLoaderInBrowser = function (component, _async) {
2824
- component.__promise__ = new Promise(function (resolve, reject) {
2923
+ __promise__ = new Promise(function (resolve, reject) {
2825
2924
  var _promise = component.__promise__;
2826
2925
  var container = (Object.hasOwnProperty.call(component, "container") && typeof component.container !== "undefined" && component.container !== null) ? (component.container) : (component.body);
2827
2926
  if (container !== null) {
@@ -2928,13 +3027,11 @@
2928
3027
  }
2929
3028
 
2930
3029
  }
2931
-
2932
- return;
2933
3030
  } else {
2934
3031
  logger.debug("CONTAINER DOESNT EXIST");
2935
3032
  }
2936
3033
  });
2937
- component.__promise__.then(function (standardResponse) {
3034
+ __promise__.then(function (standardResponse) {
2938
3035
  var _ret_;
2939
3036
  if (typeof component.done === "function") {
2940
3037
  _ret_ = component.done.call(component, standardResponse);
@@ -2949,11 +3046,11 @@
2949
3046
  }).catch(function (e) {
2950
3047
  logger.debug("Something wrong loading the component");
2951
3048
  });
2952
- return component.__promise__;
3049
+ return __promise__;
2953
3050
  };
2954
3051
  var _componentLoaderInNode = function (component, _async) {
2955
- component.__promise__ = new Promise(function (resolve, reject) {
2956
- var _promise = component.__promise__;
3052
+ __promise__ = new Promise(function (resolve, reject) {
3053
+ var _promise = __promise__;
2957
3054
  var _feedComponent_ = function (component) {
2958
3055
  component.feedComponent();
2959
3056
  var standardResponse = {
@@ -3017,8 +3114,6 @@
3017
3114
  }
3018
3115
 
3019
3116
  }
3020
-
3021
- return;
3022
3117
  });
3023
3118
  component.__promise__.then(function (standardResponse) {
3024
3119
  var _ret_;
@@ -3399,11 +3494,15 @@
3399
3494
  _component_.controller = New(_Controller, {
3400
3495
  component: _component_
3401
3496
  }); // Initializes the main controller for the component
3402
- if (Object.hasOwnProperty.call(_component_.controller, "done") && typeof _component_.controller.done === "function") {
3497
+ if (typeof _component_.controller.done === "function") {
3403
3498
  _component_.controller.done.call(_component_.controller);
3499
+ } else {
3500
+ logger.debug(`${controllerName} does not have a done() method.`);
3404
3501
  }
3405
- if (Object.hasOwnProperty.call(_component_.controller, "createRoutingController")) {
3502
+ if (typeof _component_.controller.createRoutingController === "function") {
3406
3503
  _component_.controller.createRoutingController.call(_component_.controller);
3504
+ } else {
3505
+ logger.debug(`${controllerName} does not have a createRoutingController() method.`);
3407
3506
  }
3408
3507
  }
3409
3508
  var effectClassName = _component_.body.getAttribute("effectClass");
@@ -3425,7 +3524,14 @@
3425
3524
  }
3426
3525
  _component_.body.setAttribute("loaded", true);
3427
3526
 
3428
- _component_.runComponentHelpers();
3527
+ logger.debug(`Trying to run component helpers for ${_component_.name}...`);
3528
+ try {
3529
+ _component_.runComponentHelpers();
3530
+ logger.debug(`Component helpers for ${_component_.name} executed.`);
3531
+ } catch (e){
3532
+ logger.debug(`Component helpers for ${_component_.name} could not be executed.`);
3533
+ throw Error(e);
3534
+ }
3429
3535
 
3430
3536
  if ((Tag("component[loaded=true]").length * 100 / Tag("component").length) >= 100) {
3431
3537
  d.dispatchEvent(new CustomEvent("componentsloaded", {
@@ -3579,7 +3685,7 @@
3579
3685
  HTMLElement.prototype.buildComponents = Element.prototype.buildComponents;
3580
3686
  var _ComponentWidget_ = class extends HTMLElement {
3581
3687
  constructor() {
3582
- super();
3688
+ super(...arguments);
3583
3689
  const componentWidget = this;
3584
3690
  const componentName = componentWidget.nodeName.toLowerCase();
3585
3691
  const componentBody = _DOMCreateElement("component");
@@ -3635,151 +3741,174 @@
3635
3741
 
3636
3742
  if (!isBrowser) {
3637
3743
 
3638
- Class("BackendMicroservice", Object, {
3639
- domain: domain,
3640
- basePath: basePath,
3641
- body: null,
3642
- stream: null,
3643
- request: null,
3644
- cors() {
3645
- if (this.route.cors) {
3646
- let {
3647
- allow_origins,
3648
- allow_credentials,
3649
- allow_methods,
3650
- allow_headers
3651
- } = this.route.cors;
3652
- var microservice = this;
3653
- if (typeof microservice.headers !== "object") {
3654
- microservice.headers = {};
3655
- }
3656
- if (typeof allow_origins !== "undefined") {
3657
- // an example of allow_origins is ['https://example.com','http://www.example.com']
3658
- if (allow_origins === "*" || (typeof microservice.request.headers.origin === "undefined") || [...allow_origins].indexOf(microservice.request.headers.origin) !== -1) {
3659
- // for compatibility with all browsers allways return a wildcard when the origin is allowed
3660
- microservice.headers["Access-Control-Allow-Origin"] = "*";
3661
- } else {
3662
- logger.debug("Origin is not allowed: " + microservice.request.headers.origin);
3663
- logger.debug("Forcing to finish the response...");
3664
- this.body = {};
3665
- try {
3666
- this.done();
3667
- } catch (e) {}
3744
+ Package("com.qcobjects.api", [
3745
+ class BackendMicroservice extends ClassFactory("InheritClass") {
3746
+
3747
+ constructor ({
3748
+ domain= _domain_,
3749
+ basePath= _basePath_,
3750
+ body= null,
3751
+ stream= null,
3752
+ request= null
3753
+ }){
3754
+ super(...arguments);
3755
+
3756
+ var o = this;
3757
+
3758
+ logger.debug("Executing BackendMicroservice ");
3759
+ let microservice = this;
3760
+ microservice.body = null;
3761
+ this.cors();
3762
+ microservice.stream = stream;
3763
+ stream.on("data", (data) => {
3764
+ // data from POST, GET
3765
+ var requestMethod = request.method.toLowerCase();
3766
+ var supportedMethods = {
3767
+ "post": microservice.post,
3768
+ };
3769
+ if (Object.hasOwnProperty.call(supportedMethods, requestMethod)) {
3770
+ supportedMethods[requestMethod].call(microservice, data);
3668
3771
  }
3669
- } else {
3670
- microservice.headers["Access-Control-Allow-Origin"] = "*";
3671
- }
3672
- if (typeof allow_credentials !== "undefined") {
3673
- microservice.headers["Access-Control-Allow-Credentials"] = allow_credentials.toString();
3674
- } else {
3675
- microservice.headers["Access-Control-Allow-Credentials"] = "true";
3676
- }
3677
- if (typeof allow_methods !== "undefined") {
3678
- microservice.headers["Access-Control-Allow-Methods"] = [...allow_methods].join(",");
3679
- } else {
3680
- microservice.headers["Access-Control-Allow-Methods"] = "GET, OPTIONS, POST";
3681
- }
3682
- if (typeof allow_headers !== "undefined") {
3683
- microservice.headers["Access-Control-Allow-Headers"] = [...allow_headers].join(",");
3684
- } else {
3685
- microservice.headers["Access-Control-Allow-Headers"] = "*";
3686
- }
3687
- }
3688
- },
3689
- _new_(o) {
3690
- logger.debug("Executing BackendMicroservice ");
3691
- let microservice = this;
3692
- microservice.body = null;
3693
- let request = microservice.request;
3694
- this.cors();
3695
- let stream = o.stream;
3696
- microservice.stream = stream;
3697
- stream.on("data", (data) => {
3772
+ });
3773
+
3698
3774
  // data from POST, GET
3699
3775
  var requestMethod = request.method.toLowerCase();
3700
3776
  var supportedMethods = {
3701
- "post": microservice.post,
3777
+ "get": microservice.get,
3778
+ "head": microservice.head,
3779
+ "put": microservice.put,
3780
+ "delete": microservice.delete,
3781
+ "connect": microservice.connect,
3782
+ "options": microservice.options,
3783
+ "trace": microservice.trace,
3784
+ "patch": microservice.patch
3702
3785
  };
3703
3786
  if (Object.hasOwnProperty.call(supportedMethods, requestMethod)) {
3704
- supportedMethods[requestMethod].call(microservice, data);
3787
+ supportedMethods[requestMethod].call(microservice);
3705
3788
  }
3706
- });
3707
-
3708
- // data from POST, GET
3709
- var requestMethod = request.method.toLowerCase();
3710
- var supportedMethods = {
3711
- "get": microservice.get,
3712
- "head": microservice.head,
3713
- "put": microservice.put,
3714
- "delete": microservice.delete,
3715
- "connect": microservice.connect,
3716
- "options": microservice.options,
3717
- "trace": microservice.trace,
3718
- "patch": microservice.patch
3719
- };
3720
- if (Object.hasOwnProperty.call(supportedMethods, requestMethod)) {
3721
- supportedMethods[requestMethod].call(microservice);
3789
+
3790
+
3722
3791
  }
3723
-
3724
- },
3725
- head(formData) {
3726
- this.done();
3727
- },
3728
- get(formData) {
3729
- this.done();
3730
- },
3731
- post(formData) {
3732
- this.done();
3733
- },
3734
- put(formData) {
3735
- this.done();
3736
- },
3737
- delete(formData) {
3738
- this.done();
3739
- },
3740
- connect(formData) {
3741
- this.done();
3742
- },
3743
- options(formData) {
3744
- this.done();
3745
- },
3746
- trace(formData) {
3747
- this.done();
3748
- },
3749
- patch(formData) {
3750
- this.done();
3751
- },
3752
- finishWithBody(stream) {
3753
- try {
3754
- stream.write(_DataStringify(this.body));
3755
- stream.end();
3756
- } catch (e) {
3757
- logger.debug("Something wrong writing the response for microservice" + e.toString());
3792
+
3793
+ cors() {
3794
+ if (this.route.cors) {
3795
+ let {
3796
+ allow_origins,
3797
+ allow_credentials,
3798
+ allow_methods,
3799
+ allow_headers
3800
+ } = this.route.cors;
3801
+ var microservice = this;
3802
+ if (typeof microservice.headers !== "object") {
3803
+ microservice.headers = {};
3804
+ }
3805
+ if (typeof allow_origins !== "undefined") {
3806
+ // an example of allow_origins is ['https://example.com','http://www.example.com']
3807
+ if (allow_origins === "*" || (typeof microservice.request.headers.origin === "undefined") || [...allow_origins].indexOf(microservice.request.headers.origin) !== -1) {
3808
+ // for compatibility with all browsers allways return a wildcard when the origin is allowed
3809
+ microservice.headers["Access-Control-Allow-Origin"] = "*";
3810
+ } else {
3811
+ logger.debug("Origin is not allowed: " + microservice.request.headers.origin);
3812
+ logger.debug("Forcing to finish the response...");
3813
+ this.body = {};
3814
+ try {
3815
+ this.done();
3816
+ } catch (e) {}
3817
+ }
3818
+ } else {
3819
+ microservice.headers["Access-Control-Allow-Origin"] = "*";
3820
+ }
3821
+ if (typeof allow_credentials !== "undefined") {
3822
+ microservice.headers["Access-Control-Allow-Credentials"] = allow_credentials.toString();
3823
+ } else {
3824
+ microservice.headers["Access-Control-Allow-Credentials"] = "true";
3825
+ }
3826
+ if (typeof allow_methods !== "undefined") {
3827
+ microservice.headers["Access-Control-Allow-Methods"] = [...allow_methods].join(",");
3828
+ } else {
3829
+ microservice.headers["Access-Control-Allow-Methods"] = "GET, OPTIONS, POST";
3830
+ }
3831
+ if (typeof allow_headers !== "undefined") {
3832
+ microservice.headers["Access-Control-Allow-Headers"] = [...allow_headers].join(",");
3833
+ } else {
3834
+ microservice.headers["Access-Control-Allow-Headers"] = "*";
3835
+ }
3836
+ }
3758
3837
  }
3759
- },
3760
- done() {
3761
- var microservice = this;
3762
- var stream = microservice.stream;
3763
- try {
3764
- stream.respond(microservice.headers);
3765
- } catch (e) {
3766
- logger.debug(e.toString());
3838
+
3839
+
3840
+ head(formData) {
3841
+ this.done();
3842
+ }
3843
+
3844
+ get(formData) {
3845
+ this.done();
3846
+ }
3847
+
3848
+ post(formData) {
3849
+ this.done();
3850
+ }
3851
+
3852
+ put(formData) {
3853
+ this.done();
3854
+ }
3855
+
3856
+ delete(formData) {
3857
+ this.done();
3858
+ }
3859
+
3860
+ connect(formData) {
3861
+ this.done();
3862
+ }
3863
+
3864
+ options(formData) {
3865
+ this.done();
3767
3866
  }
3768
- if (microservice.body !== null) {
3867
+
3868
+ trace(formData) {
3869
+ this.done();
3870
+ }
3871
+
3872
+ patch(formData) {
3873
+ this.done();
3874
+ }
3875
+
3876
+ finishWithBody(stream) {
3877
+ try {
3878
+ stream.write(_DataStringify(this.body));
3879
+ stream.end();
3880
+ } catch (e) {
3881
+ logger.debug("Something wrong writing the response for microservice" + e.toString());
3882
+ }
3883
+ }
3884
+
3885
+ done() {
3886
+ var microservice = this;
3887
+ var stream = microservice.stream;
3769
3888
  try {
3770
- microservice.finishWithBody.call(microservice, stream);
3889
+ stream.respond(microservice.headers);
3771
3890
  } catch (e) {
3772
3891
  logger.debug(e.toString());
3773
3892
  }
3893
+ if (microservice.body !== null) {
3894
+ try {
3895
+ microservice.finishWithBody.call(microservice, stream);
3896
+ } catch (e) {
3897
+ logger.debug(e.toString());
3898
+ }
3899
+ }
3774
3900
  }
3901
+
3902
+
3775
3903
  }
3776
- });
3904
+ ]);
3905
+
3777
3906
 
3778
3907
  }
3779
3908
 
3780
3909
  Class("SourceJS", Object, {
3781
- domain: domain,
3782
- basePath: basePath,
3910
+ domain: _domain_,
3911
+ basePath: _basePath_,
3783
3912
  body: _DOMCreateElement("script"),
3784
3913
  type: "text/javascript",
3785
3914
  containerTag: "body",
@@ -3837,8 +3966,8 @@
3837
3966
  }
3838
3967
  });
3839
3968
  Class("SourceCSS", Object, {
3840
- domain: domain,
3841
- basePath: basePath,
3969
+ domain: _domain_,
3970
+ basePath: _basePath_,
3842
3971
  body: _DOMCreateElement("link"),
3843
3972
  url: "",
3844
3973
  data: {},
@@ -4627,7 +4756,11 @@
4627
4756
  window.onpopstate = function (event) {
4628
4757
  event.stopImmediatePropagation();
4629
4758
  event.stopPropagation();
4630
- ClassFactory("Component").route();
4759
+ if (ClassFactory("CONFIG").get("rebuildObjects", true)){
4760
+ global.componentsStack = document.buildComponents.call(document, true);
4761
+ } else {
4762
+ ClassFactory("Component").route();
4763
+ }
4631
4764
  };
4632
4765
 
4633
4766
  /*