qcobjects 2.4.107-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.
Files changed (197) hide show
  1. package/.hintrc +5 -0
  2. package/VERSION +1 -1
  3. package/build/ArrayCollection.js +136 -0
  4. package/build/BackendMicroservice.js +211 -0
  5. package/build/Base64.js +100 -0
  6. package/build/CONFIG.js +85 -0
  7. package/build/Cast.js +53 -0
  8. package/build/Class.js +284 -0
  9. package/build/ClassFactory.js +38 -0
  10. package/build/ComplexStorageCache.js +91 -0
  11. package/build/Component.js +1133 -0
  12. package/build/ComponentFactory.js +113 -0
  13. package/build/ConfigSettings.js +39 -0
  14. package/build/Controller.js +81 -0
  15. package/build/Crypt.js +87 -0
  16. package/build/DDO.js +81 -0
  17. package/build/DOMCreateElement.js +15 -0
  18. package/build/DataStringify.js +22 -0
  19. package/build/DefaultTemplateHandler.js +57 -0
  20. package/build/DocumentLayout.js +20 -0
  21. package/build/Effect.js +46 -0
  22. package/build/Export.js +11 -0
  23. package/build/Import.js +140 -0
  24. package/build/IncrementInstanceID.js +11 -0
  25. package/build/InheritClass.js +194 -0
  26. package/build/LegacyCopy.js +31 -0
  27. package/build/Logger.js +33 -0
  28. package/build/MainProcess.js +549 -0
  29. package/build/NamespaceRef.js +29 -0
  30. package/build/New.js +17 -0
  31. package/build/ObjectName.js +22 -0
  32. package/build/Package.js +67 -0
  33. package/build/PrimaryCollections.js +7 -0
  34. package/build/Processor.js +81 -0
  35. package/build/QCObjects.js +182 -4843
  36. package/build/Ready.js +49 -0
  37. package/build/RegisterClass.js +28 -0
  38. package/build/Service.js +112 -0
  39. package/build/SourceCSS.js +56 -0
  40. package/build/SourceJS.js +73 -0
  41. package/build/Tag.js +77 -0
  42. package/build/Timer.js +30 -0
  43. package/build/Toggle.js +59 -0
  44. package/build/TransitionEffect.js +65 -0
  45. package/build/VO.js +11 -0
  46. package/build/View.js +18 -0
  47. package/build/WidgetsFactory.js +537 -0
  48. package/build/assign.js +32 -0
  49. package/build/asyncLoad.js +43 -0
  50. package/build/basePath.js +32 -0
  51. package/build/captureFalseTouch.js +32 -0
  52. package/build/componentLoader.js +258 -0
  53. package/build/defaultProcessors.js +130 -0
  54. package/build/domain.js +4 -0
  55. package/build/findPackageNodePath.js +47 -0
  56. package/build/getType.js +38 -0
  57. package/build/globalSettings.js +115 -0
  58. package/build/index.d.ts +1045 -0
  59. package/build/index.js +24 -4
  60. package/build/index.mjs +1 -1
  61. package/build/introspection.js +86 -0
  62. package/build/isQCObjects.js +20 -0
  63. package/build/is_a.js +19 -0
  64. package/build/is_forbidden_name.js +15 -0
  65. package/build/is_raw_class.js +7 -0
  66. package/build/loadSDK.js +63 -0
  67. package/build/localStorage.js +19 -0
  68. package/build/make_global.js +24 -0
  69. package/build/mathFunctions.js +7 -0
  70. package/build/platform.js +28 -0
  71. package/build/range.js +17 -0
  72. package/build/routings.js +21 -0
  73. package/build/secretKey.js +5 -0
  74. package/build/serviceLoader.js +300 -0
  75. package/build/shortCode.js +14 -0
  76. package/build/subelements.js +8 -0
  77. package/build/super.js +20 -0
  78. package/build/tag_filter.js +4 -0
  79. package/build/top.js +23 -0
  80. package/build/uniqueID.js +5 -0
  81. package/build/waitUntil.js +31 -0
  82. package/build-esbuild.js +62 -0
  83. package/eslint.config.mjs +87 -0
  84. package/package.json +26 -23
  85. package/public/browser/index.js +6502 -0
  86. package/public/browser/index.js.map +7 -0
  87. package/public/cjs/index.cjs +6586 -0
  88. package/public/cjs/index.cjs.map +7 -0
  89. package/public/esm/index.mjs +6494 -0
  90. package/public/esm/index.mjs.map +7 -0
  91. package/spec/helpers/mock-sdk.helper.ts +5 -0
  92. package/spec/mocks/qcobjects-sdk.mock.ts +1 -0
  93. package/spec/support/jasmine.json +3 -3
  94. package/spec/testsClassFactorySpec.ts +40 -0
  95. package/spec/{testsConfigSpec.js → testsConfigSpec.ts} +2 -2
  96. package/spec/{testsGlobalFeaturesSpec.js → testsGlobalFeaturesSpec.ts} +10 -8
  97. package/spec/{testsSpec.js → testsSpec.ts} +11 -10
  98. package/spec/{testsTypeSpec.js → testsTypeSpec.ts} +5 -3
  99. package/src/ArrayCollection.ts +143 -0
  100. package/src/BackendMicroservice.ts +229 -0
  101. package/src/Base64.ts +92 -0
  102. package/src/CONFIG.ts +96 -0
  103. package/src/Cast.ts +46 -0
  104. package/src/Class.ts +303 -0
  105. package/src/ClassFactory.ts +34 -0
  106. package/src/ComplexStorageCache.ts +97 -0
  107. package/src/Component.ts +1222 -0
  108. package/src/ComponentFactory.ts +122 -0
  109. package/src/ConfigSettings.ts +62 -0
  110. package/src/Controller.ts +90 -0
  111. package/src/Crypt.ts +87 -0
  112. package/src/DDO.ts +93 -0
  113. package/src/DOMCreateElement.ts +12 -0
  114. package/src/DataStringify.ts +19 -0
  115. package/src/DefaultTemplateHandler.ts +55 -0
  116. package/src/DocumentLayout.ts +16 -0
  117. package/src/Effect.ts +56 -0
  118. package/src/Export.ts +8 -0
  119. package/src/Import.ts +135 -0
  120. package/src/IncrementInstanceID.ts +8 -0
  121. package/src/InheritClass.ts +210 -0
  122. package/src/LegacyCopy.ts +27 -0
  123. package/src/Logger.ts +32 -0
  124. package/src/MainProcess.ts +629 -0
  125. package/src/NamespaceRef.ts +26 -0
  126. package/src/New.ts +15 -0
  127. package/src/ObjectName.ts +16 -0
  128. package/src/Package.ts +67 -0
  129. package/src/PrimaryCollections.ts +7 -0
  130. package/src/Processor.ts +93 -0
  131. package/src/QCObjects.ts +100 -0
  132. package/src/Ready.ts +44 -0
  133. package/src/RegisterClass.ts +26 -0
  134. package/src/Service.ts +127 -0
  135. package/src/SourceCSS.ts +59 -0
  136. package/src/SourceJS.ts +76 -0
  137. package/src/Tag.ts +76 -0
  138. package/src/Timer.ts +42 -0
  139. package/src/Toggle.ts +65 -0
  140. package/src/TransitionEffect.ts +80 -0
  141. package/src/VO.ts +8 -0
  142. package/src/View.ts +17 -0
  143. package/src/WidgetsFactory.ts +543 -0
  144. package/src/assign.ts +33 -0
  145. package/src/asyncLoad.ts +42 -0
  146. package/src/basePath.ts +29 -0
  147. package/src/captureFalseTouch.ts +29 -0
  148. package/src/componentLoader.ts +252 -0
  149. package/src/defaultProcessors.ts +145 -0
  150. package/src/domain.ts +1 -0
  151. package/src/findPackageNodePath.ts +43 -0
  152. package/src/getType.ts +36 -0
  153. package/src/globalSettings.ts +118 -0
  154. package/src/index.mts +1 -1
  155. package/src/index.ts +1 -1
  156. package/src/introspection.ts +80 -0
  157. package/src/isQCObjects.ts +19 -0
  158. package/src/is_a.ts +16 -0
  159. package/src/is_forbidden_name.ts +12 -0
  160. package/src/is_raw_class.ts +3 -0
  161. package/src/loadSDK.ts +59 -0
  162. package/src/localStorage.ts +17 -0
  163. package/src/make_global.ts +19 -0
  164. package/src/mathFunctions.ts +3 -0
  165. package/src/platform.ts +30 -0
  166. package/src/range.ts +15 -0
  167. package/src/routings.ts +18 -0
  168. package/src/secretKey.ts +3 -0
  169. package/src/serviceLoader.ts +306 -0
  170. package/src/shortCode.ts +11 -0
  171. package/src/subelements.ts +4 -0
  172. package/src/super.ts +17 -0
  173. package/src/tag_filter.ts +1 -0
  174. package/src/top.ts +111 -0
  175. package/src/types/global/index.d.ts +597 -0
  176. package/src/uniqueID.ts +3 -0
  177. package/src/waitUntil.ts +26 -0
  178. package/tsconfig.d.json +35 -8
  179. package/tsconfig.jasmine.json +39 -0
  180. package/tsconfig.json +46 -12
  181. package/.eslintignore +0 -5
  182. package/.eslintrc.cjs +0 -21
  183. package/.eslintrc.json +0 -24
  184. package/browser/QCObjects.js +0 -2
  185. package/browser/QCObjects.js.map +0 -7
  186. package/browser/chunks/chunk-O2PFFZVJ.js +0 -713
  187. package/browser/chunks/chunk-O2PFFZVJ.js.map +0 -7
  188. package/browser/chunks/chunk-TBLBK5VV.js +0 -713
  189. package/browser/chunks/chunk-TBLBK5VV.js.map +0 -7
  190. package/browser/chunks/chunk-ZYLXOA35.js +0 -713
  191. package/browser/chunks/chunk-ZYLXOA35.js.map +0 -7
  192. package/browser/index.js +0 -2
  193. package/browser/index.js.map +0 -7
  194. package/spec/testsClassFactorySpec.js +0 -41
  195. package/src/QCObjects.js +0 -5247
  196. package/src/index.d.ts +0 -8
  197. 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,8 @@
1
+ /**
2
+ * Primary instance ID of all objects
3
+ */
4
+ export var __instanceID = 0;
5
+
6
+ export const IncrementInstanceID = () => {
7
+ __instanceID = (typeof __instanceID === "undefined" || __instanceID === null) ? (0) : (__instanceID + 1);
8
+ };
@@ -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();