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.
- 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 +26 -23
- 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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { IQCObjectsElement, TComponentURIParams } from "types";
|
|
2
|
+
import { Class } from "./Class";
|
|
3
|
+
import { ClassFactory } from "./ClassFactory";
|
|
4
|
+
import { Component } from "./Component";
|
|
5
|
+
import { CONFIG } from "./CONFIG";
|
|
6
|
+
import { _DOMCreateElement } from "./DOMCreateElement";
|
|
7
|
+
import { __getType__ } from "./getType";
|
|
8
|
+
import { logger } from "./Logger";
|
|
9
|
+
import { New } from "./New";
|
|
10
|
+
import { Package } from "./Package";
|
|
11
|
+
import { isBrowser } from "./platform";
|
|
12
|
+
import { _tag_filter_ } from "./tag_filter";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns a standarized uri for a component
|
|
16
|
+
* @example
|
|
17
|
+
* templateURI = ComponentURI({'COMPONENTS_BASE_PATH':'','COMPONENT_NAME':'','TPLEXTENSION':'','TPL_SOURCE':''})
|
|
18
|
+
* @author: Jean Machuca <correojean@gmail.com>
|
|
19
|
+
* @param params an object with the params to build the uri path
|
|
20
|
+
*/
|
|
21
|
+
export const ComponentURI = ({ TPL_SOURCE, COMPONENTS_BASE_PATH, COMPONENT_NAME, TPLEXTENSION }:TComponentURIParams) => {
|
|
22
|
+
const templateURI = (TPL_SOURCE === "default") ? (`${COMPONENTS_BASE_PATH}${COMPONENT_NAME}.${TPLEXTENSION}`) : ("");
|
|
23
|
+
return templateURI;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const _buildComponentFromElement_ = function (element: Element, __parent__: any) {
|
|
27
|
+
const __shadowed_not_set = (element.getAttribute("shadowed") === null);
|
|
28
|
+
const __tplsource_attr_not_set = (element.getAttribute("template-source") === null);
|
|
29
|
+
const shadowed = (element.getAttribute("shadowed") === "true");
|
|
30
|
+
const __cached_not_set = (element.getAttribute("cached") === null);
|
|
31
|
+
const cached = (element.getAttribute("cached") === "true");
|
|
32
|
+
let tplextension = (typeof CONFIG.get("tplextension") !== "undefined") ? (CONFIG.get("tplextension")) : ("html");
|
|
33
|
+
tplextension = (element.getAttribute("tplextension") !== null) ? (element.getAttribute("tplextension")) : (tplextension);
|
|
34
|
+
let _componentName = element.getAttribute("name");
|
|
35
|
+
const _componentClassName = (element.getAttribute("componentClass") !== null) ? (element.getAttribute("componentClass")) : ("Component");
|
|
36
|
+
const __componentClassName = (CONFIG.get("preserveComponentBodyTag")) ? (
|
|
37
|
+
(_componentName !== null) ? ("com.qcobjects.components." + _componentName + ".ComponentBody") : ("com.qcobjects.components.ComponentBody")
|
|
38
|
+
) : (_componentClassName);
|
|
39
|
+
_componentName = (_componentName !== null) ? (_componentName) : (
|
|
40
|
+
(ClassFactory(__componentClassName as string) &&
|
|
41
|
+
typeof (ClassFactory(__componentClassName as string) as unknown as typeof Component).name !== "undefined"
|
|
42
|
+
) ? (
|
|
43
|
+
(ClassFactory(__componentClassName as string) as unknown as Component).name
|
|
44
|
+
) : ("")
|
|
45
|
+
);
|
|
46
|
+
const __classDefinition = ClassFactory(__componentClassName as string) as Component;
|
|
47
|
+
const __tplsource_prop_set = !!((__componentClassName !== "Component" && ((typeof __classDefinition !== "undefined" && typeof __classDefinition.tplsource === "string") && __classDefinition.tplsource !== "")));
|
|
48
|
+
const tplsource = (__tplsource_attr_not_set && __tplsource_prop_set) ? (__classDefinition.tplsource) : ((__tplsource_attr_not_set) ? ("default") : (element.getAttribute("template-source")));
|
|
49
|
+
logger.debug(`template source for ${_componentName} is ${tplsource} `);
|
|
50
|
+
logger.debug(`type for ${_componentName} is ${__getType__(__classDefinition)} `);
|
|
51
|
+
|
|
52
|
+
const componentURI: string = ComponentURI({
|
|
53
|
+
"COMPONENTS_BASE_PATH": CONFIG.get("componentsBasePath"),
|
|
54
|
+
"COMPONENT_NAME": _componentName ,
|
|
55
|
+
"TPLEXTENSION": tplextension,
|
|
56
|
+
"TPL_SOURCE": tplsource as string
|
|
57
|
+
});
|
|
58
|
+
if (CONFIG.get("preserveComponentBodyTag")) {
|
|
59
|
+
Package((_componentName !== "") ? ("com.qcobjects.components." + _componentName + "") : ("com.qcobjects.components"), [
|
|
60
|
+
Class("ComponentBody", Component, {
|
|
61
|
+
name: _componentName,
|
|
62
|
+
tplsource,
|
|
63
|
+
tplextension,
|
|
64
|
+
reload: true
|
|
65
|
+
})
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const __create_component_instance_ = function ():Component {
|
|
70
|
+
const __shadowed = (__shadowed_not_set) ? ((__classDefinition && __classDefinition.shadowed) || Component.shadowed) : (shadowed);
|
|
71
|
+
const __definition = {
|
|
72
|
+
__parent__,
|
|
73
|
+
name: _componentName,
|
|
74
|
+
cached: (__cached_not_set) ? (Component.cached) : (cached),
|
|
75
|
+
shadowed: __shadowed,
|
|
76
|
+
tplextension,
|
|
77
|
+
body: (CONFIG.get("preserveComponentBodyTag")) ? (_DOMCreateElement("componentBody")) : (element),
|
|
78
|
+
templateURI: componentURI,
|
|
79
|
+
tplsource
|
|
80
|
+
};
|
|
81
|
+
if (typeof _componentName === "undefined" || _componentName === "" || _componentName === null) {
|
|
82
|
+
/* this allows to use the original property defined
|
|
83
|
+
in the component definition if it is not present in the tag */
|
|
84
|
+
delete (__definition as any).name;
|
|
85
|
+
}
|
|
86
|
+
if (componentURI === "") {
|
|
87
|
+
/* this allows to use the original property defined
|
|
88
|
+
in the component definition if it is not present in the tag */
|
|
89
|
+
delete (__definition as any).templateURI;
|
|
90
|
+
}
|
|
91
|
+
const newComponent = New(__classDefinition, __definition) as Component;
|
|
92
|
+
|
|
93
|
+
if (CONFIG.get("preserveComponentBodyTag")) {
|
|
94
|
+
if (typeof newComponent !== "undefined") {
|
|
95
|
+
element.append(newComponent.body as string | Node);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return newComponent;
|
|
99
|
+
};
|
|
100
|
+
const newComponent = __create_component_instance_();
|
|
101
|
+
return newComponent;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const _buildComponentsFromElements_ = function (elements: HTMLElement[], __parent__: Component | null) {
|
|
105
|
+
let componentsBuiltWith:Component[] = [];
|
|
106
|
+
if (isBrowser) {
|
|
107
|
+
componentsBuiltWith = elements.map(
|
|
108
|
+
function (element: any) {
|
|
109
|
+
return _buildComponentFromElement_(element, __parent__);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
} else {
|
|
113
|
+
logger.debug("[_buildComponentsFromElements_] not implemented for Non-Browser environments");
|
|
114
|
+
}
|
|
115
|
+
return componentsBuiltWith;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const buildComponents = (element:HTMLElement):Component[] => {
|
|
119
|
+
const tagFilter = _tag_filter_;
|
|
120
|
+
const elements = (element as unknown as IQCObjectsElement).subelements(tagFilter) as HTMLElement[];
|
|
121
|
+
return _buildComponentsFromElements_(elements, null);
|
|
122
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { _basePath_ } from "./basePath";
|
|
2
|
+
import { InheritClass } from "./InheritClass";
|
|
3
|
+
import { Package } from "./Package";
|
|
4
|
+
|
|
5
|
+
type TConfigSettings = {
|
|
6
|
+
[key: string]: any,
|
|
7
|
+
relativeImportPath:string,
|
|
8
|
+
remoteImportsPath:string,
|
|
9
|
+
remoteSDKPath:string,
|
|
10
|
+
asynchronousImportsLoad:boolean,
|
|
11
|
+
removePackageScriptAfterLoading:boolean,
|
|
12
|
+
componentsBasePath:string,
|
|
13
|
+
delayForReady:number,
|
|
14
|
+
preserveComponentBodyTag:false,
|
|
15
|
+
useConfigService:false,
|
|
16
|
+
routingWay:string,
|
|
17
|
+
useSDK:boolean,
|
|
18
|
+
useLocalSDK:boolean,
|
|
19
|
+
basePath:string
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export class ConfigSettings extends InheritClass {
|
|
24
|
+
public _CONFIG: TConfigSettings = {
|
|
25
|
+
"relativeImportPath": "",
|
|
26
|
+
"remoteImportsPath": "",
|
|
27
|
+
"remoteSDKPath": "https://sdk.qcobjects.dev/",
|
|
28
|
+
"asynchronousImportsLoad": false,
|
|
29
|
+
"removePackageScriptAfterLoading": true,
|
|
30
|
+
"componentsBasePath": "",
|
|
31
|
+
"delayForReady": 0,
|
|
32
|
+
"preserveComponentBodyTag": false,
|
|
33
|
+
"useConfigService": false,
|
|
34
|
+
"routingWay": "hash",
|
|
35
|
+
"useSDK": true,
|
|
36
|
+
"useLocalSDK": false,
|
|
37
|
+
"basePath": _basePath_
|
|
38
|
+
};
|
|
39
|
+
protected static _instance: ConfigSettings;
|
|
40
|
+
public _CONFIG_ENC = "";
|
|
41
|
+
|
|
42
|
+
set(name:string, value:any):void {
|
|
43
|
+
this._CONFIG[name] = value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get(name:string, _defaultValue?:any):any {
|
|
47
|
+
return this._CONFIG[name] || _defaultValue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static get instance():ConfigSettings {
|
|
51
|
+
|
|
52
|
+
if (typeof ConfigSettings._instance === "undefined") {
|
|
53
|
+
ConfigSettings._instance = new ConfigSettings();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return ConfigSettings._instance;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Package("com.qcobjects", [ConfigSettings]);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { IController, IComponent, TControllerParams, IQCObjectsElement, IQCObjectsShadowedElement } from "types";
|
|
2
|
+
import { ClassFactory } from "./ClassFactory";
|
|
3
|
+
import { __getType__ } from "./getType";
|
|
4
|
+
import { InheritClass } from "./InheritClass";
|
|
5
|
+
import { logger } from "./Logger";
|
|
6
|
+
import { New } from "./New";
|
|
7
|
+
import { Package } from "./Package";
|
|
8
|
+
import { isBrowser } from "./platform";
|
|
9
|
+
|
|
10
|
+
export class Controller extends InheritClass implements IController{
|
|
11
|
+
|
|
12
|
+
component!: IComponent ;
|
|
13
|
+
dependencies?: any[] = [];
|
|
14
|
+
constructor({
|
|
15
|
+
component,
|
|
16
|
+
dependencies
|
|
17
|
+
}: TControllerParams) {
|
|
18
|
+
super({ component, dependencies });
|
|
19
|
+
this.component = component;
|
|
20
|
+
this.dependencies = dependencies;
|
|
21
|
+
if (typeof this.component === "undefined" || this.component === null) {
|
|
22
|
+
throw Error(`${__getType__(this)} must be called with a component`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line no-unused-vars
|
|
27
|
+
fail?(...args: [...args: any[]] ): void {
|
|
28
|
+
throw new Error("Method not implemented.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
routingSelectedAttr(attrName: string):any {
|
|
33
|
+
return this.component?.routingSelected.map( (r: any):any => {
|
|
34
|
+
return r[attrName];
|
|
35
|
+
}).filter(function (v: any) {
|
|
36
|
+
return v;
|
|
37
|
+
}).pop();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
isTouchable() {
|
|
41
|
+
return ("ontouchstart" in window) ||
|
|
42
|
+
((navigator as any).MaxTouchPoints > 0) ||
|
|
43
|
+
((navigator as any).msMaxTouchPoints > 0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
onpress(subelementSelector: string, handler: Function) {
|
|
47
|
+
if (isBrowser){
|
|
48
|
+
try {
|
|
49
|
+
if (this.isTouchable()) {
|
|
50
|
+
((this.component?.componentRoot as IQCObjectsElement| IQCObjectsShadowedElement)?.subelements(subelementSelector) as any[])[0].addEventListener("touchstart", handler, {
|
|
51
|
+
passive: true
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
((this.component?.componentRoot as IQCObjectsElement | IQCObjectsShadowedElement)?.subelements(subelementSelector) as any[])[0].addEventListener("click", handler, {
|
|
55
|
+
passive: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
} catch (e:any) {
|
|
59
|
+
logger.debug(`An error ocurred: ${e}.`);
|
|
60
|
+
logger.debug("No button to assign press event");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
createRoutingController() {
|
|
67
|
+
const controller = this;
|
|
68
|
+
const component = controller.component;
|
|
69
|
+
const controllerName = controller.routingSelectedAttr("controllerclass");
|
|
70
|
+
if (typeof controllerName !== "undefined") {
|
|
71
|
+
const _Controller = ClassFactory(controllerName) as unknown as IController;
|
|
72
|
+
if (typeof _Controller !== "undefined" && component !== null) {
|
|
73
|
+
component.routingController = New(_Controller, {
|
|
74
|
+
component
|
|
75
|
+
}) as IController; // Initializes the main controller for the component
|
|
76
|
+
if (typeof component.routingController !== "undefined"
|
|
77
|
+
&& Object.hasOwn(component.routingController, "done")
|
|
78
|
+
&& typeof component.routingController.done === "function") {
|
|
79
|
+
component.routingController.done.call(component.routingController);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
done() { }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
Package("com.qcobjects.controllers", [
|
|
89
|
+
Controller
|
|
90
|
+
]);
|
package/src/Crypt.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { _ICrypt } from "types";
|
|
2
|
+
import { Base64 } from "./Base64";
|
|
3
|
+
import { _DataStringify } from "./DataStringify";
|
|
4
|
+
import { InheritClass } from "./InheritClass";
|
|
5
|
+
import { Package } from "./Package";
|
|
6
|
+
import { _secretKey } from "./secretKey";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class _Crypt extends InheritClass implements _ICrypt{
|
|
10
|
+
string: string = "";
|
|
11
|
+
key: string = "";
|
|
12
|
+
// eslint-disable-next-line no-unused-vars
|
|
13
|
+
encrypt(_string_: string, key: string): string {
|
|
14
|
+
throw new Error("Method not implemented.");
|
|
15
|
+
}
|
|
16
|
+
// eslint-disable-next-line no-unused-vars
|
|
17
|
+
decrypt(_string_: string, key: string): string {
|
|
18
|
+
throw new Error("Method not implemented.");
|
|
19
|
+
}
|
|
20
|
+
last_string= "";
|
|
21
|
+
last_key= "";
|
|
22
|
+
construct= false;
|
|
23
|
+
_new_(o: { string?: string; key: string; }) {
|
|
24
|
+
const string = o.string;
|
|
25
|
+
let key:string = (Object.hasOwn(o, "key")) ? (o.key) : ("");
|
|
26
|
+
this.__new__(o);
|
|
27
|
+
key = (key === "") ? (this.__instanceID.toString()) : (key);
|
|
28
|
+
this.last_key = key;
|
|
29
|
+
this.last_string = string as string;
|
|
30
|
+
this.construct = true;
|
|
31
|
+
}
|
|
32
|
+
_encrypt():string {
|
|
33
|
+
const string = this.string;
|
|
34
|
+
const key = this.key;
|
|
35
|
+
let result = "";
|
|
36
|
+
let char;
|
|
37
|
+
let keychar;
|
|
38
|
+
for (let i = 0; i < string.length; i++) {
|
|
39
|
+
char = string.substr(i, 1);
|
|
40
|
+
keychar = key.substr((i % key.length) - 1, 1);
|
|
41
|
+
char = String.fromCharCode(char.charCodeAt(0) + keychar.charCodeAt(0));
|
|
42
|
+
result += char;
|
|
43
|
+
}
|
|
44
|
+
this.last_string = Base64.encode(result);
|
|
45
|
+
return this.last_string;
|
|
46
|
+
}
|
|
47
|
+
_decrypt():string {
|
|
48
|
+
let string = this.string;
|
|
49
|
+
const key = this.key;
|
|
50
|
+
let result = "";
|
|
51
|
+
let char;
|
|
52
|
+
let keychar;
|
|
53
|
+
string = Base64.decode(string);
|
|
54
|
+
for (let i = 0; i < string.length; i++) {
|
|
55
|
+
char = string.substr(i, 1);
|
|
56
|
+
keychar = key.substr((i % key.length) - 1, 1);
|
|
57
|
+
char = String.fromCharCode(char.charCodeAt(0) - keychar.charCodeAt(0));
|
|
58
|
+
result += char;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.last_string = result;
|
|
62
|
+
return this.last_string;
|
|
63
|
+
}
|
|
64
|
+
static encrypt(string:string, key:string):string {
|
|
65
|
+
const crypt = new _Crypt({
|
|
66
|
+
string,
|
|
67
|
+
key: (key !== "") ? (key) : ("12345678ABC")
|
|
68
|
+
});
|
|
69
|
+
return crypt._encrypt();
|
|
70
|
+
}
|
|
71
|
+
static decrypt(string:string, key:string) {
|
|
72
|
+
const crypt = new _Crypt({
|
|
73
|
+
string,
|
|
74
|
+
key: (key !== "") ? (key) : ("12345678ABC")
|
|
75
|
+
});
|
|
76
|
+
return crypt._decrypt();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const _CryptObject = function (o:any):string {
|
|
81
|
+
return _Crypt.encrypt(_DataStringify(o), _secretKey);
|
|
82
|
+
};
|
|
83
|
+
export const _DecryptObject = function (s:string):any {
|
|
84
|
+
return (s === "") ? ({}) : (JSON.parse(_Crypt.decrypt(s, _secretKey)));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Package( "com.qcobjects", [_Crypt]);
|
package/src/DDO.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { TDDOParams } from "types";
|
|
2
|
+
import { Export } from "./Export";
|
|
3
|
+
import { InheritClass } from "./InheritClass";
|
|
4
|
+
import { logger } from "./Logger";
|
|
5
|
+
import { ObjectName } from "./ObjectName";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Dynamic Data Objects Class
|
|
9
|
+
* Usage:
|
|
10
|
+
* Class('TestDDO',{
|
|
11
|
+
* data: {},
|
|
12
|
+
* _new_ (){
|
|
13
|
+
* this.ddo = New(DDO,{
|
|
14
|
+
* instance:this,
|
|
15
|
+
* name:'data',
|
|
16
|
+
* value:{},
|
|
17
|
+
* fget (value){
|
|
18
|
+
* logger.debug('returned value '+ value );
|
|
19
|
+
* }
|
|
20
|
+
* })
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export class DDO extends InheritClass {
|
|
26
|
+
constructor({
|
|
27
|
+
instance,
|
|
28
|
+
name,
|
|
29
|
+
fget,
|
|
30
|
+
fset,
|
|
31
|
+
value
|
|
32
|
+
}:TDDOParams) {
|
|
33
|
+
super({
|
|
34
|
+
instance,
|
|
35
|
+
name,
|
|
36
|
+
fget,
|
|
37
|
+
fset,
|
|
38
|
+
value
|
|
39
|
+
});
|
|
40
|
+
this._new_({
|
|
41
|
+
instance,
|
|
42
|
+
name,
|
|
43
|
+
fget,
|
|
44
|
+
fset,
|
|
45
|
+
value
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_new_({
|
|
51
|
+
instance,
|
|
52
|
+
name,
|
|
53
|
+
fget,
|
|
54
|
+
fset
|
|
55
|
+
}:TDDOParams) {
|
|
56
|
+
const ddoInstance = this;
|
|
57
|
+
var name = (typeof name === "undefined") ? (ObjectName(ddoInstance)) : (name);
|
|
58
|
+
|
|
59
|
+
Object.defineProperty(instance, name, {
|
|
60
|
+
set(val) {
|
|
61
|
+
const _value = val;
|
|
62
|
+
logger.debug("value changed " + name);
|
|
63
|
+
let ret;
|
|
64
|
+
if (typeof fset !== "undefined" && typeof fset === "function") {
|
|
65
|
+
ret = fset(_value);
|
|
66
|
+
} else {
|
|
67
|
+
ret = _value;
|
|
68
|
+
}
|
|
69
|
+
instance["_" + name] = ret;
|
|
70
|
+
|
|
71
|
+
},
|
|
72
|
+
get():any {
|
|
73
|
+
const _value = instance["_" + name];
|
|
74
|
+
logger.debug("returning value " + name);
|
|
75
|
+
const is_ddo = (v:any):any => {
|
|
76
|
+
if (typeof v === "object" && Object.hasOwn(v, "value")) {
|
|
77
|
+
return v.value;
|
|
78
|
+
}
|
|
79
|
+
return v;
|
|
80
|
+
};
|
|
81
|
+
let ret;
|
|
82
|
+
if (typeof fget !== "undefined" && typeof fget === "function") {
|
|
83
|
+
ret = fget(is_ddo(_value));
|
|
84
|
+
} else {
|
|
85
|
+
ret = is_ddo(_value);
|
|
86
|
+
}
|
|
87
|
+
return ret;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
Export(DDO);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IQCObjectsElement } from "types";
|
|
2
|
+
import { isBrowser } from "./platform";
|
|
3
|
+
|
|
4
|
+
export const _DOMCreateElement = function (elementName:string):IQCObjectsElement {
|
|
5
|
+
let _ret_;
|
|
6
|
+
if (isBrowser) {
|
|
7
|
+
_ret_ = document.createElement(elementName) as unknown as IQCObjectsElement;
|
|
8
|
+
} else {
|
|
9
|
+
_ret_ = {} as IQCObjectsElement;
|
|
10
|
+
}
|
|
11
|
+
return _ret_;
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { _LegacyCopy } from "./LegacyCopy";
|
|
2
|
+
|
|
3
|
+
export const _DataStringify = function (data:any) {
|
|
4
|
+
const getCircularReplacer = function () {
|
|
5
|
+
const seen = new WeakSet();
|
|
6
|
+
let _level = 0;
|
|
7
|
+
return function (key:string, value:any):any {
|
|
8
|
+
if (typeof value === "object" && value !== null) {
|
|
9
|
+
if (seen.has(value)) {
|
|
10
|
+
_level += 1;
|
|
11
|
+
return (_level <= 3) ? (_LegacyCopy(value)) : (null);
|
|
12
|
+
}
|
|
13
|
+
seen.add(value);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
return JSON.stringify(data, getCircularReplacer());
|
|
19
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DefaultTemplateHandlerParams } from "types";
|
|
2
|
+
import { logger } from "./Logger";
|
|
3
|
+
import { GlobalProcessor as Processor } from "./Processor";
|
|
4
|
+
import { RegisterClass } from "./RegisterClass";
|
|
5
|
+
|
|
6
|
+
export class DefaultTemplateHandler {
|
|
7
|
+
template = "";
|
|
8
|
+
__definition = {};
|
|
9
|
+
static __definition = {};
|
|
10
|
+
component;
|
|
11
|
+
|
|
12
|
+
constructor({ component, template }:DefaultTemplateHandlerParams) {
|
|
13
|
+
this.component = component;
|
|
14
|
+
this.template = template;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
assign(data:any) {
|
|
18
|
+
const templateInstance = this;
|
|
19
|
+
if (typeof templateInstance.component === "undefined") {
|
|
20
|
+
throw new Error("DefaultTemplateHandler.assign: component is undefined");
|
|
21
|
+
}
|
|
22
|
+
if (typeof templateInstance.component.processorHandler === "undefined") {
|
|
23
|
+
throw new Error("DefaultTemplateHandler.assign: component.processorHandler is undefined");
|
|
24
|
+
}
|
|
25
|
+
const processorHandler = templateInstance.component.processorHandler;
|
|
26
|
+
processorHandler.component = templateInstance.component;
|
|
27
|
+
let parsedAssignmentText = (typeof templateInstance.template !== "undefined") ? (templateInstance.template) : ("");
|
|
28
|
+
if (typeof data === "object") {
|
|
29
|
+
[...Object.keys(data)].map( (k):any => {
|
|
30
|
+
let _value = data[k];
|
|
31
|
+
if (typeof _value === "string" || typeof _value === "number" || (!isNaN(_value))) {
|
|
32
|
+
try {
|
|
33
|
+
_value = Processor.processObject.bind(processorHandler).call(processorHandler, _value, templateInstance.component);
|
|
34
|
+
parsedAssignmentText = parsedAssignmentText.replace((new RegExp(`{{${k}}}`, "g")), _value);
|
|
35
|
+
} catch (e:any) {
|
|
36
|
+
logger.warn(`${templateInstance.component.name} could not parse processors.`);
|
|
37
|
+
throw Error(`${templateInstance.component.name} could not parse processors. Reason: ${e.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return k;
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
logger.debug(`${templateInstance.component.name}.data is not an object`);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
parsedAssignmentText = Processor.processObject.call(processorHandler, parsedAssignmentText, templateInstance.component);
|
|
47
|
+
} catch (e:any) {
|
|
48
|
+
logger.warn(`${templateInstance.component.name} could not parse processors.`);
|
|
49
|
+
throw Error(`${templateInstance.component.name} could not parse processors. Reason: ${e.message}`);
|
|
50
|
+
}
|
|
51
|
+
return parsedAssignmentText;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
RegisterClass(DefaultTemplateHandler, "com.qcobjects");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const getDocumentLayout = function ():string|undefined {
|
|
2
|
+
const h = (w:number, h:number) => {
|
|
3
|
+
return w > h ? "landscape" : null;
|
|
4
|
+
};
|
|
5
|
+
const v = (w:number, h:number) => {
|
|
6
|
+
return h > w ? "portrait" : null;
|
|
7
|
+
};
|
|
8
|
+
const square = (w:number, h:number) => {
|
|
9
|
+
return w === h ? "square" : null;
|
|
10
|
+
};
|
|
11
|
+
return [
|
|
12
|
+
h(document.documentElement.clientWidth, document.documentElement.clientHeight),
|
|
13
|
+
v(document.documentElement.clientWidth, document.documentElement.clientHeight),
|
|
14
|
+
square(document.documentElement.clientWidth, document.documentElement.clientHeight)
|
|
15
|
+
].filter(e => e !== null).pop();
|
|
16
|
+
};
|
package/src/Effect.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IEffect, TEffectParams } from "types";
|
|
2
|
+
import { InheritClass } from "./InheritClass";
|
|
3
|
+
import { Package } from "./Package";
|
|
4
|
+
|
|
5
|
+
export class Effect extends InheritClass implements IEffect{
|
|
6
|
+
// eslint-disable-next-line no-unused-vars
|
|
7
|
+
done (...args: any[]): any {
|
|
8
|
+
throw new Error("Method not implemented.");
|
|
9
|
+
};
|
|
10
|
+
// eslint-disable-next-line no-unused-vars
|
|
11
|
+
apply(...args: any[]) {
|
|
12
|
+
throw new Error("Method not implemented.");
|
|
13
|
+
}
|
|
14
|
+
duration = 1000;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
animate({
|
|
18
|
+
timing,
|
|
19
|
+
draw,
|
|
20
|
+
duration
|
|
21
|
+
}: TEffectParams) {
|
|
22
|
+
const _self: this = this;
|
|
23
|
+
|
|
24
|
+
const start = performance.now();
|
|
25
|
+
|
|
26
|
+
requestAnimationFrame(function animate(time) {
|
|
27
|
+
// timeFraction goes from 0 to 1
|
|
28
|
+
let timeFraction = (time - start) / duration;
|
|
29
|
+
if (timeFraction > 1) timeFraction = 1;
|
|
30
|
+
|
|
31
|
+
// calculate the current animation state
|
|
32
|
+
const progress = timing(timeFraction);
|
|
33
|
+
|
|
34
|
+
draw(Math.round(progress * 100)); // draw it
|
|
35
|
+
|
|
36
|
+
if (timeFraction < 1) {
|
|
37
|
+
requestAnimationFrame(animate);
|
|
38
|
+
} else {
|
|
39
|
+
// if this is an object with a done method
|
|
40
|
+
if (typeof _self !== "undefined" &&
|
|
41
|
+
_self !== null &&
|
|
42
|
+
Object.hasOwn(_self, "done") &&
|
|
43
|
+
(typeof _self.done).toLowerCase() === "function") {
|
|
44
|
+
_self.done.call(_self);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
Package("com.qcobjects.effects.base", [
|
|
55
|
+
Effect
|
|
56
|
+
]);
|
package/src/Export.ts
ADDED