@zenflux/core 0.0.1-dev.3 → 0.1.0
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/package.json +29 -29
- package/src/bases/controller-base.ts +4 -4
- package/src/clients/http.ts +5 -7
- package/src/command-bases/command-base.ts +5 -3
- package/src/errors/command-already-registered.ts +1 -1
- package/src/errors/controller-already-registered.ts +1 -1
- package/src/errors/controller-already-set.ts +1 -1
- package/src/errors/force-method-implementation.ts +1 -1
- package/src/exports-index.ts +13 -0
- package/src/exports.ts +47 -27
- package/src/index.ts +12 -2
- package/src/managers/commands.ts +7 -8
- package/src/managers/controllers.ts +3 -2
- package/src/managers/export.ts +1 -1
- package/src/managers/restful.ts +8 -6
- package/dist/es/src/bases/controller-base.d.ts +0 -55
- package/dist/es/src/bases/controller-base.d.ts.map +0 -1
- package/dist/es/src/bases/index.d.ts +0 -3
- package/dist/es/src/bases/index.d.ts.map +0 -1
- package/dist/es/src/bases/object-base.d.ts +0 -32
- package/dist/es/src/bases/object-base.d.ts.map +0 -1
- package/dist/es/src/clients/http.d.ts +0 -40
- package/dist/es/src/clients/http.d.ts.map +0 -1
- package/dist/es/src/command-bases/command-base.d.ts +0 -29
- package/dist/es/src/command-bases/command-base.d.ts.map +0 -1
- package/dist/es/src/command-bases/command-internal.d.ts +0 -9
- package/dist/es/src/command-bases/command-internal.d.ts.map +0 -1
- package/dist/es/src/command-bases/command-public.d.ts +0 -9
- package/dist/es/src/command-bases/command-public.d.ts.map +0 -1
- package/dist/es/src/command-bases/command-restful.d.ts +0 -22
- package/dist/es/src/command-bases/command-restful.d.ts.map +0 -1
- package/dist/es/src/command-bases/index.d.ts +0 -8
- package/dist/es/src/command-bases/index.d.ts.map +0 -1
- package/dist/es/src/errors/command-already-registered.d.ts +0 -11
- package/dist/es/src/errors/command-already-registered.d.ts.map +0 -1
- package/dist/es/src/errors/command-not-found.d.ts +0 -10
- package/dist/es/src/errors/command-not-found.d.ts.map +0 -1
- package/dist/es/src/errors/controller-already-registered.d.ts +0 -11
- package/dist/es/src/errors/controller-already-registered.d.ts.map +0 -1
- package/dist/es/src/errors/controller-already-set.d.ts +0 -11
- package/dist/es/src/errors/controller-already-set.d.ts.map +0 -1
- package/dist/es/src/errors/force-method-implementation.d.ts +0 -14
- package/dist/es/src/errors/force-method-implementation.d.ts.map +0 -1
- package/dist/es/src/errors/index-public.d.ts +0 -2
- package/dist/es/src/errors/index-public.d.ts.map +0 -1
- package/dist/es/src/errors/index.d.ts +0 -6
- package/dist/es/src/errors/index.d.ts.map +0 -1
- package/dist/es/src/exports.d.ts +0 -37
- package/dist/es/src/exports.d.ts.map +0 -1
- package/dist/es/src/index.d.ts +0 -6
- package/dist/es/src/index.d.ts.map +0 -1
- package/dist/es/src/initializer.d.ts +0 -36
- package/dist/es/src/initializer.d.ts.map +0 -1
- package/dist/es/src/interfaces/commands.d.ts +0 -14
- package/dist/es/src/interfaces/commands.d.ts.map +0 -1
- package/dist/es/src/interfaces/config.d.ts +0 -21
- package/dist/es/src/interfaces/config.d.ts.map +0 -1
- package/dist/es/src/interfaces/index.d.ts +0 -8
- package/dist/es/src/interfaces/index.d.ts.map +0 -1
- package/dist/es/src/interfaces/logger.d.ts +0 -20
- package/dist/es/src/interfaces/logger.d.ts.map +0 -1
- package/dist/es/src/interfaces/restful.d.ts +0 -19
- package/dist/es/src/interfaces/restful.d.ts.map +0 -1
- package/dist/es/src/managers/commands.d.ts +0 -68
- package/dist/es/src/managers/commands.d.ts.map +0 -1
- package/dist/es/src/managers/controllers.d.ts +0 -17
- package/dist/es/src/managers/controllers.d.ts.map +0 -1
- package/dist/es/src/managers/export.d.ts +0 -16
- package/dist/es/src/managers/export.d.ts.map +0 -1
- package/dist/es/src/managers/index.d.ts +0 -8
- package/dist/es/src/managers/index.d.ts.map +0 -1
- package/dist/es/src/managers/internal.d.ts +0 -9
- package/dist/es/src/managers/internal.d.ts.map +0 -1
- package/dist/es/src/managers/restful.d.ts +0 -25
- package/dist/es/src/managers/restful.d.ts.map +0 -1
- package/dist/es/tsdoc-metadata.json +0 -11
- package/dist/es/zenflux-core.d.ts +0 -470
- package/dist/es/zenflux-core.js +0 -1922
- package/src/initializer.ts +0 -56
package/dist/es/zenflux-core.js
DELETED
|
@@ -1,1922 +0,0 @@
|
|
|
1
|
-
function _typeof(o) {
|
|
2
|
-
"@babel/helpers - typeof";
|
|
3
|
-
|
|
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
|
-
}
|
|
10
|
-
|
|
11
|
-
function _toPrimitive(input, hint) {
|
|
12
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
13
|
-
var prim = input[Symbol.toPrimitive];
|
|
14
|
-
if (prim !== undefined) {
|
|
15
|
-
var res = prim.call(input, hint || "default");
|
|
16
|
-
if (_typeof(res) !== "object") return res;
|
|
17
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
18
|
-
}
|
|
19
|
-
return (hint === "string" ? String : Number)(input);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function _toPropertyKey(arg) {
|
|
23
|
-
var key = _toPrimitive(arg, "string");
|
|
24
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _defineProperty(obj, key, value) {
|
|
28
|
-
key = _toPropertyKey(key);
|
|
29
|
-
if (key in obj) {
|
|
30
|
-
Object.defineProperty(obj, key, {
|
|
31
|
-
value: value,
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
obj[key] = value;
|
|
38
|
-
}
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function ownKeys(e, r) {
|
|
43
|
-
var t = Object.keys(e);
|
|
44
|
-
if (Object.getOwnPropertySymbols) {
|
|
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
|
-
}
|
|
50
|
-
return t;
|
|
51
|
-
}
|
|
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
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return e;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
var version = "0.0.1";
|
|
65
|
-
|
|
66
|
-
function _regeneratorRuntime() {
|
|
67
|
-
_regeneratorRuntime = function _regeneratorRuntime() {
|
|
68
|
-
return e;
|
|
69
|
-
};
|
|
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;
|
|
76
|
-
},
|
|
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,
|
|
84
|
-
enumerable: !0,
|
|
85
|
-
configurable: !0,
|
|
86
|
-
writable: !0
|
|
87
|
-
}), t[e];
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
define({}, "");
|
|
91
|
-
} catch (t) {
|
|
92
|
-
define = function define(t, e, r) {
|
|
93
|
-
return t[e] = r;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
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;
|
|
103
|
-
}
|
|
104
|
-
function tryCatch(t, e, r) {
|
|
105
|
-
try {
|
|
106
|
-
return {
|
|
107
|
-
type: "normal",
|
|
108
|
-
arg: t.call(e, r)
|
|
109
|
-
};
|
|
110
|
-
} catch (t) {
|
|
111
|
-
return {
|
|
112
|
-
type: "throw",
|
|
113
|
-
arg: t
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
e.wrap = wrap;
|
|
118
|
-
var h = "suspendedStart",
|
|
119
|
-
l = "suspendedYield",
|
|
120
|
-
f = "executing",
|
|
121
|
-
s = "completed",
|
|
122
|
-
y = {};
|
|
123
|
-
function Generator() {}
|
|
124
|
-
function GeneratorFunction() {}
|
|
125
|
-
function GeneratorFunctionPrototype() {}
|
|
126
|
-
var p = {};
|
|
127
|
-
define(p, a, function () {
|
|
128
|
-
return this;
|
|
129
|
-
});
|
|
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);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
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);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
a(c.arg);
|
|
158
|
-
}
|
|
159
|
-
var r;
|
|
160
|
-
o(this, "_invoke", {
|
|
161
|
-
value: function value(t, n) {
|
|
162
|
-
function callInvokeWithMethodAndArg() {
|
|
163
|
-
return new e(function (e, r) {
|
|
164
|
-
invoke(t, n, e, r);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
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
|
-
};
|
|
181
|
-
}
|
|
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;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
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;
|
|
199
|
-
return {
|
|
200
|
-
value: p.arg,
|
|
201
|
-
done: n.done
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
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);
|
|
216
|
-
}
|
|
217
|
-
function pushTryEntry(t) {
|
|
218
|
-
var e = {
|
|
219
|
-
tryLoc: t[0]
|
|
220
|
-
};
|
|
221
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
222
|
-
}
|
|
223
|
-
function resetTryEntry(t) {
|
|
224
|
-
var e = t.completion || {};
|
|
225
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
226
|
-
}
|
|
227
|
-
function Context(t) {
|
|
228
|
-
this.tryEntries = [{
|
|
229
|
-
tryLoc: "root"
|
|
230
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
231
|
-
}
|
|
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;
|
|
242
|
-
};
|
|
243
|
-
return i.next = i;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
throw new TypeError(_typeof(e) + " is not iterable");
|
|
247
|
-
}
|
|
248
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
249
|
-
value: GeneratorFunctionPrototype,
|
|
250
|
-
configurable: !0
|
|
251
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
252
|
-
value: GeneratorFunction,
|
|
253
|
-
configurable: !0
|
|
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
|
-
return {
|
|
261
|
-
__await: t
|
|
262
|
-
};
|
|
263
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
264
|
-
return this;
|
|
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
|
-
});
|
|
271
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
272
|
-
return this;
|
|
273
|
-
}), define(g, "toString", function () {
|
|
274
|
-
return "[object Generator]";
|
|
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
|
-
}
|
|
284
|
-
return next.done = !0, next;
|
|
285
|
-
};
|
|
286
|
-
}, e.values = values, Context.prototype = {
|
|
287
|
-
constructor: Context,
|
|
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
|
-
},
|
|
291
|
-
stop: function stop() {
|
|
292
|
-
this.done = !0;
|
|
293
|
-
var t = this.tryEntries[0].completion;
|
|
294
|
-
if ("throw" === t.type) throw t.arg;
|
|
295
|
-
return this.rval;
|
|
296
|
-
},
|
|
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
|
-
}
|
|
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
|
-
} else {
|
|
316
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
317
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
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
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
}
|
|
343
|
-
},
|
|
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
|
-
}
|
|
353
|
-
return o;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
throw new Error("illegal catch attempt");
|
|
357
|
-
},
|
|
358
|
-
delegateYield: function delegateYield(e, r, n) {
|
|
359
|
-
return this.delegate = {
|
|
360
|
-
iterator: values(e),
|
|
361
|
-
resultName: r,
|
|
362
|
-
nextLoc: n
|
|
363
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
364
|
-
}
|
|
365
|
-
}, e;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
369
|
-
try {
|
|
370
|
-
var info = gen[key](arg);
|
|
371
|
-
var value = info.value;
|
|
372
|
-
} catch (error) {
|
|
373
|
-
reject(error);
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
if (info.done) {
|
|
377
|
-
resolve(value);
|
|
378
|
-
} else {
|
|
379
|
-
Promise.resolve(value).then(_next, _throw);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
function _asyncToGenerator(fn) {
|
|
383
|
-
return function () {
|
|
384
|
-
var self = this,
|
|
385
|
-
args = arguments;
|
|
386
|
-
return new Promise(function (resolve, reject) {
|
|
387
|
-
var gen = fn.apply(self, args);
|
|
388
|
-
function _next(value) {
|
|
389
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
390
|
-
}
|
|
391
|
-
function _throw(err) {
|
|
392
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
393
|
-
}
|
|
394
|
-
_next(undefined);
|
|
395
|
-
});
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
function _classCallCheck(instance, Constructor) {
|
|
400
|
-
if (!(instance instanceof Constructor)) {
|
|
401
|
-
throw new TypeError("Cannot call a class as a function");
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function _defineProperties(target, props) {
|
|
406
|
-
for (var i = 0; i < props.length; i++) {
|
|
407
|
-
var descriptor = props[i];
|
|
408
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
409
|
-
descriptor.configurable = true;
|
|
410
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
411
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
415
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
416
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
417
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
418
|
-
writable: false
|
|
419
|
-
});
|
|
420
|
-
return Constructor;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function _assertThisInitialized(self) {
|
|
424
|
-
if (self === void 0) {
|
|
425
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
426
|
-
}
|
|
427
|
-
return self;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function _setPrototypeOf(o, p) {
|
|
431
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
432
|
-
o.__proto__ = p;
|
|
433
|
-
return o;
|
|
434
|
-
};
|
|
435
|
-
return _setPrototypeOf(o, p);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
function _inherits(subClass, superClass) {
|
|
439
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
440
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
441
|
-
}
|
|
442
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
443
|
-
constructor: {
|
|
444
|
-
value: subClass,
|
|
445
|
-
writable: true,
|
|
446
|
-
configurable: true
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
Object.defineProperty(subClass, "prototype", {
|
|
450
|
-
writable: false
|
|
451
|
-
});
|
|
452
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
function _getPrototypeOf(o) {
|
|
456
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
457
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
458
|
-
};
|
|
459
|
-
return _getPrototypeOf(o);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function _isNativeReflectConstruct() {
|
|
463
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
464
|
-
if (Reflect.construct.sham) return false;
|
|
465
|
-
if (typeof Proxy === "function") return true;
|
|
466
|
-
try {
|
|
467
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
468
|
-
return true;
|
|
469
|
-
} catch (e) {
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function _possibleConstructorReturn(self, call) {
|
|
475
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
476
|
-
return call;
|
|
477
|
-
} else if (call !== void 0) {
|
|
478
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
479
|
-
}
|
|
480
|
-
return _assertThisInitialized(self);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function _createSuper(Derived) {
|
|
484
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
485
|
-
return function _createSuperInternal() {
|
|
486
|
-
var Super = _getPrototypeOf(Derived),
|
|
487
|
-
result;
|
|
488
|
-
if (hasNativeReflectConstruct) {
|
|
489
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
490
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
491
|
-
} else {
|
|
492
|
-
result = Super.apply(this, arguments);
|
|
493
|
-
}
|
|
494
|
-
return _possibleConstructorReturn(this, result);
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
function _isNativeFunction(fn) {
|
|
499
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function _construct(Parent, args, Class) {
|
|
503
|
-
if (_isNativeReflectConstruct()) {
|
|
504
|
-
_construct = Reflect.construct.bind();
|
|
505
|
-
} else {
|
|
506
|
-
_construct = function _construct(Parent, args, Class) {
|
|
507
|
-
var a = [null];
|
|
508
|
-
a.push.apply(a, args);
|
|
509
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
510
|
-
var instance = new Constructor();
|
|
511
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
512
|
-
return instance;
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
return _construct.apply(null, arguments);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function _wrapNativeSuper(Class) {
|
|
519
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
520
|
-
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
521
|
-
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
522
|
-
if (typeof Class !== "function") {
|
|
523
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
524
|
-
}
|
|
525
|
-
if (typeof _cache !== "undefined") {
|
|
526
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
527
|
-
_cache.set(Class, Wrapper);
|
|
528
|
-
}
|
|
529
|
-
function Wrapper() {
|
|
530
|
-
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
531
|
-
}
|
|
532
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
533
|
-
constructor: {
|
|
534
|
-
value: Wrapper,
|
|
535
|
-
enumerable: false,
|
|
536
|
-
writable: true,
|
|
537
|
-
configurable: true
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
541
|
-
};
|
|
542
|
-
return _wrapNativeSuper(Class);
|
|
543
|
-
}
|
|
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
|
-
*/
|
|
660
|
-
var CommandAlreadyRegistered = /*#__PURE__*/function (_Error) {
|
|
661
|
-
_inherits(CommandAlreadyRegistered, _Error);
|
|
662
|
-
var _super = _createSuper(CommandAlreadyRegistered);
|
|
663
|
-
function CommandAlreadyRegistered(command) {
|
|
664
|
-
_classCallCheck(this, CommandAlreadyRegistered);
|
|
665
|
-
return _super.call(this, "Command: '".concat(command.getName(), "' is already registered"));
|
|
666
|
-
}
|
|
667
|
-
return _createClass(CommandAlreadyRegistered);
|
|
668
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
669
|
-
|
|
670
|
-
/**
|
|
671
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
672
|
-
*/
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* @internal
|
|
676
|
-
*/
|
|
677
|
-
var CommandNotFound = /*#__PURE__*/function (_Error) {
|
|
678
|
-
_inherits(CommandNotFound, _Error);
|
|
679
|
-
var _super = _createSuper(CommandNotFound);
|
|
680
|
-
function CommandNotFound(command) {
|
|
681
|
-
_classCallCheck(this, CommandNotFound);
|
|
682
|
-
return _super.call(this, "Command: '".concat(command, "' is not found"));
|
|
683
|
-
}
|
|
684
|
-
return _createClass(CommandNotFound);
|
|
685
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
689
|
-
*/
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* @internal
|
|
693
|
-
*/
|
|
694
|
-
var ControllerAlreadyRegistered = /*#__PURE__*/function (_Error) {
|
|
695
|
-
_inherits(ControllerAlreadyRegistered, _Error);
|
|
696
|
-
var _super = _createSuper(ControllerAlreadyRegistered);
|
|
697
|
-
function ControllerAlreadyRegistered(controller) {
|
|
698
|
-
_classCallCheck(this, ControllerAlreadyRegistered);
|
|
699
|
-
return _super.call(this, "Controller: '".concat(controller.getName(), "' is already registered"));
|
|
700
|
-
}
|
|
701
|
-
return _createClass(ControllerAlreadyRegistered);
|
|
702
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
706
|
-
*/
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* @internal
|
|
710
|
-
*/
|
|
711
|
-
var ControllerAlreadySet = /*#__PURE__*/function (_Error) {
|
|
712
|
-
_inherits(ControllerAlreadySet, _Error);
|
|
713
|
-
var _super = _createSuper(ControllerAlreadySet);
|
|
714
|
-
function ControllerAlreadySet(controller) {
|
|
715
|
-
_classCallCheck(this, ControllerAlreadySet);
|
|
716
|
-
return _super.call(this, "Controller: '".concat(controller.getName(), "' is already set"));
|
|
717
|
-
}
|
|
718
|
-
return _createClass(ControllerAlreadySet);
|
|
719
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
720
|
-
|
|
721
|
-
var Commands = /*#__PURE__*/function (_ObjectBase) {
|
|
722
|
-
_inherits(Commands, _ObjectBase);
|
|
723
|
-
var _super = _createSuper(Commands);
|
|
724
|
-
function Commands() {
|
|
725
|
-
var _this;
|
|
726
|
-
_classCallCheck(this, Commands);
|
|
727
|
-
_this = _super.call(this);
|
|
728
|
-
_defineProperty(_assertThisInitialized(_this), "current", {});
|
|
729
|
-
_defineProperty(_assertThisInitialized(_this), "currentArgs", {});
|
|
730
|
-
_defineProperty(_assertThisInitialized(_this), "trace", []);
|
|
731
|
-
_defineProperty(_assertThisInitialized(_this), "commands", {});
|
|
732
|
-
_defineProperty(_assertThisInitialized(_this), "onBeforeHooks", {});
|
|
733
|
-
_defineProperty(_assertThisInitialized(_this), "onBeforeUIHooks", {});
|
|
734
|
-
_defineProperty(_assertThisInitialized(_this), "onAfterHooks", {});
|
|
735
|
-
_defineProperty(_assertThisInitialized(_this), "onAfterOnceHooks", {});
|
|
736
|
-
_defineProperty(_assertThisInitialized(_this), "onAfterUIHooks", {});
|
|
737
|
-
_defineProperty(_assertThisInitialized(_this), "onAfterAffectHooks", {});
|
|
738
|
-
var type = _this.constructor;
|
|
739
|
-
_this.logger = new ZenCore.classes.Logger(type);
|
|
740
|
-
_this.logger.startsEmpty(_this.constructor);
|
|
741
|
-
return _this;
|
|
742
|
-
}
|
|
743
|
-
_createClass(Commands, [{
|
|
744
|
-
key: "run",
|
|
745
|
-
value: function () {
|
|
746
|
-
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(command) {
|
|
747
|
-
var args,
|
|
748
|
-
options,
|
|
749
|
-
result,
|
|
750
|
-
_args = arguments;
|
|
751
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
752
|
-
while (1) switch (_context.prev = _context.next) {
|
|
753
|
-
case 0:
|
|
754
|
-
args = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
755
|
-
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
756
|
-
if (typeof command === "string") {
|
|
757
|
-
command = this.getCommandInstance(command, args, options);
|
|
758
|
-
}
|
|
759
|
-
this.attachCurrent(command, args);
|
|
760
|
-
_context.next = 6;
|
|
761
|
-
return this.runInstance(command, args, options);
|
|
762
|
-
case 6:
|
|
763
|
-
result = _context.sent;
|
|
764
|
-
this.detachCurrent(command);
|
|
765
|
-
return _context.abrupt("return", result);
|
|
766
|
-
case 9:
|
|
767
|
-
case "end":
|
|
768
|
-
return _context.stop();
|
|
769
|
-
}
|
|
770
|
-
}, _callee, this);
|
|
771
|
-
}));
|
|
772
|
-
function run(_x) {
|
|
773
|
-
return _run.apply(this, arguments);
|
|
774
|
-
}
|
|
775
|
-
return run;
|
|
776
|
-
}()
|
|
777
|
-
}, {
|
|
778
|
-
key: "register",
|
|
779
|
-
value: function register(commands, controller) {
|
|
780
|
-
var _this2 = this;
|
|
781
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
782
|
-
var result = {};
|
|
783
|
-
Object.values(commands).forEach(function (command) {
|
|
784
|
-
var commandName = command.getName();
|
|
785
|
-
if (_this2.commands[commandName]) {
|
|
786
|
-
throw new CommandAlreadyRegistered(command);
|
|
787
|
-
}
|
|
788
|
-
command.setController(controller);
|
|
789
|
-
_this2.commands[commandName] = command;
|
|
790
|
-
result[commandName] = command;
|
|
791
|
-
});
|
|
792
|
-
return result;
|
|
793
|
-
}
|
|
794
|
-
}, {
|
|
795
|
-
key: "getAll",
|
|
796
|
-
value: function getAll() {
|
|
797
|
-
return this.commands;
|
|
798
|
-
}
|
|
799
|
-
}, {
|
|
800
|
-
key: "getByName",
|
|
801
|
-
value: function getByName(name) {
|
|
802
|
-
return this.commands[name];
|
|
803
|
-
}
|
|
804
|
-
}, {
|
|
805
|
-
key: "getLogger",
|
|
806
|
-
value: function getLogger() {
|
|
807
|
-
return this.logger;
|
|
808
|
-
}
|
|
809
|
-
}, {
|
|
810
|
-
key: "getCommandInstance",
|
|
811
|
-
value: function getCommandInstance(name) {
|
|
812
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
813
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
814
|
-
var CommandClass = this.commands[name];
|
|
815
|
-
if (!CommandClass) {
|
|
816
|
-
throw new CommandNotFound(name);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// @ts-ignore
|
|
820
|
-
return new CommandClass(args, options);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Used to set hooks that effects only data and not UI.
|
|
825
|
-
*/
|
|
826
|
-
}, {
|
|
827
|
-
key: "onBefore",
|
|
828
|
-
value: function onBefore(hookCommand, callback) {
|
|
829
|
-
Commands.hookCommand(this.onBeforeHooks, hookCommand, callback);
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* Used to set hooks that effects only UI.
|
|
834
|
-
*/
|
|
835
|
-
}, {
|
|
836
|
-
key: "onBeforeUI",
|
|
837
|
-
value: function onBeforeUI(hookCommand, callback) {
|
|
838
|
-
Commands.hookCommand(this.onBeforeUIHooks, hookCommand, callback);
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
/**
|
|
842
|
-
* Used to set hooks that effects only data and not UI.
|
|
843
|
-
*/
|
|
844
|
-
}, {
|
|
845
|
-
key: "onAfter",
|
|
846
|
-
value: function onAfter(hookCommand, callback) {
|
|
847
|
-
Commands.hookCommand(this.onAfterHooks, hookCommand, callback);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* Used to set hooks that effects only UI.
|
|
852
|
-
*/
|
|
853
|
-
}, {
|
|
854
|
-
key: "onAfterUI",
|
|
855
|
-
value: function onAfterUI(command, callback) {
|
|
856
|
-
Commands.hookCommand(this.onAfterUIHooks, command, callback);
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* Used to set hooks that effects only data and not UI.
|
|
861
|
-
*/
|
|
862
|
-
}, {
|
|
863
|
-
key: "onAfterOnce",
|
|
864
|
-
value: function onAfterOnce(command, callback) {
|
|
865
|
-
Commands.hookCommand(this.onAfterOnceHooks, command, callback);
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Used to register a trigger that runs command after `hookCommand` run's.
|
|
870
|
-
*/
|
|
871
|
-
}, {
|
|
872
|
-
key: "onAfterAffect",
|
|
873
|
-
value: function onAfterAffect(hookCommand, affectCommand) {
|
|
874
|
-
Commands.hookCommand(this.onAfterAffectHooks, hookCommand, affectCommand);
|
|
875
|
-
}
|
|
876
|
-
}, {
|
|
877
|
-
key: "onBeforeRun",
|
|
878
|
-
value: function onBeforeRun(command) {
|
|
879
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
880
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
881
|
-
if (this.onBeforeHooks[command.getName()]) {
|
|
882
|
-
var callbacks = this.onBeforeHooks[command.getName()];
|
|
883
|
-
callbacks.forEach(function (callback) {
|
|
884
|
-
return callback(args, options);
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
if (this.onBeforeUIHooks[command.getName()]) {
|
|
888
|
-
var _callbacks = this.onBeforeUIHooks[command.getName()];
|
|
889
|
-
_callbacks.forEach(function (callback) {
|
|
890
|
-
return callback(args, options);
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}, {
|
|
895
|
-
key: "runInstance",
|
|
896
|
-
value: function () {
|
|
897
|
-
var _runInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(command) {
|
|
898
|
-
var args,
|
|
899
|
-
options,
|
|
900
|
-
result,
|
|
901
|
-
_args2 = arguments;
|
|
902
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
903
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
904
|
-
case 0:
|
|
905
|
-
args = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
906
|
-
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
907
|
-
result = null;
|
|
908
|
-
this.logger.startsWith(this.runInstance, {
|
|
909
|
-
command: command.getName(),
|
|
910
|
-
options: options,
|
|
911
|
-
args: args
|
|
912
|
-
});
|
|
913
|
-
this.onBeforeRun(command, args, options);
|
|
914
|
-
_context2.next = 7;
|
|
915
|
-
return command.run();
|
|
916
|
-
case 7:
|
|
917
|
-
result = _context2.sent;
|
|
918
|
-
_context2.next = 10;
|
|
919
|
-
return this.onAfterRun(command, args, options, result);
|
|
920
|
-
case 10:
|
|
921
|
-
return _context2.abrupt("return", result);
|
|
922
|
-
case 11:
|
|
923
|
-
case "end":
|
|
924
|
-
return _context2.stop();
|
|
925
|
-
}
|
|
926
|
-
}, _callee2, this);
|
|
927
|
-
}));
|
|
928
|
-
function runInstance(_x2) {
|
|
929
|
-
return _runInstance.apply(this, arguments);
|
|
930
|
-
}
|
|
931
|
-
return runInstance;
|
|
932
|
-
}()
|
|
933
|
-
}, {
|
|
934
|
-
key: "onAfterRun",
|
|
935
|
-
value: function () {
|
|
936
|
-
var _onAfterRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(command, args, options, result) {
|
|
937
|
-
var _this3 = this;
|
|
938
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
939
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
940
|
-
case 0:
|
|
941
|
-
options = Object.assign({}, options);
|
|
942
|
-
if (!this.onAfterAffectHooks[command.getName()]) {
|
|
943
|
-
_context3.next = 6;
|
|
944
|
-
break;
|
|
945
|
-
}
|
|
946
|
-
this.onAfterAffectHooks[command.getName()].forEach(function (command) {
|
|
947
|
-
args.result = result;
|
|
948
|
-
result = _this3.run(command.toString(), args, options);
|
|
949
|
-
});
|
|
950
|
-
_context3.next = 5;
|
|
951
|
-
return result;
|
|
952
|
-
case 5:
|
|
953
|
-
result = _context3.sent;
|
|
954
|
-
case 6:
|
|
955
|
-
if (!this.onAfterHooks) {
|
|
956
|
-
_context3.next = 10;
|
|
957
|
-
break;
|
|
958
|
-
}
|
|
959
|
-
args.result = result;
|
|
960
|
-
_context3.next = 10;
|
|
961
|
-
return Commands.runCallbacks(Object.assign([], this.onAfterHooks[command.getName()]), args, options);
|
|
962
|
-
case 10:
|
|
963
|
-
if (!this.onAfterOnceHooks) {
|
|
964
|
-
_context3.next = 13;
|
|
965
|
-
break;
|
|
966
|
-
}
|
|
967
|
-
_context3.next = 13;
|
|
968
|
-
return Commands.runCallbacks(this.onAfterOnceHooks[command.getName()], args, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
969
|
-
pop: true // Delete after run.
|
|
970
|
-
}));
|
|
971
|
-
case 13:
|
|
972
|
-
if (this.onAfterUIHooks) {
|
|
973
|
-
Commands.runCallbacks(Object.assign([], this.onAfterUIHooks[command.getName()]), args, options);
|
|
974
|
-
}
|
|
975
|
-
return _context3.abrupt("return", result);
|
|
976
|
-
case 15:
|
|
977
|
-
case "end":
|
|
978
|
-
return _context3.stop();
|
|
979
|
-
}
|
|
980
|
-
}, _callee3, this);
|
|
981
|
-
}));
|
|
982
|
-
function onAfterRun(_x3, _x4, _x5, _x6) {
|
|
983
|
-
return _onAfterRun.apply(this, arguments);
|
|
984
|
-
}
|
|
985
|
-
return onAfterRun;
|
|
986
|
-
}()
|
|
987
|
-
}, {
|
|
988
|
-
key: "attachCurrent",
|
|
989
|
-
value: function attachCurrent(command) {
|
|
990
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
991
|
-
this.current[command.getName()] = command;
|
|
992
|
-
this.currentArgs[command.getName()] = args;
|
|
993
|
-
this.trace.push(command.getName());
|
|
994
|
-
Commands.trace.push(command.getName());
|
|
995
|
-
}
|
|
996
|
-
}, {
|
|
997
|
-
key: "detachCurrent",
|
|
998
|
-
value: function detachCurrent(command) {
|
|
999
|
-
delete this.current[command.getName()];
|
|
1000
|
-
delete this.currentArgs[command.getName()];
|
|
1001
|
-
Commands.trace.pop();
|
|
1002
|
-
this.trace.pop();
|
|
1003
|
-
}
|
|
1004
|
-
}], [{
|
|
1005
|
-
key: "getName",
|
|
1006
|
-
value: function getName() {
|
|
1007
|
-
return "ZenFlux/Core/Managers/Commands";
|
|
1008
|
-
}
|
|
1009
|
-
}, {
|
|
1010
|
-
key: "runCallbacks",
|
|
1011
|
-
value: function () {
|
|
1012
|
-
var _runCallbacks = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(callbacks) {
|
|
1013
|
-
var args,
|
|
1014
|
-
options,
|
|
1015
|
-
callbacksLength,
|
|
1016
|
-
i,
|
|
1017
|
-
callback,
|
|
1018
|
-
_args4 = arguments;
|
|
1019
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1020
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1021
|
-
case 0:
|
|
1022
|
-
args = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
1023
|
-
options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
1024
|
-
callbacksLength = (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length) || 0;
|
|
1025
|
-
i = 0;
|
|
1026
|
-
case 4:
|
|
1027
|
-
if (!(i < callbacksLength)) {
|
|
1028
|
-
_context4.next = 13;
|
|
1029
|
-
break;
|
|
1030
|
-
}
|
|
1031
|
-
callback = options.pop === true ? callbacks.pop() : callbacks[i];
|
|
1032
|
-
if (callback) {
|
|
1033
|
-
_context4.next = 8;
|
|
1034
|
-
break;
|
|
1035
|
-
}
|
|
1036
|
-
throw new Error("Callback is not defined.");
|
|
1037
|
-
case 8:
|
|
1038
|
-
_context4.next = 10;
|
|
1039
|
-
return callback(args, options);
|
|
1040
|
-
case 10:
|
|
1041
|
-
++i;
|
|
1042
|
-
_context4.next = 4;
|
|
1043
|
-
break;
|
|
1044
|
-
case 13:
|
|
1045
|
-
case "end":
|
|
1046
|
-
return _context4.stop();
|
|
1047
|
-
}
|
|
1048
|
-
}, _callee4);
|
|
1049
|
-
}));
|
|
1050
|
-
function runCallbacks(_x7) {
|
|
1051
|
-
return _runCallbacks.apply(this, arguments);
|
|
1052
|
-
}
|
|
1053
|
-
return runCallbacks;
|
|
1054
|
-
}()
|
|
1055
|
-
}, {
|
|
1056
|
-
key: "hookCommand",
|
|
1057
|
-
value: function hookCommand(stack, _hookCommand, context) {
|
|
1058
|
-
if (!stack[_hookCommand]) {
|
|
1059
|
-
stack[_hookCommand] = [];
|
|
1060
|
-
}
|
|
1061
|
-
stack[_hookCommand].push(context);
|
|
1062
|
-
}
|
|
1063
|
-
}]);
|
|
1064
|
-
return Commands;
|
|
1065
|
-
}(ObjectBase);
|
|
1066
|
-
_defineProperty(Commands, "trace", []);
|
|
1067
|
-
|
|
1068
|
-
var Controllers = /*#__PURE__*/function (_ObjectBase) {
|
|
1069
|
-
_inherits(Controllers, _ObjectBase);
|
|
1070
|
-
var _super = _createSuper(Controllers);
|
|
1071
|
-
function Controllers() {
|
|
1072
|
-
var _this;
|
|
1073
|
-
_classCallCheck(this, Controllers);
|
|
1074
|
-
_this = _super.call(this);
|
|
1075
|
-
_defineProperty(_assertThisInitialized(_this), "controllers", {});
|
|
1076
|
-
return _this;
|
|
1077
|
-
}
|
|
1078
|
-
_createClass(Controllers, [{
|
|
1079
|
-
key: "get",
|
|
1080
|
-
value: function get(name) {
|
|
1081
|
-
return this.controllers[name];
|
|
1082
|
-
}
|
|
1083
|
-
}, {
|
|
1084
|
-
key: "getAll",
|
|
1085
|
-
value: function getAll() {
|
|
1086
|
-
return this.controllers;
|
|
1087
|
-
}
|
|
1088
|
-
}, {
|
|
1089
|
-
key: "register",
|
|
1090
|
-
value: function register(controller) {
|
|
1091
|
-
if (this.controllers[controller.getName()]) {
|
|
1092
|
-
throw new ControllerAlreadyRegistered(controller);
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
// Register.
|
|
1096
|
-
this.controllers[controller.getName()] = controller;
|
|
1097
|
-
return controller;
|
|
1098
|
-
}
|
|
1099
|
-
}], [{
|
|
1100
|
-
key: "getName",
|
|
1101
|
-
value: function getName() {
|
|
1102
|
-
return "ZenFlux/Core/Managers/Controllers";
|
|
1103
|
-
}
|
|
1104
|
-
}]);
|
|
1105
|
-
return Controllers;
|
|
1106
|
-
}(ObjectBase);
|
|
1107
|
-
|
|
1108
|
-
function _superPropBase(object, property) {
|
|
1109
|
-
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
1110
|
-
object = _getPrototypeOf(object);
|
|
1111
|
-
if (object === null) break;
|
|
1112
|
-
}
|
|
1113
|
-
return object;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
function _get() {
|
|
1117
|
-
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
1118
|
-
_get = Reflect.get.bind();
|
|
1119
|
-
} else {
|
|
1120
|
-
_get = function _get(target, property, receiver) {
|
|
1121
|
-
var base = _superPropBase(target, property);
|
|
1122
|
-
if (!base) return;
|
|
1123
|
-
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
1124
|
-
if (desc.get) {
|
|
1125
|
-
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
1126
|
-
}
|
|
1127
|
-
return desc.value;
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
return _get.apply(this, arguments);
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
var E_RESPONSE_HANDLER_TYPE = /*#__PURE__*/function (E_RESPONSE_HANDLER_TYPE) {
|
|
1134
|
-
E_RESPONSE_HANDLER_TYPE["ERROR_HANDLER"] = "error_handler";
|
|
1135
|
-
E_RESPONSE_HANDLER_TYPE["RESPONSE_FILTER"] = "response_filter";
|
|
1136
|
-
E_RESPONSE_HANDLER_TYPE["RESPONSE_HANDLER"] = "response_handler";
|
|
1137
|
-
return E_RESPONSE_HANDLER_TYPE;
|
|
1138
|
-
}({});
|
|
1139
|
-
var E_HTTP_METHOD_TYPE = /*#__PURE__*/function (E_HTTP_METHOD_TYPE) {
|
|
1140
|
-
E_HTTP_METHOD_TYPE["DELETE"] = "DELETE";
|
|
1141
|
-
E_HTTP_METHOD_TYPE["GET"] = "GET";
|
|
1142
|
-
E_HTTP_METHOD_TYPE["OPTIONS"] = "OPTIONS";
|
|
1143
|
-
E_HTTP_METHOD_TYPE["PATCH"] = "PATCH";
|
|
1144
|
-
E_HTTP_METHOD_TYPE["POST"] = "POST";
|
|
1145
|
-
E_HTTP_METHOD_TYPE["PUT"] = "PUT";
|
|
1146
|
-
E_HTTP_METHOD_TYPE["__EMPTY__"] = "";
|
|
1147
|
-
return E_HTTP_METHOD_TYPE;
|
|
1148
|
-
}({});
|
|
1149
|
-
|
|
1150
|
-
/**
|
|
1151
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1152
|
-
*/
|
|
1153
|
-
|
|
1154
|
-
var index$2 = /*#__PURE__*/Object.freeze({
|
|
1155
|
-
__proto__: null,
|
|
1156
|
-
E_HTTP_METHOD_TYPE: E_HTTP_METHOD_TYPE,
|
|
1157
|
-
E_RESPONSE_HANDLER_TYPE: E_RESPONSE_HANDLER_TYPE
|
|
1158
|
-
});
|
|
1159
|
-
|
|
1160
|
-
// noinspection ExceptionCaughtLocallyJS
|
|
1161
|
-
|
|
1162
|
-
var Http = /*#__PURE__*/function (_ObjectBase) {
|
|
1163
|
-
_inherits(Http, _ObjectBase);
|
|
1164
|
-
var _super = _createSuper(Http);
|
|
1165
|
-
/**
|
|
1166
|
-
* Initializes the base class and sets up configuration parameters.
|
|
1167
|
-
*/
|
|
1168
|
-
function Http() {
|
|
1169
|
-
var _this;
|
|
1170
|
-
var apiBaseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "http://localhost";
|
|
1171
|
-
var requestInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1172
|
-
"credentials": "include"
|
|
1173
|
-
};
|
|
1174
|
-
_classCallCheck(this, Http);
|
|
1175
|
-
_this = _super.call(this);
|
|
1176
|
-
_defineProperty(_assertThisInitialized(_this), "errorHandler", undefined);
|
|
1177
|
-
_defineProperty(_assertThisInitialized(_this), "responseFilter", undefined);
|
|
1178
|
-
_defineProperty(_assertThisInitialized(_this), "responseHandler", undefined);
|
|
1179
|
-
_this.logger = new ZenCore.classes.Logger(Http);
|
|
1180
|
-
_this.logger.startsWith(_this.constructor, {
|
|
1181
|
-
apiBaseUrl: apiBaseUrl
|
|
1182
|
-
});
|
|
1183
|
-
_this.apiBaseUrl = apiBaseUrl + "/";
|
|
1184
|
-
_this.requestInit = requestInit;
|
|
1185
|
-
return _this;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* Fetches data from the specified path using the given HTTP method and optional request body.
|
|
1190
|
-
*/
|
|
1191
|
-
_createClass(Http, [{
|
|
1192
|
-
key: "fetch",
|
|
1193
|
-
value: function () {
|
|
1194
|
-
var _fetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, method) {
|
|
1195
|
-
var body,
|
|
1196
|
-
params,
|
|
1197
|
-
headers,
|
|
1198
|
-
fetchPromise,
|
|
1199
|
-
response,
|
|
1200
|
-
data,
|
|
1201
|
-
_response$headers,
|
|
1202
|
-
responseText,
|
|
1203
|
-
_args = arguments;
|
|
1204
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1205
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1206
|
-
case 0:
|
|
1207
|
-
body = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
1208
|
-
this.logger.startsWith(this.constructor, {
|
|
1209
|
-
path: path,
|
|
1210
|
-
method: method,
|
|
1211
|
-
body: body
|
|
1212
|
-
});
|
|
1213
|
-
params = Object.assign({}, this.requestInit);
|
|
1214
|
-
headers = {};
|
|
1215
|
-
if (method === E_HTTP_METHOD_TYPE.GET) {
|
|
1216
|
-
Object.assign(params, {
|
|
1217
|
-
headers: headers
|
|
1218
|
-
});
|
|
1219
|
-
} else {
|
|
1220
|
-
Object.assign(headers, {
|
|
1221
|
-
"Content-Type": "application/json"
|
|
1222
|
-
});
|
|
1223
|
-
Object.assign(params, {
|
|
1224
|
-
method: method,
|
|
1225
|
-
headers: headers,
|
|
1226
|
-
body: JSON.stringify(body)
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
fetchPromise = globalThis.fetch(this.apiBaseUrl + path, params);
|
|
1230
|
-
_context.next = 8;
|
|
1231
|
-
return fetchPromise;
|
|
1232
|
-
case 8:
|
|
1233
|
-
response = _context.sent;
|
|
1234
|
-
if (response) {
|
|
1235
|
-
_context.next = 11;
|
|
1236
|
-
break;
|
|
1237
|
-
}
|
|
1238
|
-
return _context.abrupt("return", false);
|
|
1239
|
-
case 11:
|
|
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;
|
|
1249
|
-
return response.text();
|
|
1250
|
-
case 17:
|
|
1251
|
-
responseText = _context.sent;
|
|
1252
|
-
responseText = this.applyResponseFilter(responseText);
|
|
1253
|
-
|
|
1254
|
-
// TODO: Currently support JSON and plain text.
|
|
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")) {
|
|
1256
|
-
data = JSON.parse(responseText);
|
|
1257
|
-
} else {
|
|
1258
|
-
data = responseText;
|
|
1259
|
-
}
|
|
1260
|
-
if (!this.applyResponseHandler(data)) {
|
|
1261
|
-
_context.next = 22;
|
|
1262
|
-
break;
|
|
1263
|
-
}
|
|
1264
|
-
return _context.abrupt("return", false);
|
|
1265
|
-
case 22:
|
|
1266
|
-
_context.next = 30;
|
|
1267
|
-
break;
|
|
1268
|
-
case 24:
|
|
1269
|
-
_context.prev = 24;
|
|
1270
|
-
_context.t0 = _context["catch"](12);
|
|
1271
|
-
if (!this.applyErrorHandler(_context.t0)) {
|
|
1272
|
-
_context.next = 28;
|
|
1273
|
-
break;
|
|
1274
|
-
}
|
|
1275
|
-
return _context.abrupt("return", false);
|
|
1276
|
-
case 28:
|
|
1277
|
-
_context.next = 30;
|
|
1278
|
-
return Promise.reject(_context.t0);
|
|
1279
|
-
case 30:
|
|
1280
|
-
this.logger.drop(this.fetch, {
|
|
1281
|
-
path: path
|
|
1282
|
-
}, data);
|
|
1283
|
-
return _context.abrupt("return", data);
|
|
1284
|
-
case 32:
|
|
1285
|
-
case "end":
|
|
1286
|
-
return _context.stop();
|
|
1287
|
-
}
|
|
1288
|
-
}, _callee, this, [[12, 24]]);
|
|
1289
|
-
}));
|
|
1290
|
-
function fetch(_x, _x2) {
|
|
1291
|
-
return _fetch.apply(this, arguments);
|
|
1292
|
-
}
|
|
1293
|
-
return fetch;
|
|
1294
|
-
}()
|
|
1295
|
-
/**
|
|
1296
|
-
* Sets the error handler callback for handling errors during fetch requests.
|
|
1297
|
-
*/
|
|
1298
|
-
}, {
|
|
1299
|
-
key: "setErrorHandler",
|
|
1300
|
-
value: function setErrorHandler(callback) {
|
|
1301
|
-
if (this.errorHandler) {
|
|
1302
|
-
throw new Error("Error handler already set.");
|
|
1303
|
-
}
|
|
1304
|
-
this.errorHandler = callback;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
/**
|
|
1308
|
-
* Sets the response filter callback for filtering the response text.
|
|
1309
|
-
*/
|
|
1310
|
-
}, {
|
|
1311
|
-
key: "setResponseFilter",
|
|
1312
|
-
value: function setResponseFilter(callback) {
|
|
1313
|
-
if (this.responseFilter) {
|
|
1314
|
-
throw new Error("Response filter already set.");
|
|
1315
|
-
}
|
|
1316
|
-
this.responseFilter = callback;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
/**
|
|
1320
|
-
* Sets the response handler callback for handling the response data.
|
|
1321
|
-
*/
|
|
1322
|
-
}, {
|
|
1323
|
-
key: "setResponseHandler",
|
|
1324
|
-
value: function setResponseHandler(callback) {
|
|
1325
|
-
if (this.responseHandler) {
|
|
1326
|
-
throw new Error("Response handler already set.");
|
|
1327
|
-
}
|
|
1328
|
-
this.responseHandler = callback;
|
|
1329
|
-
}
|
|
1330
|
-
}, {
|
|
1331
|
-
key: "applyErrorHandler",
|
|
1332
|
-
value: function applyErrorHandler(error) {
|
|
1333
|
-
return !!this.errorHandler && this.errorHandler(error);
|
|
1334
|
-
}
|
|
1335
|
-
}, {
|
|
1336
|
-
key: "applyResponseFilter",
|
|
1337
|
-
value: function applyResponseFilter(text) {
|
|
1338
|
-
return this.responseFilter && this.responseFilter(text) || text;
|
|
1339
|
-
}
|
|
1340
|
-
}, {
|
|
1341
|
-
key: "applyResponseHandler",
|
|
1342
|
-
value: function applyResponseHandler(text) {
|
|
1343
|
-
return !!this.responseHandler && this.responseHandler(text);
|
|
1344
|
-
}
|
|
1345
|
-
}], [{
|
|
1346
|
-
key: "getName",
|
|
1347
|
-
value: function getName() {
|
|
1348
|
-
return "ZenFlux/Core/Clients/Http";
|
|
1349
|
-
}
|
|
1350
|
-
}]);
|
|
1351
|
-
return Http;
|
|
1352
|
-
}(ObjectBase);
|
|
1353
|
-
|
|
1354
|
-
var Restful = /*#__PURE__*/function (_Commands) {
|
|
1355
|
-
_inherits(Restful, _Commands);
|
|
1356
|
-
var _super = _createSuper(Restful);
|
|
1357
|
-
function Restful(Config) {
|
|
1358
|
-
var _this;
|
|
1359
|
-
_classCallCheck(this, Restful);
|
|
1360
|
-
_this = _super.call(this);
|
|
1361
|
-
Restful.client = new Http(Config.baseURL, Config.requestInit);
|
|
1362
|
-
return _this;
|
|
1363
|
-
}
|
|
1364
|
-
_createClass(Restful, [{
|
|
1365
|
-
key: "getClient",
|
|
1366
|
-
value: function getClient() {
|
|
1367
|
-
return Restful.client;
|
|
1368
|
-
}
|
|
1369
|
-
}, {
|
|
1370
|
-
key: "get",
|
|
1371
|
-
value: function get(command) {
|
|
1372
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1373
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1374
|
-
this.currentHttpMethod = E_HTTP_METHOD_TYPE.GET;
|
|
1375
|
-
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1376
|
-
}
|
|
1377
|
-
}, {
|
|
1378
|
-
key: "update",
|
|
1379
|
-
value: function update(command) {
|
|
1380
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1381
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1382
|
-
this.currentHttpMethod = E_HTTP_METHOD_TYPE.PATCH;
|
|
1383
|
-
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1384
|
-
}
|
|
1385
|
-
}, {
|
|
1386
|
-
key: "delete",
|
|
1387
|
-
value: function _delete(command) {
|
|
1388
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1389
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1390
|
-
this.currentHttpMethod = E_HTTP_METHOD_TYPE.DELETE;
|
|
1391
|
-
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1392
|
-
}
|
|
1393
|
-
}, {
|
|
1394
|
-
key: "create",
|
|
1395
|
-
value: function create(command) {
|
|
1396
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1397
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1398
|
-
this.currentHttpMethod = E_HTTP_METHOD_TYPE.POST;
|
|
1399
|
-
return _get(_getPrototypeOf(Restful.prototype), "run", this).call(this, command, args, options);
|
|
1400
|
-
}
|
|
1401
|
-
}, {
|
|
1402
|
-
key: "runInstance",
|
|
1403
|
-
value: function () {
|
|
1404
|
-
var _runInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(command) {
|
|
1405
|
-
var args,
|
|
1406
|
-
options,
|
|
1407
|
-
newArgs,
|
|
1408
|
-
_args = arguments;
|
|
1409
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1410
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1411
|
-
case 0:
|
|
1412
|
-
args = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
1413
|
-
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
1414
|
-
if (this.currentHttpMethod) {
|
|
1415
|
-
_context.next = 4;
|
|
1416
|
-
break;
|
|
1417
|
-
}
|
|
1418
|
-
throw new Error("Cannot run directly use one of the http methods: \"get\", \"update\", \"delete, \"create");
|
|
1419
|
-
case 4:
|
|
1420
|
-
// New args.
|
|
1421
|
-
newArgs = {
|
|
1422
|
-
type: this.currentHttpMethod,
|
|
1423
|
-
args: {
|
|
1424
|
-
query: {},
|
|
1425
|
-
data: {}
|
|
1426
|
-
}
|
|
1427
|
-
};
|
|
1428
|
-
if (E_HTTP_METHOD_TYPE.GET === this.currentHttpMethod) {
|
|
1429
|
-
newArgs.args.query = args;
|
|
1430
|
-
} else {
|
|
1431
|
-
newArgs.args.data = args;
|
|
1432
|
-
}
|
|
1433
|
-
_context.next = 8;
|
|
1434
|
-
return _get(_getPrototypeOf(Restful.prototype), "runInstance", this).call(this, command, newArgs, options);
|
|
1435
|
-
case 8:
|
|
1436
|
-
args.result = _context.sent;
|
|
1437
|
-
// Clear method type.
|
|
1438
|
-
this.currentHttpMethod = E_HTTP_METHOD_TYPE.__EMPTY__;
|
|
1439
|
-
return _context.abrupt("return", args.result);
|
|
1440
|
-
case 11:
|
|
1441
|
-
case "end":
|
|
1442
|
-
return _context.stop();
|
|
1443
|
-
}
|
|
1444
|
-
}, _callee, this);
|
|
1445
|
-
}));
|
|
1446
|
-
function runInstance(_x) {
|
|
1447
|
-
return _runInstance.apply(this, arguments);
|
|
1448
|
-
}
|
|
1449
|
-
return runInstance;
|
|
1450
|
-
}()
|
|
1451
|
-
/**
|
|
1452
|
-
* Handlers on return true will swallow the request.
|
|
1453
|
-
*/
|
|
1454
|
-
}, {
|
|
1455
|
-
key: "setHandler",
|
|
1456
|
-
value: function setHandler(type, callback) {
|
|
1457
|
-
switch (type) {
|
|
1458
|
-
case E_RESPONSE_HANDLER_TYPE.ERROR_HANDLER:
|
|
1459
|
-
Restful.client.setErrorHandler(callback);
|
|
1460
|
-
break;
|
|
1461
|
-
case E_RESPONSE_HANDLER_TYPE.RESPONSE_FILTER:
|
|
1462
|
-
Restful.client.setResponseFilter(callback);
|
|
1463
|
-
break;
|
|
1464
|
-
case E_RESPONSE_HANDLER_TYPE.RESPONSE_HANDLER:
|
|
1465
|
-
Restful.client.setResponseHandler(callback);
|
|
1466
|
-
break;
|
|
1467
|
-
default:
|
|
1468
|
-
throw new Error("Unknown handler type: '".concat(type, "'"));
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
}], [{
|
|
1472
|
-
key: "getName",
|
|
1473
|
-
value: function getName() {
|
|
1474
|
-
return "ZenFlux/Core/Managers/Restful";
|
|
1475
|
-
}
|
|
1476
|
-
}]);
|
|
1477
|
-
return Restful;
|
|
1478
|
-
}(Commands);
|
|
1479
|
-
|
|
1480
|
-
var Internal = /*#__PURE__*/function (_Commands) {
|
|
1481
|
-
_inherits(Internal, _Commands);
|
|
1482
|
-
var _super = _createSuper(Internal);
|
|
1483
|
-
function Internal() {
|
|
1484
|
-
_classCallCheck(this, Internal);
|
|
1485
|
-
return _super.apply(this, arguments);
|
|
1486
|
-
}
|
|
1487
|
-
_createClass(Internal, null, [{
|
|
1488
|
-
key: "getName",
|
|
1489
|
-
value: function getName() {
|
|
1490
|
-
return "ZenFlux/Core/Managers/Internal";
|
|
1491
|
-
}
|
|
1492
|
-
}]);
|
|
1493
|
-
return Internal;
|
|
1494
|
-
}(Commands);
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1498
|
-
*/
|
|
1499
|
-
var afterInitializeCallbacks = [];
|
|
1500
|
-
function initialize(config) {
|
|
1501
|
-
commands = new Commands();
|
|
1502
|
-
controllers = new Controllers();
|
|
1503
|
-
restful = new Restful(config);
|
|
1504
|
-
internal = new Internal();
|
|
1505
|
-
}
|
|
1506
|
-
function destroy() {
|
|
1507
|
-
commands = {};
|
|
1508
|
-
controllers = {};
|
|
1509
|
-
restful = {};
|
|
1510
|
-
internal = {};
|
|
1511
|
-
}
|
|
1512
|
-
var commands = {};
|
|
1513
|
-
var controllers = {};
|
|
1514
|
-
var restful = {};
|
|
1515
|
-
var internal = {};
|
|
1516
|
-
|
|
1517
|
-
var _export = /*#__PURE__*/Object.freeze({
|
|
1518
|
-
__proto__: null,
|
|
1519
|
-
afterInitializeCallbacks: afterInitializeCallbacks,
|
|
1520
|
-
get commands () { return commands; },
|
|
1521
|
-
get controllers () { return controllers; },
|
|
1522
|
-
destroy: destroy,
|
|
1523
|
-
initialize: initialize,
|
|
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
|
|
1625
|
-
});
|
|
1626
|
-
|
|
1627
|
-
var CommandBase = /*#__PURE__*/function (_ObjectBase) {
|
|
1628
|
-
_inherits(CommandBase, _ObjectBase);
|
|
1629
|
-
var _super = _createSuper(CommandBase);
|
|
1630
|
-
function CommandBase() {
|
|
1631
|
-
var _this;
|
|
1632
|
-
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1633
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1634
|
-
_classCallCheck(this, CommandBase);
|
|
1635
|
-
_this = _super.call(this);
|
|
1636
|
-
_defineProperty(_assertThisInitialized(_this), "args", {});
|
|
1637
|
-
_defineProperty(_assertThisInitialized(_this), "options", {});
|
|
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
|
|
1642
|
-
});
|
|
1643
|
-
_this.logger.startsWith(_this.constructor, {
|
|
1644
|
-
args: args,
|
|
1645
|
-
options: options
|
|
1646
|
-
});
|
|
1647
|
-
_this.initialize(args, options);
|
|
1648
|
-
return _this;
|
|
1649
|
-
}
|
|
1650
|
-
_createClass(CommandBase, [{
|
|
1651
|
-
key: "initialize",
|
|
1652
|
-
value: function initialize(args, options) {
|
|
1653
|
-
this.args = args;
|
|
1654
|
-
this.options = options;
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
/**
|
|
1658
|
-
* TODO: Maybe abstract, currently not sure about parameters initialization.
|
|
1659
|
-
*/
|
|
1660
|
-
}, {
|
|
1661
|
-
key: "apply",
|
|
1662
|
-
value: function apply() {
|
|
1663
|
-
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
|
|
1664
|
-
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options;
|
|
1665
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1666
|
-
throw new ForceMethodImplementation(this, "apply");
|
|
1667
|
-
}
|
|
1668
|
-
}, {
|
|
1669
|
-
key: "run",
|
|
1670
|
-
value: function () {
|
|
1671
|
-
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1672
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1673
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1674
|
-
case 0:
|
|
1675
|
-
return _context.abrupt("return", this.runInternal());
|
|
1676
|
-
case 1:
|
|
1677
|
-
case "end":
|
|
1678
|
-
return _context.stop();
|
|
1679
|
-
}
|
|
1680
|
-
}, _callee, this);
|
|
1681
|
-
}));
|
|
1682
|
-
function run() {
|
|
1683
|
-
return _run.apply(this, arguments);
|
|
1684
|
-
}
|
|
1685
|
-
return run;
|
|
1686
|
-
}()
|
|
1687
|
-
}, {
|
|
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";
|
|
1717
|
-
}
|
|
1718
|
-
}, {
|
|
1719
|
-
key: "setController",
|
|
1720
|
-
value: function setController(controller) {
|
|
1721
|
-
if (this.controller) {
|
|
1722
|
-
throw new ControllerAlreadySet(this.controller);
|
|
1723
|
-
}
|
|
1724
|
-
this.controller = controller;
|
|
1725
|
-
}
|
|
1726
|
-
}, {
|
|
1727
|
-
key: "getController",
|
|
1728
|
-
value: function getController() {
|
|
1729
|
-
return this.controller;
|
|
1730
|
-
}
|
|
1731
|
-
}]);
|
|
1732
|
-
return CommandBase;
|
|
1733
|
-
}(ObjectBase);
|
|
1734
|
-
|
|
1735
|
-
var CommandPublic = /*#__PURE__*/function (_CommandBase) {
|
|
1736
|
-
_inherits(CommandPublic, _CommandBase);
|
|
1737
|
-
var _super = _createSuper(CommandPublic);
|
|
1738
|
-
function CommandPublic() {
|
|
1739
|
-
_classCallCheck(this, CommandPublic);
|
|
1740
|
-
return _super.apply(this, arguments);
|
|
1741
|
-
}
|
|
1742
|
-
_createClass(CommandPublic, null, [{
|
|
1743
|
-
key: "getName",
|
|
1744
|
-
value: function getName() {
|
|
1745
|
-
return "ZenFlux/Core/CommandBases/CommandPublic";
|
|
1746
|
-
}
|
|
1747
|
-
}]);
|
|
1748
|
-
return CommandPublic;
|
|
1749
|
-
}(CommandBase);
|
|
1750
|
-
|
|
1751
|
-
var CommandRestful = /*#__PURE__*/function (_CommandBase) {
|
|
1752
|
-
_inherits(CommandRestful, _CommandBase);
|
|
1753
|
-
var _super = _createSuper(CommandRestful);
|
|
1754
|
-
function CommandRestful() {
|
|
1755
|
-
_classCallCheck(this, CommandRestful);
|
|
1756
|
-
return _super.apply(this, arguments);
|
|
1757
|
-
}
|
|
1758
|
-
_createClass(CommandRestful, [{
|
|
1759
|
-
key: "getEndpoint",
|
|
1760
|
-
value:
|
|
1761
|
-
/**
|
|
1762
|
-
* Override this method is required to determine endpoint and magic query params.
|
|
1763
|
-
*
|
|
1764
|
-
* @example
|
|
1765
|
-
* ```
|
|
1766
|
-
* args = { query: { id: 1 } };
|
|
1767
|
-
* getEndpoint() = '/api/v1/users/{id}';
|
|
1768
|
-
* result = '/api/v1/users/1';
|
|
1769
|
-
* ```
|
|
1770
|
-
*/
|
|
1771
|
-
function getEndpoint() {
|
|
1772
|
-
throw new ForceMethodImplementation(this, "getEndpoint");
|
|
1773
|
-
}
|
|
1774
|
-
}, {
|
|
1775
|
-
key: "apply",
|
|
1776
|
-
value: function apply() {
|
|
1777
|
-
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
|
|
1778
|
-
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options;
|
|
1779
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1780
|
-
var endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
1781
|
-
return restful.getClient().fetch(endpoint, restful.currentHttpMethod, args || null);
|
|
1782
|
-
}
|
|
1783
|
-
}, {
|
|
1784
|
-
key: "applyEndpointFormat",
|
|
1785
|
-
value: function applyEndpointFormat(endpoint) {
|
|
1786
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1787
|
-
// Replace query with `magic` placeholders.
|
|
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]]) {
|
|
1792
|
-
return data[match[1]];
|
|
1793
|
-
}
|
|
1794
|
-
return endpointPart;
|
|
1795
|
-
}).join("/");
|
|
1796
|
-
}
|
|
1797
|
-
return endpoint;
|
|
1798
|
-
}
|
|
1799
|
-
}], [{
|
|
1800
|
-
key: "getName",
|
|
1801
|
-
value: function getName() {
|
|
1802
|
-
return "ZenFlux/Core/CommandBases/CommandRestful";
|
|
1803
|
-
}
|
|
1804
|
-
}]);
|
|
1805
|
-
return CommandRestful;
|
|
1806
|
-
}(CommandBase);
|
|
1807
|
-
|
|
1808
|
-
var CommandInternal = /*#__PURE__*/function (_CommandBase) {
|
|
1809
|
-
_inherits(CommandInternal, _CommandBase);
|
|
1810
|
-
var _super = _createSuper(CommandInternal);
|
|
1811
|
-
function CommandInternal() {
|
|
1812
|
-
_classCallCheck(this, CommandInternal);
|
|
1813
|
-
return _super.apply(this, arguments);
|
|
1814
|
-
}
|
|
1815
|
-
_createClass(CommandInternal, null, [{
|
|
1816
|
-
key: "getName",
|
|
1817
|
-
value: function getName() {
|
|
1818
|
-
return "ZenFlux/Core/CommandBases/CommandInternal";
|
|
1819
|
-
}
|
|
1820
|
-
}]);
|
|
1821
|
-
return CommandInternal;
|
|
1822
|
-
}(CommandBase);
|
|
1823
|
-
|
|
1824
|
-
/**
|
|
1825
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1826
|
-
*/
|
|
1827
|
-
|
|
1828
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
1829
|
-
__proto__: null,
|
|
1830
|
-
CommandBase: CommandBase,
|
|
1831
|
-
CommandInternal: CommandInternal,
|
|
1832
|
-
CommandPublic: CommandPublic,
|
|
1833
|
-
CommandRestful: CommandRestful
|
|
1834
|
-
});
|
|
1835
|
-
|
|
1836
|
-
var indexPublic = /*#__PURE__*/Object.freeze({
|
|
1837
|
-
__proto__: null,
|
|
1838
|
-
ForceMethodImplementation: ForceMethodImplementation
|
|
1839
|
-
});
|
|
1840
|
-
|
|
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
|
-
};
|
|
1882
|
-
|
|
1883
|
-
var exported = /*#__PURE__*/Object.freeze({
|
|
1884
|
-
__proto__: null,
|
|
1885
|
-
bases: index$1,
|
|
1886
|
-
classes: classes,
|
|
1887
|
-
commandBases: index,
|
|
1888
|
-
errors: indexPublic,
|
|
1889
|
-
interfaces: index$2,
|
|
1890
|
-
managers: _export
|
|
1891
|
-
});
|
|
1892
|
-
|
|
1893
|
-
function errorInitTwice() {
|
|
1894
|
-
if ("undefined" !== typeof __ZEN_CORE__IS_INITIALIZED__ && __ZEN_CORE__IS_INITIALIZED__) {
|
|
1895
|
-
throw new Error("ZenCore is already initialized.");
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
errorInitTwice();
|
|
1899
|
-
var config = {
|
|
1900
|
-
version: version
|
|
1901
|
-
};
|
|
1902
|
-
var CoreAPI = _objectSpread2({
|
|
1903
|
-
initialize: function initialize$1(configuration) {
|
|
1904
|
-
errorInitTwice();
|
|
1905
|
-
config = configuration || config;
|
|
1906
|
-
initialize(config);
|
|
1907
|
-
globalThis.__ZEN_CORE__IS_INITIALIZED__ = true;
|
|
1908
|
-
},
|
|
1909
|
-
destroy: function destroy$1() {
|
|
1910
|
-
destroy();
|
|
1911
|
-
globalThis.__ZEN_CORE__IS_INITIALIZED__ = false;
|
|
1912
|
-
},
|
|
1913
|
-
onAfterInitialize: function onAfterInitialize(callback) {
|
|
1914
|
-
afterInitializeCallbacks.push(callback);
|
|
1915
|
-
},
|
|
1916
|
-
config: config
|
|
1917
|
-
}, exported);
|
|
1918
|
-
if (!(globalThis !== null && globalThis !== void 0 && globalThis.ZenCore)) globalThis.ZenCore = CoreAPI;
|
|
1919
|
-
|
|
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 };
|