qcobjects 2.4.107-ts → 2.4.108-ts

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.hintrc +5 -0
  2. package/VERSION +1 -1
  3. package/build/ArrayCollection.js +136 -0
  4. package/build/BackendMicroservice.js +211 -0
  5. package/build/Base64.js +100 -0
  6. package/build/CONFIG.js +85 -0
  7. package/build/Cast.js +53 -0
  8. package/build/Class.js +284 -0
  9. package/build/ClassFactory.js +38 -0
  10. package/build/ComplexStorageCache.js +91 -0
  11. package/build/Component.js +1133 -0
  12. package/build/ComponentFactory.js +113 -0
  13. package/build/ConfigSettings.js +39 -0
  14. package/build/Controller.js +81 -0
  15. package/build/Crypt.js +87 -0
  16. package/build/DDO.js +81 -0
  17. package/build/DOMCreateElement.js +15 -0
  18. package/build/DataStringify.js +22 -0
  19. package/build/DefaultTemplateHandler.js +57 -0
  20. package/build/DocumentLayout.js +20 -0
  21. package/build/Effect.js +46 -0
  22. package/build/Export.js +11 -0
  23. package/build/Import.js +140 -0
  24. package/build/IncrementInstanceID.js +11 -0
  25. package/build/InheritClass.js +194 -0
  26. package/build/LegacyCopy.js +31 -0
  27. package/build/Logger.js +33 -0
  28. package/build/MainProcess.js +549 -0
  29. package/build/NamespaceRef.js +29 -0
  30. package/build/New.js +17 -0
  31. package/build/ObjectName.js +22 -0
  32. package/build/Package.js +67 -0
  33. package/build/PrimaryCollections.js +7 -0
  34. package/build/Processor.js +81 -0
  35. package/build/QCObjects.js +182 -4843
  36. package/build/Ready.js +49 -0
  37. package/build/RegisterClass.js +28 -0
  38. package/build/Service.js +112 -0
  39. package/build/SourceCSS.js +56 -0
  40. package/build/SourceJS.js +73 -0
  41. package/build/Tag.js +77 -0
  42. package/build/Timer.js +30 -0
  43. package/build/Toggle.js +59 -0
  44. package/build/TransitionEffect.js +65 -0
  45. package/build/VO.js +11 -0
  46. package/build/View.js +18 -0
  47. package/build/WidgetsFactory.js +537 -0
  48. package/build/assign.js +32 -0
  49. package/build/asyncLoad.js +43 -0
  50. package/build/basePath.js +32 -0
  51. package/build/captureFalseTouch.js +32 -0
  52. package/build/componentLoader.js +258 -0
  53. package/build/defaultProcessors.js +130 -0
  54. package/build/domain.js +4 -0
  55. package/build/findPackageNodePath.js +47 -0
  56. package/build/getType.js +38 -0
  57. package/build/globalSettings.js +115 -0
  58. package/build/index.d.ts +1045 -0
  59. package/build/index.js +24 -4
  60. package/build/index.mjs +1 -1
  61. package/build/introspection.js +86 -0
  62. package/build/isQCObjects.js +20 -0
  63. package/build/is_a.js +19 -0
  64. package/build/is_forbidden_name.js +15 -0
  65. package/build/is_raw_class.js +7 -0
  66. package/build/loadSDK.js +63 -0
  67. package/build/localStorage.js +19 -0
  68. package/build/make_global.js +24 -0
  69. package/build/mathFunctions.js +7 -0
  70. package/build/platform.js +28 -0
  71. package/build/range.js +17 -0
  72. package/build/routings.js +21 -0
  73. package/build/secretKey.js +5 -0
  74. package/build/serviceLoader.js +300 -0
  75. package/build/shortCode.js +14 -0
  76. package/build/subelements.js +8 -0
  77. package/build/super.js +20 -0
  78. package/build/tag_filter.js +4 -0
  79. package/build/top.js +23 -0
  80. package/build/uniqueID.js +5 -0
  81. package/build/waitUntil.js +31 -0
  82. package/build-esbuild.js +62 -0
  83. package/eslint.config.mjs +87 -0
  84. package/package.json +26 -23
  85. package/public/browser/index.js +6502 -0
  86. package/public/browser/index.js.map +7 -0
  87. package/public/cjs/index.cjs +6586 -0
  88. package/public/cjs/index.cjs.map +7 -0
  89. package/public/esm/index.mjs +6494 -0
  90. package/public/esm/index.mjs.map +7 -0
  91. package/spec/helpers/mock-sdk.helper.ts +5 -0
  92. package/spec/mocks/qcobjects-sdk.mock.ts +1 -0
  93. package/spec/support/jasmine.json +3 -3
  94. package/spec/testsClassFactorySpec.ts +40 -0
  95. package/spec/{testsConfigSpec.js → testsConfigSpec.ts} +2 -2
  96. package/spec/{testsGlobalFeaturesSpec.js → testsGlobalFeaturesSpec.ts} +10 -8
  97. package/spec/{testsSpec.js → testsSpec.ts} +11 -10
  98. package/spec/{testsTypeSpec.js → testsTypeSpec.ts} +5 -3
  99. package/src/ArrayCollection.ts +143 -0
  100. package/src/BackendMicroservice.ts +229 -0
  101. package/src/Base64.ts +92 -0
  102. package/src/CONFIG.ts +96 -0
  103. package/src/Cast.ts +46 -0
  104. package/src/Class.ts +303 -0
  105. package/src/ClassFactory.ts +34 -0
  106. package/src/ComplexStorageCache.ts +97 -0
  107. package/src/Component.ts +1222 -0
  108. package/src/ComponentFactory.ts +122 -0
  109. package/src/ConfigSettings.ts +62 -0
  110. package/src/Controller.ts +90 -0
  111. package/src/Crypt.ts +87 -0
  112. package/src/DDO.ts +93 -0
  113. package/src/DOMCreateElement.ts +12 -0
  114. package/src/DataStringify.ts +19 -0
  115. package/src/DefaultTemplateHandler.ts +55 -0
  116. package/src/DocumentLayout.ts +16 -0
  117. package/src/Effect.ts +56 -0
  118. package/src/Export.ts +8 -0
  119. package/src/Import.ts +135 -0
  120. package/src/IncrementInstanceID.ts +8 -0
  121. package/src/InheritClass.ts +210 -0
  122. package/src/LegacyCopy.ts +27 -0
  123. package/src/Logger.ts +32 -0
  124. package/src/MainProcess.ts +629 -0
  125. package/src/NamespaceRef.ts +26 -0
  126. package/src/New.ts +15 -0
  127. package/src/ObjectName.ts +16 -0
  128. package/src/Package.ts +67 -0
  129. package/src/PrimaryCollections.ts +7 -0
  130. package/src/Processor.ts +93 -0
  131. package/src/QCObjects.ts +100 -0
  132. package/src/Ready.ts +44 -0
  133. package/src/RegisterClass.ts +26 -0
  134. package/src/Service.ts +127 -0
  135. package/src/SourceCSS.ts +59 -0
  136. package/src/SourceJS.ts +76 -0
  137. package/src/Tag.ts +76 -0
  138. package/src/Timer.ts +42 -0
  139. package/src/Toggle.ts +65 -0
  140. package/src/TransitionEffect.ts +80 -0
  141. package/src/VO.ts +8 -0
  142. package/src/View.ts +17 -0
  143. package/src/WidgetsFactory.ts +543 -0
  144. package/src/assign.ts +33 -0
  145. package/src/asyncLoad.ts +42 -0
  146. package/src/basePath.ts +29 -0
  147. package/src/captureFalseTouch.ts +29 -0
  148. package/src/componentLoader.ts +252 -0
  149. package/src/defaultProcessors.ts +145 -0
  150. package/src/domain.ts +1 -0
  151. package/src/findPackageNodePath.ts +43 -0
  152. package/src/getType.ts +36 -0
  153. package/src/globalSettings.ts +118 -0
  154. package/src/index.mts +1 -1
  155. package/src/index.ts +1 -1
  156. package/src/introspection.ts +80 -0
  157. package/src/isQCObjects.ts +19 -0
  158. package/src/is_a.ts +16 -0
  159. package/src/is_forbidden_name.ts +12 -0
  160. package/src/is_raw_class.ts +3 -0
  161. package/src/loadSDK.ts +59 -0
  162. package/src/localStorage.ts +17 -0
  163. package/src/make_global.ts +19 -0
  164. package/src/mathFunctions.ts +3 -0
  165. package/src/platform.ts +30 -0
  166. package/src/range.ts +15 -0
  167. package/src/routings.ts +18 -0
  168. package/src/secretKey.ts +3 -0
  169. package/src/serviceLoader.ts +306 -0
  170. package/src/shortCode.ts +11 -0
  171. package/src/subelements.ts +4 -0
  172. package/src/super.ts +17 -0
  173. package/src/tag_filter.ts +1 -0
  174. package/src/top.ts +111 -0
  175. package/src/types/global/index.d.ts +597 -0
  176. package/src/uniqueID.ts +3 -0
  177. package/src/waitUntil.ts +26 -0
  178. package/tsconfig.d.json +35 -8
  179. package/tsconfig.jasmine.json +39 -0
  180. package/tsconfig.json +46 -12
  181. package/.eslintignore +0 -5
  182. package/.eslintrc.cjs +0 -21
  183. package/.eslintrc.json +0 -24
  184. package/browser/QCObjects.js +0 -2
  185. package/browser/QCObjects.js.map +0 -7
  186. package/browser/chunks/chunk-O2PFFZVJ.js +0 -713
  187. package/browser/chunks/chunk-O2PFFZVJ.js.map +0 -7
  188. package/browser/chunks/chunk-TBLBK5VV.js +0 -713
  189. package/browser/chunks/chunk-TBLBK5VV.js.map +0 -7
  190. package/browser/chunks/chunk-ZYLXOA35.js +0 -713
  191. package/browser/chunks/chunk-ZYLXOA35.js.map +0 -7
  192. package/browser/index.js +0 -2
  193. package/browser/index.js.map +0 -7
  194. package/spec/testsClassFactorySpec.js +0 -41
  195. package/src/QCObjects.js +0 -5247
  196. package/src/index.d.ts +0 -8
  197. package/types/index.d.ts +0 -472
package/build/Class.js ADDED
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Class = void 0;
4
+ const PrimaryCollections_1 = require("./PrimaryCollections");
5
+ const Cast_1 = require("./Cast");
6
+ const DOMCreateElement_1 = require("./DOMCreateElement");
7
+ const getType_1 = require("./getType");
8
+ const IncrementInstanceID_1 = require("./IncrementInstanceID");
9
+ const introspection_1 = require("./introspection");
10
+ const is_a_1 = require("./is_a");
11
+ const is_forbidden_name_1 = require("./is_forbidden_name");
12
+ const LegacyCopy_1 = require("./LegacyCopy");
13
+ const Logger_1 = require("./Logger");
14
+ const platform_1 = require("./platform");
15
+ const top_1 = require("./top");
16
+ /**
17
+ * Creates new object class of another object
18
+ *
19
+ * @param {String} name
20
+ * @param {Object} type
21
+ * @param {Object} definition
22
+ *
23
+ * @example
24
+ * Class (name, type, definition)
25
+ * Class (name, type)
26
+ * Class (name, definition)
27
+ * Class ()
28
+ *
29
+ *
30
+ * const MyClass = Class ("MyComponent", Component, {
31
+ * name: "one_component",
32
+ * method1 : () => {console.log ("done") }
33
+ * })
34
+ * const myClassInstance = new MyClass ({name: "one_component"})
35
+ *
36
+ * const MyClass = Class ("MyService",{
37
+ * name: "myservice",
38
+ * })
39
+ *
40
+ * const myClassInstance = new MyClass ({name: "myservice"})
41
+ */
42
+ const Class = (name, _type, _definition) => {
43
+ const _types_ = {};
44
+ let type, definition;
45
+ switch (true) {
46
+ case !name && !_type && !_definition:
47
+ return class {
48
+ };
49
+ case !!name && !_type && !_definition:
50
+ type = class {
51
+ };
52
+ definition = {};
53
+ break;
54
+ case !!name && !_type && !!_definition:
55
+ type = class {
56
+ };
57
+ definition = _definition;
58
+ break;
59
+ case !!name && !!_type && !!_definition:
60
+ type = _type;
61
+ definition = _definition;
62
+ break;
63
+ default:
64
+ return class {
65
+ };
66
+ }
67
+ if (typeof name !== "string") {
68
+ throw new Error("Class name must be a string");
69
+ }
70
+ if (typeof type !== "function") {
71
+ throw new Error("Class type must be a function or class");
72
+ }
73
+ if ((0, is_forbidden_name_1.__is__forbidden_name__)(name)) {
74
+ throw new Error(`${name} is not an allowed word in the name of a class`);
75
+ }
76
+ if (typeof type.__definition === "object"
77
+ && type.__definition
78
+ && Object.keys(type.__definition).length !== 0) {
79
+ definition.__definition = Object.assign((0, LegacyCopy_1._LegacyCopy)(type.__definition, ["name"]), type);
80
+ }
81
+ _types_[type.name] = type;
82
+ if (typeof definition === "undefined" || definition === null) {
83
+ definition = {};
84
+ }
85
+ else {
86
+ definition = { ...definition };
87
+ }
88
+ /* hack to prevent duplicate __instanceID */
89
+ if (typeof definition.__instanceID !== "undefined") {
90
+ delete definition.__instanceID;
91
+ }
92
+ PrimaryCollections_1._QC_CLASSES[name] = class extends _types_[type.name] {
93
+ __instanceID;
94
+ __namespace;
95
+ __definition = {
96
+ ...definition
97
+ };
98
+ childs;
99
+ _body;
100
+ get body() {
101
+ return this._body;
102
+ }
103
+ set body(value) {
104
+ this._body = value;
105
+ }
106
+ static get __classType() {
107
+ return Object.getPrototypeOf(this.constructor).name;
108
+ }
109
+ get __classType() {
110
+ return this.constructor.name;
111
+ }
112
+ static hierarchy(__class__) {
113
+ const __classType = function (o_c) {
114
+ return (Object.hasOwn(o_c, "__classType")) ? (o_c.__classType) : (getType_1.__getType__.call(__class__, o_c));
115
+ };
116
+ const __hierarchy__proto__ = (c) => {
117
+ return (typeof c !== "undefined" && typeof c.__proto__ !== "undefined" && c.__proto__ !== null) ? (((__classType(c) !== "") ? ([__classType(c)]) : ([])).concat(__hierarchy__proto__(c.__proto__))) : ([]);
118
+ };
119
+ if (typeof __class__ === "undefined" || __class__ === null) {
120
+ __class__ = this;
121
+ }
122
+ let __hierarchy = [];
123
+ __hierarchy.push(__classType(__class__));
124
+ __hierarchy = __hierarchy.concat(__hierarchy__proto__(__class__.__proto__));
125
+ return __hierarchy;
126
+ }
127
+ static getParentClass() {
128
+ return Object.getPrototypeOf(this.prototype.constructor);
129
+ }
130
+ constructor(_o_) {
131
+ super(_o_ || {});
132
+ const self = this;
133
+ (0, IncrementInstanceID_1.IncrementInstanceID)();
134
+ if (!self.__instanceID) {
135
+ Object.defineProperty(self, "__instanceID", {
136
+ value: IncrementInstanceID_1.__instanceID,
137
+ writable: false
138
+ });
139
+ }
140
+ if (typeof self.__definition !== "undefined") {
141
+ Object.keys(self.__definition).filter(function (k) {
142
+ return isNaN(k) && !["name", "__instanceID", "__classType", "__definition"].includes(k);
143
+ }).forEach(function (key) {
144
+ if (typeof self.__definition[key] === "function") {
145
+ self[key] = self.__definition[key].bind(self);
146
+ }
147
+ else {
148
+ self[key] = self.__definition[key];
149
+ }
150
+ });
151
+ }
152
+ (0, introspection_1._methods_)(PrimaryCollections_1._QC_CLASSES[self.__classType]).map(function (m) {
153
+ self[m.name] = m.bind(self);
154
+ return m;
155
+ });
156
+ (0, introspection_1._methods_)(self.__definition).map(function (m) {
157
+ self[m.name] = m.bind(self);
158
+ return m;
159
+ });
160
+ if (self.body) {
161
+ if (typeof self.__definition === "undefined" || (!Object.hasOwn(self.__definition, "body")) || typeof self.__definition.body === "undefined") {
162
+ try {
163
+ if (platform_1.isBrowser) {
164
+ self.body = (0, DOMCreateElement_1._DOMCreateElement)(self.__definition.__classType);
165
+ }
166
+ else {
167
+ self.body = {};
168
+ }
169
+ }
170
+ catch (e) {
171
+ Logger_1.logger.debug(`An error ocurred: ${e}.`);
172
+ self.body = {};
173
+ }
174
+ }
175
+ else if (Object.hasOwn(self.__definition, "body")) {
176
+ self.body = self.__definition.body;
177
+ }
178
+ }
179
+ try {
180
+ if (typeof self.__new__ === "function") {
181
+ self.__new__.call(self, _o_);
182
+ }
183
+ else if (typeof super.__new__ === "function") {
184
+ self.__new__ = super.__new__.bind(self);
185
+ self.__new__.call(self, _o_);
186
+ }
187
+ if (typeof self === "object" && Object.hasOwn(self, "_new_") && typeof self._new_.isCalled === "undefined") {
188
+ try {
189
+ self._new_(_o_);
190
+ self._new_.isCalled = true;
191
+ }
192
+ catch (e) {
193
+ Logger_1.logger.warn(`${self.__classType}._new_() failed with error: ${e}`);
194
+ }
195
+ }
196
+ }
197
+ catch (e) {
198
+ Logger_1.logger.warn(e);
199
+ }
200
+ }
201
+ __new__(_o_) {
202
+ (0, Cast_1._CastProps)(_o_, this);
203
+ }
204
+ // eslint-disable-next-line no-unused-vars
205
+ _new_(_o_) { }
206
+ getClass() {
207
+ return Object.getPrototypeOf(this.constructor);
208
+ }
209
+ css(_css) {
210
+ if (typeof this.body !== "undefined" && typeof this?.body !== "string" && typeof this?.body?.style !== "undefined") {
211
+ Logger_1.logger.debug("body style");
212
+ if (this.body) {
213
+ this.body.style = (0, Cast_1._Cast)(_css, this?.body?.style);
214
+ }
215
+ }
216
+ return (typeof this.body !== "string") ? this?.body?.style : {};
217
+ }
218
+ hierarchy() {
219
+ const __instance__ = this;
220
+ return this.getClass().hierarchy(__instance__);
221
+ }
222
+ append(_child) {
223
+ const child = _child || this.body;
224
+ Logger_1.logger.debug("append: start");
225
+ if ((0, is_a_1.is_a)(child, "Component")) {
226
+ Logger_1.logger.debug("append: child is a Component");
227
+ Logger_1.logger.debug(`appending the body of ${child.name}`);
228
+ }
229
+ if (typeof this.body !== "undefined") {
230
+ Logger_1.logger.debug("append element");
231
+ if (arguments.length > 0) {
232
+ Logger_1.logger.debug("append to element");
233
+ if (typeof this.body !== "string") {
234
+ if (typeof this.body?.append !== "undefined") {
235
+ this?.body?.append(child);
236
+ }
237
+ else {
238
+ throw Error("body.append is undefined. That means the body is not well formed.");
239
+ }
240
+ }
241
+ else {
242
+ this.append(child);
243
+ }
244
+ if (typeof this.childs === "undefined") {
245
+ this.childs = [];
246
+ }
247
+ this.childs.push(child);
248
+ }
249
+ else {
250
+ if (platform_1.isBrowser) {
251
+ Logger_1.logger.debug("append to body");
252
+ document.body.append(child);
253
+ }
254
+ }
255
+ }
256
+ }
257
+ attachIn(tag) {
258
+ if (platform_1.isBrowser) {
259
+ const tags = document.subelements(tag);
260
+ for (let i = 0, j = tags.length; i < j; i++) {
261
+ tags[i].append(this);
262
+ }
263
+ }
264
+ else {
265
+ throw new Error("attachIn not yet implemented for non browser platforms");
266
+ }
267
+ }
268
+ };
269
+ // remove the keys from definition that exist in the prototype
270
+ PrimaryCollections_1._QC_CLASSES[name] = (0, Cast_1._CastProps)(definition, PrimaryCollections_1._QC_CLASSES[name]);
271
+ PrimaryCollections_1._QC_CLASSES[name].__definition = definition;
272
+ PrimaryCollections_1._QC_CLASSES[name].__definition.__classType = name;
273
+ PrimaryCollections_1._QC_CLASSES[name].__definition.__new__ = function __new__(_o_) {
274
+ (0, Cast_1._CastProps)(_o_, this);
275
+ };
276
+ top_1._top[name] = PrimaryCollections_1._QC_CLASSES[name];
277
+ return PrimaryCollections_1._QC_CLASSES[name];
278
+ };
279
+ exports.Class = Class;
280
+ if (typeof exports.Class.prototype !== "undefined") {
281
+ exports.Class.prototype.toString = function () {
282
+ return "Class(name, type, definition) { [QCObjects native code] }";
283
+ };
284
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Returns the QCObjects Class Factory of a given ClassName
4
+ *
5
+ * @param {String} name
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ClassFactory = void 0;
9
+ const is_raw_class_1 = require("./is_raw_class");
10
+ const PrimaryCollections_1 = require("./PrimaryCollections");
11
+ const ClassFactory = (className) => {
12
+ let _classFactory;
13
+ if (typeof className === "undefined" || className === null) {
14
+ throw Error("You need to pass a parameter {className}");
15
+ }
16
+ if (className !== null && className.indexOf(".") > -1) {
17
+ const packageName = className.split(".").slice(0, className.split(".").length - 1).join(".");
18
+ const _className = className.split(".").slice(-1).join("");
19
+ const _package = PrimaryCollections_1._QC_PACKAGES[packageName] || [];
20
+ const packageClasses = _package.filter((classFactory) => {
21
+ return ((0, is_raw_class_1.__is_raw_class__)(classFactory));
22
+ }).reverse();
23
+ if (packageClasses.length > 0) {
24
+ _classFactory = packageClasses[0];
25
+ }
26
+ else {
27
+ throw Error(`Class ${_className} not found. Found classes: ${JSON.stringify(packageClasses)} in package ${packageName}`);
28
+ }
29
+ }
30
+ else if (className !== null && Object.hasOwn(PrimaryCollections_1._QC_CLASSES, className)) {
31
+ _classFactory = PrimaryCollections_1._QC_CLASSES[className];
32
+ }
33
+ else {
34
+ throw Error(`Unable to determine class ${className}. Unable to retrieve the class factory.`);
35
+ }
36
+ return _classFactory;
37
+ };
38
+ exports.ClassFactory = ClassFactory;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComplexStorageCache = void 0;
4
+ const Base64_1 = require("./Base64");
5
+ const DataStringify_1 = require("./DataStringify");
6
+ const Logger_1 = require("./Logger");
7
+ class ComplexStorageCache {
8
+ constructor(params) {
9
+ let load, alternate;
10
+ const object = params.index;
11
+ if (typeof object !== "undefined") {
12
+ load = params.load;
13
+ alternate = params.alternate;
14
+ const cachedObjectID = this.getID(object);
15
+ const cachedResponse = localStorage.getItem(cachedObjectID);
16
+ if (this.isEmpty(cachedResponse)) {
17
+ const cachedNewResponse = load.call(null, {
18
+ cachedObjectID,
19
+ cachedResponse,
20
+ "cache": this
21
+ });
22
+ this.save(object, cachedNewResponse);
23
+ Logger_1.logger.debug("RESPONSE OF {{cachedObjectID}} CACHED".replace("{{cachedObjectID}}", cachedObjectID));
24
+ }
25
+ else {
26
+ alternate.call(null, {
27
+ cachedObjectID,
28
+ cachedResponse,
29
+ "cache": this
30
+ });
31
+ Logger_1.logger.debug("RESPONSE OF {{cachedObjectID}} IS ALREADY CACHED ".replace("{{cachedObjectID}}", cachedObjectID));
32
+ }
33
+ }
34
+ else {
35
+ throw new Error("ComplexStorageCache: index is undefined");
36
+ }
37
+ return this;
38
+ }
39
+ getItem(cachedObjectID) {
40
+ const retrievedObject = localStorage.getItem(cachedObjectID);
41
+ if (!this.isEmpty(retrievedObject)) {
42
+ return JSON.parse(retrievedObject);
43
+ }
44
+ else {
45
+ return null;
46
+ }
47
+ }
48
+ setItem(cachedObjectID, value) {
49
+ localStorage.setItem(cachedObjectID, (0, DataStringify_1._DataStringify)(value));
50
+ }
51
+ isEmpty(object) {
52
+ let r = false;
53
+ switch (true) {
54
+ case (typeof object === "undefined"):
55
+ case (typeof object === "string" && object === ""):
56
+ case (typeof object === "string" && object === "undefined"):
57
+ case (typeof object === "number" && object === 0):
58
+ case (object === null):
59
+ r = true;
60
+ break;
61
+ default:
62
+ r = false;
63
+ }
64
+ return r;
65
+ }
66
+ getID(object) {
67
+ let cachedObjectID;
68
+ if (typeof object !== "undefined") {
69
+ cachedObjectID = "cachedObject_" + Base64_1.Base64.encode((0, DataStringify_1._DataStringify)(object).replace(/\{|\}|,/g, "_"));
70
+ }
71
+ return cachedObjectID;
72
+ }
73
+ save(object, cachedNewResponse) {
74
+ const cachedObjectID = this.getID(object);
75
+ Logger_1.logger.debug("CACHING THE RESPONSE OF {{cachedObjectID}} ".replace("{{cachedObjectID}}", cachedObjectID));
76
+ this.setItem(cachedObjectID, cachedNewResponse);
77
+ }
78
+ getCached(object) {
79
+ const cachedObjectID = this.getID(object);
80
+ return this.getItem(cachedObjectID);
81
+ }
82
+ clear() {
83
+ Object.keys(localStorage).filter(function (k) {
84
+ return k.startsWith("cachedObject_");
85
+ }).map(function (c) {
86
+ localStorage.removeItem(c);
87
+ return c;
88
+ });
89
+ }
90
+ }
91
+ exports.ComplexStorageCache = ComplexStorageCache;