qcobjects 2.4.15-beta → 2.4.16-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/QCObjects.js +49 -19
  2. package/VERSION +1 -1
  3. package/package.json +1 -1
package/QCObjects.js CHANGED
@@ -309,8 +309,14 @@
309
309
  }
310
310
  },
311
311
  info (message) {
312
+ var color;
312
313
  if (this.infoEnabled) {
313
- console.info("\x1b[33m%s\x1b[0m","[INFO] " + message);
314
+ if (isBrowser) {
315
+ color = "\x1b[103m%s\x1b[0m";
316
+ } else {
317
+ color = "\x1b[33m%s\x1b[0m";
318
+ }
319
+ console.info(color,"[INFO] " + message);
314
320
  }
315
321
  },
316
322
  warn (message) {
@@ -2121,27 +2127,51 @@
2121
2127
  route () {
2122
2128
  var componentClass = this;
2123
2129
  var isValidInstance = ((!!componentClass.__instanceID) &&
2124
- componentClass.hasOwnProperty.call(componentClass,"subcomponents")) ? (true) : (false);
2130
+ Object.hasOwnProperty.call(componentClass,"subcomponents")) ? (true) : (false);
2125
2131
  var __route__ = function(componentList) {
2126
- componentList.map(function (rc, r){
2127
- if (typeof rc !== "undefined"
2128
- && rc.hasOwnProperty.call(rc,"_reroute_")){
2129
- rc._reroute_();
2130
- if (rc.hasOwnProperty.call(rc,"subcomponents") &&
2131
- typeof rc.subcomponents !== "undefined" &&
2132
- rc.subcomponents.length > 0
2133
- ) {
2134
- logger.debug("LOOKING FOR ROUTINGS IN SUBCOMPONENTS FOR: " + rc.name);
2135
- __route__.call(componentClass, rc.subcomponents);
2136
- }
2137
- } else if (typeof rc !== "undefined"){
2138
- logger.debug("IT WAS NOT POSSIBLE TO RE-ROUTE: " + rc.name);
2132
+ var _componentNames_ = [];
2133
+ var _promises_ = componentList.filter(function (rc){return typeof rc !== "undefined";}).map(function (rc){
2134
+ if (typeof rc.name !== "undefined"){
2135
+ _componentNames_.push(rc.name);
2136
+ } else {
2137
+ throw new Error(__getType__(rc)+" does not have a name");
2139
2138
  }
2139
+ return new Promise (function (resolve, reject){
2140
+ var _promise_;
2141
+ if (typeof rc !== "undefined"
2142
+ && Object.hasOwnProperty.call(rc,"_reroute_")){
2143
+ _promise_ = rc._reroute_()
2144
+ .then(function (){
2145
+ rc.body.innerHTML = "";
2146
+ rc.innerHTML = "";
2147
+ return rc.rebuild();})
2148
+ .then (function (_rc_){
2149
+ if (Object.hasOwnProperty.call(_rc_,"subcomponents") &&
2150
+ typeof _rc_.subcomponents !== "undefined" &&
2151
+ _rc_.subcomponents.length > 0
2152
+ ) {
2153
+ logger.debug("LOOKING FOR ROUTINGS IN SUBCOMPONENTS FOR: " + _rc_.name);
2154
+ return __route__.call(_rc_, _rc_.subcomponents);
2155
+ } else {
2156
+ resolve(_rc_);
2157
+ }
2158
+ });
2159
+ } else if (typeof rc !== "undefined"){
2160
+ reject("Component " + rc.name + " is not an instance of Component");
2161
+ }
2162
+ return _promise_;
2163
+ });
2140
2164
  });
2165
+ return Promise.all(_promises_)
2166
+ .then(function (){
2167
+ logger.debug("ROUTING COMPLETED FOR "+ _componentNames_.join(", "));
2168
+ }).catch(function (err){
2169
+ logger.error("ROUTING FAILED FOR "+ _componentNames_.join(", ") + ": " + err);
2170
+ });
2141
2171
  };
2142
- if (isValidInstance || global.hasOwnProperty.call(_top.global,"componentsStack")) {
2143
- if (isValidInstance && componentClass.hasOwnProperty.call(componentClass,"name")) {
2144
- logger.debug("loading routings for instance" + componentClass.name);
2172
+ if (isValidInstance || Object.hasOwnProperty.call(global,"componentsStack")) {
2173
+ if (isValidInstance && is_a(componentClass, "Component")){
2174
+ logger.debug("loading routings for instance " + componentClass.name);
2145
2175
  }
2146
2176
  __route__.call(componentClass, (isValidInstance) ? (componentClass.subcomponents) : (global.componentsStack));
2147
2177
  } else {
@@ -2239,7 +2269,7 @@
2239
2269
  var self = this;
2240
2270
 
2241
2271
  if (typeof self.name === "undefined"){
2242
- logger.debug("Component name is not defined");
2272
+ logger.warn("A name is not defined for "+__getType__(self));
2243
2273
  }
2244
2274
 
2245
2275
  self.routingWay = _top.CONFIG.get("routingWay");
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.15-beta
1
+ 2.4.16-beta
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qcobjects",
3
- "version": "2.4.15-beta",
3
+ "version": "2.4.16-beta",
4
4
  "description": "QCObjects is an Open-source framework that empowers full-stack developers to make micro-services and micro-frontends into an N-Tier architecture.",
5
5
  "main": "QCObjects.js",
6
6
  "license": "LGPL-3.0",