qcobjects 2.4.107-ts → 2.5.101-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/Package.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { InheritClass } from "./InheritClass";
2
+ import { __is_raw_class__ } from "./is_raw_class";
3
+ import { _QC_PACKAGES } from "./PrimaryCollections";
4
+ import { __register_class__ } from "./RegisterClass";
5
+
6
+ /**
7
+ * Defines a package for Class classification
8
+ *
9
+ * @param {Object} namespace
10
+ * @param {Object} classes
11
+ */
12
+ export const Package = function (namespace: string, classes: any[] = []): any[] | undefined {
13
+ if (Object.hasOwn(_QC_PACKAGES, namespace) &&
14
+ typeof (_QC_PACKAGES as any)[namespace] !== "undefined" &&
15
+ Object.hasOwn((_QC_PACKAGES as any)[namespace], "length") &&
16
+ (_QC_PACKAGES as any)[namespace].length > 0 &&
17
+ typeof classes !== "undefined" &&
18
+ Object.hasOwn(classes, "length") &&
19
+ classes.length > 0
20
+ ) {
21
+ classes.filter(
22
+ function (_c1) {
23
+ return __is_raw_class__(_c1);
24
+ }
25
+ ).map(<T>(_class_: any): T => {
26
+ if (typeof _class_.__definition === "undefined") {
27
+ _class_.__definition = {};
28
+ }
29
+ _class_.__definition.__namespace = namespace;
30
+ _class_.__namespace = namespace;
31
+ return _class_ as T;
32
+ });
33
+ (_QC_PACKAGES as any)[namespace] = (_QC_PACKAGES as any)[namespace].concat(classes);
34
+ } else if (typeof classes !== "undefined") {
35
+ if (typeof classes === "object" && Object.hasOwn(classes, "length")) {
36
+ classes.filter(
37
+ function (_c1) {
38
+ return __is_raw_class__(_c1);
39
+ }
40
+ ).map(<T>(_class_: any): T => {
41
+ if (typeof _class_.__definition === "undefined") {
42
+ _class_.__definition = {};
43
+ }
44
+ _class_.__definition.__namespace = namespace;
45
+ _class_.__namespace = namespace;
46
+ return _class_ as T;
47
+ });
48
+ } else if ((classes as any).prototype instanceof InheritClass) {
49
+ if (typeof (classes as any).__definition === "undefined") {
50
+ (classes as any).__definition = {};
51
+ }
52
+ (classes as any).__definition.__namespace = namespace;
53
+ (classes as any).__namespace = namespace;
54
+ }
55
+ (_QC_PACKAGES as any)[namespace] = classes;
56
+ }
57
+ if (Object.hasOwn(_QC_PACKAGES, namespace)) {
58
+ (_QC_PACKAGES as any)[namespace].map(<T>(_class_: any): T => {
59
+ __register_class__(_class_, namespace);
60
+ return _class_ as T;
61
+ });
62
+ }
63
+ return ((Object.hasOwn(_QC_PACKAGES, namespace)) ? ((_QC_PACKAGES as any)[namespace]) : (undefined)) as any[] | undefined;
64
+ };
65
+ Package.prototype.toString = function () {
66
+ return "Package(namespace, classes) { [QCObjects native code] }";
67
+ };
@@ -0,0 +1,7 @@
1
+ import { T_QC_CLASSES, T_QC_PACKAGES } from "types";
2
+
3
+ export var _QC_CLASSES:T_QC_CLASSES = {};
4
+ export var _QC_PACKAGES:T_QC_PACKAGES = {};
5
+ export var _QC_PACKAGES_IMPORTED:any[] = [];
6
+ export var _QC_READY_LISTENERS:any[] = [];
7
+
@@ -0,0 +1,93 @@
1
+ import {type IComponent, type IProcessor } from "types";
2
+ import { CONFIG } from "./CONFIG";
3
+ import { InheritClass } from "./InheritClass";
4
+ import { New } from "./New";
5
+ import { _top } from "./top";
6
+ import { Component } from "./Component";
7
+ import { Package } from "./Package";
8
+
9
+ export class Processor extends InheritClass implements IProcessor {
10
+ protected static _instance:IProcessor | undefined;
11
+ constructor({ component, processors }: { component: IComponent | null, processors?:any }) {
12
+ super({ component });
13
+ if (typeof processors !== "undefined"){
14
+ this.processors = Object.assign (processors,Processor.instance.processors);
15
+ }
16
+ }
17
+
18
+ processors:any = {
19
+ "config"(component: Component, arg: string):string {
20
+ return CONFIG.get(arg, "") as string;
21
+ },
22
+ "ENV"(component: Component, arg: string):string {
23
+ return (typeof process !== "undefined") ? (process.env[arg] as string) : ("");
24
+ },
25
+ "global"(component: Component, arg: string):string {
26
+ return (typeof _top !== "undefined") ? ((_top as any)[arg] as string) : ("");
27
+ }
28
+ };
29
+
30
+ static get instance ():IProcessor {
31
+ if (typeof Processor._instance === "undefined"){
32
+ Processor._instance = new Processor({component:null});
33
+ }
34
+ return Processor._instance;
35
+ }
36
+
37
+ setProcessor(_proc_: Function) {
38
+ if (typeof _proc_ === "function" && _proc_.name !== "") {
39
+ this.processors[_proc_.name] = _proc_;
40
+ }
41
+ }
42
+
43
+ component!: IComponent|null;
44
+
45
+
46
+ execute(component: IComponent, processorName: string, args: string):string {
47
+ const processorHandler = (typeof component !== "undefined" && component !== null) ? (component.processorHandler) : (this);
48
+ return processorHandler?.processors[processorName].bind(processorHandler).apply(processorHandler, [component, args?.split(",")]) as string;
49
+ }
50
+
51
+ process(template: string, component: IComponent | null = null) {
52
+ const processorHandler = (component !== null) ? (component.processorHandler) : (New(Processor, { component: null }));
53
+ if (typeof template === "string") {
54
+ Object.keys(processorHandler.processors).map(function (funcName) {
55
+ [...template.matchAll(new RegExp("\\$" + funcName + "\\((.*)\\).*", "g"))].map(
56
+ function (procesorMatch) {
57
+ const match0 = `$${funcName}(${procesorMatch[1]})`;
58
+ template = template.replace(match0, processorHandler.execute.bind(processorHandler).call(processorHandler, component, funcName, procesorMatch[1]));
59
+ return procesorMatch;
60
+ }
61
+ );
62
+ });
63
+ }
64
+ return template;
65
+ }
66
+
67
+ processObject(obj: any, component: IComponent | null = null):any {
68
+ let __instance__: IProcessor | undefined = (component === null) ? (this) : (component.processorHandler);
69
+ if (typeof __instance__ === "undefined") {
70
+ __instance__ = new Processor({ component });
71
+ }
72
+ if (typeof obj === "object") {
73
+ Object.keys(obj).map(
74
+ (_k) => {
75
+ if (typeof obj[_k] === "object" && !Object.hasOwn(obj[_k], "call")) {
76
+ obj[_k] = __instance__?.processObject.bind(__instance__)(obj[_k], component as IComponent);
77
+ } else if (typeof obj[_k] === "string") {
78
+ obj[_k] = __instance__?.process.bind(__instance__)(obj[_k], component as IComponent);
79
+ }
80
+ return _k;
81
+ }
82
+ );
83
+ } else if (typeof obj === "string") {
84
+ obj = __instance__.process.bind(__instance__)(obj, component as IComponent);
85
+ }
86
+ return obj;
87
+ }
88
+
89
+ }
90
+
91
+ export const GlobalProcessor:IProcessor = Processor.instance;
92
+
93
+ Package("com.qcobjects", [Processor]);
@@ -0,0 +1,100 @@
1
+ /**
2
+ * QCObjects 2.4
3
+ * ________________
4
+ *
5
+ * Author: Jean Machuca <correojean@gmail.com>
6
+ *
7
+ * Cross Browser Javascript Framework for MVC Patterns
8
+ * QuickCorp/QCObjects is licensed under the
9
+ * GNU Lesser General Public License v3.0
10
+ * [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
11
+ *
12
+ * Permissions of this copyleft license are conditioned on making available
13
+ * complete source code of licensed works and modifications under the same
14
+ * license or the GNU GPLv3. Copyright and license notices must be preserved.
15
+ * Contributors provide an express grant of patent rights. However, a larger
16
+ * work using the licensed work through interfaces provided by the licensed
17
+ * work may be distributed under different terms and without source code for
18
+ * the larger work.
19
+ *
20
+ * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
21
+ *
22
+ * Everyone is permitted to copy and distribute verbatim copies of this
23
+ * license document, but changing it is not allowed.
24
+ */
25
+ /* eslint no-unused-vars: "off" */
26
+ /* eslint no-redeclare: "off" */
27
+ /* eslint no-empty: "off" */
28
+ /* eslint strict: "off" */
29
+
30
+ /* eslint no-mixed-operators: "off" */
31
+
32
+ "use strict";
33
+
34
+ export * as AssignPolyfill from "./assign";
35
+ export { _top, resetTop } from "./top";
36
+ export { _QC_CLASSES, _QC_PACKAGES, _QC_PACKAGES_IMPORTED, _QC_READY_LISTENERS } from "./PrimaryCollections";
37
+ export { _DataStringify } from "./DataStringify";
38
+ export { _DOMCreateElement } from "./DOMCreateElement";
39
+ export { _methods_, _protected_code_ } from "./introspection";
40
+ export { logger, Logger } from "./Logger";
41
+ export { _require_, is_phonegap, isBrowser, isNodeCommonJS } from "./platform";
42
+ export { subelements } from "./subelements";
43
+ export { __is_raw_class__ } from "./is_raw_class";
44
+ export { _LegacyCopy } from "./LegacyCopy";
45
+ export { _fireAsyncLoad, asyncLoad } from "./asyncLoad";
46
+ export { __instanceID } from "./IncrementInstanceID";
47
+ export { ObjectName } from "./ObjectName";
48
+ export { __getType__ } from "./getType";
49
+ export { is_a } from "./is_a";
50
+ export { ComplexStorageCache } from "./ComplexStorageCache";
51
+ export { waitUntil } from "./waitUntil";
52
+ export { _Cast, _CastProps } from "./Cast";
53
+ export { isQCObjects_Class, isQCObjects_Object } from "./isQCObjects";
54
+ export { Package } from "./Package";
55
+ export { ClassFactory } from "./ClassFactory";
56
+ export { Export } from "./Export";
57
+ export { Class } from "./Class";
58
+ export { InheritClass } from "./InheritClass";
59
+ export { _super_ } from "./super";
60
+ export { shortCode } from "./shortCode";
61
+ export { Processor } from "./Processor";
62
+ export { New } from "./New";
63
+ export { _Ready, ready, Ready } from "./Ready";
64
+ export { captureFalseTouch } from "./captureFalseTouch";
65
+ export { serviceLoader } from "./serviceLoader";
66
+ export { componentLoader } from "./componentLoader";
67
+ export { _buildComponentsFromElements_, ComponentURI } from "./ComponentFactory";
68
+ export { NamespaceRef } from "./NamespaceRef";
69
+ export { setDefaultProcessors } from "./defaultProcessors";
70
+ export { Tag, TagElements } from "./Tag";
71
+ export { Import } from "./Import";
72
+ export { BackendMicroservice } from "./BackendMicroservice";
73
+ export { Component } from "./Component";
74
+ export { _Crypt } from "./Crypt";
75
+ export { DefaultTemplateHandler } from "./DefaultTemplateHandler";
76
+ export { SourceJS } from "./SourceJS";
77
+ export { SourceCSS } from "./SourceCSS";
78
+ export { GlobalSettings } from "./globalSettings";
79
+ export { RegisterClass } from "./RegisterClass";
80
+ export { _ComponentWidget_, RegisterWidget, RegisterWidgets } from "./WidgetsFactory";
81
+ export { CONFIG } from "./CONFIG";
82
+ export { Controller } from "./Controller";
83
+ export { View } from "./View";
84
+ export { ConfigService, JSONService, Service } from "./Service";
85
+ export { VO } from "./VO";
86
+ export { Effect } from "./Effect";
87
+ export { TransitionEffect } from "./TransitionEffect";
88
+ export { Timer } from "./Timer";
89
+ export { _tag_filter_ } from "./tag_filter";
90
+ export { range } from "./range";
91
+ export { ArrayCollection, ArrayList } from "./ArrayCollection";
92
+ export { DDO } from "./DDO";
93
+ export { Toggle } from "./Toggle";
94
+ export { findPackageNodePath } from "./findPackageNodePath";
95
+ export { getDocumentLayout } from "./DocumentLayout";
96
+ export { IQCObjectsElement, IQCObjectsShadowedElement } from "types";
97
+ export { __to_number } from "./mathFunctions";
98
+ export {_top as global} from "./top";
99
+ export {__make_global__} from "./make_global";
100
+ export * as QCObjects from "./MainProcess";
package/src/Ready.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { CONFIG } from "./CONFIG";
2
+ import { isBrowser } from "./platform";
3
+ import { _QC_READY_LISTENERS } from "./PrimaryCollections";
4
+ import { _top } from "./top";
5
+
6
+ /**
7
+ * Defines a Custom Ready listener
8
+ */
9
+ export const Ready = function Ready(e:any) {
10
+ if (isBrowser) {
11
+ _QC_READY_LISTENERS.push(e.bind(window) as never);
12
+ } else if (typeof global !== "undefined") {
13
+ _QC_READY_LISTENERS.push(e.bind(global) as never);
14
+ }
15
+ };
16
+
17
+ export const ready = Ready; // case insensitive ready option
18
+
19
+ /**
20
+ * Default Ready event function for window. Executes all micro ready events of Import calls
21
+ *
22
+ * @param {Object} e
23
+ */
24
+ // eslint-disable-next-line no-unused-vars
25
+ export const _Ready = function (e:any) {
26
+ const _execReady = function () {
27
+ // eslint-disable-next-line array-callback-return
28
+ _QC_READY_LISTENERS.map(function (_ready_listener_, _r):any {
29
+ if (typeof _ready_listener_ === "function") {
30
+ (_ready_listener_ as Function)();
31
+ _QC_READY_LISTENERS.splice(_r, 1);
32
+ }
33
+ });
34
+ };
35
+ if (CONFIG.get("delayForReady") > 0) {
36
+ if (isBrowser) {
37
+ setTimeout(_execReady.bind(window), CONFIG.get("delayForReady"));
38
+ } else if (typeof global !== "undefined") {
39
+ setTimeout(_execReady.bind(global), CONFIG.get("delayForReady"));
40
+ }
41
+ } else {
42
+ _execReady.call(_top);
43
+ }
44
+ };
@@ -0,0 +1,26 @@
1
+ import { __getType__ } from "./getType";
2
+ import { __make_global__ } from "./make_global";
3
+ import { _QC_CLASSES } from "./PrimaryCollections";
4
+
5
+
6
+ export const __register_class__ = function (_class_:any, __namespace?:string):any {
7
+ let name = _class_.name || __getType__(_class_);
8
+ if (name.toLowerCase() === "function" && typeof _class_.__classType !== "undefined"){
9
+ name = _class_.__classType;
10
+ }
11
+ if (typeof _class_.__definition === "undefined") {
12
+ _class_.__definition = {};
13
+ }
14
+ _class_.__definition.__classType = name;
15
+ if (typeof __namespace !== "undefined") {
16
+ _class_.__definition.__namespace = __namespace;
17
+ }
18
+ (_QC_CLASSES as any)[name] = _class_;
19
+ __make_global__((_QC_CLASSES as any)[name]);
20
+ return (_QC_CLASSES as any)[name];
21
+ };
22
+
23
+ export const RegisterClass = function (_class_:any, __namespace?:string):any {
24
+ return __register_class__(_class_, __namespace);
25
+ };
26
+ __make_global__(RegisterClass);
package/src/Service.ts ADDED
@@ -0,0 +1,127 @@
1
+ import { _basePath_ } from "./basePath";
2
+ import { _Crypt } from "./Crypt";
3
+ import { _domain_ } from "./domain";
4
+ import { InheritClass } from "./InheritClass";
5
+ import { logger } from "./Logger";
6
+ import { Package } from "./Package";
7
+ import { _secretKey } from "./secretKey";
8
+ import { CONFIG } from "./CONFIG";
9
+ import { IJSONService, IService, TServiceDoneResponse, TServiceStandardResponse } from "types";
10
+
11
+ export class Service extends InheritClass implements IService{
12
+ options!: object;
13
+ withCredentials!: boolean;
14
+ useHTTP2: any;
15
+ // eslint-disable-next-line no-unused-vars
16
+ mockup({ request, service }: TServiceStandardResponse): void {
17
+ throw new Error("Method not implemented.");
18
+ }
19
+ name!: string;
20
+ responseHeaders: any;
21
+ // eslint-disable-next-line no-unused-vars
22
+ local({ request, service }: TServiceStandardResponse): void {
23
+ throw new Error("Method not implemented.");
24
+ }
25
+ kind = "rest";
26
+ /* it can be rest, mockup, local */
27
+ domain = _domain_;
28
+ basePath = _basePath_;
29
+ url = "";
30
+ method = "GET";
31
+ data = {};
32
+ reload = false;
33
+ cached = false;
34
+
35
+ headers: any;
36
+ template: unknown;
37
+
38
+ // eslint-disable-next-line no-unused-vars
39
+ done({ request, service }: TServiceDoneResponse): void {
40
+ throw new Error("Method not implemented.");
41
+ }
42
+ // eslint-disable-next-line no-unused-vars
43
+ fail(...args: any[]): void {
44
+ throw new Error("Method not implemented.");
45
+ }
46
+
47
+ set(name:string, value:never) {
48
+ this[name] = value;
49
+ }
50
+
51
+ get(name:string, _default?:never) {
52
+ return this[name] as never || _default;
53
+ }
54
+
55
+ }
56
+
57
+ export class JSONService extends Service implements IJSONService{
58
+ method = "GET";
59
+ cached = false;
60
+ headers = {
61
+ "Content-Type": "application/json",
62
+ "charset": "utf-8"
63
+ };
64
+
65
+ JSONresponse?:JSON = undefined;
66
+ done(result:TServiceDoneResponse) {
67
+ logger.debug("***** RECEIVED RESPONSE:");
68
+ logger.debug(result.service.template as string);
69
+ this.JSONresponse = JSON.parse(result.service.template as string);
70
+ }
71
+
72
+
73
+
74
+ }
75
+
76
+ export class ConfigService extends JSONService {
77
+ method = "GET";
78
+ cached = false;
79
+ configFileName = "config.json";
80
+ headers = {
81
+ "Content-Type": "application/json",
82
+ "charset": "utf-8"
83
+ };
84
+
85
+ configLoaded():Promise<void>{
86
+ throw Error ("Method not implemented.");
87
+ }
88
+
89
+ JSONresponse?:JSON = undefined;
90
+ done(result:TServiceDoneResponse) {
91
+ logger.debug("***** CONFIG LOADED:");
92
+ logger.debug(result.service.template as string);
93
+ this.JSONresponse = JSON.parse(result.service.template as string);
94
+ if (Object.hasOwn(this.JSONresponse as object, "__encoded__")) {
95
+ const decodedValue:string = _Crypt.decrypt((this.JSONresponse as any)?.__encoded__, _secretKey);
96
+ this.JSONresponse = JSON.parse(decodedValue);
97
+ }
98
+ const jsonResponse:any = this.JSONresponse;
99
+ Object.keys(jsonResponse as object).map((k:string) => {
100
+ CONFIG.set(k, (jsonResponse as never)[k]);
101
+ return k;
102
+ });
103
+ this.configLoaded().catch((e:any)=>{throw new Error (`An error ocurred: ${e}`);});
104
+ }
105
+
106
+ fail() {
107
+ this.configLoaded().catch((e:any)=>{throw new Error (`An error ocurred: ${e}`);});
108
+ }
109
+
110
+ constructor() {
111
+ super();
112
+ this.set("url", `${this.get("basePath") as string}${this.get("configFileName") as string}` as never);
113
+ }
114
+ }
115
+
116
+
117
+ Package("com.qcobjects.api", [
118
+ Service
119
+ ]);
120
+
121
+ Package("com.qcobjects.api.services", [
122
+ JSONService
123
+ ]);
124
+
125
+ Package("com.qcobjects.api.config", [
126
+ ConfigService
127
+ ]);
@@ -0,0 +1,59 @@
1
+ import { ISourceCSS, TBody } from "types";
2
+ import { _basePath_ } from "./basePath";
3
+ import { _Cast } from "./Cast";
4
+ import { _domain_ } from "./domain";
5
+ import { _DOMCreateElement } from "./DOMCreateElement";
6
+ import { InheritClass } from "./InheritClass";
7
+ import { isBrowser } from "./platform";
8
+ import { Package } from "./Package";
9
+
10
+ export class SourceCSS extends InheritClass implements ISourceCSS {
11
+ domain= _domain_;
12
+ basePath= _basePath_;
13
+ url= "";
14
+ data= {};
15
+ async= false;
16
+ external= false;
17
+
18
+ constructor(o:any){
19
+ super(o);
20
+ this.body = _DOMCreateElement("link") as TBody;
21
+ }
22
+ fail(): void {
23
+ throw new Error("Method not implemented.");
24
+ }
25
+ Cast(o: any):any {
26
+ return _Cast(this, o);
27
+ }
28
+ set(name:string, value:any) {
29
+ this[name] = value;
30
+ }
31
+ get(name:string, _default?:any):any {
32
+ return this[name] || _default;
33
+ }
34
+ done() { }
35
+ rebuild() {
36
+ const context = this;
37
+ if (isBrowser) {
38
+ window.document.getElementsByTagName("head")[0].appendChild(
39
+ (function (s:any, url:string, context:any):any {
40
+ s.type = "text/css";
41
+ s.rel = "stylesheet";
42
+ s.href = url;
43
+ s.crossOrigin = "anonymous";
44
+ s.onreadystatechange = function () {
45
+ if (this.readyState === "complete") {
46
+ context.done.call(context);
47
+ }
48
+ };
49
+ s.onload = context.done;
50
+ context.body = s;
51
+ return s;
52
+ }).call(this,
53
+ _DOMCreateElement("link"),
54
+ (this.external) ? (this.url) : (this.basePath + this.url), context));
55
+ }
56
+ }
57
+ }
58
+
59
+ Package("com.qcobjects", [SourceCSS]);
@@ -0,0 +1,76 @@
1
+ import { ISourceJS } from "types";
2
+ import { _basePath_ } from "./basePath";
3
+ import { _Cast } from "./Cast";
4
+ import { _domain_ } from "./domain";
5
+ import { _DOMCreateElement } from "./DOMCreateElement";
6
+ import { InheritClass } from "./InheritClass";
7
+ import { Package } from "./Package";
8
+ import { logger } from "./Logger";
9
+
10
+ export class SourceJS extends InheritClass implements ISourceJS {
11
+ domain= _domain_;
12
+ basePath= _basePath_;
13
+ type= "text/javascript";
14
+ containerTag= "body";
15
+ url= "";
16
+ data= {};
17
+ async= false;
18
+ external= false;
19
+
20
+ constructor(o:any){
21
+ super(o);
22
+ this.body= _DOMCreateElement("script");
23
+
24
+ }
25
+ set(name:string, value:any) {
26
+ this[name] = value;
27
+ }
28
+ get(name:string, _default?:any):any {
29
+ return this[name] || _default;
30
+ }
31
+ status= false;
32
+ done() { }
33
+ fail() { }
34
+ rebuild() {
35
+ const context = this;
36
+ try {
37
+ document.getElementsByTagName(context.containerTag)[0].appendChild(
38
+ (function (s:any, url:string, context:any):any {
39
+ s.type = context.type;
40
+ s.src = url;
41
+ s.crossOrigin = (Object.hasOwn(context, "crossOrigin")) ? (context.crossOrigin) : ("anonymous");
42
+ s.async = context.async;
43
+ s.onreadystatechange = function () {
44
+ if (this.readyState === "complete") {
45
+ context.done.call(context);
46
+ }
47
+ };
48
+ s.onload = function (e:any) {
49
+ context.status = true;
50
+ context.done.call(context, e);
51
+ };
52
+ s.onerror = function (e:any) {
53
+ context.status = false;
54
+ context.fail.call(context, e);
55
+ };
56
+ context.body = s;
57
+ return s;
58
+ }).call(this,
59
+ _DOMCreateElement("script"),
60
+ (this.external) ? (this.url) : (this.basePath + this.url), context));
61
+ } catch (e:any) {
62
+ context.status = false;
63
+ logger.debug(`An error ocurred: ${e}`);
64
+ context.fail();
65
+ }
66
+ }
67
+ Cast(o:any):any {
68
+ return _Cast(this, o);
69
+ }
70
+ _new_(properties:any) {
71
+ this.__new__(properties);
72
+ this.rebuild();
73
+ }
74
+ }
75
+
76
+ Package("com.qcobjects", [SourceJS]);
package/src/Tag.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { IQCObjectsElement, ITagElements } from "types";
2
+ import { ClassFactory } from "./ClassFactory";
3
+ import { New } from "./New";
4
+ import { Package } from "./Package";
5
+ import { isBrowser } from "./platform";
6
+ import { Effect } from "./Effect";
7
+ import { ArrayList } from "./ArrayCollection";
8
+
9
+ export class TagElements extends ArrayList implements ITagElements {
10
+ show() {
11
+ this.map(function (element:any) {
12
+ return element.style.opacity = 1;
13
+ });
14
+ }
15
+ hide() {
16
+ this.map(function (element:any) {
17
+ return element.style.opacity = 0;
18
+ });
19
+ }
20
+ effect<T>(...args:T[]) {
21
+ const effectArguments = [...args].slice(1);
22
+ const effectClassName = args[0] as string;
23
+ let effectClass = undefined;
24
+ if ((typeof effectClassName).toLowerCase() === "string") {
25
+ effectClass = ClassFactory(effectClassName);
26
+ }
27
+ this.map(function <T>(element:any):T {
28
+ return ((effectClass as Effect).apply as Function).apply(effectClass, [element].concat(effectArguments)) as T;
29
+ });
30
+ }
31
+ findElements(elementName:any):any {
32
+ const _o = New(ClassFactory("TagElements"));
33
+ if (isBrowser) {
34
+ for (const _k in this) {
35
+ if (typeof _k === "number" && typeof this[_k] !== "function" && Object.hasOwn(this[_k], "subelements")) {
36
+ _o.push(this[_k].subelements(elementName));
37
+ }
38
+ }
39
+ } else {
40
+ // not yet implemented.
41
+ }
42
+ return _o;
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Gets the element of DOM found by tag name
48
+ *
49
+ * @param {Object} tagname
50
+ * @param {Object} innerHTML
51
+ */
52
+ export const Tag = function <T>(tagname:string, innerHTML?:string): T[] {
53
+ const _o = New(TagElements);
54
+ if (isBrowser) {
55
+ const o = (document as unknown as IQCObjectsElement).subelements(tagname);
56
+ const addedKeys = [];
57
+ for (let _i = 0; _i < o.length; _i++) {
58
+ if (typeof innerHTML !== "undefined" && Object.hasOwn(o[_i], "innerHTML")) {
59
+ o[_i].innerHTML = innerHTML;
60
+ }
61
+ if (addedKeys.indexOf(_i) < 0) {
62
+ _o.push(o[_i]);
63
+ addedKeys.push(_i);
64
+ }
65
+ }
66
+ } else {
67
+ // not yet implemented.
68
+ }
69
+ return _o as T[];
70
+ };
71
+
72
+
73
+ Package("com.qcobjects",[
74
+ TagElements,
75
+ Tag
76
+ ]);