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