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.
- 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,629 @@
|
|
|
1
|
+
import { IQCObjectsElement, IQCObjectsShadowedElement } from "types";
|
|
2
|
+
import { _fireAsyncLoad, asyncLoad } from "./asyncLoad";
|
|
3
|
+
import { captureFalseTouch } from "./captureFalseTouch";
|
|
4
|
+
import { _Cast, _CastProps } from "./Cast";
|
|
5
|
+
import { Class } from "./Class";
|
|
6
|
+
import { ClassFactory } from "./ClassFactory";
|
|
7
|
+
import { Component } from "./Component";
|
|
8
|
+
import { ComponentURI } from "./ComponentFactory";
|
|
9
|
+
import { componentLoader } from "./componentLoader";
|
|
10
|
+
import { CONFIG } from "./CONFIG";
|
|
11
|
+
import { _DataStringify } from "./DataStringify";
|
|
12
|
+
import { setDefaultProcessors } from "./defaultProcessors";
|
|
13
|
+
import { Export } from "./Export";
|
|
14
|
+
import { Import } from "./Import";
|
|
15
|
+
import { _methods_, _protected_code_ } from "./introspection";
|
|
16
|
+
import { isQCObjects_Class, isQCObjects_Object } from "./isQCObjects";
|
|
17
|
+
import { logger } from "./Logger";
|
|
18
|
+
import { __to_number } from "./mathFunctions";
|
|
19
|
+
import { NamespaceRef } from "./NamespaceRef";
|
|
20
|
+
import { New } from "./New";
|
|
21
|
+
import { ObjectName } from "./ObjectName";
|
|
22
|
+
import { Package } from "./Package";
|
|
23
|
+
import { is_phonegap, isBrowser } from "./platform";
|
|
24
|
+
import { _QC_CLASSES, _QC_PACKAGES } from "./PrimaryCollections";
|
|
25
|
+
import { _Ready, ready, Ready } from "./Ready";
|
|
26
|
+
import { serviceLoader } from "./serviceLoader";
|
|
27
|
+
import { Tag } from "./Tag";
|
|
28
|
+
import { _top, resetTop } from "./top";
|
|
29
|
+
import { Processor } from "./Processor";
|
|
30
|
+
import { is_a } from "./is_a";
|
|
31
|
+
import { __getType__ } from "./getType";
|
|
32
|
+
import { shortCode } from "./shortCode";
|
|
33
|
+
import { _DOMCreateElement } from "./DOMCreateElement";
|
|
34
|
+
import { ComplexStorageCache } from "./ComplexStorageCache";
|
|
35
|
+
import { _super_ } from "./super";
|
|
36
|
+
import { waitUntil } from "./waitUntil";
|
|
37
|
+
import { subelements } from "./subelements";
|
|
38
|
+
import { GlobalSettings } from "./globalSettings";
|
|
39
|
+
import loadSDK from "./loadSDK";
|
|
40
|
+
|
|
41
|
+
(function __qcobjects__(_top: any) {
|
|
42
|
+
if (typeof Object.defineProperty !== "undefined" && typeof _top !== "undefined") {
|
|
43
|
+
try {
|
|
44
|
+
Object.defineProperty(_top, "__qcobjects__", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: false,
|
|
47
|
+
writable: false,
|
|
48
|
+
value: __qcobjects__,
|
|
49
|
+
});
|
|
50
|
+
} catch (e:any) {
|
|
51
|
+
logger.debug(`An error ocurred: ${e}`);
|
|
52
|
+
if (typeof _top.__qcobjects__ !== "undefined") {
|
|
53
|
+
_top.__qcobjects__.loaded = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (typeof _top.__qcobjects__.loaded === "undefined") {
|
|
58
|
+
_top.__qcobjects__.loaded = true;
|
|
59
|
+
|
|
60
|
+
const global = _top;
|
|
61
|
+
_top.global = global;
|
|
62
|
+
|
|
63
|
+
if (isBrowser) {
|
|
64
|
+
(Element as unknown as IQCObjectsElement).prototype.subelements = subelements;
|
|
65
|
+
(Document as unknown as IQCObjectsElement).prototype.subelements = subelements;
|
|
66
|
+
(HTMLElement as unknown as IQCObjectsElement).prototype.subelements = subelements;
|
|
67
|
+
if (typeof ShadowRoot !== "undefined") {
|
|
68
|
+
(ShadowRoot as unknown as IQCObjectsShadowedElement).prototype.subelements = subelements;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
logger.debugEnabled = false;
|
|
74
|
+
logger.infoEnabled = true;
|
|
75
|
+
_top.logger = logger;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Basic Type of all elements
|
|
79
|
+
*/
|
|
80
|
+
if (isBrowser) {
|
|
81
|
+
(Element as unknown as IQCObjectsElement).prototype.find = function (tag: string): IQCObjectsElement[] {
|
|
82
|
+
const _self = this;
|
|
83
|
+
const _oo:IQCObjectsElement[] = [];
|
|
84
|
+
const _tags = (document as unknown as IQCObjectsElement).subelements(tag);
|
|
85
|
+
_tags.map( (_tt, _t) => {
|
|
86
|
+
if ((typeof _tags[_t] !== "undefined") && (_tags[_t].parentNode as Element).tagName === _self.parentNode.tagName) {
|
|
87
|
+
_oo.push(_Cast(_tt, (new Object())));
|
|
88
|
+
}
|
|
89
|
+
return _tt;
|
|
90
|
+
});
|
|
91
|
+
return _oo;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (isBrowser) {
|
|
96
|
+
Element.prototype.append = function QC_Append(child) {
|
|
97
|
+
if (isQCObjects_Object(child) || typeof (child as any).body !== "undefined") {
|
|
98
|
+
this.appendChild((child as any).body);
|
|
99
|
+
} else {
|
|
100
|
+
this.appendChild(child as any);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A replacement for direct using of innerHTML
|
|
106
|
+
* use: [element].render('content') where 'content' is the string corresponding
|
|
107
|
+
* to the DOM to insert in the element
|
|
108
|
+
**/
|
|
109
|
+
(Element as unknown as IQCObjectsElement).prototype.render = function QC_Render(content:string) {
|
|
110
|
+
const _self = this;
|
|
111
|
+
const _appendVDOM = (_self:any, content:string):any => {
|
|
112
|
+
if (typeof document.implementation.createHTMLDocument !== "undefined") {
|
|
113
|
+
const doc = document.implementation.createHTMLDocument("");
|
|
114
|
+
doc.body.innerHTML = content;
|
|
115
|
+
(doc.body as unknown as IQCObjectsElement).subelements("*").map( (element):any => {
|
|
116
|
+
return _self.append(element);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
if (typeof this.innerHTML !== "undefined") {
|
|
121
|
+
try {
|
|
122
|
+
this.innerHTML += content;
|
|
123
|
+
} catch (e:any) {
|
|
124
|
+
logger.debug(`An error ocurred: ${e}`);
|
|
125
|
+
_appendVDOM(_self, content);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
_appendVDOM(_self, content);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
Export(waitUntil);
|
|
136
|
+
Export(_super_);
|
|
137
|
+
Export(ComplexStorageCache);
|
|
138
|
+
Export(ClassFactory);
|
|
139
|
+
Export(_DOMCreateElement);
|
|
140
|
+
Export(shortCode);
|
|
141
|
+
Export(__getType__);
|
|
142
|
+
Export(is_a);
|
|
143
|
+
Package("com.qcobjects", [Processor]);
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if (isBrowser) {
|
|
149
|
+
/**
|
|
150
|
+
* Adds a Cast functionality to every Element of DOM
|
|
151
|
+
*/
|
|
152
|
+
(Element as unknown as IQCObjectsElement).prototype.Cast = function QC_Cast<T>(_o: T): T {
|
|
153
|
+
const _self: any = this;
|
|
154
|
+
return _Cast(_self, _o) as T;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if (isBrowser) {
|
|
161
|
+
window.onload = _Ready;
|
|
162
|
+
if (is_phonegap) {
|
|
163
|
+
document.addEventListener("deviceready", _Ready, captureFalseTouch as any);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
global.onload = _Ready;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (isBrowser) {
|
|
170
|
+
window.addEventListener("popstate", function (popStateEvent) {
|
|
171
|
+
popStateEvent.stopImmediatePropagation();
|
|
172
|
+
popStateEvent.stopPropagation();
|
|
173
|
+
Component.route()
|
|
174
|
+
.catch((e:any) => {throw new Error (`An error ocurred when trying to load initial routes. ${e}`);});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
Export(serviceLoader);
|
|
181
|
+
Export(componentLoader);
|
|
182
|
+
Export(ComponentURI);
|
|
183
|
+
Export(ObjectName);
|
|
184
|
+
Export(_DataStringify);
|
|
185
|
+
Export(isQCObjects_Class);
|
|
186
|
+
Export(isQCObjects_Object);
|
|
187
|
+
Export(NamespaceRef);
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Array math functions
|
|
191
|
+
*/
|
|
192
|
+
// eslint-disable-next-line no-unused-vars
|
|
193
|
+
(Array as any).prototype.unique = function <T>(this: T[]): T[]{
|
|
194
|
+
return this.filter(function (value:any, index:any, self:any) {
|
|
195
|
+
return self.indexOf(value) === index;
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
(Array as any).unique = function <T>(a: Array<T>): T[] {
|
|
199
|
+
return (a as any).unique() as T[];
|
|
200
|
+
};
|
|
201
|
+
(_protected_code_)((Array as any).unique);
|
|
202
|
+
(_protected_code_)((Array as any).prototype.unique);
|
|
203
|
+
(Array as any).prototype.table = function ():void {
|
|
204
|
+
console.table(this);
|
|
205
|
+
};
|
|
206
|
+
(Array as any).table = function (a:any):void {
|
|
207
|
+
a.table();
|
|
208
|
+
return;
|
|
209
|
+
};
|
|
210
|
+
(_protected_code_)((Array as any).table);
|
|
211
|
+
(_protected_code_)((Array as any).prototype.table);
|
|
212
|
+
(Array as any).prototype.sum = function ():number {
|
|
213
|
+
return this.reduce(function (prev:any, current:any) {
|
|
214
|
+
return (__to_number(prev)) + (__to_number(current));
|
|
215
|
+
}, 0) as number;
|
|
216
|
+
};
|
|
217
|
+
(Array as any).sum = function (a:any):number {
|
|
218
|
+
return a.sum() as number;
|
|
219
|
+
};
|
|
220
|
+
(_protected_code_)((Array as any).sum);
|
|
221
|
+
(_protected_code_)((Array as any).prototype.sum);
|
|
222
|
+
(Array as any).prototype.avg = function ():number {
|
|
223
|
+
return (this.length < 1) ? (0) : (this.reduce(function (prev:any, current:any) {
|
|
224
|
+
return (((__to_number(prev)) + (__to_number(current))) / 2);
|
|
225
|
+
})) as number;
|
|
226
|
+
};
|
|
227
|
+
(Array as any).avg = function (a:any):number {
|
|
228
|
+
return a.avg() as number;
|
|
229
|
+
};
|
|
230
|
+
(_protected_code_)((Array as any).avg);
|
|
231
|
+
(_protected_code_)((Array as any).prototype.avg);
|
|
232
|
+
(Array as any).prototype.min = function ():number {
|
|
233
|
+
return this.reduce(function (prev:number, current:number) {
|
|
234
|
+
return (__to_number(prev) <= __to_number(current)) ? (prev) : (current);
|
|
235
|
+
}, Infinity) as number;
|
|
236
|
+
};
|
|
237
|
+
(Array as any).min = function (a:any):number {
|
|
238
|
+
return a.min() as number;
|
|
239
|
+
};
|
|
240
|
+
(_protected_code_)((Array as any).min);
|
|
241
|
+
(_protected_code_)((Array as any).prototype.min);
|
|
242
|
+
(Array as any).prototype.max = function ():number {
|
|
243
|
+
return this.reduce(function (prev:number, current:number) {
|
|
244
|
+
return (__to_number(prev) >= __to_number(current)) ? (prev) : (current);
|
|
245
|
+
}, 0) as number;
|
|
246
|
+
};
|
|
247
|
+
(Array as any).max = function (a:any):number {
|
|
248
|
+
return a.max() as number;
|
|
249
|
+
};
|
|
250
|
+
(_protected_code_)((Array as any).max);
|
|
251
|
+
(_protected_code_)((Array as any).prototype.max);
|
|
252
|
+
(Array as any).prototype.sortBy = function (propName:string, sortAsc = true):Array<any>[] {
|
|
253
|
+
const sort_function = (sortAsc) ? (
|
|
254
|
+
function (prev:any, current:any) {
|
|
255
|
+
return current[propName] < prev[propName] ? 1 : -1;
|
|
256
|
+
}
|
|
257
|
+
) : (
|
|
258
|
+
function (prev:any, current:any) {
|
|
259
|
+
return current[propName] > prev[propName] ? 1 : -1;
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
return this.sort(sort_function) as Array<any>[];
|
|
263
|
+
};
|
|
264
|
+
(Array as any).sortBy = function (a:any, propName:string, sortAsc = true):Array<any>[] {
|
|
265
|
+
return a.sortBy(propName, sortAsc) as Array<any>[];
|
|
266
|
+
};
|
|
267
|
+
(_protected_code_)((Array as any).sortBy);
|
|
268
|
+
(_protected_code_)((Array as any).prototype.sortBy);
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Extends the Array prototype to include a method that creates a matrix (2D array)
|
|
272
|
+
* with specified dimensions and fill value.
|
|
273
|
+
*
|
|
274
|
+
* @param {number} _length - The number of rows in the matrix.
|
|
275
|
+
* @param {any} [_fillValue=0] - The value to fill the matrix with (default is 0).
|
|
276
|
+
* @returns {Array<Array<any>>} A 2D array (matrix) filled with the specified value.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // Create a 3x3 matrix filled with zeros
|
|
280
|
+
* const matrix = [].matrix(3);
|
|
281
|
+
* console.log(matrix);
|
|
282
|
+
* // Output: [0, 0, 0]
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* // Create a 2x4 matrix filled with a specific value
|
|
286
|
+
* const matrix = [].matrix(2, 5);
|
|
287
|
+
* console.log(matrix);
|
|
288
|
+
* // Output: [5, 5]
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* // Create a 4x2 matrix filled with null values
|
|
292
|
+
* const matrix = [].matrix(4, null);
|
|
293
|
+
* console.log(matrix);
|
|
294
|
+
* // Output: [null, null, null, null]
|
|
295
|
+
*/
|
|
296
|
+
(Array as any).prototype.matrix = function (_length:number, _fillValue = 0) {
|
|
297
|
+
// eslint-disable-next-line no-unused-vars
|
|
298
|
+
const x_func = function (x = undefined) {
|
|
299
|
+
return _fillValue;
|
|
300
|
+
};
|
|
301
|
+
return Array.from({
|
|
302
|
+
length: _length
|
|
303
|
+
}, x_func);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Creates a matrix (2D array) from a given array.
|
|
308
|
+
*
|
|
309
|
+
* This function extends the Array constructor by adding a static method
|
|
310
|
+
* that generates a matrix with specified dimensions and fill value.
|
|
311
|
+
*
|
|
312
|
+
* @function
|
|
313
|
+
* @param {Array} a - The input array used to generate the matrix.
|
|
314
|
+
* @param {number} _length - The length of the matrix (number of rows).
|
|
315
|
+
* @param {number} [_fillValue=0] - The value to fill the matrix with (default is 0).
|
|
316
|
+
* @returns {Array} A 2D array (matrix) created from the input parameters.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* const myMatrix = Array.matrix(2, 5);
|
|
320
|
+
* // myMatrix will be [5, 5, 5]
|
|
321
|
+
*/
|
|
322
|
+
(Array as any).matrix = function <T>(a:any, _length:number, _fillValue = 0):T[] {
|
|
323
|
+
return a.matrix(_length, _fillValue) as T[];
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
(_protected_code_)((Array as any).matrix);
|
|
327
|
+
(_protected_code_)((Array as any).prototype.matrix);
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
(Array as any).prototype.matrix2d = function (_length:number, _fillValue = 0) {
|
|
331
|
+
// eslint-disable-next-line no-unused-vars
|
|
332
|
+
const y_func = function (y:any) {
|
|
333
|
+
return _fillValue;
|
|
334
|
+
};
|
|
335
|
+
// eslint-disable-next-line no-unused-vars
|
|
336
|
+
const x_func = function (x:any) {
|
|
337
|
+
return Array.from({
|
|
338
|
+
length: _length
|
|
339
|
+
}, y_func);
|
|
340
|
+
};
|
|
341
|
+
return Array.from({
|
|
342
|
+
length: _length
|
|
343
|
+
}, x_func);
|
|
344
|
+
};
|
|
345
|
+
(Array as any).matrix2d = function <T>(a:any, _length:number, _fillValue = 0):T[][] {
|
|
346
|
+
return a.matrix2d(_length, _fillValue) as T[][];
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
(_protected_code_)((Array as any).matrix2d);
|
|
350
|
+
(_protected_code_)((Array as any).prototype.matrix2d);
|
|
351
|
+
|
|
352
|
+
(Array as any).prototype.matrix3d = function (_length:number, _fillValue = 0) {
|
|
353
|
+
// eslint-disable-next-line no-unused-vars
|
|
354
|
+
const y_func = function (y:any) {
|
|
355
|
+
return Array.from({
|
|
356
|
+
length: _length
|
|
357
|
+
}, function () {
|
|
358
|
+
return _fillValue;
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
// eslint-disable-next-line no-unused-vars
|
|
362
|
+
const x_func = function (x:any) {
|
|
363
|
+
return Array.from({
|
|
364
|
+
length: _length
|
|
365
|
+
}, y_func);
|
|
366
|
+
};
|
|
367
|
+
return Array.from({
|
|
368
|
+
length: _length
|
|
369
|
+
}, x_func);
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
(Array as any).matrix3d = function <T>(a:any, _length:number, _fillValue = 0):T[][][] {
|
|
373
|
+
return a.matrix3d(_length, _fillValue) as T[][][];
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
(_protected_code_)((Array as any).matrix3d);
|
|
378
|
+
(_protected_code_)((Array as any).prototype.matrix3d);
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
(String as unknown as any).prototype.list = function ():string[] {
|
|
383
|
+
const __instance = this;
|
|
384
|
+
return _top.range(0, __instance.length - 1).map(function <T>(i:any):T {
|
|
385
|
+
return __instance[i] as T;
|
|
386
|
+
}) as string[];
|
|
387
|
+
};
|
|
388
|
+
(_protected_code_)((String as unknown as any).prototype.list);
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* End of array math functions
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
setDefaultProcessors();
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Load every component tag declared in the body
|
|
403
|
+
**/
|
|
404
|
+
Ready(function () {
|
|
405
|
+
if (!CONFIG.get("useSDK")) {
|
|
406
|
+
GlobalSettings.__start__()
|
|
407
|
+
.catch ((e:any) => {
|
|
408
|
+
throw Error (e);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
/*
|
|
414
|
+
Public variables and functions
|
|
415
|
+
*/
|
|
416
|
+
Export(Export); /* exports the same Export function once */
|
|
417
|
+
Export(Import);
|
|
418
|
+
Export(Package);
|
|
419
|
+
Export(Class);
|
|
420
|
+
Export(New);
|
|
421
|
+
Export(Tag);
|
|
422
|
+
Export(Ready);
|
|
423
|
+
Export(ready);
|
|
424
|
+
Export(isBrowser);
|
|
425
|
+
Export(_methods_);
|
|
426
|
+
Export(GlobalSettings);
|
|
427
|
+
|
|
428
|
+
resetTop(_CastProps(New(GlobalSettings), _top));
|
|
429
|
+
|
|
430
|
+
(function (_top) {
|
|
431
|
+
|
|
432
|
+
Object.defineProperty(_top, "PackagesNameList", {
|
|
433
|
+
// eslint-disable-next-line no-unused-vars
|
|
434
|
+
set(val) {
|
|
435
|
+
logger.debug("PackagesNameList is readonly");
|
|
436
|
+
|
|
437
|
+
},
|
|
438
|
+
get() {
|
|
439
|
+
const _get_packages_names = function <T>(_packages:any):T[] {
|
|
440
|
+
let _keys:any[] = [];
|
|
441
|
+
for (const _k of Object.keys(_packages)) {
|
|
442
|
+
if (
|
|
443
|
+
typeof _packages[_k] !== "undefined" &&
|
|
444
|
+
typeof _packages[_k] !== "function" &&
|
|
445
|
+
Object.hasOwn(_packages[_k], "length") &&
|
|
446
|
+
_packages[_k].length > 0
|
|
447
|
+
) {
|
|
448
|
+
_keys.push(_k);
|
|
449
|
+
_keys = _keys.concat(_get_packages_names(_packages[_k]));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return _keys as T[];
|
|
453
|
+
};
|
|
454
|
+
return _get_packages_names(_QC_PACKAGES);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
Object.defineProperty(_top, "PackagesList", {
|
|
459
|
+
// eslint-disable-next-line no-unused-vars
|
|
460
|
+
set(value) {
|
|
461
|
+
logger.debug("PackagesList is readonly");
|
|
462
|
+
|
|
463
|
+
},
|
|
464
|
+
get():any {
|
|
465
|
+
return _top.PackagesNameList.map(function <T>(packagename:string):T {
|
|
466
|
+
const _classesList:any[] = Package(packagename) as any[];
|
|
467
|
+
let _ret_:any = undefined;
|
|
468
|
+
if (_classesList) {
|
|
469
|
+
_ret_= {
|
|
470
|
+
packageName: packagename,
|
|
471
|
+
classesList: _classesList.filter(function (_packageClass:any):boolean {
|
|
472
|
+
return isQCObjects_Class(_packageClass);
|
|
473
|
+
})
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
return _ret_ as T;
|
|
477
|
+
}).filter(function (_p:any):boolean {
|
|
478
|
+
return typeof _p !== "undefined";
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
Object.defineProperty(_top, "ClassesList", {
|
|
484
|
+
// eslint-disable-next-line no-unused-vars
|
|
485
|
+
set(value) {
|
|
486
|
+
logger.debug("ClassesList is readonly");
|
|
487
|
+
|
|
488
|
+
},
|
|
489
|
+
get():any {
|
|
490
|
+
let _classesList:any[] = [];
|
|
491
|
+
_top.PackagesList.map(function <T>(_package_element:any):T {
|
|
492
|
+
_classesList = _classesList.concat(_package_element.classesList.map(
|
|
493
|
+
function (_class_element:any) {
|
|
494
|
+
return {
|
|
495
|
+
packageName: _package_element.packageName,
|
|
496
|
+
className: _package_element.packageName + "." + _class_element.__definition.__classType,
|
|
497
|
+
classFactory: _class_element
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
));
|
|
501
|
+
return _package_element as T;
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
return _classesList;
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
Object.defineProperty(_top, "ClassesNameList", {
|
|
509
|
+
// eslint-disable-next-line no-unused-vars
|
|
510
|
+
set(value) {
|
|
511
|
+
logger.debug("ClassesNameList is readonly");
|
|
512
|
+
|
|
513
|
+
},
|
|
514
|
+
get():any {
|
|
515
|
+
return _top.ClassesList.map(function <T>(_class_element:any):T {
|
|
516
|
+
return _class_element.className as T;
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
if (isBrowser) {
|
|
522
|
+
// use of GLOBAL word is deprecated in node.js
|
|
523
|
+
// this is only for compatibility purpose with old versions of QCObjects in browsers
|
|
524
|
+
Class("GLOBAL", (_QC_CLASSES as any).global); // case insensitive for compatibility con old versions;
|
|
525
|
+
Export(ClassFactory("GLOBAL"));
|
|
526
|
+
}
|
|
527
|
+
Export(global);
|
|
528
|
+
|
|
529
|
+
loadSDK();
|
|
530
|
+
})(_top);
|
|
531
|
+
|
|
532
|
+
if (isBrowser) {
|
|
533
|
+
asyncLoad(function ():any {
|
|
534
|
+
Ready(function () {
|
|
535
|
+
|
|
536
|
+
/*
|
|
537
|
+
* scroll management custom events
|
|
538
|
+
* usage: document.addEventListener('percentY90',function(e){console.log(e.detail.percentY)});
|
|
539
|
+
* possible events: scrollpercent, defaultscroll, percentY0, percentY25, percentY50, percentY75, percentY90
|
|
540
|
+
*/
|
|
541
|
+
|
|
542
|
+
(function (_top) {
|
|
543
|
+
let ticking = false;
|
|
544
|
+
const scrollHeight = Math.max(
|
|
545
|
+
document.body.scrollHeight, document.documentElement.scrollHeight,
|
|
546
|
+
document.body.offsetHeight, document.documentElement.offsetHeight,
|
|
547
|
+
document.body.clientHeight, document.documentElement.clientHeight
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
const scrollWidth = Math.max(
|
|
551
|
+
document.body.scrollWidth, document.documentElement.scrollWidth,
|
|
552
|
+
document.body.offsetWidth, document.documentElement.offsetWidth,
|
|
553
|
+
document.body.clientWidth, document.documentElement.clientWidth
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
function scrollDispatcher(event:any) {
|
|
557
|
+
const percentY = Math.round(_top.scrollY * 100 / scrollHeight);
|
|
558
|
+
const percentX = Math.round(_top.scrollX * 100 / scrollWidth);
|
|
559
|
+
const scrollPercentEventEvent = new CustomEvent("scrollpercent", {
|
|
560
|
+
detail: {
|
|
561
|
+
percentX,
|
|
562
|
+
percentY
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
event.target.dispatchEvent(scrollPercentEventEvent);
|
|
566
|
+
let secondaryEventName = "defaultscroll";
|
|
567
|
+
const __valid_scrolls__ = [0, 5, 10, 25, 50, 75, 90, 95, 100];
|
|
568
|
+
__valid_scrolls__.filter(function (p) {
|
|
569
|
+
return p === percentY;
|
|
570
|
+
}).map(function <T>(pY:T):T {
|
|
571
|
+
secondaryEventName = "percentY" + percentY.toString();
|
|
572
|
+
const secondaryCustomEvent = new CustomEvent(secondaryEventName, {
|
|
573
|
+
detail: {
|
|
574
|
+
percentX,
|
|
575
|
+
percentY
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
event.target.dispatchEvent(secondaryCustomEvent);
|
|
579
|
+
return pY;
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
document.addEventListener("scroll", function (event) {
|
|
585
|
+
|
|
586
|
+
if (!ticking) {
|
|
587
|
+
requestAnimationFrame(function () {
|
|
588
|
+
scrollDispatcher(event);
|
|
589
|
+
ticking = false;
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
ticking = true;
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
})(_top);
|
|
597
|
+
|
|
598
|
+
});
|
|
599
|
+
}, []);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (!isBrowser) {
|
|
603
|
+
if (typeof _top.global !== "undefined" && Object.hasOwn(_top.global, "_fireAsyncLoad")) {
|
|
604
|
+
_fireAsyncLoad.call(_top);
|
|
605
|
+
}
|
|
606
|
+
if (typeof _top.global !== "undefined" && Object.hasOwn(_top.global, "onload")) {
|
|
607
|
+
_top.global.onload.call(_top);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
/* Freezing Object && Object.prototype to prevent prototype pollution risks */
|
|
613
|
+
(function (isBrowser) {
|
|
614
|
+
const __freeze__ = function () {
|
|
615
|
+
Object.freeze(Object.prototype);
|
|
616
|
+
Object.freeze(Object);
|
|
617
|
+
};
|
|
618
|
+
if (isBrowser && CONFIG.get("secureObjects", false)) {
|
|
619
|
+
Ready(function () {
|
|
620
|
+
__freeze__();
|
|
621
|
+
});
|
|
622
|
+
} else if (CONFIG.get("secureObjects", false)) {
|
|
623
|
+
__freeze__();
|
|
624
|
+
}
|
|
625
|
+
})(isBrowser);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
})(_top);
|
|
629
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isQCObjects_Class } from "./isQCObjects";
|
|
2
|
+
import { Package } from "./Package";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Declare Namespace
|
|
6
|
+
*
|
|
7
|
+
* @param {String} packageName
|
|
8
|
+
* @param {Object} package
|
|
9
|
+
*/
|
|
10
|
+
export const NamespaceRef = function (namespace:string):any {
|
|
11
|
+
const packageInstance = Package(namespace) || [];
|
|
12
|
+
const classes = packageInstance.filter((c:any) => isQCObjects_Class(c)).map((c:any) => {
|
|
13
|
+
return {
|
|
14
|
+
[c.__definition.__classType]: c
|
|
15
|
+
};
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
17
|
+
}).reduce((a:any, b:any):any => {return Object.assign(a, b);});
|
|
18
|
+
return namespace.split(".").map(c => {
|
|
19
|
+
return {
|
|
20
|
+
[c]: classes
|
|
21
|
+
};
|
|
22
|
+
}).reverse().reduce((a, b) => {
|
|
23
|
+
b[Object.keys(b).join(".")] = a;
|
|
24
|
+
return b;
|
|
25
|
+
});
|
|
26
|
+
};
|
package/src/New.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an object from a Class definition
|
|
3
|
+
*
|
|
4
|
+
* @param {QC_Object} o
|
|
5
|
+
* @param {Object} args
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const New = function (__class__:any, args = {}):any {
|
|
9
|
+
args = (arguments.length > 1) ? (args) : ({});
|
|
10
|
+
return (typeof __class__ === "undefined") ? (new Object()) : (new __class__(args));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
New.prototype.toString = function () {
|
|
14
|
+
return "New(QCObjectsClassName, args) { [QCObjects native code] }";
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the object or function name
|
|
3
|
+
*
|
|
4
|
+
* @param Object or function
|
|
5
|
+
*/
|
|
6
|
+
export const ObjectName = function (o:any) {
|
|
7
|
+
let ret = "";
|
|
8
|
+
if (typeof o === "function" && Object.hasOwn(o, "name") && o.name !== "") {
|
|
9
|
+
ret = o.name;
|
|
10
|
+
} else if (typeof o !== "undefined" && typeof o.constructor === "function" && o.constructor.name !== "") {
|
|
11
|
+
ret = o.constructor.name;
|
|
12
|
+
} else if (typeof o !== "undefined" && typeof o.constructor === "object") {
|
|
13
|
+
ret = o.constructor.toString().replace(/\[(.*?)\]/g, "$1").split(" ").slice(1).join("");
|
|
14
|
+
}
|
|
15
|
+
return ret;
|
|
16
|
+
};
|