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