@zenflux/core 0.0.0-alpha.6 → 0.0.0-alpha.8

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 (74) hide show
  1. package/dist/cjs/zenflux-core.js +18 -145
  2. package/dist/es/clients/http.d.ts +21 -0
  3. package/dist/es/clients/http.d.ts.map +1 -0
  4. package/dist/es/command-bases/command-base.d.ts +23 -0
  5. package/dist/es/command-bases/command-base.d.ts.map +1 -0
  6. package/dist/es/command-bases/command-data.d.ts +18 -0
  7. package/dist/es/command-bases/command-data.d.ts.map +1 -0
  8. package/dist/es/command-bases/command-internal.d.ts +10 -0
  9. package/dist/es/command-bases/command-internal.d.ts.map +1 -0
  10. package/dist/es/command-bases/command-public.d.ts +10 -0
  11. package/dist/es/command-bases/command-public.d.ts.map +1 -0
  12. package/dist/es/command-bases/index.d.ts +8 -0
  13. package/dist/es/command-bases/index.d.ts.map +1 -0
  14. package/dist/es/core/controller.d.ts +36 -0
  15. package/dist/es/core/controller.d.ts.map +1 -0
  16. package/dist/es/core/index.d.ts +3 -0
  17. package/dist/es/core/index.d.ts.map +1 -0
  18. package/dist/es/core/object-base.d.ts +15 -0
  19. package/dist/es/core/object-base.d.ts.map +1 -0
  20. package/dist/es/enums/http.d.ts +13 -0
  21. package/dist/es/enums/http.d.ts.map +1 -0
  22. package/dist/es/errors/command-already-registered.d.ts +9 -0
  23. package/dist/es/errors/command-already-registered.d.ts.map +1 -0
  24. package/dist/es/errors/command-not-found.d.ts +8 -0
  25. package/dist/es/errors/command-not-found.d.ts.map +1 -0
  26. package/dist/es/errors/controller-already-registered.d.ts +9 -0
  27. package/dist/es/errors/controller-already-registered.d.ts.map +1 -0
  28. package/dist/es/errors/force-method.d.ts +12 -0
  29. package/dist/es/errors/force-method.d.ts.map +1 -0
  30. package/dist/es/errors/index.d.ts +5 -0
  31. package/dist/es/errors/index.d.ts.map +1 -0
  32. package/dist/es/exports.d.ts +11 -0
  33. package/dist/es/exports.d.ts.map +1 -0
  34. package/dist/es/index.d.ts +6 -0
  35. package/dist/es/index.d.ts.map +1 -0
  36. package/dist/es/initializer.d.ts +20 -0
  37. package/dist/es/initializer.d.ts.map +1 -0
  38. package/dist/es/interfaces/commands.d.ts +14 -0
  39. package/dist/es/interfaces/commands.d.ts.map +1 -0
  40. package/dist/es/interfaces/config.d.ts +11 -0
  41. package/dist/es/interfaces/config.d.ts.map +1 -0
  42. package/dist/es/interfaces/managers.d.ts +14 -0
  43. package/dist/es/interfaces/managers.d.ts.map +1 -0
  44. package/dist/es/interfaces/object-base.d.ts +11 -0
  45. package/dist/es/interfaces/object-base.d.ts.map +1 -0
  46. package/dist/es/manager-bases/commands.d.ts +76 -0
  47. package/dist/es/manager-bases/commands.d.ts.map +1 -0
  48. package/dist/es/manager-bases/controllers.d.ts +19 -0
  49. package/dist/es/manager-bases/controllers.d.ts.map +1 -0
  50. package/dist/es/manager-bases/data.d.ts +24 -0
  51. package/dist/es/manager-bases/data.d.ts.map +1 -0
  52. package/dist/es/manager-bases/index.d.ts +8 -0
  53. package/dist/es/manager-bases/index.d.ts.map +1 -0
  54. package/dist/es/manager-bases/internal.d.ts +10 -0
  55. package/dist/es/manager-bases/internal.d.ts.map +1 -0
  56. package/dist/es/managers/index.d.ts +16 -0
  57. package/dist/es/managers/index.d.ts.map +1 -0
  58. package/dist/es/modules/index.d.ts +2 -0
  59. package/dist/es/modules/index.d.ts.map +1 -0
  60. package/dist/es/modules/logger.d.ts +118 -0
  61. package/dist/es/modules/logger.d.ts.map +1 -0
  62. package/dist/es/utils/index.d.ts +3 -0
  63. package/dist/es/utils/index.d.ts.map +1 -0
  64. package/dist/es/utils/object.d.ts +7 -0
  65. package/dist/es/utils/object.d.ts.map +1 -0
  66. package/dist/es/utils/rgb.d.ts +7 -0
  67. package/dist/es/utils/rgb.d.ts.map +1 -0
  68. package/dist/es/zenflux-core.js +18 -145
  69. package/dist/esm/zenflux-core.mjs +2083 -0
  70. package/dist/umd/zenflux-core.js +18 -145
  71. package/package.json +3 -2
  72. package/src/initializer.ts +2 -1
  73. package/types/index.d.ts +3 -3
  74. package/dist/es/zenflux-core.mjs +0 -1
@@ -0,0 +1,2083 @@
1
+ function _iterableToArrayLimit(arr, i) {
2
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
3
+ if (null != _i) {
4
+ var _s,
5
+ _e,
6
+ _x,
7
+ _r,
8
+ _arr = [],
9
+ _n = !0,
10
+ _d = !1;
11
+ try {
12
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
13
+ if (Object(_i) !== _i) return;
14
+ _n = !1;
15
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
16
+ } catch (err) {
17
+ _d = !0, _e = err;
18
+ } finally {
19
+ try {
20
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
21
+ } finally {
22
+ if (_d) throw _e;
23
+ }
24
+ }
25
+ return _arr;
26
+ }
27
+ }
28
+ function ownKeys(object, enumerableOnly) {
29
+ var keys = Object.keys(object);
30
+ if (Object.getOwnPropertySymbols) {
31
+ var symbols = Object.getOwnPropertySymbols(object);
32
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
33
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
34
+ })), keys.push.apply(keys, symbols);
35
+ }
36
+ return keys;
37
+ }
38
+ function _objectSpread2(target) {
39
+ for (var i = 1; i < arguments.length; i++) {
40
+ var source = null != arguments[i] ? arguments[i] : {};
41
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
42
+ _defineProperty(target, key, source[key]);
43
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
44
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
45
+ });
46
+ }
47
+ return target;
48
+ }
49
+ function _regeneratorRuntime() {
50
+ _regeneratorRuntime = function () {
51
+ return exports;
52
+ };
53
+ var exports = {},
54
+ Op = Object.prototype,
55
+ hasOwn = Op.hasOwnProperty,
56
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
57
+ obj[key] = desc.value;
58
+ },
59
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
60
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
61
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
62
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
63
+ function define(obj, key, value) {
64
+ return Object.defineProperty(obj, key, {
65
+ value: value,
66
+ enumerable: !0,
67
+ configurable: !0,
68
+ writable: !0
69
+ }), obj[key];
70
+ }
71
+ try {
72
+ define({}, "");
73
+ } catch (err) {
74
+ define = function (obj, key, value) {
75
+ return obj[key] = value;
76
+ };
77
+ }
78
+ function wrap(innerFn, outerFn, self, tryLocsList) {
79
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
80
+ generator = Object.create(protoGenerator.prototype),
81
+ context = new Context(tryLocsList || []);
82
+ return defineProperty(generator, "_invoke", {
83
+ value: makeInvokeMethod(innerFn, self, context)
84
+ }), generator;
85
+ }
86
+ function tryCatch(fn, obj, arg) {
87
+ try {
88
+ return {
89
+ type: "normal",
90
+ arg: fn.call(obj, arg)
91
+ };
92
+ } catch (err) {
93
+ return {
94
+ type: "throw",
95
+ arg: err
96
+ };
97
+ }
98
+ }
99
+ exports.wrap = wrap;
100
+ var ContinueSentinel = {};
101
+ function Generator() {}
102
+ function GeneratorFunction() {}
103
+ function GeneratorFunctionPrototype() {}
104
+ var IteratorPrototype = {};
105
+ define(IteratorPrototype, iteratorSymbol, function () {
106
+ return this;
107
+ });
108
+ var getProto = Object.getPrototypeOf,
109
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
110
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
111
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
112
+ function defineIteratorMethods(prototype) {
113
+ ["next", "throw", "return"].forEach(function (method) {
114
+ define(prototype, method, function (arg) {
115
+ return this._invoke(method, arg);
116
+ });
117
+ });
118
+ }
119
+ function AsyncIterator(generator, PromiseImpl) {
120
+ function invoke(method, arg, resolve, reject) {
121
+ var record = tryCatch(generator[method], generator, arg);
122
+ if ("throw" !== record.type) {
123
+ var result = record.arg,
124
+ value = result.value;
125
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
126
+ invoke("next", value, resolve, reject);
127
+ }, function (err) {
128
+ invoke("throw", err, resolve, reject);
129
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
130
+ result.value = unwrapped, resolve(result);
131
+ }, function (error) {
132
+ return invoke("throw", error, resolve, reject);
133
+ });
134
+ }
135
+ reject(record.arg);
136
+ }
137
+ var previousPromise;
138
+ defineProperty(this, "_invoke", {
139
+ value: function (method, arg) {
140
+ function callInvokeWithMethodAndArg() {
141
+ return new PromiseImpl(function (resolve, reject) {
142
+ invoke(method, arg, resolve, reject);
143
+ });
144
+ }
145
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
146
+ }
147
+ });
148
+ }
149
+ function makeInvokeMethod(innerFn, self, context) {
150
+ var state = "suspendedStart";
151
+ return function (method, arg) {
152
+ if ("executing" === state) throw new Error("Generator is already running");
153
+ if ("completed" === state) {
154
+ if ("throw" === method) throw arg;
155
+ return doneResult();
156
+ }
157
+ for (context.method = method, context.arg = arg;;) {
158
+ var delegate = context.delegate;
159
+ if (delegate) {
160
+ var delegateResult = maybeInvokeDelegate(delegate, context);
161
+ if (delegateResult) {
162
+ if (delegateResult === ContinueSentinel) continue;
163
+ return delegateResult;
164
+ }
165
+ }
166
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
167
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
168
+ context.dispatchException(context.arg);
169
+ } else "return" === context.method && context.abrupt("return", context.arg);
170
+ state = "executing";
171
+ var record = tryCatch(innerFn, self, context);
172
+ if ("normal" === record.type) {
173
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
174
+ return {
175
+ value: record.arg,
176
+ done: context.done
177
+ };
178
+ }
179
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
180
+ }
181
+ };
182
+ }
183
+ function maybeInvokeDelegate(delegate, context) {
184
+ var methodName = context.method,
185
+ method = delegate.iterator[methodName];
186
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
187
+ var record = tryCatch(method, delegate.iterator, context.arg);
188
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
189
+ var info = record.arg;
190
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
191
+ }
192
+ function pushTryEntry(locs) {
193
+ var entry = {
194
+ tryLoc: locs[0]
195
+ };
196
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
197
+ }
198
+ function resetTryEntry(entry) {
199
+ var record = entry.completion || {};
200
+ record.type = "normal", delete record.arg, entry.completion = record;
201
+ }
202
+ function Context(tryLocsList) {
203
+ this.tryEntries = [{
204
+ tryLoc: "root"
205
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
206
+ }
207
+ function values(iterable) {
208
+ if (iterable) {
209
+ var iteratorMethod = iterable[iteratorSymbol];
210
+ if (iteratorMethod) return iteratorMethod.call(iterable);
211
+ if ("function" == typeof iterable.next) return iterable;
212
+ if (!isNaN(iterable.length)) {
213
+ var i = -1,
214
+ next = function next() {
215
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
216
+ return next.value = undefined, next.done = !0, next;
217
+ };
218
+ return next.next = next;
219
+ }
220
+ }
221
+ return {
222
+ next: doneResult
223
+ };
224
+ }
225
+ function doneResult() {
226
+ return {
227
+ value: undefined,
228
+ done: !0
229
+ };
230
+ }
231
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
232
+ value: GeneratorFunctionPrototype,
233
+ configurable: !0
234
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
235
+ value: GeneratorFunction,
236
+ configurable: !0
237
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
238
+ var ctor = "function" == typeof genFun && genFun.constructor;
239
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
240
+ }, exports.mark = function (genFun) {
241
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
242
+ }, exports.awrap = function (arg) {
243
+ return {
244
+ __await: arg
245
+ };
246
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
247
+ return this;
248
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
249
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
250
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
251
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
252
+ return result.done ? result.value : iter.next();
253
+ });
254
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
255
+ return this;
256
+ }), define(Gp, "toString", function () {
257
+ return "[object Generator]";
258
+ }), exports.keys = function (val) {
259
+ var object = Object(val),
260
+ keys = [];
261
+ for (var key in object) keys.push(key);
262
+ return keys.reverse(), function next() {
263
+ for (; keys.length;) {
264
+ var key = keys.pop();
265
+ if (key in object) return next.value = key, next.done = !1, next;
266
+ }
267
+ return next.done = !0, next;
268
+ };
269
+ }, exports.values = values, Context.prototype = {
270
+ constructor: Context,
271
+ reset: function (skipTempReset) {
272
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
273
+ },
274
+ stop: function () {
275
+ this.done = !0;
276
+ var rootRecord = this.tryEntries[0].completion;
277
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
278
+ return this.rval;
279
+ },
280
+ dispatchException: function (exception) {
281
+ if (this.done) throw exception;
282
+ var context = this;
283
+ function handle(loc, caught) {
284
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
285
+ }
286
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
287
+ var entry = this.tryEntries[i],
288
+ record = entry.completion;
289
+ if ("root" === entry.tryLoc) return handle("end");
290
+ if (entry.tryLoc <= this.prev) {
291
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
292
+ hasFinally = hasOwn.call(entry, "finallyLoc");
293
+ if (hasCatch && hasFinally) {
294
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
295
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
296
+ } else if (hasCatch) {
297
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
298
+ } else {
299
+ if (!hasFinally) throw new Error("try statement without catch or finally");
300
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
301
+ }
302
+ }
303
+ }
304
+ },
305
+ abrupt: function (type, arg) {
306
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
307
+ var entry = this.tryEntries[i];
308
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
309
+ var finallyEntry = entry;
310
+ break;
311
+ }
312
+ }
313
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
314
+ var record = finallyEntry ? finallyEntry.completion : {};
315
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
316
+ },
317
+ complete: function (record, afterLoc) {
318
+ if ("throw" === record.type) throw record.arg;
319
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
320
+ },
321
+ finish: function (finallyLoc) {
322
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
323
+ var entry = this.tryEntries[i];
324
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
325
+ }
326
+ },
327
+ catch: function (tryLoc) {
328
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
329
+ var entry = this.tryEntries[i];
330
+ if (entry.tryLoc === tryLoc) {
331
+ var record = entry.completion;
332
+ if ("throw" === record.type) {
333
+ var thrown = record.arg;
334
+ resetTryEntry(entry);
335
+ }
336
+ return thrown;
337
+ }
338
+ }
339
+ throw new Error("illegal catch attempt");
340
+ },
341
+ delegateYield: function (iterable, resultName, nextLoc) {
342
+ return this.delegate = {
343
+ iterator: values(iterable),
344
+ resultName: resultName,
345
+ nextLoc: nextLoc
346
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
347
+ }
348
+ }, exports;
349
+ }
350
+ function _typeof(obj) {
351
+ "@babel/helpers - typeof";
352
+
353
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
354
+ return typeof obj;
355
+ } : function (obj) {
356
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
357
+ }, _typeof(obj);
358
+ }
359
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
360
+ try {
361
+ var info = gen[key](arg);
362
+ var value = info.value;
363
+ } catch (error) {
364
+ reject(error);
365
+ return;
366
+ }
367
+ if (info.done) {
368
+ resolve(value);
369
+ } else {
370
+ Promise.resolve(value).then(_next, _throw);
371
+ }
372
+ }
373
+ function _asyncToGenerator(fn) {
374
+ return function () {
375
+ var self = this,
376
+ args = arguments;
377
+ return new Promise(function (resolve, reject) {
378
+ var gen = fn.apply(self, args);
379
+ function _next(value) {
380
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
381
+ }
382
+ function _throw(err) {
383
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
384
+ }
385
+ _next(undefined);
386
+ });
387
+ };
388
+ }
389
+ function _classCallCheck(instance, Constructor) {
390
+ if (!(instance instanceof Constructor)) {
391
+ throw new TypeError("Cannot call a class as a function");
392
+ }
393
+ }
394
+ function _defineProperties(target, props) {
395
+ for (var i = 0; i < props.length; i++) {
396
+ var descriptor = props[i];
397
+ descriptor.enumerable = descriptor.enumerable || false;
398
+ descriptor.configurable = true;
399
+ if ("value" in descriptor) descriptor.writable = true;
400
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
401
+ }
402
+ }
403
+ function _createClass(Constructor, protoProps, staticProps) {
404
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
405
+ if (staticProps) _defineProperties(Constructor, staticProps);
406
+ Object.defineProperty(Constructor, "prototype", {
407
+ writable: false
408
+ });
409
+ return Constructor;
410
+ }
411
+ function _defineProperty(obj, key, value) {
412
+ key = _toPropertyKey(key);
413
+ if (key in obj) {
414
+ Object.defineProperty(obj, key, {
415
+ value: value,
416
+ enumerable: true,
417
+ configurable: true,
418
+ writable: true
419
+ });
420
+ } else {
421
+ obj[key] = value;
422
+ }
423
+ return obj;
424
+ }
425
+ function _inherits(subClass, superClass) {
426
+ if (typeof superClass !== "function" && superClass !== null) {
427
+ throw new TypeError("Super expression must either be null or a function");
428
+ }
429
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
430
+ constructor: {
431
+ value: subClass,
432
+ writable: true,
433
+ configurable: true
434
+ }
435
+ });
436
+ Object.defineProperty(subClass, "prototype", {
437
+ writable: false
438
+ });
439
+ if (superClass) _setPrototypeOf(subClass, superClass);
440
+ }
441
+ function _getPrototypeOf(o) {
442
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
443
+ return o.__proto__ || Object.getPrototypeOf(o);
444
+ };
445
+ return _getPrototypeOf(o);
446
+ }
447
+ function _setPrototypeOf(o, p) {
448
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
449
+ o.__proto__ = p;
450
+ return o;
451
+ };
452
+ return _setPrototypeOf(o, p);
453
+ }
454
+ function _isNativeReflectConstruct() {
455
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
456
+ if (Reflect.construct.sham) return false;
457
+ if (typeof Proxy === "function") return true;
458
+ try {
459
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
460
+ return true;
461
+ } catch (e) {
462
+ return false;
463
+ }
464
+ }
465
+ function _construct(Parent, args, Class) {
466
+ if (_isNativeReflectConstruct()) {
467
+ _construct = Reflect.construct.bind();
468
+ } else {
469
+ _construct = function _construct(Parent, args, Class) {
470
+ var a = [null];
471
+ a.push.apply(a, args);
472
+ var Constructor = Function.bind.apply(Parent, a);
473
+ var instance = new Constructor();
474
+ if (Class) _setPrototypeOf(instance, Class.prototype);
475
+ return instance;
476
+ };
477
+ }
478
+ return _construct.apply(null, arguments);
479
+ }
480
+ function _isNativeFunction(fn) {
481
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
482
+ }
483
+ function _wrapNativeSuper(Class) {
484
+ var _cache = typeof Map === "function" ? new Map() : undefined;
485
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
486
+ if (Class === null || !_isNativeFunction(Class)) return Class;
487
+ if (typeof Class !== "function") {
488
+ throw new TypeError("Super expression must either be null or a function");
489
+ }
490
+ if (typeof _cache !== "undefined") {
491
+ if (_cache.has(Class)) return _cache.get(Class);
492
+ _cache.set(Class, Wrapper);
493
+ }
494
+ function Wrapper() {
495
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
496
+ }
497
+ Wrapper.prototype = Object.create(Class.prototype, {
498
+ constructor: {
499
+ value: Wrapper,
500
+ enumerable: false,
501
+ writable: true,
502
+ configurable: true
503
+ }
504
+ });
505
+ return _setPrototypeOf(Wrapper, Class);
506
+ };
507
+ return _wrapNativeSuper(Class);
508
+ }
509
+ function _assertThisInitialized(self) {
510
+ if (self === void 0) {
511
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
512
+ }
513
+ return self;
514
+ }
515
+ function _possibleConstructorReturn(self, call) {
516
+ if (call && (typeof call === "object" || typeof call === "function")) {
517
+ return call;
518
+ } else if (call !== void 0) {
519
+ throw new TypeError("Derived constructors may only return object or undefined");
520
+ }
521
+ return _assertThisInitialized(self);
522
+ }
523
+ function _createSuper(Derived) {
524
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
525
+ return function _createSuperInternal() {
526
+ var Super = _getPrototypeOf(Derived),
527
+ result;
528
+ if (hasNativeReflectConstruct) {
529
+ var NewTarget = _getPrototypeOf(this).constructor;
530
+ result = Reflect.construct(Super, arguments, NewTarget);
531
+ } else {
532
+ result = Super.apply(this, arguments);
533
+ }
534
+ return _possibleConstructorReturn(this, result);
535
+ };
536
+ }
537
+ function _superPropBase(object, property) {
538
+ while (!Object.prototype.hasOwnProperty.call(object, property)) {
539
+ object = _getPrototypeOf(object);
540
+ if (object === null) break;
541
+ }
542
+ return object;
543
+ }
544
+ function _get() {
545
+ if (typeof Reflect !== "undefined" && Reflect.get) {
546
+ _get = Reflect.get.bind();
547
+ } else {
548
+ _get = function _get(target, property, receiver) {
549
+ var base = _superPropBase(target, property);
550
+ if (!base) return;
551
+ var desc = Object.getOwnPropertyDescriptor(base, property);
552
+ if (desc.get) {
553
+ return desc.get.call(arguments.length < 3 ? target : receiver);
554
+ }
555
+ return desc.value;
556
+ };
557
+ }
558
+ return _get.apply(this, arguments);
559
+ }
560
+ function _slicedToArray(arr, i) {
561
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
562
+ }
563
+ function _arrayWithHoles(arr) {
564
+ if (Array.isArray(arr)) return arr;
565
+ }
566
+ function _unsupportedIterableToArray(o, minLen) {
567
+ if (!o) return;
568
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
569
+ var n = Object.prototype.toString.call(o).slice(8, -1);
570
+ if (n === "Object" && o.constructor) n = o.constructor.name;
571
+ if (n === "Map" || n === "Set") return Array.from(o);
572
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
573
+ }
574
+ function _arrayLikeToArray(arr, len) {
575
+ if (len == null || len > arr.length) len = arr.length;
576
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
577
+ return arr2;
578
+ }
579
+ function _nonIterableRest() {
580
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
581
+ }
582
+ function _toPrimitive(input, hint) {
583
+ if (typeof input !== "object" || input === null) return input;
584
+ var prim = input[Symbol.toPrimitive];
585
+ if (prim !== undefined) {
586
+ var res = prim.call(input, hint || "default");
587
+ if (typeof res !== "object") return res;
588
+ throw new TypeError("@@toPrimitive must return a primitive value.");
589
+ }
590
+ return (hint === "string" ? String : Number)(input);
591
+ }
592
+ function _toPropertyKey(arg) {
593
+ var key = _toPrimitive(arg, "string");
594
+ return typeof key === "symbol" ? key : String(key);
595
+ }
596
+
597
+ var version = "0.0.0-alpha.8";
598
+
599
+ /**
600
+ * Function getCircularReplacer() : Reduce circular references.
601
+ *
602
+ * @copyright https://stackoverflow.com/a/53731154
603
+ */
604
+ var getCircularReplacer = function getCircularReplacer() {
605
+ var seen = new WeakSet();
606
+ return function (key, value) {
607
+ if (_typeof(value) === "object" && value !== null) {
608
+ if (seen.has(value)) {
609
+ return;
610
+ }
611
+ seen.add(value);
612
+ }
613
+ return value;
614
+ };
615
+ };
616
+
617
+ /**
618
+ * Function hexColorDelta() : Return color difference in ratio decimal point.
619
+ *
620
+ * @copyright http://jsfiddle.net/96sME/
621
+ */
622
+ var hexColorDelta = function hexColorDelta(hex1, hex2) {
623
+ hex1 = hex1.replace("#", "");
624
+ hex2 = hex2.replace("#", "");
625
+ // Get red/green/blue int values of hex1
626
+ var r1 = parseInt(hex1.substring(0, 2), 16);
627
+ var g1 = parseInt(hex1.substring(2, 4), 16);
628
+ var b1 = parseInt(hex1.substring(4, 6), 16);
629
+ // Get red/green/blue int values of hex2
630
+ var r2 = parseInt(hex2.substring(0, 2), 16);
631
+ var g2 = parseInt(hex2.substring(2, 4), 16);
632
+ var b2 = parseInt(hex2.substring(4, 6), 16);
633
+ // Calculate differences between reds, greens and blues
634
+ var r = 255 - Math.abs(r1 - r2);
635
+ var g = 255 - Math.abs(g1 - g2);
636
+ var b = 255 - Math.abs(b1 - b2);
637
+ // Limit differences between 0 and 1
638
+ r /= 255;
639
+ g /= 255;
640
+ b /= 255;
641
+ // 0 means opposite colors, 1 means same colors
642
+ return (r + g + b) / 3;
643
+ };
644
+
645
+ var index$6 = /*#__PURE__*/Object.freeze({
646
+ __proto__: null,
647
+ getCircularReplacer: getCircularReplacer,
648
+ hexColorDelta: hexColorDelta
649
+ });
650
+
651
+ // TODO: Should by dynamic/configure-able.
652
+ var MAX_WRAPPING_RECURSIVE_DEPTH = 4,
653
+ STACK_BACKWARD_CALLER_INDEX = 3,
654
+ UNKNOWN_CALLER_NAME = 'anonymous function',
655
+ BABEL_EXCLUDE_FUNCTIONS_NAMES = ['_callee', 'tryCatch', '<anonymous>', 'Generator.next', 'asyncGeneratorStep', '_next'];
656
+ // TODO: Should by dynamic/configure-able.
657
+ Error.stackTraceLimit = 50;
658
+ var Logger = /*#__PURE__*/function () {
659
+ /**
660
+ * Function constructor() : Create logger class.
661
+ */
662
+ function Logger(owner) {
663
+ var _globalThis$process;
664
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
665
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
666
+ _classCallCheck(this, Logger);
667
+ _defineProperty(this, "args", {});
668
+ _defineProperty(this, "state", false);
669
+ if ('off' === ((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process.env['flow_modules_logger'])) {
670
+ return;
671
+ }
672
+ this.state = isActive;
673
+ this.args = args;
674
+ this.name = "";
675
+ if (typeof owner == "string") {
676
+ this.name = owner;
677
+ } else {
678
+ this.name = owner.constructor.name;
679
+ }
680
+ if (isActive) {
681
+ this.initialize();
682
+ }
683
+ }
684
+ /**
685
+ * Function initialize() : Initialize logger class.
686
+ */
687
+ _createClass(Logger, [{
688
+ key: "initialize",
689
+ value: function initialize() {
690
+ // @ts-ignore
691
+ if (this.args.sameColor) {
692
+ if (!Logger.sharedData[this.name]) {
693
+ Logger.sharedData[this.name] = this.getRandomColor();
694
+ }
695
+ this.color = Logger.sharedData[this.name];
696
+ } else {
697
+ this.color = this.getRandomColor();
698
+ Logger.colorsInUse.push(this.color);
699
+ }
700
+ this.outputHandler = console.log;
701
+ this.defaultStyle = ["color: grey;font-size:7px", "display: block", "color: ".concat(this.color), "color: grey", "font-weight: bold", "color: #607D8B", "font-size: 16px;color: red;font-weight:800"];
702
+ }
703
+ /**
704
+ * Function setOutputHandler() : Set custom output handler.
705
+ */
706
+ }, {
707
+ key: "setOutputHandler",
708
+ value: function setOutputHandler(outputHandler) {
709
+ this.outputHandler = outputHandler;
710
+ }
711
+ /**
712
+ * Function useWrapper() : Search for customized log view, each instance,
713
+ * that typeof the instance was registered wrapper will have unique output
714
+ * according to the registered callback.
715
+ */
716
+ }, {
717
+ key: "useWrapper",
718
+ value: function useWrapper(obj) {
719
+ var _this = this;
720
+ var shouldHandleChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
721
+ if (!obj || 'object' !== _typeof(obj) || Array.isArray(obj)) {
722
+ return obj;
723
+ }
724
+ Logger.wrapperDepth++;
725
+ // Result will lose classType (instanceOf will not work), now based on obj.
726
+ var result = _objectSpread2({}, obj);
727
+ // @ts-ignore
728
+ Object.values(Logger.wrappers).forEach(function (_ref) {
729
+ var _ref2 = _slicedToArray(_ref, 1),
730
+ wrapper = _ref2[0];
731
+ if (obj instanceof wrapper.classType) {
732
+ result = wrapper.callback(obj) || result;
733
+ }
734
+ });
735
+ if (Logger.wrapperDepth >= MAX_WRAPPING_RECURSIVE_DEPTH) {
736
+ Logger.wrapperDepth--;
737
+ return result;
738
+ }
739
+ if (shouldHandleChildren && result) {
740
+ Object.entries(result).forEach(function (_ref3) {
741
+ var _ref4 = _slicedToArray(_ref3, 2),
742
+ key = _ref4[0],
743
+ value = _ref4[1];
744
+ result[key] = _this.useWrapper(value, true);
745
+ });
746
+ }
747
+ Logger.wrapperDepth--;
748
+ return result;
749
+ }
750
+ /**
751
+ * Function startEmpty() : Notify function start without args.
752
+ *
753
+ * @param {string} output
754
+ */
755
+ }, {
756
+ key: "startEmpty",
757
+ value: function startEmpty() {
758
+ var output = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
759
+ if (!this.state) return;
760
+ this.printFunctionNotify("se", Logger.getCallerName(), output);
761
+ }
762
+ /**
763
+ * Function startWith() : Notify function start with args.
764
+ *
765
+ * TODO: Rename to startsWith
766
+ */
767
+ }, {
768
+ key: "startWith",
769
+ value: function startWith(params) {
770
+ if (!this.state) return;
771
+ params = Object.assign({}, params);
772
+ var type = "se";
773
+ var source = Logger.getCallerName();
774
+ if (typeof params == "string") {
775
+ this.printInLineString(type, source, params);
776
+ } else if (Object.keys(params).length === 1) {
777
+ var key = Object.keys(params)[0];
778
+ var value = Object.values(params)[0];
779
+ // TODO: Check is repeated logic, handle it.
780
+ if (_typeof(value) === "object") {
781
+ this.printNextLineObject(type, source, key, value || {});
782
+ } else if (typeof value == "function") {
783
+ this.printInLineFunction(type, source, key, value);
784
+ } else {
785
+ this.printInLineElement(type, source, key, value);
786
+ }
787
+ } else {
788
+ this.printMultiLineObject(type, source, params);
789
+ }
790
+ }
791
+ /**
792
+ * Function object() : Prints object.
793
+ **/
794
+ }, {
795
+ key: "object",
796
+ value: function object() {
797
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
798
+ var notice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
799
+ if (!this.state) return;
800
+ var source = Logger.getCallerName();
801
+ params = Object.create(params);
802
+ for (var key in params) {
803
+ if (_typeof(params[key]) === "object") {
804
+ params[key] = JSON.stringify(this.useWrapper(params[key]), getCircularReplacer());
805
+ }
806
+ this.out.apply(this, ["%c(ob)-> %c%c".concat(this.name, "%c::%c").concat(source, "%c() [").concat(notice, "] ->> ").concat(key, ": '").concat(params[key], "'%c")].concat(this.defaultStyle));
807
+ }
808
+ }
809
+ /**
810
+ * Function debug() : Notify debug.
811
+ */
812
+ }, {
813
+ key: "debug",
814
+ value: function debug(output) {
815
+ if (!this.state) return;
816
+ this.printFunctionNotify("db", Logger.getCallerName(), output);
817
+ }
818
+ /**
819
+ * Function drop : Preview as continue of log which drop ite.
820
+ */
821
+ }, {
822
+ key: "drop",
823
+ value: function drop(according, data) {
824
+ if (!this.state) return;
825
+ var source = Logger.getCallerName();
826
+ for (var key in according) {
827
+ this.out.apply(this, ["%c(dr)-> %c%c".concat(this.name, "%c::%c").concat(source, "%c() ->> corresponding ").concat(key, ": '").concat(according[key], "' RESULT: %c\u2193")].concat(this.defaultStyle));
828
+ }
829
+ this.out(data);
830
+ }
831
+ /**
832
+ * Function throw() : Throws logged error.
833
+ */
834
+ }, {
835
+ key: "throw",
836
+ value: function _throw(output) {
837
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'null';
838
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
839
+ this.printFunctionNotify("tw", Logger.getCallerName(), output);
840
+ if (params) this.printNextLineObject("tw", Logger.getCallerName(), name, params);
841
+ throw new Error().stack;
842
+ }
843
+ /**
844
+ * Function clone() : Create clone instance.
845
+ */
846
+ }, {
847
+ key: "clone",
848
+ value: function clone() {
849
+ return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
850
+ }
851
+ /**
852
+ * Function printFunctionNotify() : Print simple log for notify source (function).
853
+ *
854
+ */
855
+ }, {
856
+ key: "printFunctionNotify",
857
+ value: function printFunctionNotify(type, source, output) {
858
+ this.out.apply(this, ["%c(".concat(type, ")-> %c%c").concat(this.name, "%c::%c").concat(source, "%c() ").concat(output, "%c")].concat(this.defaultStyle));
859
+ }
860
+ /**
861
+ * Function printInLineElement() : Print in line element.
862
+ */
863
+ }, {
864
+ key: "printInLineElement",
865
+ value: function printInLineElement(type, source, key, value) {
866
+ this.out.apply(this, ["%c(".concat(type, ")-> %c%c").concat(this.name, "%c::%c").concat(source, "%c() ->> ").concat(key, ": '").concat(value, "'%c")].concat(this.defaultStyle));
867
+ }
868
+ /**
869
+ * Function printInLineFunction() : Print in line function.
870
+ */
871
+ }, {
872
+ key: "printInLineFunction",
873
+ value: function printInLineFunction(type, source, key, fn) {
874
+ fn = Logger.getFunctionView(fn);
875
+ this.printInLineElement(type, source, key, fn);
876
+ }
877
+ /**
878
+ * Function printInLineString() : Print in line string.
879
+ */
880
+ }, {
881
+ key: "printInLineString",
882
+ value: function printInLineString(type, source, string) {
883
+ this.printInLineElement(type, source, "(string)", string);
884
+ }
885
+ /**
886
+ * Function printNextLineObject() : Print object in next line.
887
+ */
888
+ }, {
889
+ key: "printNextLineObject",
890
+ value: function printNextLineObject(type, source, key, obj) {
891
+ obj = this.useWrapper(obj);
892
+ this.out.apply(this, ["%c(".concat(type, ")-> %c%c").concat(this.name, "%c::%c").concat(source, "%c() ->> ").concat(key, " %c\u2193")].concat(this.defaultStyle));
893
+ // print in next line
894
+ this.out(obj);
895
+ }
896
+ /**
897
+ * Function printMultiLineObject() : Print object in multiline format.
898
+ */
899
+ }, {
900
+ key: "printMultiLineObject",
901
+ value: function printMultiLineObject(type, source, obj) {
902
+ this.out.apply(this, ["%c(".concat(type, ")-> %c%c").concat(this.name, "%c::%c").concat(source, "%c(").concat(Object.keys(obj).join(", "), ") %c\u2193")].concat(this.defaultStyle));
903
+ for (var key in obj) {
904
+ var value = obj[key];
905
+ if (_typeof(value) === "object") {
906
+ value = JSON.stringify(this.useWrapper(value), getCircularReplacer());
907
+ } else if (typeof obj[key] == "function") {
908
+ value = Logger.getFunctionView(value);
909
+ }
910
+ this.out.apply(this, ["%c" + key + ": `" + this.useWrapper(value) + "`", "color: #a3a3a3"]);
911
+ }
912
+ }
913
+ /**
914
+ * Function getRandomColor() : Return random color.
915
+ */
916
+ }, {
917
+ key: "getRandomColor",
918
+ value: function getRandomColor() {
919
+ var letters = "0123456789ABCDEF";
920
+ var color = "#";
921
+ for (var i = 0; i < 6; i++) {
922
+ color += letters[Math.floor(Math.random() * 16)];
923
+ }
924
+ var similar = Logger.colorsInUse.some(function (value) {
925
+ // it returns the ratio of difference... closer to 1.0 is less difference.
926
+ return hexColorDelta(color, value) >= 0.8;
927
+ });
928
+ // if the color is similar, try again.
929
+ if (similar) {
930
+ return this.getRandomColor();
931
+ }
932
+ return color;
933
+ }
934
+ /**
935
+ * Function out() : Print console log with style
936
+ */
937
+ }, {
938
+ key: "out",
939
+ value: function out() {
940
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
941
+ args[_key] = arguments[_key];
942
+ }
943
+ this.outputHandler.apply(this, args);
944
+ }
945
+ }], [{
946
+ key: "getName",
947
+ value: function getName() {
948
+ return 'Core/Modules/Logger';
949
+ }
950
+ /**
951
+ * Function reset() : Reset logger globals.
952
+ */
953
+ }, {
954
+ key: "reset",
955
+ value: function reset() {
956
+ Logger.wrappers = {};
957
+ Logger.wrapperDepth = 0;
958
+ Logger.colorsInUse = [];
959
+ Logger.sharedData = {};
960
+ }
961
+ /**
962
+ * Function createCustomWrapper() : Creates custom wrapper for log entities.
963
+ */
964
+ }, {
965
+ key: "createCustomWrapper",
966
+ value: function createCustomWrapper(classType, callback) {
967
+ // @ts-ignore
968
+ if (!Logger.wrappers[classType]) {
969
+ // @ts-ignore
970
+ Logger.wrappers[classType.name] = [];
971
+ }
972
+ // @ts-ignore
973
+ Logger.wrappers[classType.name].push({
974
+ classType: classType,
975
+ callback: callback
976
+ });
977
+ }
978
+ /**
979
+ * Function getCallerName() : Return caller name.
980
+ */
981
+ }, {
982
+ key: "getCallerName",
983
+ value: function getCallerName() {
984
+ var _error$stack;
985
+ var error = new Error(),
986
+ errorsPerLine = ((_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : _error$stack.split("\n")) || [],
987
+ caller = errorsPerLine.length ? errorsPerLine[STACK_BACKWARD_CALLER_INDEX].trim() : UNKNOWN_CALLER_NAME;
988
+ if (caller.startsWith("at new")) {
989
+ return "constructor";
990
+ }
991
+ var extractName = caller.split(".")[1].split(" ")[0],
992
+ isBabelAsyncRuntime = false;
993
+ // Babel compatibility.
994
+ if (extractName.includes('_callee')) {
995
+ var _loop = function _loop() {
996
+ var line = errorsPerLine[i];
997
+ var isExcluded = BABEL_EXCLUDE_FUNCTIONS_NAMES.some(function (excludeName) {
998
+ return line.includes(excludeName);
999
+ });
1000
+ if (!isExcluded) {
1001
+ var format = line.trim().split(' ');
1002
+ if (format.length <= 2) {
1003
+ return "continue";
1004
+ }
1005
+ extractName = format[1].split(".")[1];
1006
+ isBabelAsyncRuntime = true;
1007
+ return "break";
1008
+ }
1009
+ };
1010
+ // Run till find reliable function name.
1011
+ for (var i = STACK_BACKWARD_CALLER_INDEX; i < errorsPerLine.length; i++) {
1012
+ var _ret = _loop();
1013
+ if (_ret === "continue") continue;
1014
+ if (_ret === "break") break;
1015
+ }
1016
+ if (!isBabelAsyncRuntime) {
1017
+ extractName = UNKNOWN_CALLER_NAME;
1018
+ }
1019
+ }
1020
+ return extractName;
1021
+ }
1022
+ /**
1023
+ * Function functionView() : Return function preview.
1024
+ */
1025
+ }, {
1026
+ key: "getFunctionView",
1027
+ value: function getFunctionView(fn) {
1028
+ var fReturn = UNKNOWN_CALLER_NAME;
1029
+ // TODO: Check if works.
1030
+ if (typeof fn !== "string" && fn.name.length !== 0) {
1031
+ fReturn = fn.name.split(" ")[1] + "()";
1032
+ }
1033
+ return fReturn;
1034
+ }
1035
+ }]);
1036
+ return Logger;
1037
+ }();
1038
+ _defineProperty(Logger, "wrappers", {});
1039
+ _defineProperty(Logger, "wrapperDepth", 0);
1040
+ _defineProperty(Logger, "sharedData", {});
1041
+ _defineProperty(Logger, "colorsInUse", []);
1042
+
1043
+ var index$5 = /*#__PURE__*/Object.freeze({
1044
+ __proto__: null,
1045
+ Logger: Logger
1046
+ });
1047
+
1048
+ var CommandAlreadyRegistered = /*#__PURE__*/function (_Error) {
1049
+ _inherits(CommandAlreadyRegistered, _Error);
1050
+ var _super = _createSuper(CommandAlreadyRegistered);
1051
+ function CommandAlreadyRegistered(command) {
1052
+ _classCallCheck(this, CommandAlreadyRegistered);
1053
+ return _super.call(this, "Command: '".concat(command.getName(), "' is already registered"));
1054
+ }
1055
+ return _createClass(CommandAlreadyRegistered);
1056
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
1057
+
1058
+ /**
1059
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1060
+ */
1061
+ var CommandNotFound = /*#__PURE__*/function (_Error) {
1062
+ _inherits(CommandNotFound, _Error);
1063
+ var _super = _createSuper(CommandNotFound);
1064
+ function CommandNotFound(command) {
1065
+ _classCallCheck(this, CommandNotFound);
1066
+ return _super.call(this, "Command: '".concat(command, "' is not found"));
1067
+ }
1068
+ return _createClass(CommandNotFound);
1069
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
1070
+
1071
+ var ControllerAlreadyRegistered = /*#__PURE__*/function (_Error) {
1072
+ _inherits(ControllerAlreadyRegistered, _Error);
1073
+ var _super = _createSuper(ControllerAlreadyRegistered);
1074
+ function ControllerAlreadyRegistered(controller) {
1075
+ _classCallCheck(this, ControllerAlreadyRegistered);
1076
+ return _super.call(this, "Controller: '".concat(controller.getName(), "' is already registered"));
1077
+ }
1078
+ return _createClass(ControllerAlreadyRegistered);
1079
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
1080
+
1081
+ var ForceMethodBase = /*#__PURE__*/function (_Error) {
1082
+ _inherits(ForceMethodBase, _Error);
1083
+ var _super = _createSuper(ForceMethodBase);
1084
+ function ForceMethodBase(className, methodName) {
1085
+ _classCallCheck(this, ForceMethodBase);
1086
+ return _super.call(this, "ForeMethod implementation: at '".concat(className, "' method: '").concat(methodName, "'"));
1087
+ }
1088
+ return _createClass(ForceMethodBase);
1089
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
1090
+ var ForceMethod = /*#__PURE__*/function (_Error2) {
1091
+ _inherits(ForceMethod, _Error2);
1092
+ var _super2 = _createSuper(ForceMethod);
1093
+ function ForceMethod(context, methodName) {
1094
+ _classCallCheck(this, ForceMethod);
1095
+ return _super2.call(this, "ForeMethod implementation: at '".concat(context.getName(), "' method: '").concat(methodName, "'"));
1096
+ }
1097
+ return _createClass(ForceMethod);
1098
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
1099
+
1100
+ var index$4 = /*#__PURE__*/Object.freeze({
1101
+ __proto__: null,
1102
+ CommandAlreadyRegistered: CommandAlreadyRegistered,
1103
+ CommandNotFound: CommandNotFound,
1104
+ ControllerAlreadyRegistered: ControllerAlreadyRegistered,
1105
+ ForceMethod: ForceMethod
1106
+ });
1107
+
1108
+ var IdCounter = 0;
1109
+ /**
1110
+ * Base class 4 *
1111
+ */
1112
+ var ObjectBase = /*#__PURE__*/function () {
1113
+ function ObjectBase() {
1114
+ _classCallCheck(this, ObjectBase);
1115
+ _defineProperty(this, "virtualId", 0);
1116
+ this.virtualId = IdCounter;
1117
+ APIIncreaseIdCounter();
1118
+ }
1119
+ _createClass(ObjectBase, [{
1120
+ key: "getName",
1121
+ value: function getName() {
1122
+ return this.constructor.getName();
1123
+ }
1124
+ }], [{
1125
+ key: "getName",
1126
+ value: function getName() {
1127
+ throw new ForceMethodBase("ObjectBase", "getName");
1128
+ }
1129
+ }]);
1130
+ return ObjectBase;
1131
+ }();
1132
+ function APIIncreaseIdCounter() {
1133
+ return IdCounter++;
1134
+ }
1135
+
1136
+ var Commands = /*#__PURE__*/function (_ObjectBase) {
1137
+ _inherits(Commands, _ObjectBase);
1138
+ var _super = _createSuper(Commands);
1139
+ function Commands() {
1140
+ var _this;
1141
+ _classCallCheck(this, Commands);
1142
+ _this = _super.call(this);
1143
+ _defineProperty(_assertThisInitialized(_this), "current", {});
1144
+ _defineProperty(_assertThisInitialized(_this), "currentArgs", {});
1145
+ _defineProperty(_assertThisInitialized(_this), "trace", []);
1146
+ _defineProperty(_assertThisInitialized(_this), "commands", {});
1147
+ _defineProperty(_assertThisInitialized(_this), "onBeforeHooks", {});
1148
+ _defineProperty(_assertThisInitialized(_this), "onBeforeUIHooks", {});
1149
+ _defineProperty(_assertThisInitialized(_this), "onAfterHooks", {});
1150
+ _defineProperty(_assertThisInitialized(_this), "onAfterOnceHooks", {});
1151
+ _defineProperty(_assertThisInitialized(_this), "onAfterUIHooks", {});
1152
+ _defineProperty(_assertThisInitialized(_this), "onAfterAffectHooks", {});
1153
+ _this.logger = new Logger(_this.getName(), true);
1154
+ _this.logger.startEmpty();
1155
+ return _this;
1156
+ }
1157
+ _createClass(Commands, [{
1158
+ key: "run",
1159
+ value: function () {
1160
+ var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(command) {
1161
+ var args,
1162
+ options,
1163
+ result,
1164
+ _args = arguments;
1165
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1166
+ while (1) switch (_context.prev = _context.next) {
1167
+ case 0:
1168
+ args = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
1169
+ options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
1170
+ if (typeof command === "string") {
1171
+ command = this.getCommandInstance(command, args, options);
1172
+ }
1173
+ this.attachCurrent(command, args);
1174
+ _context.next = 6;
1175
+ return this.runInstance(command, args, options);
1176
+ case 6:
1177
+ result = _context.sent;
1178
+ this.detachCurrent(command);
1179
+ return _context.abrupt("return", result);
1180
+ case 9:
1181
+ case "end":
1182
+ return _context.stop();
1183
+ }
1184
+ }, _callee, this);
1185
+ }));
1186
+ function run(_x) {
1187
+ return _run.apply(this, arguments);
1188
+ }
1189
+ return run;
1190
+ }()
1191
+ }, {
1192
+ key: "register",
1193
+ value: function register(commands, controller) {
1194
+ var _this2 = this;
1195
+ var result = {};
1196
+ Object.values(commands).forEach(function (command) {
1197
+ var commandName = command.getName();
1198
+ if (_this2.commands[commandName]) {
1199
+ throw new CommandAlreadyRegistered(command);
1200
+ }
1201
+ _this2.commands[commandName] = command;
1202
+ result[commandName] = command;
1203
+ });
1204
+ return result;
1205
+ }
1206
+ }, {
1207
+ key: "getAll",
1208
+ value: function getAll() {
1209
+ return this.commands;
1210
+ }
1211
+ }, {
1212
+ key: "getByName",
1213
+ value: function getByName(name) {
1214
+ return this.commands[name];
1215
+ }
1216
+ }, {
1217
+ key: "getLogger",
1218
+ value: function getLogger() {
1219
+ return this.logger;
1220
+ }
1221
+ }, {
1222
+ key: "getCommandInstance",
1223
+ value: function getCommandInstance(name) {
1224
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1225
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1226
+ var CommandClass = this.commands[name];
1227
+ if (!CommandClass) {
1228
+ throw new CommandNotFound(name);
1229
+ }
1230
+ // @ts-ignore
1231
+ return new CommandClass(args, options);
1232
+ }
1233
+ /**
1234
+ * Function onBefore() : Used to set hooks that effects only data and not UI.
1235
+ */
1236
+ }, {
1237
+ key: "onBefore",
1238
+ value: function onBefore(hookCommand, callback) {
1239
+ Commands.hookCommand(this.onBeforeHooks, hookCommand, callback);
1240
+ }
1241
+ /**
1242
+ * Function onBeforeUI() : Used to set hooks that effects only UI.
1243
+ */
1244
+ }, {
1245
+ key: "onBeforeUI",
1246
+ value: function onBeforeUI(hookCommand, callback) {
1247
+ Commands.hookCommand(this.onBeforeUIHooks, hookCommand, callback);
1248
+ }
1249
+ /**
1250
+ * Function onAfter() : Used to set hooks that effects only data and not UI.
1251
+ */
1252
+ }, {
1253
+ key: "onAfter",
1254
+ value: function onAfter(hookCommand, callback) {
1255
+ Commands.hookCommand(this.onAfterHooks, hookCommand, callback);
1256
+ }
1257
+ /**
1258
+ * Function onAfterUI() : Used to set hooks that effects only UI.
1259
+ */
1260
+ }, {
1261
+ key: "onAfterUI",
1262
+ value: function onAfterUI(command, callback) {
1263
+ Commands.hookCommand(this.onAfterUIHooks, command, callback);
1264
+ }
1265
+ /**
1266
+ * Function onAfterOnce() : Used to set hooks that effects only data and not UI.
1267
+ */
1268
+ }, {
1269
+ key: "onAfterOnce",
1270
+ value: function onAfterOnce(command, callback) {
1271
+ Commands.hookCommand(this.onAfterOnceHooks, command, callback);
1272
+ }
1273
+ /**
1274
+ * Function onAfterAffect() : Used to register a trigger that runs command after `hookCommand` run's.
1275
+ */
1276
+ }, {
1277
+ key: "onAfterAffect",
1278
+ value: function onAfterAffect(hookCommand, affectCommand) {
1279
+ Commands.hookCommand(this.onAfterAffectHooks, hookCommand, affectCommand);
1280
+ }
1281
+ }, {
1282
+ key: "onBeforeRun",
1283
+ value: function onBeforeRun(command) {
1284
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1285
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1286
+ if (this.onBeforeHooks[command.getName()]) {
1287
+ var callbacks = this.onBeforeHooks[command.getName()];
1288
+ callbacks.forEach(function (callback) {
1289
+ return callback(args, options);
1290
+ });
1291
+ }
1292
+ if (this.onBeforeUIHooks[command.getName()]) {
1293
+ var _callbacks = this.onBeforeUIHooks[command.getName()];
1294
+ _callbacks.forEach(function (callback) {
1295
+ return callback(args, options);
1296
+ });
1297
+ }
1298
+ }
1299
+ }, {
1300
+ key: "runInstance",
1301
+ value: function () {
1302
+ var _runInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(command) {
1303
+ var args,
1304
+ options,
1305
+ result,
1306
+ _args2 = arguments;
1307
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1308
+ while (1) switch (_context2.prev = _context2.next) {
1309
+ case 0:
1310
+ args = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
1311
+ options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
1312
+ result = null; // TODO: Maybe a logger method to handle such cases.
1313
+ if (Object.keys(args).length) {
1314
+ this.logger.startWith({
1315
+ command: command.getName(),
1316
+ options: options,
1317
+ CommandArgs: "->"
1318
+ });
1319
+ this.logger.debug("CommandArgs:");
1320
+ this.logger.object(args);
1321
+ } else {
1322
+ this.logger.startWith({
1323
+ command: command.getName(),
1324
+ options: options,
1325
+ args: args
1326
+ });
1327
+ }
1328
+ this.onBeforeRun(command, args, options);
1329
+ _context2.next = 7;
1330
+ return command.run();
1331
+ case 7:
1332
+ result = _context2.sent;
1333
+ _context2.next = 10;
1334
+ return this.onAfterRun(command, args, options, result);
1335
+ case 10:
1336
+ return _context2.abrupt("return", result);
1337
+ case 11:
1338
+ case "end":
1339
+ return _context2.stop();
1340
+ }
1341
+ }, _callee2, this);
1342
+ }));
1343
+ function runInstance(_x2) {
1344
+ return _runInstance.apply(this, arguments);
1345
+ }
1346
+ return runInstance;
1347
+ }()
1348
+ }, {
1349
+ key: "onAfterRun",
1350
+ value: function () {
1351
+ var _onAfterRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(command, args, options, result) {
1352
+ var _this3 = this;
1353
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1354
+ while (1) switch (_context3.prev = _context3.next) {
1355
+ case 0:
1356
+ options = Object.assign({}, options);
1357
+ if (!this.onAfterAffectHooks[command.getName()]) {
1358
+ _context3.next = 6;
1359
+ break;
1360
+ }
1361
+ this.onAfterAffectHooks[command.getName()].forEach(function (command) {
1362
+ args.result = result;
1363
+ result = _this3.run(command.toString(), args, options);
1364
+ });
1365
+ _context3.next = 5;
1366
+ return result;
1367
+ case 5:
1368
+ result = _context3.sent;
1369
+ case 6:
1370
+ if (!this.onAfterHooks) {
1371
+ _context3.next = 10;
1372
+ break;
1373
+ }
1374
+ args.result = result;
1375
+ _context3.next = 10;
1376
+ return Commands.runCallbacks(Object.assign([], this.onAfterHooks[command.getName()]), args, options);
1377
+ case 10:
1378
+ if (!this.onAfterOnceHooks) {
1379
+ _context3.next = 13;
1380
+ break;
1381
+ }
1382
+ _context3.next = 13;
1383
+ return Commands.runCallbacks(this.onAfterOnceHooks[command.getName()], args, _objectSpread2(_objectSpread2({}, options), {}, {
1384
+ pop: true // Delete after run.
1385
+ }));
1386
+ case 13:
1387
+ if (this.onAfterUIHooks) {
1388
+ Commands.runCallbacks(Object.assign([], this.onAfterUIHooks[command.getName()]), args, options);
1389
+ }
1390
+ return _context3.abrupt("return", result);
1391
+ case 15:
1392
+ case "end":
1393
+ return _context3.stop();
1394
+ }
1395
+ }, _callee3, this);
1396
+ }));
1397
+ function onAfterRun(_x3, _x4, _x5, _x6) {
1398
+ return _onAfterRun.apply(this, arguments);
1399
+ }
1400
+ return onAfterRun;
1401
+ }()
1402
+ }, {
1403
+ key: "attachCurrent",
1404
+ value: function attachCurrent(command) {
1405
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1406
+ this.current[command.getName()] = command;
1407
+ this.currentArgs[command.getName()] = args;
1408
+ this.trace.push(command.getName());
1409
+ Commands.trace.push(command.getName());
1410
+ }
1411
+ }, {
1412
+ key: "detachCurrent",
1413
+ value: function detachCurrent(command) {
1414
+ delete this.current[command.getName()];
1415
+ delete this.currentArgs[command.getName()];
1416
+ Commands.trace.pop();
1417
+ this.trace.pop();
1418
+ }
1419
+ }], [{
1420
+ key: "getName",
1421
+ value: function getName() {
1422
+ return 'Core/Managers/Commands';
1423
+ }
1424
+ }, {
1425
+ key: "runCallbacks",
1426
+ value: function () {
1427
+ var _runCallbacks = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(callbacks) {
1428
+ var args,
1429
+ options,
1430
+ callbacksLength,
1431
+ i,
1432
+ callback,
1433
+ _args4 = arguments;
1434
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1435
+ while (1) switch (_context4.prev = _context4.next) {
1436
+ case 0:
1437
+ args = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
1438
+ options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
1439
+ callbacksLength = (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length) || 0;
1440
+ i = 0;
1441
+ case 4:
1442
+ if (!(i < callbacksLength)) {
1443
+ _context4.next = 13;
1444
+ break;
1445
+ }
1446
+ callback = options.pop === true ? callbacks.pop() : callbacks[i];
1447
+ if (callback) {
1448
+ _context4.next = 8;
1449
+ break;
1450
+ }
1451
+ throw new Error("Callback is not defined.");
1452
+ case 8:
1453
+ _context4.next = 10;
1454
+ return callback(args, options);
1455
+ case 10:
1456
+ ++i;
1457
+ _context4.next = 4;
1458
+ break;
1459
+ case 13:
1460
+ case "end":
1461
+ return _context4.stop();
1462
+ }
1463
+ }, _callee4);
1464
+ }));
1465
+ function runCallbacks(_x7) {
1466
+ return _runCallbacks.apply(this, arguments);
1467
+ }
1468
+ return runCallbacks;
1469
+ }()
1470
+ }, {
1471
+ key: "hookCommand",
1472
+ value: function hookCommand(stack, _hookCommand, context) {
1473
+ if (!stack[_hookCommand]) {
1474
+ stack[_hookCommand] = [];
1475
+ }
1476
+ stack[_hookCommand].push(context);
1477
+ }
1478
+ }]);
1479
+ return Commands;
1480
+ }(ObjectBase);
1481
+ _defineProperty(Commands, "trace", []);
1482
+
1483
+ var Controllers = /*#__PURE__*/function (_ObjectBase) {
1484
+ _inherits(Controllers, _ObjectBase);
1485
+ var _super = _createSuper(Controllers);
1486
+ function Controllers() {
1487
+ var _this;
1488
+ _classCallCheck(this, Controllers);
1489
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1490
+ args[_key] = arguments[_key];
1491
+ }
1492
+ _this = _super.call.apply(_super, [this].concat(args));
1493
+ _defineProperty(_assertThisInitialized(_this), "controllers", {});
1494
+ return _this;
1495
+ }
1496
+ _createClass(Controllers, [{
1497
+ key: "get",
1498
+ value: function get(name) {
1499
+ return this.controllers[name];
1500
+ }
1501
+ }, {
1502
+ key: "getAll",
1503
+ value: function getAll() {
1504
+ return this.controllers;
1505
+ }
1506
+ }, {
1507
+ key: "register",
1508
+ value: function register(controller) {
1509
+ if (this.controllers[controller.getName()]) {
1510
+ throw new ControllerAlreadyRegistered(controller);
1511
+ }
1512
+ // Register.
1513
+ this.controllers[controller.getName()] = controller;
1514
+ return controller;
1515
+ }
1516
+ }], [{
1517
+ key: "getName",
1518
+ value: function getName() {
1519
+ return 'Core/Managers/Controllers';
1520
+ }
1521
+ }]);
1522
+ return Controllers;
1523
+ }(ObjectBase);
1524
+
1525
+ /**
1526
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1527
+ */
1528
+ var HTTPMethodEnum;
1529
+ (function (HTTPMethodEnum) {
1530
+ HTTPMethodEnum["DELETE"] = "DELETE";
1531
+ HTTPMethodEnum["GET"] = "GET";
1532
+ HTTPMethodEnum["OPTIONS"] = "OPTIONS";
1533
+ HTTPMethodEnum["PATCH"] = "PATCH";
1534
+ HTTPMethodEnum["POST"] = "POST";
1535
+ HTTPMethodEnum["PUT"] = "PUT";
1536
+ HTTPMethodEnum["__EMPTY__"] = "";
1537
+ })(HTTPMethodEnum || (HTTPMethodEnum = {}));
1538
+
1539
+ var Http = /*#__PURE__*/function (_ObjectBase) {
1540
+ _inherits(Http, _ObjectBase);
1541
+ var _super = _createSuper(Http);
1542
+ /**
1543
+ * Function constructor() : Create the http.
1544
+ */
1545
+ function Http() {
1546
+ var _this;
1547
+ var apiBaseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'http://localhost';
1548
+ _classCallCheck(this, Http);
1549
+ _this = _super.call(this);
1550
+ _this.logger = new Logger(Http.getName(), true);
1551
+ _this.logger.startWith({
1552
+ apiBaseUrl: apiBaseUrl
1553
+ });
1554
+ _this.apiBaseUrl = apiBaseUrl + '/';
1555
+ return _this;
1556
+ }
1557
+ /**
1558
+ * Function fetch() : Fetch api.
1559
+ */
1560
+ _createClass(Http, [{
1561
+ key: "fetch",
1562
+ value: function () {
1563
+ var _fetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, method) {
1564
+ var _data, _data2, _data3;
1565
+ var body,
1566
+ params,
1567
+ headers,
1568
+ response,
1569
+ data,
1570
+ _args = arguments;
1571
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1572
+ while (1) switch (_context.prev = _context.next) {
1573
+ case 0:
1574
+ body = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
1575
+ this.logger.startWith({
1576
+ path: path,
1577
+ method: method,
1578
+ body: body
1579
+ });
1580
+ params = {
1581
+ 'credentials': 'include'
1582
+ }, headers = {};
1583
+ if ([HTTPMethodEnum.POST, HTTPMethodEnum.PUT, HTTPMethodEnum.PATCH].includes(method)) {
1584
+ Object.assign(headers, {
1585
+ 'Content-Type': 'application/json'
1586
+ });
1587
+ Object.assign(params, {
1588
+ method: method,
1589
+ headers: headers,
1590
+ body: JSON.stringify(body)
1591
+ });
1592
+ } else {
1593
+ Object.assign(params, {
1594
+ headers: headers
1595
+ });
1596
+ }
1597
+ _context.next = 6;
1598
+ return globalThis.fetch(this.apiBaseUrl + path, params);
1599
+ case 6:
1600
+ response = _context.sent;
1601
+ data = undefined;
1602
+ _context.prev = 8;
1603
+ _context.next = 11;
1604
+ return response.json();
1605
+ case 11:
1606
+ data = _context.sent;
1607
+ _context.next = 18;
1608
+ break;
1609
+ case 14:
1610
+ _context.prev = 14;
1611
+ _context.t0 = _context["catch"](8);
1612
+ console.error(_context.t0);
1613
+ return _context.abrupt("return", false);
1614
+ case 18:
1615
+ if (!((_data = data) !== null && _data !== void 0 && _data.error && (_data2 = data) !== null && _data2 !== void 0 && _data2.global && (_data3 = data) !== null && _data3 !== void 0 && _data3.message)) {
1616
+ _context.next = 20;
1617
+ break;
1618
+ }
1619
+ throw new Error(data.message);
1620
+ case 20:
1621
+ this.logger.drop({
1622
+ path: path
1623
+ }, data);
1624
+ return _context.abrupt("return", data);
1625
+ case 22:
1626
+ case "end":
1627
+ return _context.stop();
1628
+ }
1629
+ }, _callee, this, [[8, 14]]);
1630
+ }));
1631
+ function fetch(_x, _x2) {
1632
+ return _fetch.apply(this, arguments);
1633
+ }
1634
+ return fetch;
1635
+ }()
1636
+ }], [{
1637
+ key: "getName",
1638
+ value: function getName() {
1639
+ return 'Core/Clients/Http';
1640
+ }
1641
+ }]);
1642
+ return Http;
1643
+ }(ObjectBase);
1644
+
1645
+ var Data = /*#__PURE__*/function (_Commands) {
1646
+ _inherits(Data, _Commands);
1647
+ var _super = _createSuper(Data);
1648
+ function Data(Config) {
1649
+ var _this;
1650
+ _classCallCheck(this, Data);
1651
+ _this = _super.call(this);
1652
+ // @ts-ignore
1653
+ Data.client = new Http(Config.baseURL);
1654
+ return _this;
1655
+ }
1656
+ _createClass(Data, [{
1657
+ key: "getClient",
1658
+ value: function getClient() {
1659
+ return Data.client;
1660
+ }
1661
+ }, {
1662
+ key: "get",
1663
+ value: function get(command) {
1664
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1665
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1666
+ this.currentHttpMethod = HTTPMethodEnum.GET;
1667
+ return _get(_getPrototypeOf(Data.prototype), "run", this).call(this, command, args, options);
1668
+ }
1669
+ }, {
1670
+ key: "update",
1671
+ value: function update(command) {
1672
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1673
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1674
+ this.currentHttpMethod = HTTPMethodEnum.PATCH;
1675
+ return _get(_getPrototypeOf(Data.prototype), "run", this).call(this, command, args, options);
1676
+ }
1677
+ }, {
1678
+ key: "delete",
1679
+ value: function _delete(command) {
1680
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1681
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1682
+ this.currentHttpMethod = HTTPMethodEnum.DELETE;
1683
+ return _get(_getPrototypeOf(Data.prototype), "run", this).call(this, command, args, options);
1684
+ }
1685
+ }, {
1686
+ key: "create",
1687
+ value: function create(command) {
1688
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1689
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1690
+ this.currentHttpMethod = HTTPMethodEnum.POST;
1691
+ return _get(_getPrototypeOf(Data.prototype), "run", this).call(this, command, args, options);
1692
+ }
1693
+ }, {
1694
+ key: "runInstance",
1695
+ value: function () {
1696
+ var _runInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(command) {
1697
+ var args,
1698
+ options,
1699
+ newArgs,
1700
+ _args = arguments;
1701
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1702
+ while (1) switch (_context.prev = _context.next) {
1703
+ case 0:
1704
+ args = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
1705
+ options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
1706
+ if (this.currentHttpMethod) {
1707
+ _context.next = 4;
1708
+ break;
1709
+ }
1710
+ throw new Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');
1711
+ case 4:
1712
+ // New args.
1713
+ newArgs = {
1714
+ type: this.currentHttpMethod,
1715
+ args: {
1716
+ query: {},
1717
+ data: {}
1718
+ }
1719
+ };
1720
+ if (HTTPMethodEnum.GET === this.currentHttpMethod) {
1721
+ newArgs.args.query = args;
1722
+ } else {
1723
+ newArgs.args.data = args;
1724
+ }
1725
+ _context.next = 8;
1726
+ return _get(_getPrototypeOf(Data.prototype), "runInstance", this).call(this, command, newArgs, options);
1727
+ case 8:
1728
+ args.result = _context.sent;
1729
+ // Clear method type.
1730
+ this.currentHttpMethod = HTTPMethodEnum.__EMPTY__;
1731
+ return _context.abrupt("return", args.result);
1732
+ case 11:
1733
+ case "end":
1734
+ return _context.stop();
1735
+ }
1736
+ }, _callee, this);
1737
+ }));
1738
+ function runInstance(_x) {
1739
+ return _runInstance.apply(this, arguments);
1740
+ }
1741
+ return runInstance;
1742
+ }()
1743
+ }], [{
1744
+ key: "getName",
1745
+ value: function getName() {
1746
+ return 'Core/Managers/Data';
1747
+ }
1748
+ }]);
1749
+ return Data;
1750
+ }(Commands);
1751
+
1752
+ var Internal = /*#__PURE__*/function (_Commands) {
1753
+ _inherits(Internal, _Commands);
1754
+ var _super = _createSuper(Internal);
1755
+ function Internal() {
1756
+ _classCallCheck(this, Internal);
1757
+ return _super.apply(this, arguments);
1758
+ }
1759
+ _createClass(Internal, null, [{
1760
+ key: "getName",
1761
+ value: function getName() {
1762
+ return 'Core/Managers/Internal';
1763
+ }
1764
+ }]);
1765
+ return Internal;
1766
+ }(Commands);
1767
+
1768
+ /**
1769
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1770
+ */
1771
+ var afterInitializeCallbacks = [];
1772
+ function initialize(config) {
1773
+ commands = new Commands();
1774
+ controllers = new Controllers();
1775
+ data = new Data(config);
1776
+ internal = new Internal();
1777
+ }
1778
+ function destroy() {
1779
+ commands = {};
1780
+ controllers = {};
1781
+ data = {};
1782
+ internal = {};
1783
+ }
1784
+ var commands = {};
1785
+ var controllers = {};
1786
+ var data = {};
1787
+ var internal = {};
1788
+
1789
+ var index$3 = /*#__PURE__*/Object.freeze({
1790
+ __proto__: null,
1791
+ afterInitializeCallbacks: afterInitializeCallbacks,
1792
+ get commands () { return commands; },
1793
+ get controllers () { return controllers; },
1794
+ get data () { return data; },
1795
+ destroy: destroy,
1796
+ initialize: initialize,
1797
+ get internal () { return internal; }
1798
+ });
1799
+
1800
+ var CommandBase = /*#__PURE__*/function (_ObjectBase) {
1801
+ _inherits(CommandBase, _ObjectBase);
1802
+ var _super = _createSuper(CommandBase);
1803
+ function CommandBase() {
1804
+ var _this;
1805
+ var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1806
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1807
+ _classCallCheck(this, CommandBase);
1808
+ _this = _super.call(this);
1809
+ _defineProperty(_assertThisInitialized(_this), "args", {});
1810
+ _defineProperty(_assertThisInitialized(_this), "options", {});
1811
+ var name = _this.constructor.getName();
1812
+ _this.logger = new Logger(name, true, {
1813
+ sameColor: true
1814
+ });
1815
+ _this.logger.startWith({
1816
+ args: args,
1817
+ options: options
1818
+ });
1819
+ _this.initialize(args, options);
1820
+ return _this;
1821
+ }
1822
+ _createClass(CommandBase, [{
1823
+ key: "initialize",
1824
+ value: function initialize(args, options) {
1825
+ this.args = args;
1826
+ this.options = options;
1827
+ }
1828
+ }, {
1829
+ key: "apply",
1830
+ value: function apply() {
1831
+ arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
1832
+ arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options;
1833
+ throw new ForceMethod(this, "apply");
1834
+ }
1835
+ }, {
1836
+ key: "run",
1837
+ value: function () {
1838
+ var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1839
+ var result;
1840
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1841
+ while (1) switch (_context.prev = _context.next) {
1842
+ case 0:
1843
+ this.onBeforeApply && this.onBeforeApply();
1844
+ _context.next = 3;
1845
+ return this.apply(this.args, this.options);
1846
+ case 3:
1847
+ result = _context.sent;
1848
+ this.onAfterApply && this.onAfterApply();
1849
+ return _context.abrupt("return", result);
1850
+ case 6:
1851
+ case "end":
1852
+ return _context.stop();
1853
+ }
1854
+ }, _callee, this);
1855
+ }));
1856
+ function run() {
1857
+ return _run.apply(this, arguments);
1858
+ }
1859
+ return run;
1860
+ }()
1861
+ }, {
1862
+ key: "getArgs",
1863
+ value: function getArgs() {
1864
+ return this.args;
1865
+ }
1866
+ }, {
1867
+ key: "getOptions",
1868
+ value: function getOptions() {
1869
+ return this.options;
1870
+ }
1871
+ }]);
1872
+ return CommandBase;
1873
+ }(ObjectBase);
1874
+
1875
+ var CommandPublic = /*#__PURE__*/function (_CommandBase) {
1876
+ _inherits(CommandPublic, _CommandBase);
1877
+ var _super = _createSuper(CommandPublic);
1878
+ function CommandPublic() {
1879
+ _classCallCheck(this, CommandPublic);
1880
+ return _super.apply(this, arguments);
1881
+ }
1882
+ _createClass(CommandPublic, null, [{
1883
+ key: "getName",
1884
+ value: function getName() {
1885
+ return 'Core/CommandBases/CommandPublic';
1886
+ }
1887
+ }]);
1888
+ return CommandPublic;
1889
+ }(CommandBase);
1890
+
1891
+ var CommandData = /*#__PURE__*/function (_CommandBase) {
1892
+ _inherits(CommandData, _CommandBase);
1893
+ var _super = _createSuper(CommandData);
1894
+ function CommandData() {
1895
+ _classCallCheck(this, CommandData);
1896
+ return _super.apply(this, arguments);
1897
+ }
1898
+ _createClass(CommandData, [{
1899
+ key: "getEndpoint",
1900
+ value:
1901
+ /**
1902
+ * Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
1903
+ * @example
1904
+ * ```
1905
+ * args = { query: { id: 1 } };
1906
+ * getEndpoint() = '/api/v1/users/{id}';
1907
+ * result = '/api/v1/users/1';
1908
+ * ```
1909
+ */
1910
+ function getEndpoint() {
1911
+ throw new ForceMethod(this, 'getEndpoint');
1912
+ }
1913
+ }, {
1914
+ key: "apply",
1915
+ value: function apply() {
1916
+ var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
1917
+ arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options;
1918
+ var endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
1919
+ return data.getClient().fetch(endpoint, data.currentHttpMethod, args || null);
1920
+ }
1921
+ }, {
1922
+ key: "applyEndpointFormat",
1923
+ value: function applyEndpointFormat(endpoint) {
1924
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1925
+ // Replace query with `magic` placeholders.
1926
+ if (endpoint.includes('{')) {
1927
+ endpoint = endpoint.split('/').map(function (endpointPart) {
1928
+ var match = endpointPart.match('\\{(.*?)\\}');
1929
+ if (match !== null && match !== void 0 && match.length && 'undefined' !== typeof data[match[1]]) {
1930
+ return data[match[1]];
1931
+ }
1932
+ return endpointPart;
1933
+ }).join('/');
1934
+ }
1935
+ return endpoint;
1936
+ }
1937
+ }], [{
1938
+ key: "getName",
1939
+ value: function getName() {
1940
+ return 'Core/CommandBases/CommandData';
1941
+ }
1942
+ }]);
1943
+ return CommandData;
1944
+ }(CommandBase);
1945
+
1946
+ var CommandInternal = /*#__PURE__*/function (_CommandBase) {
1947
+ _inherits(CommandInternal, _CommandBase);
1948
+ var _super = _createSuper(CommandInternal);
1949
+ function CommandInternal() {
1950
+ _classCallCheck(this, CommandInternal);
1951
+ return _super.apply(this, arguments);
1952
+ }
1953
+ _createClass(CommandInternal, null, [{
1954
+ key: "getName",
1955
+ value: function getName() {
1956
+ return 'Core/CommandBases/CommandInternal';
1957
+ }
1958
+ }]);
1959
+ return CommandInternal;
1960
+ }(CommandBase);
1961
+
1962
+ /**
1963
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
1964
+ */
1965
+
1966
+ var index$2 = /*#__PURE__*/Object.freeze({
1967
+ __proto__: null,
1968
+ CommandBase: CommandBase,
1969
+ CommandData: CommandData,
1970
+ CommandInternal: CommandInternal,
1971
+ CommandPublic: CommandPublic
1972
+ });
1973
+
1974
+ var Controller = /*#__PURE__*/function (_ObjectBase) {
1975
+ _inherits(Controller, _ObjectBase);
1976
+ var _super = _createSuper(Controller);
1977
+ function Controller() {
1978
+ var _this;
1979
+ _classCallCheck(this, Controller);
1980
+ _this = _super.call(this);
1981
+ _this.initialize();
1982
+ return _this;
1983
+ }
1984
+ _createClass(Controller, [{
1985
+ key: "initialize",
1986
+ value: function initialize() {
1987
+ this.register();
1988
+ this.setupHooks && this.setupHooks();
1989
+ }
1990
+ }, {
1991
+ key: "register",
1992
+ value: function register() {
1993
+ this.commands = commands.register(this.getCommands(), this);
1994
+ this.data = data.register(this.getData(), this);
1995
+ this.internal = internal.register(this.getInternal(), this);
1996
+ }
1997
+ }, {
1998
+ key: "getCommands",
1999
+ value: function getCommands() {
2000
+ return {};
2001
+ }
2002
+ }, {
2003
+ key: "getData",
2004
+ value: function getData() {
2005
+ return {};
2006
+ }
2007
+ }, {
2008
+ key: "getInternal",
2009
+ value: function getInternal() {
2010
+ return {};
2011
+ }
2012
+ }], [{
2013
+ key: "getName",
2014
+ value: function getName() {
2015
+ return 'Core/Core/Controller';
2016
+ }
2017
+ }]);
2018
+ return Controller;
2019
+ }(ObjectBase);
2020
+
2021
+ var index$1 = /*#__PURE__*/Object.freeze({
2022
+ __proto__: null,
2023
+ Controller: Controller,
2024
+ ObjectBase: ObjectBase
2025
+ });
2026
+
2027
+ /**
2028
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
2029
+ */
2030
+
2031
+ var index = /*#__PURE__*/Object.freeze({
2032
+ __proto__: null,
2033
+ Commands: Commands,
2034
+ Controllers: Controllers,
2035
+ Data: Data,
2036
+ Internal: Internal
2037
+ });
2038
+
2039
+ /**
2040
+ * @author: Leonid Vinikov <leonidvinikov@gmail.com>
2041
+ */
2042
+
2043
+ var exported = /*#__PURE__*/Object.freeze({
2044
+ __proto__: null,
2045
+ commandBases: index$2,
2046
+ core: index$1,
2047
+ errors: index$4,
2048
+ managerBases: index,
2049
+ managers: index$3,
2050
+ modules: index$5,
2051
+ utils: index$6
2052
+ });
2053
+
2054
+ var isInitialized = false;
2055
+ function errorInitTwice() {
2056
+ if (isInitialized) {
2057
+ throw new Error('ZenCore is already initialized.');
2058
+ }
2059
+ }
2060
+ errorInitTwice();
2061
+ var config = {
2062
+ version: version
2063
+ };
2064
+ var CoreAPI = _objectSpread2({
2065
+ initialize: function initialize$1(configuration) {
2066
+ errorInitTwice();
2067
+ config = configuration || config;
2068
+ initialize(config);
2069
+ isInitialized = true;
2070
+ },
2071
+ destroy: function destroy$1() {
2072
+ destroy();
2073
+ isInitialized = false;
2074
+ },
2075
+ onAfterInitialize: function onAfterInitialize(callback) {
2076
+ afterInitializeCallbacks.push(callback);
2077
+ },
2078
+ config: config
2079
+ }, exported);
2080
+ // TODO: Make it available only for development.
2081
+ if (!(globalThis !== null && globalThis !== void 0 && globalThis.ZenCore)) globalThis.ZenCore = CoreAPI;
2082
+
2083
+ export { index$2 as commandBases, index$1 as core, CoreAPI as default, index$4 as errors, index as managerBases, index$3 as managers, index$5 as modules, index$6 as utils };