qcobjects 2.4.29-beta → 2.4.32-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.
- package/QCObjects.js +1518 -1385
- package/VERSION +1 -1
- package/package.json +1 -1
package/QCObjects.js
CHANGED
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
/*eslint no-empty: "off"*/
|
|
28
28
|
/*eslint strict: "off"*/
|
|
29
29
|
/*eslint no-mixed-operators: "off"*/
|
|
30
|
-
(function(_top) {
|
|
30
|
+
(function (_top) {
|
|
31
31
|
"use strict";
|
|
32
32
|
var global = _top;
|
|
33
33
|
_top.global = global;
|
|
34
34
|
|
|
35
|
-
var _protected_code_ = function(_) {
|
|
36
|
-
var __oldtoString = (typeof _.prototype !== "undefined") ? (_.prototype.toString) : (function() {
|
|
35
|
+
var _protected_code_ = function (_) {
|
|
36
|
+
var __oldtoString = (typeof _.prototype !== "undefined") ? (_.prototype.toString) : (function () {
|
|
37
37
|
return "";
|
|
38
38
|
});
|
|
39
39
|
if (typeof _.prototype !== "undefined") {
|
|
40
|
-
_.prototype.toString = function() {
|
|
40
|
+
_.prototype.toString = function () {
|
|
41
41
|
var _protected_symbols = ["ComplexStorageCache",
|
|
42
42
|
"css",
|
|
43
43
|
"append",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
(_protected_code_)(Function);
|
|
102
|
-
var _methods_ = function(_) {
|
|
102
|
+
var _methods_ = function (_) {
|
|
103
103
|
var _m = [];
|
|
104
104
|
for (var i in _) {
|
|
105
105
|
if ((typeof _[i]).toLowerCase() === "function") {
|
|
@@ -110,23 +110,23 @@
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
String.prototype.__mAll__ = function (regex) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
// This is an alternative to old browsers that dont support String.prototype.matchAll
|
|
114
|
+
// https://github.com/tc39/proposal-string-matchall
|
|
115
|
+
var matches = [];
|
|
116
|
+
this.replace(regex, function () {
|
|
117
|
+
var match = Array.prototype.slice.call(arguments, 0, -2);
|
|
118
|
+
match.input = arguments[arguments.length - 1];
|
|
119
|
+
match.index = arguments[arguments.length - 2];
|
|
120
|
+
matches.push(match);
|
|
121
|
+
});
|
|
122
|
+
return matches;
|
|
123
123
|
};
|
|
124
|
-
if (typeof String.prototype.matchAll === "undefined"){
|
|
125
|
-
|
|
124
|
+
if (typeof String.prototype.matchAll === "undefined") {
|
|
125
|
+
String.prototype.matchAll = String.prototype.__mAll__;
|
|
126
126
|
}
|
|
127
127
|
var isDeno = (typeof window !== "undefined" && "Deno" in window);
|
|
128
128
|
var isBrowser = (typeof window !== "undefined" && typeof window.self !== "undefined" && window === window.self) && !isDeno;
|
|
129
|
-
var _DOMCreateElement = function(elementName) {
|
|
129
|
+
var _DOMCreateElement = function (elementName) {
|
|
130
130
|
var _ret_;
|
|
131
131
|
if (isBrowser) {
|
|
132
132
|
_ret_ = document.createElement(elementName);
|
|
@@ -140,11 +140,11 @@
|
|
|
140
140
|
const fs = require("fs");
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
var _DataStringify = function(data) {
|
|
144
|
-
var getCircularReplacer = function() {
|
|
143
|
+
var _DataStringify = function (data) {
|
|
144
|
+
var getCircularReplacer = function () {
|
|
145
145
|
var seen = new WeakSet();
|
|
146
146
|
var _level = 0;
|
|
147
|
-
return function(key, value) {
|
|
147
|
+
return function (key, value) {
|
|
148
148
|
if (typeof value === "object" && value !== null) {
|
|
149
149
|
if (seen.has(value)) {
|
|
150
150
|
_level += 1;
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
Element.prototype.subelements = _subelements;
|
|
166
166
|
HTMLDocument.prototype.subelements = _subelements;
|
|
167
167
|
HTMLElement.prototype.subelements = _subelements;
|
|
168
|
-
if (typeof ShadowRoot !== "undefined"){
|
|
168
|
+
if (typeof ShadowRoot !== "undefined") {
|
|
169
169
|
ShadowRoot.prototype.subelements = _subelements;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
_top = global;
|
|
192
192
|
}
|
|
193
193
|
var basePath = (
|
|
194
|
-
function() {
|
|
194
|
+
function () {
|
|
195
195
|
var _basePath = "";
|
|
196
196
|
if (isBrowser) {
|
|
197
197
|
var baseURI = _top.document.baseURI.split("?")[0].split("/");
|
|
@@ -218,14 +218,14 @@
|
|
|
218
218
|
* Polyfilling Promise
|
|
219
219
|
*/
|
|
220
220
|
if (!("Promise" in _top)) {
|
|
221
|
-
_top.Promise = function(_f) {
|
|
221
|
+
_top.Promise = function (_f) {
|
|
222
222
|
var _p = {
|
|
223
|
-
then
|
|
223
|
+
then() {},
|
|
224
224
|
catch () {},
|
|
225
|
-
_then
|
|
225
|
+
_then(response) {
|
|
226
226
|
this.then.call(_p, response);
|
|
227
227
|
},
|
|
228
|
-
_catch
|
|
228
|
+
_catch(response) {
|
|
229
229
|
this.catch.call(_p, response);
|
|
230
230
|
}
|
|
231
231
|
};
|
|
@@ -234,18 +234,18 @@
|
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
if (typeof _top.console === "undefined") {
|
|
237
|
-
_top.console = function() {};
|
|
238
|
-
_top.console.prototype.log = function(message) {};
|
|
237
|
+
_top.console = function () {};
|
|
238
|
+
_top.console.prototype.log = function (message) {};
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
var domain = (
|
|
242
|
-
function() {
|
|
242
|
+
function () {
|
|
243
243
|
return (typeof document !== "undefined" && document.domain !== "") ? (document.domain) : ("localhost");
|
|
244
244
|
}
|
|
245
245
|
)();
|
|
246
246
|
|
|
247
247
|
var _secretKey = (
|
|
248
|
-
function() {
|
|
248
|
+
function () {
|
|
249
249
|
var __secretKey = _top[(![] + [])[((+!+[]) + (+!+[]))] + (typeof ![])[(+!+[])] + (typeof [])[((+!+[]) + (+!+[])) * ((+!+[]) + (+!+[]))] + (![] + [])[(+!+[])] + (!![] + [])[(+[])] + ([] + [] + [][
|
|
250
250
|
[]
|
|
251
251
|
])[(+[+!+[] + [+[]]]) / ((+!+[]) + (+!+[]))] + (typeof ![])[(+!+[])] + ([] + [] + [][
|
|
@@ -255,7 +255,7 @@
|
|
|
255
255
|
}
|
|
256
256
|
)();
|
|
257
257
|
var is_phonegap = (
|
|
258
|
-
function() {
|
|
258
|
+
function () {
|
|
259
259
|
return (typeof cordova !== "undefined") ? (true) : (false);
|
|
260
260
|
}
|
|
261
261
|
)();
|
|
@@ -268,11 +268,11 @@
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
_top._asyncLoad = [];
|
|
271
|
-
var asyncLoad = function(callback, args) {
|
|
271
|
+
var asyncLoad = function (callback, args) {
|
|
272
272
|
var asyncCallback = {
|
|
273
273
|
"func": callback,
|
|
274
274
|
"args": args,
|
|
275
|
-
"dispatch"
|
|
275
|
+
"dispatch"() {
|
|
276
276
|
this.func.apply(null, this.args);
|
|
277
277
|
}
|
|
278
278
|
};
|
|
@@ -281,34 +281,34 @@
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
if (isBrowser) {
|
|
284
|
-
var _fireAsyncLoad = function() {
|
|
284
|
+
var _fireAsyncLoad = function () {
|
|
285
285
|
if (document.readyState === "complete") {
|
|
286
|
-
_top._asyncLoad.map(function (fc){
|
|
286
|
+
_top._asyncLoad.map(function (fc) {
|
|
287
287
|
fc.dispatch.call(fc);
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
document.onreadystatechange = _fireAsyncLoad;
|
|
292
292
|
} else if (typeof _top.global !== "undefined") {
|
|
293
|
-
_top.global._fireAsyncLoad = function() {
|
|
294
|
-
_top._asyncLoad.map(function (fc){
|
|
293
|
+
_top.global._fireAsyncLoad = function () {
|
|
294
|
+
_top._asyncLoad.map(function (fc) {
|
|
295
295
|
fc.dispatch.call(fc);
|
|
296
296
|
});
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
_top.asyncLoad = asyncLoad;
|
|
301
|
-
var Logger = function() {
|
|
301
|
+
var Logger = function () {
|
|
302
302
|
return {
|
|
303
303
|
debugEnabled: true,
|
|
304
304
|
infoEnabled: true,
|
|
305
305
|
warnEnabled: true,
|
|
306
|
-
debug
|
|
306
|
+
debug(message) {
|
|
307
307
|
if (this.debugEnabled) {
|
|
308
|
-
console.log("\x1b[35m%s\x1b[0m","[DEBUG] " + message);
|
|
308
|
+
console.log("\x1b[35m%s\x1b[0m", "[DEBUG] " + message);
|
|
309
309
|
}
|
|
310
310
|
},
|
|
311
|
-
info
|
|
311
|
+
info(message) {
|
|
312
312
|
var color;
|
|
313
313
|
if (this.infoEnabled) {
|
|
314
314
|
if (isBrowser) {
|
|
@@ -316,12 +316,12 @@
|
|
|
316
316
|
} else {
|
|
317
317
|
color = "\x1b[33m%s\x1b[0m";
|
|
318
318
|
}
|
|
319
|
-
console.info(color,"[INFO] " + message);
|
|
319
|
+
console.info(color, "[INFO] " + message);
|
|
320
320
|
}
|
|
321
321
|
},
|
|
322
|
-
warn
|
|
322
|
+
warn(message) {
|
|
323
323
|
if (this.warnEnabled) {
|
|
324
|
-
console.warn("\x1b[31m%s\x1b[0m","[WARN] " + message);
|
|
324
|
+
console.warn("\x1b[31m%s\x1b[0m", "[WARN] " + message);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
};
|
|
@@ -332,7 +332,7 @@
|
|
|
332
332
|
_top.logger = logger;
|
|
333
333
|
var Base64 = {
|
|
334
334
|
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
335
|
-
encode
|
|
335
|
+
encode(e) {
|
|
336
336
|
var t = "";
|
|
337
337
|
var n, r, i, s, o, u, a;
|
|
338
338
|
var f = 0;
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
}
|
|
355
355
|
return t;
|
|
356
356
|
},
|
|
357
|
-
decode
|
|
357
|
+
decode(e) {
|
|
358
358
|
var t = "";
|
|
359
359
|
var n, r, i;
|
|
360
360
|
var s, o, u, a;
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
t = Base64._utf8_decode(t);
|
|
380
380
|
return t;
|
|
381
381
|
},
|
|
382
|
-
_utf8_encode
|
|
382
|
+
_utf8_encode(e) {
|
|
383
383
|
e = e.replace(/rn/g, "n");
|
|
384
384
|
var t = "";
|
|
385
385
|
for (var n = 0; n < e.length; n++) {
|
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
}
|
|
398
398
|
return t;
|
|
399
399
|
},
|
|
400
|
-
_utf8_decode
|
|
400
|
+
_utf8_decode(e) {
|
|
401
401
|
var t = "";
|
|
402
402
|
var n = 0;
|
|
403
403
|
var r = 0;
|
|
@@ -423,11 +423,11 @@
|
|
|
423
423
|
return t;
|
|
424
424
|
}
|
|
425
425
|
};
|
|
426
|
-
var waitUntil = function(func, exp) {
|
|
427
|
-
var _waitUntil = function(func, exp) {
|
|
426
|
+
var waitUntil = function (func, exp) {
|
|
427
|
+
var _waitUntil = function (func, exp) {
|
|
428
428
|
var maxWaitCycles = 2000;
|
|
429
429
|
var _w = 0;
|
|
430
|
-
var _t = setInterval(function() {
|
|
430
|
+
var _t = setInterval(function () {
|
|
431
431
|
if (exp.call()) {
|
|
432
432
|
clearInterval(_t);
|
|
433
433
|
func.call();
|
|
@@ -443,26 +443,26 @@
|
|
|
443
443
|
}
|
|
444
444
|
}, 1);
|
|
445
445
|
};
|
|
446
|
-
setTimeout(function() {
|
|
446
|
+
setTimeout(function () {
|
|
447
447
|
_waitUntil(func, exp);
|
|
448
448
|
}, 1);
|
|
449
449
|
};
|
|
450
|
-
if (typeof localStorage === "undefined"){
|
|
450
|
+
if (typeof localStorage === "undefined") {
|
|
451
451
|
/* Polyfill for localStorage */
|
|
452
452
|
var localStorage = {
|
|
453
|
-
getItem
|
|
454
|
-
return (Object.hasOwnProperty.call(this, name))?(this[name]):(null);
|
|
453
|
+
getItem(name) {
|
|
454
|
+
return (Object.hasOwnProperty.call(this, name)) ? (this[name]) : (null);
|
|
455
455
|
},
|
|
456
|
-
setItem
|
|
456
|
+
setItem(name, value) {
|
|
457
457
|
this[name] = value;
|
|
458
458
|
},
|
|
459
|
-
removeItem
|
|
459
|
+
removeItem(name) {
|
|
460
460
|
delete this[name];
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
/* end Polyfill for localStorage */
|
|
464
464
|
}
|
|
465
|
-
var ComplexStorageCache = function(params) {
|
|
465
|
+
var ComplexStorageCache = function (params) {
|
|
466
466
|
var object, load, alternate;
|
|
467
467
|
object = params.index;
|
|
468
468
|
if (typeof object !== "undefined") {
|
|
@@ -486,13 +486,13 @@
|
|
|
486
486
|
});
|
|
487
487
|
logger.debug("RESPONSE OF {{cachedObjectID}} IS ALREADY CACHED ".replace("{{cachedObjectID}}", cachedObjectID));
|
|
488
488
|
}
|
|
489
|
-
|
|
489
|
+
|
|
490
490
|
} else {
|
|
491
491
|
throw new Error("ComplexStorageCache: index is undefined");
|
|
492
492
|
}
|
|
493
493
|
return this;
|
|
494
494
|
};
|
|
495
|
-
ComplexStorageCache.prototype.getItem = function(cachedObjectID) {
|
|
495
|
+
ComplexStorageCache.prototype.getItem = function (cachedObjectID) {
|
|
496
496
|
var retrievedObject = localStorage.getItem(cachedObjectID);
|
|
497
497
|
if (!this.isEmpty(retrievedObject)) {
|
|
498
498
|
return JSON.parse(retrievedObject);
|
|
@@ -500,10 +500,10 @@
|
|
|
500
500
|
return null;
|
|
501
501
|
}
|
|
502
502
|
};
|
|
503
|
-
ComplexStorageCache.prototype.setItem = function(cachedObjectID, value) {
|
|
503
|
+
ComplexStorageCache.prototype.setItem = function (cachedObjectID, value) {
|
|
504
504
|
localStorage.setItem(cachedObjectID, _DataStringify(value));
|
|
505
505
|
};
|
|
506
|
-
ComplexStorageCache.prototype.isEmpty = function(object) {
|
|
506
|
+
ComplexStorageCache.prototype.isEmpty = function (object) {
|
|
507
507
|
var r = false;
|
|
508
508
|
switch (true) {
|
|
509
509
|
case (typeof object === "undefined"):
|
|
@@ -518,24 +518,28 @@
|
|
|
518
518
|
}
|
|
519
519
|
return r;
|
|
520
520
|
};
|
|
521
|
-
ComplexStorageCache.prototype.getID = function(object) {
|
|
521
|
+
ComplexStorageCache.prototype.getID = function (object) {
|
|
522
522
|
var cachedObjectID;
|
|
523
523
|
if (typeof object !== "undefined") {
|
|
524
524
|
cachedObjectID = "cachedObject_" + Base64.encode(_DataStringify(object).replace(/\{|\}|,/g, "_"));
|
|
525
525
|
}
|
|
526
526
|
return cachedObjectID;
|
|
527
527
|
};
|
|
528
|
-
ComplexStorageCache.prototype.save = function(object, cachedNewResponse) {
|
|
528
|
+
ComplexStorageCache.prototype.save = function (object, cachedNewResponse) {
|
|
529
529
|
var cachedObjectID = this.getID(object);
|
|
530
530
|
logger.debug("CACHING THE RESPONSE OF {{cachedObjectID}} ".replace("{{cachedObjectID}}", cachedObjectID));
|
|
531
531
|
this.setItem(cachedObjectID, cachedNewResponse);
|
|
532
532
|
};
|
|
533
|
-
ComplexStorageCache.prototype.getCached = function(object) {
|
|
533
|
+
ComplexStorageCache.prototype.getCached = function (object) {
|
|
534
534
|
var cachedObjectID = this.getID(object);
|
|
535
535
|
return this.getItem(cachedObjectID);
|
|
536
536
|
};
|
|
537
|
-
ComplexStorageCache.prototype.clear = function() {
|
|
538
|
-
Object.keys(localStorage).filter
|
|
537
|
+
ComplexStorageCache.prototype.clear = function () {
|
|
538
|
+
Object.keys(localStorage).filter(function (k) {
|
|
539
|
+
return k.startsWith("cachedObject_");
|
|
540
|
+
}).map(function (c) {
|
|
541
|
+
localStorage.removeItem(c);
|
|
542
|
+
});
|
|
539
543
|
};
|
|
540
544
|
|
|
541
545
|
/**
|
|
@@ -549,7 +553,7 @@
|
|
|
549
553
|
var supportsPassive = false;
|
|
550
554
|
try {
|
|
551
555
|
var opts = Object.defineProperty({}, "passive", {
|
|
552
|
-
get
|
|
556
|
+
get() {
|
|
553
557
|
supportsPassive = true;
|
|
554
558
|
return supportsPassive;
|
|
555
559
|
}
|
|
@@ -557,7 +561,7 @@
|
|
|
557
561
|
window.addEventListener("testPassive", null, opts);
|
|
558
562
|
window.removeEventListener("testPassive", null, opts);
|
|
559
563
|
} catch (e) {}
|
|
560
|
-
var captureFalse = function() {
|
|
564
|
+
var captureFalse = function () {
|
|
561
565
|
return (supportsPassive) ? ({
|
|
562
566
|
passive: true
|
|
563
567
|
}) : (false);
|
|
@@ -572,18 +576,18 @@
|
|
|
572
576
|
/**
|
|
573
577
|
* Basic Type of all elements
|
|
574
578
|
*/
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
579
|
+
if (isBrowser) {
|
|
580
|
+
Element.prototype.find = function (tag) {
|
|
581
|
+
var _oo = [];
|
|
582
|
+
var _tags = document.subelements(tag);
|
|
583
|
+
_tags.map(function (_tt, _t) {
|
|
584
|
+
if ((typeof _tags[_t] !== "undefined") && _tags[_t].parentNode.tagName === this.parentNode.tagName) {
|
|
585
|
+
_oo.push(_Cast(_tt, (new Object())));
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
return _oo;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
587
591
|
|
|
588
592
|
/**
|
|
589
593
|
* Primary instance ID of all objects
|
|
@@ -591,22 +595,22 @@
|
|
|
591
595
|
var __instanceID;
|
|
592
596
|
// Adaptation of Production steps of ECMA-262, Edition 5, 15.2.3.5
|
|
593
597
|
// Reference: http://es5.github.io/#x15.2.3.5
|
|
594
|
-
var _Object_Create = (function() {
|
|
598
|
+
var _Object_Create = (function () {
|
|
595
599
|
|
|
596
600
|
// make a safe reference to Object.prototype.hasOwnProperty
|
|
597
601
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
598
602
|
|
|
599
|
-
return function(O) {
|
|
603
|
+
return function (O) {
|
|
600
604
|
// 1. If Type(O) is not Object or Null throw a TypeError exception.
|
|
601
605
|
if (typeof O !== "object") {
|
|
602
|
-
throw TypeError("Object prototype may only be an Object or null. The type is " + typeof(O));
|
|
606
|
+
throw TypeError("Object prototype may only be an Object or null. The type is " + typeof (O));
|
|
603
607
|
}
|
|
604
608
|
|
|
605
609
|
// 2. Let obj be the result of creating a new object as if by the
|
|
606
610
|
// expression new Object() where Object is the standard built-in
|
|
607
611
|
// constructor with that name
|
|
608
612
|
// 3. Set the [[Prototype]] internal property of obj to O.
|
|
609
|
-
var QCObjects = function() {};
|
|
613
|
+
var QCObjects = function () {};
|
|
610
614
|
QCObjects.prototype = O;
|
|
611
615
|
var obj = new QCObjects();
|
|
612
616
|
|
|
@@ -664,10 +668,10 @@
|
|
|
664
668
|
}
|
|
665
669
|
|
|
666
670
|
var __is_raw_class__ = function (o_c) {
|
|
667
|
-
return (typeof o_c === "function" && o_c.toString().startsWith("class"))?(true):(false);
|
|
671
|
+
return (typeof o_c === "function" && o_c.toString().startsWith("class")) ? (true) : (false);
|
|
668
672
|
};
|
|
669
673
|
|
|
670
|
-
var _LegacyCopy = function(obj) {
|
|
674
|
+
var _LegacyCopy = function (obj) {
|
|
671
675
|
var _value_;
|
|
672
676
|
switch (true) {
|
|
673
677
|
case typeof obj === "string":
|
|
@@ -702,17 +706,17 @@
|
|
|
702
706
|
*
|
|
703
707
|
* @param Object or function
|
|
704
708
|
*/
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
709
|
+
var ObjectName = function (o) {
|
|
710
|
+
var ret = "";
|
|
711
|
+
if (typeof o === "function" && Object.hasOwnProperty.call(o, "name") && o.name !== "") {
|
|
712
|
+
ret = o.name;
|
|
713
|
+
} else if (typeof o !== "undefined" && typeof o.constructor === "function" && o.constructor.name !== "") {
|
|
714
|
+
ret = o.constructor.name;
|
|
715
|
+
} else if (typeof o !== "undefined" && typeof o.constructor === "object") {
|
|
716
|
+
ret = o.constructor.toString().replace(/\[(.*?)\]/g, "$1").split(" ").slice(1).join("");
|
|
717
|
+
}
|
|
718
|
+
return ret;
|
|
719
|
+
};
|
|
716
720
|
|
|
717
721
|
/**
|
|
718
722
|
* Casts an object to another object class type
|
|
@@ -720,7 +724,7 @@
|
|
|
720
724
|
* @param {Object} obj_source
|
|
721
725
|
* @param {Object} obj_dest
|
|
722
726
|
*/
|
|
723
|
-
var _Cast = function(obj_source, obj_dest) {
|
|
727
|
+
var _Cast = function (obj_source, obj_dest) {
|
|
724
728
|
for (var v in obj_source) {
|
|
725
729
|
if (typeof obj_source[v] !== "undefined") {
|
|
726
730
|
try {
|
|
@@ -739,7 +743,7 @@
|
|
|
739
743
|
* @param {Object} obj_source
|
|
740
744
|
* @param {Object} obj_dest
|
|
741
745
|
*/
|
|
742
|
-
var _CastProps = function(obj_source, obj_dest) {
|
|
746
|
+
var _CastProps = function (obj_source, obj_dest) {
|
|
743
747
|
for (var v in obj_source) {
|
|
744
748
|
if (typeof obj_source[v] !== "undefined" && typeof obj_source[v] !== "function") {
|
|
745
749
|
try {
|
|
@@ -747,7 +751,7 @@
|
|
|
747
751
|
} catch (e) {
|
|
748
752
|
// DO NOTHING
|
|
749
753
|
}
|
|
750
|
-
} else if (typeof obj_source[v] === "function"){
|
|
754
|
+
} else if (typeof obj_source[v] === "function") {
|
|
751
755
|
try {
|
|
752
756
|
obj_dest[v] = obj_source[v].bind(obj_dest);
|
|
753
757
|
} catch (e) {
|
|
@@ -766,22 +770,22 @@
|
|
|
766
770
|
* @param {Object} type
|
|
767
771
|
* @param {Object} definition
|
|
768
772
|
*/
|
|
769
|
-
var __is__forbidden_name__ = function (){
|
|
770
|
-
return (["__proto__", "prototype", "Object", "Map", "defineProperty", "indexOf", "toString", "__instanceID"].indexOf(arguments[0])!== -1)?(true):(false);
|
|
773
|
+
var __is__forbidden_name__ = function () {
|
|
774
|
+
return (["__proto__", "prototype", "Object", "Map", "defineProperty", "indexOf", "toString", "__instanceID"].indexOf(arguments[0]) !== -1) ? (true) : (false);
|
|
771
775
|
};
|
|
772
776
|
|
|
773
777
|
/**
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
+
* Determine the type of the Object for any QCObjects Object
|
|
779
|
+
*
|
|
780
|
+
* @param {Object} object
|
|
781
|
+
*/
|
|
778
782
|
var __getType__ = function __getType__(o_c) {
|
|
779
783
|
var _ret_ = "";
|
|
780
784
|
switch (true) {
|
|
781
|
-
case typeof o_c === "object"
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
+
case typeof o_c === "object" &&
|
|
786
|
+
!!o_c.constructor &&
|
|
787
|
+
Object.hasOwnProperty.call(o_c.constructor, "name") &&
|
|
788
|
+
o_c.constructor.name !== "":
|
|
785
789
|
_ret_ = o_c.constructor.name;
|
|
786
790
|
break;
|
|
787
791
|
case (!!o_c && !!o_c.__classType) && o_c.__classType !== "":
|
|
@@ -798,23 +802,46 @@
|
|
|
798
802
|
};
|
|
799
803
|
|
|
800
804
|
/**
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
+
* Returns if a class or object is from a determinated type
|
|
806
|
+
* @param {Object} object
|
|
807
|
+
* @param {String} typeName
|
|
808
|
+
*/
|
|
805
809
|
var is_a = function is_a(obj, typeName) {
|
|
806
810
|
return (typeof obj !== "undefined" && obj !== null &&
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
+
(((isQCObjects_Class(obj) || isQCObjects_Object(obj)) && (obj.hierarchy().includes(typeName))) ||
|
|
812
|
+
__getType__(obj) === typeName ||
|
|
813
|
+
ObjectName(obj) === typeName ||
|
|
814
|
+
typeof obj === typeName)) ? (true) : (false);
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
var __make_global__ = function (f) {
|
|
819
|
+
if (typeof f !== "undefined") {
|
|
820
|
+
if (isBrowser) {
|
|
821
|
+
try {
|
|
822
|
+
_top[f.name] = f;
|
|
823
|
+
window[f.name] = f;
|
|
824
|
+
} catch (e) {}
|
|
825
|
+
} else if (typeof global !== "undefined") {
|
|
826
|
+
if (!Object.hasOwnProperty.call(global, f.name)) {
|
|
827
|
+
global[f.name] = f;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
811
832
|
};
|
|
812
833
|
|
|
813
|
-
var __register_class__ = function (
|
|
834
|
+
var __register_class__ = function (_class_) {
|
|
835
|
+
var name = _class_.name;
|
|
814
836
|
_QC_CLASSES[name] = _class_;
|
|
815
837
|
_top[name] = _QC_CLASSES[name];
|
|
816
838
|
return _top[name];
|
|
817
|
-
}
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
var RegisterClass = function (_class_) {
|
|
842
|
+
return __register_class__(_class_);
|
|
843
|
+
};
|
|
844
|
+
__make_global__(RegisterClass);
|
|
818
845
|
|
|
819
846
|
/**
|
|
820
847
|
* Creates new object class of another object
|
|
@@ -853,7 +880,7 @@
|
|
|
853
880
|
throw new Error("Class type must be a function or class");
|
|
854
881
|
}
|
|
855
882
|
|
|
856
|
-
if (__is__forbidden_name__.call(this, name)){
|
|
883
|
+
if (__is__forbidden_name__.call(this, name)) {
|
|
857
884
|
throw new Error(`${name} is not an allowed word in the name of a class`);
|
|
858
885
|
}
|
|
859
886
|
|
|
@@ -868,36 +895,42 @@
|
|
|
868
895
|
} else {
|
|
869
896
|
definition = _LegacyCopy(definition);
|
|
870
897
|
}
|
|
871
|
-
|
|
898
|
+
|
|
872
899
|
/* hack to prevent duplicate __instanceID */
|
|
873
900
|
if (typeof definition["__instanceID"] !== "undefined") {
|
|
874
901
|
delete definition["__instanceID"];
|
|
875
|
-
}
|
|
902
|
+
}
|
|
876
903
|
|
|
877
904
|
_QC_CLASSES[name] = class extends _types_[type.name] {
|
|
878
905
|
__classType = name;
|
|
879
|
-
__definition = {
|
|
906
|
+
__definition = {
|
|
907
|
+
...definition
|
|
908
|
+
};
|
|
880
909
|
body = null;
|
|
881
910
|
|
|
882
911
|
static hierarchy(__class__) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
912
|
+
var __classType = function (o_c) {
|
|
913
|
+
return (Object.hasOwnProperty.call(o_c, "__classType")) ? (o_c.__classType) : (__getType__.call(__class__, o_c));
|
|
914
|
+
};
|
|
915
|
+
var __hierarchy__proto__ = (c) => {
|
|
916
|
+
return (typeof c !== "undefined" && typeof c.__proto__ !== "undefined" && c.__proto__ !== null) ? (((__classType(c) !== "") ? ([__classType(c)]) : ([])).concat(__hierarchy__proto__(c.__proto__))) : ([]);
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
if (typeof __class__ === "undefined" || __class__ === null) {
|
|
920
|
+
__class__ = this;
|
|
921
|
+
}
|
|
922
|
+
var __hierarchy = [];
|
|
923
|
+
__hierarchy.push(__classType(__class__));
|
|
924
|
+
__hierarchy = __hierarchy.concat(__hierarchy__proto__(__class__.__proto__));
|
|
925
|
+
return __hierarchy;
|
|
895
926
|
}
|
|
896
927
|
|
|
897
|
-
constructor
|
|
928
|
+
constructor() {
|
|
898
929
|
var _o_;
|
|
899
930
|
if (arguments.length > 0) {
|
|
900
|
-
_o_ = {
|
|
931
|
+
_o_ = {
|
|
932
|
+
...arguments[0]
|
|
933
|
+
};
|
|
901
934
|
} else {
|
|
902
935
|
_o_ = {};
|
|
903
936
|
}
|
|
@@ -912,9 +945,9 @@
|
|
|
912
945
|
}
|
|
913
946
|
|
|
914
947
|
if (typeof self.__definition !== "undefined") {
|
|
915
|
-
Object.keys(self.__definition).filter(function (k){
|
|
916
|
-
return isNaN(k) && !["name","__instanceID", "__classType", "__definition"].includes(k);
|
|
917
|
-
}).forEach(function(key) {
|
|
948
|
+
Object.keys(self.__definition).filter(function (k) {
|
|
949
|
+
return isNaN(k) && !["name", "__instanceID", "__classType", "__definition"].includes(k);
|
|
950
|
+
}).forEach(function (key) {
|
|
918
951
|
if (typeof self.__definition[key] === "function") {
|
|
919
952
|
self[key] = self.__definition[key].bind(self);
|
|
920
953
|
} else {
|
|
@@ -922,54 +955,57 @@
|
|
|
922
955
|
}
|
|
923
956
|
});
|
|
924
957
|
}
|
|
925
|
-
_methods_(_QC_CLASSES[self.__classType]).map
|
|
926
|
-
self[m.name] = m.bind(self);
|
|
927
|
-
|
|
958
|
+
_methods_(_QC_CLASSES[self.__classType]).map(function (m) {
|
|
959
|
+
self[m.name] = m.bind(self);
|
|
960
|
+
});
|
|
961
|
+
_methods_(self.__definition).map(function (m) {
|
|
962
|
+
self[m.name] = m.bind(self);
|
|
963
|
+
});
|
|
928
964
|
|
|
929
|
-
if (typeof self.__definition === "undefined" || (!Object.hasOwnProperty.call(self.__definition,"body")) ||
|
|
965
|
+
if (typeof self.__definition === "undefined" || (!Object.hasOwnProperty.call(self.__definition, "body")) || typeof self.__definition.body === "undefined") {
|
|
930
966
|
try {
|
|
931
967
|
if (isBrowser) {
|
|
932
|
-
self["body"] =
|
|
968
|
+
self["body"] = _DOMCreateElement(self.__definition.__classType);
|
|
933
969
|
} else {
|
|
934
970
|
self["body"] = {};
|
|
935
971
|
}
|
|
936
972
|
} catch (e) {
|
|
937
973
|
self["body"] = {};
|
|
938
974
|
}
|
|
939
|
-
} else if (Object.hasOwnProperty.call(self.__definition,"body")) {
|
|
975
|
+
} else if (Object.hasOwnProperty.call(self.__definition, "body")) {
|
|
940
976
|
self["body"] = self.__definition.body;
|
|
941
977
|
}
|
|
942
978
|
|
|
943
979
|
try {
|
|
944
980
|
if (typeof self.__new__ === "function") {
|
|
945
|
-
self.__new__.call(self,_o_);
|
|
981
|
+
self.__new__.call(self, _o_);
|
|
946
982
|
} else if (typeof super.__new__ === "function") {
|
|
947
983
|
self.__new__ = super.__new__.bind(self);
|
|
948
|
-
self.__new__.call(self,_o_);
|
|
984
|
+
self.__new__.call(self, _o_);
|
|
949
985
|
}
|
|
950
|
-
if (typeof self === "object" && Object.hasOwnProperty.call(self,"_new_") && typeof self._new_.isCalled === "undefined") {
|
|
986
|
+
if (typeof self === "object" && Object.hasOwnProperty.call(self, "_new_") && typeof self._new_.isCalled === "undefined") {
|
|
951
987
|
try {
|
|
952
|
-
self._new_.call(self,_o_);
|
|
988
|
+
self._new_.call(self, _o_);
|
|
953
989
|
self._new_.isCalled = true;
|
|
954
|
-
}catch (e){
|
|
990
|
+
} catch (e) {
|
|
955
991
|
logger.warn(`${self.__classType}._new_() failed with error: ${e}`);
|
|
956
992
|
}
|
|
957
993
|
}
|
|
958
|
-
} catch (e){
|
|
994
|
+
} catch (e) {
|
|
959
995
|
logger.warn(e);
|
|
960
996
|
}
|
|
961
997
|
}
|
|
962
998
|
|
|
963
|
-
__new__
|
|
964
|
-
_CastProps(_o_, this);
|
|
999
|
+
__new__(_o_) {
|
|
1000
|
+
_CastProps(_o_, this);
|
|
965
1001
|
}
|
|
966
|
-
_new_
|
|
1002
|
+
_new_() {}
|
|
967
1003
|
|
|
968
|
-
getClass
|
|
1004
|
+
getClass() {
|
|
969
1005
|
return Object.getPrototypeOf(this.constructor);
|
|
970
1006
|
}
|
|
971
1007
|
|
|
972
|
-
css
|
|
1008
|
+
css(_css) {
|
|
973
1009
|
if (typeof this["body"] !== "undefined" && this["body"]["style"] !== "undefined") {
|
|
974
1010
|
logger.debug("body style");
|
|
975
1011
|
this["body"]["style"] = _Cast(_css, this["body"]["style"]);
|
|
@@ -977,7 +1013,7 @@
|
|
|
977
1013
|
return this["body"]["style"];
|
|
978
1014
|
}
|
|
979
1015
|
|
|
980
|
-
hierarchy
|
|
1016
|
+
hierarchy(__instance__) {
|
|
981
1017
|
var __hierarchy;
|
|
982
1018
|
if (typeof __instance__ === "undefined" || __instance__ === null) {
|
|
983
1019
|
__instance__ = this;
|
|
@@ -988,13 +1024,15 @@
|
|
|
988
1024
|
} else {
|
|
989
1025
|
__hierarchy = [];
|
|
990
1026
|
}
|
|
991
|
-
return [__getType__(__instance__)].concat(__hierarchy).filter(function (value, index, self) {
|
|
1027
|
+
return [__getType__(__instance__)].concat(__hierarchy).filter(function (value, index, self) {
|
|
1028
|
+
return self.indexOf(value) === index;
|
|
1029
|
+
});
|
|
992
1030
|
}
|
|
993
1031
|
|
|
994
1032
|
|
|
995
|
-
append
|
|
1033
|
+
append(child) {
|
|
996
1034
|
logger.debug("append: start");
|
|
997
|
-
if (is_a(child, "Component")){
|
|
1035
|
+
if (is_a(child, "Component")) {
|
|
998
1036
|
logger.debug("append: child is a Component");
|
|
999
1037
|
logger.debug(`appending the body of ${child.name}`);
|
|
1000
1038
|
}
|
|
@@ -1017,7 +1055,7 @@
|
|
|
1017
1055
|
}
|
|
1018
1056
|
}
|
|
1019
1057
|
|
|
1020
|
-
attachIn
|
|
1058
|
+
attachIn(tag) {
|
|
1021
1059
|
if (isBrowser) {
|
|
1022
1060
|
var tags = document.subelements(tag);
|
|
1023
1061
|
for (var i = 0, j = tags.length; i < j; i++) {
|
|
@@ -1036,16 +1074,16 @@
|
|
|
1036
1074
|
_QC_CLASSES[name]["__definition"] = definition;
|
|
1037
1075
|
_QC_CLASSES[name]["__definition"]["hierarchy"] = _QC_CLASSES[name]["hierarchy"].bind(_QC_CLASSES[name]["__definition"]);
|
|
1038
1076
|
_QC_CLASSES[name]["__definition"]["__classType"] = name;
|
|
1039
|
-
_QC_CLASSES[name]["__definition"]["__new__"] = function __new__
|
|
1077
|
+
_QC_CLASSES[name]["__definition"]["__new__"] = function __new__(_o_) {
|
|
1040
1078
|
_CastProps(_o_, this);
|
|
1041
1079
|
};
|
|
1042
1080
|
|
|
1043
1081
|
_top[name] = _QC_CLASSES[name];
|
|
1044
|
-
|
|
1082
|
+
|
|
1045
1083
|
return _top[name];
|
|
1046
1084
|
};
|
|
1047
1085
|
|
|
1048
|
-
Class.prototype.toString = function() {
|
|
1086
|
+
Class.prototype.toString = function () {
|
|
1049
1087
|
return "Class(name, type, definition) { [QCObjects native code] }";
|
|
1050
1088
|
};
|
|
1051
1089
|
|
|
@@ -1055,22 +1093,23 @@
|
|
|
1055
1093
|
* @param {String} name
|
|
1056
1094
|
*/
|
|
1057
1095
|
|
|
1058
|
-
var ClassFactory = function(className) {
|
|
1096
|
+
var ClassFactory = function (className) {
|
|
1059
1097
|
var _classFactory;
|
|
1060
|
-
if (className !== null && className.indexOf(".")
|
|
1061
|
-
var packageName = className.split(".").slice(0,className.split(".").length-1).join(".");
|
|
1098
|
+
if (className !== null && className.indexOf(".") > -1) {
|
|
1099
|
+
var packageName = className.split(".").slice(0, className.split(".").length - 1).join(".");
|
|
1062
1100
|
var _className = className.split(".").slice(-1).join("");
|
|
1063
1101
|
var _package = Package(packageName);
|
|
1064
|
-
var packageClasses = (typeof _package !== "undefined")?(_package.filter(classFactory=>{
|
|
1065
|
-
return typeof classFactory !== "undefined"
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1102
|
+
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");
|
|
1108
|
+
}).reverse()) : ([]);
|
|
1109
|
+
if (packageClasses.length > 0) {
|
|
1071
1110
|
_classFactory = packageClasses[0];
|
|
1072
1111
|
}
|
|
1073
|
-
} else if (className !== null && Object.hasOwnProperty.call(_QC_CLASSES,className)) {
|
|
1112
|
+
} else if (className !== null && Object.hasOwnProperty.call(_QC_CLASSES, className)) {
|
|
1074
1113
|
_classFactory = _QC_CLASSES[className];
|
|
1075
1114
|
}
|
|
1076
1115
|
return _classFactory;
|
|
@@ -1086,29 +1125,29 @@
|
|
|
1086
1125
|
};
|
|
1087
1126
|
|
|
1088
1127
|
/**
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1128
|
+
* A replacement for direct using of innerHTML
|
|
1129
|
+
* use: [element].render('content') where 'content' is the string corresponding
|
|
1130
|
+
* to the DOM to insert in the element
|
|
1131
|
+
**/
|
|
1093
1132
|
Element.prototype.render = function QC_Render(content) {
|
|
1094
1133
|
var _self = this;
|
|
1095
|
-
var _appendVDOM = function (_self,content){
|
|
1096
|
-
if (typeof document.implementation.createHTMLDocument !== "undefined"){
|
|
1134
|
+
var _appendVDOM = function (_self, content) {
|
|
1135
|
+
if (typeof document.implementation.createHTMLDocument !== "undefined") {
|
|
1097
1136
|
var doc = document.implementation.createHTMLDocument("");
|
|
1098
1137
|
doc.innerHTML = content;
|
|
1099
|
-
doc.body.subelements("*").map(function (element){
|
|
1138
|
+
doc.body.subelements("*").map(function (element) {
|
|
1100
1139
|
return _self.append(element);
|
|
1101
1140
|
});
|
|
1102
1141
|
}
|
|
1103
1142
|
};
|
|
1104
|
-
if (typeof this.innerHTML !== "undefined"){
|
|
1143
|
+
if (typeof this.innerHTML !== "undefined") {
|
|
1105
1144
|
try {
|
|
1106
1145
|
this.innerHTML += content;
|
|
1107
|
-
}catch (e){
|
|
1108
|
-
_appendVDOM(_self,content);
|
|
1146
|
+
} catch (e) {
|
|
1147
|
+
_appendVDOM(_self, content);
|
|
1109
1148
|
}
|
|
1110
1149
|
} else {
|
|
1111
|
-
_appendVDOM(_self,content);
|
|
1150
|
+
_appendVDOM(_self, content);
|
|
1112
1151
|
}
|
|
1113
1152
|
};
|
|
1114
1153
|
}
|
|
@@ -1122,10 +1161,10 @@
|
|
|
1122
1161
|
* @param {String} classMethodName
|
|
1123
1162
|
* @param {Object} params
|
|
1124
1163
|
*/
|
|
1125
|
-
var _super_ = function(className, classMethodName, params) {
|
|
1164
|
+
var _super_ = function (className, classMethodName, params) {
|
|
1126
1165
|
return ClassFactory(className)[classMethodName];
|
|
1127
1166
|
};
|
|
1128
|
-
_super_.prototype.toString = function() {
|
|
1167
|
+
_super_.prototype.toString = function () {
|
|
1129
1168
|
return "_super_(className,classMethodName,params) { [QCObjects native code] }";
|
|
1130
1169
|
};
|
|
1131
1170
|
|
|
@@ -1136,40 +1175,25 @@
|
|
|
1136
1175
|
* @param {Object} args
|
|
1137
1176
|
*/
|
|
1138
1177
|
|
|
1139
|
-
var New = function(__class__, args) {
|
|
1178
|
+
var New = function (__class__, args) {
|
|
1140
1179
|
args = (arguments.length > 1) ? (args) : ({});
|
|
1141
1180
|
return (typeof __class__ === "undefined") ? (new Object()) : (new __class__(args));
|
|
1142
1181
|
};
|
|
1143
1182
|
|
|
1144
|
-
New.prototype.toString = function() {
|
|
1183
|
+
New.prototype.toString = function () {
|
|
1145
1184
|
return "New(QCObjectsClassName, args) { [QCObjects native code] }";
|
|
1146
1185
|
};
|
|
1147
1186
|
|
|
1148
|
-
var __make_global__ = function (f) {
|
|
1149
|
-
if (typeof f !== "undefined") {
|
|
1150
|
-
if (isBrowser) {
|
|
1151
|
-
try {
|
|
1152
|
-
_top[f.name] = f;
|
|
1153
|
-
window[f.name] = f;
|
|
1154
|
-
} catch (e) {}
|
|
1155
|
-
} else if (typeof global !== "undefined") {
|
|
1156
|
-
if (!Object.hasOwnProperty.call(global,f.name)) {
|
|
1157
|
-
global[f.name] = f;
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
};
|
|
1163
1187
|
|
|
1164
1188
|
var Export = function (f) {
|
|
1165
1189
|
return __make_global__(f);
|
|
1166
1190
|
};
|
|
1167
|
-
Export.prototype.toString = function() {
|
|
1191
|
+
Export.prototype.toString = function () {
|
|
1168
1192
|
return "Export(function or symbol) { [QCObjects native code] }";
|
|
1169
1193
|
};
|
|
1170
1194
|
|
|
1171
1195
|
if (!isBrowser) {
|
|
1172
|
-
var findPackageNodePath = function(packagename) {
|
|
1196
|
+
var findPackageNodePath = function (packagename) {
|
|
1173
1197
|
const fs = require("fs");
|
|
1174
1198
|
var sdkPath = null;
|
|
1175
1199
|
try {
|
|
@@ -1194,7 +1218,7 @@
|
|
|
1194
1218
|
sdkPath = sdkPaths[0];
|
|
1195
1219
|
logger.info(packagename + " is Installed.");
|
|
1196
1220
|
} else {
|
|
1197
|
-
// logger.debug(packagename + ' is not in a standard path.');
|
|
1221
|
+
// logger.debug(packagename + ' is not in a standard path.');
|
|
1198
1222
|
}
|
|
1199
1223
|
} catch (e) {
|
|
1200
1224
|
// do nothing
|
|
@@ -1209,16 +1233,16 @@
|
|
|
1209
1233
|
last_string: "",
|
|
1210
1234
|
last_key: "",
|
|
1211
1235
|
construct: false,
|
|
1212
|
-
_new_
|
|
1236
|
+
_new_(o) {
|
|
1213
1237
|
var string = o["string"];
|
|
1214
|
-
var key = (o.hasOwnProperty.call(o,"key")) ? (o["key"]) : (null);
|
|
1238
|
+
var key = (o.hasOwnProperty.call(o, "key")) ? (o["key"]) : (null);
|
|
1215
1239
|
this.__new__(o);
|
|
1216
1240
|
key = (key === null) ? (this.__instanceID) : (key);
|
|
1217
1241
|
this.last_key = key;
|
|
1218
1242
|
this.last_string = string;
|
|
1219
1243
|
this.construct = true;
|
|
1220
1244
|
},
|
|
1221
|
-
_encrypt
|
|
1245
|
+
_encrypt() {
|
|
1222
1246
|
var string = this.string;
|
|
1223
1247
|
var key = this.key;
|
|
1224
1248
|
var result = "";
|
|
@@ -1233,7 +1257,7 @@
|
|
|
1233
1257
|
this.last_string = Base64.encode(result);
|
|
1234
1258
|
return this.last_string;
|
|
1235
1259
|
},
|
|
1236
|
-
_decrypt
|
|
1260
|
+
_decrypt() {
|
|
1237
1261
|
var string = this.string;
|
|
1238
1262
|
var key = this.key;
|
|
1239
1263
|
var result = "";
|
|
@@ -1250,86 +1274,88 @@
|
|
|
1250
1274
|
this.last_string = result;
|
|
1251
1275
|
return this.last_string;
|
|
1252
1276
|
},
|
|
1253
|
-
encrypt
|
|
1277
|
+
encrypt(string, key) {
|
|
1254
1278
|
var crypt = New(ClassFactory("_Crypt"), {
|
|
1255
1279
|
string: string,
|
|
1256
|
-
key: (key !== "")?(key):("12345678ABC")
|
|
1280
|
+
key: (key !== "") ? (key) : ("12345678ABC")
|
|
1257
1281
|
});
|
|
1258
1282
|
return crypt._encrypt();
|
|
1259
1283
|
},
|
|
1260
|
-
decrypt
|
|
1284
|
+
decrypt(string, key) {
|
|
1261
1285
|
var crypt = New(ClassFactory("_Crypt"), {
|
|
1262
1286
|
string: string,
|
|
1263
|
-
key: (key !== "")?(key):("12345678ABC")
|
|
1287
|
+
key: (key !== "") ? (key) : ("12345678ABC")
|
|
1264
1288
|
});
|
|
1265
1289
|
return crypt._decrypt();
|
|
1266
1290
|
}
|
|
1267
1291
|
});
|
|
1268
1292
|
|
|
1269
|
-
var _CryptObject = function(o) {
|
|
1293
|
+
var _CryptObject = function (o) {
|
|
1270
1294
|
return ClassFactory("_Crypt").encrypt(_DataStringify(o), _secretKey);
|
|
1271
1295
|
};
|
|
1272
|
-
var _DecryptObject = function(s) {
|
|
1273
|
-
return (s === "")?({}):(JSON.parse(ClassFactory("_Crypt").decrypt(s, _secretKey)));
|
|
1296
|
+
var _DecryptObject = function (s) {
|
|
1297
|
+
return (s === "") ? ({}) : (JSON.parse(ClassFactory("_Crypt").decrypt(s, _secretKey)));
|
|
1274
1298
|
};
|
|
1275
1299
|
|
|
1276
1300
|
var shortCode = function () {
|
|
1277
1301
|
var length = 1000;
|
|
1278
|
-
var code1 = ClassFactory("_Crypt").encrypt((Math.random()*length).toString().replace(".", ""), (new Date()).getTime().toString());
|
|
1279
|
-
var code2 = ClassFactory("_Crypt").encrypt((Math.random()*length).toString().replace(".", ""), (new Date((new Date()).getTime() - 1000*1000)).getTime().toString());
|
|
1280
|
-
var shortCode = code2.list().map((o1, index)=> {
|
|
1302
|
+
var code1 = ClassFactory("_Crypt").encrypt((Math.random() * length).toString().replace(".", ""), (new Date()).getTime().toString());
|
|
1303
|
+
var code2 = ClassFactory("_Crypt").encrypt((Math.random() * length).toString().replace(".", ""), (new Date((new Date()).getTime() - 1000 * 1000)).getTime().toString());
|
|
1304
|
+
var shortCode = code2.list().map((o1, index) => {
|
|
1305
|
+
return code1.list()[index] === o1 ? null : o1;
|
|
1306
|
+
}).filter(c => c !== null).join("");
|
|
1281
1307
|
return shortCode;
|
|
1282
1308
|
};
|
|
1283
1309
|
var uniqueId = shortCode;
|
|
1284
1310
|
|
|
1285
1311
|
Class("Processor", {
|
|
1286
1312
|
processors: {
|
|
1287
|
-
"config"
|
|
1288
|
-
return _top.CONFIG.get(arg,"");
|
|
1313
|
+
"config"(arg) {
|
|
1314
|
+
return _top.CONFIG.get(arg, "");
|
|
1289
1315
|
},
|
|
1290
|
-
"ENV"
|
|
1291
|
-
return (typeof process !== "undefined")?(process.env[arg]):("");
|
|
1316
|
+
"ENV"(arg) {
|
|
1317
|
+
return (typeof process !== "undefined") ? (process.env[arg]) : ("");
|
|
1292
1318
|
},
|
|
1293
|
-
"global"
|
|
1294
|
-
return (typeof global !== "undefined")?(global[arg]):("");
|
|
1319
|
+
"global"(arg) {
|
|
1320
|
+
return (typeof global !== "undefined") ? (global[arg]) : ("");
|
|
1295
1321
|
}
|
|
1296
1322
|
},
|
|
1297
|
-
setProcessor
|
|
1298
|
-
if (typeof _proc_ === "function" && _proc_.name !== ""){
|
|
1323
|
+
setProcessor(_proc_) {
|
|
1324
|
+
if (typeof _proc_ === "function" && _proc_.name !== "") {
|
|
1299
1325
|
this.processors[_proc_.name] = _proc_;
|
|
1300
1326
|
}
|
|
1301
1327
|
},
|
|
1302
|
-
execute
|
|
1328
|
+
execute(processorName, args) {
|
|
1303
1329
|
let processorHandler = this;
|
|
1304
1330
|
return processorHandler.processors[processorName].apply(processorHandler, args.split(","));
|
|
1305
1331
|
},
|
|
1306
|
-
process
|
|
1307
|
-
if (typeof template === "string"){
|
|
1332
|
+
process(template) {
|
|
1333
|
+
if (typeof template === "string") {
|
|
1308
1334
|
let processorHandler = this;
|
|
1309
|
-
Object.keys(processorHandler.processors).map(function (funcName){
|
|
1310
|
-
[...template.matchAll(new RegExp("\\$"+funcName+"\\((.*)\\).*","g"))].map(
|
|
1311
|
-
function (procesorMatch){
|
|
1335
|
+
Object.keys(processorHandler.processors).map(function (funcName) {
|
|
1336
|
+
[...template.matchAll(new RegExp("\\$" + funcName + "\\((.*)\\).*", "g"))].map(
|
|
1337
|
+
function (procesorMatch) {
|
|
1312
1338
|
var match0 = `$${funcName}(${procesorMatch[1]})`;
|
|
1313
|
-
template = template.replace(match0,processorHandler.execute.call(processorHandler, funcName, procesorMatch[1]));
|
|
1339
|
+
template = template.replace(match0, processorHandler.execute.call(processorHandler, funcName, procesorMatch[1]));
|
|
1314
1340
|
}
|
|
1315
1341
|
);
|
|
1316
1342
|
});
|
|
1317
1343
|
}
|
|
1318
1344
|
return template;
|
|
1319
1345
|
},
|
|
1320
|
-
processObject
|
|
1346
|
+
processObject(obj) {
|
|
1321
1347
|
let __instance__ = this;
|
|
1322
|
-
if (typeof obj === "object"){
|
|
1348
|
+
if (typeof obj === "object") {
|
|
1323
1349
|
Object.keys(obj).map(
|
|
1324
|
-
function (_k){
|
|
1325
|
-
if (typeof obj[_k] === "object" && !obj[_k].hasOwnProperty.call(obj[_k],"call")){
|
|
1350
|
+
function (_k) {
|
|
1351
|
+
if (typeof obj[_k] === "object" && !obj[_k].hasOwnProperty.call(obj[_k], "call")) {
|
|
1326
1352
|
obj[_k] = __instance__.processObject(obj[_k]);
|
|
1327
|
-
} else if (typeof obj[_k] === "string"){
|
|
1353
|
+
} else if (typeof obj[_k] === "string") {
|
|
1328
1354
|
obj[_k] = __instance__.process(obj[_k]);
|
|
1329
1355
|
}
|
|
1330
1356
|
}
|
|
1331
1357
|
);
|
|
1332
|
-
} else if (typeof obj === "string"){
|
|
1358
|
+
} else if (typeof obj === "string") {
|
|
1333
1359
|
obj = __instance__.process(obj);
|
|
1334
1360
|
}
|
|
1335
1361
|
return obj;
|
|
@@ -1337,52 +1363,52 @@
|
|
|
1337
1363
|
});
|
|
1338
1364
|
|
|
1339
1365
|
class ConfigSettings {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
return this._instance;
|
|
1366
|
+
static _instance = null;
|
|
1367
|
+
static _CONFIG_ENC = null;
|
|
1368
|
+
static get instance() {
|
|
1369
|
+
|
|
1370
|
+
if (this._instance === null) {
|
|
1371
|
+
var _config_settings = new ConfigSettings();
|
|
1372
|
+
_config_settings._CONFIG = {
|
|
1373
|
+
"relativeImportPath": "",
|
|
1374
|
+
"remoteImportsPath": "",
|
|
1375
|
+
"remoteSDKPath": "https://sdk.qcobjects.dev/v2.4/",
|
|
1376
|
+
"asynchronousImportsLoad": false,
|
|
1377
|
+
"removePackageScriptAfterLoading": true,
|
|
1378
|
+
"componentsBasePath": "",
|
|
1379
|
+
"delayForReady": 0,
|
|
1380
|
+
"preserveComponentBodyTag": false,
|
|
1381
|
+
"overrideComponentTag": false,
|
|
1382
|
+
"useConfigService": false,
|
|
1383
|
+
"routingWay": "hash",
|
|
1384
|
+
"useSDK": true,
|
|
1385
|
+
"useLocalSDK": false,
|
|
1386
|
+
"basePath": basePath
|
|
1387
|
+
};
|
|
1388
|
+
_config_settings._CONFIG_ENC = null;
|
|
1389
|
+
this._instance = _config_settings;
|
|
1367
1390
|
}
|
|
1368
1391
|
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1392
|
+
return this._instance;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
static set instance(value) {
|
|
1396
|
+
this._instance = value;
|
|
1397
|
+
}
|
|
1372
1398
|
}
|
|
1373
1399
|
_QC_CLASSES["ConfigSettings"] = ConfigSettings;
|
|
1374
1400
|
|
|
1375
1401
|
Class("CONFIG", Object, {
|
|
1376
1402
|
|
|
1377
|
-
get _CONFIG_ENC
|
|
1403
|
+
get _CONFIG_ENC() {
|
|
1378
1404
|
return ClassFactory("ConfigSettings").instance._CONFIG_ENC;
|
|
1379
1405
|
},
|
|
1380
1406
|
|
|
1381
|
-
get _CONFIG
|
|
1407
|
+
get _CONFIG() {
|
|
1382
1408
|
return ClassFactory("ConfigSettings").instance._CONFIG;
|
|
1383
1409
|
},
|
|
1384
1410
|
|
|
1385
|
-
set
|
|
1411
|
+
set(name, value) {
|
|
1386
1412
|
logger.debug(`CONFIG.set ${name}: ${value}`);
|
|
1387
1413
|
// hack to force update basePath from CONFIG
|
|
1388
1414
|
if (name === "basePath") {
|
|
@@ -1391,8 +1417,8 @@
|
|
|
1391
1417
|
var _conf;
|
|
1392
1418
|
try {
|
|
1393
1419
|
_conf = (
|
|
1394
|
-
function(config) {
|
|
1395
|
-
if (config._CONFIG_ENC === null){
|
|
1420
|
+
function (config) {
|
|
1421
|
+
if (config._CONFIG_ENC === null) {
|
|
1396
1422
|
config._CONFIG_ENC = ClassFactory("_Crypt").encrypt(_DataStringify({}), _secretKey);
|
|
1397
1423
|
}
|
|
1398
1424
|
var _protectedEnc = config._CONFIG_ENC.valueOf();
|
|
@@ -1402,22 +1428,22 @@
|
|
|
1402
1428
|
)(ClassFactory("ConfigSettings").instance);
|
|
1403
1429
|
} catch (e) {
|
|
1404
1430
|
_conf = {};
|
|
1405
|
-
console.error
|
|
1431
|
+
console.error(e);
|
|
1406
1432
|
logger.debug("failed to encrypt config");
|
|
1407
1433
|
}
|
|
1408
1434
|
|
|
1409
1435
|
_conf[name] = value;
|
|
1410
1436
|
ClassFactory("ConfigSettings").instance._CONFIG_ENC = _CryptObject(_conf);
|
|
1411
|
-
if (Object.hasOwnProperty.call(ClassFactory("ConfigSettings").instance, "_CONFIG") && Object.hasOwnProperty.call(ClassFactory("ConfigSettings").instance._CONFIG,name)) {
|
|
1437
|
+
if (Object.hasOwnProperty.call(ClassFactory("ConfigSettings").instance, "_CONFIG") && Object.hasOwnProperty.call(ClassFactory("ConfigSettings").instance._CONFIG, name)) {
|
|
1412
1438
|
ClassFactory("ConfigSettings").instance._CONFIG[name] = value;
|
|
1413
1439
|
}
|
|
1414
1440
|
},
|
|
1415
|
-
get
|
|
1441
|
+
get(name, _default) {
|
|
1416
1442
|
var _value;
|
|
1417
1443
|
try {
|
|
1418
1444
|
var _conf = (
|
|
1419
|
-
function(config) {
|
|
1420
|
-
if (config._CONFIG_ENC === null){
|
|
1445
|
+
function (config) {
|
|
1446
|
+
if (config._CONFIG_ENC === null) {
|
|
1421
1447
|
config._CONFIG_ENC = ClassFactory("_Crypt").encrypt(_DataStringify({}), _secretKey);
|
|
1422
1448
|
}
|
|
1423
1449
|
var _protectedEnc = config._CONFIG_ENC.valueOf();
|
|
@@ -1425,21 +1451,21 @@
|
|
|
1425
1451
|
return _CastProps(_protectedConf, _DecryptObject(_protectedEnc));
|
|
1426
1452
|
}
|
|
1427
1453
|
)(ClassFactory("ConfigSettings").instance);
|
|
1428
|
-
if (typeof _conf[name] !== "undefined"){
|
|
1454
|
+
if (typeof _conf[name] !== "undefined") {
|
|
1429
1455
|
_value = _conf[name];
|
|
1430
|
-
} else
|
|
1456
|
+
} else if (typeof _default !== "undefined") {
|
|
1431
1457
|
_value = _default;
|
|
1432
1458
|
}
|
|
1433
|
-
} catch (e){
|
|
1434
|
-
console.error
|
|
1459
|
+
} catch (e) {
|
|
1460
|
+
console.error(e);
|
|
1435
1461
|
logger.debug("Something wrong when trying to get CONFIG values");
|
|
1436
|
-
logger.debug("No config value for: "+name);
|
|
1462
|
+
logger.debug("No config value for: " + name);
|
|
1437
1463
|
_value = _default;
|
|
1438
1464
|
}
|
|
1439
|
-
return ClassFactory("Processor").processObject.call(ClassFactory("Processor"),_value);
|
|
1465
|
+
return ClassFactory("Processor").processObject.call(ClassFactory("Processor"), _value);
|
|
1440
1466
|
}
|
|
1441
1467
|
});
|
|
1442
|
-
|
|
1468
|
+
|
|
1443
1469
|
Export(waitUntil);
|
|
1444
1470
|
Export(_super_);
|
|
1445
1471
|
Export(ComplexStorageCache);
|
|
@@ -1449,22 +1475,22 @@
|
|
|
1449
1475
|
Export(__getType__);
|
|
1450
1476
|
Export(is_a);
|
|
1451
1477
|
|
|
1452
|
-
var isQCObjects_Object = function (_){
|
|
1453
|
-
return (typeof _ === "object"
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1478
|
+
var isQCObjects_Object = function (_) {
|
|
1479
|
+
return (typeof _ === "object" &&
|
|
1480
|
+
Object.hasOwnProperty.call(_, "__classType") &&
|
|
1481
|
+
(!!_.__instanceID) &&
|
|
1482
|
+
Object.hasOwnProperty.call(_, "__definition") &&
|
|
1483
|
+
typeof _.__definition !== "undefined"
|
|
1484
|
+
) ? (true) : (false);
|
|
1459
1485
|
};
|
|
1460
1486
|
|
|
1461
|
-
var isQCObjects_Class = function (_){
|
|
1462
|
-
return (typeof _ === "function"
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1487
|
+
var isQCObjects_Class = function (_) {
|
|
1488
|
+
return (typeof _ === "function" &&
|
|
1489
|
+
(!_.__instanceID) &&
|
|
1490
|
+
(!!_.__definition) &&
|
|
1491
|
+
typeof _.__definition !== "undefined" &&
|
|
1492
|
+
!!_.__definition.__classType
|
|
1493
|
+
) ? (true) : (false);
|
|
1468
1494
|
};
|
|
1469
1495
|
|
|
1470
1496
|
/**
|
|
@@ -1473,56 +1499,69 @@
|
|
|
1473
1499
|
* @param {Object} namespace
|
|
1474
1500
|
* @param {Object} classes
|
|
1475
1501
|
*/
|
|
1476
|
-
var Package = function(namespace, classes) {
|
|
1477
|
-
if (_QC_PACKAGES.hasOwnProperty.call(_QC_PACKAGES,namespace) &&
|
|
1502
|
+
var Package = function (namespace, classes) {
|
|
1503
|
+
if (_QC_PACKAGES.hasOwnProperty.call(_QC_PACKAGES, namespace) &&
|
|
1478
1504
|
typeof _QC_PACKAGES[namespace] !== "undefined" &&
|
|
1479
|
-
_QC_PACKAGES[namespace].hasOwnProperty.call(_QC_PACKAGES[namespace],"length") &&
|
|
1505
|
+
_QC_PACKAGES[namespace].hasOwnProperty.call(_QC_PACKAGES[namespace], "length") &&
|
|
1480
1506
|
_QC_PACKAGES[namespace].length > 0 &&
|
|
1481
1507
|
typeof classes !== "undefined" &&
|
|
1482
|
-
classes.hasOwnProperty.call(classes,"length") &&
|
|
1508
|
+
classes.hasOwnProperty.call(classes, "length") &&
|
|
1483
1509
|
classes.length > 0
|
|
1484
1510
|
) {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
});
|
|
1511
|
+
classes.filter(
|
|
1512
|
+
function (_c1) {
|
|
1513
|
+
return isQCObjects_Class(_c1);
|
|
1514
|
+
}
|
|
1515
|
+
).map(function (_class_) {
|
|
1516
|
+
_class_.__definition.__namespace = namespace;
|
|
1517
|
+
});
|
|
1493
1518
|
_QC_PACKAGES[namespace] = _QC_PACKAGES[namespace].concat(classes);
|
|
1494
|
-
} else if (typeof classes !== "undefined"){
|
|
1495
|
-
if (typeof classes === "object" && classes.hasOwnProperty.call(classes,"length")){
|
|
1519
|
+
} else if (typeof classes !== "undefined") {
|
|
1520
|
+
if (typeof classes === "object" && classes.hasOwnProperty.call(classes, "length")) {
|
|
1496
1521
|
classes.filter(
|
|
1497
|
-
function (_c1){
|
|
1522
|
+
function (_c1) {
|
|
1498
1523
|
return isQCObjects_Class(_c1);
|
|
1499
1524
|
}
|
|
1500
|
-
).map(function (_class_){
|
|
1525
|
+
).map(function (_class_) {
|
|
1501
1526
|
_class_.__definition.__namespace = namespace;
|
|
1502
|
-
__register_class__(_class_);
|
|
1503
1527
|
});
|
|
1504
1528
|
} else if (isQCObjects_Class(classes)) {
|
|
1505
1529
|
classes.__definition.__namespace = namespace;
|
|
1506
|
-
__register_class__(classes);
|
|
1507
1530
|
}
|
|
1508
1531
|
_QC_PACKAGES[namespace] = classes;
|
|
1509
1532
|
}
|
|
1510
|
-
|
|
1533
|
+
if (Object.hasOwnProperty.call(_QC_PACKAGES, namespace)) {
|
|
1534
|
+
_QC_PACKAGES[namespace].map(function (_class_) {
|
|
1535
|
+
__register_class__(_class_);
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
return (Object.hasOwnProperty.call(_QC_PACKAGES, namespace)) ? (_QC_PACKAGES[namespace]) : (undefined);
|
|
1511
1539
|
};
|
|
1512
|
-
Package.prototype.toString = function() {
|
|
1540
|
+
Package.prototype.toString = function () {
|
|
1513
1541
|
return "Package(namespace, classes) { [QCObjects native code] }";
|
|
1514
1542
|
};
|
|
1515
1543
|
|
|
1516
1544
|
/**
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
var NamespaceRef = function (namespace){
|
|
1545
|
+
* Declare Namespace
|
|
1546
|
+
*
|
|
1547
|
+
* @param {String} packageName
|
|
1548
|
+
* @param {Object} package
|
|
1549
|
+
*/
|
|
1550
|
+
var NamespaceRef = function (namespace) {
|
|
1523
1551
|
let packageInstance = Package(namespace);
|
|
1524
|
-
let classes = packageInstance.filter(c=>isQCObjects_Class(c)).map(c=>
|
|
1525
|
-
|
|
1552
|
+
let classes = packageInstance.filter(c => isQCObjects_Class(c)).map(c => {
|
|
1553
|
+
return {
|
|
1554
|
+
[c.__definition.__classType]: c
|
|
1555
|
+
};
|
|
1556
|
+
}).reduce((a, b) => Object.assign(a, b));
|
|
1557
|
+
return namespace.split(".").map(c => {
|
|
1558
|
+
return {
|
|
1559
|
+
[c]: classes
|
|
1560
|
+
};
|
|
1561
|
+
}).reverse().reduce((a, b) => {
|
|
1562
|
+
b[Object.keys(b)] = a;
|
|
1563
|
+
return b;
|
|
1564
|
+
});
|
|
1526
1565
|
};
|
|
1527
1566
|
|
|
1528
1567
|
|
|
@@ -1533,9 +1572,9 @@
|
|
|
1533
1572
|
* @param {Object} ready
|
|
1534
1573
|
* @param {Boolean} external
|
|
1535
1574
|
*/
|
|
1536
|
-
var Import = function() {
|
|
1575
|
+
var Import = function () {
|
|
1537
1576
|
var packagename;
|
|
1538
|
-
var ready = function() {};
|
|
1577
|
+
var ready = function () {};
|
|
1539
1578
|
var external = false;
|
|
1540
1579
|
if (arguments.length < 1) {
|
|
1541
1580
|
return;
|
|
@@ -1557,9 +1596,9 @@
|
|
|
1557
1596
|
}
|
|
1558
1597
|
var _promise_import_;
|
|
1559
1598
|
if (isBrowser) {
|
|
1560
|
-
_promise_import_ = new Promise(function(resolve, reject) {
|
|
1599
|
+
_promise_import_ = new Promise(function (resolve, reject) {
|
|
1561
1600
|
|
|
1562
|
-
var allPackagesImported = function() {
|
|
1601
|
+
var allPackagesImported = function () {
|
|
1563
1602
|
var ret = false;
|
|
1564
1603
|
var cp = 0;
|
|
1565
1604
|
for (var p in _QC_PACKAGES) {
|
|
@@ -1573,14 +1612,14 @@
|
|
|
1573
1612
|
return ret;
|
|
1574
1613
|
};
|
|
1575
1614
|
|
|
1576
|
-
var readyImported = function(e) {
|
|
1615
|
+
var readyImported = function (e) {
|
|
1577
1616
|
_QC_PACKAGES_IMPORTED.push(ready);
|
|
1578
1617
|
if (allPackagesImported()) {
|
|
1579
|
-
_QC_PACKAGES_IMPORTED.map(function (_imported_){
|
|
1618
|
+
_QC_PACKAGES_IMPORTED.map(function (_imported_) {
|
|
1580
1619
|
_QC_READY_LISTENERS.push(_imported_);
|
|
1581
1620
|
});
|
|
1582
1621
|
}
|
|
1583
|
-
if (isBrowser && _top.CONFIG.get("removePackageScriptAfterLoading")){
|
|
1622
|
+
if (isBrowser && _top.CONFIG.get("removePackageScriptAfterLoading")) {
|
|
1584
1623
|
e.target.remove();
|
|
1585
1624
|
}
|
|
1586
1625
|
resolve.call(_promise_import_, {
|
|
@@ -1589,17 +1628,17 @@
|
|
|
1589
1628
|
});
|
|
1590
1629
|
};
|
|
1591
1630
|
|
|
1592
|
-
if (!_QC_PACKAGES.hasOwnProperty.call(_QC_PACKAGES,packagename)) {
|
|
1631
|
+
if (!_QC_PACKAGES.hasOwnProperty.call(_QC_PACKAGES, packagename)) {
|
|
1593
1632
|
var s1 = _DOMCreateElement("script");
|
|
1594
1633
|
s1.type = _top.CONFIG.get("sourceType", "text/javascript");
|
|
1595
1634
|
s1.async = (_top.CONFIG.get("asynchronousImportsLoad")) ? (true) : (false);
|
|
1596
|
-
s1.onreadystatechange = function() {
|
|
1635
|
+
s1.onreadystatechange = function () {
|
|
1597
1636
|
if (s1.readyState === "complete") {
|
|
1598
1637
|
readyImported.call();
|
|
1599
1638
|
}
|
|
1600
1639
|
};
|
|
1601
1640
|
s1.onload = readyImported;
|
|
1602
|
-
s1.onerror = function(e) {
|
|
1641
|
+
s1.onerror = function (e) {
|
|
1603
1642
|
reject.call(_promise_import_, {
|
|
1604
1643
|
"_imported_": s1,
|
|
1605
1644
|
"_package_name_": packagename
|
|
@@ -1609,13 +1648,13 @@
|
|
|
1609
1648
|
document.getElementsByTagName("head")[0].appendChild(s1);
|
|
1610
1649
|
}
|
|
1611
1650
|
});
|
|
1612
|
-
_promise_import_.catch(function() {
|
|
1651
|
+
_promise_import_.catch(function () {
|
|
1613
1652
|
logger.debug("Import: Error loading a package ");
|
|
1614
1653
|
});
|
|
1615
1654
|
|
|
1616
1655
|
} else {
|
|
1617
1656
|
// support to be used in a nodejs environment
|
|
1618
|
-
_promise_import_ = new Promise(function(resolve, reject) {
|
|
1657
|
+
_promise_import_ = new Promise(function (resolve, reject) {
|
|
1619
1658
|
try {
|
|
1620
1659
|
var standardNodePath = findPackageNodePath(packagename);
|
|
1621
1660
|
var packageAbsoluteName = "";
|
|
@@ -1634,29 +1673,32 @@
|
|
|
1634
1673
|
"_imported_": require(`${packageAbsoluteName}`),
|
|
1635
1674
|
"_package_name_": packagename
|
|
1636
1675
|
});
|
|
1637
|
-
}catch (e){
|
|
1638
|
-
console.log(e);
|
|
1676
|
+
} catch (e) {
|
|
1639
1677
|
reject.call(_promise_import_, {
|
|
1640
1678
|
"_imported_": null,
|
|
1641
|
-
"_package_name_": packagename
|
|
1679
|
+
"_package_name_": packagename,
|
|
1680
|
+
"error": e
|
|
1642
1681
|
});
|
|
1643
1682
|
}
|
|
1644
1683
|
} catch (e) {
|
|
1645
|
-
console.log(e);
|
|
1646
1684
|
reject.call(_promise_import_, {
|
|
1647
1685
|
"_imported_": null,
|
|
1648
|
-
"_package_name_": packagename
|
|
1686
|
+
"_package_name_": packagename,
|
|
1687
|
+
"error": e
|
|
1649
1688
|
});
|
|
1650
1689
|
}
|
|
1651
|
-
}).catch(function(e) {
|
|
1690
|
+
}).catch(function (e) {
|
|
1652
1691
|
// something wrong importing a package
|
|
1653
|
-
console.log(e);
|
|
1654
1692
|
logger.debug("Something happened when importing " + packagename);
|
|
1693
|
+
console.warn(e);
|
|
1655
1694
|
});
|
|
1656
1695
|
}
|
|
1696
|
+
_promise_import_.catch(function (e) {
|
|
1697
|
+
logger.warn(_DataStringify(e));
|
|
1698
|
+
});
|
|
1657
1699
|
return _promise_import_;
|
|
1658
1700
|
};
|
|
1659
|
-
Import.prototype.toString = function() {
|
|
1701
|
+
Import.prototype.toString = function () {
|
|
1660
1702
|
return "Import(packagename,ready,external) { [QCObjects native code] }";
|
|
1661
1703
|
};
|
|
1662
1704
|
|
|
@@ -1672,31 +1714,31 @@
|
|
|
1672
1714
|
}
|
|
1673
1715
|
|
|
1674
1716
|
Class("TagElements", Array, {
|
|
1675
|
-
show
|
|
1676
|
-
this.map(function(element) {
|
|
1717
|
+
show() {
|
|
1718
|
+
this.map(function (element) {
|
|
1677
1719
|
return element.style.opacity = 1;
|
|
1678
1720
|
});
|
|
1679
1721
|
},
|
|
1680
|
-
hide
|
|
1681
|
-
this.map(function(element) {
|
|
1722
|
+
hide() {
|
|
1723
|
+
this.map(function (element) {
|
|
1682
1724
|
return element.style.opacity = 0;
|
|
1683
1725
|
});
|
|
1684
1726
|
},
|
|
1685
|
-
effect
|
|
1727
|
+
effect() {
|
|
1686
1728
|
var effectArguments = [...arguments].slice(1);
|
|
1687
1729
|
var effectClass = arguments[0];
|
|
1688
1730
|
if ((typeof effectClass).toLowerCase() === "string") {
|
|
1689
1731
|
effectClass = ClassFactory(effectClass);
|
|
1690
1732
|
}
|
|
1691
|
-
this.map(function(element) {
|
|
1733
|
+
this.map(function (element) {
|
|
1692
1734
|
return effectClass.apply.apply(effectClass, [element].concat(effectArguments));
|
|
1693
1735
|
});
|
|
1694
1736
|
},
|
|
1695
|
-
findElements
|
|
1737
|
+
findElements(elementName) {
|
|
1696
1738
|
var _o = New(ClassFactory("TagElements"));
|
|
1697
1739
|
if (isBrowser) {
|
|
1698
1740
|
for (var _k in this) {
|
|
1699
|
-
if (typeof _k === "number" && typeof this[_k] !== "function" && this[_k].hasOwnProperty.call(this[_k],"subelements")) {
|
|
1741
|
+
if (typeof _k === "number" && typeof this[_k] !== "function" && this[_k].hasOwnProperty.call(this[_k], "subelements")) {
|
|
1700
1742
|
_o.push(this[_k].subelements(elementName));
|
|
1701
1743
|
}
|
|
1702
1744
|
}
|
|
@@ -1713,13 +1755,13 @@
|
|
|
1713
1755
|
* @param {Object} tagname
|
|
1714
1756
|
* @param {Object} innerHTML
|
|
1715
1757
|
*/
|
|
1716
|
-
var Tag = function(tagname, innerHTML) {
|
|
1758
|
+
var Tag = function (tagname, innerHTML) {
|
|
1717
1759
|
var _o = New(ClassFactory("TagElements"));
|
|
1718
1760
|
if (isBrowser) {
|
|
1719
1761
|
var o = document.subelements(tagname);
|
|
1720
1762
|
var addedKeys = [];
|
|
1721
1763
|
for (var _i = 0; _i < o.length; _i++) {
|
|
1722
|
-
if (typeof innerHTML !== "undefined" && o[_i].hasOwnProperty.call(o[_i],"innerHTML")) {
|
|
1764
|
+
if (typeof innerHTML !== "undefined" && o[_i].hasOwnProperty.call(o[_i], "innerHTML")) {
|
|
1723
1765
|
o[_i].innerHTML = innerHTML;
|
|
1724
1766
|
}
|
|
1725
1767
|
if (addedKeys.indexOf(_i) < 0) {
|
|
@@ -1750,9 +1792,9 @@
|
|
|
1750
1792
|
*
|
|
1751
1793
|
* @param {Object} e
|
|
1752
1794
|
*/
|
|
1753
|
-
var _Ready = function(e) {
|
|
1754
|
-
var _execReady = function() {
|
|
1755
|
-
_QC_READY_LISTENERS.map(function (_ready_listener_,_r){
|
|
1795
|
+
var _Ready = function (e) {
|
|
1796
|
+
var _execReady = function () {
|
|
1797
|
+
_QC_READY_LISTENERS.map(function (_ready_listener_, _r) {
|
|
1756
1798
|
if (typeof _ready_listener_ === "function") {
|
|
1757
1799
|
_ready_listener_.call();
|
|
1758
1800
|
delete _QC_READY_LISTENERS[_r];
|
|
@@ -1798,7 +1840,7 @@
|
|
|
1798
1840
|
* });
|
|
1799
1841
|
*
|
|
1800
1842
|
*/
|
|
1801
|
-
class DDO extends ClassFactory
|
|
1843
|
+
class DDO extends ClassFactory("InheritClass") {
|
|
1802
1844
|
constructor({
|
|
1803
1845
|
instance,
|
|
1804
1846
|
name,
|
|
@@ -1823,7 +1865,7 @@
|
|
|
1823
1865
|
|
|
1824
1866
|
}
|
|
1825
1867
|
|
|
1826
|
-
_new_
|
|
1868
|
+
_new_({
|
|
1827
1869
|
instance,
|
|
1828
1870
|
name,
|
|
1829
1871
|
fget,
|
|
@@ -1843,14 +1885,14 @@
|
|
|
1843
1885
|
} else {
|
|
1844
1886
|
ret = _value;
|
|
1845
1887
|
}
|
|
1846
|
-
instance["_"+name] = ret;
|
|
1888
|
+
instance["_" + name] = ret;
|
|
1847
1889
|
return;
|
|
1848
1890
|
},
|
|
1849
1891
|
get() {
|
|
1850
|
-
let _value = instance["_"+name];
|
|
1892
|
+
let _value = instance["_" + name];
|
|
1851
1893
|
logger.debug("returning value " + name);
|
|
1852
|
-
var is_ddo = function(v) {
|
|
1853
|
-
if (typeof v === "object" && Object.hasOwnProperty.call(v,"value")) {
|
|
1894
|
+
var is_ddo = function (v) {
|
|
1895
|
+
if (typeof v === "object" && Object.hasOwnProperty.call(v, "value")) {
|
|
1854
1896
|
return v.value;
|
|
1855
1897
|
}
|
|
1856
1898
|
return v;
|
|
@@ -1867,11 +1909,11 @@
|
|
|
1867
1909
|
}
|
|
1868
1910
|
|
|
1869
1911
|
}
|
|
1870
|
-
Export
|
|
1912
|
+
Export(DDO);
|
|
1871
1913
|
|
|
1872
1914
|
Class("DefaultTemplateHandler", Object, {
|
|
1873
1915
|
template: "",
|
|
1874
|
-
assign
|
|
1916
|
+
assign(data) {
|
|
1875
1917
|
var templateInstance = this;
|
|
1876
1918
|
if (typeof templateInstance.component === "undefined") {
|
|
1877
1919
|
throw new Error("DefaultTemplateHandler.assign: component is undefined");
|
|
@@ -1880,39 +1922,41 @@
|
|
|
1880
1922
|
throw new Error("DefaultTemplateHandler.assign: component.processorHandler is undefined");
|
|
1881
1923
|
}
|
|
1882
1924
|
var processorHandler = templateInstance.component.processorHandler;
|
|
1883
|
-
var parsedAssignmentText = (typeof templateInstance.template !== "undefined")?(templateInstance.template):("");
|
|
1884
|
-
if (typeof data === "object"){
|
|
1885
|
-
[...Object.keys(data)].map(function (k){
|
|
1925
|
+
var parsedAssignmentText = (typeof templateInstance.template !== "undefined") ? (templateInstance.template) : ("");
|
|
1926
|
+
if (typeof data === "object") {
|
|
1927
|
+
[...Object.keys(data)].map(function (k) {
|
|
1886
1928
|
var _value = data[k];
|
|
1887
|
-
if (typeof _value === "string" || typeof _value === "number" || (!isNaN(_value))){
|
|
1929
|
+
if (typeof _value === "string" || typeof _value === "number" || (!isNaN(_value))) {
|
|
1888
1930
|
try {
|
|
1889
|
-
_value = ClassFactory("Processor").processObject.call(processorHandler,_value);
|
|
1931
|
+
_value = ClassFactory("Processor").processObject.call(processorHandler, _value);
|
|
1890
1932
|
parsedAssignmentText = parsedAssignmentText.replace((new RegExp(`{{${k}}}`, "g")), _value);
|
|
1891
|
-
}catch (e){
|
|
1933
|
+
} catch (e) {
|
|
1892
1934
|
logger.warn(e);
|
|
1893
1935
|
}
|
|
1894
1936
|
}
|
|
1895
1937
|
});
|
|
1896
1938
|
} else {
|
|
1897
|
-
logger.debug
|
|
1939
|
+
logger.debug(`${templateInstance.component.name}.data is not an object`);
|
|
1898
1940
|
}
|
|
1899
|
-
parsedAssignmentText = ClassFactory("Processor").processObject.call(processorHandler,parsedAssignmentText);
|
|
1941
|
+
parsedAssignmentText = ClassFactory("Processor").processObject.call(processorHandler, parsedAssignmentText);
|
|
1900
1942
|
return parsedAssignmentText;
|
|
1901
1943
|
}
|
|
1902
1944
|
});
|
|
1903
1945
|
|
|
1904
|
-
var __routing_params__ = function (routing, routingPath){
|
|
1905
|
-
let standardRoutingPath = routing.path.replace(/{(.*?)}/g,"(?<$1>.*)"); //allowing {param}
|
|
1906
|
-
return {
|
|
1946
|
+
var __routing_params__ = function (routing, routingPath) {
|
|
1947
|
+
let standardRoutingPath = routing.path.replace(/{(.*?)}/g, "(?<$1>.*)"); //allowing {param}
|
|
1948
|
+
return {
|
|
1949
|
+
...[...routingPath.matchAll((new RegExp(standardRoutingPath, "g")))][0]["groups"]
|
|
1950
|
+
};
|
|
1907
1951
|
};
|
|
1908
1952
|
|
|
1909
|
-
var __valid_routings__ = function (routings, routingPath){
|
|
1910
|
-
return routings.filter(function(routing) {
|
|
1911
|
-
var standardRoutingPath = routing.path.replace(/{(.*?)}/g,"(?<$1>.*)");
|
|
1953
|
+
var __valid_routings__ = function (routings, routingPath) {
|
|
1954
|
+
return routings.filter(function (routing) {
|
|
1955
|
+
var standardRoutingPath = routing.path.replace(/{(.*?)}/g, "(?<$1>.*)");
|
|
1912
1956
|
return (new RegExp(standardRoutingPath, "g")).test(routingPath);
|
|
1913
1957
|
}).reverse();
|
|
1914
1958
|
};
|
|
1915
|
-
var __valid_routing_way__ = function (validRoutingWays, routingWay){
|
|
1959
|
+
var __valid_routing_way__ = function (validRoutingWays, routingWay) {
|
|
1916
1960
|
return validRoutingWays.includes(routingWay);
|
|
1917
1961
|
};
|
|
1918
1962
|
|
|
@@ -1921,12 +1965,12 @@
|
|
|
1921
1965
|
{
|
|
1922
1966
|
if (isBrowser) {
|
|
1923
1967
|
if (!_top._bindroute_.__assigned) {
|
|
1924
|
-
document.addEventListener("componentsloaded", function(e) {
|
|
1968
|
+
document.addEventListener("componentsloaded", function (e) {
|
|
1925
1969
|
e.stopImmediatePropagation();
|
|
1926
1970
|
e.stopPropagation();
|
|
1927
1971
|
if (!_top._bindroute_.__assigned) {
|
|
1928
1972
|
|
|
1929
|
-
_top.onpopstate = function(e) {
|
|
1973
|
+
_top.onpopstate = function (e) {
|
|
1930
1974
|
e.stopImmediatePropagation();
|
|
1931
1975
|
e.stopPropagation();
|
|
1932
1976
|
ClassFactory("Component").route();
|
|
@@ -1934,9 +1978,9 @@
|
|
|
1934
1978
|
e.target.__oldpopstate.call(e.target, e);
|
|
1935
1979
|
}
|
|
1936
1980
|
};
|
|
1937
|
-
Tag("a").map(function(a) {
|
|
1981
|
+
Tag("a").map(function (a) {
|
|
1938
1982
|
a.oldclick = a.onclick;
|
|
1939
|
-
a.onclick = function(e) {
|
|
1983
|
+
a.onclick = function (e) {
|
|
1940
1984
|
var _ret_ = true;
|
|
1941
1985
|
if (!_top.global.get("routingPaths")) {
|
|
1942
1986
|
_top.global.set("routingPaths", []);
|
|
@@ -1975,7 +2019,7 @@
|
|
|
1975
2019
|
}
|
|
1976
2020
|
}
|
|
1977
2021
|
};
|
|
1978
|
-
Class
|
|
2022
|
+
Class("Component", ClassFactory("InheritClass"), {
|
|
1979
2023
|
domain: domain,
|
|
1980
2024
|
basePath: basePath,
|
|
1981
2025
|
templateURI: "",
|
|
@@ -1988,38 +2032,38 @@
|
|
|
1988
2032
|
method: "GET",
|
|
1989
2033
|
data: {},
|
|
1990
2034
|
reload: false,
|
|
1991
|
-
shadowed:false,
|
|
2035
|
+
shadowed: false,
|
|
1992
2036
|
cached: true,
|
|
1993
|
-
done
|
|
2037
|
+
done() {
|
|
1994
2038
|
//TODO: default done method
|
|
1995
2039
|
},
|
|
1996
|
-
fail
|
|
2040
|
+
fail() {
|
|
1997
2041
|
//TODO: default fail method
|
|
1998
2042
|
},
|
|
1999
|
-
set
|
|
2043
|
+
set(name, value) {
|
|
2000
2044
|
this[name] = value;
|
|
2001
2045
|
},
|
|
2002
|
-
get
|
|
2046
|
+
get(name) {
|
|
2003
2047
|
return this[name];
|
|
2004
|
-
},
|
|
2048
|
+
},
|
|
2005
2049
|
__promise__: null,
|
|
2006
|
-
feedComponent
|
|
2050
|
+
feedComponent() {
|
|
2007
2051
|
var _component_ = this;
|
|
2008
|
-
var _feedComponent_InBrowser = function (_component_){
|
|
2052
|
+
var _feedComponent_InBrowser = function (_component_) {
|
|
2009
2053
|
if (typeof _component_.container === "undefined" && typeof _component_.body === "undefined") {
|
|
2010
|
-
logger.warn
|
|
2054
|
+
logger.warn("COMPONENT {{NAME}} has an undefined container and body".replace("{{NAME}}", _component_.name));
|
|
2011
2055
|
return;
|
|
2012
2056
|
}
|
|
2013
2057
|
var container = (typeof _component_.container === "undefined" || _component_.container === null) ? (_component_.body) : (_component_.container);
|
|
2014
2058
|
var parsedAssignmentText = _component_.parsedAssignmentText;
|
|
2015
2059
|
_component_.innerHTML = parsedAssignmentText;
|
|
2016
|
-
if (_component_.shadowed){
|
|
2060
|
+
if (_component_.shadowed) {
|
|
2017
2061
|
logger.debug("COMPONENT {{NAME}} is shadowed".replace("{{NAME}}", _component_.name));
|
|
2018
2062
|
logger.debug("Preparing slots for Shadowed COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
|
|
2019
2063
|
var tmp_shadowContainer = _DOMCreateElement("div");
|
|
2020
2064
|
container.subelements("[slot]").map(
|
|
2021
|
-
function (c){
|
|
2022
|
-
if (c.parentElement===container){
|
|
2065
|
+
function (c) {
|
|
2066
|
+
if (c.parentElement === container) {
|
|
2023
2067
|
tmp_shadowContainer.appendChild(c);
|
|
2024
2068
|
}
|
|
2025
2069
|
});
|
|
@@ -2027,16 +2071,18 @@
|
|
|
2027
2071
|
var shadowContainer = _DOMCreateElement("div");
|
|
2028
2072
|
shadowContainer.classList.add("shadowHost");
|
|
2029
2073
|
try {
|
|
2030
|
-
_component_.shadowRoot = shadowContainer.attachShadow({
|
|
2031
|
-
|
|
2074
|
+
_component_.shadowRoot = shadowContainer.attachShadow({
|
|
2075
|
+
mode: "open"
|
|
2076
|
+
});
|
|
2077
|
+
} catch (e) {
|
|
2032
2078
|
try {
|
|
2033
2079
|
logger.debug("Shadowed COMPONENT {{NAME}} is repeated".replace("{{NAME}}", _component_.name));
|
|
2034
2080
|
_component_.shadowRoot = shadowContainer.shadowRoot;
|
|
2035
|
-
} catch (e){
|
|
2081
|
+
} catch (e) {
|
|
2036
2082
|
logger.warn("Shadowed COMPONENT {{NAME}} is not allowed on this browser".replace("{{NAME}}", _component_.name));
|
|
2037
2083
|
}
|
|
2038
2084
|
}
|
|
2039
|
-
if (typeof _component_.shadowRoot !== "undefined" && _component_.shadowRoot !== null){
|
|
2085
|
+
if (typeof _component_.shadowRoot !== "undefined" && _component_.shadowRoot !== null) {
|
|
2040
2086
|
if (_component_.reload) {
|
|
2041
2087
|
logger.debug("FORCED RELOADING OF CONTAINER FOR Shadowed COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
|
|
2042
2088
|
shadowContainer.shadowRoot.innerHTML = _component_.innerHTML;
|
|
@@ -2048,7 +2094,7 @@
|
|
|
2048
2094
|
logger.debug("ADDING Slots to Shadowed COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
|
|
2049
2095
|
shadowContainer.innerHTML += tmp_shadowContainer.innerHTML;
|
|
2050
2096
|
logger.debug("APPENDING Shadowed COMPONENT {{NAME}} to Container ".replace("{{NAME}}", _component_.name));
|
|
2051
|
-
if (container.subelements(".shadowHost")<1){
|
|
2097
|
+
if (container.subelements(".shadowHost") < 1) {
|
|
2052
2098
|
container.appendChild(shadowContainer);
|
|
2053
2099
|
} else {
|
|
2054
2100
|
logger.debug("Shadowed Container for COMPONENT {{NAME}} is already present in the tree ".replace("{{NAME}}", _component_.name));
|
|
@@ -2062,7 +2108,7 @@
|
|
|
2062
2108
|
if (_component_.reload) {
|
|
2063
2109
|
logger.debug("FORCED RELOADING OF CONTAINER FOR COMPONENT {{NAME}}".replace("{{NAME}}", _component_.name));
|
|
2064
2110
|
container.innerHTML = _component_.innerHTML;
|
|
2065
|
-
} else if (container && _component_){
|
|
2111
|
+
} else if (container && _component_) {
|
|
2066
2112
|
logger.debug("ADDING COMPONENT {{NAME}} ".replace("{{NAME}}", _component_.name));
|
|
2067
2113
|
container.innerHTML += _component_.innerHTML;
|
|
2068
2114
|
} else {
|
|
@@ -2072,30 +2118,30 @@
|
|
|
2072
2118
|
|
|
2073
2119
|
};
|
|
2074
2120
|
|
|
2075
|
-
var _feedComponent_InNode = function (_component_){
|
|
2121
|
+
var _feedComponent_InNode = function (_component_) {
|
|
2076
2122
|
var parsedAssignmentText = _component_.parsedAssignmentText;
|
|
2077
2123
|
_component_.innerHTML = parsedAssignmentText;
|
|
2078
2124
|
};
|
|
2079
2125
|
|
|
2080
2126
|
var _ret_;
|
|
2081
|
-
if (!is_a(_component_, "Component")){
|
|
2127
|
+
if (!is_a(_component_, "Component")) {
|
|
2082
2128
|
logger.warn("Trying to feed a non component object");
|
|
2083
2129
|
return;
|
|
2084
2130
|
}
|
|
2085
|
-
if (isBrowser){
|
|
2131
|
+
if (isBrowser) {
|
|
2086
2132
|
_ret_ = _feedComponent_InBrowser(_component_);
|
|
2087
2133
|
} else {
|
|
2088
2134
|
_ret_ = _feedComponent_InNode(_component_);
|
|
2089
2135
|
}
|
|
2090
2136
|
return _ret_;
|
|
2091
2137
|
},
|
|
2092
|
-
rebuild
|
|
2138
|
+
rebuild() {
|
|
2093
2139
|
var _component = this;
|
|
2094
|
-
var _promise = new Promise(function(resolve, reject) {
|
|
2095
|
-
if (typeof _component === "undefined" || _component === null){
|
|
2140
|
+
var _promise = new Promise(function (resolve, reject) {
|
|
2141
|
+
if (typeof _component === "undefined" || _component === null) {
|
|
2096
2142
|
reject("Component is undefined");
|
|
2097
2143
|
}
|
|
2098
|
-
if (isQCObjects_Object(_component) && is_a(_component, "Component")){
|
|
2144
|
+
if (isQCObjects_Object(_component) && is_a(_component, "Component")) {
|
|
2099
2145
|
switch (true) {
|
|
2100
2146
|
case (_component.get("tplsource") === "none"):
|
|
2101
2147
|
logger.debug("Component " + _component.name + " has specified template-source=none, so no template load was done");
|
|
@@ -2124,10 +2170,10 @@
|
|
|
2124
2170
|
_component.get("templateURI") !== ""):
|
|
2125
2171
|
_component.set("url", _component.get("basePath") + _component.get("templateURI"));
|
|
2126
2172
|
componentLoader(_component, false).then(
|
|
2127
|
-
function(standardResponse) {
|
|
2173
|
+
function (standardResponse) {
|
|
2128
2174
|
resolve.call(_promise, standardResponse);
|
|
2129
2175
|
},
|
|
2130
|
-
function(standardResponse) {
|
|
2176
|
+
function (standardResponse) {
|
|
2131
2177
|
reject.call(_promise, standardResponse);
|
|
2132
2178
|
});
|
|
2133
2179
|
break;
|
|
@@ -2135,10 +2181,10 @@
|
|
|
2135
2181
|
_component.get("templateURI") !== ""):
|
|
2136
2182
|
_component.set("url", _component.get("templateURI"));
|
|
2137
2183
|
componentLoader(_component, false).then(
|
|
2138
|
-
function(standardResponse) {
|
|
2184
|
+
function (standardResponse) {
|
|
2139
2185
|
resolve.call(_promise, standardResponse);
|
|
2140
2186
|
},
|
|
2141
|
-
function(standardResponse) {
|
|
2187
|
+
function (standardResponse) {
|
|
2142
2188
|
reject.call(_promise, standardResponse);
|
|
2143
2189
|
});
|
|
2144
2190
|
break;
|
|
@@ -2154,14 +2200,18 @@
|
|
|
2154
2200
|
});
|
|
2155
2201
|
break;
|
|
2156
2202
|
}
|
|
2157
|
-
|
|
2203
|
+
|
|
2158
2204
|
}
|
|
2159
2205
|
});
|
|
2160
2206
|
return _promise;
|
|
2161
2207
|
},
|
|
2162
|
-
Cast
|
|
2208
|
+
Cast(oClass) {
|
|
2163
2209
|
/* Cast method for components has been deprecated. Don't use this method, it is available only for compatibility purposes */
|
|
2164
|
-
let o = _methods_(oClass).map(m=>m.name.replace(/bound /g, "")).map(m
|
|
2210
|
+
let o = _methods_(oClass).map(m => m.name.replace(/bound /g, "")).map(m => {
|
|
2211
|
+
return {
|
|
2212
|
+
[m]: oClass[m].bind(this)
|
|
2213
|
+
};
|
|
2214
|
+
}).reduce((c, p) => Object.assign(c, p), {});
|
|
2165
2215
|
return _Cast(this, o);
|
|
2166
2216
|
},
|
|
2167
2217
|
routingWay: null,
|
|
@@ -2169,29 +2219,32 @@
|
|
|
2169
2219
|
routingNodes: [],
|
|
2170
2220
|
routings: [],
|
|
2171
2221
|
routingPath: "",
|
|
2172
|
-
route
|
|
2222
|
+
route() {
|
|
2173
2223
|
var componentClass = this;
|
|
2174
2224
|
var isValidInstance = ((!!componentClass.__instanceID) &&
|
|
2175
|
-
Object.hasOwnProperty.call(componentClass,"subcomponents")) ? (true) : (false);
|
|
2176
|
-
var __route__ = function(componentList) {
|
|
2225
|
+
Object.hasOwnProperty.call(componentClass, "subcomponents")) ? (true) : (false);
|
|
2226
|
+
var __route__ = function (componentList) {
|
|
2177
2227
|
var _componentNames_ = [];
|
|
2178
|
-
var _promises_ = componentList.filter(function (rc)
|
|
2179
|
-
|
|
2228
|
+
var _promises_ = componentList.filter(function (rc) {
|
|
2229
|
+
return typeof rc !== "undefined";
|
|
2230
|
+
}).map(function (rc) {
|
|
2231
|
+
if (typeof rc.name !== "undefined") {
|
|
2180
2232
|
_componentNames_.push(rc.name);
|
|
2181
2233
|
} else {
|
|
2182
|
-
throw new Error(__getType__(rc)+" does not have a name");
|
|
2234
|
+
throw new Error(__getType__(rc) + " does not have a name");
|
|
2183
2235
|
}
|
|
2184
|
-
return new Promise
|
|
2236
|
+
return new Promise(function (resolve, reject) {
|
|
2185
2237
|
var _promise_;
|
|
2186
|
-
if (typeof rc !== "undefined"
|
|
2187
|
-
|
|
2238
|
+
if (typeof rc !== "undefined" &&
|
|
2239
|
+
Object.hasOwnProperty.call(rc, "_reroute_")) {
|
|
2188
2240
|
_promise_ = rc._reroute_()
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
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") &&
|
|
2195
2248
|
typeof _rc_.subcomponents !== "undefined" &&
|
|
2196
2249
|
_rc_.subcomponents.length > 0
|
|
2197
2250
|
) {
|
|
@@ -2201,21 +2254,21 @@
|
|
|
2201
2254
|
resolve(_rc_);
|
|
2202
2255
|
}
|
|
2203
2256
|
});
|
|
2204
|
-
} else if (typeof rc !== "undefined"){
|
|
2257
|
+
} else if (typeof rc !== "undefined") {
|
|
2205
2258
|
reject("Component " + rc.name + " is not an instance of Component");
|
|
2206
2259
|
}
|
|
2207
2260
|
return _promise_;
|
|
2208
2261
|
});
|
|
2209
2262
|
});
|
|
2210
2263
|
return Promise.all(_promises_)
|
|
2211
|
-
.then(function (){
|
|
2212
|
-
logger.debug("ROUTING COMPLETED FOR "+ _componentNames_.join(", "));
|
|
2213
|
-
}).catch(function (err){
|
|
2214
|
-
logger.error("ROUTING FAILED FOR "+ _componentNames_.join(", ") + ": " + err);
|
|
2264
|
+
.then(function () {
|
|
2265
|
+
logger.debug("ROUTING COMPLETED FOR " + _componentNames_.join(", "));
|
|
2266
|
+
}).catch(function (err) {
|
|
2267
|
+
logger.error("ROUTING FAILED FOR " + _componentNames_.join(", ") + ": " + err);
|
|
2215
2268
|
});
|
|
2216
2269
|
};
|
|
2217
|
-
if (isValidInstance || Object.hasOwnProperty.call(global,"componentsStack")) {
|
|
2218
|
-
if (isValidInstance && is_a(componentClass, "Component")){
|
|
2270
|
+
if (isValidInstance || Object.hasOwnProperty.call(global, "componentsStack")) {
|
|
2271
|
+
if (isValidInstance && is_a(componentClass, "Component")) {
|
|
2219
2272
|
logger.debug("loading routings for instance " + componentClass.name);
|
|
2220
2273
|
}
|
|
2221
2274
|
__route__.call(componentClass, (isValidInstance) ? (componentClass.subcomponents) : (global.componentsStack));
|
|
@@ -2223,7 +2276,7 @@
|
|
|
2223
2276
|
logger.debug("An undetermined result expected if load routings. So will not be loaded this time.");
|
|
2224
2277
|
}
|
|
2225
2278
|
},
|
|
2226
|
-
fullscreen
|
|
2279
|
+
fullscreen() {
|
|
2227
2280
|
if (isBrowser) {
|
|
2228
2281
|
var elem = this.body;
|
|
2229
2282
|
if (elem.requestFullscreen) {
|
|
@@ -2242,7 +2295,7 @@
|
|
|
2242
2295
|
// not yet implemented.
|
|
2243
2296
|
}
|
|
2244
2297
|
},
|
|
2245
|
-
closefullscreen
|
|
2298
|
+
closefullscreen() {
|
|
2246
2299
|
if (isBrowser) {
|
|
2247
2300
|
if (document.exitFullscreen) {
|
|
2248
2301
|
document.exitFullscreen();
|
|
@@ -2257,7 +2310,7 @@
|
|
|
2257
2310
|
// noy yet implemented.
|
|
2258
2311
|
}
|
|
2259
2312
|
},
|
|
2260
|
-
_generateRoutingPaths
|
|
2313
|
+
_generateRoutingPaths(componentBody) {
|
|
2261
2314
|
var component = this;
|
|
2262
2315
|
if (isBrowser) {
|
|
2263
2316
|
if (__valid_routing_way__(component.validRoutingWays, component.routingWay)) {
|
|
@@ -2265,10 +2318,10 @@
|
|
|
2265
2318
|
component.innerHTML = componentBody.innerHTML;
|
|
2266
2319
|
component.routingNodes = componentBody.subelements("routing");
|
|
2267
2320
|
component.routings = [];
|
|
2268
|
-
component.routingNodes.map(function (routingNode, r){
|
|
2321
|
+
component.routingNodes.map(function (routingNode, r) {
|
|
2269
2322
|
var attributeNames = routingNode.getAttributeNames();
|
|
2270
2323
|
var routing = {};
|
|
2271
|
-
attributeNames.map(function (attributeName, a){
|
|
2324
|
+
attributeNames.map(function (attributeName, a) {
|
|
2272
2325
|
routing[attributeNames[a]] = routingNode.getAttribute(attributeNames[a]);
|
|
2273
2326
|
});
|
|
2274
2327
|
component.routings.push(routing);
|
|
@@ -2285,10 +2338,10 @@
|
|
|
2285
2338
|
// not yet implemented.
|
|
2286
2339
|
}
|
|
2287
2340
|
},
|
|
2288
|
-
parseTemplate
|
|
2341
|
+
parseTemplate(template) {
|
|
2289
2342
|
var _self = this;
|
|
2290
2343
|
var _parsedAssignmentText;
|
|
2291
|
-
if (Object.hasOwnProperty.call(_self,"templateHandler")) {
|
|
2344
|
+
if (Object.hasOwnProperty.call(_self, "templateHandler")) {
|
|
2292
2345
|
var value = template;
|
|
2293
2346
|
var templateHandlerName = _self.templateHandler;
|
|
2294
2347
|
var templateHandlerClass = ClassFactory(_self.templateHandler);
|
|
@@ -2297,10 +2350,10 @@
|
|
|
2297
2350
|
template: value
|
|
2298
2351
|
});
|
|
2299
2352
|
var selfData = _self.data;
|
|
2300
|
-
if (Object.hasOwnProperty.call(_self,"assignRoutingParams") && _self.assignRoutingParams){
|
|
2353
|
+
if (Object.hasOwnProperty.call(_self, "assignRoutingParams") && _self.assignRoutingParams) {
|
|
2301
2354
|
try {
|
|
2302
|
-
selfData = Object.assign(selfData,_self.routingParams);
|
|
2303
|
-
}catch (e){
|
|
2355
|
+
selfData = Object.assign(selfData, _self.routingParams);
|
|
2356
|
+
} catch (e) {
|
|
2304
2357
|
logger.debug("[parseTemplate] it was not possible to assign the routing params to the template");
|
|
2305
2358
|
}
|
|
2306
2359
|
}
|
|
@@ -2310,16 +2363,16 @@
|
|
|
2310
2363
|
}
|
|
2311
2364
|
return _parsedAssignmentText;
|
|
2312
2365
|
},
|
|
2313
|
-
_new_
|
|
2366
|
+
_new_(properties) {
|
|
2314
2367
|
var self = this;
|
|
2315
2368
|
|
|
2316
|
-
if (typeof self.name === "undefined"){
|
|
2317
|
-
logger.warn("A name is not defined for "+__getType__(self));
|
|
2369
|
+
if (typeof self.name === "undefined") {
|
|
2370
|
+
logger.warn("A name is not defined for " + __getType__(self));
|
|
2318
2371
|
}
|
|
2319
2372
|
|
|
2320
2373
|
self.routingWay = _top.CONFIG.get("routingWay");
|
|
2321
2374
|
|
|
2322
|
-
self.processorHandler = New(ClassFactory("Processor"),{
|
|
2375
|
+
self.processorHandler = New(ClassFactory("Processor"), {
|
|
2323
2376
|
component: self
|
|
2324
2377
|
});
|
|
2325
2378
|
|
|
@@ -2342,7 +2395,7 @@
|
|
|
2342
2395
|
},
|
|
2343
2396
|
get() {
|
|
2344
2397
|
var __routing_path__ = _DataStringify(self.routingPath);
|
|
2345
|
-
return Base64.encode(self.name + __routing_path__
|
|
2398
|
+
return Base64.encode(self.name + __routing_path__);
|
|
2346
2399
|
}
|
|
2347
2400
|
});
|
|
2348
2401
|
|
|
@@ -2361,7 +2414,7 @@
|
|
|
2361
2414
|
Object.defineProperty(self, "shadowRoot", {
|
|
2362
2415
|
configurable: true,
|
|
2363
2416
|
set(value) {
|
|
2364
|
-
if (typeof self.__shadowRoot == "undefined"){
|
|
2417
|
+
if (typeof self.__shadowRoot == "undefined") {
|
|
2365
2418
|
self.__shadowRoot = value;
|
|
2366
2419
|
} else {
|
|
2367
2420
|
logger.debug("[shadowRoot] This property can only be assigned once!");
|
|
@@ -2372,57 +2425,59 @@
|
|
|
2372
2425
|
}
|
|
2373
2426
|
});
|
|
2374
2427
|
|
|
2375
|
-
Object.defineProperty(self, "routingSelected",{
|
|
2428
|
+
Object.defineProperty(self, "routingSelected", {
|
|
2376
2429
|
configurable: true,
|
|
2377
|
-
set(value){
|
|
2430
|
+
set(value) {
|
|
2378
2431
|
logger.debug("[routingSelected] This is a read-only property of the component");
|
|
2379
2432
|
},
|
|
2380
|
-
get(){
|
|
2381
|
-
return __valid_routings__(this.routings,this.routingPath);
|
|
2433
|
+
get() {
|
|
2434
|
+
return __valid_routings__(this.routings, this.routingPath);
|
|
2382
2435
|
}
|
|
2383
2436
|
});
|
|
2384
2437
|
|
|
2385
|
-
Object.defineProperty(self, "routingParams",{
|
|
2438
|
+
Object.defineProperty(self, "routingParams", {
|
|
2386
2439
|
configurable: true,
|
|
2387
|
-
set(value){
|
|
2440
|
+
set(value) {
|
|
2388
2441
|
logger.debug("[routingParams] This is a read-only property of the component");
|
|
2389
2442
|
},
|
|
2390
|
-
get(){
|
|
2443
|
+
get() {
|
|
2391
2444
|
var component = this;
|
|
2392
|
-
return [{}].concat(component.routingSelected.map(function (routing){
|
|
2393
|
-
return __routing_params__(routing,component.routingPath);
|
|
2394
|
-
})).reduce(function (accumulator, colData, index){
|
|
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);
|
|
2449
|
+
});
|
|
2395
2450
|
}
|
|
2396
2451
|
});
|
|
2397
2452
|
|
|
2398
|
-
if (typeof self.__new__ === "function"){
|
|
2399
|
-
self.__new__.call(self,properties);
|
|
2453
|
+
if (typeof self.__new__ === "function") {
|
|
2454
|
+
self.__new__.call(self, properties);
|
|
2400
2455
|
}
|
|
2401
2456
|
|
|
2402
2457
|
self._reroute_()
|
|
2403
|
-
.then(function (){
|
|
2458
|
+
.then(function () {
|
|
2404
2459
|
return self.rebuild()
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
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
|
+
});
|
|
2466
|
+
});
|
|
2467
|
+
|
|
2413
2468
|
},
|
|
2414
|
-
_reroute_
|
|
2469
|
+
_reroute_() {
|
|
2415
2470
|
/* This method set the selected routing and makes the switch to the templateURI */
|
|
2416
2471
|
var rc = this;
|
|
2417
|
-
return new Promise
|
|
2418
|
-
if (isBrowser){
|
|
2472
|
+
return new Promise(function (resolve, reject) {
|
|
2473
|
+
if (isBrowser) {
|
|
2419
2474
|
if (__valid_routing_way__(rc.validRoutingWays, rc.routingWay)) {
|
|
2420
2475
|
rc.routingPath = document.location[rc.routingWay];
|
|
2421
|
-
rc.routingSelected.map(function (routing, r){
|
|
2476
|
+
rc.routingSelected.map(function (routing, r) {
|
|
2422
2477
|
var componentURI = ComponentURI({
|
|
2423
2478
|
"COMPONENTS_BASE_PATH": _top.CONFIG.get("componentsBasePath"),
|
|
2424
2479
|
"COMPONENT_NAME": routing.name.toString(),
|
|
2425
|
-
"TPLEXTENSION": (Object.hasOwnProperty.call(routing,"tplextension")) ? (routing.tplextension) : (rc.tplextension),
|
|
2480
|
+
"TPLEXTENSION": (Object.hasOwnProperty.call(routing, "tplextension")) ? (routing.tplextension) : (rc.tplextension),
|
|
2426
2481
|
"TPL_SOURCE": "default" /* here is always default in order to get the right uri */
|
|
2427
2482
|
});
|
|
2428
2483
|
rc.templateURI = componentURI;
|
|
@@ -2434,15 +2489,15 @@
|
|
|
2434
2489
|
}
|
|
2435
2490
|
}
|
|
2436
2491
|
resolve(rc);
|
|
2437
|
-
|
|
2492
|
+
|
|
2438
2493
|
});
|
|
2439
2494
|
},
|
|
2440
|
-
lazyLoadImages
|
|
2441
|
-
if (isBrowser){
|
|
2495
|
+
lazyLoadImages() {
|
|
2496
|
+
if (isBrowser) {
|
|
2442
2497
|
var component = this;
|
|
2443
|
-
var _componentRoot = (component.shadowed)?(component.shadowRoot):(component.body);
|
|
2498
|
+
var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
2444
2499
|
var _imgLazyLoaded = [..._componentRoot.subelements("img[lazy-src]")];
|
|
2445
|
-
var _lazyLoadImages = function(image) {
|
|
2500
|
+
var _lazyLoadImages = function (image) {
|
|
2446
2501
|
image.setAttribute("src", image.getAttribute("lazy-src"));
|
|
2447
2502
|
image.onload = () => {
|
|
2448
2503
|
image.removeAttribute("lazy-src");
|
|
@@ -2457,7 +2512,7 @@
|
|
|
2457
2512
|
}
|
|
2458
2513
|
});
|
|
2459
2514
|
});
|
|
2460
|
-
_imgLazyLoaded.map(function(img) {
|
|
2515
|
+
_imgLazyLoaded.map(function (img) {
|
|
2461
2516
|
return observer.observe(img);
|
|
2462
2517
|
});
|
|
2463
2518
|
} else {
|
|
@@ -2469,7 +2524,7 @@
|
|
|
2469
2524
|
}
|
|
2470
2525
|
return null;
|
|
2471
2526
|
},
|
|
2472
|
-
applyTransitionEffect
|
|
2527
|
+
applyTransitionEffect(effectClassName) {
|
|
2473
2528
|
var _Effect = ClassFactory(effectClassName);
|
|
2474
2529
|
if (typeof _Effect !== "undefined" && is_a(_Effect, "TransitionEffect")) {
|
|
2475
2530
|
this.effect = New(_Effect, {
|
|
@@ -2480,11 +2535,11 @@
|
|
|
2480
2535
|
logger.debug(`${__getType__(_Effect)} is not a TransitionEffect`);
|
|
2481
2536
|
}
|
|
2482
2537
|
},
|
|
2483
|
-
applyObserveTransitionEffect
|
|
2484
|
-
if (isBrowser){
|
|
2538
|
+
applyObserveTransitionEffect(effectClassName) {
|
|
2539
|
+
if (isBrowser) {
|
|
2485
2540
|
var component = this;
|
|
2486
|
-
var _componentRoot = (component.shadowed)?(component.shadowRoot):(component.body);
|
|
2487
|
-
var _applyEffect_ = function(element) {
|
|
2541
|
+
var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
2542
|
+
var _applyEffect_ = function (element) {
|
|
2488
2543
|
component.applyTransitionEffect(effectClassName);
|
|
2489
2544
|
};
|
|
2490
2545
|
if ("IntersectionObserver" in window) {
|
|
@@ -2505,16 +2560,20 @@
|
|
|
2505
2560
|
}
|
|
2506
2561
|
return null;
|
|
2507
2562
|
},
|
|
2508
|
-
scrollIntoHash
|
|
2509
|
-
if (isBrowser){
|
|
2563
|
+
scrollIntoHash() {
|
|
2564
|
+
if (isBrowser) {
|
|
2510
2565
|
var component = this;
|
|
2511
|
-
if (document.location.hash !== ""){
|
|
2512
|
-
var _componentRoot = (component.shadowed)?(component.shadowRoot):(component.body);
|
|
2566
|
+
if (document.location.hash !== "") {
|
|
2567
|
+
var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
2513
2568
|
_componentRoot.subelements(document.location.hash).map(
|
|
2514
|
-
function (element){
|
|
2515
|
-
if (typeof element.scrollIntoView === "function"){
|
|
2569
|
+
function (element) {
|
|
2570
|
+
if (typeof element.scrollIntoView === "function") {
|
|
2516
2571
|
element.scrollIntoView(
|
|
2517
|
-
_top.CONFIG.get("scrollIntoHash",{
|
|
2572
|
+
_top.CONFIG.get("scrollIntoHash", {
|
|
2573
|
+
behavior: "auto",
|
|
2574
|
+
block: "top",
|
|
2575
|
+
inline: "top"
|
|
2576
|
+
})
|
|
2518
2577
|
);
|
|
2519
2578
|
}
|
|
2520
2579
|
}
|
|
@@ -2524,36 +2583,36 @@
|
|
|
2524
2583
|
// not yet implemented
|
|
2525
2584
|
}
|
|
2526
2585
|
},
|
|
2527
|
-
i18n_translate
|
|
2528
|
-
if (isBrowser){
|
|
2529
|
-
if (_top.CONFIG.get("use_i18n")){
|
|
2586
|
+
i18n_translate() {
|
|
2587
|
+
if (isBrowser) {
|
|
2588
|
+
if (_top.CONFIG.get("use_i18n")) {
|
|
2530
2589
|
var component = this;
|
|
2531
|
-
var _componentRoot = (component.shadowed)?(component.shadowRoot):(component.body);
|
|
2532
|
-
var lang1=_top.CONFIG.get("lang","en");
|
|
2590
|
+
var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
2591
|
+
var lang1 = _top.CONFIG.get("lang", "en");
|
|
2533
2592
|
var lang2 = navigator.language.slice(0, 2);
|
|
2534
2593
|
var i18n = _top.global.get("i18n");
|
|
2535
|
-
if ((lang1 !== lang2) && (typeof i18n === "object" && Object.hasOwnProperty.call(i18n,"messages"))){
|
|
2536
|
-
var callback_i18n = function (){
|
|
2594
|
+
if ((lang1 !== lang2) && (typeof i18n === "object" && Object.hasOwnProperty.call(i18n, "messages"))) {
|
|
2595
|
+
var callback_i18n = function () {
|
|
2537
2596
|
var component = this;
|
|
2538
|
-
return new Promise(function (resolve, reject){
|
|
2539
|
-
var messages = i18n.messages.filter(function (message){
|
|
2540
|
-
return Object.hasOwnProperty.call(message,lang1) && Object.hasOwnProperty.call(message,lang2);
|
|
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);
|
|
2541
2600
|
});
|
|
2542
2601
|
_componentRoot.subelements("ul,li,h1,h2,h3,a,b,p,input,textarea,summary,details,option,component")
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
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;
|
|
2549
2610
|
});
|
|
2550
|
-
return element;
|
|
2551
|
-
});
|
|
2552
2611
|
resolve();
|
|
2553
2612
|
});
|
|
2554
2613
|
};
|
|
2555
|
-
callback_i18n.call(component).then(function (){
|
|
2556
|
-
logger.debug("i18n loaded for component: "+component.name);
|
|
2614
|
+
callback_i18n.call(component).then(function () {
|
|
2615
|
+
logger.debug("i18n loaded for component: " + component.name);
|
|
2557
2616
|
});
|
|
2558
2617
|
|
|
2559
2618
|
}
|
|
@@ -2562,48 +2621,48 @@
|
|
|
2562
2621
|
// not yet implemented
|
|
2563
2622
|
}
|
|
2564
2623
|
},
|
|
2565
|
-
_componentHelpers:[],
|
|
2566
|
-
addComponentHelper
|
|
2624
|
+
_componentHelpers: [],
|
|
2625
|
+
addComponentHelper(componentHelper) {
|
|
2567
2626
|
var component = this;
|
|
2568
2627
|
component._componentHelpers.push(componentHelper);
|
|
2569
2628
|
},
|
|
2570
|
-
runComponentHelpers
|
|
2571
|
-
if (isBrowser){
|
|
2629
|
+
runComponentHelpers() {
|
|
2630
|
+
if (isBrowser) {
|
|
2572
2631
|
var component = this;
|
|
2573
2632
|
var __component_helpers__ = [];
|
|
2574
2633
|
/*
|
|
2575
|
-
|
|
2576
|
-
|
|
2634
|
+
* BEGIN use i18n translation
|
|
2635
|
+
*/
|
|
2577
2636
|
__component_helpers__.push(component.i18n_translate.bind(component));
|
|
2578
2637
|
/*
|
|
2579
|
-
|
|
2580
|
-
|
|
2638
|
+
* END use i18n translation
|
|
2639
|
+
*/
|
|
2581
2640
|
|
|
2582
2641
|
/*
|
|
2583
|
-
|
|
2584
|
-
|
|
2642
|
+
* BEGIN component scrollIntoHash
|
|
2643
|
+
*/
|
|
2585
2644
|
__component_helpers__.push(component.scrollIntoHash.bind(component));
|
|
2586
2645
|
/*
|
|
2587
|
-
|
|
2588
|
-
|
|
2646
|
+
* END component scrollIntoHash
|
|
2647
|
+
*/
|
|
2589
2648
|
|
|
2590
2649
|
/*
|
|
2591
2650
|
* BEGIN component images lazy-load
|
|
2592
2651
|
*/
|
|
2593
2652
|
|
|
2594
|
-
|
|
2653
|
+
__component_helpers__.push(component.lazyLoadImages.bind(component));
|
|
2595
2654
|
|
|
2596
2655
|
/*
|
|
2597
2656
|
* END component images lazy-load
|
|
2598
2657
|
*/
|
|
2599
2658
|
|
|
2600
|
-
|
|
2659
|
+
__component_helpers__ = __component_helpers__.concat(component._componentHelpers);
|
|
2601
2660
|
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2661
|
+
__component_helpers__.map(
|
|
2662
|
+
function (_component_helper_) {
|
|
2663
|
+
_component_helper_();
|
|
2664
|
+
}
|
|
2665
|
+
);
|
|
2607
2666
|
|
|
2608
2667
|
} else {
|
|
2609
2668
|
// not yet implemented
|
|
@@ -2612,43 +2671,53 @@
|
|
|
2612
2671
|
}
|
|
2613
2672
|
});
|
|
2614
2673
|
|
|
2615
|
-
_top._bindroute_.__assigned=false;
|
|
2674
|
+
_top._bindroute_.__assigned = false;
|
|
2616
2675
|
|
|
2617
|
-
(_methods_)(ClassFactory("Component")).map(function (__c__){
|
|
2676
|
+
(_methods_)(ClassFactory("Component")).map(function (__c__) {
|
|
2677
|
+
(_protected_code_)(__c__);
|
|
2678
|
+
});
|
|
2618
2679
|
|
|
2619
|
-
Class
|
|
2680
|
+
Class("Controller", ClassFactory("InheritClass"), {
|
|
2620
2681
|
dependencies: [],
|
|
2621
2682
|
component: null,
|
|
2622
|
-
routingSelectedAttr
|
|
2623
|
-
return this.component.routingSelected.map(function (r)
|
|
2683
|
+
routingSelectedAttr(attrName) {
|
|
2684
|
+
return this.component.routingSelected.map(function (r) {
|
|
2685
|
+
return r[attrName];
|
|
2686
|
+
}).filter(function (v) {
|
|
2687
|
+
return v;
|
|
2688
|
+
}).pop();
|
|
2624
2689
|
},
|
|
2625
|
-
isTouchable
|
|
2626
|
-
return ("ontouchstart" in window)
|
|
2627
|
-
|
|
2628
|
-
|
|
2690
|
+
isTouchable() {
|
|
2691
|
+
return ("ontouchstart" in window) ||
|
|
2692
|
+
(navigator.MaxTouchPoints > 0) ||
|
|
2693
|
+
(navigator.msMaxTouchPoints > 0);
|
|
2629
2694
|
},
|
|
2630
|
-
onpress
|
|
2695
|
+
onpress(subelementSelector, handler) {
|
|
2631
2696
|
try {
|
|
2632
|
-
if (this.isTouchable()){
|
|
2633
|
-
this.component.body.subelements(subelementSelector)[0].addEventListener("touchstart",handler, {
|
|
2697
|
+
if (this.isTouchable()) {
|
|
2698
|
+
this.component.body.subelements(subelementSelector)[0].addEventListener("touchstart", handler, {
|
|
2699
|
+
passive: true
|
|
2700
|
+
});
|
|
2634
2701
|
} else {
|
|
2635
|
-
this.component.body.subelements(subelementSelector)[0].addEventListener("click",handler, {
|
|
2702
|
+
this.component.body.subelements(subelementSelector)[0].addEventListener("click", handler, {
|
|
2703
|
+
passive: true
|
|
2704
|
+
});
|
|
2636
2705
|
}
|
|
2637
|
-
}catch (e){
|
|
2706
|
+
} catch (e) {
|
|
2638
2707
|
logger.debug("No button to assign press event");
|
|
2639
2708
|
}
|
|
2640
2709
|
},
|
|
2641
|
-
createRoutingController
|
|
2710
|
+
createRoutingController() {
|
|
2642
2711
|
var controller = this;
|
|
2643
2712
|
var component = controller.component;
|
|
2644
2713
|
var controllerName = controller.routingSelectedAttr("controllerclass");
|
|
2645
|
-
if (typeof controllerName !== "undefined"){
|
|
2714
|
+
if (typeof controllerName !== "undefined") {
|
|
2646
2715
|
var _Controller = ClassFactory(controllerName);
|
|
2647
2716
|
if (typeof _Controller !== "undefined") {
|
|
2648
2717
|
component.routingController = New(_Controller, {
|
|
2649
2718
|
component: component
|
|
2650
2719
|
}); // Initializes the main controller for the component
|
|
2651
|
-
if (Object.hasOwnProperty.call(component.routingController,"done") && typeof component.routingController.done === "function") {
|
|
2720
|
+
if (Object.hasOwnProperty.call(component.routingController, "done") && typeof component.routingController.done === "function") {
|
|
2652
2721
|
component.routingController.done.call(component.routingController);
|
|
2653
2722
|
}
|
|
2654
2723
|
}
|
|
@@ -2656,13 +2725,14 @@
|
|
|
2656
2725
|
}
|
|
2657
2726
|
});
|
|
2658
2727
|
|
|
2659
|
-
Class("View",
|
|
2728
|
+
Class("View", ClassFactory("InheritClass"), {
|
|
2660
2729
|
dependencies: [],
|
|
2661
2730
|
component: null
|
|
2662
2731
|
});
|
|
2663
2732
|
|
|
2664
|
-
Class("Service",
|
|
2665
|
-
kind: "rest",
|
|
2733
|
+
Class("Service", ClassFactory("InheritClass"), {
|
|
2734
|
+
kind: "rest",
|
|
2735
|
+
/* it can be rest, mockup, local */
|
|
2666
2736
|
domain: domain,
|
|
2667
2737
|
basePath: basePath,
|
|
2668
2738
|
url: "",
|
|
@@ -2670,10 +2740,10 @@
|
|
|
2670
2740
|
data: {},
|
|
2671
2741
|
reload: false,
|
|
2672
2742
|
cached: false,
|
|
2673
|
-
set
|
|
2743
|
+
set(name, value) {
|
|
2674
2744
|
this[name] = value;
|
|
2675
2745
|
},
|
|
2676
|
-
get
|
|
2746
|
+
get(name) {
|
|
2677
2747
|
return this[name];
|
|
2678
2748
|
}
|
|
2679
2749
|
});
|
|
@@ -2686,7 +2756,7 @@
|
|
|
2686
2756
|
"charset": "utf-8"
|
|
2687
2757
|
},
|
|
2688
2758
|
JSONresponse: null,
|
|
2689
|
-
done
|
|
2759
|
+
done(result) {
|
|
2690
2760
|
logger.debug("***** RECEIVED RESPONSE:");
|
|
2691
2761
|
logger.debug(result.service.template);
|
|
2692
2762
|
this.JSONresponse = JSON.parse(result.service.template);
|
|
@@ -2702,11 +2772,11 @@
|
|
|
2702
2772
|
"charset": "utf-8"
|
|
2703
2773
|
},
|
|
2704
2774
|
JSONresponse: null,
|
|
2705
|
-
done
|
|
2775
|
+
done(result) {
|
|
2706
2776
|
logger.debug("***** CONFIG LOADED:");
|
|
2707
2777
|
logger.debug(result.service.template);
|
|
2708
2778
|
this.JSONresponse = JSON.parse(result.service.template);
|
|
2709
|
-
if (Object.hasOwnProperty.call(this.JSONresponse,"__encoded__")) {
|
|
2779
|
+
if (Object.hasOwnProperty.call(this.JSONresponse, "__encoded__")) {
|
|
2710
2780
|
this.JSONresponse = JSON.parse(ClassFactory("_Crypt").decrypt(this.JSONresponse.__encoded__, _secretKey));
|
|
2711
2781
|
}
|
|
2712
2782
|
for (var k in this.JSONresponse) {
|
|
@@ -2714,15 +2784,15 @@
|
|
|
2714
2784
|
}
|
|
2715
2785
|
this.configLoaded.call(this);
|
|
2716
2786
|
},
|
|
2717
|
-
fail
|
|
2787
|
+
fail(result) {
|
|
2718
2788
|
this.configLoaded.call(this);
|
|
2719
2789
|
},
|
|
2720
|
-
_new_
|
|
2790
|
+
_new_(o) {
|
|
2721
2791
|
this.set("url", this.get("basePath") + this.get("configFileName"));
|
|
2722
2792
|
}
|
|
2723
2793
|
});
|
|
2724
2794
|
|
|
2725
|
-
Class("VO",
|
|
2795
|
+
Class("VO", ClassFactory("InheritClass"), {});
|
|
2726
2796
|
|
|
2727
2797
|
/**
|
|
2728
2798
|
* Returns a standarized uri for a component
|
|
@@ -2731,7 +2801,7 @@
|
|
|
2731
2801
|
* @author: Jean Machuca <correojean@gmail.com>
|
|
2732
2802
|
* @param params an object with the params to build the uri path
|
|
2733
2803
|
*/
|
|
2734
|
-
var ComponentURI = function(params) {
|
|
2804
|
+
var ComponentURI = function (params) {
|
|
2735
2805
|
var templateURI = "";
|
|
2736
2806
|
if (params["TPL_SOURCE"] === "default") {
|
|
2737
2807
|
templateURI = "{{COMPONENTS_BASE_PATH}}{{COMPONENT_NAME}}.{{TPLEXTENSION}}";
|
|
@@ -2749,13 +2819,13 @@
|
|
|
2749
2819
|
* @author: Jean Machuca <correojean@gmail.com>
|
|
2750
2820
|
* @param component a Component object
|
|
2751
2821
|
*/
|
|
2752
|
-
var componentLoader = function(component, _async) {
|
|
2753
|
-
var _componentLoaderInBrowser = function(component, _async) {
|
|
2754
|
-
component.__promise__ = new Promise(function(resolve, reject) {
|
|
2822
|
+
var componentLoader = function (component, _async) {
|
|
2823
|
+
var _componentLoaderInBrowser = function (component, _async) {
|
|
2824
|
+
component.__promise__ = new Promise(function (resolve, reject) {
|
|
2755
2825
|
var _promise = component.__promise__;
|
|
2756
|
-
var container = (Object.hasOwnProperty.call(component,"container") && typeof component.container !== "undefined" && component.container !== null) ? (component.container) : (component.body);
|
|
2826
|
+
var container = (Object.hasOwnProperty.call(component, "container") && typeof component.container !== "undefined" && component.container !== null) ? (component.container) : (component.body);
|
|
2757
2827
|
if (container !== null) {
|
|
2758
|
-
var _feedComponent_ = function(component) {
|
|
2828
|
+
var _feedComponent_ = function (component) {
|
|
2759
2829
|
component.feedComponent();
|
|
2760
2830
|
var standardResponse = {
|
|
2761
2831
|
"request": xhr,
|
|
@@ -2765,7 +2835,7 @@
|
|
|
2765
2835
|
};
|
|
2766
2836
|
logger.debug("LOADING COMPONENT DATA {{DATA}} FROM {{URL}}".replace("{{DATA}}", _DataStringify(component.data)).replace("{{URL}}", component.url));
|
|
2767
2837
|
|
|
2768
|
-
var _componentLoaded = function() {
|
|
2838
|
+
var _componentLoaded = function () {
|
|
2769
2839
|
var successStatus = (is_file) ? (0) : (200);
|
|
2770
2840
|
if (xhr.status === successStatus) {
|
|
2771
2841
|
var response = xhr.responseText;
|
|
@@ -2785,27 +2855,27 @@
|
|
|
2785
2855
|
|
|
2786
2856
|
}
|
|
2787
2857
|
};
|
|
2788
|
-
if (typeof component.template === "string" && component.template !== ""){
|
|
2858
|
+
if (typeof component.template === "string" && component.template !== "") {
|
|
2789
2859
|
// component already has a template it does not need to be reloaded
|
|
2790
2860
|
_feedComponent_.call(this, component);
|
|
2791
2861
|
} else {
|
|
2792
2862
|
var is_file = (component.url.startsWith("file:")) ? (true) : (false);
|
|
2793
2863
|
var xhr = new XMLHttpRequest();
|
|
2794
|
-
if (!is_file){
|
|
2864
|
+
if (!is_file) {
|
|
2795
2865
|
try {
|
|
2796
2866
|
logger.debug("Calling the url of component in async mode.");
|
|
2797
2867
|
xhr.open(component.method, component.url, true);
|
|
2798
|
-
} catch (e){
|
|
2868
|
+
} catch (e) {
|
|
2799
2869
|
logger.debug("Last try has failed... The component cannot be loaded.");
|
|
2800
2870
|
}
|
|
2801
2871
|
} else {
|
|
2802
|
-
if ("fetch" in _top){
|
|
2872
|
+
if ("fetch" in _top) {
|
|
2803
2873
|
logger.debug("I can use fetch...");
|
|
2804
2874
|
logger.debug("It is a file to be loaded, so I will try to use fetch");
|
|
2805
|
-
var _p = fetch
|
|
2875
|
+
var _p = fetch(component.url).then(response => {
|
|
2806
2876
|
logger.debug("I got a response from fetch, so I'll feed the component");
|
|
2807
|
-
response.text().then(text=>{
|
|
2808
|
-
component.template=text;
|
|
2877
|
+
response.text().then(text => {
|
|
2878
|
+
component.template = text;
|
|
2809
2879
|
_feedComponent_.call(this, component);
|
|
2810
2880
|
});
|
|
2811
2881
|
});
|
|
@@ -2817,11 +2887,11 @@
|
|
|
2817
2887
|
if (!is_file) {
|
|
2818
2888
|
xhr.onload = _componentLoaded;
|
|
2819
2889
|
}
|
|
2820
|
-
var _directLoad = function(is_file) {
|
|
2821
|
-
is_file = (typeof is_file === "undefined" || !is_file)?(false):(true);
|
|
2890
|
+
var _directLoad = function (is_file) {
|
|
2891
|
+
is_file = (typeof is_file === "undefined" || !is_file) ? (false) : (true);
|
|
2822
2892
|
logger.debug("SENDING THE NORMAL REQUEST ");
|
|
2823
2893
|
if (is_file) {
|
|
2824
|
-
if(!("fetch" in _top)){
|
|
2894
|
+
if (!("fetch" in _top)) {
|
|
2825
2895
|
logger.debug("I have to try to load the file using xhr... ");
|
|
2826
2896
|
xhr.send(null);
|
|
2827
2897
|
if (xhr.status === XMLHttpRequest.DONE) {
|
|
@@ -2838,15 +2908,15 @@
|
|
|
2838
2908
|
logger.debug("USING CACHE FOR COMPONENT: " + component.name);
|
|
2839
2909
|
var cache = new ComplexStorageCache({
|
|
2840
2910
|
index: component.cacheIndex,
|
|
2841
|
-
load
|
|
2842
|
-
_directLoad.call(this,is_file);
|
|
2911
|
+
load(cacheController) {
|
|
2912
|
+
_directLoad.call(this, is_file);
|
|
2843
2913
|
},
|
|
2844
|
-
alternate
|
|
2914
|
+
alternate(cacheController) {
|
|
2845
2915
|
if (component.method === "GET") {
|
|
2846
2916
|
component.template = cacheController.cache.getCached(component.cacheIndex);
|
|
2847
2917
|
_feedComponent_.call(this, component);
|
|
2848
2918
|
} else {
|
|
2849
|
-
_directLoad.call(this,is_file);
|
|
2919
|
+
_directLoad.call(this, is_file);
|
|
2850
2920
|
}
|
|
2851
2921
|
return;
|
|
2852
2922
|
}
|
|
@@ -2854,7 +2924,7 @@
|
|
|
2854
2924
|
global.lastCache = cache;
|
|
2855
2925
|
} else {
|
|
2856
2926
|
logger.debug("NOT USING CACHE FOR COMPONENT: " + component.name);
|
|
2857
|
-
_directLoad.call(this,is_file);
|
|
2927
|
+
_directLoad.call(this, is_file);
|
|
2858
2928
|
}
|
|
2859
2929
|
|
|
2860
2930
|
}
|
|
@@ -2864,112 +2934,112 @@
|
|
|
2864
2934
|
logger.debug("CONTAINER DOESNT EXIST");
|
|
2865
2935
|
}
|
|
2866
2936
|
});
|
|
2867
|
-
component.__promise__.then(function(standardResponse) {
|
|
2937
|
+
component.__promise__.then(function (standardResponse) {
|
|
2868
2938
|
var _ret_;
|
|
2869
2939
|
if (typeof component.done === "function") {
|
|
2870
2940
|
_ret_ = component.done.call(component, standardResponse);
|
|
2871
2941
|
}
|
|
2872
2942
|
return Promise.resolve(_ret_);
|
|
2873
|
-
}, function(standardResponse) {
|
|
2943
|
+
}, function (standardResponse) {
|
|
2874
2944
|
var _ret_;
|
|
2875
2945
|
if (typeof component.fail === "function") {
|
|
2876
2946
|
_ret_ = component.fail.call(component, standardResponse);
|
|
2877
2947
|
}
|
|
2878
2948
|
return Promise.reject(_ret_);
|
|
2879
|
-
}).catch(function(e) {
|
|
2949
|
+
}).catch(function (e) {
|
|
2880
2950
|
logger.debug("Something wrong loading the component");
|
|
2881
2951
|
});
|
|
2882
2952
|
return component.__promise__;
|
|
2883
2953
|
};
|
|
2884
|
-
var _componentLoaderInNode = function(component, _async) {
|
|
2885
|
-
component.__promise__ = new Promise(function(resolve, reject) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
};
|
|
2893
|
-
resolve.call(_promise, standardResponse);
|
|
2954
|
+
var _componentLoaderInNode = function (component, _async) {
|
|
2955
|
+
component.__promise__ = new Promise(function (resolve, reject) {
|
|
2956
|
+
var _promise = component.__promise__;
|
|
2957
|
+
var _feedComponent_ = function (component) {
|
|
2958
|
+
component.feedComponent();
|
|
2959
|
+
var standardResponse = {
|
|
2960
|
+
"request": null,
|
|
2961
|
+
"component": component
|
|
2894
2962
|
};
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
} else {
|
|
2908
|
-
var standardResponse = {
|
|
2909
|
-
"request": null,
|
|
2910
|
-
"component": component
|
|
2911
|
-
};
|
|
2912
|
-
reject.call(_promise, standardResponse);
|
|
2963
|
+
resolve.call(_promise, standardResponse);
|
|
2964
|
+
};
|
|
2965
|
+
logger.debug("LOADING COMPONENT DATA {{DATA}} FROM {{URL}}".replace("{{DATA}}", _DataStringify(component.data)).replace("{{URL}}", component.url));
|
|
2966
|
+
|
|
2967
|
+
var _componentLoaded = function (err, responseText) {
|
|
2968
|
+
if (!err) {
|
|
2969
|
+
var response = responseText.toString();
|
|
2970
|
+
logger.debug("Data received {{DATA}}".replace("{{DATA}}", _DataStringify(response)));
|
|
2971
|
+
logger.debug("CREATING COMPONENT {{NAME}}".replace("{{NAME}}", component.name));
|
|
2972
|
+
component.template = response;
|
|
2973
|
+
if (component.cached && (typeof cache !== "undefined")) {
|
|
2974
|
+
cache.save(component.name, component.template);
|
|
2913
2975
|
}
|
|
2914
|
-
};
|
|
2915
|
-
if (typeof component.template === "string" && component.template !== ""){
|
|
2916
|
-
// component already has a template it does not need to be reloaded
|
|
2917
2976
|
_feedComponent_.call(this, component);
|
|
2918
2977
|
} else {
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
logger.debug("SENDING THE NORMAL REQUEST ");
|
|
2923
|
-
fs.readFile(component.url, _componentLoaded);
|
|
2978
|
+
var standardResponse = {
|
|
2979
|
+
"request": null,
|
|
2980
|
+
"component": component
|
|
2924
2981
|
};
|
|
2982
|
+
reject.call(_promise, standardResponse);
|
|
2983
|
+
}
|
|
2984
|
+
};
|
|
2985
|
+
if (typeof component.template === "string" && component.template !== "") {
|
|
2986
|
+
// component already has a template it does not need to be reloaded
|
|
2987
|
+
_feedComponent_.call(this, component);
|
|
2988
|
+
} else {
|
|
2989
|
+
logger.debug("Loading the component as a local file in server...");
|
|
2990
|
+
var _directLoad = function (is_file) {
|
|
2991
|
+
const fs = require("fs");
|
|
2992
|
+
logger.debug("SENDING THE NORMAL REQUEST ");
|
|
2993
|
+
fs.readFile(component.url, _componentLoaded);
|
|
2994
|
+
};
|
|
2925
2995
|
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2996
|
+
if (component.cached) {
|
|
2997
|
+
logger.debug("USING CACHE FOR COMPONENT: " + component.name);
|
|
2998
|
+
var cache = new ComplexStorageCache({
|
|
2999
|
+
index: component.cacheIndex,
|
|
3000
|
+
load(cacheController) {
|
|
3001
|
+
_directLoad.call(this);
|
|
3002
|
+
},
|
|
3003
|
+
alternate(cacheController) {
|
|
3004
|
+
if (component.method === "GET") {
|
|
3005
|
+
component.template = cacheController.cache.getCached(component.cacheIndex);
|
|
3006
|
+
_feedComponent_.call(this, component);
|
|
3007
|
+
} else {
|
|
2931
3008
|
_directLoad.call(this);
|
|
2932
|
-
},
|
|
2933
|
-
alternate (cacheController) {
|
|
2934
|
-
if (component.method === "GET") {
|
|
2935
|
-
component.template = cacheController.cache.getCached(component.cacheIndex);
|
|
2936
|
-
_feedComponent_.call(this, component);
|
|
2937
|
-
} else {
|
|
2938
|
-
_directLoad.call(this);
|
|
2939
|
-
}
|
|
2940
|
-
return;
|
|
2941
3009
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
}
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
3013
|
+
global.lastCache = cache;
|
|
3014
|
+
} else {
|
|
3015
|
+
logger.debug("NOT USING CACHE FOR COMPONENT: " + component.name);
|
|
3016
|
+
_directLoad.call(this);
|
|
2949
3017
|
}
|
|
2950
3018
|
|
|
2951
|
-
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
return;
|
|
2952
3022
|
});
|
|
2953
|
-
component.__promise__.then(function(standardResponse) {
|
|
3023
|
+
component.__promise__.then(function (standardResponse) {
|
|
2954
3024
|
var _ret_;
|
|
2955
3025
|
if (typeof component.done === "function") {
|
|
2956
3026
|
_ret_ = component.done.call(component, standardResponse);
|
|
2957
3027
|
}
|
|
2958
3028
|
return Promise.resolve(_ret_);
|
|
2959
|
-
}, function(standardResponse) {
|
|
3029
|
+
}, function (standardResponse) {
|
|
2960
3030
|
var _ret_;
|
|
2961
3031
|
if (typeof component.fail === "function") {
|
|
2962
3032
|
_ret_ = component.fail.call(component, standardResponse);
|
|
2963
3033
|
}
|
|
2964
3034
|
return Promise.reject(_ret_);
|
|
2965
|
-
}).catch(function(e) {
|
|
3035
|
+
}).catch(function (e) {
|
|
2966
3036
|
logger.debug("Something wrong loading the component");
|
|
2967
3037
|
});
|
|
2968
3038
|
return component.__promise__;
|
|
2969
3039
|
};
|
|
2970
3040
|
|
|
2971
3041
|
var _ret_;
|
|
2972
|
-
if (isBrowser){
|
|
3042
|
+
if (isBrowser) {
|
|
2973
3043
|
if (typeof _async !== "undefined" && _async) {
|
|
2974
3044
|
_ret_ = asyncLoad(_componentLoaderInBrowser, arguments);
|
|
2975
3045
|
} else {
|
|
@@ -2987,10 +3057,10 @@
|
|
|
2987
3057
|
* @author: Jean Machuca <correojean@gmail.com>
|
|
2988
3058
|
* @param service a Service object
|
|
2989
3059
|
*/
|
|
2990
|
-
var serviceLoader = function(service, _async) {
|
|
2991
|
-
var _serviceLoaderInBrowser = function(service, _async) {
|
|
3060
|
+
var serviceLoader = function (service, _async) {
|
|
3061
|
+
var _serviceLoaderInBrowser = function (service, _async) {
|
|
2992
3062
|
var _promise = new Promise(
|
|
2993
|
-
function(resolve, reject) {
|
|
3063
|
+
function (resolve, reject) {
|
|
2994
3064
|
|
|
2995
3065
|
logger.debug("LOADING SERVICE DATA {{DATA}} FROM {{URL}}".replace("{{DATA}}", _DataStringify(service.data)).replace("{{URL}}", service.url));
|
|
2996
3066
|
var xhr = new XMLHttpRequest();
|
|
@@ -2999,14 +3069,14 @@
|
|
|
2999
3069
|
xhr.open(service.method, service.url, xhrasync);
|
|
3000
3070
|
for (var header in service.headers) {
|
|
3001
3071
|
try {
|
|
3002
|
-
if (typeof service.headers[header] !== "function"){
|
|
3072
|
+
if (typeof service.headers[header] !== "function") {
|
|
3003
3073
|
xhr.setRequestHeader(header, service.headers[header]);
|
|
3004
3074
|
}
|
|
3005
|
-
} catch (e){
|
|
3006
|
-
logger.debug("Something went wrong when assign the header "+header);
|
|
3075
|
+
} catch (e) {
|
|
3076
|
+
logger.debug("Something went wrong when assign the header " + header);
|
|
3007
3077
|
}
|
|
3008
3078
|
}
|
|
3009
|
-
xhr.onload = function() {
|
|
3079
|
+
xhr.onload = function () {
|
|
3010
3080
|
if (xhr.status === 200) {
|
|
3011
3081
|
var response = xhr.responseText;
|
|
3012
3082
|
logger.debug("Data received {{DATA}}".replace("{{DATA}}", _DataStringify(response)));
|
|
@@ -3035,7 +3105,7 @@
|
|
|
3035
3105
|
}
|
|
3036
3106
|
};
|
|
3037
3107
|
|
|
3038
|
-
var _directLoad = function() {
|
|
3108
|
+
var _directLoad = function () {
|
|
3039
3109
|
logger.debug("SENDING THE NORMAL REQUEST ");
|
|
3040
3110
|
try {
|
|
3041
3111
|
xhr.send(_DataStringify(service.data));
|
|
@@ -3051,10 +3121,10 @@
|
|
|
3051
3121
|
if (service.cached) {
|
|
3052
3122
|
var cache = new ComplexStorageCache({
|
|
3053
3123
|
index: service.data,
|
|
3054
|
-
load
|
|
3124
|
+
load(cacheController) {
|
|
3055
3125
|
_directLoad.call(this);
|
|
3056
3126
|
},
|
|
3057
|
-
alternate
|
|
3127
|
+
alternate(cacheController) {
|
|
3058
3128
|
if (service.method === "GET") {
|
|
3059
3129
|
service.template = cacheController.cache.getCached(service.name);
|
|
3060
3130
|
if (typeof service.done === "function") {
|
|
@@ -3082,19 +3152,19 @@
|
|
|
3082
3152
|
return _promise;
|
|
3083
3153
|
};
|
|
3084
3154
|
|
|
3085
|
-
var _serviceLoaderInNode = function(service, _async) {
|
|
3155
|
+
var _serviceLoaderInNode = function (service, _async) {
|
|
3086
3156
|
var _promise = new Promise(
|
|
3087
|
-
function(resolve, reject) {
|
|
3157
|
+
function (resolve, reject) {
|
|
3088
3158
|
if (typeof URL === "undefined") {
|
|
3089
3159
|
global.URL = require("url").URL;
|
|
3090
3160
|
let URL = global.URL;
|
|
3091
|
-
}
|
|
3161
|
+
}
|
|
3092
3162
|
var serviceURL = new URL(service.url);
|
|
3093
3163
|
var req;
|
|
3094
|
-
service.useHTTP2 = Object.hasOwnProperty.call(service,"useHTTP2") && service.useHTTP2;
|
|
3164
|
+
service.useHTTP2 = Object.hasOwnProperty.call(service, "useHTTP2") && service.useHTTP2;
|
|
3095
3165
|
|
|
3096
3166
|
|
|
3097
|
-
var captureEvents = function (req){
|
|
3167
|
+
var captureEvents = function (req) {
|
|
3098
3168
|
logger.debug("LOADING SERVICE DATA (non-browser) {{DATA}} FROM {{URL}}".replace("{{DATA}}", _DataStringify(service.data)).replace("{{URL}}", service.url));
|
|
3099
3169
|
var dataXML;
|
|
3100
3170
|
var standardResponse = {
|
|
@@ -3104,20 +3174,20 @@
|
|
|
3104
3174
|
"responseHeaders": null
|
|
3105
3175
|
};
|
|
3106
3176
|
|
|
3107
|
-
if (typeof service.data === "object" && service.data !== null){
|
|
3108
|
-
if (service.useHTTP2){
|
|
3177
|
+
if (typeof service.data === "object" && service.data !== null) {
|
|
3178
|
+
if (service.useHTTP2) {
|
|
3109
3179
|
try {
|
|
3110
3180
|
logger.debug("Sending data...");
|
|
3111
3181
|
let buffer = new Buffer(_DataStringify(service.data));
|
|
3112
3182
|
req.write(buffer);
|
|
3113
|
-
}catch (e){
|
|
3183
|
+
} catch (e) {
|
|
3114
3184
|
logger.debug("It was not possible to send any data");
|
|
3115
3185
|
}
|
|
3116
3186
|
}
|
|
3117
3187
|
}
|
|
3118
3188
|
|
|
3119
3189
|
dataXML = "";
|
|
3120
|
-
req.on("response", (responseHeaders,flags) => {
|
|
3190
|
+
req.on("response", (responseHeaders, flags) => {
|
|
3121
3191
|
logger.debug("receiving response...");
|
|
3122
3192
|
standardResponse.responseHeaders = responseHeaders;
|
|
3123
3193
|
/*
|
|
@@ -3130,16 +3200,16 @@
|
|
|
3130
3200
|
req.on("data", (chunk) => {
|
|
3131
3201
|
logger.debug("receiving data...");
|
|
3132
3202
|
// do something with the data
|
|
3133
|
-
dataXML += ""+ chunk.toString();
|
|
3203
|
+
dataXML += "" + chunk.toString();
|
|
3134
3204
|
service.template = dataXML;
|
|
3135
3205
|
});
|
|
3136
|
-
if (service.useHTTP2){
|
|
3206
|
+
if (service.useHTTP2) {
|
|
3137
3207
|
req.resume();
|
|
3138
3208
|
}
|
|
3139
3209
|
req.on("end", () => {
|
|
3140
3210
|
logger.debug("ending call...");
|
|
3141
3211
|
service.template = dataXML;
|
|
3142
|
-
if (Object.hasOwnProperty.call(service,"useHTTP2") && service.useHTTP2) {
|
|
3212
|
+
if (Object.hasOwnProperty.call(service, "useHTTP2") && service.useHTTP2) {
|
|
3143
3213
|
client.destroy();
|
|
3144
3214
|
} else {
|
|
3145
3215
|
req.destroy();
|
|
@@ -3147,7 +3217,7 @@
|
|
|
3147
3217
|
service.done.call(service, standardResponse);
|
|
3148
3218
|
resolve.call(_promise, standardResponse);
|
|
3149
3219
|
});
|
|
3150
|
-
if (service.useHTTP2){
|
|
3220
|
+
if (service.useHTTP2) {
|
|
3151
3221
|
req.end();
|
|
3152
3222
|
}
|
|
3153
3223
|
|
|
@@ -3163,12 +3233,12 @@
|
|
|
3163
3233
|
":method": service.method,
|
|
3164
3234
|
":path": serviceURL.pathname
|
|
3165
3235
|
}, service.options);
|
|
3166
|
-
requestOptions = Object.assign(requestOptions,service.headers);
|
|
3236
|
+
requestOptions = Object.assign(requestOptions, service.headers);
|
|
3167
3237
|
req = client.request(requestOptions);
|
|
3168
3238
|
req.setEncoding("utf8");
|
|
3169
3239
|
captureEvents(req);
|
|
3170
3240
|
} else {
|
|
3171
|
-
if (serviceURL.protocol === "http:"){
|
|
3241
|
+
if (serviceURL.protocol === "http:") {
|
|
3172
3242
|
var http = require("http");
|
|
3173
3243
|
var request = http.request;
|
|
3174
3244
|
requestOptions = Object.assign({
|
|
@@ -3177,7 +3247,7 @@
|
|
|
3177
3247
|
}, service.options);
|
|
3178
3248
|
var req = request(service.url);
|
|
3179
3249
|
captureEvents(req);
|
|
3180
|
-
} else if (serviceURL.protocol === "https:"){
|
|
3250
|
+
} else if (serviceURL.protocol === "https:") {
|
|
3181
3251
|
var https = require("https");
|
|
3182
3252
|
requestOptions = Object.assign({
|
|
3183
3253
|
hostname: serviceURL.hostname,
|
|
@@ -3186,14 +3256,14 @@
|
|
|
3186
3256
|
method: service.method,
|
|
3187
3257
|
headers: service.headers
|
|
3188
3258
|
}, service.options);
|
|
3189
|
-
var _req_ = https.request(requestOptions, function (req){
|
|
3259
|
+
var _req_ = https.request(requestOptions, function (req) {
|
|
3190
3260
|
captureEvents(req);
|
|
3191
3261
|
});
|
|
3192
3262
|
_req_.end();
|
|
3193
3263
|
} else {
|
|
3194
|
-
var e = "Protocol not supported: "+serviceURL.protocol;
|
|
3264
|
+
var e = "Protocol not supported: " + serviceURL.protocol;
|
|
3195
3265
|
logger.debug(e);
|
|
3196
|
-
throw new Error
|
|
3266
|
+
throw new Error(e);
|
|
3197
3267
|
}
|
|
3198
3268
|
}
|
|
3199
3269
|
|
|
@@ -3204,18 +3274,18 @@
|
|
|
3204
3274
|
reject.call(_promise, e);
|
|
3205
3275
|
|
|
3206
3276
|
}
|
|
3207
|
-
}).catch(function(e) {
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3277
|
+
}).catch(function (e) {
|
|
3278
|
+
console.log(e);
|
|
3279
|
+
logger.debug("Something happened when trying to call the service: " + service.name);
|
|
3280
|
+
service.fail.call(service, e);
|
|
3211
3281
|
});
|
|
3212
3282
|
return _promise;
|
|
3213
3283
|
|
|
3214
3284
|
};
|
|
3215
3285
|
|
|
3216
|
-
var _serviceLoaderMockup = function(service, _async) {
|
|
3286
|
+
var _serviceLoaderMockup = function (service, _async) {
|
|
3217
3287
|
var _promise = new Promise(
|
|
3218
|
-
function(resolve, reject) {
|
|
3288
|
+
function (resolve, reject) {
|
|
3219
3289
|
logger.debug(`Calling mockup service ${service.name} ...`);
|
|
3220
3290
|
var standardResponse = {
|
|
3221
3291
|
"request": null,
|
|
@@ -3231,8 +3301,8 @@
|
|
|
3231
3301
|
});
|
|
3232
3302
|
return _promise;
|
|
3233
3303
|
};
|
|
3234
|
-
var _serviceLoaderLocal = function(service, _async) {
|
|
3235
|
-
var _promise = new Promise
|
|
3304
|
+
var _serviceLoaderLocal = function (service, _async) {
|
|
3305
|
+
var _promise = new Promise(
|
|
3236
3306
|
function (resolve, reject) {
|
|
3237
3307
|
logger.debug(`Calling local service ${service.name} ...`);
|
|
3238
3308
|
var standardResponse = {
|
|
@@ -3284,425 +3354,221 @@
|
|
|
3284
3354
|
Export(isQCObjects_Object);
|
|
3285
3355
|
Export(NamespaceRef);
|
|
3286
3356
|
|
|
3287
|
-
asyncLoad(function() {
|
|
3288
3357
|
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
var
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
logger.debug("Service Worker Ready");
|
|
3323
|
-
resolve.call(_promise, registration);
|
|
3324
|
-
}, function(registration) {
|
|
3325
|
-
logger.debug("Error loading Service Worker");
|
|
3326
|
-
reject.call(_promise, registration);
|
|
3327
|
-
});
|
|
3358
|
+
if (isBrowser) {
|
|
3359
|
+
|
|
3360
|
+
Element.prototype.buildComponents = function (rebuildObjects = false) {
|
|
3361
|
+
var tagFilter = (!rebuildObjects) ? ("component:not([loaded])") : ("component");
|
|
3362
|
+
var d = this;
|
|
3363
|
+
var _buildComponent = function (components, __parent__) {
|
|
3364
|
+
var componentsBuiltWith = components.map(function (_component_, _c) {
|
|
3365
|
+
_component_ = components[_c];
|
|
3366
|
+
var data = {};
|
|
3367
|
+
var attributenames = components[_c].getAttributeNames().filter(function (a) {
|
|
3368
|
+
return a.startsWith("data-");
|
|
3369
|
+
}).map(function (a) {
|
|
3370
|
+
return a.split("-")[1];
|
|
3371
|
+
});
|
|
3372
|
+
attributenames.map(function (_attribute_name_) {
|
|
3373
|
+
data[_attribute_name_] = components[_c].getAttribute("data-" + _attribute_name_);
|
|
3374
|
+
});
|
|
3375
|
+
var componentDone = function () {
|
|
3376
|
+
var _component_ = this;
|
|
3377
|
+
if (typeof _component_ === "undefined") {
|
|
3378
|
+
throw new Error("componentDone() has lost its context");
|
|
3379
|
+
}
|
|
3380
|
+
if (typeof _component_.body === "undefined") {
|
|
3381
|
+
throw new Error("The component has no body");
|
|
3382
|
+
}
|
|
3383
|
+
var viewName = _component_.body.getAttribute("viewClass");
|
|
3384
|
+
var _View = ClassFactory(viewName);
|
|
3385
|
+
if (typeof _View !== "undefined") {
|
|
3386
|
+
_component_.view = New(_View, {
|
|
3387
|
+
component: _component_
|
|
3388
|
+
}); // Initializes the main view for the component
|
|
3389
|
+
if (Object.hasOwnProperty.call(_component_.view, "done") && typeof _component_.view.done === "function") {
|
|
3390
|
+
_component_.view.done.call(_component_.view);
|
|
3328
3391
|
}
|
|
3329
|
-
});
|
|
3330
|
-
}
|
|
3331
|
-
return _promise;
|
|
3332
|
-
};
|
|
3333
|
-
var _buildComponents = function() {
|
|
3334
|
-
if (isBrowser) {
|
|
3335
|
-
logger.debug("Starting to bind routes");
|
|
3336
|
-
_top._bindroute_.call(ClassFactory("Component"));
|
|
3337
|
-
logger.debug("Starting to building components");
|
|
3338
|
-
global.componentsStack = document.buildComponents.call(document);
|
|
3339
|
-
logger.debug("Initializing the service worker");
|
|
3340
|
-
__load__serviceWorker.call(_top).catch(function() {
|
|
3341
|
-
logger.debug("error loading the service worker");
|
|
3342
|
-
});
|
|
3343
|
-
|
|
3344
|
-
}
|
|
3345
|
-
};
|
|
3346
|
-
logger.debug("Starting to load the config settings...");
|
|
3347
|
-
if (_top.CONFIG.get("useConfigService", false)) {
|
|
3348
|
-
logger.debug("Loading settings using local configuration file...");
|
|
3349
|
-
_top.global.configService = New(ClassFactory("ConfigService"));
|
|
3350
|
-
_top.global.configService.configLoaded = _buildComponents;
|
|
3351
|
-
serviceLoader(_top.global.configService);
|
|
3352
|
-
} else {
|
|
3353
|
-
logger.debug("Starting to load the components...");
|
|
3354
|
-
_buildComponents.call(this);
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
});
|
|
3358
|
-
var _g_ = New(ClassFactory("GlobalSettings"));
|
|
3359
|
-
|
|
3360
|
-
Object.defineProperty(global,"PackagesNameList",{
|
|
3361
|
-
set(val){
|
|
3362
|
-
logger.debug("PackagesNameList is readonly");
|
|
3363
|
-
return;
|
|
3364
|
-
},
|
|
3365
|
-
get(){
|
|
3366
|
-
var _get_packages_names = function (_packages){
|
|
3367
|
-
var _keys = [];
|
|
3368
|
-
for (var _k in _packages){
|
|
3369
|
-
if (
|
|
3370
|
-
typeof _packages[_k] !== "undefined"
|
|
3371
|
-
&& typeof _packages[_k] !== "function"
|
|
3372
|
-
&& Object.hasOwnProperty.call(_packages[_k],"length")
|
|
3373
|
-
&& _packages[_k].length>0
|
|
3374
|
-
){
|
|
3375
|
-
_keys.push(_k);
|
|
3376
|
-
_keys = _keys.concat(_get_packages_names(_packages[_k]));
|
|
3377
3392
|
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
return _get_packages_names(_QC_PACKAGES);
|
|
3382
|
-
}
|
|
3383
|
-
});
|
|
3384
|
-
|
|
3385
|
-
Object.defineProperty(global,"PackagesList",{
|
|
3386
|
-
set(value){
|
|
3387
|
-
logger.debug("PackagesList is readonly");
|
|
3388
|
-
return;
|
|
3389
|
-
},
|
|
3390
|
-
get(){
|
|
3391
|
-
return global.PackagesNameList.map(function (packagename) {
|
|
3392
|
-
let _classesList = Package(packagename);
|
|
3393
|
-
let _ret_;
|
|
3394
|
-
if (_classesList){
|
|
3395
|
-
_ret_ = {
|
|
3396
|
-
packageName:packagename,
|
|
3397
|
-
classesList:_classesList.filter(function (_packageClass) {
|
|
3398
|
-
return isQCObjects_Class(_packageClass);
|
|
3399
|
-
}
|
|
3400
|
-
)
|
|
3401
|
-
};
|
|
3402
|
-
}
|
|
3403
|
-
return _ret_;
|
|
3404
|
-
}).filter(function (_p){return typeof _p !== "undefined";});
|
|
3405
|
-
}
|
|
3406
|
-
});
|
|
3407
|
-
|
|
3408
|
-
Object.defineProperty(global,"ClassesList",{
|
|
3409
|
-
set(value){
|
|
3410
|
-
logger.debug("ClassesList is readonly");
|
|
3411
|
-
return;
|
|
3412
|
-
},
|
|
3413
|
-
get(){
|
|
3414
|
-
var _classesList = [];
|
|
3415
|
-
global.PackagesList.map(function (_package_element){
|
|
3416
|
-
_classesList = _classesList.concat(_package_element.classesList.map(
|
|
3417
|
-
function (_class_element){
|
|
3418
|
-
return {
|
|
3419
|
-
packageName:_package_element.packageName,
|
|
3420
|
-
className:_package_element.packageName+"."+_class_element.__definition.__classType,
|
|
3421
|
-
classFactory:_class_element
|
|
3422
|
-
};
|
|
3393
|
+
var controllerName = _component_.body.getAttribute("controllerClass");
|
|
3394
|
+
if (!controllerName) {
|
|
3395
|
+
controllerName = "Controller";
|
|
3423
3396
|
}
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
if (isBrowser) {
|
|
3447
|
-
// use of GLOBAL word is deprecated in node.js
|
|
3448
|
-
// this is only for compatibility purpose with old versions of QCObjects in browsers
|
|
3449
|
-
Class("GLOBAL", _QC_CLASSES["global"]); // case insensitive for compatibility con old versions;
|
|
3450
|
-
Export(ClassFactory("GLOBAL"));
|
|
3451
|
-
}
|
|
3452
|
-
Export(global);
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
if (_top.CONFIG.get("useSDK")) {
|
|
3456
|
-
(function() {
|
|
3457
|
-
var remoteImportsPath = _top.CONFIG.get("remoteImportsPath");
|
|
3458
|
-
var external = (!_top.CONFIG.get("useLocalSDK")) ? (true) : (false);
|
|
3459
|
-
_top.CONFIG.set("remoteImportsPath", _top.CONFIG.get("remoteSDKPath"));
|
|
3460
|
-
|
|
3461
|
-
var tryImportingSDK = false;
|
|
3462
|
-
var sdkName = "QCObjects-SDK";
|
|
3463
|
-
if (isBrowser) {
|
|
3464
|
-
tryImportingSDK = true;
|
|
3465
|
-
} else {
|
|
3466
|
-
var sdkPath = findPackageNodePath("qcobjects-sdk");
|
|
3467
|
-
if (sdkPath !== null) {
|
|
3468
|
-
sdkName = "qcobjects-sdk";
|
|
3469
|
-
tryImportingSDK = true;
|
|
3470
|
-
} else {
|
|
3471
|
-
sdkName = "node_modules/qcobjects-sdk/QCObjects-SDK";
|
|
3472
|
-
tryImportingSDK = true;
|
|
3473
|
-
}
|
|
3474
|
-
}
|
|
3475
|
-
|
|
3476
|
-
if (tryImportingSDK) {
|
|
3477
|
-
logger.info("Importing SDK... " + sdkName);
|
|
3478
|
-
Import(sdkName, function() {
|
|
3479
|
-
if (external) {
|
|
3480
|
-
logger.debug("QCObjects-SDK.js loaded from remote location");
|
|
3397
|
+
var _Controller = ClassFactory(controllerName);
|
|
3398
|
+
if (typeof _Controller !== "undefined") {
|
|
3399
|
+
_component_.controller = New(_Controller, {
|
|
3400
|
+
component: _component_
|
|
3401
|
+
}); // Initializes the main controller for the component
|
|
3402
|
+
if (Object.hasOwnProperty.call(_component_.controller, "done") && typeof _component_.controller.done === "function") {
|
|
3403
|
+
_component_.controller.done.call(_component_.controller);
|
|
3404
|
+
}
|
|
3405
|
+
if (Object.hasOwnProperty.call(_component_.controller, "createRoutingController")) {
|
|
3406
|
+
_component_.controller.createRoutingController.call(_component_.controller);
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
var effectClassName = _component_.body.getAttribute("effectClass");
|
|
3410
|
+
var applyEffectTo = _component_.body.getAttribute("apply-effect-to");
|
|
3411
|
+
applyEffectTo = (applyEffectTo !== null) ? (applyEffectTo) : ("load");
|
|
3412
|
+
if (effectClassName !== null && applyEffectTo === "observe") {
|
|
3413
|
+
_component_.applyObserveTransitionEffect(effectClassName);
|
|
3414
|
+
} else if (effectClassName !== null && applyEffectTo === "load") {
|
|
3415
|
+
_component_.applyTransitionEffect(effectClassName);
|
|
3416
|
+
}
|
|
3417
|
+
if (_component_.shadowed && (typeof _component_.shadowRoot !== "undefined")) {
|
|
3418
|
+
_component_.subcomponents = _buildComponent(_component_.shadowRoot.subelements(tagFilter), _component_);
|
|
3481
3419
|
} else {
|
|
3482
|
-
|
|
3420
|
+
_component_.subcomponents = _buildComponent(_component_.body.subelements(tagFilter), _component_);
|
|
3483
3421
|
}
|
|
3484
|
-
_top.CONFIG.set("remoteImportsPath", remoteImportsPath);
|
|
3485
|
-
}, external);
|
|
3486
|
-
} else {
|
|
3487
|
-
logger.debug("SDK has not been imported as it is not available at the moment");
|
|
3488
|
-
}
|
|
3489
|
-
}).call(null);
|
|
3490
|
-
}
|
|
3491
|
-
|
|
3492
3422
|
|
|
3493
|
-
|
|
3423
|
+
if (_top.CONFIG.get("overrideComponentTag")) {
|
|
3424
|
+
_component_.body.outerHTML = this.body.innerHTML;
|
|
3425
|
+
}
|
|
3426
|
+
_component_.body.setAttribute("loaded", true);
|
|
3494
3427
|
|
|
3495
|
-
|
|
3428
|
+
_component_.runComponentHelpers();
|
|
3496
3429
|
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
var componentsBuiltWith = components.map (function (_component_, _c){
|
|
3502
|
-
_component_ = components[_c];
|
|
3503
|
-
var data = {};
|
|
3504
|
-
var attributenames = components[_c].getAttributeNames().filter(function(a) {
|
|
3505
|
-
return a.startsWith("data-");
|
|
3506
|
-
}).map(function(a) {
|
|
3507
|
-
return a.split("-")[1];
|
|
3508
|
-
});
|
|
3509
|
-
attributenames.map(function (_attribute_name_){
|
|
3510
|
-
data[_attribute_name_] = components[_c].getAttribute("data-" + _attribute_name_);
|
|
3511
|
-
});
|
|
3512
|
-
var componentDone = function() {
|
|
3513
|
-
var _component_ = this;
|
|
3514
|
-
if (typeof _component_ === "undefined") {
|
|
3515
|
-
throw new Error("componentDone() has lost its context");
|
|
3516
|
-
}
|
|
3517
|
-
if (typeof _component_.body === "undefined") {
|
|
3518
|
-
throw new Error("The component has no body");
|
|
3519
|
-
}
|
|
3520
|
-
var viewName = _component_.body.getAttribute("viewClass");
|
|
3521
|
-
var _View = ClassFactory(viewName);
|
|
3522
|
-
if (typeof _View !== "undefined") {
|
|
3523
|
-
_component_.view = New(_View, {
|
|
3524
|
-
component: _component_
|
|
3525
|
-
}); // Initializes the main view for the component
|
|
3526
|
-
if (Object.hasOwnProperty.call(_component_.view,"done") && typeof _component_.view.done === "function") {
|
|
3527
|
-
_component_.view.done.call(_component_.view);
|
|
3430
|
+
if ((Tag("component[loaded=true]").length * 100 / Tag("component").length) >= 100) {
|
|
3431
|
+
d.dispatchEvent(new CustomEvent("componentsloaded", {
|
|
3432
|
+
detail: {
|
|
3433
|
+
lastComponent: _component_
|
|
3528
3434
|
}
|
|
3529
|
-
}
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
controllerName = "Controller";
|
|
3533
|
-
}
|
|
3534
|
-
var _Controller = ClassFactory(controllerName);
|
|
3535
|
-
if (typeof _Controller !== "undefined") {
|
|
3536
|
-
_component_.controller = New(_Controller, {
|
|
3537
|
-
component: _component_
|
|
3538
|
-
}); // Initializes the main controller for the component
|
|
3539
|
-
if (Object.hasOwnProperty.call(_component_.controller,"done") && typeof _component_.controller.done === "function") {
|
|
3540
|
-
_component_.controller.done.call(_component_.controller);
|
|
3541
|
-
}
|
|
3542
|
-
if (Object.hasOwnProperty.call(_component_.controller,"createRoutingController")){
|
|
3543
|
-
_component_.controller.createRoutingController.call(_component_.controller);
|
|
3544
|
-
}
|
|
3545
|
-
}
|
|
3546
|
-
var effectClassName = _component_.body.getAttribute("effectClass");
|
|
3547
|
-
var applyEffectTo = _component_.body.getAttribute("apply-effect-to");
|
|
3548
|
-
applyEffectTo = (applyEffectTo !== null)?(applyEffectTo):("load");
|
|
3549
|
-
if (effectClassName !== null && applyEffectTo === "observe"){
|
|
3550
|
-
_component_.applyObserveTransitionEffect(effectClassName);
|
|
3551
|
-
} else if (effectClassName !== null && applyEffectTo === "load"){
|
|
3552
|
-
_component_.applyTransitionEffect(effectClassName);
|
|
3553
|
-
}
|
|
3554
|
-
if (_component_.shadowed && (typeof _component_.shadowRoot !== "undefined")){
|
|
3555
|
-
_component_.subcomponents = _buildComponent(_component_.shadowRoot.subelements(tagFilter), _component_);
|
|
3556
|
-
} else {
|
|
3557
|
-
_component_.subcomponents = _buildComponent(_component_.body.subelements(tagFilter), _component_);
|
|
3558
|
-
}
|
|
3435
|
+
}));
|
|
3436
|
+
}
|
|
3437
|
+
};
|
|
3559
3438
|
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3439
|
+
var __shadowed_not_set = (components[_c].getAttribute("shadowed") === null) ? (true) : (false);
|
|
3440
|
+
var __tplsource_attr_not_set = (components[_c].getAttribute("template-source") === null) ? (true) : (false);
|
|
3441
|
+
var shadowed = (components[_c].getAttribute("shadowed") === "true") ? (true) : (false);
|
|
3442
|
+
var __cached_not_set = (components[_c].getAttribute("cached") === null) ? (true) : (false);
|
|
3443
|
+
var cached = (components[_c].getAttribute("cached") === "true") ? (true) : (false);
|
|
3444
|
+
var tplextension = (typeof _top.CONFIG.get("tplextension") !== "undefined") ? (_top.CONFIG.get("tplextension")) : ("html");
|
|
3445
|
+
tplextension = (components[_c].getAttribute("tplextension") !== null) ? (components[_c].getAttribute("tplextension")) : (tplextension);
|
|
3446
|
+
var _componentName = components[_c].getAttribute("name");
|
|
3447
|
+
var _componentClassName = (components[_c].getAttribute("componentClass") !== null) ? (components[_c].getAttribute("componentClass")) : ("Component");
|
|
3448
|
+
var _serviceClassName = (components[_c].getAttribute("serviceClass") !== null) ? (components[_c].getAttribute("serviceClass")) : (null);
|
|
3449
|
+
/* __enable_service_class__ = true by default */
|
|
3450
|
+
var __enable_service_class__ = (
|
|
3451
|
+
(Object.hasOwnProperty.call(components[_c], "enableServiceClass") && components[_c].enableServiceClass) ||
|
|
3452
|
+
(!Object.hasOwnProperty.call(components[_c], "enableServiceClass"))
|
|
3453
|
+
) ? (true) : (false);
|
|
3454
|
+
var _response_to_data_ = (components[_c].getAttribute("response-to") !== null && components[_c].getAttribute("response-to") === "data") ? (true) : (false);
|
|
3455
|
+
var _response_to_template_ = (components[_c].getAttribute("response-to") !== null && components[_c].getAttribute("response-to") === "template") ? (true) : (false);
|
|
3456
|
+
let __componentClassName = (_top.CONFIG.get("preserveComponentBodyTag")) ? (
|
|
3457
|
+
(_componentName !== null) ? ("com.qcobjects.components." + _componentName + ".ComponentBody") : ("com.qcobjects.components.ComponentBody")
|
|
3458
|
+
) : (_componentClassName);
|
|
3459
|
+
_componentName = (_componentName !== null) ? (_componentName) : (
|
|
3460
|
+
(ClassFactory(__componentClassName) &&
|
|
3461
|
+
typeof ClassFactory(__componentClassName).name !== "undefined"
|
|
3462
|
+
) ? (
|
|
3463
|
+
ClassFactory(__componentClassName).name
|
|
3464
|
+
) : ("")
|
|
3465
|
+
);
|
|
3466
|
+
var __classDefinition = ClassFactory(__componentClassName);
|
|
3467
|
+
var __tplsource_prop_set = (__componentClassName !== "Component" && ((typeof __classDefinition !== "undefined" && typeof __classDefinition.tplsource === "string") && __classDefinition.tplsource !== "")) ? (true) : (false);
|
|
3468
|
+
var tplsource = (__tplsource_attr_not_set && __tplsource_prop_set) ? (__classDefinition.tplsource) : ((__tplsource_attr_not_set) ? ("default") : (components[_c].getAttribute("template-source")));
|
|
3469
|
+
logger.debug(`template source for ${_componentName} is ${tplsource} `);
|
|
3470
|
+
logger.debug(`type for ${_componentName} is ${__getType__(__classDefinition)} `);
|
|
3471
|
+
|
|
3472
|
+
var componentURI;
|
|
3473
|
+
componentURI = ComponentURI({
|
|
3474
|
+
"COMPONENTS_BASE_PATH": _top.CONFIG.get("componentsBasePath"),
|
|
3475
|
+
"COMPONENT_NAME": _componentName,
|
|
3476
|
+
"TPLEXTENSION": tplextension,
|
|
3477
|
+
"TPL_SOURCE": tplsource
|
|
3478
|
+
});
|
|
3479
|
+
if (_top.CONFIG.get("preserveComponentBodyTag")) {
|
|
3480
|
+
Package((_componentName !== "") ? ("com.qcobjects.components." + _componentName + "") : ("com.qcobjects.components"), [
|
|
3481
|
+
Class("ComponentBody", ClassFactory("Component"), {
|
|
3482
|
+
name: _componentName,
|
|
3483
|
+
tplsource: tplsource,
|
|
3484
|
+
tplextension: tplextension,
|
|
3485
|
+
reload: true
|
|
3486
|
+
})
|
|
3487
|
+
]);
|
|
3488
|
+
}
|
|
3564
3489
|
|
|
3565
|
-
|
|
3490
|
+
var __serviceClass;
|
|
3491
|
+
if (__enable_service_class__ && _serviceClassName !== null) {
|
|
3492
|
+
__serviceClass = ClassFactory(_serviceClassName);
|
|
3493
|
+
}
|
|
3494
|
+
if (!_response_to_data_ && __classDefinition && Object.hasOwnProperty.call(__classDefinition, "responseTo")) {
|
|
3495
|
+
_response_to_data_ = (__classDefinition.responseTo === "data") ? (true) : (false);
|
|
3496
|
+
} else if (!_response_to_data_ && Object.hasOwnProperty.call(ClassFactory("Component"), "responseTo")) {
|
|
3497
|
+
_response_to_data_ = (ClassFactory("Component").responseTo === "data") ? (true) : (false);
|
|
3498
|
+
}
|
|
3499
|
+
if (!_response_to_template_ && __classDefinition && Object.hasOwnProperty.call(__classDefinition, "responseTo")) {
|
|
3500
|
+
_response_to_template_ = (__classDefinition.responseTo === "template") ? (true) : (false);
|
|
3501
|
+
} else if (!_response_to_template_ && Object.hasOwnProperty.call(ClassFactory("Component"), "responseTo")) {
|
|
3502
|
+
_response_to_template_ = (ClassFactory("Component").responseTo === "template") ? (true) : (false);
|
|
3503
|
+
}
|
|
3566
3504
|
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3505
|
+
var __create_component_instance_ = function (data, serviceResponse) {
|
|
3506
|
+
var __shadowed = (__shadowed_not_set) ? ((__classDefinition && __classDefinition.shadowed) || ClassFactory("Component").shadowed) : (shadowed);
|
|
3507
|
+
var __definition = {
|
|
3508
|
+
__parent__: __parent__,
|
|
3509
|
+
name: _componentName,
|
|
3510
|
+
data: data,
|
|
3511
|
+
cached: (__cached_not_set) ? (ClassFactory("Component").cached) : (cached),
|
|
3512
|
+
shadowed: __shadowed,
|
|
3513
|
+
tplextension: tplextension,
|
|
3514
|
+
body: (_top.CONFIG.get("preserveComponentBodyTag")) ? (_DOMCreateElement("componentBody")) : (components[_c]),
|
|
3515
|
+
templateURI: componentURI,
|
|
3516
|
+
tplsource: tplsource,
|
|
3517
|
+
subcomponents: []
|
|
3574
3518
|
};
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
var __tplsource_attr_not_set = (components[_c].getAttribute("template-source") === null) ? (true) : (false);
|
|
3578
|
-
var shadowed = (components[_c].getAttribute("shadowed") === "true") ? (true) : (false);
|
|
3579
|
-
var __cached_not_set = (components[_c].getAttribute("cached") === null) ? (true) : (false);
|
|
3580
|
-
var cached = (components[_c].getAttribute("cached") === "true") ? (true) : (false);
|
|
3581
|
-
var tplextension = (typeof _top.CONFIG.get("tplextension") !== "undefined") ? (_top.CONFIG.get("tplextension")) : ("html");
|
|
3582
|
-
tplextension = (components[_c].getAttribute("tplextension") !== null) ? (components[_c].getAttribute("tplextension")) : (tplextension);
|
|
3583
|
-
var _componentName = components[_c].getAttribute("name");
|
|
3584
|
-
var _componentClassName = (components[_c].getAttribute("componentClass") !== null) ? (components[_c].getAttribute("componentClass")) : ("Component");
|
|
3585
|
-
var _serviceClassName = (components[_c].getAttribute("serviceClass") !== null) ? (components[_c].getAttribute("serviceClass")) : (null);
|
|
3586
|
-
/* __enable_service_class__ = true by default */
|
|
3587
|
-
var __enable_service_class__ = (
|
|
3588
|
-
(Object.hasOwnProperty.call(components[_c], "enableServiceClass") && components[_c].enableServiceClass)
|
|
3589
|
-
|| (!Object.hasOwnProperty.call(components[_c], "enableServiceClass"))
|
|
3590
|
-
) ? (true) : (false);
|
|
3591
|
-
var _response_to_data_ = (components[_c].getAttribute("response-to") !== null && components[_c].getAttribute("response-to") === "data") ? (true) : (false);
|
|
3592
|
-
var _response_to_template_ = (components[_c].getAttribute("response-to") !== null && components[_c].getAttribute("response-to") === "template") ? (true) : (false);
|
|
3593
|
-
let __componentClassName = (_top.CONFIG.get("preserveComponentBodyTag"))?(
|
|
3594
|
-
(_componentName !== null)?("com.qcobjects.components."+_componentName+".ComponentBody"):("com.qcobjects.components.ComponentBody")
|
|
3595
|
-
):(_componentClassName);
|
|
3596
|
-
_componentName = (_componentName !== null)?(_componentName):(
|
|
3597
|
-
(ClassFactory(__componentClassName)
|
|
3598
|
-
&& typeof ClassFactory(__componentClassName).name !== "undefined"
|
|
3599
|
-
)?(
|
|
3600
|
-
ClassFactory(__componentClassName).name
|
|
3601
|
-
):("")
|
|
3602
|
-
);
|
|
3603
|
-
var __classDefinition = ClassFactory(__componentClassName);
|
|
3604
|
-
var __tplsource_prop_set = (__componentClassName !== "Component" && ((typeof __classDefinition !== "undefined" && typeof __classDefinition.tplsource === "string") && __classDefinition.tplsource !== "") ) ? (true) : (false);
|
|
3605
|
-
var tplsource = (__tplsource_attr_not_set && __tplsource_prop_set) ? (__classDefinition.tplsource) : ((__tplsource_attr_not_set)?("default"):(components[_c].getAttribute("template-source")));
|
|
3606
|
-
logger.debug (`template source for ${_componentName} is ${tplsource} `);
|
|
3607
|
-
logger.debug (`type for ${_componentName} is ${__getType__(__classDefinition)} `);
|
|
3608
|
-
|
|
3609
|
-
var componentURI;
|
|
3610
|
-
componentURI = ComponentURI({
|
|
3611
|
-
"COMPONENTS_BASE_PATH": _top.CONFIG.get("componentsBasePath"),
|
|
3612
|
-
"COMPONENT_NAME": _componentName,
|
|
3613
|
-
"TPLEXTENSION": tplextension,
|
|
3614
|
-
"TPL_SOURCE": tplsource
|
|
3615
|
-
});
|
|
3616
|
-
if (_top.CONFIG.get("preserveComponentBodyTag")) {
|
|
3617
|
-
Package((_componentName !== "")?("com.qcobjects.components."+_componentName+""):("com.qcobjects.components"),[
|
|
3618
|
-
Class("ComponentBody", ClassFactory("Component"), {
|
|
3619
|
-
name: _componentName,
|
|
3620
|
-
tplsource:tplsource,
|
|
3621
|
-
tplextension:tplextension,
|
|
3622
|
-
reload: true
|
|
3623
|
-
})
|
|
3624
|
-
]);
|
|
3519
|
+
if (_response_to_template_) {
|
|
3520
|
+
__definition.template = serviceResponse;
|
|
3625
3521
|
}
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
}
|
|
3631
|
-
if (!_response_to_data_ && __classDefinition && Object.hasOwnProperty.call(__classDefinition, "responseTo")){
|
|
3632
|
-
_response_to_data_ = (__classDefinition.responseTo === "data")?(true):(false);
|
|
3633
|
-
} else if (!_response_to_data_ && Object.hasOwnProperty.call(ClassFactory("Component"), "responseTo")){
|
|
3634
|
-
_response_to_data_ = (ClassFactory("Component").responseTo === "data")?(true):(false);
|
|
3522
|
+
if (typeof _componentName === "undefined" || _componentName === "" || _componentName === null) {
|
|
3523
|
+
/* this allows to use the original property defined
|
|
3524
|
+
in the component definition if it is not present in the tag */
|
|
3525
|
+
delete __definition.name;
|
|
3635
3526
|
}
|
|
3636
|
-
if (
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3527
|
+
if (componentURI === "") {
|
|
3528
|
+
/* this allows to use the original property defined
|
|
3529
|
+
in the component definition if it is not present in the tag */
|
|
3530
|
+
delete __definition.templateURI;
|
|
3640
3531
|
}
|
|
3532
|
+
var newComponent = New(__classDefinition, __definition);
|
|
3641
3533
|
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
var __definition = {
|
|
3645
|
-
__parent__:__parent__,
|
|
3646
|
-
name: _componentName,
|
|
3647
|
-
data: data,
|
|
3648
|
-
cached: (__cached_not_set) ? (ClassFactory("Component").cached) : (cached),
|
|
3649
|
-
shadowed: __shadowed,
|
|
3650
|
-
tplextension: tplextension,
|
|
3651
|
-
body: (_top.CONFIG.get("preserveComponentBodyTag")) ? (_DOMCreateElement("componentBody")):(components[_c]),
|
|
3652
|
-
templateURI: componentURI,
|
|
3653
|
-
tplsource: tplsource,
|
|
3654
|
-
subcomponents: []
|
|
3655
|
-
};
|
|
3656
|
-
if (_response_to_template_){
|
|
3657
|
-
__definition.template = serviceResponse;
|
|
3658
|
-
}
|
|
3659
|
-
if (typeof _componentName === "undefined" || _componentName === "" || _componentName === null){
|
|
3660
|
-
/* this allows to use the original property defined
|
|
3661
|
-
in the component definition if it is not present in the tag */
|
|
3662
|
-
delete __definition.name;
|
|
3663
|
-
}
|
|
3664
|
-
if (componentURI === ""){
|
|
3665
|
-
/* this allows to use the original property defined
|
|
3666
|
-
in the component definition if it is not present in the tag */
|
|
3667
|
-
delete __definition.templateURI;
|
|
3668
|
-
}
|
|
3669
|
-
var newComponent = New(__classDefinition, __definition);
|
|
3670
|
-
|
|
3671
|
-
if (_top.CONFIG.get("preserveComponentBodyTag")) {
|
|
3672
|
-
components[_c].append(newComponent);
|
|
3673
|
-
}
|
|
3674
|
-
newComponent.done = componentDone;
|
|
3675
|
-
return newComponent;
|
|
3676
|
-
};
|
|
3677
|
-
var newComponent;
|
|
3678
|
-
if (typeof __serviceClass !== "undefined"
|
|
3679
|
-
&& (typeof __enable_service_class__ !== "undefined"
|
|
3680
|
-
&& __enable_service_class__ === true)
|
|
3681
|
-
&& (_response_to_data_ || _response_to_template_)
|
|
3682
|
-
){
|
|
3683
|
-
logger.info("Loading service "+_serviceClassName);
|
|
3684
|
-
var serviceInstance = New(__serviceClass, {
|
|
3685
|
-
data: data
|
|
3686
|
-
});
|
|
3687
|
-
serviceLoader(serviceInstance).then(function ({request, service}){
|
|
3688
|
-
var serviceResponse = service.template;
|
|
3689
|
-
if (_response_to_data_){
|
|
3690
|
-
if (typeof data === "object" && typeof serviceResponse === "object"){
|
|
3691
|
-
data = Object.assign(data, serviceResponse);
|
|
3692
|
-
} else {
|
|
3693
|
-
data = serviceResponse;
|
|
3694
|
-
}
|
|
3695
|
-
}
|
|
3696
|
-
newComponent = __create_component_instance_.call(this, data, serviceResponse);
|
|
3697
|
-
newComponent.serviceInstance = serviceInstance;
|
|
3698
|
-
newComponent.serviceData = data;
|
|
3699
|
-
}).catch (function (e){
|
|
3700
|
-
logger.debug("Something went wroing while trying to load the service "+_serviceClassName);
|
|
3701
|
-
});
|
|
3702
|
-
} else {
|
|
3703
|
-
newComponent = __create_component_instance_.call(this, data, null);
|
|
3534
|
+
if (_top.CONFIG.get("preserveComponentBodyTag")) {
|
|
3535
|
+
components[_c].append(newComponent);
|
|
3704
3536
|
}
|
|
3537
|
+
newComponent.done = componentDone;
|
|
3705
3538
|
return newComponent;
|
|
3539
|
+
};
|
|
3540
|
+
var newComponent;
|
|
3541
|
+
if (typeof __serviceClass !== "undefined" &&
|
|
3542
|
+
(typeof __enable_service_class__ !== "undefined" &&
|
|
3543
|
+
__enable_service_class__ === true) &&
|
|
3544
|
+
(_response_to_data_ || _response_to_template_)
|
|
3545
|
+
) {
|
|
3546
|
+
logger.info("Loading service " + _serviceClassName);
|
|
3547
|
+
var serviceInstance = New(__serviceClass, {
|
|
3548
|
+
data: data
|
|
3549
|
+
});
|
|
3550
|
+
serviceLoader(serviceInstance).then(function ({
|
|
3551
|
+
request,
|
|
3552
|
+
service
|
|
3553
|
+
}) {
|
|
3554
|
+
var serviceResponse = service.template;
|
|
3555
|
+
if (_response_to_data_) {
|
|
3556
|
+
if (typeof data === "object" && typeof serviceResponse === "object") {
|
|
3557
|
+
data = Object.assign(data, serviceResponse);
|
|
3558
|
+
} else {
|
|
3559
|
+
data = serviceResponse;
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
newComponent = __create_component_instance_.call(this, data, serviceResponse);
|
|
3563
|
+
newComponent.serviceInstance = serviceInstance;
|
|
3564
|
+
newComponent.serviceData = data;
|
|
3565
|
+
}).catch(function (e) {
|
|
3566
|
+
logger.debug("Something went wroing while trying to load the service " + _serviceClassName);
|
|
3567
|
+
});
|
|
3568
|
+
} else {
|
|
3569
|
+
newComponent = __create_component_instance_.call(this, data, null);
|
|
3570
|
+
}
|
|
3571
|
+
return newComponent;
|
|
3706
3572
|
});
|
|
3707
3573
|
return componentsBuiltWith;
|
|
3708
3574
|
};
|
|
@@ -3717,28 +3583,28 @@
|
|
|
3717
3583
|
const componentWidget = this;
|
|
3718
3584
|
const componentName = componentWidget.nodeName.toLowerCase();
|
|
3719
3585
|
const componentBody = _DOMCreateElement("component");
|
|
3720
|
-
const __enabled__atributes__ = ["cached","splashscreen","response-to","shadowed","componentClass", "controllerClass", "viewClass", "serviceClass", "effectClass", "tplextension", "template-source", "data"];
|
|
3721
|
-
componentBody.setAttribute("name",componentName);
|
|
3586
|
+
const __enabled__atributes__ = ["cached", "splashscreen", "response-to", "shadowed", "componentClass", "controllerClass", "viewClass", "serviceClass", "effectClass", "tplextension", "template-source", "data"];
|
|
3587
|
+
componentBody.setAttribute("name", componentName);
|
|
3722
3588
|
|
|
3723
3589
|
if (!componentWidget.hasAttribute("shadowed")) {
|
|
3724
|
-
componentBody.setAttribute("shadowed","true");
|
|
3590
|
+
componentBody.setAttribute("shadowed", "true");
|
|
3725
3591
|
}
|
|
3726
|
-
__enabled__atributes__.map
|
|
3727
|
-
if (componentWidget.hasAttribute(attributeName)){
|
|
3728
|
-
componentBody.setAttribute(attributeName,componentWidget.getAttribute(attributeName));
|
|
3592
|
+
__enabled__atributes__.map(function (attributeName) {
|
|
3593
|
+
if (componentWidget.hasAttribute(attributeName)) {
|
|
3594
|
+
componentBody.setAttribute(attributeName, componentWidget.getAttribute(attributeName));
|
|
3729
3595
|
componentWidget.removeAttribute(attributeName);
|
|
3730
3596
|
}
|
|
3731
3597
|
});
|
|
3732
|
-
var data_attributenames = componentWidget.getAttributeNames().filter(function(a) {
|
|
3598
|
+
var data_attributenames = componentWidget.getAttributeNames().filter(function (a) {
|
|
3733
3599
|
return a.startsWith("data-");
|
|
3734
|
-
}).map(function(a) {
|
|
3600
|
+
}).map(function (a) {
|
|
3735
3601
|
return a.split("-")[1];
|
|
3736
3602
|
});
|
|
3737
|
-
data_attributenames.map(function (_attribute_name_){
|
|
3603
|
+
data_attributenames.map(function (_attribute_name_) {
|
|
3738
3604
|
componentBody.setAttribute("data-" + _attribute_name_, componentWidget.getAttribute("data-" + _attribute_name_));
|
|
3739
3605
|
componentWidget.removeAttribute("data-" + _attribute_name_);
|
|
3740
3606
|
});
|
|
3741
|
-
[...componentWidget.children].map(function (element){
|
|
3607
|
+
[...componentWidget.children].map(function (element) {
|
|
3742
3608
|
componentBody.appendChild(element.cloneNode(true));
|
|
3743
3609
|
element.remove();
|
|
3744
3610
|
});
|
|
@@ -3747,12 +3613,14 @@
|
|
|
3747
3613
|
}
|
|
3748
3614
|
};
|
|
3749
3615
|
Export(_ComponentWidget_);
|
|
3750
|
-
var RegisterWidget = function (widgetName){
|
|
3751
|
-
customElements.define(widgetName,class extends _ComponentWidget_ {});
|
|
3616
|
+
var RegisterWidget = function (widgetName) {
|
|
3617
|
+
customElements.define(widgetName, class extends _ComponentWidget_ {});
|
|
3752
3618
|
};
|
|
3753
|
-
var RegisterWidgets = function (){
|
|
3619
|
+
var RegisterWidgets = function () {
|
|
3754
3620
|
var widgetList = [...arguments];
|
|
3755
|
-
widgetList.filter(function (widgetName)
|
|
3621
|
+
widgetList.filter(function (widgetName) {
|
|
3622
|
+
return typeof widgetName === "string";
|
|
3623
|
+
}).map(function (widgetName) {
|
|
3756
3624
|
RegisterWidget(widgetName);
|
|
3757
3625
|
});
|
|
3758
3626
|
};
|
|
@@ -3773,16 +3641,21 @@
|
|
|
3773
3641
|
body: null,
|
|
3774
3642
|
stream: null,
|
|
3775
3643
|
request: null,
|
|
3776
|
-
cors
|
|
3777
|
-
if (this.route.cors){
|
|
3778
|
-
let {
|
|
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;
|
|
3779
3652
|
var microservice = this;
|
|
3780
|
-
if (typeof microservice.headers !== "object"){
|
|
3653
|
+
if (typeof microservice.headers !== "object") {
|
|
3781
3654
|
microservice.headers = {};
|
|
3782
3655
|
}
|
|
3783
|
-
if (typeof allow_origins !== "undefined"){
|
|
3656
|
+
if (typeof allow_origins !== "undefined") {
|
|
3784
3657
|
// an example of allow_origins is ['https://example.com','http://www.example.com']
|
|
3785
|
-
if (allow_origins === "*" || (typeof microservice.request.headers.origin === "undefined") || [...allow_origins].indexOf(microservice.request.headers.origin)!== -1){
|
|
3658
|
+
if (allow_origins === "*" || (typeof microservice.request.headers.origin === "undefined") || [...allow_origins].indexOf(microservice.request.headers.origin) !== -1) {
|
|
3786
3659
|
// for compatibility with all browsers allways return a wildcard when the origin is allowed
|
|
3787
3660
|
microservice.headers["Access-Control-Allow-Origin"] = "*";
|
|
3788
3661
|
} else {
|
|
@@ -3791,29 +3664,29 @@
|
|
|
3791
3664
|
this.body = {};
|
|
3792
3665
|
try {
|
|
3793
3666
|
this.done();
|
|
3794
|
-
} catch (e){}
|
|
3667
|
+
} catch (e) {}
|
|
3795
3668
|
}
|
|
3796
3669
|
} else {
|
|
3797
3670
|
microservice.headers["Access-Control-Allow-Origin"] = "*";
|
|
3798
3671
|
}
|
|
3799
|
-
if (typeof allow_credentials !== "undefined"){
|
|
3672
|
+
if (typeof allow_credentials !== "undefined") {
|
|
3800
3673
|
microservice.headers["Access-Control-Allow-Credentials"] = allow_credentials.toString();
|
|
3801
3674
|
} else {
|
|
3802
3675
|
microservice.headers["Access-Control-Allow-Credentials"] = "true";
|
|
3803
3676
|
}
|
|
3804
|
-
if (typeof allow_methods !== "undefined"){
|
|
3677
|
+
if (typeof allow_methods !== "undefined") {
|
|
3805
3678
|
microservice.headers["Access-Control-Allow-Methods"] = [...allow_methods].join(",");
|
|
3806
3679
|
} else {
|
|
3807
3680
|
microservice.headers["Access-Control-Allow-Methods"] = "GET, OPTIONS, POST";
|
|
3808
3681
|
}
|
|
3809
|
-
if (typeof allow_headers !== "undefined"){
|
|
3682
|
+
if (typeof allow_headers !== "undefined") {
|
|
3810
3683
|
microservice.headers["Access-Control-Allow-Headers"] = [...allow_headers].join(",");
|
|
3811
3684
|
} else {
|
|
3812
3685
|
microservice.headers["Access-Control-Allow-Headers"] = "*";
|
|
3813
3686
|
}
|
|
3814
3687
|
}
|
|
3815
3688
|
},
|
|
3816
|
-
_new_
|
|
3689
|
+
_new_(o) {
|
|
3817
3690
|
logger.debug("Executing BackendMicroservice ");
|
|
3818
3691
|
let microservice = this;
|
|
3819
3692
|
microservice.body = null;
|
|
@@ -3827,7 +3700,7 @@
|
|
|
3827
3700
|
var supportedMethods = {
|
|
3828
3701
|
"post": microservice.post,
|
|
3829
3702
|
};
|
|
3830
|
-
if (Object.hasOwnProperty.call(supportedMethods,requestMethod)) {
|
|
3703
|
+
if (Object.hasOwnProperty.call(supportedMethods, requestMethod)) {
|
|
3831
3704
|
supportedMethods[requestMethod].call(microservice, data);
|
|
3832
3705
|
}
|
|
3833
3706
|
});
|
|
@@ -3844,39 +3717,39 @@
|
|
|
3844
3717
|
"trace": microservice.trace,
|
|
3845
3718
|
"patch": microservice.patch
|
|
3846
3719
|
};
|
|
3847
|
-
if (Object.hasOwnProperty.call(supportedMethods,requestMethod)) {
|
|
3720
|
+
if (Object.hasOwnProperty.call(supportedMethods, requestMethod)) {
|
|
3848
3721
|
supportedMethods[requestMethod].call(microservice);
|
|
3849
3722
|
}
|
|
3850
3723
|
|
|
3851
3724
|
},
|
|
3852
|
-
head
|
|
3725
|
+
head(formData) {
|
|
3853
3726
|
this.done();
|
|
3854
3727
|
},
|
|
3855
|
-
get
|
|
3728
|
+
get(formData) {
|
|
3856
3729
|
this.done();
|
|
3857
3730
|
},
|
|
3858
|
-
post
|
|
3731
|
+
post(formData) {
|
|
3859
3732
|
this.done();
|
|
3860
3733
|
},
|
|
3861
|
-
put
|
|
3734
|
+
put(formData) {
|
|
3862
3735
|
this.done();
|
|
3863
3736
|
},
|
|
3864
|
-
delete
|
|
3737
|
+
delete(formData) {
|
|
3865
3738
|
this.done();
|
|
3866
3739
|
},
|
|
3867
|
-
connect
|
|
3740
|
+
connect(formData) {
|
|
3868
3741
|
this.done();
|
|
3869
3742
|
},
|
|
3870
|
-
options
|
|
3743
|
+
options(formData) {
|
|
3871
3744
|
this.done();
|
|
3872
3745
|
},
|
|
3873
|
-
trace
|
|
3746
|
+
trace(formData) {
|
|
3874
3747
|
this.done();
|
|
3875
3748
|
},
|
|
3876
|
-
patch
|
|
3749
|
+
patch(formData) {
|
|
3877
3750
|
this.done();
|
|
3878
3751
|
},
|
|
3879
|
-
finishWithBody
|
|
3752
|
+
finishWithBody(stream) {
|
|
3880
3753
|
try {
|
|
3881
3754
|
stream.write(_DataStringify(this.body));
|
|
3882
3755
|
stream.end();
|
|
@@ -3884,18 +3757,18 @@
|
|
|
3884
3757
|
logger.debug("Something wrong writing the response for microservice" + e.toString());
|
|
3885
3758
|
}
|
|
3886
3759
|
},
|
|
3887
|
-
done
|
|
3760
|
+
done() {
|
|
3888
3761
|
var microservice = this;
|
|
3889
3762
|
var stream = microservice.stream;
|
|
3890
3763
|
try {
|
|
3891
3764
|
stream.respond(microservice.headers);
|
|
3892
|
-
} catch (e){
|
|
3765
|
+
} catch (e) {
|
|
3893
3766
|
logger.debug(e.toString());
|
|
3894
3767
|
}
|
|
3895
3768
|
if (microservice.body !== null) {
|
|
3896
3769
|
try {
|
|
3897
3770
|
microservice.finishWithBody.call(microservice, stream);
|
|
3898
|
-
} catch (e){
|
|
3771
|
+
} catch (e) {
|
|
3899
3772
|
logger.debug(e.toString());
|
|
3900
3773
|
}
|
|
3901
3774
|
}
|
|
@@ -3914,34 +3787,34 @@
|
|
|
3914
3787
|
data: {},
|
|
3915
3788
|
async: false,
|
|
3916
3789
|
external: false,
|
|
3917
|
-
set
|
|
3790
|
+
set(name, value) {
|
|
3918
3791
|
this[name] = value;
|
|
3919
3792
|
},
|
|
3920
|
-
get
|
|
3793
|
+
get(name) {
|
|
3921
3794
|
return this[name];
|
|
3922
3795
|
},
|
|
3923
3796
|
status: false,
|
|
3924
|
-
done
|
|
3925
|
-
fail
|
|
3926
|
-
rebuild
|
|
3797
|
+
done() {},
|
|
3798
|
+
fail() {},
|
|
3799
|
+
rebuild() {
|
|
3927
3800
|
var context = this;
|
|
3928
3801
|
try {
|
|
3929
3802
|
document.getElementsByTagName(context.containerTag)[0].appendChild(
|
|
3930
|
-
(function(s, url, context) {
|
|
3803
|
+
(function (s, url, context) {
|
|
3931
3804
|
s.type = context.type;
|
|
3932
3805
|
s.src = url;
|
|
3933
|
-
s.crossOrigin = (Object.hasOwnProperty.call(context,"crossOrigin")) ? (context.crossOrigin) : ("anonymous");
|
|
3806
|
+
s.crossOrigin = (Object.hasOwnProperty.call(context, "crossOrigin")) ? (context.crossOrigin) : ("anonymous");
|
|
3934
3807
|
s.async = context.async;
|
|
3935
|
-
s.onreadystatechange = function() {
|
|
3808
|
+
s.onreadystatechange = function () {
|
|
3936
3809
|
if (this.readyState === "complete") {
|
|
3937
3810
|
context.done.call(context);
|
|
3938
3811
|
}
|
|
3939
3812
|
};
|
|
3940
|
-
s.onload = function(e) {
|
|
3813
|
+
s.onload = function (e) {
|
|
3941
3814
|
context.status = true;
|
|
3942
3815
|
context.done.call(context, e);
|
|
3943
3816
|
};
|
|
3944
|
-
s.onerror = function(e) {
|
|
3817
|
+
s.onerror = function (e) {
|
|
3945
3818
|
context.status = false;
|
|
3946
3819
|
context.fail.call(context, e);
|
|
3947
3820
|
};
|
|
@@ -3955,10 +3828,10 @@
|
|
|
3955
3828
|
context.fail.call(context, e);
|
|
3956
3829
|
}
|
|
3957
3830
|
},
|
|
3958
|
-
Cast
|
|
3831
|
+
Cast(o) {
|
|
3959
3832
|
return _Cast(this, o);
|
|
3960
3833
|
},
|
|
3961
|
-
_new_
|
|
3834
|
+
_new_(properties) {
|
|
3962
3835
|
this.__new__(properties);
|
|
3963
3836
|
this.rebuild();
|
|
3964
3837
|
}
|
|
@@ -3971,23 +3844,23 @@
|
|
|
3971
3844
|
data: {},
|
|
3972
3845
|
async: false,
|
|
3973
3846
|
external: false,
|
|
3974
|
-
set
|
|
3847
|
+
set(name, value) {
|
|
3975
3848
|
this[name] = value;
|
|
3976
3849
|
},
|
|
3977
|
-
get
|
|
3850
|
+
get(name) {
|
|
3978
3851
|
return this[name];
|
|
3979
3852
|
},
|
|
3980
|
-
done
|
|
3981
|
-
rebuild
|
|
3853
|
+
done() {},
|
|
3854
|
+
rebuild() {
|
|
3982
3855
|
var context = this;
|
|
3983
|
-
if (isBrowser){
|
|
3856
|
+
if (isBrowser) {
|
|
3984
3857
|
window.document.getElementsByTagName("head")[0].appendChild(
|
|
3985
|
-
(function(s, url, context) {
|
|
3858
|
+
(function (s, url, context) {
|
|
3986
3859
|
s.type = "text/css";
|
|
3987
3860
|
s.rel = "stylesheet";
|
|
3988
3861
|
s.href = url;
|
|
3989
3862
|
s.crossOrigin = "anonymous";
|
|
3990
|
-
s.onreadystatechange = function() {
|
|
3863
|
+
s.onreadystatechange = function () {
|
|
3991
3864
|
if (this.readyState === "complete") {
|
|
3992
3865
|
context.done.call(context);
|
|
3993
3866
|
}
|
|
@@ -4000,144 +3873,183 @@
|
|
|
4000
3873
|
(this.external) ? (this.url) : (this.basePath + this.url), context));
|
|
4001
3874
|
}
|
|
4002
3875
|
},
|
|
4003
|
-
Cast
|
|
3876
|
+
Cast(o) {
|
|
4004
3877
|
return _Cast(this, o);
|
|
4005
3878
|
},
|
|
4006
|
-
_new_
|
|
3879
|
+
_new_(properties) {
|
|
4007
3880
|
this.__new__(properties);
|
|
4008
3881
|
this.rebuild();
|
|
4009
3882
|
}
|
|
4010
3883
|
});
|
|
4011
3884
|
|
|
4012
3885
|
/**
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
var __to_number = function(value) {
|
|
3886
|
+
* Array math functions
|
|
3887
|
+
*/
|
|
3888
|
+
var __to_number = function (value) {
|
|
4016
3889
|
return (isNaN(value)) ? (new Number(0)) : (new Number(value));
|
|
4017
3890
|
};
|
|
4018
|
-
Array.prototype.unique = function() {
|
|
4019
|
-
return this.filter(function (value, index, self) {
|
|
3891
|
+
Array.prototype.unique = function () {
|
|
3892
|
+
return this.filter(function (value, index, self) {
|
|
3893
|
+
return self.indexOf(value) === index;
|
|
3894
|
+
});
|
|
4020
3895
|
};
|
|
4021
|
-
Array.unique = function (a){
|
|
3896
|
+
Array.unique = function (a) {
|
|
4022
3897
|
return a.unique();
|
|
4023
3898
|
};
|
|
4024
3899
|
(_protected_code_)(Array.unique);
|
|
4025
3900
|
(_protected_code_)(Array.prototype.unique);
|
|
4026
|
-
Array.prototype.table = function() {
|
|
3901
|
+
Array.prototype.table = function () {
|
|
4027
3902
|
console.table(this);
|
|
4028
3903
|
};
|
|
4029
|
-
Array.table = function (a){
|
|
3904
|
+
Array.table = function (a) {
|
|
4030
3905
|
return a.table();
|
|
4031
3906
|
};
|
|
4032
3907
|
(_protected_code_)(Array.table);
|
|
4033
3908
|
(_protected_code_)(Array.prototype.table);
|
|
4034
|
-
Array.prototype.sum = function() {
|
|
4035
|
-
return this.reduce(function(prev, current) {
|
|
3909
|
+
Array.prototype.sum = function () {
|
|
3910
|
+
return this.reduce(function (prev, current) {
|
|
4036
3911
|
return __to_number(prev) + __to_number(current);
|
|
4037
|
-
},0);
|
|
3912
|
+
}, 0);
|
|
4038
3913
|
};
|
|
4039
|
-
Array.sum = function (a){
|
|
3914
|
+
Array.sum = function (a) {
|
|
4040
3915
|
return a.sum();
|
|
4041
3916
|
};
|
|
4042
3917
|
(_protected_code_)(Array.sum);
|
|
4043
3918
|
(_protected_code_)(Array.prototype.sum);
|
|
4044
|
-
Array.prototype.avg = function() {
|
|
4045
|
-
return (this.length<1)?(0):(this.reduce(function(prev, current) {
|
|
3919
|
+
Array.prototype.avg = function () {
|
|
3920
|
+
return (this.length < 1) ? (0) : (this.reduce(function (prev, current) {
|
|
4046
3921
|
return ((__to_number(prev) + __to_number(current)) / 2);
|
|
4047
3922
|
}));
|
|
4048
3923
|
};
|
|
4049
|
-
Array.avg = function (a){
|
|
3924
|
+
Array.avg = function (a) {
|
|
4050
3925
|
return a.avg();
|
|
4051
3926
|
};
|
|
4052
3927
|
(_protected_code_)(Array.avg);
|
|
4053
3928
|
(_protected_code_)(Array.prototype.avg);
|
|
4054
|
-
Array.prototype.min = function() {
|
|
4055
|
-
return this.reduce(function(prev, current) {
|
|
4056
|
-
return (
|
|
4057
|
-
},Infinity);
|
|
3929
|
+
Array.prototype.min = function () {
|
|
3930
|
+
return this.reduce(function (prev, current) {
|
|
3931
|
+
return (__to_number(prev) <= __to_number(current)) ? (prev) : (current);
|
|
3932
|
+
}, Infinity);
|
|
4058
3933
|
};
|
|
4059
|
-
Array.min = function (a){
|
|
3934
|
+
Array.min = function (a) {
|
|
4060
3935
|
return a.min();
|
|
4061
3936
|
};
|
|
4062
3937
|
(_protected_code_)(Array.min);
|
|
4063
3938
|
(_protected_code_)(Array.prototype.min);
|
|
4064
|
-
Array.prototype.max = function() {
|
|
4065
|
-
return this.reduce(function(prev, current) {
|
|
4066
|
-
return (
|
|
4067
|
-
},0);
|
|
3939
|
+
Array.prototype.max = function () {
|
|
3940
|
+
return this.reduce(function (prev, current) {
|
|
3941
|
+
return (__to_number(prev) >= __to_number(current)) ? (prev) : (current);
|
|
3942
|
+
}, 0);
|
|
4068
3943
|
};
|
|
4069
|
-
Array.max = function (a){
|
|
3944
|
+
Array.max = function (a) {
|
|
4070
3945
|
return a.max();
|
|
4071
3946
|
};
|
|
4072
3947
|
(_protected_code_)(Array.max);
|
|
4073
3948
|
(_protected_code_)(Array.prototype.max);
|
|
4074
|
-
Array.prototype.sortBy = function (propName, sortAsc = true){
|
|
4075
|
-
var sort_function = (sortAsc)?(
|
|
4076
|
-
function (prev, current) {
|
|
4077
|
-
|
|
4078
|
-
|
|
3949
|
+
Array.prototype.sortBy = function (propName, sortAsc = true) {
|
|
3950
|
+
var sort_function = (sortAsc) ? (
|
|
3951
|
+
function (prev, current) {
|
|
3952
|
+
return current[propName] < prev[propName] ? 1 : -1;
|
|
3953
|
+
}
|
|
3954
|
+
) : (
|
|
3955
|
+
function (prev, current) {
|
|
3956
|
+
return current[propName] > prev[propName] ? 1 : -1;
|
|
3957
|
+
}
|
|
4079
3958
|
);
|
|
4080
3959
|
return this.sort(sort_function);
|
|
4081
3960
|
};
|
|
4082
|
-
Array.sortBy = function (a, propName, sortAsc = true){
|
|
3961
|
+
Array.sortBy = function (a, propName, sortAsc = true) {
|
|
4083
3962
|
return a.sortBy(propName, sortAsc);
|
|
4084
3963
|
};
|
|
4085
3964
|
(_protected_code_)(Array.sortBy);
|
|
4086
3965
|
(_protected_code_)(Array.prototype.sortBy);
|
|
4087
3966
|
|
|
4088
|
-
Array.matrix = function (_length, _fillValue = 0){
|
|
4089
|
-
var x_func = function (x){
|
|
4090
|
-
|
|
3967
|
+
Array.matrix = function (_length, _fillValue = 0) {
|
|
3968
|
+
var x_func = function (x) {
|
|
3969
|
+
return _fillValue;
|
|
3970
|
+
};
|
|
3971
|
+
return Array.from({
|
|
3972
|
+
length: _length
|
|
3973
|
+
}, x_func);
|
|
4091
3974
|
};
|
|
4092
3975
|
(_protected_code_)(Array.matrix);
|
|
4093
3976
|
|
|
4094
|
-
Array.matrix2d = function (_length, _fillValue = 0){
|
|
4095
|
-
var y_func = function (y){
|
|
4096
|
-
|
|
4097
|
-
|
|
3977
|
+
Array.matrix2d = function (_length, _fillValue = 0) {
|
|
3978
|
+
var y_func = function (y) {
|
|
3979
|
+
return _fillValue;
|
|
3980
|
+
};
|
|
3981
|
+
var x_func = function (x) {
|
|
3982
|
+
return Array.from({
|
|
3983
|
+
length: _length
|
|
3984
|
+
}, y_func);
|
|
3985
|
+
};
|
|
3986
|
+
return Array.from({
|
|
3987
|
+
length: _length
|
|
3988
|
+
}, x_func);
|
|
4098
3989
|
};
|
|
4099
3990
|
(_protected_code_)(Array.matrix2d);
|
|
4100
3991
|
|
|
4101
|
-
Array.matrix3d = function (_length, _fillValue = 0){
|
|
4102
|
-
var y_func = function (y)
|
|
4103
|
-
|
|
4104
|
-
|
|
3992
|
+
Array.matrix3d = function (_length, _fillValue = 0) {
|
|
3993
|
+
var y_func = function (y) {
|
|
3994
|
+
return Array.from({
|
|
3995
|
+
length: _length
|
|
3996
|
+
}, function () {
|
|
3997
|
+
return _fillValue;
|
|
3998
|
+
});
|
|
3999
|
+
};
|
|
4000
|
+
var x_func = function (x) {
|
|
4001
|
+
return Array.from({
|
|
4002
|
+
length: _length
|
|
4003
|
+
}, y_func);
|
|
4004
|
+
};
|
|
4005
|
+
return Array.from({
|
|
4006
|
+
length: _length
|
|
4007
|
+
}, x_func);
|
|
4105
4008
|
};
|
|
4106
4009
|
(_protected_code_)(Array.matrix3d);
|
|
4107
4010
|
|
|
4108
|
-
_top.range = function (start, stop=0, step=1) {
|
|
4109
|
-
if (stop===0 || typeof stop === "undefined"){
|
|
4011
|
+
_top.range = function (start, stop = 0, step = 1) {
|
|
4012
|
+
if (stop === 0 || typeof stop === "undefined") {
|
|
4110
4013
|
stop = start;
|
|
4111
4014
|
start = 0;
|
|
4112
4015
|
}
|
|
4113
|
-
return Array.from({
|
|
4016
|
+
return Array.from({
|
|
4017
|
+
length: (stop - start) / step + 1
|
|
4018
|
+
}, function (_, i) {
|
|
4019
|
+
return start + (i * step);
|
|
4020
|
+
});
|
|
4114
4021
|
};
|
|
4115
4022
|
(_protected_code_)(_top.range);
|
|
4116
4023
|
|
|
4117
|
-
String.prototype.list = function () {
|
|
4024
|
+
String.prototype.list = function () {
|
|
4025
|
+
var __instance = this;
|
|
4026
|
+
return _top.range(0, __instance.length - 1).map(function (i) {
|
|
4027
|
+
return __instance[i];
|
|
4028
|
+
});
|
|
4029
|
+
};
|
|
4118
4030
|
(_protected_code_)(String.prototype.list);
|
|
4119
4031
|
|
|
4120
4032
|
_top.getDocumentLayout = function () {
|
|
4121
4033
|
var h = (w, h) => {
|
|
4122
|
-
return w>h ? "landscape": null;
|
|
4034
|
+
return w > h ? "landscape" : null;
|
|
4123
4035
|
};
|
|
4124
4036
|
var v = (w, h) => {
|
|
4125
|
-
return h>w ? "portrait": null;
|
|
4037
|
+
return h > w ? "portrait" : null;
|
|
4126
4038
|
};
|
|
4127
4039
|
var square = (w, h) => {
|
|
4128
|
-
return w===h ? "square": null;
|
|
4040
|
+
return w === h ? "square" : null;
|
|
4129
4041
|
};
|
|
4130
4042
|
return [
|
|
4131
|
-
h(document.documentElement.clientWidth,document.documentElement.clientHeight),
|
|
4132
|
-
v(document.documentElement.clientWidth,document.documentElement.clientHeight),
|
|
4133
|
-
square(document.documentElement.clientWidth,document.documentElement.clientHeight)
|
|
4134
|
-
].filter(e=>e!==null).pop();
|
|
4043
|
+
h(document.documentElement.clientWidth, document.documentElement.clientHeight),
|
|
4044
|
+
v(document.documentElement.clientWidth, document.documentElement.clientHeight),
|
|
4045
|
+
square(document.documentElement.clientWidth, document.documentElement.clientHeight)
|
|
4046
|
+
].filter(e => e !== null).pop();
|
|
4135
4047
|
};
|
|
4136
4048
|
|
|
4137
4049
|
|
|
4138
4050
|
/**
|
|
4139
|
-
|
|
4140
|
-
|
|
4051
|
+
* End of array math functions
|
|
4052
|
+
*/
|
|
4141
4053
|
|
|
4142
4054
|
|
|
4143
4055
|
Class("ArrayList", Array, []);
|
|
@@ -4150,31 +4062,31 @@
|
|
|
4150
4062
|
|
|
4151
4063
|
Class("ArrayCollection", Object, {
|
|
4152
4064
|
source: New(ClassFactory("ArrayList"), []),
|
|
4153
|
-
changed
|
|
4065
|
+
changed(prop, value) {
|
|
4154
4066
|
logger.debug("VALUE CHANGED");
|
|
4155
4067
|
logger.debug(prop);
|
|
4156
4068
|
logger.debug(value);
|
|
4157
4069
|
},
|
|
4158
|
-
push
|
|
4070
|
+
push(value) {
|
|
4159
4071
|
var self = this;
|
|
4160
4072
|
logger.debug("VALUE ADDED");
|
|
4161
4073
|
logger.debug(value);
|
|
4162
4074
|
self.source.push(value);
|
|
4163
4075
|
},
|
|
4164
|
-
pop
|
|
4076
|
+
pop(value) {
|
|
4165
4077
|
var self = this;
|
|
4166
4078
|
logger.debug("VALUE POPPED");
|
|
4167
4079
|
logger.debug(value);
|
|
4168
4080
|
self.source.pop(value);
|
|
4169
4081
|
},
|
|
4170
|
-
_new_
|
|
4082
|
+
_new_(source) {
|
|
4171
4083
|
var self = this;
|
|
4172
4084
|
var _index = 0;
|
|
4173
4085
|
self.source = New(ClassFactory("ArrayList"), source);
|
|
4174
4086
|
for (var _k in self.source) {
|
|
4175
4087
|
if (!isNaN(_k)) {
|
|
4176
4088
|
logger.debug("binding " + _k.toString());
|
|
4177
|
-
(function(_pname) {
|
|
4089
|
+
(function (_pname) {
|
|
4178
4090
|
Object.defineProperty(self, _pname, {
|
|
4179
4091
|
set(value) {
|
|
4180
4092
|
logger.debug("setting " + _pname + "=" + value);
|
|
@@ -4201,7 +4113,7 @@
|
|
|
4201
4113
|
|
|
4202
4114
|
Class("Effect", {
|
|
4203
4115
|
duration: 1000,
|
|
4204
|
-
animate
|
|
4116
|
+
animate({
|
|
4205
4117
|
timing,
|
|
4206
4118
|
draw,
|
|
4207
4119
|
duration
|
|
@@ -4223,9 +4135,9 @@
|
|
|
4223
4135
|
requestAnimationFrame(animate);
|
|
4224
4136
|
} else {
|
|
4225
4137
|
// if this is an object with a done method
|
|
4226
|
-
if (typeof this !== "undefined"
|
|
4227
|
-
|
|
4228
|
-
|
|
4138
|
+
if (typeof this !== "undefined" &&
|
|
4139
|
+
this !== null &&
|
|
4140
|
+
Object.hasOwnProperty.call(this, "done") &&
|
|
4229
4141
|
(typeof this.done).toLowerCase() === "function") {
|
|
4230
4142
|
this.done.call(this);
|
|
4231
4143
|
}
|
|
@@ -4235,57 +4147,59 @@
|
|
|
4235
4147
|
}
|
|
4236
4148
|
});
|
|
4237
4149
|
|
|
4238
|
-
Class("TransitionEffect",ClassFactory("Effect"),{
|
|
4239
|
-
duration:385,
|
|
4240
|
-
defaultParams:{
|
|
4241
|
-
alphaFrom:0,
|
|
4242
|
-
alphaTo:1,
|
|
4243
|
-
angleFrom:180,
|
|
4244
|
-
angleTo:0,
|
|
4245
|
-
radiusFrom:0,
|
|
4246
|
-
radiusTo:30,
|
|
4247
|
-
scaleFrom:0,
|
|
4248
|
-
scaleTo:1
|
|
4150
|
+
Class("TransitionEffect", ClassFactory("Effect"), {
|
|
4151
|
+
duration: 385,
|
|
4152
|
+
defaultParams: {
|
|
4153
|
+
alphaFrom: 0,
|
|
4154
|
+
alphaTo: 1,
|
|
4155
|
+
angleFrom: 180,
|
|
4156
|
+
angleTo: 0,
|
|
4157
|
+
radiusFrom: 0,
|
|
4158
|
+
radiusTo: 30,
|
|
4159
|
+
scaleFrom: 0,
|
|
4160
|
+
scaleTo: 1
|
|
4249
4161
|
},
|
|
4250
|
-
fitToHeight:false,
|
|
4251
|
-
fitToWidth:false,
|
|
4162
|
+
fitToHeight: false,
|
|
4163
|
+
fitToWidth: false,
|
|
4252
4164
|
effects: [],
|
|
4253
|
-
_new_
|
|
4165
|
+
_new_(o) {
|
|
4254
4166
|
logger.info("DECLARING TransitionEffect ");
|
|
4255
4167
|
this.component.defaultParams = this.defaultParams;
|
|
4256
4168
|
},
|
|
4257
|
-
apply
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4169
|
+
apply({
|
|
4170
|
+
alphaFrom,
|
|
4171
|
+
alphaTo,
|
|
4172
|
+
angleFrom,
|
|
4173
|
+
angleTo,
|
|
4174
|
+
radiusFrom,
|
|
4175
|
+
radiusTo,
|
|
4176
|
+
scaleFrom,
|
|
4177
|
+
scaleTo
|
|
4178
|
+
}) {
|
|
4265
4179
|
var _transition_ = this;
|
|
4266
4180
|
logger.info("EXECUTING TransitionEffect ");
|
|
4267
|
-
if (_transition_.fitToHeight){
|
|
4181
|
+
if (_transition_.fitToHeight) {
|
|
4268
4182
|
_transition_.component.body.height = _transition_.component.body.offsetParent.scrollHeight;
|
|
4269
4183
|
}
|
|
4270
|
-
if (_transition_.fitToWidth){
|
|
4184
|
+
if (_transition_.fitToWidth) {
|
|
4271
4185
|
_transition_.component.body.width = _transition_.component.body.offsetParent.scrollWidth;
|
|
4272
4186
|
}
|
|
4273
4187
|
_transition_.component.body.style.display = "block";
|
|
4274
|
-
_transition_.effects.map(function (effectClassName,eff){
|
|
4275
|
-
var
|
|
4276
|
-
var
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
));
|
|
4288
|
-
effectClassMethod.apply(_transition_,args);
|
|
4188
|
+
_transition_.effects.map(function (effectClassName, eff) {
|
|
4189
|
+
var __effectClass__ = ClassFactory(effectClassName);
|
|
4190
|
+
var effectObj = new __effectClass__();
|
|
4191
|
+
var effectClassMethod = effectObj.apply;
|
|
4192
|
+
var args = [_transition_.component.body].concat(Object.values({
|
|
4193
|
+
alphaFrom,
|
|
4194
|
+
alphaTo,
|
|
4195
|
+
angleFrom,
|
|
4196
|
+
angleTo,
|
|
4197
|
+
radiusFrom,
|
|
4198
|
+
radiusTo,
|
|
4199
|
+
scaleFrom,
|
|
4200
|
+
scaleTo
|
|
4201
|
+
}));
|
|
4202
|
+
effectClassMethod.apply(_transition_, args);
|
|
4289
4203
|
});
|
|
4290
4204
|
}
|
|
4291
4205
|
});
|
|
@@ -4293,7 +4207,7 @@
|
|
|
4293
4207
|
Class("Timer", {
|
|
4294
4208
|
duration: 1000,
|
|
4295
4209
|
alive: true,
|
|
4296
|
-
thread
|
|
4210
|
+
thread({
|
|
4297
4211
|
timing,
|
|
4298
4212
|
intervalInterceptor,
|
|
4299
4213
|
duration
|
|
@@ -4328,10 +4242,10 @@
|
|
|
4328
4242
|
_negative: null,
|
|
4329
4243
|
_dispatched: null,
|
|
4330
4244
|
_args: {},
|
|
4331
|
-
changeToggle
|
|
4245
|
+
changeToggle() {
|
|
4332
4246
|
this._toggle = (this._toggle) ? (false) : (true);
|
|
4333
4247
|
},
|
|
4334
|
-
_new_
|
|
4248
|
+
_new_({
|
|
4335
4249
|
positive,
|
|
4336
4250
|
negative,
|
|
4337
4251
|
args
|
|
@@ -4340,9 +4254,9 @@
|
|
|
4340
4254
|
this._negative = negative;
|
|
4341
4255
|
this._args = args;
|
|
4342
4256
|
},
|
|
4343
|
-
fire
|
|
4257
|
+
fire() {
|
|
4344
4258
|
var toggle = this;
|
|
4345
|
-
var _promise = new Promise(function(resolve, reject) {
|
|
4259
|
+
var _promise = new Promise(function (resolve, reject) {
|
|
4346
4260
|
|
|
4347
4261
|
if (typeof toggle._positive === "function" && typeof toggle._negative === "function") {
|
|
4348
4262
|
if (toggle._inverse) {
|
|
@@ -4356,9 +4270,9 @@
|
|
|
4356
4270
|
logger.debug("Toggle functions are not declared");
|
|
4357
4271
|
reject.call(_promise, toggle);
|
|
4358
4272
|
}
|
|
4359
|
-
}).then(function(toggle) {
|
|
4273
|
+
}).then(function (toggle) {
|
|
4360
4274
|
toggle.changeToggle();
|
|
4361
|
-
}).catch(function(e) {
|
|
4275
|
+
}).catch(function (e) {
|
|
4362
4276
|
logger.debug(e.toString());
|
|
4363
4277
|
});
|
|
4364
4278
|
return _promise;
|
|
@@ -4366,27 +4280,27 @@
|
|
|
4366
4280
|
});
|
|
4367
4281
|
|
|
4368
4282
|
// Set Processors
|
|
4369
|
-
(function (_top){
|
|
4283
|
+
(function (_top) {
|
|
4370
4284
|
|
|
4371
4285
|
let mapper = function (componentName, valueName) {
|
|
4372
4286
|
/*
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4287
|
+
* Mapper processor
|
|
4288
|
+
* @usage
|
|
4289
|
+
* $mapper(<componentName>,<valueName>)
|
|
4290
|
+
*
|
|
4291
|
+
* Where componentName is the name of the component (same value as in attribute tag name) without quotes
|
|
4292
|
+
* and valueName is the name of the variable that contains the value to map, it can be either a property of
|
|
4293
|
+
* the component instance, the data object or a global value
|
|
4294
|
+
*/
|
|
4381
4295
|
|
|
4382
4296
|
|
|
4383
4297
|
let globalValue = _top.global.get(valueName);
|
|
4384
4298
|
let componentValue = this.component.get(valueName);
|
|
4385
4299
|
let dataValue = this.component.data[valueName];
|
|
4386
|
-
let list = (typeof dataValue !== "undefined")?(
|
|
4300
|
+
let list = (typeof dataValue !== "undefined") ? (dataValue) : ((typeof componentValue !== "undefined") ? (componentValue) : (globalValue));
|
|
4387
4301
|
let listItems = "";
|
|
4388
|
-
if (typeof list !== "undefined" && typeof list["map"] !== "undefined"){
|
|
4389
|
-
listItems = list.map
|
|
4302
|
+
if (typeof list !== "undefined" && typeof list["map"] !== "undefined") {
|
|
4303
|
+
listItems = list.map(function (element) {
|
|
4390
4304
|
let dataItems = [...Object.keys(element)].map(k => ` data-${k}="${element[k].toString()}"`).join("");
|
|
4391
4305
|
return `<component name="${componentName}" ${dataItems} ></component>`;
|
|
4392
4306
|
}).join("");
|
|
@@ -4397,14 +4311,14 @@
|
|
|
4397
4311
|
};
|
|
4398
4312
|
ClassFactory("Processor").setProcessor(mapper);
|
|
4399
4313
|
|
|
4400
|
-
let layout = function (layoutname, cssfile){
|
|
4314
|
+
let layout = function (layoutname, cssfile) {
|
|
4401
4315
|
/*
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4316
|
+
* Layout processor
|
|
4317
|
+
* @usage
|
|
4318
|
+
* $layout(<layoutname>, <cssfile>)
|
|
4319
|
+
* Where layoutname can be "portrait" or "landscape" without quotes
|
|
4320
|
+
* cssfile is the uri for the css file to import
|
|
4321
|
+
*/
|
|
4408
4322
|
|
|
4409
4323
|
var layout_portrait = `
|
|
4410
4324
|
/* CSS Document for Mobile Imports */
|
|
@@ -4425,25 +4339,33 @@
|
|
|
4425
4339
|
@import url("${cssfile}") (aspect-ratio: 3/2) and (min-width:460px);
|
|
4426
4340
|
`;
|
|
4427
4341
|
var layout_code = {
|
|
4428
|
-
"landscape":layout_landscape,
|
|
4429
|
-
"portrait":layout_portrait
|
|
4342
|
+
"landscape": layout_landscape,
|
|
4343
|
+
"portrait": layout_portrait
|
|
4430
4344
|
};
|
|
4431
4345
|
|
|
4432
|
-
return (Object.hasOwnProperty.call(layout_code, layoutname))?(layout_code[layoutname]):("");
|
|
4346
|
+
return (Object.hasOwnProperty.call(layout_code, layoutname)) ? (layout_code[layoutname]) : ("");
|
|
4433
4347
|
};
|
|
4434
4348
|
|
|
4435
4349
|
ClassFactory("Processor").setProcessor(layout);
|
|
4436
4350
|
|
|
4437
4351
|
let component = function () {
|
|
4438
4352
|
/*
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
let arg = [...arguments].map(function (a)
|
|
4446
|
-
|
|
4353
|
+
* component processor
|
|
4354
|
+
* @usage
|
|
4355
|
+
* $component(name=<name>, componentClass=<componentClass>, ...)
|
|
4356
|
+
* Returns a component tag declaration like:
|
|
4357
|
+
* <component name=<name> ...></component>
|
|
4358
|
+
*/
|
|
4359
|
+
let arg = [...arguments].map(function (a) {
|
|
4360
|
+
return {
|
|
4361
|
+
[a.split("=")[0]]: a.split("=")[1]
|
|
4362
|
+
};
|
|
4363
|
+
}).reduce(function (k1, k2) {
|
|
4364
|
+
return Object.assign(k1, k2);
|
|
4365
|
+
});
|
|
4366
|
+
let attrs = [...Object.keys(arg)].map(function (a) {
|
|
4367
|
+
return `${a}=${arg[a]}`;
|
|
4368
|
+
}).join(" ");
|
|
4447
4369
|
return `<component ${attrs}></component>`;
|
|
4448
4370
|
};
|
|
4449
4371
|
|
|
@@ -4451,14 +4373,14 @@
|
|
|
4451
4373
|
|
|
4452
4374
|
let repeat = function (length, text) {
|
|
4453
4375
|
/*
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4376
|
+
* Repeat processor
|
|
4377
|
+
* @usage
|
|
4378
|
+
* $repeat(<length>, <text>)
|
|
4379
|
+
* Where length is the number of occurrences of text
|
|
4380
|
+
*/
|
|
4459
4381
|
return _top.range(length).map(
|
|
4460
4382
|
function (index) {
|
|
4461
|
-
return text.replace("{{index}}",index.toString());
|
|
4383
|
+
return text.replace("{{index}}", index.toString());
|
|
4462
4384
|
}
|
|
4463
4385
|
).join("");
|
|
4464
4386
|
};
|
|
@@ -4471,7 +4393,7 @@
|
|
|
4471
4393
|
/**
|
|
4472
4394
|
* Load every component tag declared in the body
|
|
4473
4395
|
**/
|
|
4474
|
-
Ready(function() {
|
|
4396
|
+
Ready(function () {
|
|
4475
4397
|
if (!_top.CONFIG.get("useSDK")) {
|
|
4476
4398
|
_top.__start__();
|
|
4477
4399
|
}
|
|
@@ -4491,19 +4413,218 @@
|
|
|
4491
4413
|
Export(isBrowser);
|
|
4492
4414
|
Export(_methods_);
|
|
4493
4415
|
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4416
|
+
asyncLoad(function () {
|
|
4417
|
+
|
|
4418
|
+
Class("GlobalSettings", Object, {
|
|
4419
|
+
_GLOBAL: {},
|
|
4420
|
+
set(name, value) {
|
|
4421
|
+
this._GLOBAL[name] = value;
|
|
4422
|
+
},
|
|
4423
|
+
get(name, _default) {
|
|
4424
|
+
var _value;
|
|
4425
|
+
if (typeof this._GLOBAL[name] !== "undefined") {
|
|
4426
|
+
_value = this._GLOBAL[name];
|
|
4427
|
+
} else if (typeof _default !== "undefined") {
|
|
4428
|
+
_value = _default;
|
|
4429
|
+
}
|
|
4430
|
+
return _value;
|
|
4431
|
+
},
|
|
4432
|
+
__start__() {
|
|
4433
|
+
var __load__serviceWorker = function () {
|
|
4434
|
+
var _promise;
|
|
4435
|
+
if (isBrowser) {
|
|
4436
|
+
_promise = new Promise(function (resolve, reject) {
|
|
4437
|
+
if (("serviceWorker" in navigator) &&
|
|
4438
|
+
(typeof _top.CONFIG.get("serviceWorkerURI") !== "undefined")) {
|
|
4439
|
+
_top.CONFIG.set("serviceWorkerScope", _top.CONFIG.get("serviceWorkerScope") ? (_top.CONFIG.get("serviceWorkerScope")) : ("/"));
|
|
4440
|
+
navigator.serviceWorker.register(_top.CONFIG.get("serviceWorkerURI"), {
|
|
4441
|
+
scope: _top.CONFIG.get("serviceWorkerScope")
|
|
4442
|
+
})
|
|
4443
|
+
.then(function (registration) {
|
|
4444
|
+
logger.debug("Service Worker Registered");
|
|
4445
|
+
resolve.call(_promise, registration);
|
|
4446
|
+
}, function (registration) {
|
|
4447
|
+
logger.debug("Error registering Service Worker");
|
|
4448
|
+
reject.call(_promise, registration);
|
|
4449
|
+
});
|
|
4450
|
+
navigator.serviceWorker.ready.then(function (registration) {
|
|
4451
|
+
logger.debug("Service Worker Ready");
|
|
4452
|
+
resolve.call(_promise, registration);
|
|
4453
|
+
}, function (registration) {
|
|
4454
|
+
logger.debug("Error loading Service Worker");
|
|
4455
|
+
reject.call(_promise, registration);
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
});
|
|
4459
|
+
}
|
|
4460
|
+
return _promise;
|
|
4461
|
+
};
|
|
4462
|
+
var _buildComponents = function () {
|
|
4463
|
+
if (isBrowser) {
|
|
4464
|
+
logger.debug("Starting to bind routes");
|
|
4465
|
+
_top._bindroute_.call(ClassFactory("Component"));
|
|
4466
|
+
logger.debug("Starting to building components");
|
|
4467
|
+
global.componentsStack = document.buildComponents.call(document);
|
|
4468
|
+
logger.debug("Initializing the service worker");
|
|
4469
|
+
__load__serviceWorker.call(_top).catch(function () {
|
|
4470
|
+
logger.debug("error loading the service worker");
|
|
4471
|
+
});
|
|
4472
|
+
|
|
4473
|
+
}
|
|
4474
|
+
};
|
|
4475
|
+
logger.debug("Starting to load the config settings...");
|
|
4476
|
+
if (_top.CONFIG.get("useConfigService", false)) {
|
|
4477
|
+
logger.debug("Loading settings using local configuration file...");
|
|
4478
|
+
_top.global.configService = New(ClassFactory("ConfigService"));
|
|
4479
|
+
_top.global.configService.configLoaded = _buildComponents;
|
|
4480
|
+
serviceLoader(_top.global.configService);
|
|
4481
|
+
} else {
|
|
4482
|
+
logger.debug("Starting to load the components...");
|
|
4483
|
+
_buildComponents.call(this);
|
|
4484
|
+
}
|
|
4485
|
+
}
|
|
4486
|
+
});
|
|
4487
|
+
var _g_ = New(ClassFactory("GlobalSettings"));
|
|
4488
|
+
|
|
4489
|
+
Object.defineProperty(global, "PackagesNameList", {
|
|
4490
|
+
set(val) {
|
|
4491
|
+
logger.debug("PackagesNameList is readonly");
|
|
4492
|
+
return;
|
|
4493
|
+
},
|
|
4494
|
+
get() {
|
|
4495
|
+
var _get_packages_names = function (_packages) {
|
|
4496
|
+
var _keys = [];
|
|
4497
|
+
for (var _k in _packages) {
|
|
4498
|
+
if (
|
|
4499
|
+
typeof _packages[_k] !== "undefined" &&
|
|
4500
|
+
typeof _packages[_k] !== "function" &&
|
|
4501
|
+
Object.hasOwnProperty.call(_packages[_k], "length") &&
|
|
4502
|
+
_packages[_k].length > 0
|
|
4503
|
+
) {
|
|
4504
|
+
_keys.push(_k);
|
|
4505
|
+
_keys = _keys.concat(_get_packages_names(_packages[_k]));
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
return _keys;
|
|
4509
|
+
};
|
|
4510
|
+
return _get_packages_names(_QC_PACKAGES);
|
|
4511
|
+
}
|
|
4512
|
+
});
|
|
4513
|
+
|
|
4514
|
+
Object.defineProperty(global, "PackagesList", {
|
|
4515
|
+
set(value) {
|
|
4516
|
+
logger.debug("PackagesList is readonly");
|
|
4517
|
+
return;
|
|
4518
|
+
},
|
|
4519
|
+
get() {
|
|
4520
|
+
return global.PackagesNameList.map(function (packagename) {
|
|
4521
|
+
let _classesList = Package(packagename);
|
|
4522
|
+
let _ret_;
|
|
4523
|
+
if (_classesList) {
|
|
4524
|
+
_ret_ = {
|
|
4525
|
+
packageName: packagename,
|
|
4526
|
+
classesList: _classesList.filter(function (_packageClass) {
|
|
4527
|
+
return isQCObjects_Class(_packageClass);
|
|
4528
|
+
})
|
|
4529
|
+
};
|
|
4530
|
+
}
|
|
4531
|
+
return _ret_;
|
|
4532
|
+
}).filter(function (_p) {
|
|
4533
|
+
return typeof _p !== "undefined";
|
|
4534
|
+
});
|
|
4535
|
+
}
|
|
4536
|
+
});
|
|
4537
|
+
|
|
4538
|
+
Object.defineProperty(global, "ClassesList", {
|
|
4539
|
+
set(value) {
|
|
4540
|
+
logger.debug("ClassesList is readonly");
|
|
4541
|
+
return;
|
|
4542
|
+
},
|
|
4543
|
+
get() {
|
|
4544
|
+
var _classesList = [];
|
|
4545
|
+
global.PackagesList.map(function (_package_element) {
|
|
4546
|
+
_classesList = _classesList.concat(_package_element.classesList.map(
|
|
4547
|
+
function (_class_element) {
|
|
4548
|
+
return {
|
|
4549
|
+
packageName: _package_element.packageName,
|
|
4550
|
+
className: _package_element.packageName + "." + _class_element.__definition.__classType,
|
|
4551
|
+
classFactory: _class_element
|
|
4552
|
+
};
|
|
4553
|
+
}
|
|
4554
|
+
));
|
|
4555
|
+
return _package_element;
|
|
4556
|
+
});
|
|
4557
|
+
|
|
4558
|
+
return _classesList;
|
|
4559
|
+
}
|
|
4560
|
+
});
|
|
4561
|
+
|
|
4562
|
+
Object.defineProperty(global, "ClassesNameList", {
|
|
4563
|
+
set(value) {
|
|
4564
|
+
logger.debug("ClassesNameList is readonly");
|
|
4565
|
+
return;
|
|
4566
|
+
},
|
|
4567
|
+
get() {
|
|
4568
|
+
return global.ClassesList.map(function (_class_element) {
|
|
4569
|
+
return _class_element.className;
|
|
4570
|
+
});
|
|
4571
|
+
}
|
|
4572
|
+
});
|
|
4573
|
+
|
|
4574
|
+
_top = _CastProps(_g_, _top);
|
|
4575
|
+
|
|
4576
|
+
if (isBrowser) {
|
|
4577
|
+
// use of GLOBAL word is deprecated in node.js
|
|
4578
|
+
// this is only for compatibility purpose with old versions of QCObjects in browsers
|
|
4579
|
+
Class("GLOBAL", _QC_CLASSES["global"]); // case insensitive for compatibility con old versions;
|
|
4580
|
+
Export(ClassFactory("GLOBAL"));
|
|
4497
4581
|
}
|
|
4498
|
-
|
|
4499
|
-
|
|
4582
|
+
Export(global);
|
|
4583
|
+
|
|
4584
|
+
if (_top.CONFIG.get("useSDK")) {
|
|
4585
|
+
(function () {
|
|
4586
|
+
var remoteImportsPath = _top.CONFIG.get("remoteImportsPath");
|
|
4587
|
+
var external = (!_top.CONFIG.get("useLocalSDK")) ? (true) : (false);
|
|
4588
|
+
_top.CONFIG.set("remoteImportsPath", _top.CONFIG.get("remoteSDKPath"));
|
|
4589
|
+
|
|
4590
|
+
var tryImportingSDK = false;
|
|
4591
|
+
var sdkName = "QCObjects-SDK";
|
|
4592
|
+
if (isBrowser) {
|
|
4593
|
+
tryImportingSDK = true;
|
|
4594
|
+
} else {
|
|
4595
|
+
var sdkPath = findPackageNodePath("qcobjects-sdk");
|
|
4596
|
+
if (sdkPath !== null) {
|
|
4597
|
+
sdkName = "qcobjects-sdk";
|
|
4598
|
+
tryImportingSDK = true;
|
|
4599
|
+
} else {
|
|
4600
|
+
sdkName = "node_modules/qcobjects-sdk/QCObjects-SDK";
|
|
4601
|
+
tryImportingSDK = true;
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
|
|
4605
|
+
if (tryImportingSDK) {
|
|
4606
|
+
logger.info("Importing SDK... " + sdkName);
|
|
4607
|
+
Import(sdkName, function () {
|
|
4608
|
+
if (external) {
|
|
4609
|
+
logger.debug("QCObjects-SDK.js loaded from remote location");
|
|
4610
|
+
} else {
|
|
4611
|
+
logger.debug("QCObjects-SDK.js loaded from local");
|
|
4612
|
+
}
|
|
4613
|
+
_top.CONFIG.set("remoteImportsPath", remoteImportsPath);
|
|
4614
|
+
}, external);
|
|
4615
|
+
} else {
|
|
4616
|
+
logger.debug("SDK has not been imported as it is not available at the moment");
|
|
4617
|
+
}
|
|
4618
|
+
}).call(null);
|
|
4500
4619
|
}
|
|
4501
|
-
|
|
4620
|
+
|
|
4621
|
+
|
|
4622
|
+
}, null);
|
|
4502
4623
|
|
|
4503
4624
|
if (isBrowser) {
|
|
4504
|
-
asyncLoad(function() {
|
|
4505
|
-
Ready(function() {
|
|
4506
|
-
window.onpopstate = function(event) {
|
|
4625
|
+
asyncLoad(function () {
|
|
4626
|
+
Ready(function () {
|
|
4627
|
+
window.onpopstate = function (event) {
|
|
4507
4628
|
event.stopImmediatePropagation();
|
|
4508
4629
|
event.stopPropagation();
|
|
4509
4630
|
ClassFactory("Component").route();
|
|
@@ -4515,79 +4636,91 @@
|
|
|
4515
4636
|
* possible events: scrollpercent, defaultscroll, percentY0, percentY25, percentY50, percentY75, percentY90
|
|
4516
4637
|
*/
|
|
4517
4638
|
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4639
|
+
(function (_top) {
|
|
4640
|
+
let lastKnownScrollPosition = 0;
|
|
4641
|
+
let ticking = false;
|
|
4642
|
+
let scrollHeight = Math.max(
|
|
4643
|
+
document.body.scrollHeight, document.documentElement.scrollHeight,
|
|
4644
|
+
document.body.offsetHeight, document.documentElement.offsetHeight,
|
|
4645
|
+
document.body.clientHeight, document.documentElement.clientHeight
|
|
4646
|
+
);
|
|
4647
|
+
|
|
4648
|
+
let scrollWidth = Math.max(
|
|
4649
|
+
document.body.scrollWidth, document.documentElement.scrollWidth,
|
|
4650
|
+
document.body.offsetWidth, document.documentElement.offsetWidth,
|
|
4651
|
+
document.body.clientWidth, document.documentElement.clientWidth
|
|
4652
|
+
);
|
|
4653
|
+
|
|
4654
|
+
function scrollDispatcher(event) {
|
|
4655
|
+
var percentY = Math.round(_top.scrollY * 100 / scrollHeight);
|
|
4656
|
+
var percentX = Math.round(_top.scrollX * 100 / scrollWidth);
|
|
4657
|
+
var scrollPercentEventEvent = new CustomEvent("scrollpercent", {
|
|
4658
|
+
detail: {
|
|
4659
|
+
percentX: percentX,
|
|
4660
|
+
percentY: percentY
|
|
4661
|
+
}
|
|
4662
|
+
});
|
|
4663
|
+
event.target.dispatchEvent(scrollPercentEventEvent);
|
|
4664
|
+
var secondaryEventName = "defaultscroll";
|
|
4665
|
+
var __valid_scrolls__ = [0, 5, 10, 25, 50, 75, 90, 95, 100];
|
|
4666
|
+
__valid_scrolls__.filter(function (p) {
|
|
4667
|
+
return p === percentY;
|
|
4668
|
+
}).map(function (pY) {
|
|
4669
|
+
secondaryEventName = "percentY" + percentY.toString();
|
|
4670
|
+
var secondaryCustomEvent = new CustomEvent(secondaryEventName, {
|
|
4671
|
+
detail: {
|
|
4672
|
+
percentX: percentX,
|
|
4673
|
+
percentY: percentY
|
|
4674
|
+
}
|
|
4675
|
+
});
|
|
4676
|
+
event.target.dispatchEvent(secondaryCustomEvent);
|
|
4677
|
+
});
|
|
4678
|
+
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
document.addEventListener("scroll", function (event) {
|
|
4682
|
+
|
|
4683
|
+
if (!ticking) {
|
|
4684
|
+
requestAnimationFrame(function () {
|
|
4685
|
+
scrollDispatcher(event);
|
|
4686
|
+
ticking = false;
|
|
4687
|
+
});
|
|
4688
|
+
|
|
4689
|
+
ticking = true;
|
|
4690
|
+
}
|
|
4691
|
+
});
|
|
4692
|
+
|
|
4693
|
+
})(_top);
|
|
4571
4694
|
|
|
4572
4695
|
});
|
|
4573
4696
|
}, null);
|
|
4574
4697
|
}
|
|
4575
4698
|
|
|
4699
|
+
if (!isBrowser) {
|
|
4700
|
+
if (typeof _top.global !== "undefined" && Object.hasOwnProperty.call(_top.global, "_fireAsyncLoad")) {
|
|
4701
|
+
_top.global._fireAsyncLoad.call(this);
|
|
4702
|
+
}
|
|
4703
|
+
if (typeof _top.global !== "undefined" && Object.hasOwnProperty.call(_top.global, "onload")) {
|
|
4704
|
+
_top.global.onload.call(this);
|
|
4705
|
+
}
|
|
4706
|
+
}
|
|
4707
|
+
|
|
4708
|
+
|
|
4576
4709
|
/* Freezing Object && Object.prototype to prevent prototype pollution risks */
|
|
4577
|
-
(function (isBrowser){
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
__freeze__();
|
|
4585
|
-
});
|
|
4586
|
-
} else if (_top.CONFIG.get("secureObjects", false)) {
|
|
4710
|
+
(function (isBrowser) {
|
|
4711
|
+
var __freeze__ = function () {
|
|
4712
|
+
Object.freeze(Object.prototype);
|
|
4713
|
+
Object.freeze(Object);
|
|
4714
|
+
};
|
|
4715
|
+
if (isBrowser && _top.CONFIG.get("secureObjects", false)) {
|
|
4716
|
+
Ready(function () {
|
|
4587
4717
|
__freeze__();
|
|
4588
|
-
}
|
|
4718
|
+
});
|
|
4719
|
+
} else if (_top.CONFIG.get("secureObjects", false)) {
|
|
4720
|
+
__freeze__();
|
|
4721
|
+
}
|
|
4589
4722
|
})(isBrowser);
|
|
4590
4723
|
|
|
4591
|
-
}).call(null,(typeof module === "object" && typeof module.exports === "object")?(module.exports = global):((typeof global === "object")?(global):(
|
|
4592
|
-
(typeof window === "object")?(window):({})
|
|
4593
|
-
)));
|
|
4724
|
+
}).call(null, (typeof module === "object" && typeof module.exports === "object") ? (module.exports = global) : ((typeof global === "object") ? (global) : (
|
|
4725
|
+
(typeof window === "object") ? (window) : ({})
|
|
4726
|
+
)));
|