@zenflux/core 0.0.1-dev.2 → 0.0.1-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/src/bases/controller-base.d.ts +55 -0
- package/dist/es/src/bases/controller-base.d.ts.map +1 -0
- package/dist/es/src/bases/index.d.ts +3 -0
- package/dist/es/src/bases/index.d.ts.map +1 -0
- package/dist/es/src/bases/object-base.d.ts +32 -0
- package/dist/es/src/bases/object-base.d.ts.map +1 -0
- package/dist/es/{clients → src/clients}/http.d.ts +16 -7
- package/dist/es/src/clients/http.d.ts.map +1 -0
- package/dist/es/src/command-bases/command-base.d.ts +29 -0
- package/dist/es/src/command-bases/command-base.d.ts.map +1 -0
- package/dist/es/src/command-bases/command-internal.d.ts +9 -0
- package/dist/es/src/command-bases/command-internal.d.ts.map +1 -0
- package/dist/es/src/command-bases/command-public.d.ts +9 -0
- package/dist/es/src/command-bases/command-public.d.ts.map +1 -0
- package/dist/es/src/command-bases/command-restful.d.ts +22 -0
- package/dist/es/src/command-bases/command-restful.d.ts.map +1 -0
- package/dist/es/src/command-bases/index.d.ts +8 -0
- package/dist/es/src/command-bases/index.d.ts.map +1 -0
- package/dist/es/src/errors/command-already-registered.d.ts +11 -0
- package/dist/es/src/errors/command-already-registered.d.ts.map +1 -0
- package/dist/es/src/errors/command-not-found.d.ts +10 -0
- package/dist/es/src/errors/command-not-found.d.ts.map +1 -0
- package/dist/es/src/errors/controller-already-registered.d.ts +11 -0
- package/dist/es/src/errors/controller-already-registered.d.ts.map +1 -0
- package/dist/es/src/errors/controller-already-set.d.ts +11 -0
- package/dist/es/src/errors/controller-already-set.d.ts.map +1 -0
- package/dist/es/src/errors/force-method-implementation.d.ts +14 -0
- package/dist/es/src/errors/force-method-implementation.d.ts.map +1 -0
- package/dist/es/src/errors/index-public.d.ts +2 -0
- package/dist/es/src/errors/index-public.d.ts.map +1 -0
- package/dist/es/src/errors/index.d.ts +6 -0
- package/dist/es/src/errors/index.d.ts.map +1 -0
- package/dist/es/src/exports.d.ts +37 -0
- package/dist/es/src/exports.d.ts.map +1 -0
- package/dist/es/src/index.d.ts +6 -0
- package/dist/es/src/index.d.ts.map +1 -0
- package/dist/es/src/initializer.d.ts +36 -0
- package/dist/es/src/initializer.d.ts.map +1 -0
- package/dist/es/{interfaces → src/interfaces}/commands.d.ts +3 -3
- package/dist/es/src/interfaces/commands.d.ts.map +1 -0
- package/dist/es/src/interfaces/config.d.ts +21 -0
- package/dist/es/src/interfaces/config.d.ts.map +1 -0
- package/dist/es/src/interfaces/index.d.ts +8 -0
- package/dist/es/src/interfaces/index.d.ts.map +1 -0
- package/dist/es/src/interfaces/logger.d.ts +20 -0
- package/dist/es/src/interfaces/logger.d.ts.map +1 -0
- package/dist/es/{interfaces/data.d.ts → src/interfaces/restful.d.ts} +2 -2
- package/dist/es/src/interfaces/restful.d.ts.map +1 -0
- package/dist/es/src/managers/commands.d.ts +68 -0
- package/dist/es/src/managers/commands.d.ts.map +1 -0
- package/dist/es/src/managers/controllers.d.ts +17 -0
- package/dist/es/src/managers/controllers.d.ts.map +1 -0
- package/dist/es/src/managers/export.d.ts +16 -0
- package/dist/es/src/managers/export.d.ts.map +1 -0
- package/dist/es/src/managers/index.d.ts +8 -0
- package/dist/es/src/managers/index.d.ts.map +1 -0
- package/dist/es/src/managers/internal.d.ts +9 -0
- package/dist/es/src/managers/internal.d.ts.map +1 -0
- package/dist/es/{manager-bases/data.d.ts → src/managers/restful.d.ts} +9 -10
- package/dist/es/src/managers/restful.d.ts.map +1 -0
- package/dist/es/tsdoc-metadata.json +11 -0
- package/dist/es/zenflux-core.d.ts +470 -0
- package/dist/es/zenflux-core.js +704 -1017
- package/package.json +29 -47
- package/src/bases/controller-base.ts +96 -0
- package/src/bases/index.ts +2 -0
- package/src/bases/object-base.ts +83 -0
- package/src/clients/http.ts +48 -35
- package/src/command-bases/command-base.ts +34 -38
- package/src/command-bases/command-internal.ts +5 -7
- package/src/command-bases/command-public.ts +5 -6
- package/src/command-bases/command-restful.ts +55 -0
- package/src/command-bases/index.ts +5 -5
- package/src/errors/command-already-registered.ts +6 -5
- package/src/errors/command-not-found.ts +6 -4
- package/src/errors/controller-already-registered.ts +6 -5
- package/src/errors/controller-already-set.ts +8 -5
- package/src/errors/force-method-implementation.ts +23 -0
- package/src/errors/index-public.ts +1 -0
- package/src/errors/index.ts +5 -5
- package/src/exports.ts +47 -9
- package/src/index.ts +3 -4
- package/src/initializer.ts +13 -13
- package/src/interfaces/commands.ts +3 -3
- package/src/interfaces/config.ts +10 -3
- package/src/interfaces/index.ts +5 -6
- package/src/interfaces/logger.ts +18 -0
- package/src/interfaces/{data.ts → restful.ts} +10 -10
- package/src/{manager-bases → managers}/commands.ts +52 -60
- package/src/managers/controllers.ts +39 -0
- package/src/managers/export.ts +30 -0
- package/src/managers/index.ts +5 -28
- package/src/managers/internal.ts +11 -0
- package/src/{manager-bases/data.ts → managers/restful.ts} +18 -19
- package/LICENSE +0 -21
- package/README.md +0 -2
- package/dist/es/clients/http.d.ts.map +0 -1
- package/dist/es/command-bases/command-base.d.ts +0 -27
- package/dist/es/command-bases/command-base.d.ts.map +0 -1
- package/dist/es/command-bases/command-data.d.ts +0 -18
- package/dist/es/command-bases/command-data.d.ts.map +0 -1
- package/dist/es/command-bases/command-internal.d.ts +0 -10
- package/dist/es/command-bases/command-internal.d.ts.map +0 -1
- package/dist/es/command-bases/command-public.d.ts +0 -10
- package/dist/es/command-bases/command-public.d.ts.map +0 -1
- package/dist/es/command-bases/index.d.ts +0 -8
- package/dist/es/command-bases/index.d.ts.map +0 -1
- package/dist/es/core/controller.d.ts +0 -36
- package/dist/es/core/controller.d.ts.map +0 -1
- package/dist/es/core/index.d.ts +0 -3
- package/dist/es/core/index.d.ts.map +0 -1
- package/dist/es/core/object-base.d.ts +0 -15
- package/dist/es/core/object-base.d.ts.map +0 -1
- package/dist/es/errors/command-already-registered.d.ts +0 -9
- package/dist/es/errors/command-already-registered.d.ts.map +0 -1
- package/dist/es/errors/command-not-found.d.ts +0 -8
- package/dist/es/errors/command-not-found.d.ts.map +0 -1
- package/dist/es/errors/controller-already-registered.d.ts +0 -9
- package/dist/es/errors/controller-already-registered.d.ts.map +0 -1
- package/dist/es/errors/controller-already-set.d.ts +0 -8
- package/dist/es/errors/controller-already-set.d.ts.map +0 -1
- package/dist/es/errors/force-method.d.ts +0 -12
- package/dist/es/errors/force-method.d.ts.map +0 -1
- package/dist/es/errors/index.d.ts +0 -6
- package/dist/es/errors/index.d.ts.map +0 -1
- package/dist/es/exports.d.ts +0 -12
- package/dist/es/exports.d.ts.map +0 -1
- package/dist/es/index.d.ts +0 -6
- package/dist/es/index.d.ts.map +0 -1
- package/dist/es/initializer.d.ts +0 -22
- package/dist/es/initializer.d.ts.map +0 -1
- package/dist/es/interfaces/commands.d.ts.map +0 -1
- package/dist/es/interfaces/config.d.ts +0 -15
- package/dist/es/interfaces/config.d.ts.map +0 -1
- package/dist/es/interfaces/data.d.ts.map +0 -1
- package/dist/es/interfaces/index.d.ts +0 -9
- package/dist/es/interfaces/index.d.ts.map +0 -1
- package/dist/es/interfaces/managers.d.ts +0 -14
- package/dist/es/interfaces/managers.d.ts.map +0 -1
- package/dist/es/interfaces/object-base.d.ts +0 -11
- package/dist/es/interfaces/object-base.d.ts.map +0 -1
- package/dist/es/manager-bases/commands.d.ts +0 -76
- package/dist/es/manager-bases/commands.d.ts.map +0 -1
- package/dist/es/manager-bases/controllers.d.ts +0 -19
- package/dist/es/manager-bases/controllers.d.ts.map +0 -1
- package/dist/es/manager-bases/data.d.ts.map +0 -1
- package/dist/es/manager-bases/index.d.ts +0 -8
- package/dist/es/manager-bases/index.d.ts.map +0 -1
- package/dist/es/manager-bases/internal.d.ts +0 -10
- package/dist/es/manager-bases/internal.d.ts.map +0 -1
- package/dist/es/managers/index.d.ts +0 -16
- package/dist/es/managers/index.d.ts.map +0 -1
- package/dist/es/modules/index.d.ts +0 -2
- package/dist/es/modules/index.d.ts.map +0 -1
- package/dist/es/modules/logger.d.ts +0 -118
- package/dist/es/modules/logger.d.ts.map +0 -1
- package/dist/es/utils/index.d.ts +0 -3
- package/dist/es/utils/index.d.ts.map +0 -1
- package/dist/es/utils/object.d.ts +0 -7
- package/dist/es/utils/object.d.ts.map +0 -1
- package/dist/es/utils/rgb.d.ts +0 -7
- package/dist/es/utils/rgb.d.ts.map +0 -1
- package/src/command-bases/command-data.ts +0 -54
- package/src/core/controller.ts +0 -61
- package/src/core/index.ts +0 -2
- package/src/core/object-base.ts +0 -46
- package/src/errors/force-method.ts +0 -22
- package/src/interfaces/managers.ts +0 -16
- package/src/interfaces/object-base.ts +0 -12
- package/src/manager-bases/controllers.ts +0 -37
- package/src/manager-bases/index.ts +0 -7
- package/src/manager-bases/internal.ts +0 -13
- package/src/modules/index.ts +0 -1
- package/src/modules/logger.ts +0 -459
- package/src/utils/index.ts +0 -2
- package/src/utils/object.ts +0 -18
- package/src/utils/rgb.ts +0 -33
- package/types/index.d.ts +0 -6
package/dist/es/zenflux-core.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
function _typeof(
|
|
1
|
+
function _typeof(o) {
|
|
2
2
|
"@babel/helpers - typeof";
|
|
3
3
|
|
|
4
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (
|
|
5
|
-
return typeof
|
|
6
|
-
} : function (
|
|
7
|
-
return
|
|
8
|
-
}, _typeof(
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function (o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function _toPrimitive(input, hint) {
|
|
@@ -39,330 +39,330 @@ function _defineProperty(obj, key, value) {
|
|
|
39
39
|
return obj;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function ownKeys(
|
|
43
|
-
var
|
|
42
|
+
function ownKeys(e, r) {
|
|
43
|
+
var t = Object.keys(e);
|
|
44
44
|
if (Object.getOwnPropertySymbols) {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
return Object.getOwnPropertyDescriptor(
|
|
48
|
-
})),
|
|
45
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
46
|
+
r && (o = o.filter(function (r) {
|
|
47
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
48
|
+
})), t.push.apply(t, o);
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return t;
|
|
51
51
|
}
|
|
52
|
-
function _objectSpread2(
|
|
53
|
-
for (var
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
_defineProperty(
|
|
57
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
58
|
-
Object.defineProperty(
|
|
52
|
+
function _objectSpread2(e) {
|
|
53
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
54
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
55
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
56
|
+
_defineProperty(e, r, t[r]);
|
|
57
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
58
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return e;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
var version = "0.0.1
|
|
64
|
+
var version = "0.0.1";
|
|
65
65
|
|
|
66
66
|
function _regeneratorRuntime() {
|
|
67
67
|
_regeneratorRuntime = function _regeneratorRuntime() {
|
|
68
|
-
return
|
|
68
|
+
return e;
|
|
69
69
|
};
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
var t,
|
|
71
|
+
e = {},
|
|
72
|
+
r = Object.prototype,
|
|
73
|
+
n = r.hasOwnProperty,
|
|
74
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
75
|
+
t[e] = r.value;
|
|
75
76
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
function define(
|
|
81
|
-
return Object.defineProperty(
|
|
82
|
-
value:
|
|
77
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
78
|
+
a = i.iterator || "@@iterator",
|
|
79
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
80
|
+
u = i.toStringTag || "@@toStringTag";
|
|
81
|
+
function define(t, e, r) {
|
|
82
|
+
return Object.defineProperty(t, e, {
|
|
83
|
+
value: r,
|
|
83
84
|
enumerable: !0,
|
|
84
85
|
configurable: !0,
|
|
85
86
|
writable: !0
|
|
86
|
-
}),
|
|
87
|
+
}), t[e];
|
|
87
88
|
}
|
|
88
89
|
try {
|
|
89
90
|
define({}, "");
|
|
90
|
-
} catch (
|
|
91
|
-
define = function define(
|
|
92
|
-
return
|
|
91
|
+
} catch (t) {
|
|
92
|
+
define = function define(t, e, r) {
|
|
93
|
+
return t[e] = r;
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
|
-
function wrap(
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return
|
|
100
|
-
value: makeInvokeMethod(
|
|
101
|
-
}),
|
|
96
|
+
function wrap(t, e, r, n) {
|
|
97
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
98
|
+
a = Object.create(i.prototype),
|
|
99
|
+
c = new Context(n || []);
|
|
100
|
+
return o(a, "_invoke", {
|
|
101
|
+
value: makeInvokeMethod(t, r, c)
|
|
102
|
+
}), a;
|
|
102
103
|
}
|
|
103
|
-
function tryCatch(
|
|
104
|
+
function tryCatch(t, e, r) {
|
|
104
105
|
try {
|
|
105
106
|
return {
|
|
106
107
|
type: "normal",
|
|
107
|
-
arg:
|
|
108
|
+
arg: t.call(e, r)
|
|
108
109
|
};
|
|
109
|
-
} catch (
|
|
110
|
+
} catch (t) {
|
|
110
111
|
return {
|
|
111
112
|
type: "throw",
|
|
112
|
-
arg:
|
|
113
|
+
arg: t
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
var
|
|
117
|
+
e.wrap = wrap;
|
|
118
|
+
var h = "suspendedStart",
|
|
119
|
+
l = "suspendedYield",
|
|
120
|
+
f = "executing",
|
|
121
|
+
s = "completed",
|
|
122
|
+
y = {};
|
|
118
123
|
function Generator() {}
|
|
119
124
|
function GeneratorFunction() {}
|
|
120
125
|
function GeneratorFunctionPrototype() {}
|
|
121
|
-
var
|
|
122
|
-
define(
|
|
126
|
+
var p = {};
|
|
127
|
+
define(p, a, function () {
|
|
123
128
|
return this;
|
|
124
129
|
});
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var
|
|
129
|
-
function defineIteratorMethods(
|
|
130
|
-
["next", "throw", "return"].forEach(function (
|
|
131
|
-
define(
|
|
132
|
-
return this._invoke(
|
|
130
|
+
var d = Object.getPrototypeOf,
|
|
131
|
+
v = d && d(d(values([])));
|
|
132
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
133
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
134
|
+
function defineIteratorMethods(t) {
|
|
135
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
136
|
+
define(t, e, function (t) {
|
|
137
|
+
return this._invoke(e, t);
|
|
133
138
|
});
|
|
134
139
|
});
|
|
135
140
|
}
|
|
136
|
-
function AsyncIterator(
|
|
137
|
-
function invoke(
|
|
138
|
-
var
|
|
139
|
-
if ("throw" !==
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
return
|
|
143
|
-
invoke("next",
|
|
144
|
-
}, function (
|
|
145
|
-
invoke("throw",
|
|
146
|
-
}) :
|
|
147
|
-
|
|
148
|
-
}, function (
|
|
149
|
-
return invoke("throw",
|
|
141
|
+
function AsyncIterator(t, e) {
|
|
142
|
+
function invoke(r, o, i, a) {
|
|
143
|
+
var c = tryCatch(t[r], t, o);
|
|
144
|
+
if ("throw" !== c.type) {
|
|
145
|
+
var u = c.arg,
|
|
146
|
+
h = u.value;
|
|
147
|
+
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
148
|
+
invoke("next", t, i, a);
|
|
149
|
+
}, function (t) {
|
|
150
|
+
invoke("throw", t, i, a);
|
|
151
|
+
}) : e.resolve(h).then(function (t) {
|
|
152
|
+
u.value = t, i(u);
|
|
153
|
+
}, function (t) {
|
|
154
|
+
return invoke("throw", t, i, a);
|
|
150
155
|
});
|
|
151
156
|
}
|
|
152
|
-
|
|
157
|
+
a(c.arg);
|
|
153
158
|
}
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
value: function value(
|
|
159
|
+
var r;
|
|
160
|
+
o(this, "_invoke", {
|
|
161
|
+
value: function value(t, n) {
|
|
157
162
|
function callInvokeWithMethodAndArg() {
|
|
158
|
-
return new
|
|
159
|
-
invoke(
|
|
163
|
+
return new e(function (e, r) {
|
|
164
|
+
invoke(t, n, e, r);
|
|
160
165
|
});
|
|
161
166
|
}
|
|
162
|
-
return
|
|
167
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
163
168
|
}
|
|
164
169
|
});
|
|
165
170
|
}
|
|
166
|
-
function makeInvokeMethod(
|
|
167
|
-
var
|
|
168
|
-
return function (
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
171
|
-
if ("throw" ===
|
|
172
|
-
return
|
|
171
|
+
function makeInvokeMethod(e, r, n) {
|
|
172
|
+
var o = h;
|
|
173
|
+
return function (i, a) {
|
|
174
|
+
if (o === f) throw new Error("Generator is already running");
|
|
175
|
+
if (o === s) {
|
|
176
|
+
if ("throw" === i) throw a;
|
|
177
|
+
return {
|
|
178
|
+
value: t,
|
|
179
|
+
done: !0
|
|
180
|
+
};
|
|
173
181
|
}
|
|
174
|
-
for (
|
|
175
|
-
var
|
|
176
|
-
if (
|
|
177
|
-
var
|
|
178
|
-
if (
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
182
|
+
for (n.method = i, n.arg = a;;) {
|
|
183
|
+
var c = n.delegate;
|
|
184
|
+
if (c) {
|
|
185
|
+
var u = maybeInvokeDelegate(c, n);
|
|
186
|
+
if (u) {
|
|
187
|
+
if (u === y) continue;
|
|
188
|
+
return u;
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
|
-
if ("next" ===
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
} else "return" ===
|
|
187
|
-
|
|
188
|
-
var
|
|
189
|
-
if ("normal" ===
|
|
190
|
-
if (
|
|
191
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
192
|
+
if (o === h) throw o = s, n.arg;
|
|
193
|
+
n.dispatchException(n.arg);
|
|
194
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
195
|
+
o = f;
|
|
196
|
+
var p = tryCatch(e, r, n);
|
|
197
|
+
if ("normal" === p.type) {
|
|
198
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
191
199
|
return {
|
|
192
|
-
value:
|
|
193
|
-
done:
|
|
200
|
+
value: p.arg,
|
|
201
|
+
done: n.done
|
|
194
202
|
};
|
|
195
203
|
}
|
|
196
|
-
"throw" ===
|
|
204
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
197
205
|
}
|
|
198
206
|
};
|
|
199
207
|
}
|
|
200
|
-
function maybeInvokeDelegate(
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
if (
|
|
204
|
-
var
|
|
205
|
-
if ("throw" ===
|
|
206
|
-
var
|
|
207
|
-
return
|
|
208
|
+
function maybeInvokeDelegate(e, r) {
|
|
209
|
+
var n = r.method,
|
|
210
|
+
o = e.iterator[n];
|
|
211
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
212
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
213
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
214
|
+
var a = i.arg;
|
|
215
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
208
216
|
}
|
|
209
|
-
function pushTryEntry(
|
|
210
|
-
var
|
|
211
|
-
tryLoc:
|
|
217
|
+
function pushTryEntry(t) {
|
|
218
|
+
var e = {
|
|
219
|
+
tryLoc: t[0]
|
|
212
220
|
};
|
|
213
|
-
1 in
|
|
221
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
214
222
|
}
|
|
215
|
-
function resetTryEntry(
|
|
216
|
-
var
|
|
217
|
-
|
|
223
|
+
function resetTryEntry(t) {
|
|
224
|
+
var e = t.completion || {};
|
|
225
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
218
226
|
}
|
|
219
|
-
function Context(
|
|
227
|
+
function Context(t) {
|
|
220
228
|
this.tryEntries = [{
|
|
221
229
|
tryLoc: "root"
|
|
222
|
-
}],
|
|
230
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
223
231
|
}
|
|
224
|
-
function values(
|
|
225
|
-
if (
|
|
226
|
-
var
|
|
227
|
-
if (
|
|
228
|
-
if ("function" == typeof
|
|
229
|
-
if (!isNaN(
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
for (; ++
|
|
233
|
-
return next.value =
|
|
232
|
+
function values(e) {
|
|
233
|
+
if (e || "" === e) {
|
|
234
|
+
var r = e[a];
|
|
235
|
+
if (r) return r.call(e);
|
|
236
|
+
if ("function" == typeof e.next) return e;
|
|
237
|
+
if (!isNaN(e.length)) {
|
|
238
|
+
var o = -1,
|
|
239
|
+
i = function next() {
|
|
240
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
241
|
+
return next.value = t, next.done = !0, next;
|
|
234
242
|
};
|
|
235
|
-
return
|
|
243
|
+
return i.next = i;
|
|
236
244
|
}
|
|
237
245
|
}
|
|
238
|
-
|
|
239
|
-
next: doneResult
|
|
240
|
-
};
|
|
246
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
241
247
|
}
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
value: undefined,
|
|
245
|
-
done: !0
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
248
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
249
249
|
value: GeneratorFunctionPrototype,
|
|
250
250
|
configurable: !0
|
|
251
|
-
}),
|
|
251
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
252
252
|
value: GeneratorFunction,
|
|
253
253
|
configurable: !0
|
|
254
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype,
|
|
255
|
-
var
|
|
256
|
-
return !!
|
|
257
|
-
},
|
|
258
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(
|
|
259
|
-
},
|
|
254
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
255
|
+
var e = "function" == typeof t && t.constructor;
|
|
256
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
257
|
+
}, e.mark = function (t) {
|
|
258
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
259
|
+
}, e.awrap = function (t) {
|
|
260
260
|
return {
|
|
261
|
-
__await:
|
|
261
|
+
__await: t
|
|
262
262
|
};
|
|
263
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype,
|
|
263
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
264
264
|
return this;
|
|
265
|
-
}),
|
|
266
|
-
void 0 ===
|
|
267
|
-
var
|
|
268
|
-
return
|
|
269
|
-
return
|
|
265
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
266
|
+
void 0 === i && (i = Promise);
|
|
267
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
268
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
269
|
+
return t.done ? t.value : a.next();
|
|
270
270
|
});
|
|
271
|
-
}, defineIteratorMethods(
|
|
271
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
272
272
|
return this;
|
|
273
|
-
}), define(
|
|
273
|
+
}), define(g, "toString", function () {
|
|
274
274
|
return "[object Generator]";
|
|
275
|
-
}),
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
for (var
|
|
279
|
-
return
|
|
280
|
-
for (;
|
|
281
|
-
var
|
|
282
|
-
if (
|
|
275
|
+
}), e.keys = function (t) {
|
|
276
|
+
var e = Object(t),
|
|
277
|
+
r = [];
|
|
278
|
+
for (var n in e) r.push(n);
|
|
279
|
+
return r.reverse(), function next() {
|
|
280
|
+
for (; r.length;) {
|
|
281
|
+
var t = r.pop();
|
|
282
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
283
283
|
}
|
|
284
284
|
return next.done = !0, next;
|
|
285
285
|
};
|
|
286
|
-
},
|
|
286
|
+
}, e.values = values, Context.prototype = {
|
|
287
287
|
constructor: Context,
|
|
288
|
-
reset: function reset(
|
|
289
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent =
|
|
288
|
+
reset: function reset(e) {
|
|
289
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
290
290
|
},
|
|
291
291
|
stop: function stop() {
|
|
292
292
|
this.done = !0;
|
|
293
|
-
var
|
|
294
|
-
if ("throw" ===
|
|
293
|
+
var t = this.tryEntries[0].completion;
|
|
294
|
+
if ("throw" === t.type) throw t.arg;
|
|
295
295
|
return this.rval;
|
|
296
296
|
},
|
|
297
|
-
dispatchException: function dispatchException(
|
|
298
|
-
if (this.done) throw
|
|
299
|
-
var
|
|
300
|
-
function handle(
|
|
301
|
-
return
|
|
297
|
+
dispatchException: function dispatchException(e) {
|
|
298
|
+
if (this.done) throw e;
|
|
299
|
+
var r = this;
|
|
300
|
+
function handle(n, o) {
|
|
301
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
302
302
|
}
|
|
303
|
-
for (var
|
|
304
|
-
var
|
|
305
|
-
|
|
306
|
-
if ("root" ===
|
|
307
|
-
if (
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
if (
|
|
311
|
-
if (this.prev <
|
|
312
|
-
if (this.prev <
|
|
313
|
-
} else if (
|
|
314
|
-
if (this.prev <
|
|
303
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
304
|
+
var i = this.tryEntries[o],
|
|
305
|
+
a = i.completion;
|
|
306
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
307
|
+
if (i.tryLoc <= this.prev) {
|
|
308
|
+
var c = n.call(i, "catchLoc"),
|
|
309
|
+
u = n.call(i, "finallyLoc");
|
|
310
|
+
if (c && u) {
|
|
311
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
312
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
313
|
+
} else if (c) {
|
|
314
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
315
315
|
} else {
|
|
316
|
-
if (!
|
|
317
|
-
if (this.prev <
|
|
316
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
317
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
},
|
|
322
|
-
abrupt: function abrupt(
|
|
323
|
-
for (var
|
|
324
|
-
var
|
|
325
|
-
if (
|
|
326
|
-
var
|
|
322
|
+
abrupt: function abrupt(t, e) {
|
|
323
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
324
|
+
var o = this.tryEntries[r];
|
|
325
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
326
|
+
var i = o;
|
|
327
327
|
break;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
|
|
331
|
-
var
|
|
332
|
-
return
|
|
330
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
331
|
+
var a = i ? i.completion : {};
|
|
332
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
333
333
|
},
|
|
334
|
-
complete: function complete(
|
|
335
|
-
if ("throw" ===
|
|
336
|
-
return "break" ===
|
|
334
|
+
complete: function complete(t, e) {
|
|
335
|
+
if ("throw" === t.type) throw t.arg;
|
|
336
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
337
337
|
},
|
|
338
|
-
finish: function finish(
|
|
339
|
-
for (var
|
|
340
|
-
var
|
|
341
|
-
if (
|
|
338
|
+
finish: function finish(t) {
|
|
339
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
340
|
+
var r = this.tryEntries[e];
|
|
341
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
|
-
"catch": function _catch(
|
|
345
|
-
for (var
|
|
346
|
-
var
|
|
347
|
-
if (
|
|
348
|
-
var
|
|
349
|
-
if ("throw" ===
|
|
350
|
-
var
|
|
351
|
-
resetTryEntry(
|
|
344
|
+
"catch": function _catch(t) {
|
|
345
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
346
|
+
var r = this.tryEntries[e];
|
|
347
|
+
if (r.tryLoc === t) {
|
|
348
|
+
var n = r.completion;
|
|
349
|
+
if ("throw" === n.type) {
|
|
350
|
+
var o = n.arg;
|
|
351
|
+
resetTryEntry(r);
|
|
352
352
|
}
|
|
353
|
-
return
|
|
353
|
+
return o;
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
throw new Error("illegal catch attempt");
|
|
357
357
|
},
|
|
358
|
-
delegateYield: function delegateYield(
|
|
358
|
+
delegateYield: function delegateYield(e, r, n) {
|
|
359
359
|
return this.delegate = {
|
|
360
|
-
iterator: values(
|
|
361
|
-
resultName:
|
|
362
|
-
nextLoc:
|
|
363
|
-
}, "next" === this.method && (this.arg =
|
|
360
|
+
iterator: values(e),
|
|
361
|
+
resultName: r,
|
|
362
|
+
nextLoc: n
|
|
363
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
364
364
|
}
|
|
365
|
-
},
|
|
365
|
+
}, e;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -495,510 +495,6 @@ function _createSuper(Derived) {
|
|
|
495
495
|
};
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
function _arrayWithHoles(arr) {
|
|
499
|
-
if (Array.isArray(arr)) return arr;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function _iterableToArrayLimit(arr, i) {
|
|
503
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
504
|
-
if (null != _i) {
|
|
505
|
-
var _s,
|
|
506
|
-
_e,
|
|
507
|
-
_x,
|
|
508
|
-
_r,
|
|
509
|
-
_arr = [],
|
|
510
|
-
_n = !0,
|
|
511
|
-
_d = !1;
|
|
512
|
-
try {
|
|
513
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
514
|
-
if (Object(_i) !== _i) return;
|
|
515
|
-
_n = !1;
|
|
516
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
517
|
-
} catch (err) {
|
|
518
|
-
_d = !0, _e = err;
|
|
519
|
-
} finally {
|
|
520
|
-
try {
|
|
521
|
-
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
522
|
-
} finally {
|
|
523
|
-
if (_d) throw _e;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return _arr;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
function _arrayLikeToArray(arr, len) {
|
|
531
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
532
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
533
|
-
return arr2;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
537
|
-
if (!o) return;
|
|
538
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
539
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
540
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
541
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
542
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
function _nonIterableRest() {
|
|
546
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function _slicedToArray(arr, i) {
|
|
550
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Function getCircularReplacer() : Reduce circular references.
|
|
555
|
-
*
|
|
556
|
-
* @copyright https://stackoverflow.com/a/53731154
|
|
557
|
-
*/
|
|
558
|
-
var getCircularReplacer = function getCircularReplacer() {
|
|
559
|
-
var seen = new WeakSet();
|
|
560
|
-
return function (key, value) {
|
|
561
|
-
if (_typeof(value) === "object" && value !== null) {
|
|
562
|
-
if (seen.has(value)) {
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
seen.add(value);
|
|
566
|
-
}
|
|
567
|
-
return value;
|
|
568
|
-
};
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Function hexColorDelta() : Return color difference in ratio decimal point.
|
|
573
|
-
*
|
|
574
|
-
* @copyright http://jsfiddle.net/96sME/
|
|
575
|
-
*/
|
|
576
|
-
var hexColorDelta = function hexColorDelta(hex1, hex2) {
|
|
577
|
-
hex1 = hex1.replace("#", "");
|
|
578
|
-
hex2 = hex2.replace("#", "");
|
|
579
|
-
// Get red/green/blue int values of hex1
|
|
580
|
-
var r1 = parseInt(hex1.substring(0, 2), 16);
|
|
581
|
-
var g1 = parseInt(hex1.substring(2, 4), 16);
|
|
582
|
-
var b1 = parseInt(hex1.substring(4, 6), 16);
|
|
583
|
-
// Get red/green/blue int values of hex2
|
|
584
|
-
var r2 = parseInt(hex2.substring(0, 2), 16);
|
|
585
|
-
var g2 = parseInt(hex2.substring(2, 4), 16);
|
|
586
|
-
var b2 = parseInt(hex2.substring(4, 6), 16);
|
|
587
|
-
// Calculate differences between reds, greens and blues
|
|
588
|
-
var r = 255 - Math.abs(r1 - r2);
|
|
589
|
-
var g = 255 - Math.abs(g1 - g2);
|
|
590
|
-
var b = 255 - Math.abs(b1 - b2);
|
|
591
|
-
// Limit differences between 0 and 1
|
|
592
|
-
r /= 255;
|
|
593
|
-
g /= 255;
|
|
594
|
-
b /= 255;
|
|
595
|
-
// 0 means opposite colors, 1 means same colors
|
|
596
|
-
return (r + g + b) / 3;
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
var index$7 = /*#__PURE__*/Object.freeze({
|
|
600
|
-
__proto__: null,
|
|
601
|
-
getCircularReplacer: getCircularReplacer,
|
|
602
|
-
hexColorDelta: hexColorDelta
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
// TODO: Should by dynamic/configure-able.
|
|
606
|
-
var MAX_WRAPPING_RECURSIVE_DEPTH = 4,
|
|
607
|
-
STACK_BACKWARD_CALLER_INDEX = 3,
|
|
608
|
-
UNKNOWN_CALLER_NAME = 'anonymous function',
|
|
609
|
-
BABEL_EXCLUDE_FUNCTIONS_NAMES = ['_callee', 'tryCatch', '<anonymous>', 'Generator.next', 'asyncGeneratorStep', '_next'];
|
|
610
|
-
// TODO: Should by dynamic/configure-able.
|
|
611
|
-
Error.stackTraceLimit = 50;
|
|
612
|
-
var Logger = /*#__PURE__*/function () {
|
|
613
|
-
/**
|
|
614
|
-
* Function constructor() : Create logger class.
|
|
615
|
-
*/
|
|
616
|
-
function Logger(owner) {
|
|
617
|
-
var _globalThis$process;
|
|
618
|
-
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
619
|
-
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
620
|
-
_classCallCheck(this, Logger);
|
|
621
|
-
_defineProperty(this, "args", {});
|
|
622
|
-
_defineProperty(this, "state", false);
|
|
623
|
-
if ('off' === ((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process.env['flow_modules_logger'])) {
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
this.state = isActive;
|
|
627
|
-
this.args = args;
|
|
628
|
-
this.name = "";
|
|
629
|
-
if (typeof owner == "string") {
|
|
630
|
-
this.name = owner;
|
|
631
|
-
} else {
|
|
632
|
-
this.name = owner.constructor.name;
|
|
633
|
-
}
|
|
634
|
-
if (isActive) {
|
|
635
|
-
this.initialize();
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Function initialize() : Initialize logger class.
|
|
640
|
-
*/
|
|
641
|
-
_createClass(Logger, [{
|
|
642
|
-
key: "initialize",
|
|
643
|
-
value: function initialize() {
|
|
644
|
-
// @ts-ignore
|
|
645
|
-
if (this.args.sameColor) {
|
|
646
|
-
if (!Logger.sharedData[this.name]) {
|
|
647
|
-
Logger.sharedData[this.name] = this.getRandomColor();
|
|
648
|
-
}
|
|
649
|
-
this.color = Logger.sharedData[this.name];
|
|
650
|
-
} else {
|
|
651
|
-
this.color = this.getRandomColor();
|
|
652
|
-
Logger.colorsInUse.push(this.color);
|
|
653
|
-
}
|
|
654
|
-
this.outputHandler = console.log;
|
|
655
|
-
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"];
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Function setOutputHandler() : Set custom output handler.
|
|
659
|
-
*/
|
|
660
|
-
}, {
|
|
661
|
-
key: "setOutputHandler",
|
|
662
|
-
value: function setOutputHandler(outputHandler) {
|
|
663
|
-
this.outputHandler = outputHandler;
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Function useWrapper() : Search for customized log view, each instance,
|
|
667
|
-
* that typeof the instance was registered wrapper will have unique output
|
|
668
|
-
* according to the registered callback.
|
|
669
|
-
*/
|
|
670
|
-
}, {
|
|
671
|
-
key: "useWrapper",
|
|
672
|
-
value: function useWrapper(obj) {
|
|
673
|
-
var _this = this;
|
|
674
|
-
var shouldHandleChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
675
|
-
if (!obj || 'object' !== _typeof(obj) || Array.isArray(obj)) {
|
|
676
|
-
return obj;
|
|
677
|
-
}
|
|
678
|
-
Logger.wrapperDepth++;
|
|
679
|
-
// Result will lose classType (instanceOf will not work), now based on obj.
|
|
680
|
-
var result = _objectSpread2({}, obj);
|
|
681
|
-
// @ts-ignore
|
|
682
|
-
Object.values(Logger.wrappers).forEach(function (_ref) {
|
|
683
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
684
|
-
wrapper = _ref2[0];
|
|
685
|
-
if (obj instanceof wrapper.classType) {
|
|
686
|
-
result = wrapper.callback(obj) || result;
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
if (Logger.wrapperDepth >= MAX_WRAPPING_RECURSIVE_DEPTH) {
|
|
690
|
-
Logger.wrapperDepth--;
|
|
691
|
-
return result;
|
|
692
|
-
}
|
|
693
|
-
if (shouldHandleChildren && result) {
|
|
694
|
-
Object.entries(result).forEach(function (_ref3) {
|
|
695
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
696
|
-
key = _ref4[0],
|
|
697
|
-
value = _ref4[1];
|
|
698
|
-
result[key] = _this.useWrapper(value, true);
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
Logger.wrapperDepth--;
|
|
702
|
-
return result;
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Function startEmpty() : Notify function start without args.
|
|
706
|
-
*
|
|
707
|
-
* @param {string} output
|
|
708
|
-
*/
|
|
709
|
-
}, {
|
|
710
|
-
key: "startEmpty",
|
|
711
|
-
value: function startEmpty() {
|
|
712
|
-
var output = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
713
|
-
if (!this.state) return;
|
|
714
|
-
this.printFunctionNotify("se", Logger.getCallerName(), output);
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Function startWith() : Notify function start with args.
|
|
718
|
-
*
|
|
719
|
-
* TODO: Rename to startsWith
|
|
720
|
-
*/
|
|
721
|
-
}, {
|
|
722
|
-
key: "startWith",
|
|
723
|
-
value: function startWith(params) {
|
|
724
|
-
if (!this.state) return;
|
|
725
|
-
params = Object.assign({}, params);
|
|
726
|
-
var type = "se";
|
|
727
|
-
var source = Logger.getCallerName();
|
|
728
|
-
if (typeof params == "string") {
|
|
729
|
-
this.printInLineString(type, source, params);
|
|
730
|
-
} else if (Object.keys(params).length === 1) {
|
|
731
|
-
var key = Object.keys(params)[0];
|
|
732
|
-
var value = Object.values(params)[0];
|
|
733
|
-
// TODO: Check is repeated logic, handle it.
|
|
734
|
-
if (_typeof(value) === "object") {
|
|
735
|
-
this.printNextLineObject(type, source, key, value || {});
|
|
736
|
-
} else if (typeof value == "function") {
|
|
737
|
-
this.printInLineFunction(type, source, key, value);
|
|
738
|
-
} else {
|
|
739
|
-
this.printInLineElement(type, source, key, value);
|
|
740
|
-
}
|
|
741
|
-
} else {
|
|
742
|
-
this.printMultiLineObject(type, source, params);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
* Function object() : Prints object.
|
|
747
|
-
**/
|
|
748
|
-
}, {
|
|
749
|
-
key: "object",
|
|
750
|
-
value: function object() {
|
|
751
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
752
|
-
var notice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
753
|
-
if (!this.state) return;
|
|
754
|
-
var source = Logger.getCallerName();
|
|
755
|
-
params = Object.create(params);
|
|
756
|
-
for (var key in params) {
|
|
757
|
-
if (_typeof(params[key]) === "object") {
|
|
758
|
-
params[key] = JSON.stringify(this.useWrapper(params[key]), getCircularReplacer());
|
|
759
|
-
}
|
|
760
|
-
this.out.apply(this, ["%c(ob)-> %c%c".concat(this.name, "%c::%c").concat(source, "%c() [").concat(notice, "] ->> ").concat(key, ": '").concat(params[key], "'%c")].concat(this.defaultStyle));
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Function debug() : Notify debug.
|
|
765
|
-
*/
|
|
766
|
-
}, {
|
|
767
|
-
key: "debug",
|
|
768
|
-
value: function debug(output) {
|
|
769
|
-
if (!this.state) return;
|
|
770
|
-
this.printFunctionNotify("db", Logger.getCallerName(), output);
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Function drop : Preview as continue of log which drop ite.
|
|
774
|
-
*/
|
|
775
|
-
}, {
|
|
776
|
-
key: "drop",
|
|
777
|
-
value: function drop(according, data) {
|
|
778
|
-
if (!this.state) return;
|
|
779
|
-
var source = Logger.getCallerName();
|
|
780
|
-
for (var key in according) {
|
|
781
|
-
this.out.apply(this, ["%c(dr)-> %c%c".concat(this.name, "%c::%c").concat(source, "%c() ->> corresponding ").concat(key, ": '").concat(according[key], "' RESULT: %c\u2193")].concat(this.defaultStyle));
|
|
782
|
-
}
|
|
783
|
-
this.out(data);
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* Function throw() : Throws logged error.
|
|
787
|
-
*/
|
|
788
|
-
}, {
|
|
789
|
-
key: "throw",
|
|
790
|
-
value: function _throw(output) {
|
|
791
|
-
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'null';
|
|
792
|
-
var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
793
|
-
this.printFunctionNotify("tw", Logger.getCallerName(), output);
|
|
794
|
-
if (params) this.printNextLineObject("tw", Logger.getCallerName(), name, params);
|
|
795
|
-
throw new Error().stack;
|
|
796
|
-
}
|
|
797
|
-
/**
|
|
798
|
-
* Function clone() : Create clone instance.
|
|
799
|
-
*/
|
|
800
|
-
}, {
|
|
801
|
-
key: "clone",
|
|
802
|
-
value: function clone() {
|
|
803
|
-
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Function printFunctionNotify() : Print simple log for notify source (function).
|
|
807
|
-
*
|
|
808
|
-
*/
|
|
809
|
-
}, {
|
|
810
|
-
key: "printFunctionNotify",
|
|
811
|
-
value: function printFunctionNotify(type, source, output) {
|
|
812
|
-
this.out.apply(this, ["%c(".concat(type, ")-> %c%c").concat(this.name, "%c::%c").concat(source, "%c() ").concat(output, "%c")].concat(this.defaultStyle));
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Function printInLineElement() : Print in line element.
|
|
816
|
-
*/
|
|
817
|
-
}, {
|
|
818
|
-
key: "printInLineElement",
|
|
819
|
-
value: function printInLineElement(type, source, key, value) {
|
|
820
|
-
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));
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Function printInLineFunction() : Print in line function.
|
|
824
|
-
*/
|
|
825
|
-
}, {
|
|
826
|
-
key: "printInLineFunction",
|
|
827
|
-
value: function printInLineFunction(type, source, key, fn) {
|
|
828
|
-
fn = Logger.getFunctionView(fn);
|
|
829
|
-
this.printInLineElement(type, source, key, fn);
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Function printInLineString() : Print in line string.
|
|
833
|
-
*/
|
|
834
|
-
}, {
|
|
835
|
-
key: "printInLineString",
|
|
836
|
-
value: function printInLineString(type, source, string) {
|
|
837
|
-
this.printInLineElement(type, source, "(string)", string);
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Function printNextLineObject() : Print object in next line.
|
|
841
|
-
*/
|
|
842
|
-
}, {
|
|
843
|
-
key: "printNextLineObject",
|
|
844
|
-
value: function printNextLineObject(type, source, key, obj) {
|
|
845
|
-
obj = this.useWrapper(obj);
|
|
846
|
-
this.out.apply(this, ["%c(".concat(type, ")-> %c%c").concat(this.name, "%c::%c").concat(source, "%c() ->> ").concat(key, " %c\u2193")].concat(this.defaultStyle));
|
|
847
|
-
// print in next line
|
|
848
|
-
this.out(obj);
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* Function printMultiLineObject() : Print object in multiline format.
|
|
852
|
-
*/
|
|
853
|
-
}, {
|
|
854
|
-
key: "printMultiLineObject",
|
|
855
|
-
value: function printMultiLineObject(type, source, obj) {
|
|
856
|
-
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));
|
|
857
|
-
for (var key in obj) {
|
|
858
|
-
var value = obj[key];
|
|
859
|
-
if (_typeof(value) === "object") {
|
|
860
|
-
value = JSON.stringify(this.useWrapper(value), getCircularReplacer());
|
|
861
|
-
} else if (typeof obj[key] == "function") {
|
|
862
|
-
value = Logger.getFunctionView(value);
|
|
863
|
-
}
|
|
864
|
-
this.out.apply(this, ["%c" + key + ": `" + this.useWrapper(value) + "`", "color: #a3a3a3"]);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Function getRandomColor() : Return random color.
|
|
869
|
-
*/
|
|
870
|
-
}, {
|
|
871
|
-
key: "getRandomColor",
|
|
872
|
-
value: function getRandomColor() {
|
|
873
|
-
var letters = "0123456789ABCDEF";
|
|
874
|
-
var color = "#";
|
|
875
|
-
for (var i = 0; i < 6; i++) {
|
|
876
|
-
color += letters[Math.floor(Math.random() * 16)];
|
|
877
|
-
}
|
|
878
|
-
var similar = Logger.colorsInUse.some(function (value) {
|
|
879
|
-
// it returns the ratio of difference... closer to 1.0 is less difference.
|
|
880
|
-
return hexColorDelta(color, value) >= 0.8;
|
|
881
|
-
});
|
|
882
|
-
// if the color is similar, try again.
|
|
883
|
-
if (similar) {
|
|
884
|
-
return this.getRandomColor();
|
|
885
|
-
}
|
|
886
|
-
return color;
|
|
887
|
-
}
|
|
888
|
-
/**
|
|
889
|
-
* Function out() : Print console log with style
|
|
890
|
-
*/
|
|
891
|
-
}, {
|
|
892
|
-
key: "out",
|
|
893
|
-
value: function out() {
|
|
894
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
895
|
-
args[_key] = arguments[_key];
|
|
896
|
-
}
|
|
897
|
-
this.outputHandler.apply(this, args);
|
|
898
|
-
}
|
|
899
|
-
}], [{
|
|
900
|
-
key: "getName",
|
|
901
|
-
value: function getName() {
|
|
902
|
-
return 'Core/Modules/Logger';
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Function reset() : Reset logger globals.
|
|
906
|
-
*/
|
|
907
|
-
}, {
|
|
908
|
-
key: "reset",
|
|
909
|
-
value: function reset() {
|
|
910
|
-
Logger.wrappers = {};
|
|
911
|
-
Logger.wrapperDepth = 0;
|
|
912
|
-
Logger.colorsInUse = [];
|
|
913
|
-
Logger.sharedData = {};
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Function createCustomWrapper() : Creates custom wrapper for log entities.
|
|
917
|
-
*/
|
|
918
|
-
}, {
|
|
919
|
-
key: "createCustomWrapper",
|
|
920
|
-
value: function createCustomWrapper(classType, callback) {
|
|
921
|
-
// @ts-ignore
|
|
922
|
-
if (!Logger.wrappers[classType]) {
|
|
923
|
-
// @ts-ignore
|
|
924
|
-
Logger.wrappers[classType.name] = [];
|
|
925
|
-
}
|
|
926
|
-
// @ts-ignore
|
|
927
|
-
Logger.wrappers[classType.name].push({
|
|
928
|
-
classType: classType,
|
|
929
|
-
callback: callback
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Function getCallerName() : Return caller name.
|
|
934
|
-
*/
|
|
935
|
-
}, {
|
|
936
|
-
key: "getCallerName",
|
|
937
|
-
value: function getCallerName() {
|
|
938
|
-
var _error$stack;
|
|
939
|
-
var error = new Error(),
|
|
940
|
-
errorsPerLine = ((_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : _error$stack.split("\n")) || [],
|
|
941
|
-
caller = errorsPerLine.length ? errorsPerLine[STACK_BACKWARD_CALLER_INDEX].trim() : UNKNOWN_CALLER_NAME;
|
|
942
|
-
if (caller.startsWith("at new")) {
|
|
943
|
-
return "constructor";
|
|
944
|
-
}
|
|
945
|
-
var extractName = caller.split(".")[1].split(" ")[0],
|
|
946
|
-
isBabelAsyncRuntime = false;
|
|
947
|
-
// Babel compatibility.
|
|
948
|
-
if (extractName.includes('_callee')) {
|
|
949
|
-
var _loop = function _loop() {
|
|
950
|
-
var line = errorsPerLine[i];
|
|
951
|
-
var isExcluded = BABEL_EXCLUDE_FUNCTIONS_NAMES.some(function (excludeName) {
|
|
952
|
-
return line.includes(excludeName);
|
|
953
|
-
});
|
|
954
|
-
if (!isExcluded) {
|
|
955
|
-
var format = line.trim().split(' ');
|
|
956
|
-
if (format.length <= 2) {
|
|
957
|
-
return "continue";
|
|
958
|
-
}
|
|
959
|
-
extractName = format[1].split(".")[1];
|
|
960
|
-
isBabelAsyncRuntime = true;
|
|
961
|
-
return "break";
|
|
962
|
-
}
|
|
963
|
-
};
|
|
964
|
-
// Run till find reliable function name.
|
|
965
|
-
for (var i = STACK_BACKWARD_CALLER_INDEX; i < errorsPerLine.length; i++) {
|
|
966
|
-
var _ret = _loop();
|
|
967
|
-
if (_ret === "continue") continue;
|
|
968
|
-
if (_ret === "break") break;
|
|
969
|
-
}
|
|
970
|
-
if (!isBabelAsyncRuntime) {
|
|
971
|
-
extractName = UNKNOWN_CALLER_NAME;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
return extractName;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Function functionView() : Return function preview.
|
|
978
|
-
*/
|
|
979
|
-
}, {
|
|
980
|
-
key: "getFunctionView",
|
|
981
|
-
value: function getFunctionView(fn) {
|
|
982
|
-
var fReturn = UNKNOWN_CALLER_NAME;
|
|
983
|
-
// TODO: Check if works.
|
|
984
|
-
if (typeof fn !== "string" && fn.name.length !== 0) {
|
|
985
|
-
fReturn = fn.name.split(" ")[1] + "()";
|
|
986
|
-
}
|
|
987
|
-
return fReturn;
|
|
988
|
-
}
|
|
989
|
-
}]);
|
|
990
|
-
return Logger;
|
|
991
|
-
}();
|
|
992
|
-
_defineProperty(Logger, "wrappers", {});
|
|
993
|
-
_defineProperty(Logger, "wrapperDepth", 0);
|
|
994
|
-
_defineProperty(Logger, "sharedData", {});
|
|
995
|
-
_defineProperty(Logger, "colorsInUse", []);
|
|
996
|
-
|
|
997
|
-
var index$6 = /*#__PURE__*/Object.freeze({
|
|
998
|
-
__proto__: null,
|
|
999
|
-
Logger: Logger
|
|
1000
|
-
});
|
|
1001
|
-
|
|
1002
498
|
function _isNativeFunction(fn) {
|
|
1003
499
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
1004
500
|
}
|
|
@@ -1046,6 +542,121 @@ function _wrapNativeSuper(Class) {
|
|
|
1046
542
|
return _wrapNativeSuper(Class);
|
|
1047
543
|
}
|
|
1048
544
|
|
|
545
|
+
/**
|
|
546
|
+
* @internal
|
|
547
|
+
*/
|
|
548
|
+
var ForceMethodBase = /*#__PURE__*/function (_Error) {
|
|
549
|
+
_inherits(ForceMethodBase, _Error);
|
|
550
|
+
var _super = _createSuper(ForceMethodBase);
|
|
551
|
+
function ForceMethodBase(className, methodName) {
|
|
552
|
+
_classCallCheck(this, ForceMethodBase);
|
|
553
|
+
return _super.call(this, "ForceMethod implementation: at: '".concat(className, "' method: '").concat(methodName, "'"));
|
|
554
|
+
}
|
|
555
|
+
return _createClass(ForceMethodBase);
|
|
556
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* @public
|
|
560
|
+
*/
|
|
561
|
+
var ForceMethodImplementation = /*#__PURE__*/function (_Error2) {
|
|
562
|
+
_inherits(ForceMethodImplementation, _Error2);
|
|
563
|
+
var _super2 = _createSuper(ForceMethodImplementation);
|
|
564
|
+
function ForceMethodImplementation(context, methodName) {
|
|
565
|
+
_classCallCheck(this, ForceMethodImplementation);
|
|
566
|
+
return _super2.call(this, "ForceMethod implementation: at: '".concat("string" === typeof context ? context : context.getName(), "' method: '").concat(methodName, "'"));
|
|
567
|
+
}
|
|
568
|
+
return _createClass(ForceMethodImplementation);
|
|
569
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
570
|
+
|
|
571
|
+
var ObjectBase = /*#__PURE__*/function () {
|
|
572
|
+
/**
|
|
573
|
+
* Initializes the name and unique identifier for the instance.
|
|
574
|
+
*/
|
|
575
|
+
function ObjectBase() {
|
|
576
|
+
_classCallCheck(this, ObjectBase);
|
|
577
|
+
_defineProperty(this, "name", "__UNDEFINED_NAME__");
|
|
578
|
+
// Initialize the name by calling the abstract method getName()
|
|
579
|
+
this.name = this.getName();
|
|
580
|
+
|
|
581
|
+
// Generate a unique identifier using a combination of timestamp and random numbers
|
|
582
|
+
var timestamp = performance.now() * 1000000;
|
|
583
|
+
var random1 = BigInt(Math.floor(Math.random() * 1000000));
|
|
584
|
+
var random2 = BigInt(Math.floor(Math.random() * 1000000));
|
|
585
|
+
this._id = "".concat(timestamp).concat(random1).concat(random2);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Static method to retrieve the name of the class. This method is abstract and must be implemented
|
|
590
|
+
* by derived classes.
|
|
591
|
+
*/
|
|
592
|
+
_createClass(ObjectBase, [{
|
|
593
|
+
key: "getName",
|
|
594
|
+
value:
|
|
595
|
+
/**
|
|
596
|
+
* Retrieves the name of the current instance by calling the static `getName()` method of the
|
|
597
|
+
* constructor (derived class).
|
|
598
|
+
*/
|
|
599
|
+
function getName() {
|
|
600
|
+
return this.constructor.getName();
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Retrieves the unique identifier of the current instance.
|
|
605
|
+
*/
|
|
606
|
+
}, {
|
|
607
|
+
key: "getUniqueId",
|
|
608
|
+
value: function getUniqueId() {
|
|
609
|
+
return this._id;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Retrieves the initial name that was set during construction. This name may be "__UNDEFINED_NAME__"
|
|
614
|
+
* if the `getName()` method of the derived class does not provide a valid name.
|
|
615
|
+
*/
|
|
616
|
+
}, {
|
|
617
|
+
key: "getInitialName",
|
|
618
|
+
value: function getInitialName() {
|
|
619
|
+
return this.name;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Retrieves an array of hierarchical class names from the current instance up to the `ObjectBase` class.
|
|
624
|
+
*/
|
|
625
|
+
}, {
|
|
626
|
+
key: "getHierarchyNames",
|
|
627
|
+
value: function getHierarchyNames() {
|
|
628
|
+
var classNames = [];
|
|
629
|
+
var obj = Object.getPrototypeOf(this);
|
|
630
|
+
var className;
|
|
631
|
+
|
|
632
|
+
// Traverse the prototype chain and collect class names until the base ObjectBase class is reached.
|
|
633
|
+
while ((className = obj.getName()) !== "Object") {
|
|
634
|
+
classNames.push(className);
|
|
635
|
+
obj = Object.getPrototypeOf(obj);
|
|
636
|
+
|
|
637
|
+
// Break the loop if the prototype's constructor is ObjectBase (reached the base class).
|
|
638
|
+
if (obj.constructor === ObjectBase) {
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return classNames;
|
|
643
|
+
}
|
|
644
|
+
}], [{
|
|
645
|
+
key: "getName",
|
|
646
|
+
value: function getName() {
|
|
647
|
+
throw new ForceMethodBase("ObjectBase", "getName");
|
|
648
|
+
}
|
|
649
|
+
}]);
|
|
650
|
+
return ObjectBase;
|
|
651
|
+
}();
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
655
|
+
*/
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* @internal
|
|
659
|
+
*/
|
|
1049
660
|
var CommandAlreadyRegistered = /*#__PURE__*/function (_Error) {
|
|
1050
661
|
_inherits(CommandAlreadyRegistered, _Error);
|
|
1051
662
|
var _super = _createSuper(CommandAlreadyRegistered);
|
|
@@ -1057,7 +668,11 @@ var CommandAlreadyRegistered = /*#__PURE__*/function (_Error) {
|
|
|
1057
668
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1058
669
|
|
|
1059
670
|
/**
|
|
1060
|
-
* @author
|
|
671
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
672
|
+
*/
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* @internal
|
|
1061
676
|
*/
|
|
1062
677
|
var CommandNotFound = /*#__PURE__*/function (_Error) {
|
|
1063
678
|
_inherits(CommandNotFound, _Error);
|
|
@@ -1069,6 +684,13 @@ var CommandNotFound = /*#__PURE__*/function (_Error) {
|
|
|
1069
684
|
return _createClass(CommandNotFound);
|
|
1070
685
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1071
686
|
|
|
687
|
+
/**
|
|
688
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
689
|
+
*/
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* @internal
|
|
693
|
+
*/
|
|
1072
694
|
var ControllerAlreadyRegistered = /*#__PURE__*/function (_Error) {
|
|
1073
695
|
_inherits(ControllerAlreadyRegistered, _Error);
|
|
1074
696
|
var _super = _createSuper(ControllerAlreadyRegistered);
|
|
@@ -1080,74 +702,22 @@ var ControllerAlreadyRegistered = /*#__PURE__*/function (_Error) {
|
|
|
1080
702
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1081
703
|
|
|
1082
704
|
/**
|
|
1083
|
-
* @author
|
|
705
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
706
|
+
*/
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* @internal
|
|
1084
710
|
*/
|
|
1085
711
|
var ControllerAlreadySet = /*#__PURE__*/function (_Error) {
|
|
1086
712
|
_inherits(ControllerAlreadySet, _Error);
|
|
1087
713
|
var _super = _createSuper(ControllerAlreadySet);
|
|
1088
|
-
function ControllerAlreadySet() {
|
|
714
|
+
function ControllerAlreadySet(controller) {
|
|
1089
715
|
_classCallCheck(this, ControllerAlreadySet);
|
|
1090
|
-
return _super.call(this,
|
|
716
|
+
return _super.call(this, "Controller: '".concat(controller.getName(), "' is already set"));
|
|
1091
717
|
}
|
|
1092
718
|
return _createClass(ControllerAlreadySet);
|
|
1093
719
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1094
720
|
|
|
1095
|
-
var ForceMethodBase = /*#__PURE__*/function (_Error) {
|
|
1096
|
-
_inherits(ForceMethodBase, _Error);
|
|
1097
|
-
var _super = _createSuper(ForceMethodBase);
|
|
1098
|
-
function ForceMethodBase(className, methodName) {
|
|
1099
|
-
_classCallCheck(this, ForceMethodBase);
|
|
1100
|
-
return _super.call(this, "ForeMethod implementation: at '".concat(className, "' method: '").concat(methodName, "'"));
|
|
1101
|
-
}
|
|
1102
|
-
return _createClass(ForceMethodBase);
|
|
1103
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1104
|
-
var ForceMethod = /*#__PURE__*/function (_Error2) {
|
|
1105
|
-
_inherits(ForceMethod, _Error2);
|
|
1106
|
-
var _super2 = _createSuper(ForceMethod);
|
|
1107
|
-
function ForceMethod(context, methodName) {
|
|
1108
|
-
_classCallCheck(this, ForceMethod);
|
|
1109
|
-
return _super2.call(this, "ForeMethod implementation: at '".concat(context.getName(), "' method: '").concat(methodName, "'"));
|
|
1110
|
-
}
|
|
1111
|
-
return _createClass(ForceMethod);
|
|
1112
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1113
|
-
|
|
1114
|
-
var index$5 = /*#__PURE__*/Object.freeze({
|
|
1115
|
-
__proto__: null,
|
|
1116
|
-
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
1117
|
-
CommandNotFound: CommandNotFound,
|
|
1118
|
-
ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
1119
|
-
ControllerAlreadySet: ControllerAlreadySet,
|
|
1120
|
-
ForceMethod: ForceMethod
|
|
1121
|
-
});
|
|
1122
|
-
|
|
1123
|
-
var IdCounter = 0;
|
|
1124
|
-
/**
|
|
1125
|
-
* Base class 4 *
|
|
1126
|
-
*/
|
|
1127
|
-
var ObjectBase = /*#__PURE__*/function () {
|
|
1128
|
-
function ObjectBase() {
|
|
1129
|
-
_classCallCheck(this, ObjectBase);
|
|
1130
|
-
_defineProperty(this, "virtualId", 0);
|
|
1131
|
-
this.virtualId = IdCounter;
|
|
1132
|
-
APIIncreaseIdCounter();
|
|
1133
|
-
}
|
|
1134
|
-
_createClass(ObjectBase, [{
|
|
1135
|
-
key: "getName",
|
|
1136
|
-
value: function getName() {
|
|
1137
|
-
return this.constructor.getName();
|
|
1138
|
-
}
|
|
1139
|
-
}], [{
|
|
1140
|
-
key: "getName",
|
|
1141
|
-
value: function getName() {
|
|
1142
|
-
throw new ForceMethodBase("ObjectBase", "getName");
|
|
1143
|
-
}
|
|
1144
|
-
}]);
|
|
1145
|
-
return ObjectBase;
|
|
1146
|
-
}();
|
|
1147
|
-
function APIIncreaseIdCounter() {
|
|
1148
|
-
return IdCounter++;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
721
|
var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
1152
722
|
_inherits(Commands, _ObjectBase);
|
|
1153
723
|
var _super = _createSuper(Commands);
|
|
@@ -1165,8 +735,9 @@ var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1165
735
|
_defineProperty(_assertThisInitialized(_this), "onAfterOnceHooks", {});
|
|
1166
736
|
_defineProperty(_assertThisInitialized(_this), "onAfterUIHooks", {});
|
|
1167
737
|
_defineProperty(_assertThisInitialized(_this), "onAfterAffectHooks", {});
|
|
1168
|
-
|
|
1169
|
-
_this.logger.
|
|
738
|
+
var type = _this.constructor;
|
|
739
|
+
_this.logger = new ZenCore.classes.Logger(type);
|
|
740
|
+
_this.logger.startsEmpty(_this.constructor);
|
|
1170
741
|
return _this;
|
|
1171
742
|
}
|
|
1172
743
|
_createClass(Commands, [{
|
|
@@ -1207,6 +778,7 @@ var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1207
778
|
key: "register",
|
|
1208
779
|
value: function register(commands, controller) {
|
|
1209
780
|
var _this2 = this;
|
|
781
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1210
782
|
var result = {};
|
|
1211
783
|
Object.values(commands).forEach(function (command) {
|
|
1212
784
|
var commandName = command.getName();
|
|
@@ -1243,51 +815,58 @@ var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1243
815
|
if (!CommandClass) {
|
|
1244
816
|
throw new CommandNotFound(name);
|
|
1245
817
|
}
|
|
818
|
+
|
|
1246
819
|
// @ts-ignore
|
|
1247
820
|
return new CommandClass(args, options);
|
|
1248
821
|
}
|
|
822
|
+
|
|
1249
823
|
/**
|
|
1250
|
-
*
|
|
824
|
+
* Used to set hooks that effects only data and not UI.
|
|
1251
825
|
*/
|
|
1252
826
|
}, {
|
|
1253
827
|
key: "onBefore",
|
|
1254
828
|
value: function onBefore(hookCommand, callback) {
|
|
1255
829
|
Commands.hookCommand(this.onBeforeHooks, hookCommand, callback);
|
|
1256
830
|
}
|
|
831
|
+
|
|
1257
832
|
/**
|
|
1258
|
-
*
|
|
833
|
+
* Used to set hooks that effects only UI.
|
|
1259
834
|
*/
|
|
1260
835
|
}, {
|
|
1261
836
|
key: "onBeforeUI",
|
|
1262
837
|
value: function onBeforeUI(hookCommand, callback) {
|
|
1263
838
|
Commands.hookCommand(this.onBeforeUIHooks, hookCommand, callback);
|
|
1264
839
|
}
|
|
840
|
+
|
|
1265
841
|
/**
|
|
1266
|
-
*
|
|
842
|
+
* Used to set hooks that effects only data and not UI.
|
|
1267
843
|
*/
|
|
1268
844
|
}, {
|
|
1269
845
|
key: "onAfter",
|
|
1270
846
|
value: function onAfter(hookCommand, callback) {
|
|
1271
847
|
Commands.hookCommand(this.onAfterHooks, hookCommand, callback);
|
|
1272
848
|
}
|
|
849
|
+
|
|
1273
850
|
/**
|
|
1274
|
-
*
|
|
851
|
+
* Used to set hooks that effects only UI.
|
|
1275
852
|
*/
|
|
1276
853
|
}, {
|
|
1277
854
|
key: "onAfterUI",
|
|
1278
855
|
value: function onAfterUI(command, callback) {
|
|
1279
856
|
Commands.hookCommand(this.onAfterUIHooks, command, callback);
|
|
1280
857
|
}
|
|
858
|
+
|
|
1281
859
|
/**
|
|
1282
|
-
*
|
|
860
|
+
* Used to set hooks that effects only data and not UI.
|
|
1283
861
|
*/
|
|
1284
862
|
}, {
|
|
1285
863
|
key: "onAfterOnce",
|
|
1286
864
|
value: function onAfterOnce(command, callback) {
|
|
1287
865
|
Commands.hookCommand(this.onAfterOnceHooks, command, callback);
|
|
1288
866
|
}
|
|
867
|
+
|
|
1289
868
|
/**
|
|
1290
|
-
*
|
|
869
|
+
* Used to register a trigger that runs command after `hookCommand` run's.
|
|
1291
870
|
*/
|
|
1292
871
|
}, {
|
|
1293
872
|
key: "onAfterAffect",
|
|
@@ -1325,22 +904,12 @@ var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1325
904
|
case 0:
|
|
1326
905
|
args = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
1327
906
|
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
1328
|
-
result = null;
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
});
|
|
1335
|
-
this.logger.debug("CommandArgs:");
|
|
1336
|
-
this.logger.object(args);
|
|
1337
|
-
} else {
|
|
1338
|
-
this.logger.startWith({
|
|
1339
|
-
command: command.getName(),
|
|
1340
|
-
options: options,
|
|
1341
|
-
args: args
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
907
|
+
result = null;
|
|
908
|
+
this.logger.startsWith(this.runInstance, {
|
|
909
|
+
command: command.getName(),
|
|
910
|
+
options: options,
|
|
911
|
+
args: args
|
|
912
|
+
});
|
|
1344
913
|
this.onBeforeRun(command, args, options);
|
|
1345
914
|
_context2.next = 7;
|
|
1346
915
|
return command.run();
|
|
@@ -1435,7 +1004,7 @@ var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1435
1004
|
}], [{
|
|
1436
1005
|
key: "getName",
|
|
1437
1006
|
value: function getName() {
|
|
1438
|
-
return
|
|
1007
|
+
return "ZenFlux/Core/Managers/Commands";
|
|
1439
1008
|
}
|
|
1440
1009
|
}, {
|
|
1441
1010
|
key: "runCallbacks",
|
|
@@ -1502,10 +1071,7 @@ var Controllers = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1502
1071
|
function Controllers() {
|
|
1503
1072
|
var _this;
|
|
1504
1073
|
_classCallCheck(this, Controllers);
|
|
1505
|
-
|
|
1506
|
-
args[_key] = arguments[_key];
|
|
1507
|
-
}
|
|
1508
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
1074
|
+
_this = _super.call(this);
|
|
1509
1075
|
_defineProperty(_assertThisInitialized(_this), "controllers", {});
|
|
1510
1076
|
return _this;
|
|
1511
1077
|
}
|
|
@@ -1525,6 +1091,7 @@ var Controllers = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1525
1091
|
if (this.controllers[controller.getName()]) {
|
|
1526
1092
|
throw new ControllerAlreadyRegistered(controller);
|
|
1527
1093
|
}
|
|
1094
|
+
|
|
1528
1095
|
// Register.
|
|
1529
1096
|
this.controllers[controller.getName()] = controller;
|
|
1530
1097
|
return controller;
|
|
@@ -1532,7 +1099,7 @@ var Controllers = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1532
1099
|
}], [{
|
|
1533
1100
|
key: "getName",
|
|
1534
1101
|
value: function getName() {
|
|
1535
|
-
return
|
|
1102
|
+
return "ZenFlux/Core/Managers/Controllers";
|
|
1536
1103
|
}
|
|
1537
1104
|
}]);
|
|
1538
1105
|
return Controllers;
|
|
@@ -1563,14 +1130,13 @@ function _get() {
|
|
|
1563
1130
|
return _get.apply(this, arguments);
|
|
1564
1131
|
}
|
|
1565
1132
|
|
|
1566
|
-
var E_RESPONSE_HANDLER_TYPE
|
|
1567
|
-
(function (E_RESPONSE_HANDLER_TYPE) {
|
|
1133
|
+
var E_RESPONSE_HANDLER_TYPE = /*#__PURE__*/function (E_RESPONSE_HANDLER_TYPE) {
|
|
1568
1134
|
E_RESPONSE_HANDLER_TYPE["ERROR_HANDLER"] = "error_handler";
|
|
1569
1135
|
E_RESPONSE_HANDLER_TYPE["RESPONSE_FILTER"] = "response_filter";
|
|
1570
1136
|
E_RESPONSE_HANDLER_TYPE["RESPONSE_HANDLER"] = "response_handler";
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1137
|
+
return E_RESPONSE_HANDLER_TYPE;
|
|
1138
|
+
}({});
|
|
1139
|
+
var E_HTTP_METHOD_TYPE = /*#__PURE__*/function (E_HTTP_METHOD_TYPE) {
|
|
1574
1140
|
E_HTTP_METHOD_TYPE["DELETE"] = "DELETE";
|
|
1575
1141
|
E_HTTP_METHOD_TYPE["GET"] = "GET";
|
|
1576
1142
|
E_HTTP_METHOD_TYPE["OPTIONS"] = "OPTIONS";
|
|
@@ -1578,46 +1144,49 @@ var E_HTTP_METHOD_TYPE;
|
|
|
1578
1144
|
E_HTTP_METHOD_TYPE["POST"] = "POST";
|
|
1579
1145
|
E_HTTP_METHOD_TYPE["PUT"] = "PUT";
|
|
1580
1146
|
E_HTTP_METHOD_TYPE["__EMPTY__"] = "";
|
|
1581
|
-
|
|
1147
|
+
return E_HTTP_METHOD_TYPE;
|
|
1148
|
+
}({});
|
|
1582
1149
|
|
|
1583
1150
|
/**
|
|
1584
|
-
* @author
|
|
1151
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1585
1152
|
*/
|
|
1586
1153
|
|
|
1587
|
-
var index$
|
|
1154
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
1588
1155
|
__proto__: null,
|
|
1589
|
-
|
|
1590
|
-
|
|
1156
|
+
E_HTTP_METHOD_TYPE: E_HTTP_METHOD_TYPE,
|
|
1157
|
+
E_RESPONSE_HANDLER_TYPE: E_RESPONSE_HANDLER_TYPE
|
|
1591
1158
|
});
|
|
1592
1159
|
|
|
1593
1160
|
// noinspection ExceptionCaughtLocallyJS
|
|
1161
|
+
|
|
1594
1162
|
var Http = /*#__PURE__*/function (_ObjectBase) {
|
|
1595
1163
|
_inherits(Http, _ObjectBase);
|
|
1596
1164
|
var _super = _createSuper(Http);
|
|
1597
1165
|
/**
|
|
1598
|
-
*
|
|
1166
|
+
* Initializes the base class and sets up configuration parameters.
|
|
1599
1167
|
*/
|
|
1600
1168
|
function Http() {
|
|
1601
1169
|
var _this;
|
|
1602
|
-
var apiBaseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
1170
|
+
var apiBaseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "http://localhost";
|
|
1603
1171
|
var requestInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1604
|
-
|
|
1172
|
+
"credentials": "include"
|
|
1605
1173
|
};
|
|
1606
1174
|
_classCallCheck(this, Http);
|
|
1607
1175
|
_this = _super.call(this);
|
|
1608
1176
|
_defineProperty(_assertThisInitialized(_this), "errorHandler", undefined);
|
|
1609
1177
|
_defineProperty(_assertThisInitialized(_this), "responseFilter", undefined);
|
|
1610
1178
|
_defineProperty(_assertThisInitialized(_this), "responseHandler", undefined);
|
|
1611
|
-
_this.logger = new Logger(Http
|
|
1612
|
-
_this.logger.
|
|
1179
|
+
_this.logger = new ZenCore.classes.Logger(Http);
|
|
1180
|
+
_this.logger.startsWith(_this.constructor, {
|
|
1613
1181
|
apiBaseUrl: apiBaseUrl
|
|
1614
1182
|
});
|
|
1615
|
-
_this.apiBaseUrl = apiBaseUrl +
|
|
1183
|
+
_this.apiBaseUrl = apiBaseUrl + "/";
|
|
1616
1184
|
_this.requestInit = requestInit;
|
|
1617
1185
|
return _this;
|
|
1618
1186
|
}
|
|
1187
|
+
|
|
1619
1188
|
/**
|
|
1620
|
-
*
|
|
1189
|
+
* Fetches data from the specified path using the given HTTP method and optional request body.
|
|
1621
1190
|
*/
|
|
1622
1191
|
_createClass(Http, [{
|
|
1623
1192
|
key: "fetch",
|
|
@@ -1626,29 +1195,30 @@ var Http = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1626
1195
|
var body,
|
|
1627
1196
|
params,
|
|
1628
1197
|
headers,
|
|
1198
|
+
fetchPromise,
|
|
1629
1199
|
response,
|
|
1630
1200
|
data,
|
|
1631
1201
|
_response$headers,
|
|
1632
|
-
_response$headers$get,
|
|
1633
1202
|
responseText,
|
|
1634
1203
|
_args = arguments;
|
|
1635
1204
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1636
1205
|
while (1) switch (_context.prev = _context.next) {
|
|
1637
1206
|
case 0:
|
|
1638
1207
|
body = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
1639
|
-
this.logger.
|
|
1208
|
+
this.logger.startsWith(this.constructor, {
|
|
1640
1209
|
path: path,
|
|
1641
1210
|
method: method,
|
|
1642
1211
|
body: body
|
|
1643
1212
|
});
|
|
1644
|
-
params = Object.assign({}, this.requestInit)
|
|
1213
|
+
params = Object.assign({}, this.requestInit);
|
|
1214
|
+
headers = {};
|
|
1645
1215
|
if (method === E_HTTP_METHOD_TYPE.GET) {
|
|
1646
1216
|
Object.assign(params, {
|
|
1647
1217
|
headers: headers
|
|
1648
1218
|
});
|
|
1649
1219
|
} else {
|
|
1650
1220
|
Object.assign(headers, {
|
|
1651
|
-
|
|
1221
|
+
"Content-Type": "application/json"
|
|
1652
1222
|
});
|
|
1653
1223
|
Object.assign(params, {
|
|
1654
1224
|
method: method,
|
|
@@ -1656,92 +1226,111 @@ var Http = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1656
1226
|
body: JSON.stringify(body)
|
|
1657
1227
|
});
|
|
1658
1228
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1229
|
+
fetchPromise = globalThis.fetch(this.apiBaseUrl + path, params);
|
|
1230
|
+
_context.next = 8;
|
|
1231
|
+
return fetchPromise;
|
|
1232
|
+
case 8:
|
|
1662
1233
|
response = _context.sent;
|
|
1663
|
-
|
|
1664
|
-
_context.prev = 8;
|
|
1665
|
-
if (response.ok) {
|
|
1234
|
+
if (response) {
|
|
1666
1235
|
_context.next = 11;
|
|
1667
1236
|
break;
|
|
1668
1237
|
}
|
|
1669
|
-
|
|
1238
|
+
return _context.abrupt("return", false);
|
|
1670
1239
|
case 11:
|
|
1671
|
-
|
|
1240
|
+
data = undefined;
|
|
1241
|
+
_context.prev = 12;
|
|
1242
|
+
if (response.ok) {
|
|
1243
|
+
_context.next = 15;
|
|
1244
|
+
break;
|
|
1245
|
+
}
|
|
1246
|
+
throw new Error(response.statusText);
|
|
1247
|
+
case 15:
|
|
1248
|
+
_context.next = 17;
|
|
1672
1249
|
return response.text();
|
|
1673
|
-
case
|
|
1250
|
+
case 17:
|
|
1674
1251
|
responseText = _context.sent;
|
|
1675
1252
|
responseText = this.applyResponseFilter(responseText);
|
|
1253
|
+
|
|
1676
1254
|
// TODO: Currently support JSON and plain text.
|
|
1677
|
-
if ((_response$headers = response.headers) !== null && _response$headers !== void 0 && (_response$headers
|
|
1255
|
+
if ((_response$headers = response.headers) !== null && _response$headers !== void 0 && (_response$headers = _response$headers.get("Content-Type")) !== null && _response$headers !== void 0 && _response$headers.includes("application/json")) {
|
|
1678
1256
|
data = JSON.parse(responseText);
|
|
1679
1257
|
} else {
|
|
1680
1258
|
data = responseText;
|
|
1681
1259
|
}
|
|
1682
1260
|
if (!this.applyResponseHandler(data)) {
|
|
1683
|
-
_context.next =
|
|
1261
|
+
_context.next = 22;
|
|
1684
1262
|
break;
|
|
1685
1263
|
}
|
|
1686
1264
|
return _context.abrupt("return", false);
|
|
1687
|
-
case
|
|
1688
|
-
_context.next =
|
|
1265
|
+
case 22:
|
|
1266
|
+
_context.next = 30;
|
|
1689
1267
|
break;
|
|
1690
|
-
case
|
|
1691
|
-
_context.prev =
|
|
1692
|
-
_context.t0 = _context["catch"](
|
|
1268
|
+
case 24:
|
|
1269
|
+
_context.prev = 24;
|
|
1270
|
+
_context.t0 = _context["catch"](12);
|
|
1693
1271
|
if (!this.applyErrorHandler(_context.t0)) {
|
|
1694
|
-
_context.next =
|
|
1272
|
+
_context.next = 28;
|
|
1695
1273
|
break;
|
|
1696
1274
|
}
|
|
1697
1275
|
return _context.abrupt("return", false);
|
|
1698
|
-
case
|
|
1699
|
-
_context.next =
|
|
1276
|
+
case 28:
|
|
1277
|
+
_context.next = 30;
|
|
1700
1278
|
return Promise.reject(_context.t0);
|
|
1701
|
-
case
|
|
1702
|
-
this.logger.drop({
|
|
1279
|
+
case 30:
|
|
1280
|
+
this.logger.drop(this.fetch, {
|
|
1703
1281
|
path: path
|
|
1704
1282
|
}, data);
|
|
1705
1283
|
return _context.abrupt("return", data);
|
|
1706
|
-
case
|
|
1284
|
+
case 32:
|
|
1707
1285
|
case "end":
|
|
1708
1286
|
return _context.stop();
|
|
1709
1287
|
}
|
|
1710
|
-
}, _callee, this, [[
|
|
1288
|
+
}, _callee, this, [[12, 24]]);
|
|
1711
1289
|
}));
|
|
1712
1290
|
function fetch(_x, _x2) {
|
|
1713
1291
|
return _fetch.apply(this, arguments);
|
|
1714
1292
|
}
|
|
1715
1293
|
return fetch;
|
|
1716
1294
|
}()
|
|
1295
|
+
/**
|
|
1296
|
+
* Sets the error handler callback for handling errors during fetch requests.
|
|
1297
|
+
*/
|
|
1717
1298
|
}, {
|
|
1718
1299
|
key: "setErrorHandler",
|
|
1719
1300
|
value: function setErrorHandler(callback) {
|
|
1720
1301
|
if (this.errorHandler) {
|
|
1721
|
-
throw new Error(
|
|
1302
|
+
throw new Error("Error handler already set.");
|
|
1722
1303
|
}
|
|
1723
1304
|
this.errorHandler = callback;
|
|
1724
1305
|
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* Sets the response filter callback for filtering the response text.
|
|
1309
|
+
*/
|
|
1725
1310
|
}, {
|
|
1726
1311
|
key: "setResponseFilter",
|
|
1727
1312
|
value: function setResponseFilter(callback) {
|
|
1728
1313
|
if (this.responseFilter) {
|
|
1729
|
-
throw new Error(
|
|
1314
|
+
throw new Error("Response filter already set.");
|
|
1730
1315
|
}
|
|
1731
1316
|
this.responseFilter = callback;
|
|
1732
1317
|
}
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Sets the response handler callback for handling the response data.
|
|
1321
|
+
*/
|
|
1733
1322
|
}, {
|
|
1734
1323
|
key: "setResponseHandler",
|
|
1735
1324
|
value: function setResponseHandler(callback) {
|
|
1736
1325
|
if (this.responseHandler) {
|
|
1737
|
-
throw new Error(
|
|
1326
|
+
throw new Error("Response handler already set.");
|
|
1738
1327
|
}
|
|
1739
1328
|
this.responseHandler = callback;
|
|
1740
1329
|
}
|
|
1741
1330
|
}, {
|
|
1742
1331
|
key: "applyErrorHandler",
|
|
1743
1332
|
value: function applyErrorHandler(error) {
|
|
1744
|
-
return this.errorHandler && this.errorHandler(error);
|
|
1333
|
+
return !!this.errorHandler && this.errorHandler(error);
|
|
1745
1334
|
}
|
|
1746
1335
|
}, {
|
|
1747
1336
|
key: "applyResponseFilter",
|
|
@@ -1751,31 +1340,31 @@ var Http = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1751
1340
|
}, {
|
|
1752
1341
|
key: "applyResponseHandler",
|
|
1753
1342
|
value: function applyResponseHandler(text) {
|
|
1754
|
-
return this.responseHandler && this.responseHandler(text);
|
|
1343
|
+
return !!this.responseHandler && this.responseHandler(text);
|
|
1755
1344
|
}
|
|
1756
1345
|
}], [{
|
|
1757
1346
|
key: "getName",
|
|
1758
1347
|
value: function getName() {
|
|
1759
|
-
return
|
|
1348
|
+
return "ZenFlux/Core/Clients/Http";
|
|
1760
1349
|
}
|
|
1761
1350
|
}]);
|
|
1762
1351
|
return Http;
|
|
1763
1352
|
}(ObjectBase);
|
|
1764
1353
|
|
|
1765
|
-
var
|
|
1766
|
-
_inherits(
|
|
1767
|
-
var _super = _createSuper(
|
|
1768
|
-
function
|
|
1354
|
+
var Restful = /*#__PURE__*/function (_Commands) {
|
|
1355
|
+
_inherits(Restful, _Commands);
|
|
1356
|
+
var _super = _createSuper(Restful);
|
|
1357
|
+
function Restful(Config) {
|
|
1769
1358
|
var _this;
|
|
1770
|
-
_classCallCheck(this,
|
|
1359
|
+
_classCallCheck(this, Restful);
|
|
1771
1360
|
_this = _super.call(this);
|
|
1772
|
-
|
|
1361
|
+
Restful.client = new Http(Config.baseURL, Config.requestInit);
|
|
1773
1362
|
return _this;
|
|
1774
1363
|
}
|
|
1775
|
-
_createClass(
|
|
1364
|
+
_createClass(Restful, [{
|
|
1776
1365
|
key: "getClient",
|
|
1777
1366
|
value: function getClient() {
|
|
1778
|
-
return
|
|
1367
|
+
return Restful.client;
|
|
1779
1368
|
}
|
|
1780
1369
|
}, {
|
|
1781
1370
|
key: "get",
|
|
@@ -1783,7 +1372,7 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1783
1372
|
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1784
1373
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1785
1374
|
this.currentHttpMethod = E_HTTP_METHOD_TYPE.GET;
|
|
1786
|
-
return _get(_getPrototypeOf(
|
|
1375
|
+
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1787
1376
|
}
|
|
1788
1377
|
}, {
|
|
1789
1378
|
key: "update",
|
|
@@ -1791,7 +1380,7 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1791
1380
|
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1792
1381
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1793
1382
|
this.currentHttpMethod = E_HTTP_METHOD_TYPE.PATCH;
|
|
1794
|
-
return _get(_getPrototypeOf(
|
|
1383
|
+
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1795
1384
|
}
|
|
1796
1385
|
}, {
|
|
1797
1386
|
key: "delete",
|
|
@@ -1799,7 +1388,7 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1799
1388
|
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1800
1389
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1801
1390
|
this.currentHttpMethod = E_HTTP_METHOD_TYPE.DELETE;
|
|
1802
|
-
return _get(_getPrototypeOf(
|
|
1391
|
+
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1803
1392
|
}
|
|
1804
1393
|
}, {
|
|
1805
1394
|
key: "create",
|
|
@@ -1807,7 +1396,7 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1807
1396
|
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1808
1397
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1809
1398
|
this.currentHttpMethod = E_HTTP_METHOD_TYPE.POST;
|
|
1810
|
-
return _get(_getPrototypeOf(
|
|
1399
|
+
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1811
1400
|
}
|
|
1812
1401
|
}, {
|
|
1813
1402
|
key: "runInstance",
|
|
@@ -1826,7 +1415,7 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1826
1415
|
_context.next = 4;
|
|
1827
1416
|
break;
|
|
1828
1417
|
}
|
|
1829
|
-
throw new Error(
|
|
1418
|
+
throw new Error("Cannot run directly use one of the http methods: \"get\", \"update\", \"delete, \"create");
|
|
1830
1419
|
case 4:
|
|
1831
1420
|
// New args.
|
|
1832
1421
|
newArgs = {
|
|
@@ -1842,7 +1431,7 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1842
1431
|
newArgs.args.data = args;
|
|
1843
1432
|
}
|
|
1844
1433
|
_context.next = 8;
|
|
1845
|
-
return _get(_getPrototypeOf(
|
|
1434
|
+
return _get(_getPrototypeOf(Restful.prototype), "runInstance", this).call(this, command, newArgs, options);
|
|
1846
1435
|
case 8:
|
|
1847
1436
|
args.result = _context.sent;
|
|
1848
1437
|
// Clear method type.
|
|
@@ -1867,13 +1456,13 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1867
1456
|
value: function setHandler(type, callback) {
|
|
1868
1457
|
switch (type) {
|
|
1869
1458
|
case E_RESPONSE_HANDLER_TYPE.ERROR_HANDLER:
|
|
1870
|
-
|
|
1459
|
+
Restful.client.setErrorHandler(callback);
|
|
1871
1460
|
break;
|
|
1872
1461
|
case E_RESPONSE_HANDLER_TYPE.RESPONSE_FILTER:
|
|
1873
|
-
|
|
1462
|
+
Restful.client.setResponseFilter(callback);
|
|
1874
1463
|
break;
|
|
1875
1464
|
case E_RESPONSE_HANDLER_TYPE.RESPONSE_HANDLER:
|
|
1876
|
-
|
|
1465
|
+
Restful.client.setResponseHandler(callback);
|
|
1877
1466
|
break;
|
|
1878
1467
|
default:
|
|
1879
1468
|
throw new Error("Unknown handler type: '".concat(type, "'"));
|
|
@@ -1882,10 +1471,10 @@ var Data = /*#__PURE__*/function (_Commands) {
|
|
|
1882
1471
|
}], [{
|
|
1883
1472
|
key: "getName",
|
|
1884
1473
|
value: function getName() {
|
|
1885
|
-
return
|
|
1474
|
+
return "ZenFlux/Core/Managers/Restful";
|
|
1886
1475
|
}
|
|
1887
1476
|
}]);
|
|
1888
|
-
return
|
|
1477
|
+
return Restful;
|
|
1889
1478
|
}(Commands);
|
|
1890
1479
|
|
|
1891
1480
|
var Internal = /*#__PURE__*/function (_Commands) {
|
|
@@ -1898,42 +1487,141 @@ var Internal = /*#__PURE__*/function (_Commands) {
|
|
|
1898
1487
|
_createClass(Internal, null, [{
|
|
1899
1488
|
key: "getName",
|
|
1900
1489
|
value: function getName() {
|
|
1901
|
-
return
|
|
1490
|
+
return "ZenFlux/Core/Managers/Internal";
|
|
1902
1491
|
}
|
|
1903
1492
|
}]);
|
|
1904
1493
|
return Internal;
|
|
1905
1494
|
}(Commands);
|
|
1906
1495
|
|
|
1907
1496
|
/**
|
|
1908
|
-
* @author
|
|
1497
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1909
1498
|
*/
|
|
1910
1499
|
var afterInitializeCallbacks = [];
|
|
1911
1500
|
function initialize(config) {
|
|
1912
1501
|
commands = new Commands();
|
|
1913
1502
|
controllers = new Controllers();
|
|
1914
|
-
|
|
1503
|
+
restful = new Restful(config);
|
|
1915
1504
|
internal = new Internal();
|
|
1916
1505
|
}
|
|
1917
1506
|
function destroy() {
|
|
1918
1507
|
commands = {};
|
|
1919
1508
|
controllers = {};
|
|
1920
|
-
|
|
1509
|
+
restful = {};
|
|
1921
1510
|
internal = {};
|
|
1922
1511
|
}
|
|
1923
1512
|
var commands = {};
|
|
1924
1513
|
var controllers = {};
|
|
1925
|
-
var
|
|
1514
|
+
var restful = {};
|
|
1926
1515
|
var internal = {};
|
|
1927
1516
|
|
|
1928
|
-
var
|
|
1517
|
+
var _export = /*#__PURE__*/Object.freeze({
|
|
1929
1518
|
__proto__: null,
|
|
1930
1519
|
afterInitializeCallbacks: afterInitializeCallbacks,
|
|
1931
1520
|
get commands () { return commands; },
|
|
1932
1521
|
get controllers () { return controllers; },
|
|
1933
|
-
get data () { return data; },
|
|
1934
1522
|
destroy: destroy,
|
|
1935
1523
|
initialize: initialize,
|
|
1936
|
-
get internal () { return internal; }
|
|
1524
|
+
get internal () { return internal; },
|
|
1525
|
+
get restful () { return restful; }
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
// noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
|
|
1529
|
+
|
|
1530
|
+
var ControllerBase = /*#__PURE__*/function (_ObjectBase) {
|
|
1531
|
+
_inherits(ControllerBase, _ObjectBase);
|
|
1532
|
+
var _super = _createSuper(ControllerBase);
|
|
1533
|
+
/**
|
|
1534
|
+
* Constructor for `ControllerBase` instances.
|
|
1535
|
+
* Initializes the base class and invokes the `initialize()` method.
|
|
1536
|
+
*/
|
|
1537
|
+
function ControllerBase() {
|
|
1538
|
+
var _this;
|
|
1539
|
+
_classCallCheck(this, ControllerBase);
|
|
1540
|
+
_this = _super.call(this);
|
|
1541
|
+
|
|
1542
|
+
// Initialize the controller
|
|
1543
|
+
_this.initialize();
|
|
1544
|
+
return _this;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Initializes the controller by calling the `register()` method and optionally the `setupHooks()` method.
|
|
1549
|
+
*/
|
|
1550
|
+
_createClass(ControllerBase, [{
|
|
1551
|
+
key: "initialize",
|
|
1552
|
+
value: function initialize() {
|
|
1553
|
+
// Register commands and command types
|
|
1554
|
+
this.register();
|
|
1555
|
+
|
|
1556
|
+
// Optionally, set up hooks if the `setupHooks()` method is defined in derived classes
|
|
1557
|
+
this.setupHooks && this.setupHooks();
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Registers commands and command types by calling manager functions.
|
|
1562
|
+
*/
|
|
1563
|
+
}, {
|
|
1564
|
+
key: "register",
|
|
1565
|
+
value: function register() {
|
|
1566
|
+
// Register public commands
|
|
1567
|
+
this.commands = commands.register(this.getCommands(), this);
|
|
1568
|
+
|
|
1569
|
+
// Register RESTful commands
|
|
1570
|
+
this.restful = restful.register(this.getRestful(), this);
|
|
1571
|
+
|
|
1572
|
+
// Register internal commands
|
|
1573
|
+
this.internal = internal.register(this.getInternal(), this);
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
/**
|
|
1577
|
+
* Retrieve the public commands associated with this controller.
|
|
1578
|
+
* Derived classes can override this method to specify their own commands.
|
|
1579
|
+
*/
|
|
1580
|
+
}, {
|
|
1581
|
+
key: "getCommands",
|
|
1582
|
+
value: function getCommands() {
|
|
1583
|
+
return {};
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* Retrieve the RESTful commands associated with this controller.
|
|
1588
|
+
* Derived classes can override this method to specify their own RESTful commands.
|
|
1589
|
+
*/
|
|
1590
|
+
}, {
|
|
1591
|
+
key: "getRestful",
|
|
1592
|
+
value: function getRestful() {
|
|
1593
|
+
return {};
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Retrieve the internal commands associated with this controller.
|
|
1598
|
+
* Derived classes can override this method to specify their own internal commands.
|
|
1599
|
+
*/
|
|
1600
|
+
}, {
|
|
1601
|
+
key: "getInternal",
|
|
1602
|
+
value: function getInternal() {
|
|
1603
|
+
return {};
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* A hook method that can be optionally overridden in derived classes to set up hooks or event listeners.
|
|
1608
|
+
*/
|
|
1609
|
+
}, {
|
|
1610
|
+
key: "setupHooks",
|
|
1611
|
+
value: function setupHooks() {}
|
|
1612
|
+
}], [{
|
|
1613
|
+
key: "getName",
|
|
1614
|
+
value: function getName() {
|
|
1615
|
+
return "ZenFlux/Core/ControllerBase";
|
|
1616
|
+
}
|
|
1617
|
+
}]);
|
|
1618
|
+
return ControllerBase;
|
|
1619
|
+
}(ObjectBase);
|
|
1620
|
+
|
|
1621
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1622
|
+
__proto__: null,
|
|
1623
|
+
ControllerBase: ControllerBase,
|
|
1624
|
+
ObjectBase: ObjectBase
|
|
1937
1625
|
});
|
|
1938
1626
|
|
|
1939
1627
|
var CommandBase = /*#__PURE__*/function (_ObjectBase) {
|
|
@@ -1947,11 +1635,12 @@ var CommandBase = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1947
1635
|
_this = _super.call(this);
|
|
1948
1636
|
_defineProperty(_assertThisInitialized(_this), "args", {});
|
|
1949
1637
|
_defineProperty(_assertThisInitialized(_this), "options", {});
|
|
1950
|
-
var
|
|
1951
|
-
_this.logger = new Logger(
|
|
1952
|
-
|
|
1638
|
+
var type = _this.constructor;
|
|
1639
|
+
_this.logger = new ZenCore.classes.Logger(type, {
|
|
1640
|
+
// Happens or occurs many times, often in a similar or identical manner.
|
|
1641
|
+
repeatedly: true
|
|
1953
1642
|
});
|
|
1954
|
-
_this.logger.
|
|
1643
|
+
_this.logger.startsWith(_this.constructor, {
|
|
1955
1644
|
args: args,
|
|
1956
1645
|
options: options
|
|
1957
1646
|
});
|
|
@@ -1964,29 +1653,27 @@ var CommandBase = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1964
1653
|
this.args = args;
|
|
1965
1654
|
this.options = options;
|
|
1966
1655
|
}
|
|
1656
|
+
|
|
1657
|
+
/**
|
|
1658
|
+
* TODO: Maybe abstract, currently not sure about parameters initialization.
|
|
1659
|
+
*/
|
|
1967
1660
|
}, {
|
|
1968
1661
|
key: "apply",
|
|
1969
1662
|
value: function apply() {
|
|
1970
1663
|
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
|
|
1971
1664
|
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options;
|
|
1972
|
-
|
|
1665
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1666
|
+
throw new ForceMethodImplementation(this, "apply");
|
|
1973
1667
|
}
|
|
1974
1668
|
}, {
|
|
1975
1669
|
key: "run",
|
|
1976
1670
|
value: function () {
|
|
1977
1671
|
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1978
|
-
var result;
|
|
1979
1672
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1980
1673
|
while (1) switch (_context.prev = _context.next) {
|
|
1981
1674
|
case 0:
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
return this.apply(this.args, this.options);
|
|
1985
|
-
case 3:
|
|
1986
|
-
result = _context.sent;
|
|
1987
|
-
this.onAfterApply && this.onAfterApply();
|
|
1988
|
-
return _context.abrupt("return", result);
|
|
1989
|
-
case 6:
|
|
1675
|
+
return _context.abrupt("return", this.runInternal());
|
|
1676
|
+
case 1:
|
|
1990
1677
|
case "end":
|
|
1991
1678
|
return _context.stop();
|
|
1992
1679
|
}
|
|
@@ -1998,20 +1685,41 @@ var CommandBase = /*#__PURE__*/function (_ObjectBase) {
|
|
|
1998
1685
|
return run;
|
|
1999
1686
|
}()
|
|
2000
1687
|
}, {
|
|
2001
|
-
key: "
|
|
2002
|
-
value: function
|
|
2003
|
-
|
|
1688
|
+
key: "runInternal",
|
|
1689
|
+
value: function () {
|
|
1690
|
+
var _runInternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1691
|
+
var result;
|
|
1692
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1693
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1694
|
+
case 0:
|
|
1695
|
+
this.onBeforeApply && this.onBeforeApply();
|
|
1696
|
+
_context2.next = 3;
|
|
1697
|
+
return this.apply(this.args, this.options);
|
|
1698
|
+
case 3:
|
|
1699
|
+
result = _context2.sent;
|
|
1700
|
+
this.onAfterApply && this.onAfterApply();
|
|
1701
|
+
return _context2.abrupt("return", result);
|
|
1702
|
+
case 6:
|
|
1703
|
+
case "end":
|
|
1704
|
+
return _context2.stop();
|
|
1705
|
+
}
|
|
1706
|
+
}, _callee2, this);
|
|
1707
|
+
}));
|
|
1708
|
+
function runInternal() {
|
|
1709
|
+
return _runInternal.apply(this, arguments);
|
|
1710
|
+
}
|
|
1711
|
+
return runInternal;
|
|
1712
|
+
}()
|
|
1713
|
+
}], [{
|
|
1714
|
+
key: "getName",
|
|
1715
|
+
value: function getName() {
|
|
1716
|
+
return "ZenFlux/Core/CommandBases/CommandBase";
|
|
2004
1717
|
}
|
|
2005
1718
|
}, {
|
|
2006
|
-
key: "getOptions",
|
|
2007
|
-
value: function getOptions() {
|
|
2008
|
-
return this.options;
|
|
2009
|
-
}
|
|
2010
|
-
}], [{
|
|
2011
1719
|
key: "setController",
|
|
2012
1720
|
value: function setController(controller) {
|
|
2013
1721
|
if (this.controller) {
|
|
2014
|
-
throw new ControllerAlreadySet();
|
|
1722
|
+
throw new ControllerAlreadySet(this.controller);
|
|
2015
1723
|
}
|
|
2016
1724
|
this.controller = controller;
|
|
2017
1725
|
}
|
|
@@ -2034,24 +1742,25 @@ var CommandPublic = /*#__PURE__*/function (_CommandBase) {
|
|
|
2034
1742
|
_createClass(CommandPublic, null, [{
|
|
2035
1743
|
key: "getName",
|
|
2036
1744
|
value: function getName() {
|
|
2037
|
-
return
|
|
1745
|
+
return "ZenFlux/Core/CommandBases/CommandPublic";
|
|
2038
1746
|
}
|
|
2039
1747
|
}]);
|
|
2040
1748
|
return CommandPublic;
|
|
2041
1749
|
}(CommandBase);
|
|
2042
1750
|
|
|
2043
|
-
var
|
|
2044
|
-
_inherits(
|
|
2045
|
-
var _super = _createSuper(
|
|
2046
|
-
function
|
|
2047
|
-
_classCallCheck(this,
|
|
1751
|
+
var CommandRestful = /*#__PURE__*/function (_CommandBase) {
|
|
1752
|
+
_inherits(CommandRestful, _CommandBase);
|
|
1753
|
+
var _super = _createSuper(CommandRestful);
|
|
1754
|
+
function CommandRestful() {
|
|
1755
|
+
_classCallCheck(this, CommandRestful);
|
|
2048
1756
|
return _super.apply(this, arguments);
|
|
2049
1757
|
}
|
|
2050
|
-
_createClass(
|
|
1758
|
+
_createClass(CommandRestful, [{
|
|
2051
1759
|
key: "getEndpoint",
|
|
2052
1760
|
value:
|
|
2053
1761
|
/**
|
|
2054
|
-
*
|
|
1762
|
+
* Override this method is required to determine endpoint and magic query params.
|
|
1763
|
+
*
|
|
2055
1764
|
* @example
|
|
2056
1765
|
* ```
|
|
2057
1766
|
* args = { query: { id: 1 } };
|
|
@@ -2060,39 +1769,40 @@ var CommandData = /*#__PURE__*/function (_CommandBase) {
|
|
|
2060
1769
|
* ```
|
|
2061
1770
|
*/
|
|
2062
1771
|
function getEndpoint() {
|
|
2063
|
-
throw new
|
|
1772
|
+
throw new ForceMethodImplementation(this, "getEndpoint");
|
|
2064
1773
|
}
|
|
2065
1774
|
}, {
|
|
2066
1775
|
key: "apply",
|
|
2067
1776
|
value: function apply() {
|
|
2068
1777
|
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
|
|
2069
1778
|
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options;
|
|
1779
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2070
1780
|
var endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
2071
|
-
return
|
|
1781
|
+
return restful.getClient().fetch(endpoint, restful.currentHttpMethod, args || null);
|
|
2072
1782
|
}
|
|
2073
1783
|
}, {
|
|
2074
1784
|
key: "applyEndpointFormat",
|
|
2075
1785
|
value: function applyEndpointFormat(endpoint) {
|
|
2076
1786
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2077
1787
|
// Replace query with `magic` placeholders.
|
|
2078
|
-
if (endpoint.includes(
|
|
2079
|
-
endpoint = endpoint.split(
|
|
2080
|
-
var match = endpointPart.match(
|
|
2081
|
-
if (match !== null && match !== void 0 && match.length &&
|
|
1788
|
+
if (endpoint.includes("{")) {
|
|
1789
|
+
endpoint = endpoint.split("/").map(function (endpointPart) {
|
|
1790
|
+
var match = endpointPart.match("\\{(.*?)\\}");
|
|
1791
|
+
if (match !== null && match !== void 0 && match.length && "undefined" !== typeof data[match[1]]) {
|
|
2082
1792
|
return data[match[1]];
|
|
2083
1793
|
}
|
|
2084
1794
|
return endpointPart;
|
|
2085
|
-
}).join(
|
|
1795
|
+
}).join("/");
|
|
2086
1796
|
}
|
|
2087
1797
|
return endpoint;
|
|
2088
1798
|
}
|
|
2089
1799
|
}], [{
|
|
2090
1800
|
key: "getName",
|
|
2091
1801
|
value: function getName() {
|
|
2092
|
-
return
|
|
1802
|
+
return "ZenFlux/Core/CommandBases/CommandRestful";
|
|
2093
1803
|
}
|
|
2094
1804
|
}]);
|
|
2095
|
-
return
|
|
1805
|
+
return CommandRestful;
|
|
2096
1806
|
}(CommandBase);
|
|
2097
1807
|
|
|
2098
1808
|
var CommandInternal = /*#__PURE__*/function (_CommandBase) {
|
|
@@ -2105,108 +1815,84 @@ var CommandInternal = /*#__PURE__*/function (_CommandBase) {
|
|
|
2105
1815
|
_createClass(CommandInternal, null, [{
|
|
2106
1816
|
key: "getName",
|
|
2107
1817
|
value: function getName() {
|
|
2108
|
-
return
|
|
1818
|
+
return "ZenFlux/Core/CommandBases/CommandInternal";
|
|
2109
1819
|
}
|
|
2110
1820
|
}]);
|
|
2111
1821
|
return CommandInternal;
|
|
2112
1822
|
}(CommandBase);
|
|
2113
1823
|
|
|
2114
1824
|
/**
|
|
2115
|
-
* @author
|
|
1825
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
2116
1826
|
*/
|
|
2117
1827
|
|
|
2118
|
-
var index
|
|
1828
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
2119
1829
|
__proto__: null,
|
|
2120
1830
|
CommandBase: CommandBase,
|
|
2121
|
-
CommandData: CommandData,
|
|
2122
1831
|
CommandInternal: CommandInternal,
|
|
2123
|
-
CommandPublic: CommandPublic
|
|
1832
|
+
CommandPublic: CommandPublic,
|
|
1833
|
+
CommandRestful: CommandRestful
|
|
2124
1834
|
});
|
|
2125
1835
|
|
|
2126
|
-
var
|
|
2127
|
-
_inherits(Controller, _ObjectBase);
|
|
2128
|
-
var _super = _createSuper(Controller);
|
|
2129
|
-
function Controller() {
|
|
2130
|
-
var _this;
|
|
2131
|
-
_classCallCheck(this, Controller);
|
|
2132
|
-
_this = _super.call(this);
|
|
2133
|
-
_this.initialize();
|
|
2134
|
-
return _this;
|
|
2135
|
-
}
|
|
2136
|
-
_createClass(Controller, [{
|
|
2137
|
-
key: "initialize",
|
|
2138
|
-
value: function initialize() {
|
|
2139
|
-
this.register();
|
|
2140
|
-
this.setupHooks && this.setupHooks();
|
|
2141
|
-
}
|
|
2142
|
-
}, {
|
|
2143
|
-
key: "register",
|
|
2144
|
-
value: function register() {
|
|
2145
|
-
this.commands = commands.register(this.getCommands(), this);
|
|
2146
|
-
this.data = data.register(this.getData(), this);
|
|
2147
|
-
this.internal = internal.register(this.getInternal(), this);
|
|
2148
|
-
}
|
|
2149
|
-
}, {
|
|
2150
|
-
key: "getCommands",
|
|
2151
|
-
value: function getCommands() {
|
|
2152
|
-
return {};
|
|
2153
|
-
}
|
|
2154
|
-
}, {
|
|
2155
|
-
key: "getData",
|
|
2156
|
-
value: function getData() {
|
|
2157
|
-
return {};
|
|
2158
|
-
}
|
|
2159
|
-
}, {
|
|
2160
|
-
key: "getInternal",
|
|
2161
|
-
value: function getInternal() {
|
|
2162
|
-
return {};
|
|
2163
|
-
}
|
|
2164
|
-
}], [{
|
|
2165
|
-
key: "getName",
|
|
2166
|
-
value: function getName() {
|
|
2167
|
-
return 'Core/Core/Controller';
|
|
2168
|
-
}
|
|
2169
|
-
}]);
|
|
2170
|
-
return Controller;
|
|
2171
|
-
}(ObjectBase);
|
|
2172
|
-
|
|
2173
|
-
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1836
|
+
var indexPublic = /*#__PURE__*/Object.freeze({
|
|
2174
1837
|
__proto__: null,
|
|
2175
|
-
|
|
2176
|
-
ObjectBase: ObjectBase
|
|
1838
|
+
ForceMethodImplementation: ForceMethodImplementation
|
|
2177
1839
|
});
|
|
2178
1840
|
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
*/
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
1841
|
+
var classes = {
|
|
1842
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1843
|
+
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
1844
|
+
|
|
1845
|
+
Logger: /*#__PURE__*/function () {
|
|
1846
|
+
function NullLogger(owner) {
|
|
1847
|
+
_classCallCheck(this, NullLogger);
|
|
1848
|
+
}
|
|
1849
|
+
_createClass(NullLogger, [{
|
|
1850
|
+
key: "log",
|
|
1851
|
+
value: function log(caller, message) {}
|
|
1852
|
+
}, {
|
|
1853
|
+
key: "warn",
|
|
1854
|
+
value: function warn(caller, message) {}
|
|
1855
|
+
}, {
|
|
1856
|
+
key: "error",
|
|
1857
|
+
value: function error(caller, message) {}
|
|
1858
|
+
}, {
|
|
1859
|
+
key: "info",
|
|
1860
|
+
value: function info(caller, message) {}
|
|
1861
|
+
}, {
|
|
1862
|
+
key: "debug",
|
|
1863
|
+
value: function debug(caller, message) {}
|
|
1864
|
+
}, {
|
|
1865
|
+
key: "startsEmpty",
|
|
1866
|
+
value: function startsEmpty(caller) {}
|
|
1867
|
+
}, {
|
|
1868
|
+
key: "startsWith",
|
|
1869
|
+
value: function startsWith(caller, params) {}
|
|
1870
|
+
}, {
|
|
1871
|
+
key: "dump",
|
|
1872
|
+
value: function dump(caller, data) {}
|
|
1873
|
+
}, {
|
|
1874
|
+
key: "drop",
|
|
1875
|
+
value: function drop(caller, according, data) {}
|
|
1876
|
+
}]);
|
|
1877
|
+
return NullLogger;
|
|
1878
|
+
}()
|
|
1879
|
+
|
|
1880
|
+
/* eslint-enable */
|
|
1881
|
+
};
|
|
2194
1882
|
|
|
2195
1883
|
var exported = /*#__PURE__*/Object.freeze({
|
|
2196
1884
|
__proto__: null,
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
managers:
|
|
2203
|
-
modules: index$6,
|
|
2204
|
-
utils: index$7
|
|
1885
|
+
bases: index$1,
|
|
1886
|
+
classes: classes,
|
|
1887
|
+
commandBases: index,
|
|
1888
|
+
errors: indexPublic,
|
|
1889
|
+
interfaces: index$2,
|
|
1890
|
+
managers: _export
|
|
2205
1891
|
});
|
|
2206
1892
|
|
|
2207
1893
|
function errorInitTwice() {
|
|
2208
|
-
if (
|
|
2209
|
-
throw new Error(
|
|
1894
|
+
if ("undefined" !== typeof __ZEN_CORE__IS_INITIALIZED__ && __ZEN_CORE__IS_INITIALIZED__) {
|
|
1895
|
+
throw new Error("ZenCore is already initialized.");
|
|
2210
1896
|
}
|
|
2211
1897
|
}
|
|
2212
1898
|
errorInitTwice();
|
|
@@ -2229,7 +1915,8 @@ var CoreAPI = _objectSpread2({
|
|
|
2229
1915
|
},
|
|
2230
1916
|
config: config
|
|
2231
1917
|
}, exported);
|
|
2232
|
-
// TODO: Make it available only for development.
|
|
2233
1918
|
if (!(globalThis !== null && globalThis !== void 0 && globalThis.ZenCore)) globalThis.ZenCore = CoreAPI;
|
|
2234
1919
|
|
|
2235
|
-
|
|
1920
|
+
// console.log( `ZenCore initialized, version: ${pkg.version}` );
|
|
1921
|
+
|
|
1922
|
+
export { index$1 as bases, classes, index as commandBases, CoreAPI as default, indexPublic as errors, index$2 as interfaces, _export as managers };
|