qcobjects 2.4.32-beta → 2.4.37
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 +1005 -872
- package/VERSION +1 -1
- package/package.json +1 -1
- package/spec/testsClassFactorySpec.js +3 -3
package/QCObjects.js
CHANGED
|
@@ -190,7 +190,8 @@
|
|
|
190
190
|
} else if (typeof global !== "undefined") {
|
|
191
191
|
_top = global;
|
|
192
192
|
}
|
|
193
|
-
var
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
1017
|
-
var
|
|
1018
|
-
|
|
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
|
|
1104
|
-
|
|
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":
|
|
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
|
-
|
|
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") : (
|
|
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 =
|
|
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
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
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
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
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
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
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
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
return;
|
|
2128
|
+
get shadowRoot() {
|
|
2129
|
+
var self= this;
|
|
2130
|
+
return self.__shadowRoot;
|
|
2130
2131
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
set routingSelected(value){
|
|
2135
|
+
logger.debug("[routingSelected] This is a read-only property of the component");
|
|
2135
2136
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
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
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
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
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
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
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
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
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
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
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
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
|
-
|
|
2258
|
-
reject("Component " + rc.name + " is not an instance of Component");
|
|
2335
|
+
break;
|
|
2259
2336
|
}
|
|
2260
|
-
|
|
2261
|
-
}
|
|
2337
|
+
|
|
2338
|
+
}
|
|
2262
2339
|
});
|
|
2263
|
-
return
|
|
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
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
}
|
|
2305
|
-
|
|
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
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
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
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
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
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
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
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
if (
|
|
2418
|
-
|
|
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
|
-
|
|
2473
|
+
// not yet implemented.
|
|
2421
2474
|
}
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
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
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
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
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
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
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
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
|
-
|
|
2576
|
+
logger.debug(`${__getType__(_Effect)} is not a TransitionEffect`);
|
|
2520
2577
|
}
|
|
2521
|
-
|
|
2522
|
-
} else {
|
|
2523
|
-
// not yet implemented
|
|
2524
2578
|
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
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
|
-
|
|
2596
|
+
observer.observe(_componentRoot);
|
|
2597
|
+
} else {
|
|
2598
|
+
_applyEffect_(_componentRoot);
|
|
2599
|
+
}
|
|
2555
2600
|
} else {
|
|
2556
|
-
|
|
2601
|
+
// not yet implemented
|
|
2557
2602
|
}
|
|
2558
|
-
|
|
2559
|
-
// not yet implemented
|
|
2603
|
+
return null;
|
|
2560
2604
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
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
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
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
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
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
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2767
|
-
|
|
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
|
-
|
|
2783
|
-
|
|
2823
|
+
|
|
2824
|
+
get(name) {
|
|
2825
|
+
return this[name];
|
|
2784
2826
|
}
|
|
2785
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
3049
|
+
return __promise__;
|
|
2953
3050
|
};
|
|
2954
3051
|
var _componentLoaderInNode = function (component, _async) {
|
|
2955
|
-
|
|
2956
|
-
var _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 (
|
|
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 (
|
|
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_.
|
|
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
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
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
|
-
}
|
|
3670
|
-
|
|
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
|
-
"
|
|
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
|
|
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
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
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
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
3782
|
-
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:
|
|
3841
|
-
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("
|
|
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
|
/*
|