@zenflux/core 0.0.0-abc.2 → 0.0.0-abc.24
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 +1989 -874
- package/dist/es/src/exports.d.ts +1 -0
- package/dist/es/src/globals.d.ts +3 -0
- package/dist/es/src/index.d.ts +1 -1
- package/dist/es/src/initializer.d.ts +2 -1
- package/dist/es/src/interfaces/managers.d.ts +13 -0
- package/dist/es/src/manager-bases/commands.d.ts +2 -1
- package/dist/es/src/manager-bases/controllers.d.ts +2 -1
- package/dist/es/src/managers/index.d.ts +12 -8
- package/dist/es/zenflux-core.js +1984 -870
- package/dist/es/zenflux-core.mjs +1 -12
- package/dist/umd/zenflux-core.js +1 -12
- package/package.json +22 -29
- package/src/command-bases/command-data.ts +1 -1
- package/src/core/controller.ts +1 -1
- package/src/exports.ts +1 -1
- package/src/index.ts +2 -1
- package/src/initializer.ts +7 -14
- package/src/interfaces/managers.ts +16 -0
- package/src/manager-bases/commands.ts +3 -1
- package/src/manager-bases/controllers.ts +2 -1
- package/src/managers/index.ts +24 -7
- package/types/index.d.ts +5 -1
package/dist/cjs/zenflux-core.js
CHANGED
|
@@ -2,40 +2,617 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
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;
|
|
9
55
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
});
|
|
13
64
|
}
|
|
65
|
+
return target;
|
|
14
66
|
}
|
|
15
67
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
68
|
+
var name = "@zenflux/core";
|
|
69
|
+
var version = "0.0.0-alpha.0";
|
|
70
|
+
var description = "ZenFlux core";
|
|
71
|
+
var keywords = [
|
|
72
|
+
"zenflux",
|
|
73
|
+
"zen",
|
|
74
|
+
"flux",
|
|
75
|
+
"commands",
|
|
76
|
+
"manager",
|
|
77
|
+
"commands manager",
|
|
78
|
+
"core",
|
|
79
|
+
"zenflux-core"
|
|
80
|
+
];
|
|
81
|
+
var repository = {
|
|
82
|
+
type: "git",
|
|
83
|
+
url: "git+https://github.com/zenflux/core.git"
|
|
84
|
+
};
|
|
85
|
+
var license = "MIT";
|
|
86
|
+
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
87
|
+
var main = "dist/cjs/zenflux-core.js";
|
|
88
|
+
var unpkg = "dist/umd/zenflux-core.js";
|
|
89
|
+
var module$1 = "dist/es/zenflux-core.js";
|
|
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
|
+
};
|
|
103
|
+
var devDependencies = {
|
|
104
|
+
"@babel/preset-env": "^7.20.2",
|
|
105
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
106
|
+
"@types/jest": "^29.2.5",
|
|
107
|
+
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
108
|
+
"@typescript-eslint/parser": "^5.48.0",
|
|
109
|
+
"@zenflux/rollup-toolkit": "^0.0.0-alpha.0",
|
|
110
|
+
"babel-jest": "^29.3.1",
|
|
111
|
+
"ts-jest": "^29.0.3",
|
|
112
|
+
tslib: "^2.4.1"
|
|
113
|
+
};
|
|
114
|
+
var pkg = {
|
|
115
|
+
name: name,
|
|
116
|
+
version: version,
|
|
117
|
+
description: description,
|
|
118
|
+
keywords: keywords,
|
|
119
|
+
repository: repository,
|
|
120
|
+
license: license,
|
|
121
|
+
author: author,
|
|
122
|
+
main: main,
|
|
123
|
+
unpkg: unpkg,
|
|
124
|
+
module: module$1,
|
|
125
|
+
types: types,
|
|
126
|
+
files: files,
|
|
127
|
+
scripts: scripts,
|
|
128
|
+
devDependencies: devDependencies
|
|
129
|
+
};
|
|
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
|
+
};
|
|
28
159
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
}
|
|
32
180
|
}
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
});
|
|
35
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;
|
|
36
431
|
}
|
|
37
|
-
|
|
38
|
-
|
|
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();
|
|
39
616
|
}
|
|
40
617
|
|
|
41
618
|
/**
|
|
@@ -43,10 +620,10 @@ function APIIncreaseIdCounter() {
|
|
|
43
620
|
*
|
|
44
621
|
* @copyright https://stackoverflow.com/a/53731154
|
|
45
622
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return (key, value)
|
|
49
|
-
if (
|
|
623
|
+
var getCircularReplacer = function getCircularReplacer() {
|
|
624
|
+
var seen = new WeakSet();
|
|
625
|
+
return function (key, value) {
|
|
626
|
+
if (_typeof(value) === "object" && value !== null) {
|
|
50
627
|
if (seen.has(value)) {
|
|
51
628
|
return;
|
|
52
629
|
}
|
|
@@ -61,109 +638,55 @@ const getCircularReplacer = () => {
|
|
|
61
638
|
*
|
|
62
639
|
* @copyright http://jsfiddle.net/96sME/
|
|
63
640
|
*/
|
|
64
|
-
|
|
641
|
+
var hexColorDelta = function hexColorDelta(hex1, hex2) {
|
|
65
642
|
hex1 = hex1.replace("#", "");
|
|
66
643
|
hex2 = hex2.replace("#", "");
|
|
644
|
+
|
|
67
645
|
// Get red/green/blue int values of hex1
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
|
|
71
650
|
// Get red/green/blue int values of hex2
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
|
|
75
655
|
// Calculate differences between reds, greens and blues
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
|
|
79
660
|
// Limit differences between 0 and 1
|
|
661
|
+
|
|
80
662
|
r /= 255;
|
|
81
663
|
g /= 255;
|
|
82
664
|
b /= 255;
|
|
665
|
+
|
|
83
666
|
// 0 means opposite colors, 1 means same colors
|
|
84
667
|
return (r + g + b) / 3;
|
|
85
668
|
};
|
|
86
669
|
|
|
87
|
-
var index$
|
|
670
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
88
671
|
__proto__: null,
|
|
89
672
|
getCircularReplacer: getCircularReplacer,
|
|
90
673
|
hexColorDelta: hexColorDelta
|
|
91
674
|
});
|
|
92
675
|
|
|
93
|
-
/**
|
|
94
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
95
|
-
* @description: Module for logging instances.
|
|
96
|
-
* @TODO:
|
|
97
|
-
* - Remove `@ts-ignore`, requires a refactor.
|
|
98
|
-
* - Add night/white mode.
|
|
99
|
-
*/
|
|
100
676
|
// TODO: Should by dynamic/configure-able.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
static wrappers = {};
|
|
104
|
-
static wrapperDepth = 0;
|
|
105
|
-
static sharedData = {};
|
|
106
|
-
static colorsInUse = [];
|
|
107
|
-
defaultStyle;
|
|
108
|
-
color;
|
|
109
|
-
outputHandler;
|
|
110
|
-
args = {};
|
|
111
|
-
name;
|
|
112
|
-
state = false;
|
|
113
|
-
static getName() {
|
|
114
|
-
return 'Core/Modules/Logger';
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Function reset() : Reset logger globals.
|
|
118
|
-
*/
|
|
119
|
-
static reset() {
|
|
120
|
-
Logger.wrappers = {};
|
|
121
|
-
Logger.wrapperDepth = 0;
|
|
122
|
-
Logger.colorsInUse = [];
|
|
123
|
-
Logger.sharedData = {};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Function createCustomWrapper() : Creates custom wrapper for log entities.
|
|
127
|
-
*/
|
|
128
|
-
static createCustomWrapper(classType, callback) {
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
if (!Logger.wrappers[classType]) {
|
|
131
|
-
// @ts-ignore
|
|
132
|
-
Logger.wrappers[classType.name] = [];
|
|
133
|
-
}
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
Logger.wrappers[classType.name].push({
|
|
136
|
-
classType,
|
|
137
|
-
callback
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Function getCallerName() : Return caller name.
|
|
142
|
-
*/
|
|
143
|
-
static getCallerName() {
|
|
144
|
-
const error = new Error(),
|
|
145
|
-
caller = error.stack ? error.stack.split("\n")[3].trim() : '_UNKNOWN_CALLER_NAME_';
|
|
146
|
-
if (caller.startsWith("at new")) {
|
|
147
|
-
return "constructor";
|
|
148
|
-
}
|
|
149
|
-
return caller.split(".")[1].split(" ")[0];
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Function functionView() : Return function preview.
|
|
153
|
-
*/
|
|
154
|
-
static getFunctionView(fn) {
|
|
155
|
-
let fReturn = "anonymous function()";
|
|
156
|
-
// TODO: Check if works.
|
|
157
|
-
if (typeof fn !== "string" && fn.name.length !== 0) {
|
|
158
|
-
fReturn = fn.name.split(" ")[1] + "()";
|
|
159
|
-
}
|
|
160
|
-
return fReturn;
|
|
161
|
-
}
|
|
677
|
+
var MAX_WRAPPING_RECURSIVE_DEPTH = 4;
|
|
678
|
+
var Logger = /*#__PURE__*/function () {
|
|
162
679
|
/**
|
|
163
680
|
* Function constructor() : Create logger class.
|
|
164
681
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
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'])) {
|
|
167
690
|
return;
|
|
168
691
|
}
|
|
169
692
|
this.state = isActive;
|
|
@@ -178,404 +701,478 @@ class Logger {
|
|
|
178
701
|
this.initialize();
|
|
179
702
|
}
|
|
180
703
|
}
|
|
704
|
+
|
|
181
705
|
/**
|
|
182
706
|
* Function initialize() : Initialize logger class.
|
|
183
707
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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);
|
|
189
720
|
}
|
|
190
|
-
this.
|
|
191
|
-
|
|
192
|
-
this.color = this.getRandomColor();
|
|
193
|
-
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"];
|
|
194
723
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
+
});
|
|
222
771
|
}
|
|
223
|
-
});
|
|
224
|
-
if (Logger.wrapperDepth >= MAX_WRAPPING_RECURSIVE_DEPTH) {
|
|
225
772
|
Logger.wrapperDepth--;
|
|
226
773
|
return result;
|
|
227
774
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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);
|
|
232
787
|
}
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
// TODO: Check is repeated logic, handle it.
|
|
261
|
-
if (typeof value === "object") {
|
|
262
|
-
this.printNextLineObject(type, source, key, value || {});
|
|
263
|
-
} else if (typeof value == "function") {
|
|
264
|
-
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
|
+
}
|
|
265
815
|
} else {
|
|
266
|
-
this.
|
|
816
|
+
this.printMultiLineObject(type, source, params);
|
|
267
817
|
}
|
|
268
|
-
} else {
|
|
269
|
-
this.printMultiLineObject(type, source, params);
|
|
270
818
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (
|
|
281
|
-
|
|
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));
|
|
282
836
|
}
|
|
283
|
-
this.out.apply(this, [`%c(ob)-> %c%c${this.name}%c::%c${source}%c() [${notice}] ->> ${key}: '${params[key]}'%c`].concat(this.defaultStyle));
|
|
284
837
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
* Function drop : Preview as continue of log which drop ite.
|
|
295
|
-
*/
|
|
296
|
-
drop(according, data) {
|
|
297
|
-
if (!this.state) return;
|
|
298
|
-
const source = Logger.getCallerName();
|
|
299
|
-
for (let key in according) {
|
|
300
|
-
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);
|
|
301
847
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
* Function clone() : Create clone instance.
|
|
314
|
-
*/
|
|
315
|
-
clone() {
|
|
316
|
-
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Function printFunctionNotify() : Print simple log for notify source (function).
|
|
320
|
-
*
|
|
321
|
-
*/
|
|
322
|
-
printFunctionNotify(type, source, output) {
|
|
323
|
-
this.out.apply(this, [`%c(${type})-> %c%c${this.name}%c::%c${source}%c() ${output}%c`].concat(this.defaultStyle));
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Function printInLineElement() : Print in line element.
|
|
327
|
-
*/
|
|
328
|
-
printInLineElement(type, source, key, value) {
|
|
329
|
-
this.out.apply(this, [`%c(${type})-> %c%c${this.name}%c::%c${source}%c() ->> ${key}: '${value}'%c`].concat(this.defaultStyle));
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Function printInLineFunction() : Print in line function.
|
|
333
|
-
*/
|
|
334
|
-
printInLineFunction(type, source, key, fn) {
|
|
335
|
-
fn = Logger.getFunctionView(fn);
|
|
336
|
-
this.printInLineElement(type, source, key, fn);
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Function printInLineString() : Print in line string.
|
|
340
|
-
*/
|
|
341
|
-
printInLineString(type, source, string) {
|
|
342
|
-
this.printInLineElement(type, source, "(string)", string);
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Function printNextLineObject() : Print object in next line.
|
|
346
|
-
*/
|
|
347
|
-
printNextLineObject(type, source, key, obj) {
|
|
348
|
-
obj = this.useWrapper(obj);
|
|
349
|
-
this.out.apply(this, [`%c(${type})-> %c%c${this.name}%c::%c${source}%c() ->> ${key} %c↓`].concat(this.defaultStyle));
|
|
350
|
-
// print in next line
|
|
351
|
-
this.out(obj);
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Function printMultiLineObject() : Print object in multiline format.
|
|
355
|
-
*/
|
|
356
|
-
printMultiLineObject(type, source, obj) {
|
|
357
|
-
this.out.apply(this, [`%c(${type})-> %c%c${this.name}%c::%c${source}%c(${Object.keys(obj).join(", ")}) %c↓`].concat(this.defaultStyle));
|
|
358
|
-
for (let key in obj) {
|
|
359
|
-
let value = obj[key];
|
|
360
|
-
if (typeof value === "object") {
|
|
361
|
-
value = JSON.stringify(this.useWrapper(value), getCircularReplacer());
|
|
362
|
-
} else if (typeof obj[key] == "function") {
|
|
363
|
-
value = Logger.getFunctionView(value);
|
|
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));
|
|
364
859
|
}
|
|
365
|
-
this.out
|
|
860
|
+
this.out(data);
|
|
366
861
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return hexColorDelta(color, value) >= 0.8;
|
|
380
|
-
});
|
|
381
|
-
// if the color is similar, try again.
|
|
382
|
-
if (similar) {
|
|
383
|
-
return this.getRandomColor();
|
|
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;
|
|
384
874
|
}
|
|
385
|
-
return color;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Function out() : Print console log with style
|
|
389
|
-
*/
|
|
390
|
-
out(...args) {
|
|
391
|
-
this.outputHandler.apply(this, args);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
875
|
|
|
395
|
-
/**
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
options = {};
|
|
404
|
-
logger;
|
|
405
|
-
constructor(args = {}, options = {}) {
|
|
406
|
-
super();
|
|
407
|
-
const name = this.constructor.getName();
|
|
408
|
-
this.logger = new Logger(name, true, {
|
|
409
|
-
sameColor: true
|
|
410
|
-
});
|
|
411
|
-
this.logger.startWith({
|
|
412
|
-
args,
|
|
413
|
-
options
|
|
414
|
-
});
|
|
415
|
-
this.initialize(args, options);
|
|
416
|
-
}
|
|
417
|
-
initialize(args, options) {
|
|
418
|
-
this.args = args;
|
|
419
|
-
this.options = options;
|
|
420
|
-
}
|
|
421
|
-
apply(args = this.args, options = this.options) {
|
|
422
|
-
throw new ForceMethod(this, "apply");
|
|
423
|
-
}
|
|
424
|
-
async run() {
|
|
425
|
-
this.onBeforeApply && this.onBeforeApply();
|
|
426
|
-
const result = await this.apply(this.args, this.options);
|
|
427
|
-
this.onAfterApply && this.onAfterApply();
|
|
428
|
-
return result;
|
|
429
|
-
}
|
|
430
|
-
getArgs() {
|
|
431
|
-
return this.args;
|
|
432
|
-
}
|
|
433
|
-
getOptions() {
|
|
434
|
-
return this.options;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
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
|
+
}
|
|
437
884
|
|
|
438
|
-
/**
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
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
|
+
}
|
|
447
894
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
+
}
|
|
454
903
|
|
|
455
|
-
/**
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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);
|
|
486
948
|
}
|
|
487
|
-
|
|
488
|
-
}
|
|
949
|
+
this.out.apply(this, ["%c" + _key4 + ": `" + this.useWrapper(value) + "`", "color: #a3a3a3"]);
|
|
950
|
+
}
|
|
489
951
|
}
|
|
490
|
-
|
|
491
|
-
|
|
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();
|
|
972
|
+
}
|
|
973
|
+
return color;
|
|
974
|
+
}
|
|
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 = {};
|
|
1003
|
+
}
|
|
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", []);
|
|
1058
|
+
|
|
1059
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
1060
|
+
__proto__: null,
|
|
1061
|
+
Logger: Logger
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
function _isNativeFunction(fn) {
|
|
1065
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
492
1066
|
}
|
|
493
1067
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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
|
+
};
|
|
501
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);
|
|
502
1109
|
}
|
|
503
1110
|
|
|
504
1111
|
/**
|
|
505
1112
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
506
1113
|
*/
|
|
507
1114
|
|
|
508
|
-
var
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
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));
|
|
515
1124
|
|
|
516
1125
|
/**
|
|
517
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
518
|
-
|
|
519
|
-
*/
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
super();
|
|
529
|
-
this.initialize();
|
|
530
|
-
}
|
|
531
|
-
initialize() {
|
|
532
|
-
this.register();
|
|
533
|
-
this.setupHooks && this.setupHooks();
|
|
534
|
-
}
|
|
535
|
-
register() {
|
|
536
|
-
this.commands = managers.commands.register(this.getCommands(), this);
|
|
537
|
-
this.data = managers.data.register(this.getData(), this);
|
|
538
|
-
this.internal = managers.internal.register(this.getInternal(), this);
|
|
539
|
-
}
|
|
540
|
-
getCommands() {
|
|
541
|
-
return {};
|
|
542
|
-
}
|
|
543
|
-
getData() {
|
|
544
|
-
return {};
|
|
545
|
-
}
|
|
546
|
-
getInternal() {
|
|
547
|
-
return {};
|
|
548
|
-
}
|
|
549
|
-
}
|
|
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));
|
|
550
1137
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
ObjectBase: ObjectBase
|
|
555
|
-
});
|
|
1138
|
+
/**
|
|
1139
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1140
|
+
*/
|
|
556
1141
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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));
|
|
562
1151
|
|
|
563
1152
|
/**
|
|
564
1153
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
565
1154
|
*/
|
|
566
|
-
class CommandNotFound extends Error {
|
|
567
|
-
constructor(command) {
|
|
568
|
-
super(`Command: '${command}' is not found`);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
1155
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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));
|
|
577
1174
|
|
|
578
|
-
var index$
|
|
1175
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
579
1176
|
__proto__: null,
|
|
580
1177
|
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
581
1178
|
CommandNotFound: CommandNotFound,
|
|
@@ -583,221 +1180,456 @@ ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
|
583
1180
|
ForceMethod: ForceMethod
|
|
584
1181
|
});
|
|
585
1182
|
|
|
586
|
-
var
|
|
587
|
-
__proto__: null,
|
|
588
|
-
Logger: Logger
|
|
589
|
-
});
|
|
1183
|
+
var IdCounter = 0;
|
|
590
1184
|
|
|
591
1185
|
/**
|
|
592
|
-
*
|
|
593
|
-
* @description: Responsible for manging/running/hooking commands.
|
|
1186
|
+
* Base class 4 *
|
|
594
1187
|
*/
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
onBeforeHooks = {};
|
|
602
|
-
onBeforeUIHooks = {};
|
|
603
|
-
onAfterHooks = {};
|
|
604
|
-
onAfterOnceHooks = {};
|
|
605
|
-
onAfterUIHooks = {};
|
|
606
|
-
onAfterAffectHooks = {};
|
|
607
|
-
logger;
|
|
608
|
-
static getName() {
|
|
609
|
-
return 'Core/Managers/Commands';
|
|
1188
|
+
var ObjectBase = /*#__PURE__*/function () {
|
|
1189
|
+
function ObjectBase() {
|
|
1190
|
+
_classCallCheck(this, ObjectBase);
|
|
1191
|
+
_defineProperty(this, "virtualId", 0);
|
|
1192
|
+
this.virtualId = IdCounter;
|
|
1193
|
+
APIIncreaseIdCounter();
|
|
610
1194
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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
|
+
}();
|
|
1208
|
+
function APIIncreaseIdCounter() {
|
|
1209
|
+
return IdCounter++;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
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);
|
|
617
1264
|
}
|
|
618
|
-
|
|
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;
|
|
619
1282
|
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
1283
|
+
}, {
|
|
1284
|
+
key: "getAll",
|
|
1285
|
+
value: function getAll() {
|
|
1286
|
+
return this.commands;
|
|
624
1287
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
Object.values(commands).forEach(command => {
|
|
644
|
-
const commandName = command.getName();
|
|
645
|
-
if (this.commands[commandName]) {
|
|
646
|
-
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);
|
|
647
1306
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
return result;
|
|
652
|
-
}
|
|
653
|
-
getAll() {
|
|
654
|
-
return this.commands;
|
|
655
|
-
}
|
|
656
|
-
getByName(name) {
|
|
657
|
-
return this.commands[name];
|
|
658
|
-
}
|
|
659
|
-
getLogger() {
|
|
660
|
-
return this.logger;
|
|
661
|
-
}
|
|
662
|
-
getCommandInstance(name, args = {}, options = {}) {
|
|
663
|
-
const CommandClass = this.commands[name];
|
|
664
|
-
if (!CommandClass) {
|
|
665
|
-
throw new CommandNotFound(name);
|
|
1307
|
+
|
|
1308
|
+
// @ts-ignore
|
|
1309
|
+
return new CommandClass(args, options);
|
|
666
1310
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Function onBeforeUI() : Used to set hooks that effects only UI.
|
|
678
|
-
*/
|
|
679
|
-
onBeforeUI(hookCommand, callback) {
|
|
680
|
-
Commands.hookCommand(this.onBeforeUIHooks, hookCommand, callback);
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Function onAfter() : Used to set hooks that effects only data and not UI.
|
|
684
|
-
*/
|
|
685
|
-
onAfter(hookCommand, callback) {
|
|
686
|
-
Commands.hookCommand(this.onAfterHooks, hookCommand, callback);
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* Function onAfterUI() : Used to set hooks that effects only UI.
|
|
690
|
-
*/
|
|
691
|
-
onAfterUI(command, callback) {
|
|
692
|
-
Commands.hookCommand(this.onAfterUIHooks, command, callback);
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Function onAfterOnce() : Used to set hooks that effects only data and not UI.
|
|
696
|
-
*/
|
|
697
|
-
onAfterOnce(command, callback) {
|
|
698
|
-
Commands.hookCommand(this.onAfterOnceHooks, command, callback);
|
|
699
|
-
}
|
|
700
|
-
/**
|
|
701
|
-
* Function onAfterAffect() : Used to register a trigger that runs command after `hookCommand` run's.
|
|
702
|
-
*/
|
|
703
|
-
onAfterAffect(hookCommand, affectCommand) {
|
|
704
|
-
Commands.hookCommand(this.onAfterAffectHooks, hookCommand, affectCommand);
|
|
705
|
-
}
|
|
706
|
-
onBeforeRun(command, args = {}, options = {}) {
|
|
707
|
-
if (this.onBeforeHooks[command.getName()]) {
|
|
708
|
-
const callbacks = this.onBeforeHooks[command.getName()];
|
|
709
|
-
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);
|
|
710
1319
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
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);
|
|
714
1328
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
CommandArgs: "->"
|
|
724
|
-
});
|
|
725
|
-
this.logger.debug("CommandArgs:");
|
|
726
|
-
this.logger.object(args);
|
|
727
|
-
} else {
|
|
728
|
-
this.logger.startWith({
|
|
729
|
-
command: command.getName(),
|
|
730
|
-
options,
|
|
731
|
-
args
|
|
732
|
-
});
|
|
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);
|
|
733
1337
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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);
|
|
1346
|
+
}
|
|
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);
|
|
747
1355
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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);
|
|
751
1364
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
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());
|
|
757
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';
|
|
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", []);
|
|
758
1566
|
|
|
759
|
-
|
|
760
|
-
|
|
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];
|
|
761
1575
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
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;
|
|
775
1614
|
}
|
|
1615
|
+
return object;
|
|
776
1616
|
}
|
|
777
1617
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
return this.controllers;
|
|
792
|
-
}
|
|
793
|
-
register(controller) {
|
|
794
|
-
if (this.controllers[controller.getName()]) {
|
|
795
|
-
throw new ControllerAlreadyRegistered(controller);
|
|
796
|
-
}
|
|
797
|
-
// Register.
|
|
798
|
-
this.controllers[controller.getName()] = controller;
|
|
799
|
-
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
|
+
};
|
|
800
1631
|
}
|
|
1632
|
+
return _get.apply(this, arguments);
|
|
801
1633
|
}
|
|
802
1634
|
|
|
803
1635
|
/**
|
|
@@ -814,141 +1646,501 @@ var HTTPMethodEnum;
|
|
|
814
1646
|
HTTPMethodEnum["__EMPTY__"] = "";
|
|
815
1647
|
})(HTTPMethodEnum || (HTTPMethodEnum = {}));
|
|
816
1648
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
*/
|
|
821
|
-
class Http extends ObjectBase {
|
|
822
|
-
logger;
|
|
823
|
-
apiBaseUrl;
|
|
824
|
-
static getName() {
|
|
825
|
-
return 'Core/Clients/Http';
|
|
826
|
-
}
|
|
1649
|
+
var Http = /*#__PURE__*/function (_ObjectBase) {
|
|
1650
|
+
_inherits(Http, _ObjectBase);
|
|
1651
|
+
var _super = _createSuper(Http);
|
|
827
1652
|
/**
|
|
828
1653
|
* Function constructor() : Create the http.
|
|
829
1654
|
*/
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
this
|
|
834
|
-
|
|
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
|
|
835
1663
|
});
|
|
836
|
-
|
|
1664
|
+
_this.apiBaseUrl = apiBaseUrl + '/';
|
|
1665
|
+
return _this;
|
|
837
1666
|
}
|
|
1667
|
+
|
|
838
1668
|
/**
|
|
839
1669
|
* Function fetch() : Fetch api.
|
|
840
1670
|
*/
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
method
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
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';
|
|
865
1751
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
this.logger.drop({
|
|
879
|
-
path
|
|
880
|
-
}, data);
|
|
881
|
-
return data;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
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);
|
|
884
1763
|
|
|
885
|
-
/**
|
|
886
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
887
|
-
* @description: Responsible for manging data commands which are wrappers for HTTP requests.
|
|
888
|
-
*/
|
|
889
|
-
class Data extends Commands {
|
|
890
|
-
static client;
|
|
891
|
-
currentHttpMethod;
|
|
892
|
-
static getName() {
|
|
893
|
-
return 'Core/Managers/Data';
|
|
894
|
-
}
|
|
895
|
-
constructor(Config) {
|
|
896
|
-
super();
|
|
897
1764
|
// @ts-ignore
|
|
898
1765
|
Data.client = new Http(Config.baseURL);
|
|
1766
|
+
return _this;
|
|
899
1767
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
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);
|
|
929
1852
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1853
|
+
return runInstance;
|
|
1854
|
+
}()
|
|
1855
|
+
}], [{
|
|
1856
|
+
key: "getName",
|
|
1857
|
+
value: function getName() {
|
|
1858
|
+
return 'Core/Managers/Data';
|
|
935
1859
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1860
|
+
}]);
|
|
1861
|
+
return Data;
|
|
1862
|
+
}(Commands);
|
|
1863
|
+
|
|
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);
|
|
942
1879
|
|
|
943
1880
|
/**
|
|
944
1881
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
945
|
-
* @description: Responsible for manging internal commands, To serve commands that are not triggered by user.
|
|
946
1882
|
*/
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1883
|
+
var afterInitializeCallbacks = [];
|
|
1884
|
+
function initialize(config) {
|
|
1885
|
+
commands = new Commands();
|
|
1886
|
+
controllers = new Controllers();
|
|
1887
|
+
data = new Data(config);
|
|
1888
|
+
internal = new Internal();
|
|
951
1889
|
}
|
|
1890
|
+
function destroy() {
|
|
1891
|
+
commands = {};
|
|
1892
|
+
controllers = {};
|
|
1893
|
+
data = {};
|
|
1894
|
+
internal = {};
|
|
1895
|
+
}
|
|
1896
|
+
var commands = {};
|
|
1897
|
+
var controllers = {};
|
|
1898
|
+
var data = {};
|
|
1899
|
+
var internal = {};
|
|
1900
|
+
|
|
1901
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
1902
|
+
__proto__: null,
|
|
1903
|
+
afterInitializeCallbacks: afterInitializeCallbacks,
|
|
1904
|
+
get commands () { return commands; },
|
|
1905
|
+
get controllers () { return controllers; },
|
|
1906
|
+
get data () { return data; },
|
|
1907
|
+
destroy: destroy,
|
|
1908
|
+
initialize: initialize,
|
|
1909
|
+
get internal () { return internal; }
|
|
1910
|
+
});
|
|
1911
|
+
|
|
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, {
|
|
1925
|
+
sameColor: true
|
|
1926
|
+
});
|
|
1927
|
+
_this.logger.startWith({
|
|
1928
|
+
args: args,
|
|
1929
|
+
options: options
|
|
1930
|
+
});
|
|
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);
|
|
1987
|
+
|
|
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);
|
|
2003
|
+
|
|
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');
|
|
2025
|
+
}
|
|
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);
|
|
2059
|
+
|
|
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);
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
2078
|
+
*/
|
|
2079
|
+
|
|
2080
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
2081
|
+
__proto__: null,
|
|
2082
|
+
CommandBase: CommandBase,
|
|
2083
|
+
CommandData: CommandData,
|
|
2084
|
+
CommandInternal: CommandInternal,
|
|
2085
|
+
CommandPublic: CommandPublic
|
|
2086
|
+
});
|
|
2087
|
+
|
|
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);
|
|
2138
|
+
|
|
2139
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
2140
|
+
__proto__: null,
|
|
2141
|
+
Controller: Controller,
|
|
2142
|
+
ObjectBase: ObjectBase
|
|
2143
|
+
});
|
|
952
2144
|
|
|
953
2145
|
/**
|
|
954
2146
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
@@ -968,127 +2160,50 @@ Internal: Internal
|
|
|
968
2160
|
|
|
969
2161
|
var exported = /*#__PURE__*/Object.freeze({
|
|
970
2162
|
__proto__: null,
|
|
971
|
-
commandBases: index$
|
|
972
|
-
core: index$
|
|
973
|
-
errors: index$
|
|
2163
|
+
commandBases: index$2,
|
|
2164
|
+
core: index$1,
|
|
2165
|
+
errors: index$4,
|
|
974
2166
|
managerBases: index,
|
|
975
|
-
|
|
976
|
-
|
|
2167
|
+
managers: index$3,
|
|
2168
|
+
modules: index$5,
|
|
2169
|
+
utils: index$6
|
|
977
2170
|
});
|
|
978
2171
|
|
|
979
|
-
var
|
|
980
|
-
var version = "0.0.0-abc.1";
|
|
981
|
-
var description = "ZenFlux core";
|
|
982
|
-
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
983
|
-
var scripts = {
|
|
984
|
-
test: "export flow_modules_logger=off && jest",
|
|
985
|
-
build: "rollup --config rollup.config.ts --configPlugin typescript"
|
|
986
|
-
};
|
|
987
|
-
var repository = {
|
|
988
|
-
type: "git",
|
|
989
|
-
url: "git+https://github.com/zenflux/core.git"
|
|
990
|
-
};
|
|
991
|
-
var keywords = [
|
|
992
|
-
"zenflux",
|
|
993
|
-
"zen",
|
|
994
|
-
"flux",
|
|
995
|
-
"commands",
|
|
996
|
-
"manager",
|
|
997
|
-
"commands manager"
|
|
998
|
-
];
|
|
999
|
-
var files = [
|
|
1000
|
-
"dist",
|
|
1001
|
-
"src",
|
|
1002
|
-
"types"
|
|
1003
|
-
];
|
|
1004
|
-
var license = "MIT";
|
|
1005
|
-
var main = "dist/cjs/zenflux-core.js";
|
|
1006
|
-
var unpkg = "dist/umd/zenflux-core.js";
|
|
1007
|
-
var module$1 = "dist/es/zenflux-core.js";
|
|
1008
|
-
var types = "types/index.d.ts";
|
|
1009
|
-
var devDependencies = {
|
|
1010
|
-
"@babel/core": "^7.20.7",
|
|
1011
|
-
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
1012
|
-
"@babel/preset-env": "^7.20.2",
|
|
1013
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
1014
|
-
"@babel/runtime": "^7.20.7",
|
|
1015
|
-
"@rollup/plugin-babel": "^6.0.3",
|
|
1016
|
-
"@rollup/plugin-json": "^6.0.0",
|
|
1017
|
-
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
1018
|
-
"@rollup/plugin-replace": "^5.0.2",
|
|
1019
|
-
"@rollup/plugin-terser": "^0.2.1",
|
|
1020
|
-
"@rollup/plugin-typescript": "^10.0.1",
|
|
1021
|
-
"@types/jest": "^29.2.5",
|
|
1022
|
-
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
1023
|
-
"@typescript-eslint/parser": "^5.48.0",
|
|
1024
|
-
"babel-jest": "^29.3.1",
|
|
1025
|
-
rollup: "^3.9.1",
|
|
1026
|
-
"ts-jest": "^29.0.3",
|
|
1027
|
-
tslib: "^2.4.1"
|
|
1028
|
-
};
|
|
1029
|
-
var dependencies = {
|
|
1030
|
-
"@babel/runtime": "^7.19.0"
|
|
1031
|
-
};
|
|
1032
|
-
var pkg = {
|
|
1033
|
-
name: name,
|
|
1034
|
-
version: version,
|
|
1035
|
-
description: description,
|
|
1036
|
-
author: author,
|
|
1037
|
-
scripts: scripts,
|
|
1038
|
-
repository: repository,
|
|
1039
|
-
keywords: keywords,
|
|
1040
|
-
files: files,
|
|
1041
|
-
license: license,
|
|
1042
|
-
main: main,
|
|
1043
|
-
unpkg: unpkg,
|
|
1044
|
-
module: module$1,
|
|
1045
|
-
types: types,
|
|
1046
|
-
devDependencies: devDependencies,
|
|
1047
|
-
dependencies: dependencies
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
let isInitialized = false;
|
|
2172
|
+
var isInitialized = false;
|
|
1051
2173
|
function errorInitTwice() {
|
|
1052
2174
|
if (isInitialized) {
|
|
1053
2175
|
throw new Error('ZenCore is already initialized.');
|
|
1054
2176
|
}
|
|
1055
2177
|
}
|
|
1056
2178
|
errorInitTwice();
|
|
1057
|
-
|
|
2179
|
+
var config = {
|
|
1058
2180
|
version: pkg.version
|
|
1059
2181
|
};
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
initialize: configuration => {
|
|
2182
|
+
var CoreAPI = _objectSpread2({
|
|
2183
|
+
initialize: function initialize$1(configuration) {
|
|
1063
2184
|
errorInitTwice();
|
|
1064
2185
|
config = configuration || config;
|
|
1065
|
-
|
|
1066
|
-
managers.controllers = new Controllers();
|
|
1067
|
-
managers.data = new Data(config);
|
|
1068
|
-
managers.internal = new Internal();
|
|
2186
|
+
initialize(config);
|
|
1069
2187
|
isInitialized = true;
|
|
1070
|
-
afterInitializeCallbacks.forEach(callback => callback());
|
|
1071
2188
|
},
|
|
1072
|
-
destroy: ()
|
|
2189
|
+
destroy: function destroy$1() {
|
|
2190
|
+
destroy();
|
|
1073
2191
|
isInitialized = false;
|
|
1074
|
-
managers.commands = {};
|
|
1075
|
-
managers.controllers = {};
|
|
1076
|
-
managers.data = {};
|
|
1077
|
-
managers.internal = {};
|
|
1078
2192
|
},
|
|
1079
|
-
onAfterInitialize: callback
|
|
2193
|
+
onAfterInitialize: function onAfterInitialize(callback) {
|
|
1080
2194
|
afterInitializeCallbacks.push(callback);
|
|
1081
2195
|
},
|
|
1082
|
-
config
|
|
1083
|
-
|
|
1084
|
-
|
|
2196
|
+
config: config
|
|
2197
|
+
}, exported);
|
|
2198
|
+
|
|
1085
2199
|
// TODO: Make it available only for development.
|
|
1086
|
-
if (!globalThis
|
|
2200
|
+
if (!(globalThis !== null && globalThis !== void 0 && globalThis.ZenCore)) globalThis.ZenCore = CoreAPI;
|
|
1087
2201
|
|
|
1088
|
-
exports.commandBases = index$
|
|
1089
|
-
exports.core = index$
|
|
2202
|
+
exports.commandBases = index$2;
|
|
2203
|
+
exports.core = index$1;
|
|
1090
2204
|
exports.default = CoreAPI;
|
|
1091
|
-
exports.errors = index$
|
|
2205
|
+
exports.errors = index$4;
|
|
1092
2206
|
exports.managerBases = index;
|
|
1093
|
-
exports.
|
|
1094
|
-
exports.
|
|
2207
|
+
exports.managers = index$3;
|
|
2208
|
+
exports.modules = index$5;
|
|
2209
|
+
exports.utils = index$6;
|