lakutata
Version:
An IoC-based universal application framework.
1,479 lines (1,444 loc) • 49.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const e = require("../../../vendor/Package.5.cjs");
var t = {
exports: {}
};
var r = t.exports;
(function(e, t) {
!function(t) {
var r = Object.hasOwnProperty;
var i = Array.isArray ? Array.isArray : function e(t) {
return Object.prototype.toString.call(t) === "[object Array]";
};
var n = 10;
var s = typeof process == "object" && typeof process.nextTick == "function";
var o = typeof Symbol === "function";
var a = typeof Reflect === "object";
var l = typeof setImmediate === "function";
var f = l ? setImmediate : setTimeout;
var c = o ? a && typeof Reflect.ownKeys === "function" ? Reflect.ownKeys : function(e) {
var t = Object.getOwnPropertyNames(e);
t.push.apply(t, Object.getOwnPropertySymbols(e));
return t;
} : Object.keys;
function h() {
this._events = {};
if (this._conf) {
u.call(this, this._conf);
}
}
function u(e) {
if (e) {
this._conf = e;
e.delimiter && (this.delimiter = e.delimiter);
if (e.maxListeners !== t) {
this._maxListeners = e.maxListeners;
}
e.wildcard && (this.wildcard = e.wildcard);
e.newListener && (this._newListener = e.newListener);
e.removeListener && (this._removeListener = e.removeListener);
e.verboseMemoryLeak && (this.verboseMemoryLeak = e.verboseMemoryLeak);
e.ignoreErrors && (this.ignoreErrors = e.ignoreErrors);
if (this.wildcard) {
this.listenerTree = {};
}
}
}
function p(e, t) {
var r = "(node) warning: possible EventEmitter memory " + "leak detected. " + e + " listeners added. " + "Use emitter.setMaxListeners() to increase limit.";
if (this.verboseMemoryLeak) {
r += " Event name: " + t + ".";
}
if (typeof process !== "undefined" && process.emitWarning) {
var i = new Error(r);
i.name = "MaxListenersExceededWarning";
i.emitter = this;
i.count = e;
process.emitWarning(i);
} else {
console.error(r);
if (console.trace) {
console.trace();
}
}
}
var v = function(e, t, r) {
var i = arguments.length;
switch (i) {
case 0:
return [];
case 1:
return [ e ];
case 2:
return [ e, t ];
case 3:
return [ e, t, r ];
default:
var n = new Array(i);
while (i--) {
n[i] = arguments[i];
}
return n;
}
};
function m(e, r) {
var i = {};
var n;
var s = e.length;
var o = r ? r.length : 0;
for (var a = 0; a < s; a++) {
n = e[a];
i[n] = a < o ? r[a] : t;
}
return i;
}
function y(e, t, r) {
this._emitter = e;
this._target = t;
this._listeners = {};
this._listenersCount = 0;
var i, n;
if (r.on || r.off) {
i = r.on;
n = r.off;
}
if (t.addEventListener) {
i = t.addEventListener;
n = t.removeEventListener;
} else if (t.addListener) {
i = t.addListener;
n = t.removeListener;
} else if (t.on) {
i = t.on;
n = t.off;
}
if (!i && !n) {
throw Error("target does not implement any known event API");
}
if (typeof i !== "function") {
throw TypeError("on method must be a function");
}
if (typeof n !== "function") {
throw TypeError("off method must be a function");
}
this._on = i;
this._off = n;
var s = e._observers;
if (s) {
s.push(this);
} else {
e._observers = [ this ];
}
}
Object.assign(y.prototype, {
subscribe: function(e, t, r) {
var i = this;
var n = this._target;
var s = this._emitter;
var o = this._listeners;
var a = function() {
var i = v.apply(null, arguments);
var o = {
data: i,
name: t,
original: e
};
if (r) {
var a = r.call(n, o);
if (a !== false) {
s.emit.apply(s, [ o.name ].concat(i));
}
return;
}
s.emit.apply(s, [ t ].concat(i));
};
if (o[e]) {
throw Error("Event '" + e + "' is already listening");
}
this._listenersCount++;
if (s._newListener && s._removeListener && !i._onNewListener) {
this._onNewListener = function(r) {
if (r === t && o[e] === null) {
o[e] = a;
i._on.call(n, e, a);
}
};
s.on("newListener", this._onNewListener);
this._onRemoveListener = function(r) {
if (r === t && !s.hasListeners(r) && o[e]) {
o[e] = null;
i._off.call(n, e, a);
}
};
o[e] = null;
s.on("removeListener", this._onRemoveListener);
} else {
o[e] = a;
i._on.call(n, e, a);
}
},
unsubscribe: function(e) {
var t = this;
var r = this._listeners;
var i = this._emitter;
var n;
var s;
var o = this._off;
var a = this._target;
var l;
if (e && typeof e !== "string") {
throw TypeError("event must be a string");
}
function f() {
if (t._onNewListener) {
i.off("newListener", t._onNewListener);
i.off("removeListener", t._onRemoveListener);
t._onNewListener = null;
t._onRemoveListener = null;
}
var e = E.call(i, t);
i._observers.splice(e, 1);
}
if (e) {
n = r[e];
if (!n) return;
o.call(a, e, n);
delete r[e];
if (! --this._listenersCount) {
f();
}
} else {
s = c(r);
l = s.length;
while (l-- > 0) {
e = s[l];
o.call(a, e, r[e]);
}
this._listeners = {};
this._listenersCount = 0;
f();
}
}
});
function _(e, i, n, s) {
var o = Object.assign({}, i);
if (!e) return o;
if (typeof e !== "object") {
throw TypeError("options must be an object");
}
var a = Object.keys(e);
var l = a.length;
var f, c;
var h;
function u(e) {
throw Error('Invalid "' + f + '" option value' + (e ? ". Reason: " + e : ""));
}
for (var p = 0; p < l; p++) {
f = a[p];
if (!s && !r.call(i, f)) {
throw Error('Unknown "' + f + '" option');
}
c = e[f];
if (c !== t) {
h = n[f];
o[f] = h ? h(c, u) : c;
}
}
return o;
}
function d(e, t) {
if (typeof e !== "function" || !e.hasOwnProperty("prototype")) {
t("value must be a constructor");
}
return e;
}
function g(e) {
var t = "value must be type of " + e.join("|");
var r = e.length;
var i = e[0];
var n = e[1];
if (r === 1) {
return function(e, r) {
if (typeof e === i) {
return e;
}
r(t);
};
}
if (r === 2) {
return function(e, r) {
var s = typeof e;
if (s === i || s === n) return e;
r(t);
};
}
return function(i, n) {
var s = typeof i;
var o = r;
while (o-- > 0) {
if (s === e[o]) return i;
}
n(t);
};
}
var w = g([ "function" ]);
var b = g([ "object", "function" ]);
function L(e, t, r) {
var i;
var n;
var s = 0;
var o;
var a = new e((function(l, f, c) {
r = _(r, {
timeout: 0,
overload: false
}, {
timeout: function(e, t) {
e *= 1;
if (typeof e !== "number" || e < 0 || !Number.isFinite(e)) {
t("timeout must be a positive number");
}
return e;
}
});
i = !r.overload && typeof e.prototype.cancel === "function" && typeof c === "function";
function h() {
if (n) {
n = null;
}
if (s) {
clearTimeout(s);
s = 0;
}
}
var u = function(e) {
h();
l(e);
};
var p = function(e) {
h();
f(e);
};
if (i) {
t(u, p, c);
} else {
n = [ function(e) {
p(e || Error("canceled"));
} ];
t(u, p, (function(e) {
if (o) {
throw Error("Unable to subscribe on cancel event asynchronously");
}
if (typeof e !== "function") {
throw TypeError("onCancel callback must be a function");
}
n.push(e);
}));
o = true;
}
if (r.timeout > 0) {
s = setTimeout((function() {
var e = Error("timeout");
e.code = "ETIMEDOUT";
s = 0;
a.cancel(e);
f(e);
}), r.timeout);
}
}));
if (!i) {
a.cancel = function(e) {
if (!n) {
return;
}
var t = n.length;
for (var r = 1; r < t; r++) {
n[r](e);
}
n[0](e);
n = null;
};
}
return a;
}
function E(e) {
var t = this._observers;
if (!t) {
return -1;
}
var r = t.length;
for (var i = 0; i < r; i++) {
if (t[i]._target === e) return i;
}
return -1;
}
function M(e, t, r, i, n) {
if (!r) {
return null;
}
if (i === 0) {
var s = typeof t;
if (s === "string") {
var o, a, l = 0, f = 0, h = this.delimiter, u = h.length;
if ((a = t.indexOf(h)) !== -1) {
o = new Array(5);
do {
o[l++] = t.slice(f, a);
f = a + u;
} while ((a = t.indexOf(h, f)) !== -1);
o[l++] = t.slice(f);
t = o;
n = l;
} else {
t = [ t ];
n = 1;
}
} else if (s === "object") {
n = t.length;
} else {
t = [ t ];
n = 1;
}
}
var p = null, v, m, y, _, d, g = t[i], w = t[i + 1], b, L;
if (i === n) {
if (r._listeners) {
if (typeof r._listeners === "function") {
e && e.push(r._listeners);
p = [ r ];
} else {
e && e.push.apply(e, r._listeners);
p = [ r ];
}
}
} else {
if (g === "*") {
b = c(r);
a = b.length;
while (a-- > 0) {
v = b[a];
if (v !== "_listeners") {
L = M(e, t, r[v], i + 1, n);
if (L) {
if (p) {
p.push.apply(p, L);
} else {
p = L;
}
}
}
}
return p;
} else if (g === "**") {
d = i + 1 === n || i + 2 === n && w === "*";
if (d && r._listeners) {
p = M(e, t, r, n, n);
}
b = c(r);
a = b.length;
while (a-- > 0) {
v = b[a];
if (v !== "_listeners") {
if (v === "*" || v === "**") {
if (r[v]._listeners && !d) {
L = M(e, t, r[v], n, n);
if (L) {
if (p) {
p.push.apply(p, L);
} else {
p = L;
}
}
}
L = M(e, t, r[v], i, n);
} else if (v === w) {
L = M(e, t, r[v], i + 2, n);
} else {
L = M(e, t, r[v], i, n);
}
if (L) {
if (p) {
p.push.apply(p, L);
} else {
p = L;
}
}
}
}
return p;
} else if (r[g]) {
p = M(e, t, r[g], i + 1, n);
}
}
m = r["*"];
if (m) {
M(e, t, m, i + 1, n);
}
y = r["**"];
if (y) {
if (i < n) {
if (y._listeners) {
M(e, t, y, n, n);
}
b = c(y);
a = b.length;
while (a-- > 0) {
v = b[a];
if (v !== "_listeners") {
if (v === w) {
M(e, t, y[v], i + 2, n);
} else if (v === g) {
M(e, t, y[v], i + 1, n);
} else {
_ = {};
_[v] = y[v];
M(e, t, {
"**": _
}, i + 1, n);
}
}
}
} else if (y._listeners) {
M(e, t, y, n, n);
} else if (y["*"] && y["*"]._listeners) {
M(e, t, y["*"], n, n);
}
}
return p;
}
function x(e, t, r) {
var i = 0, n = 0, s, o = this.delimiter, a = o.length, l;
if (typeof e === "string") {
if ((s = e.indexOf(o)) !== -1) {
l = new Array(5);
do {
l[i++] = e.slice(n, s);
n = s + a;
} while ((s = e.indexOf(o, n)) !== -1);
l[i++] = e.slice(n);
} else {
l = [ e ];
i = 1;
}
} else {
l = e;
i = e.length;
}
if (i > 1) {
for (s = 0; s + 1 < i; s++) {
if (l[s] === "**" && l[s + 1] === "**") {
return;
}
}
}
var f = this.listenerTree, c;
for (s = 0; s < i; s++) {
c = l[s];
f = f[c] || (f[c] = {});
if (s === i - 1) {
if (!f._listeners) {
f._listeners = t;
} else {
if (typeof f._listeners === "function") {
f._listeners = [ f._listeners ];
}
if (r) {
f._listeners.unshift(t);
} else {
f._listeners.push(t);
}
if (!f._listeners.warned && this._maxListeners > 0 && f._listeners.length > this._maxListeners) {
f._listeners.warned = true;
p.call(this, f._listeners.length, c);
}
}
return true;
}
}
return true;
}
function j(e, t, r, i) {
var n = c(e);
var s = n.length;
var o, a, l;
var f = e["_listeners"];
var h;
while (s-- > 0) {
a = n[s];
o = e[a];
if (a === "_listeners") {
l = r;
} else {
l = r ? r.concat(a) : [ a ];
}
h = i || typeof a === "symbol";
f && t.push(h ? l : l.join(this.delimiter));
if (typeof o === "object") {
j.call(this, o, t, l, h);
}
}
return t;
}
function k(e) {
var t = c(e);
var r = t.length;
var i, n, s;
while (r-- > 0) {
n = t[r];
i = e[n];
if (i) {
s = true;
if (n !== "_listeners" && !k(i)) {
delete e[n];
}
}
}
return s;
}
function A(e, t, r) {
this.emitter = e;
this.event = t;
this.listener = r;
}
A.prototype.off = function() {
this.emitter.off(this.event, this.listener);
return this;
};
function T(e, r, i) {
if (i === true) {
o = true;
} else if (i === false) {
n = true;
} else {
if (!i || typeof i !== "object") {
throw TypeError("options should be an object or true");
}
var n = i.async;
var o = i.promisify;
var a = i.nextTick;
var l = i.objectify;
}
if (n || a || o) {
var c = r;
var h = r._origin || r;
if (a && !s) {
throw Error("process.nextTick is not supported");
}
if (o === t) {
o = r.constructor.name === "AsyncFunction";
}
r = function() {
var e = arguments;
var t = this;
var r = this.event;
return o ? a ? Promise.resolve() : new Promise((function(e) {
f(e);
})).then((function() {
t.event = r;
return c.apply(t, e);
})) : (a ? process.nextTick : f)((function() {
t.event = r;
c.apply(t, e);
}));
};
r._async = true;
r._origin = h;
}
return [ r, l ? new A(this, e, r) : this ];
}
function R(e) {
this._events = {};
this._newListener = false;
this._removeListener = false;
this.verboseMemoryLeak = false;
u.call(this, e);
}
R.EventEmitter2 = R;
R.prototype.listenTo = function(e, r, n) {
if (typeof e !== "object") {
throw TypeError("target musts be an object");
}
var s = this;
n = _(n, {
on: t,
off: t,
reducers: t
}, {
on: w,
off: w,
reducers: b
});
function o(t) {
if (typeof t !== "object") {
throw TypeError("events must be an object");
}
var r = n.reducers;
var i = E.call(s, e);
var o;
if (i === -1) {
o = new y(s, e, n);
} else {
o = s._observers[i];
}
var a = c(t);
var l = a.length;
var f;
var h = typeof r === "function";
for (var u = 0; u < l; u++) {
f = a[u];
o.subscribe(f, t[f] || f, h ? r : r && r[f]);
}
}
i(r) ? o(m(r)) : typeof r === "string" ? o(m(r.split(/\s+/))) : o(r);
return this;
};
R.prototype.stopListeningTo = function(e, t) {
var r = this._observers;
if (!r) {
return false;
}
var i = r.length;
var n;
var s = false;
if (e && typeof e !== "object") {
throw TypeError("target should be an object");
}
while (i-- > 0) {
n = r[i];
if (!e || n._target === e) {
n.unsubscribe(t);
s = true;
}
}
return s;
};
R.prototype.delimiter = ".";
R.prototype.setMaxListeners = function(e) {
if (e !== t) {
this._maxListeners = e;
if (!this._conf) this._conf = {};
this._conf.maxListeners = e;
}
};
R.prototype.getMaxListeners = function() {
return this._maxListeners;
};
R.prototype.event = "";
R.prototype.once = function(e, t, r) {
return this._once(e, t, false, r);
};
R.prototype.prependOnceListener = function(e, t, r) {
return this._once(e, t, true, r);
};
R.prototype._once = function(e, t, r, i) {
return this._many(e, 1, t, r, i);
};
R.prototype.many = function(e, t, r, i) {
return this._many(e, t, r, false, i);
};
R.prototype.prependMany = function(e, t, r, i) {
return this._many(e, t, r, true, i);
};
R.prototype._many = function(e, t, r, i, n) {
var s = this;
if (typeof r !== "function") {
throw new Error("many only accepts instances of Function");
}
function o() {
if (--t === 0) {
s.off(e, o);
}
return r.apply(this, arguments);
}
o._origin = r;
return this._on(e, o, i, n);
};
R.prototype.emit = function() {
if (!this._events && !this._all) {
return false;
}
this._events || h.call(this);
var e = arguments[0], t, r = this.wildcard;
var i, n, s, a, l;
if (e === "newListener" && !this._newListener) {
if (!this._events.newListener) {
return false;
}
}
if (r) {
t = e;
if (e !== "newListener" && e !== "removeListener") {
if (typeof e === "object") {
n = e.length;
if (o) {
for (s = 0; s < n; s++) {
if (typeof e[s] === "symbol") {
l = true;
break;
}
}
}
if (!l) {
e = e.join(this.delimiter);
}
}
}
}
var f = arguments.length;
var c;
if (this._all && this._all.length) {
c = this._all.slice();
for (s = 0, n = c.length; s < n; s++) {
this.event = e;
switch (f) {
case 1:
c[s].call(this, e);
break;
case 2:
c[s].call(this, e, arguments[1]);
break;
case 3:
c[s].call(this, e, arguments[1], arguments[2]);
break;
default:
c[s].apply(this, arguments);
}
}
}
if (r) {
c = [];
M.call(this, c, t, this.listenerTree, 0, n);
} else {
c = this._events[e];
if (typeof c === "function") {
this.event = e;
switch (f) {
case 1:
c.call(this);
break;
case 2:
c.call(this, arguments[1]);
break;
case 3:
c.call(this, arguments[1], arguments[2]);
break;
default:
i = new Array(f - 1);
for (a = 1; a < f; a++) i[a - 1] = arguments[a];
c.apply(this, i);
}
return true;
} else if (c) {
c = c.slice();
}
}
if (c && c.length) {
if (f > 3) {
i = new Array(f - 1);
for (a = 1; a < f; a++) i[a - 1] = arguments[a];
}
for (s = 0, n = c.length; s < n; s++) {
this.event = e;
switch (f) {
case 1:
c[s].call(this);
break;
case 2:
c[s].call(this, arguments[1]);
break;
case 3:
c[s].call(this, arguments[1], arguments[2]);
break;
default:
c[s].apply(this, i);
}
}
return true;
} else if (!this.ignoreErrors && !this._all && e === "error") {
if (arguments[1] instanceof Error) {
throw arguments[1];
} else {
throw new Error("Uncaught, unspecified 'error' event.");
}
}
return !!this._all;
};
R.prototype.emitAsync = function() {
if (!this._events && !this._all) {
return false;
}
this._events || h.call(this);
var e = arguments[0], t = this.wildcard, r, i;
var n, s, a, l;
if (e === "newListener" && !this._newListener) {
if (!this._events.newListener) {
return Promise.resolve([ false ]);
}
}
if (t) {
r = e;
if (e !== "newListener" && e !== "removeListener") {
if (typeof e === "object") {
s = e.length;
if (o) {
for (a = 0; a < s; a++) {
if (typeof e[a] === "symbol") {
i = true;
break;
}
}
}
if (!i) {
e = e.join(this.delimiter);
}
}
}
}
var f = [];
var c = arguments.length;
var u;
if (this._all) {
for (a = 0, s = this._all.length; a < s; a++) {
this.event = e;
switch (c) {
case 1:
f.push(this._all[a].call(this, e));
break;
case 2:
f.push(this._all[a].call(this, e, arguments[1]));
break;
case 3:
f.push(this._all[a].call(this, e, arguments[1], arguments[2]));
break;
default:
f.push(this._all[a].apply(this, arguments));
}
}
}
if (t) {
u = [];
M.call(this, u, r, this.listenerTree, 0);
} else {
u = this._events[e];
}
if (typeof u === "function") {
this.event = e;
switch (c) {
case 1:
f.push(u.call(this));
break;
case 2:
f.push(u.call(this, arguments[1]));
break;
case 3:
f.push(u.call(this, arguments[1], arguments[2]));
break;
default:
n = new Array(c - 1);
for (l = 1; l < c; l++) n[l - 1] = arguments[l];
f.push(u.apply(this, n));
}
} else if (u && u.length) {
u = u.slice();
if (c > 3) {
n = new Array(c - 1);
for (l = 1; l < c; l++) n[l - 1] = arguments[l];
}
for (a = 0, s = u.length; a < s; a++) {
this.event = e;
switch (c) {
case 1:
f.push(u[a].call(this));
break;
case 2:
f.push(u[a].call(this, arguments[1]));
break;
case 3:
f.push(u[a].call(this, arguments[1], arguments[2]));
break;
default:
f.push(u[a].apply(this, n));
}
}
} else if (!this.ignoreErrors && !this._all && e === "error") {
if (arguments[1] instanceof Error) {
return Promise.reject(arguments[1]);
} else {
return Promise.reject("Uncaught, unspecified 'error' event.");
}
}
return Promise.all(f);
};
R.prototype.on = function(e, t, r) {
return this._on(e, t, false, r);
};
R.prototype.prependListener = function(e, t, r) {
return this._on(e, t, true, r);
};
R.prototype.onAny = function(e) {
return this._onAny(e, false);
};
R.prototype.prependAny = function(e) {
return this._onAny(e, true);
};
R.prototype.addListener = R.prototype.on;
R.prototype._onAny = function(e, t) {
if (typeof e !== "function") {
throw new Error("onAny only accepts instances of Function");
}
if (!this._all) {
this._all = [];
}
if (t) {
this._all.unshift(e);
} else {
this._all.push(e);
}
return this;
};
R.prototype._on = function(e, r, i, n) {
if (typeof e === "function") {
this._onAny(e, r);
return this;
}
if (typeof r !== "function") {
throw new Error("on only accepts instances of Function");
}
this._events || h.call(this);
var s = this, o;
if (n !== t) {
o = T.call(this, e, r, n);
r = o[0];
s = o[1];
}
if (this._newListener) {
this.emit("newListener", e, r);
}
if (this.wildcard) {
x.call(this, e, r, i);
return s;
}
if (!this._events[e]) {
this._events[e] = r;
} else {
if (typeof this._events[e] === "function") {
this._events[e] = [ this._events[e] ];
}
if (i) {
this._events[e].unshift(r);
} else {
this._events[e].push(r);
}
if (!this._events[e].warned && this._maxListeners > 0 && this._events[e].length > this._maxListeners) {
this._events[e].warned = true;
p.call(this, this._events[e].length, e);
}
}
return s;
};
R.prototype.off = function(e, t) {
if (typeof t !== "function") {
throw new Error("removeListener only takes instances of Function");
}
var r, n = [];
if (this.wildcard) {
var s = typeof e === "string" ? e.split(this.delimiter) : e.slice();
n = M.call(this, null, s, this.listenerTree, 0);
if (!n) return this;
} else {
if (!this._events[e]) return this;
r = this._events[e];
n.push({
_listeners: r
});
}
for (var o = 0; o < n.length; o++) {
var a = n[o];
r = a._listeners;
if (i(r)) {
var l = -1;
for (var f = 0, c = r.length; f < c; f++) {
if (r[f] === t || r[f].listener && r[f].listener === t || r[f]._origin && r[f]._origin === t) {
l = f;
break;
}
}
if (l < 0) {
continue;
}
if (this.wildcard) {
a._listeners.splice(l, 1);
} else {
this._events[e].splice(l, 1);
}
if (r.length === 0) {
if (this.wildcard) {
delete a._listeners;
} else {
delete this._events[e];
}
}
if (this._removeListener) this.emit("removeListener", e, t);
return this;
} else if (r === t || r.listener && r.listener === t || r._origin && r._origin === t) {
if (this.wildcard) {
delete a._listeners;
} else {
delete this._events[e];
}
if (this._removeListener) this.emit("removeListener", e, t);
}
}
this.listenerTree && k(this.listenerTree);
return this;
};
R.prototype.offAny = function(e) {
var t = 0, r = 0, i;
if (e && this._all && this._all.length > 0) {
i = this._all;
for (t = 0, r = i.length; t < r; t++) {
if (e === i[t]) {
i.splice(t, 1);
if (this._removeListener) this.emit("removeListenerAny", e);
return this;
}
}
} else {
i = this._all;
if (this._removeListener) {
for (t = 0, r = i.length; t < r; t++) this.emit("removeListenerAny", i[t]);
}
this._all = [];
}
return this;
};
R.prototype.removeListener = R.prototype.off;
R.prototype.removeAllListeners = function(e) {
if (e === t) {
!this._events || h.call(this);
return this;
}
if (this.wildcard) {
var r = M.call(this, null, e, this.listenerTree, 0), i, n;
if (!r) return this;
for (n = 0; n < r.length; n++) {
i = r[n];
i._listeners = null;
}
this.listenerTree && k(this.listenerTree);
} else if (this._events) {
this._events[e] = null;
}
return this;
};
R.prototype.listeners = function(e) {
var r = this._events;
var i, n, s;
var o;
var a;
if (e === t) {
if (this.wildcard) {
throw Error("event name required for wildcard emitter");
}
if (!r) {
return [];
}
i = c(r);
o = i.length;
s = [];
while (o-- > 0) {
n = r[i[o]];
if (typeof n === "function") {
s.push(n);
} else {
s.push.apply(s, n);
}
}
return s;
} else {
if (this.wildcard) {
a = this.listenerTree;
if (!a) return [];
var l = [];
var f = typeof e === "string" ? e.split(this.delimiter) : e.slice();
M.call(this, l, f, a, 0);
return l;
}
if (!r) {
return [];
}
n = r[e];
if (!n) {
return [];
}
return typeof n === "function" ? [ n ] : n;
}
};
R.prototype.eventNames = function(e) {
var t = this._events;
return this.wildcard ? j.call(this, this.listenerTree, [], null, e) : t ? c(t) : [];
};
R.prototype.listenerCount = function(e) {
return this.listeners(e).length;
};
R.prototype.hasListeners = function(e) {
if (this.wildcard) {
var r = [];
var i = typeof e === "string" ? e.split(this.delimiter) : e.slice();
M.call(this, r, i, this.listenerTree, 0);
return r.length > 0;
}
var n = this._events;
var s = this._all;
return !!(s && s.length || n && (e === t ? c(n).length : n[e]));
};
R.prototype.listenersAny = function() {
if (this._all) {
return this._all;
} else {
return [];
}
};
R.prototype.waitFor = function(e, r) {
var i = this;
var n = typeof r;
if (n === "number") {
r = {
timeout: r
};
} else if (n === "function") {
r = {
filter: r
};
}
r = _(r, {
timeout: 0,
filter: t,
handleError: false,
Promise: Promise,
overload: false
}, {
filter: w,
Promise: d
});
return L(r.Promise, (function(t, n, s) {
function o() {
var s = r.filter;
if (s && !s.apply(i, arguments)) {
return;
}
i.off(e, o);
if (r.handleError) {
var a = arguments[0];
a ? n(a) : t(v.apply(null, arguments).slice(1));
} else {
t(v.apply(null, arguments));
}
}
s((function() {
i.off(e, o);
}));
i._on(e, o, false);
}), {
timeout: r.timeout,
overload: r.overload
});
};
function O(e, t, r) {
r = _(r, {
Promise: Promise,
timeout: 0,
overload: false
}, {
Promise: d
});
var i = r.Promise;
return L(i, (function(r, i, n) {
var s;
if (typeof e.addEventListener === "function") {
s = function() {
r(v.apply(null, arguments));
};
n((function() {
e.removeEventListener(t, s);
}));
e.addEventListener(t, s, {
once: true
});
return;
}
var o = function() {
a && e.removeListener("error", a);
r(v.apply(null, arguments));
};
var a;
if (t !== "error") {
a = function(r) {
e.removeListener(t, o);
i(r);
};
e.once("error", a);
}
n((function() {
a && e.removeListener("error", a);
e.removeListener(t, o);
}));
e.once(t, o);
}), {
timeout: r.timeout,
overload: r.overload
});
}
var P = R.prototype;
Object.defineProperties(R, {
defaultMaxListeners: {
get: function() {
return P._maxListeners;
},
set: function(e) {
if (typeof e !== "number" || e < 0 || Number.isNaN(e)) {
throw TypeError("n must be a non-negative number");
}
P._maxListeners = e;
},
enumerable: true
},
once: {
value: O,
writable: true,
configurable: true
}
});
Object.defineProperties(P, {
_maxListeners: {
value: n,
writable: true,
configurable: true
},
_observers: {
value: null,
writable: true,
configurable: true
}
});
if (typeof t === "function" && t.amd) {
t((function() {
return R;
}));
} else if ("object" === "object") {
e.exports = R;
} else {
var N = new Function("", "return this")();
N.EventEmitter2 = R;
}
}();
})(t, t.exports);
var i = t.exports;
const n = e.getDefaultExportFromCjs(i);
const s = {
async: true,
nextTick: false,
promisify: true,
objectify: false
};
const o = {
wildcard: true,
delimiter: ".",
newListener: false,
removeListener: false,
maxListeners: 11,
verboseMemoryLeak: true,
ignoreErrors: false
};
class EventEmitter {
constructor(e = {}) {
Reflect.defineMetadata(this.constructor.name, new i.EventEmitter2({
...o,
...e
}), this);
}
emit(e, ...t) {
return Reflect.getMetadata(this.constructor.name, this).emit(e, ...t);
}
async emitRequest(e, ...t) {
return Reflect.getMetadata(this.constructor.name, this).emitAsync(e, ...t);
}
addListener(e, t) {
Reflect.getMetadata(this.constructor.name, this).addListener(e, t);
return this;
}
on(e, t) {
Reflect.getMetadata(this.constructor.name, this).on(e, t, s);
return this;
}
prependListener(e, t) {
Reflect.getMetadata(this.constructor.name, this).prependListener(e, t, s);
return this;
}
once(e, t) {
Reflect.getMetadata(this.constructor.name, this).once(e, t, s);
return this;
}
prependOnceListener(e, t) {
Reflect.getMetadata(this.constructor.name, this).prependOnceListener(e, t, s);
return this;
}
many(e, t, r) {
Reflect.getMetadata(this.constructor.name, this).many(e, t, r, s);
return this;
}
prependMany(e, t, r) {
Reflect.getMetadata(this.constructor.name, this).prependMany(e, t, r, s);
return this;
}
onAny(e) {
Reflect.getMetadata(this.constructor.name, this).onAny(e);
return this;
}
prependAny(e) {
Reflect.getMetadata(this.constructor.name, this).prependAny(e);
return this;
}
offAny(e) {
Reflect.getMetadata(this.constructor.name, this).offAny(e);
return this;
}
removeListener(e, t) {
Reflect.getMetadata(this.constructor.name, this).removeListener(e, t);
return this;
}
off(e, t) {
Reflect.getMetadata(this.constructor.name, this).off(e, t);
return this;
}
removeAllListeners(e) {
Reflect.getMetadata(this.constructor.name, this).removeAllListeners(e);
return this;
}
setMaxListeners(e) {
return Reflect.getMetadata(this.constructor.name, this).setMaxListeners(e);
}
getMaxListeners() {
return Reflect.getMetadata(this.constructor.name, this).getMaxListeners();
}
eventNames(e) {
return Reflect.getMetadata(this.constructor.name, this).eventNames(e);
}
listenerCount(e) {
return Reflect.getMetadata(this.constructor.name, this).listenerCount(e);
}
listeners(e) {
return Reflect.getMetadata(this.constructor.name, this).listeners(e);
}
listenersAny() {
return Reflect.getMetadata(this.constructor.name, this).listenersAny();
}
hasListeners(e) {
return Reflect.getMetadata(this.constructor.name, this).hasListeners(e).valueOf();
}
}
exports.DefaultEventEmitterOptions = o;
exports.EventEmitter = EventEmitter;