qcobjects 2.4.105-ts → 2.4.108-ts
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/.hintrc +5 -0
- package/VERSION +1 -1
- package/build/ArrayCollection.js +136 -0
- package/build/BackendMicroservice.js +211 -0
- package/build/Base64.js +100 -0
- package/build/CONFIG.js +85 -0
- package/build/Cast.js +53 -0
- package/build/Class.js +284 -0
- package/build/ClassFactory.js +38 -0
- package/build/ComplexStorageCache.js +91 -0
- package/build/Component.js +1133 -0
- package/build/ComponentFactory.js +113 -0
- package/build/ConfigSettings.js +39 -0
- package/build/Controller.js +81 -0
- package/build/Crypt.js +87 -0
- package/build/DDO.js +81 -0
- package/build/DOMCreateElement.js +15 -0
- package/build/DataStringify.js +22 -0
- package/build/DefaultTemplateHandler.js +57 -0
- package/build/DocumentLayout.js +20 -0
- package/build/Effect.js +46 -0
- package/build/Export.js +11 -0
- package/build/Import.js +140 -0
- package/build/IncrementInstanceID.js +11 -0
- package/build/InheritClass.js +194 -0
- package/build/LegacyCopy.js +31 -0
- package/build/Logger.js +33 -0
- package/build/MainProcess.js +549 -0
- package/build/NamespaceRef.js +29 -0
- package/build/New.js +17 -0
- package/build/ObjectName.js +22 -0
- package/build/Package.js +67 -0
- package/build/PrimaryCollections.js +7 -0
- package/build/Processor.js +81 -0
- package/build/QCObjects.js +182 -4843
- package/build/Ready.js +49 -0
- package/build/RegisterClass.js +28 -0
- package/build/Service.js +112 -0
- package/build/SourceCSS.js +56 -0
- package/build/SourceJS.js +73 -0
- package/build/Tag.js +77 -0
- package/build/Timer.js +30 -0
- package/build/Toggle.js +59 -0
- package/build/TransitionEffect.js +65 -0
- package/build/VO.js +11 -0
- package/build/View.js +18 -0
- package/build/WidgetsFactory.js +537 -0
- package/build/assign.js +32 -0
- package/build/asyncLoad.js +43 -0
- package/build/basePath.js +32 -0
- package/build/captureFalseTouch.js +32 -0
- package/build/componentLoader.js +258 -0
- package/build/defaultProcessors.js +130 -0
- package/build/domain.js +4 -0
- package/build/findPackageNodePath.js +47 -0
- package/build/getType.js +38 -0
- package/build/globalSettings.js +115 -0
- package/build/index.d.ts +1045 -0
- package/build/index.js +24 -4
- package/build/index.mjs +1 -1
- package/build/introspection.js +86 -0
- package/build/isQCObjects.js +20 -0
- package/build/is_a.js +19 -0
- package/build/is_forbidden_name.js +15 -0
- package/build/is_raw_class.js +7 -0
- package/build/loadSDK.js +63 -0
- package/build/localStorage.js +19 -0
- package/build/make_global.js +24 -0
- package/build/mathFunctions.js +7 -0
- package/build/platform.js +28 -0
- package/build/range.js +17 -0
- package/build/routings.js +21 -0
- package/build/secretKey.js +5 -0
- package/build/serviceLoader.js +300 -0
- package/build/shortCode.js +14 -0
- package/build/subelements.js +8 -0
- package/build/super.js +20 -0
- package/build/tag_filter.js +4 -0
- package/build/top.js +23 -0
- package/build/uniqueID.js +5 -0
- package/build/waitUntil.js +31 -0
- package/build-esbuild.js +62 -0
- package/eslint.config.mjs +87 -0
- package/package.json +25 -22
- package/public/browser/index.js +6502 -0
- package/public/browser/index.js.map +7 -0
- package/public/cjs/index.cjs +6586 -0
- package/public/cjs/index.cjs.map +7 -0
- package/public/esm/index.mjs +6494 -0
- package/public/esm/index.mjs.map +7 -0
- package/spec/helpers/mock-sdk.helper.ts +5 -0
- package/spec/mocks/qcobjects-sdk.mock.ts +1 -0
- package/spec/support/jasmine.json +3 -3
- package/spec/testsClassFactorySpec.ts +40 -0
- package/spec/{testsConfigSpec.js → testsConfigSpec.ts} +2 -2
- package/spec/{testsGlobalFeaturesSpec.js → testsGlobalFeaturesSpec.ts} +10 -8
- package/spec/{testsSpec.js → testsSpec.ts} +11 -10
- package/spec/{testsTypeSpec.js → testsTypeSpec.ts} +5 -3
- package/src/ArrayCollection.ts +143 -0
- package/src/BackendMicroservice.ts +229 -0
- package/src/Base64.ts +92 -0
- package/src/CONFIG.ts +96 -0
- package/src/Cast.ts +46 -0
- package/src/Class.ts +303 -0
- package/src/ClassFactory.ts +34 -0
- package/src/ComplexStorageCache.ts +97 -0
- package/src/Component.ts +1222 -0
- package/src/ComponentFactory.ts +122 -0
- package/src/ConfigSettings.ts +62 -0
- package/src/Controller.ts +90 -0
- package/src/Crypt.ts +87 -0
- package/src/DDO.ts +93 -0
- package/src/DOMCreateElement.ts +12 -0
- package/src/DataStringify.ts +19 -0
- package/src/DefaultTemplateHandler.ts +55 -0
- package/src/DocumentLayout.ts +16 -0
- package/src/Effect.ts +56 -0
- package/src/Export.ts +8 -0
- package/src/Import.ts +135 -0
- package/src/IncrementInstanceID.ts +8 -0
- package/src/InheritClass.ts +210 -0
- package/src/LegacyCopy.ts +27 -0
- package/src/Logger.ts +32 -0
- package/src/MainProcess.ts +629 -0
- package/src/NamespaceRef.ts +26 -0
- package/src/New.ts +15 -0
- package/src/ObjectName.ts +16 -0
- package/src/Package.ts +67 -0
- package/src/PrimaryCollections.ts +7 -0
- package/src/Processor.ts +93 -0
- package/src/QCObjects.ts +100 -0
- package/src/Ready.ts +44 -0
- package/src/RegisterClass.ts +26 -0
- package/src/Service.ts +127 -0
- package/src/SourceCSS.ts +59 -0
- package/src/SourceJS.ts +76 -0
- package/src/Tag.ts +76 -0
- package/src/Timer.ts +42 -0
- package/src/Toggle.ts +65 -0
- package/src/TransitionEffect.ts +80 -0
- package/src/VO.ts +8 -0
- package/src/View.ts +17 -0
- package/src/WidgetsFactory.ts +543 -0
- package/src/assign.ts +33 -0
- package/src/asyncLoad.ts +42 -0
- package/src/basePath.ts +29 -0
- package/src/captureFalseTouch.ts +29 -0
- package/src/componentLoader.ts +252 -0
- package/src/defaultProcessors.ts +145 -0
- package/src/domain.ts +1 -0
- package/src/findPackageNodePath.ts +43 -0
- package/src/getType.ts +36 -0
- package/src/globalSettings.ts +118 -0
- package/src/index.mts +1 -1
- package/src/index.ts +1 -1
- package/src/introspection.ts +80 -0
- package/src/isQCObjects.ts +19 -0
- package/src/is_a.ts +16 -0
- package/src/is_forbidden_name.ts +12 -0
- package/src/is_raw_class.ts +3 -0
- package/src/loadSDK.ts +59 -0
- package/src/localStorage.ts +17 -0
- package/src/make_global.ts +19 -0
- package/src/mathFunctions.ts +3 -0
- package/src/platform.ts +30 -0
- package/src/range.ts +15 -0
- package/src/routings.ts +18 -0
- package/src/secretKey.ts +3 -0
- package/src/serviceLoader.ts +306 -0
- package/src/shortCode.ts +11 -0
- package/src/subelements.ts +4 -0
- package/src/super.ts +17 -0
- package/src/tag_filter.ts +1 -0
- package/src/top.ts +111 -0
- package/src/types/global/index.d.ts +597 -0
- package/src/uniqueID.ts +3 -0
- package/src/waitUntil.ts +26 -0
- package/tsconfig.d.json +35 -8
- package/tsconfig.jasmine.json +39 -0
- package/tsconfig.json +46 -12
- package/.eslintignore +0 -5
- package/.eslintrc.cjs +0 -21
- package/.eslintrc.json +0 -24
- package/browser/QCObjects.js +0 -2
- package/browser/QCObjects.js.map +0 -7
- package/browser/chunks/chunk-O2PFFZVJ.js +0 -713
- package/browser/chunks/chunk-O2PFFZVJ.js.map +0 -7
- package/browser/chunks/chunk-TBLBK5VV.js +0 -713
- package/browser/chunks/chunk-TBLBK5VV.js.map +0 -7
- package/browser/chunks/chunk-ZYLXOA35.js +0 -713
- package/browser/chunks/chunk-ZYLXOA35.js.map +0 -7
- package/browser/index.js +0 -2
- package/browser/index.js.map +0 -7
- package/spec/testsClassFactorySpec.js +0 -41
- package/src/QCObjects.js +0 -5247
- package/src/index.d.ts +0 -8
- package/types/index.d.ts +0 -472
package/src/Import.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { _basePath_ } from "./basePath";
|
|
2
|
+
import { CONFIG } from "./CONFIG";
|
|
3
|
+
import { _DataStringify } from "./DataStringify";
|
|
4
|
+
import { _DOMCreateElement } from "./DOMCreateElement";
|
|
5
|
+
import { findPackageNodePath } from "./findPackageNodePath";
|
|
6
|
+
import { logger } from "./Logger";
|
|
7
|
+
import { _require_, isBrowser } from "./platform";
|
|
8
|
+
import { _QC_PACKAGES, _QC_PACKAGES_IMPORTED, _QC_READY_LISTENERS } from "./PrimaryCollections";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Imports a script with the package nomenclature
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} packagename
|
|
14
|
+
* @param {Object} ready
|
|
15
|
+
* @param {Boolean} external
|
|
16
|
+
*/
|
|
17
|
+
export const Import = function (packagename:string, ready?:Function, external?:boolean):Promise<{_imported_?:any, _package_name_?:string}> | undefined {
|
|
18
|
+
|
|
19
|
+
if (external !== undefined){
|
|
20
|
+
logger.debug(`[Import] Setting external=${external.toString()} resource to import: ${packagename}`);
|
|
21
|
+
}
|
|
22
|
+
if (external) {
|
|
23
|
+
logger.debug(`[Import] Registering external resource to import: ${packagename}`);
|
|
24
|
+
} else {
|
|
25
|
+
logger.debug(`[Import] Registering local resource to import: ${packagename}`);
|
|
26
|
+
}
|
|
27
|
+
let _promise_import_: Promise<any>;
|
|
28
|
+
if (isBrowser) {
|
|
29
|
+
_promise_import_ = new Promise(function (resolve, reject) {
|
|
30
|
+
|
|
31
|
+
const allPackagesImported = function () {
|
|
32
|
+
let ret = false;
|
|
33
|
+
let cp = 0;
|
|
34
|
+
// eslint-disable-next-line no-unused-vars
|
|
35
|
+
for (const p in _QC_PACKAGES) {
|
|
36
|
+
cp++;
|
|
37
|
+
}
|
|
38
|
+
if (cp < _QC_PACKAGES_IMPORTED.length) {
|
|
39
|
+
ret = false;
|
|
40
|
+
} else {
|
|
41
|
+
ret = true;
|
|
42
|
+
}
|
|
43
|
+
return ret;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const readyImported = function (e: { target: { remove: () => void; }; }) {
|
|
47
|
+
_QC_PACKAGES_IMPORTED.push(ready as never);
|
|
48
|
+
if (allPackagesImported()) {
|
|
49
|
+
_QC_PACKAGES_IMPORTED.map(function (_imported_) {
|
|
50
|
+
_QC_READY_LISTENERS.push(_imported_);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (isBrowser && CONFIG.get("removePackageScriptAfterLoading")) {
|
|
54
|
+
e.target.remove();
|
|
55
|
+
}
|
|
56
|
+
resolve.call(_promise_import_, {
|
|
57
|
+
"_imported_": e.target,
|
|
58
|
+
"_package_name_": packagename
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (!Object.hasOwn(_QC_PACKAGES, packagename)) {
|
|
63
|
+
const s1:HTMLScriptElement = _DOMCreateElement("script") as unknown as HTMLScriptElement;
|
|
64
|
+
s1.type = CONFIG.get("sourceType", "text/javascript");
|
|
65
|
+
s1.async = !!(CONFIG.get("asynchronousImportsLoad"));
|
|
66
|
+
(s1 as any).onreadystatechange = function () {
|
|
67
|
+
if ((s1 as any).readyState === "complete") {
|
|
68
|
+
readyImported(s1 as any);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
(s1 as any).onload = readyImported;
|
|
72
|
+
s1.onerror = function (e: any) {
|
|
73
|
+
logger.debug(`An error ocurred: ${e}.`);
|
|
74
|
+
reject.call(_promise_import_, {
|
|
75
|
+
"_imported_": s1,
|
|
76
|
+
"_package_name_": packagename
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
s1.src = (external) ? (CONFIG.get("remoteImportsPath") + packagename + ".js") : (_basePath_ + CONFIG.get("relativeImportPath") + packagename + ".js");
|
|
80
|
+
document.getElementsByTagName("head")[0].appendChild(s1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
_promise_import_.catch(function () {
|
|
84
|
+
logger.debug("Import: Error loading a package ");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
} else {
|
|
88
|
+
// support to be used in a nodejs environment
|
|
89
|
+
_promise_import_ = new Promise(function (resolve, reject) {
|
|
90
|
+
try {
|
|
91
|
+
const standardNodePath = findPackageNodePath(packagename);
|
|
92
|
+
let packageAbsoluteName = "";
|
|
93
|
+
if (standardNodePath !== null) {
|
|
94
|
+
packageAbsoluteName = standardNodePath + "/" + packagename;
|
|
95
|
+
} else {
|
|
96
|
+
const jsNodePath = findPackageNodePath(packagename + ".js");
|
|
97
|
+
if (jsNodePath !== null) {
|
|
98
|
+
packageAbsoluteName = jsNodePath + "/" + packagename + ".js";
|
|
99
|
+
} else {
|
|
100
|
+
packageAbsoluteName = _basePath_ + CONFIG.get("relativeImportPath") + packagename;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
resolve.call(_promise_import_, {
|
|
105
|
+
"_imported_": _require_(`${packageAbsoluteName}`),
|
|
106
|
+
"_package_name_": packagename
|
|
107
|
+
});
|
|
108
|
+
} catch (e) {
|
|
109
|
+
reject.call(_promise_import_, {
|
|
110
|
+
"_imported_": null,
|
|
111
|
+
"_package_name_": packagename,
|
|
112
|
+
"error": e
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} catch (e) {
|
|
116
|
+
reject.call(_promise_import_, {
|
|
117
|
+
"_imported_": null,
|
|
118
|
+
"_package_name_": packagename,
|
|
119
|
+
"error": e
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}).catch(function (e) {
|
|
123
|
+
// something wrong importing a package
|
|
124
|
+
logger.debug("Something happened when importing " + packagename);
|
|
125
|
+
console.warn(e);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
_promise_import_.catch(function (e) {
|
|
129
|
+
logger.warn(_DataStringify(e));
|
|
130
|
+
});
|
|
131
|
+
return _promise_import_;
|
|
132
|
+
};
|
|
133
|
+
Import.prototype.toString = function () {
|
|
134
|
+
return "Import(packagename,ready,external) { [QCObjects native code] }";
|
|
135
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { type IInheritClass, type IQCObjectsElement, type TBody } from "types";
|
|
2
|
+
import { logger } from "./Logger";
|
|
3
|
+
import { __instanceID, IncrementInstanceID } from "./IncrementInstanceID";
|
|
4
|
+
import { _CastProps, _Cast } from "./Cast";
|
|
5
|
+
import { _DOMCreateElement } from "./DOMCreateElement";
|
|
6
|
+
import { __getType__ } from "./getType";
|
|
7
|
+
import { _methods_ } from "./introspection";
|
|
8
|
+
import { is_a } from "./is_a";
|
|
9
|
+
import { isBrowser } from "./platform";
|
|
10
|
+
import { _QC_CLASSES } from "./PrimaryCollections";
|
|
11
|
+
import { Package } from "./Package";
|
|
12
|
+
|
|
13
|
+
export class InheritClass implements IInheritClass {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
__definition: any;
|
|
16
|
+
private _body: TBody;
|
|
17
|
+
public get body(): TBody {
|
|
18
|
+
return this._body;
|
|
19
|
+
}
|
|
20
|
+
public set body(value: TBody) {
|
|
21
|
+
this._body = value;
|
|
22
|
+
}
|
|
23
|
+
childs: any;
|
|
24
|
+
__instanceID!: number;
|
|
25
|
+
|
|
26
|
+
constructor(_o_?: any) {
|
|
27
|
+
|
|
28
|
+
if (typeof _o_ !== "undefined" && typeof _o_.__definition !== "undefined"){
|
|
29
|
+
this.__definition = {
|
|
30
|
+
...(_o_.__definition)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const self:any = this;
|
|
35
|
+
IncrementInstanceID();
|
|
36
|
+
if (!self.__instanceID) {
|
|
37
|
+
Object.defineProperty(self, "__instanceID", {
|
|
38
|
+
value: __instanceID,
|
|
39
|
+
writable: false
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof self.__definition !== "undefined") {
|
|
44
|
+
Object.keys(self.__definition).filter(function (k) {
|
|
45
|
+
return isNaN(k as any) && !["name", "__instanceID", "__classType", "__definition"].includes(k);
|
|
46
|
+
}).forEach(function (key) {
|
|
47
|
+
if (typeof self.__definition[key] === "function") {
|
|
48
|
+
self[key] = self.__definition[key].bind(self);
|
|
49
|
+
} else {
|
|
50
|
+
self[key] = self.__definition[key];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
_methods_((_QC_CLASSES as any)[self.__classType]).map(function (m): any {
|
|
55
|
+
self[(m as Function).name] = (m as Function).bind(self);
|
|
56
|
+
return m;
|
|
57
|
+
});
|
|
58
|
+
_methods_(self.__definition).map(function (m): any {
|
|
59
|
+
self[(m as Function).name] = (m as Function).bind(self);
|
|
60
|
+
return m;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (self.body) {
|
|
64
|
+
if (typeof self.__definition === "undefined" || (!Object.hasOwn(self.__definition, "body")) || typeof self.__definition.body === "undefined") {
|
|
65
|
+
try {
|
|
66
|
+
if (isBrowser) {
|
|
67
|
+
self.body = _DOMCreateElement(self.__definition.__classType);
|
|
68
|
+
} else {
|
|
69
|
+
self.body = {};
|
|
70
|
+
}
|
|
71
|
+
} catch (e:any) {
|
|
72
|
+
logger.debug(`An error ocurred: ${e}.`);
|
|
73
|
+
self.body = {};
|
|
74
|
+
}
|
|
75
|
+
} else if (Object.hasOwn(self.__definition, "body")) {
|
|
76
|
+
self.body = self.__definition.body;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
self.__new__.call(self, _o_);
|
|
83
|
+
if (typeof self === "object" && Object.hasOwn(self, "_new_") && typeof self._new_.isCalled === "undefined") {
|
|
84
|
+
try {
|
|
85
|
+
self._new_(_o_);
|
|
86
|
+
self._new_.isCalled = true;
|
|
87
|
+
} catch (e: any) {
|
|
88
|
+
logger.warn(`${self.__classType}._new_() failed with error: ${e}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} catch (e: any) {
|
|
92
|
+
logger.warn(e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static get __classType(): any {
|
|
97
|
+
return (Object.getPrototypeOf(this.constructor) as Function).name;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get __classType(): string {
|
|
101
|
+
return this.constructor.name;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
static hierarchy(__class__: any): any[] {
|
|
106
|
+
const __classType = function (o_c: any): any {
|
|
107
|
+
return (Object.hasOwn(o_c, "__classType")) ? (o_c.__classType) : (__getType__.call(__class__, o_c));
|
|
108
|
+
};
|
|
109
|
+
const __hierarchy__proto__ = (c: any): any[] => {
|
|
110
|
+
return (typeof c !== "undefined" && typeof c.__proto__ !== "undefined" && c.__proto__ !== null) ? (((__classType(c) !== "") ? ([__classType(c)]) : ([])).concat(__hierarchy__proto__(c.__proto__))) : ([]);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
if (typeof __class__ === "undefined" || __class__ === null) {
|
|
114
|
+
__class__ = this;
|
|
115
|
+
}
|
|
116
|
+
let __hierarchy = [];
|
|
117
|
+
__hierarchy.push(__classType(__class__));
|
|
118
|
+
__hierarchy = __hierarchy.concat(__hierarchy__proto__(__class__.__proto__));
|
|
119
|
+
return __hierarchy;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
__namespace?: string | undefined;
|
|
124
|
+
|
|
125
|
+
__new__(_o_: any) {
|
|
126
|
+
_CastProps(_o_, this);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// eslint-disable-next-line no-unused-vars
|
|
130
|
+
_new_(_o_?: any) { }
|
|
131
|
+
|
|
132
|
+
static getParentClass(): any {
|
|
133
|
+
return Object.getPrototypeOf(this.prototype.constructor);
|
|
134
|
+
}
|
|
135
|
+
getParentClass():any {
|
|
136
|
+
return (this.constructor as typeof InheritClass).getParentClass();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
static getClass(): any {
|
|
141
|
+
return Object.getPrototypeOf(this.constructor);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getClass(): any {
|
|
145
|
+
return (this.constructor as typeof InheritClass).getClass();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
css(_css: any): any {
|
|
149
|
+
if (typeof this.body !== "undefined" && typeof this?.body !== "string" && typeof (this?.body as HTMLElement)?.style !== "undefined") {
|
|
150
|
+
logger.debug("body style");
|
|
151
|
+
if (this.body){
|
|
152
|
+
(this.body as any).style = _Cast(_css, (this?.body as HTMLElement)?.style);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return (typeof this.body !== "string")? (this?.body as HTMLElement)?.style :{};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
hierarchy(): any {
|
|
159
|
+
const __instance__ = this;
|
|
160
|
+
return this.getClass().hierarchy(__instance__);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
append(_child?: any) {
|
|
165
|
+
const child: any = _child || this.body;
|
|
166
|
+
logger.debug("append: start");
|
|
167
|
+
if (is_a(child, "Component")) {
|
|
168
|
+
logger.debug("append: child is a Component");
|
|
169
|
+
logger.debug(`appending the body of ${child.name}`);
|
|
170
|
+
}
|
|
171
|
+
if (typeof this.body !== "undefined") {
|
|
172
|
+
logger.debug("append element");
|
|
173
|
+
if (arguments.length > 0) {
|
|
174
|
+
logger.debug("append to element");
|
|
175
|
+
if (typeof this.body !== "string"){
|
|
176
|
+
if (typeof (this.body as IQCObjectsElement)?.append !== "undefined") {
|
|
177
|
+
(this?.body as IQCObjectsElement)?.append(child);
|
|
178
|
+
} else {
|
|
179
|
+
throw Error ("body.append is undefined. That means the body is not well formed.");
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
this.append(child);
|
|
183
|
+
}
|
|
184
|
+
if (typeof this.childs === "undefined") {
|
|
185
|
+
this.childs = [];
|
|
186
|
+
}
|
|
187
|
+
this.childs.push(child);
|
|
188
|
+
} else {
|
|
189
|
+
if (isBrowser) {
|
|
190
|
+
logger.debug("append to body");
|
|
191
|
+
document.body.append(child);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
attachIn(tag: any) {
|
|
198
|
+
if (isBrowser) {
|
|
199
|
+
const tags = (document as any).subelements(tag);
|
|
200
|
+
for (let i = 0, j = tags.length; i < j; i++) {
|
|
201
|
+
tags[i].append(this as any);
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
throw new Error("attachIn not yet implemented for non browser platforms");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
Package("com.qcobjects", [InheritClass]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __is_raw_class__ } from "./is_raw_class";
|
|
2
|
+
|
|
3
|
+
export const _LegacyCopy = function (obj:any, _ignore?:string[]):any {
|
|
4
|
+
let _value_;
|
|
5
|
+
switch (true) {
|
|
6
|
+
case typeof obj === "string":
|
|
7
|
+
_value_ = obj;
|
|
8
|
+
break;
|
|
9
|
+
case typeof obj === "number":
|
|
10
|
+
_value_ = obj;
|
|
11
|
+
break;
|
|
12
|
+
case typeof obj === "object":
|
|
13
|
+
_value_ = [{...Object.keys(obj).filter(k => !_ignore?.includes(k))}]
|
|
14
|
+
.map(k => {return {[k as never]:obj[k as never]}; })
|
|
15
|
+
.reduce ((p, c) => Object.assign(p, c)) as any;
|
|
16
|
+
break;
|
|
17
|
+
case typeof obj === "function":
|
|
18
|
+
_value_ = obj.bind({});
|
|
19
|
+
break;
|
|
20
|
+
case __is_raw_class__(obj):
|
|
21
|
+
_value_ = class extends obj { };
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
return _value_;
|
|
27
|
+
};
|
package/src/Logger.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isBrowser } from "./platform";
|
|
2
|
+
|
|
3
|
+
export class Logger {
|
|
4
|
+
debugEnabled = true;
|
|
5
|
+
infoEnabled = true;
|
|
6
|
+
warnEnabled = true;
|
|
7
|
+
debug(message:string) {
|
|
8
|
+
if (this.debugEnabled) {
|
|
9
|
+
console.log("\x1b[35m%s\x1b[0m", `[DEBUG][${performance.now().toLocaleString()}] ${message}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
info(message:string) {
|
|
14
|
+
let color;
|
|
15
|
+
if (this.infoEnabled) {
|
|
16
|
+
if (isBrowser) {
|
|
17
|
+
color = "\x1b[103m%s\x1b[0m";
|
|
18
|
+
} else {
|
|
19
|
+
color = "\x1b[33m%s\x1b[0m";
|
|
20
|
+
}
|
|
21
|
+
console.info(color, `[INFO][${performance.now().toLocaleString()}] ${message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
warn(message:string) {
|
|
26
|
+
if (this.warnEnabled) {
|
|
27
|
+
console.warn("\x1b[31m%s\x1b[0m", `[WARN][${performance.now().toLocaleString()}] ${message}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const logger = new Logger();
|