qcobjects 2.4.105-ts → 2.4.108-ts
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.hintrc +5 -0
- package/VERSION +1 -1
- package/build/ArrayCollection.js +136 -0
- package/build/BackendMicroservice.js +211 -0
- package/build/Base64.js +100 -0
- package/build/CONFIG.js +85 -0
- package/build/Cast.js +53 -0
- package/build/Class.js +284 -0
- package/build/ClassFactory.js +38 -0
- package/build/ComplexStorageCache.js +91 -0
- package/build/Component.js +1133 -0
- package/build/ComponentFactory.js +113 -0
- package/build/ConfigSettings.js +39 -0
- package/build/Controller.js +81 -0
- package/build/Crypt.js +87 -0
- package/build/DDO.js +81 -0
- package/build/DOMCreateElement.js +15 -0
- package/build/DataStringify.js +22 -0
- package/build/DefaultTemplateHandler.js +57 -0
- package/build/DocumentLayout.js +20 -0
- package/build/Effect.js +46 -0
- package/build/Export.js +11 -0
- package/build/Import.js +140 -0
- package/build/IncrementInstanceID.js +11 -0
- package/build/InheritClass.js +194 -0
- package/build/LegacyCopy.js +31 -0
- package/build/Logger.js +33 -0
- package/build/MainProcess.js +549 -0
- package/build/NamespaceRef.js +29 -0
- package/build/New.js +17 -0
- package/build/ObjectName.js +22 -0
- package/build/Package.js +67 -0
- package/build/PrimaryCollections.js +7 -0
- package/build/Processor.js +81 -0
- package/build/QCObjects.js +182 -4843
- package/build/Ready.js +49 -0
- package/build/RegisterClass.js +28 -0
- package/build/Service.js +112 -0
- package/build/SourceCSS.js +56 -0
- package/build/SourceJS.js +73 -0
- package/build/Tag.js +77 -0
- package/build/Timer.js +30 -0
- package/build/Toggle.js +59 -0
- package/build/TransitionEffect.js +65 -0
- package/build/VO.js +11 -0
- package/build/View.js +18 -0
- package/build/WidgetsFactory.js +537 -0
- package/build/assign.js +32 -0
- package/build/asyncLoad.js +43 -0
- package/build/basePath.js +32 -0
- package/build/captureFalseTouch.js +32 -0
- package/build/componentLoader.js +258 -0
- package/build/defaultProcessors.js +130 -0
- package/build/domain.js +4 -0
- package/build/findPackageNodePath.js +47 -0
- package/build/getType.js +38 -0
- package/build/globalSettings.js +115 -0
- package/build/index.d.ts +1045 -0
- package/build/index.js +24 -4
- package/build/index.mjs +1 -1
- package/build/introspection.js +86 -0
- package/build/isQCObjects.js +20 -0
- package/build/is_a.js +19 -0
- package/build/is_forbidden_name.js +15 -0
- package/build/is_raw_class.js +7 -0
- package/build/loadSDK.js +63 -0
- package/build/localStorage.js +19 -0
- package/build/make_global.js +24 -0
- package/build/mathFunctions.js +7 -0
- package/build/platform.js +28 -0
- package/build/range.js +17 -0
- package/build/routings.js +21 -0
- package/build/secretKey.js +5 -0
- package/build/serviceLoader.js +300 -0
- package/build/shortCode.js +14 -0
- package/build/subelements.js +8 -0
- package/build/super.js +20 -0
- package/build/tag_filter.js +4 -0
- package/build/top.js +23 -0
- package/build/uniqueID.js +5 -0
- package/build/waitUntil.js +31 -0
- package/build-esbuild.js +62 -0
- package/eslint.config.mjs +87 -0
- package/package.json +25 -22
- package/public/browser/index.js +6502 -0
- package/public/browser/index.js.map +7 -0
- package/public/cjs/index.cjs +6586 -0
- package/public/cjs/index.cjs.map +7 -0
- package/public/esm/index.mjs +6494 -0
- package/public/esm/index.mjs.map +7 -0
- package/spec/helpers/mock-sdk.helper.ts +5 -0
- package/spec/mocks/qcobjects-sdk.mock.ts +1 -0
- package/spec/support/jasmine.json +3 -3
- package/spec/testsClassFactorySpec.ts +40 -0
- package/spec/{testsConfigSpec.js → testsConfigSpec.ts} +2 -2
- package/spec/{testsGlobalFeaturesSpec.js → testsGlobalFeaturesSpec.ts} +10 -8
- package/spec/{testsSpec.js → testsSpec.ts} +11 -10
- package/spec/{testsTypeSpec.js → testsTypeSpec.ts} +5 -3
- package/src/ArrayCollection.ts +143 -0
- package/src/BackendMicroservice.ts +229 -0
- package/src/Base64.ts +92 -0
- package/src/CONFIG.ts +96 -0
- package/src/Cast.ts +46 -0
- package/src/Class.ts +303 -0
- package/src/ClassFactory.ts +34 -0
- package/src/ComplexStorageCache.ts +97 -0
- package/src/Component.ts +1222 -0
- package/src/ComponentFactory.ts +122 -0
- package/src/ConfigSettings.ts +62 -0
- package/src/Controller.ts +90 -0
- package/src/Crypt.ts +87 -0
- package/src/DDO.ts +93 -0
- package/src/DOMCreateElement.ts +12 -0
- package/src/DataStringify.ts +19 -0
- package/src/DefaultTemplateHandler.ts +55 -0
- package/src/DocumentLayout.ts +16 -0
- package/src/Effect.ts +56 -0
- package/src/Export.ts +8 -0
- package/src/Import.ts +135 -0
- package/src/IncrementInstanceID.ts +8 -0
- package/src/InheritClass.ts +210 -0
- package/src/LegacyCopy.ts +27 -0
- package/src/Logger.ts +32 -0
- package/src/MainProcess.ts +629 -0
- package/src/NamespaceRef.ts +26 -0
- package/src/New.ts +15 -0
- package/src/ObjectName.ts +16 -0
- package/src/Package.ts +67 -0
- package/src/PrimaryCollections.ts +7 -0
- package/src/Processor.ts +93 -0
- package/src/QCObjects.ts +100 -0
- package/src/Ready.ts +44 -0
- package/src/RegisterClass.ts +26 -0
- package/src/Service.ts +127 -0
- package/src/SourceCSS.ts +59 -0
- package/src/SourceJS.ts +76 -0
- package/src/Tag.ts +76 -0
- package/src/Timer.ts +42 -0
- package/src/Toggle.ts +65 -0
- package/src/TransitionEffect.ts +80 -0
- package/src/VO.ts +8 -0
- package/src/View.ts +17 -0
- package/src/WidgetsFactory.ts +543 -0
- package/src/assign.ts +33 -0
- package/src/asyncLoad.ts +42 -0
- package/src/basePath.ts +29 -0
- package/src/captureFalseTouch.ts +29 -0
- package/src/componentLoader.ts +252 -0
- package/src/defaultProcessors.ts +145 -0
- package/src/domain.ts +1 -0
- package/src/findPackageNodePath.ts +43 -0
- package/src/getType.ts +36 -0
- package/src/globalSettings.ts +118 -0
- package/src/index.mts +1 -1
- package/src/index.ts +1 -1
- package/src/introspection.ts +80 -0
- package/src/isQCObjects.ts +19 -0
- package/src/is_a.ts +16 -0
- package/src/is_forbidden_name.ts +12 -0
- package/src/is_raw_class.ts +3 -0
- package/src/loadSDK.ts +59 -0
- package/src/localStorage.ts +17 -0
- package/src/make_global.ts +19 -0
- package/src/mathFunctions.ts +3 -0
- package/src/platform.ts +30 -0
- package/src/range.ts +15 -0
- package/src/routings.ts +18 -0
- package/src/secretKey.ts +3 -0
- package/src/serviceLoader.ts +306 -0
- package/src/shortCode.ts +11 -0
- package/src/subelements.ts +4 -0
- package/src/super.ts +17 -0
- package/src/tag_filter.ts +1 -0
- package/src/top.ts +111 -0
- package/src/types/global/index.d.ts +597 -0
- package/src/uniqueID.ts +3 -0
- package/src/waitUntil.ts +26 -0
- package/tsconfig.d.json +35 -8
- package/tsconfig.jasmine.json +39 -0
- package/tsconfig.json +46 -12
- package/.eslintignore +0 -5
- package/.eslintrc.cjs +0 -21
- package/.eslintrc.json +0 -24
- package/browser/QCObjects.js +0 -2
- package/browser/QCObjects.js.map +0 -7
- package/browser/chunks/chunk-O2PFFZVJ.js +0 -713
- package/browser/chunks/chunk-O2PFFZVJ.js.map +0 -7
- package/browser/chunks/chunk-TBLBK5VV.js +0 -713
- package/browser/chunks/chunk-TBLBK5VV.js.map +0 -7
- package/browser/chunks/chunk-ZYLXOA35.js +0 -713
- package/browser/chunks/chunk-ZYLXOA35.js.map +0 -7
- package/browser/index.js +0 -2
- package/browser/index.js.map +0 -7
- package/spec/testsClassFactorySpec.js +0 -41
- package/src/QCObjects.js +0 -5247
- package/src/index.d.ts +0 -8
- package/types/index.d.ts +0 -472
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.componentLoader = void 0;
|
|
4
|
+
const asyncLoad_1 = require("./asyncLoad");
|
|
5
|
+
const ComplexStorageCache_1 = require("./ComplexStorageCache");
|
|
6
|
+
const DataStringify_1 = require("./DataStringify");
|
|
7
|
+
const Logger_1 = require("./Logger");
|
|
8
|
+
const platform_1 = require("./platform");
|
|
9
|
+
const top_1 = require("./top");
|
|
10
|
+
/**
|
|
11
|
+
* Loads a simple component from a template
|
|
12
|
+
*
|
|
13
|
+
* @author: Jean Machuca <correojean@gmail.com>
|
|
14
|
+
* @param component a Component object
|
|
15
|
+
*/
|
|
16
|
+
const componentLoader = function (component, _async) {
|
|
17
|
+
let __promise__;
|
|
18
|
+
const _componentLoaderInBrowser = function (component) {
|
|
19
|
+
__promise__ = new Promise(function (resolve, reject) {
|
|
20
|
+
const _promise = component.__promise__;
|
|
21
|
+
const container = (Object.hasOwn(component, "container") && typeof component.container !== "undefined" && component.container !== null) ? (component.container) : (component.body);
|
|
22
|
+
if (container !== null) {
|
|
23
|
+
const _feedComponent_ = function (component) {
|
|
24
|
+
component.feedComponent();
|
|
25
|
+
const standardResponse = {
|
|
26
|
+
"request": xhr,
|
|
27
|
+
component
|
|
28
|
+
};
|
|
29
|
+
resolve.call(_promise, standardResponse);
|
|
30
|
+
};
|
|
31
|
+
Logger_1.logger.debug("LOADING COMPONENT DATA {{DATA}} FROM {{URL}}".replace("{{DATA}}", (0, DataStringify_1._DataStringify)(component.data)).replace("{{URL}}", component.url));
|
|
32
|
+
const _componentLoaded = function () {
|
|
33
|
+
const successStatus = (is_file) ? (0) : (200);
|
|
34
|
+
if (xhr.status === successStatus) {
|
|
35
|
+
const response = xhr.responseText;
|
|
36
|
+
Logger_1.logger.debug("Data received {{DATA}}".replace("{{DATA}}", (0, DataStringify_1._DataStringify)(response)));
|
|
37
|
+
Logger_1.logger.debug("CREATING COMPONENT {{NAME}}".replace("{{NAME}}", component.name));
|
|
38
|
+
component.template = response;
|
|
39
|
+
if (component.cached && (typeof cache !== "undefined")) {
|
|
40
|
+
cache.save(component.name, component.template);
|
|
41
|
+
}
|
|
42
|
+
_feedComponent_(component);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const standardResponse = {
|
|
46
|
+
"request": xhr,
|
|
47
|
+
component
|
|
48
|
+
};
|
|
49
|
+
reject.call(_promise, standardResponse);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
if (typeof component.template === "string" && component.template !== "") {
|
|
53
|
+
// component already has a template it does not need to be reloaded
|
|
54
|
+
_feedComponent_(component);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
var is_file = !!(component.url.startsWith("file:"));
|
|
58
|
+
var xhr = new XMLHttpRequest();
|
|
59
|
+
if (!is_file) {
|
|
60
|
+
try {
|
|
61
|
+
Logger_1.logger.debug("Calling the url of component in async mode.");
|
|
62
|
+
xhr.open(component.method, component.url, true);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
Logger_1.logger.debug(`An error ocurred: ${e}.`);
|
|
66
|
+
Logger_1.logger.debug("Last try has failed... The component cannot be loaded.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if ("fetch" in top_1._top) {
|
|
71
|
+
Logger_1.logger.debug("I can use fetch...");
|
|
72
|
+
Logger_1.logger.debug("It is a file to be loaded, so I will try to use fetch");
|
|
73
|
+
fetch(component.url).then(response => {
|
|
74
|
+
Logger_1.logger.debug("I got a response from fetch, so I'll feed the component");
|
|
75
|
+
response.text().then(text => {
|
|
76
|
+
component.template = text;
|
|
77
|
+
_feedComponent_(component);
|
|
78
|
+
})
|
|
79
|
+
.catch((e) => { throw new Error(`An error ocurred: ${e}`); });
|
|
80
|
+
}).catch((e) => { throw new Error(`An error ocurred: ${e}`); });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!platform_1.is_phonegap && !is_file) {
|
|
84
|
+
xhr.setRequestHeader("Content-Type", "text/html");
|
|
85
|
+
}
|
|
86
|
+
if (!is_file) {
|
|
87
|
+
xhr.onload = _componentLoaded;
|
|
88
|
+
}
|
|
89
|
+
const _directLoad = function (is_file) {
|
|
90
|
+
is_file = !((typeof is_file === "undefined" || !is_file));
|
|
91
|
+
Logger_1.logger.debug("SENDING THE NORMAL REQUEST ");
|
|
92
|
+
if (is_file) {
|
|
93
|
+
if (!("fetch" in top_1._top)) {
|
|
94
|
+
Logger_1.logger.debug("I have to try to load the file using xhr... ");
|
|
95
|
+
xhr.send(null);
|
|
96
|
+
if (xhr.status === XMLHttpRequest.DONE) {
|
|
97
|
+
_componentLoaded();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
Logger_1.logger.debug("Trying to send the data to the component... ");
|
|
103
|
+
xhr.send((0, DataStringify_1._DataStringify)(component.data));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (component.cached && (!is_file)) {
|
|
107
|
+
Logger_1.logger.debug("USING CACHE FOR COMPONENT: " + component.name);
|
|
108
|
+
var cache = new ComplexStorageCache_1.ComplexStorageCache({
|
|
109
|
+
index: component.cacheIndex,
|
|
110
|
+
load() {
|
|
111
|
+
_directLoad.call(this, is_file);
|
|
112
|
+
},
|
|
113
|
+
alternate(cacheController) {
|
|
114
|
+
if (component.method === "GET") {
|
|
115
|
+
component.template = cacheController.cache.getCached(component.cacheIndex);
|
|
116
|
+
_feedComponent_.call(this, component);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
_directLoad.call(this, is_file);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
top_1._top.lastCache = cache;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
Logger_1.logger.debug("NOT USING CACHE FOR COMPONENT: " + component.name);
|
|
127
|
+
_directLoad(is_file);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
Logger_1.logger.debug("CONTAINER DOESNT EXIST");
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
__promise__.then(function (standardResponse) {
|
|
136
|
+
return component.__done__().then(function () {
|
|
137
|
+
let _ret_;
|
|
138
|
+
if (typeof component.done === "function") {
|
|
139
|
+
_ret_ = component.done.call(component, standardResponse);
|
|
140
|
+
}
|
|
141
|
+
return Promise.resolve(_ret_);
|
|
142
|
+
});
|
|
143
|
+
}, function (standardResponse) {
|
|
144
|
+
if (typeof component.fail === "function") {
|
|
145
|
+
component.fail.call(component, standardResponse)
|
|
146
|
+
.catch((e) => { throw new Error(`${e}`); });
|
|
147
|
+
}
|
|
148
|
+
return Promise.reject(new Error("An error ocurred"));
|
|
149
|
+
}).catch(function (e) {
|
|
150
|
+
Logger_1.logger.debug("Something wrong loading the component");
|
|
151
|
+
throw new Error(`An error ocurred: ${e}`);
|
|
152
|
+
});
|
|
153
|
+
return __promise__;
|
|
154
|
+
};
|
|
155
|
+
const _componentLoaderInNode = function (component) {
|
|
156
|
+
__promise__ = new Promise(function (resolve, reject) {
|
|
157
|
+
const _promise = __promise__;
|
|
158
|
+
const _feedComponent_ = function (component) {
|
|
159
|
+
component.feedComponent()
|
|
160
|
+
.catch((e) => {
|
|
161
|
+
throw new Error(`An error ocurred trying to feed the component: ${component.name}. Error: ${e}`);
|
|
162
|
+
});
|
|
163
|
+
const standardResponse = {
|
|
164
|
+
"request": null,
|
|
165
|
+
component
|
|
166
|
+
};
|
|
167
|
+
resolve.call(_promise, standardResponse);
|
|
168
|
+
};
|
|
169
|
+
Logger_1.logger.debug("LOADING COMPONENT DATA {{DATA}} FROM {{URL}}".replace("{{DATA}}", (0, DataStringify_1._DataStringify)(component.data)).replace("{{URL}}", component.url));
|
|
170
|
+
const _componentLoaded = function (err, responseText) {
|
|
171
|
+
if (!err) {
|
|
172
|
+
const response = responseText.toString();
|
|
173
|
+
Logger_1.logger.debug("Data received {{DATA}}".replace("{{DATA}}", (0, DataStringify_1._DataStringify)(response)));
|
|
174
|
+
Logger_1.logger.debug("CREATING COMPONENT {{NAME}}".replace("{{NAME}}", component.name));
|
|
175
|
+
component.template = response;
|
|
176
|
+
if (component.cached && (typeof cache !== "undefined")) {
|
|
177
|
+
cache.save(component.name, component.template);
|
|
178
|
+
}
|
|
179
|
+
_feedComponent_(component);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const standardResponse = {
|
|
183
|
+
"request": null,
|
|
184
|
+
component
|
|
185
|
+
};
|
|
186
|
+
reject.call(_promise, standardResponse);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
if (typeof component.template === "string" && component.template !== "") {
|
|
190
|
+
// component already has a template it does not need to be reloaded
|
|
191
|
+
_feedComponent_(component);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
Logger_1.logger.debug("Loading the component as a local file in server...");
|
|
195
|
+
const _directLoad = function () {
|
|
196
|
+
const fs = (0, platform_1._require_)("fs");
|
|
197
|
+
Logger_1.logger.debug("SENDING THE NORMAL REQUEST ");
|
|
198
|
+
(fs).readFile(component.url, _componentLoaded);
|
|
199
|
+
};
|
|
200
|
+
if (component.cached) {
|
|
201
|
+
Logger_1.logger.debug("USING CACHE FOR COMPONENT: " + component.name);
|
|
202
|
+
var cache = new ComplexStorageCache_1.ComplexStorageCache({
|
|
203
|
+
index: component.cacheIndex,
|
|
204
|
+
load() {
|
|
205
|
+
_directLoad();
|
|
206
|
+
},
|
|
207
|
+
alternate(cacheController) {
|
|
208
|
+
if (component.method === "GET") {
|
|
209
|
+
component.template = cacheController.cache.getCached(component.cacheIndex);
|
|
210
|
+
_feedComponent_.call(this, component);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
_directLoad.call(this);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
top_1._top.lastCache = cache;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
Logger_1.logger.debug("NOT USING CACHE FOR COMPONENT: " + component.name);
|
|
221
|
+
_directLoad();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
__promise__.then(function (standardResponse) {
|
|
226
|
+
return component.__done__().then(function () {
|
|
227
|
+
let _ret_;
|
|
228
|
+
if (typeof component.done === "function") {
|
|
229
|
+
_ret_ = component.done.call(component, standardResponse);
|
|
230
|
+
}
|
|
231
|
+
return Promise.resolve(_ret_);
|
|
232
|
+
});
|
|
233
|
+
}, function (standardResponse) {
|
|
234
|
+
if (typeof component.fail === "function") {
|
|
235
|
+
component.fail.call(component, standardResponse)
|
|
236
|
+
.catch((e) => { throw new Error(`An error ocurred: ${e}`); });
|
|
237
|
+
}
|
|
238
|
+
return Promise.reject(new Error("An error ocurred."));
|
|
239
|
+
}).catch(function (e) {
|
|
240
|
+
Logger_1.logger.debug(`Something wrong loading the component: ${e}`);
|
|
241
|
+
});
|
|
242
|
+
return __promise__;
|
|
243
|
+
};
|
|
244
|
+
let _ret_;
|
|
245
|
+
if (platform_1.isBrowser) {
|
|
246
|
+
if (typeof _async !== "undefined" && _async) {
|
|
247
|
+
_ret_ = (0, asyncLoad_1.asyncLoad)(_componentLoaderInBrowser, [component, _async]);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
_ret_ = _componentLoaderInBrowser(component);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
_ret_ = _componentLoaderInNode(component);
|
|
255
|
+
}
|
|
256
|
+
return _ret_;
|
|
257
|
+
};
|
|
258
|
+
exports.componentLoader = componentLoader;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setDefaultProcessors = void 0;
|
|
4
|
+
const Logger_1 = require("./Logger");
|
|
5
|
+
const Processor_1 = require("./Processor");
|
|
6
|
+
const top_1 = require("./top");
|
|
7
|
+
const range_1 = require("./range");
|
|
8
|
+
// Set Processors
|
|
9
|
+
const setDefaultProcessors = () => {
|
|
10
|
+
(function (_top) {
|
|
11
|
+
const mapper = (componentInstance, componentName, valueName) => {
|
|
12
|
+
/*
|
|
13
|
+
* Mapper processor
|
|
14
|
+
* @usage
|
|
15
|
+
* $mapper(<componentName>,<valueName>)
|
|
16
|
+
*
|
|
17
|
+
* Where componentName is the name of the component (same value as in attribute tag name) without quotes
|
|
18
|
+
* and valueName is the name of the variable that contains the value to map, it can be either a property of
|
|
19
|
+
* the component instance, the data object or a global value
|
|
20
|
+
*/
|
|
21
|
+
if (typeof componentInstance === "undefined" || componentInstance === null) {
|
|
22
|
+
throw Error(`mapper.${componentName}.${valueName} does not have a component instance or it is null.`);
|
|
23
|
+
}
|
|
24
|
+
const globalValue = _top.global.get(valueName);
|
|
25
|
+
const componentValue = componentInstance.get(valueName);
|
|
26
|
+
const dataValue = componentInstance.data[valueName];
|
|
27
|
+
const list = (typeof dataValue !== "undefined") ? (dataValue) : ((typeof componentValue !== "undefined") ? (componentValue) : (globalValue));
|
|
28
|
+
let listItems = "";
|
|
29
|
+
if (typeof list !== "undefined" && typeof list.map !== "undefined") {
|
|
30
|
+
listItems = list.map(function (element) {
|
|
31
|
+
const dataItems = [...Object.keys(element)].map(k => ` data-${k}="${(typeof element[k] !== "undefined" && element[k] !== null) ? (element[k].toString()) : ("")}"`).join("");
|
|
32
|
+
return `<quick-component name="${componentName}" ${dataItems} ></quick-component>`;
|
|
33
|
+
}).join("");
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
Logger_1.logger.debug(`${componentName}.${valueName} does not have a map property`);
|
|
37
|
+
}
|
|
38
|
+
return listItems;
|
|
39
|
+
};
|
|
40
|
+
Processor_1.GlobalProcessor.setProcessor(mapper);
|
|
41
|
+
const layout = function (componentInstance, layoutname, cssfile) {
|
|
42
|
+
/*
|
|
43
|
+
* Layout processor
|
|
44
|
+
* @usage
|
|
45
|
+
* $layout(<layoutname>, <cssfile>)
|
|
46
|
+
* Where layoutname can be "portrait" or "landscape" without quotes
|
|
47
|
+
* cssfile is the uri for the css file to import
|
|
48
|
+
*/
|
|
49
|
+
const layout_portrait = `
|
|
50
|
+
/* CSS Document for Mobile Imports */
|
|
51
|
+
@import url("${cssfile}") (orientation:portrait);
|
|
52
|
+
@import url("${cssfile}") (max-width:460px);
|
|
53
|
+
@import url("${cssfile}") (aspect-ratio: 9/16);
|
|
54
|
+
@import url("${cssfile}") (aspect-ratio: 10/16);
|
|
55
|
+
@import url("${cssfile}") (aspect-ratio: 5/8);
|
|
56
|
+
@import url("${cssfile}") (aspect-ratio: 3/4);
|
|
57
|
+
@import url("${cssfile}") (aspect-ratio: 2/3);
|
|
58
|
+
`;
|
|
59
|
+
const layout_landscape = `
|
|
60
|
+
@import url("${cssfile}") (orientation:landscape) and (min-width:460px);
|
|
61
|
+
@import url("${cssfile}") (aspect-ratio: 16/9) and (min-width:460px);
|
|
62
|
+
@import url("${cssfile}") (aspect-ratio: 16/10) and (min-width:460px);
|
|
63
|
+
@import url("${cssfile}") (aspect-ratio: 8/5) and (min-width:460px);
|
|
64
|
+
@import url("${cssfile}") (aspect-ratio: 4/3) and (min-width:460px);
|
|
65
|
+
@import url("${cssfile}") (aspect-ratio: 3/2) and (min-width:460px);
|
|
66
|
+
`;
|
|
67
|
+
const layout_code = {
|
|
68
|
+
"landscape": layout_landscape,
|
|
69
|
+
"portrait": layout_portrait
|
|
70
|
+
};
|
|
71
|
+
return (Object.hasOwn(layout_code, layoutname)) ? layout_code[layoutname] : ("");
|
|
72
|
+
};
|
|
73
|
+
Processor_1.GlobalProcessor.setProcessor(layout);
|
|
74
|
+
const component = (componentInstance, name, componentClass, ...args) => {
|
|
75
|
+
/*
|
|
76
|
+
* component processor
|
|
77
|
+
* @usage
|
|
78
|
+
* $component(name=<name>, componentClass=<componentClass>, ...)
|
|
79
|
+
* Returns a component tag declaration like:
|
|
80
|
+
* <component name=<name> ...></component>
|
|
81
|
+
*/
|
|
82
|
+
const arg = [...args].map(function (a) {
|
|
83
|
+
return {
|
|
84
|
+
[a.split("=")[0]]: a.split("=")[1]
|
|
85
|
+
};
|
|
86
|
+
}).reduce(function (k1, k2) {
|
|
87
|
+
return Object.assign(k1, k2);
|
|
88
|
+
});
|
|
89
|
+
const attrs = [...Object.keys(arg)].map(function (a) {
|
|
90
|
+
return `${a}=${arg[a]}`;
|
|
91
|
+
}).join(" ");
|
|
92
|
+
return `<component name="${name}" componentClass="${componentClass}" ${attrs}></component>`;
|
|
93
|
+
};
|
|
94
|
+
Processor_1.GlobalProcessor.setProcessor(component);
|
|
95
|
+
const quick_component = (componentInstance, name, componentClass, ...args) => {
|
|
96
|
+
/*
|
|
97
|
+
* component processor
|
|
98
|
+
* @usage
|
|
99
|
+
* $quick_component(name=<name>, componentClass=<componentClass>, ...)
|
|
100
|
+
* Returns a component tag declaration like:
|
|
101
|
+
* <quick-component name=<name> ...></quick-component>
|
|
102
|
+
*/
|
|
103
|
+
const arg = [...args].map(function (a) {
|
|
104
|
+
return {
|
|
105
|
+
[a.split("=")[0]]: a.split("=")[1]
|
|
106
|
+
};
|
|
107
|
+
}).reduce(function (k1, k2) {
|
|
108
|
+
return Object.assign(k1, k2);
|
|
109
|
+
});
|
|
110
|
+
const attrs = [...Object.keys(arg)].map(function (a) {
|
|
111
|
+
return `${a}=${arg[a]}`;
|
|
112
|
+
}).join(" ");
|
|
113
|
+
return `<quick-component name="${name}" componentClass="${componentClass}" ${attrs}></quick-component>`;
|
|
114
|
+
};
|
|
115
|
+
Processor_1.GlobalProcessor.setProcessor(quick_component);
|
|
116
|
+
const repeat = (componentInstance, length, text) => {
|
|
117
|
+
/*
|
|
118
|
+
* Repeat processor
|
|
119
|
+
* @usage
|
|
120
|
+
* $repeat(<length>, <text>)
|
|
121
|
+
* Where length is the number of occurrences of text
|
|
122
|
+
*/
|
|
123
|
+
return (0, range_1.range)(length).map(function (index) {
|
|
124
|
+
return text.replace("{{index}}", index.toString());
|
|
125
|
+
}).join("");
|
|
126
|
+
};
|
|
127
|
+
Processor_1.GlobalProcessor.setProcessor(repeat);
|
|
128
|
+
})(top_1._top);
|
|
129
|
+
};
|
|
130
|
+
exports.setDefaultProcessors = setDefaultProcessors;
|
package/build/domain.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findPackageNodePath = void 0;
|
|
4
|
+
const CONFIG_1 = require("./CONFIG");
|
|
5
|
+
const Export_1 = require("./Export");
|
|
6
|
+
const Logger_1 = require("./Logger");
|
|
7
|
+
const platform_1 = require("./platform");
|
|
8
|
+
const findPackageNodePath = function (packagename) {
|
|
9
|
+
let sdkPath = null;
|
|
10
|
+
if (!platform_1.isBrowser) {
|
|
11
|
+
const fs = (0, platform_1._require_)("fs");
|
|
12
|
+
try {
|
|
13
|
+
let sdkPaths = [
|
|
14
|
+
`${CONFIG_1.CONFIG.get("projectPath")}${CONFIG_1.CONFIG.get("relativeImportPath")}`,
|
|
15
|
+
`${CONFIG_1.CONFIG.get("basePath")}${CONFIG_1.CONFIG.get("relativeImportPath")}`,
|
|
16
|
+
`${CONFIG_1.CONFIG.get("projectPath")}`,
|
|
17
|
+
`${CONFIG_1.CONFIG.get("basePath")}`,
|
|
18
|
+
`${CONFIG_1.CONFIG.get("relativeImportPath")}`,
|
|
19
|
+
`${process.cwd()}${CONFIG_1.CONFIG.get("relativeImportPath")}`,
|
|
20
|
+
`${process.cwd()}/node_modules/` + packagename,
|
|
21
|
+
`${process.cwd()}/node_modules`,
|
|
22
|
+
`${process.cwd()}`,
|
|
23
|
+
"node_modules",
|
|
24
|
+
"./",
|
|
25
|
+
""
|
|
26
|
+
].concat(module.paths);
|
|
27
|
+
sdkPaths = sdkPaths.filter(p => {
|
|
28
|
+
return (fs).existsSync(p + "/" + packagename);
|
|
29
|
+
});
|
|
30
|
+
if (sdkPaths.length > 0) {
|
|
31
|
+
sdkPath = sdkPaths[0];
|
|
32
|
+
Logger_1.logger.info(packagename + " is Installed.");
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
sdkPath = "";
|
|
36
|
+
Logger_1.logger.info(`${packagename} is not in a standard path.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
// do nothing
|
|
41
|
+
console.log(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return sdkPath;
|
|
45
|
+
};
|
|
46
|
+
exports.findPackageNodePath = findPackageNodePath;
|
|
47
|
+
(0, Export_1.Export)(exports.findPackageNodePath);
|
package/build/getType.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__getType__ = void 0;
|
|
4
|
+
const is_raw_class_1 = require("./is_raw_class");
|
|
5
|
+
const ObjectName_1 = require("./ObjectName");
|
|
6
|
+
/**
|
|
7
|
+
* Determine the type of the Object for any QCObjects Object
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} object
|
|
10
|
+
*/
|
|
11
|
+
const __getType__ = function __getType__(o_c) {
|
|
12
|
+
let _ret_ = "";
|
|
13
|
+
switch (true) {
|
|
14
|
+
case (0, is_raw_class_1.__is_raw_class__)(o_c) && !!o_c.name:
|
|
15
|
+
_ret_ = o_c.name;
|
|
16
|
+
break;
|
|
17
|
+
case typeof o_c === "object" &&
|
|
18
|
+
(!!o_c.constructor &&
|
|
19
|
+
!!o_c.constructor.name)
|
|
20
|
+
&& o_c.constructor.name !== "":
|
|
21
|
+
_ret_ = o_c.constructor.name;
|
|
22
|
+
break;
|
|
23
|
+
case (!!o_c && !!o_c.__classType) && o_c.__classType !== "":
|
|
24
|
+
_ret_ = o_c.__classType;
|
|
25
|
+
break;
|
|
26
|
+
case (!!o_c && !!o_c.__definition) && (!!o_c.__definition.__classType) && o_c.__definition.__classType !== "":
|
|
27
|
+
_ret_ = o_c.__definition.__classType;
|
|
28
|
+
break;
|
|
29
|
+
case typeof o_c === "function" && !!o_c.name:
|
|
30
|
+
_ret_ = o_c.name;
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
_ret_ = (0, ObjectName_1.ObjectName)(o_c);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
return _ret_;
|
|
37
|
+
};
|
|
38
|
+
exports.__getType__ = __getType__;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GlobalSettings = void 0;
|
|
4
|
+
const CONFIG_1 = require("./CONFIG");
|
|
5
|
+
const InheritClass_1 = require("./InheritClass");
|
|
6
|
+
const Logger_1 = require("./Logger");
|
|
7
|
+
const Package_1 = require("./Package");
|
|
8
|
+
const platform_1 = require("./platform");
|
|
9
|
+
const serviceLoader_1 = require("./serviceLoader");
|
|
10
|
+
const top_1 = require("./top");
|
|
11
|
+
const Service_1 = require("./Service");
|
|
12
|
+
class GlobalSettings extends InheritClass_1.InheritClass {
|
|
13
|
+
static __start__() {
|
|
14
|
+
return GlobalSettings.instance.__start__();
|
|
15
|
+
}
|
|
16
|
+
_GLOBAL = {};
|
|
17
|
+
static _instance;
|
|
18
|
+
static get instance() {
|
|
19
|
+
if (typeof GlobalSettings._instance === "undefined") {
|
|
20
|
+
GlobalSettings._instance = new GlobalSettings();
|
|
21
|
+
}
|
|
22
|
+
return GlobalSettings._instance;
|
|
23
|
+
}
|
|
24
|
+
set(name, value) {
|
|
25
|
+
this._GLOBAL[name] = value;
|
|
26
|
+
}
|
|
27
|
+
get(name, _default) {
|
|
28
|
+
let _value;
|
|
29
|
+
if (typeof this._GLOBAL[name] !== "undefined") {
|
|
30
|
+
_value = this._GLOBAL[name];
|
|
31
|
+
}
|
|
32
|
+
else if (typeof _default !== "undefined") {
|
|
33
|
+
_value = _default;
|
|
34
|
+
}
|
|
35
|
+
return _value;
|
|
36
|
+
}
|
|
37
|
+
__start__() {
|
|
38
|
+
const __load__serviceWorker = function () {
|
|
39
|
+
let _promise;
|
|
40
|
+
if (platform_1.isBrowser) {
|
|
41
|
+
_promise = new Promise(function (resolve, reject) {
|
|
42
|
+
if (("serviceWorker" in navigator) &&
|
|
43
|
+
(typeof CONFIG_1.CONFIG.get("serviceWorkerURI") !== "undefined")) {
|
|
44
|
+
CONFIG_1.CONFIG.set("serviceWorkerScope", CONFIG_1.CONFIG.get("serviceWorkerScope") ? (CONFIG_1.CONFIG.get("serviceWorkerScope")) : ("/"));
|
|
45
|
+
navigator.serviceWorker.register(CONFIG_1.CONFIG.get("serviceWorkerURI"), {
|
|
46
|
+
scope: CONFIG_1.CONFIG.get("serviceWorkerScope")
|
|
47
|
+
})
|
|
48
|
+
.then(function (registration) {
|
|
49
|
+
Logger_1.logger.debug("Service Worker Registered");
|
|
50
|
+
resolve.call(_promise, registration);
|
|
51
|
+
}, function (registration) {
|
|
52
|
+
Logger_1.logger.debug("Error registering Service Worker");
|
|
53
|
+
reject.call(_promise, registration);
|
|
54
|
+
});
|
|
55
|
+
navigator.serviceWorker.ready.then(function (registration) {
|
|
56
|
+
Logger_1.logger.debug("Service Worker Ready");
|
|
57
|
+
resolve.call(_promise, registration);
|
|
58
|
+
}, function (registration) {
|
|
59
|
+
Logger_1.logger.debug("Error loading Service Worker");
|
|
60
|
+
reject.call(_promise, registration);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
_promise = Promise.resolve();
|
|
67
|
+
}
|
|
68
|
+
return _promise;
|
|
69
|
+
};
|
|
70
|
+
const _buildComponents = function () {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
if (platform_1.isBrowser) {
|
|
73
|
+
Logger_1.logger.debug("Starting to building components");
|
|
74
|
+
try {
|
|
75
|
+
(0, top_1.buildComponentsStack)();
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
throw Error(`Something went wrong trying to start components tree: ${e.message}`);
|
|
79
|
+
}
|
|
80
|
+
Logger_1.logger.debug("Initializing the service worker");
|
|
81
|
+
__load__serviceWorker.call(top_1._top)
|
|
82
|
+
.catch(function (e) {
|
|
83
|
+
Logger_1.logger.debug(`error loading the service worker ${e}`);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
resolve();
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
Logger_1.logger.debug("Starting to load the config settings...");
|
|
91
|
+
if (CONFIG_1.CONFIG.get("useConfigService", false)) {
|
|
92
|
+
Logger_1.logger.debug("Loading settings using local configuration file...");
|
|
93
|
+
(0, top_1.setConfigService)(new Service_1.ConfigService());
|
|
94
|
+
top_1.configService.configLoaded = _buildComponents;
|
|
95
|
+
(0, serviceLoader_1.serviceLoader)(top_1.configService)
|
|
96
|
+
?.then((standardResponse) => {
|
|
97
|
+
resolve(standardResponse);
|
|
98
|
+
})
|
|
99
|
+
?.catch((e) => { throw new Error(`An error ocurred while trying to load ${top_1.configService.url}: ${e}`); });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
Logger_1.logger.debug("Starting to load the components...");
|
|
103
|
+
_buildComponents.call(this)
|
|
104
|
+
.then(() => {
|
|
105
|
+
resolve({});
|
|
106
|
+
})
|
|
107
|
+
.catch((e) => { throw new Error(`An error ocurred while trying to build the components stack. ${e}`); });
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.GlobalSettings = GlobalSettings;
|
|
113
|
+
(0, Package_1.Package)("com.qcobjects", [
|
|
114
|
+
GlobalSettings
|
|
115
|
+
]);
|