@zenflux/core 0.0.0-alpha.5 → 0.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/zenflux-core.js +43 -5
- package/dist/es/zenflux-core.js +43 -5
- package/dist/es/zenflux-core.mjs +1 -1
- package/dist/umd/zenflux-core.js +2227 -1
- package/package.json +2 -2
- package/src/modules/logger.ts +53 -7
- package/dist/es/rollup.config.d.ts +0 -23
- package/dist/es/src/clients/http.d.ts +0 -20
- package/dist/es/src/command-bases/command-base.d.ts +0 -22
- package/dist/es/src/command-bases/command-data.d.ts +0 -17
- package/dist/es/src/command-bases/command-internal.d.ts +0 -9
- package/dist/es/src/command-bases/command-public.d.ts +0 -9
- package/dist/es/src/command-bases/index.d.ts +0 -7
- package/dist/es/src/core/controller.d.ts +0 -35
- package/dist/es/src/core/index.d.ts +0 -2
- package/dist/es/src/core/object-base.d.ts +0 -14
- package/dist/es/src/enums/http.d.ts +0 -12
- package/dist/es/src/errors/command-already-registered.d.ts +0 -8
- package/dist/es/src/errors/command-not-found.d.ts +0 -7
- package/dist/es/src/errors/controller-already-registered.d.ts +0 -8
- package/dist/es/src/errors/force-method.d.ts +0 -11
- package/dist/es/src/errors/index.d.ts +0 -4
- package/dist/es/src/exports.d.ts +0 -10
- package/dist/es/src/globals.d.ts +0 -3
- package/dist/es/src/index.d.ts +0 -5
- package/dist/es/src/initializer.d.ts +0 -19
- package/dist/es/src/interfaces/commands.d.ts +0 -13
- package/dist/es/src/interfaces/config.d.ts +0 -10
- package/dist/es/src/interfaces/managers.d.ts +0 -13
- package/dist/es/src/interfaces/object-base.d.ts +0 -10
- package/dist/es/src/manager-bases/commands.d.ts +0 -75
- package/dist/es/src/manager-bases/controllers.d.ts +0 -18
- package/dist/es/src/manager-bases/data.d.ts +0 -23
- package/dist/es/src/manager-bases/index.d.ts +0 -7
- package/dist/es/src/manager-bases/internal.d.ts +0 -9
- package/dist/es/src/managers/index.d.ts +0 -15
- package/dist/es/src/modules/index.d.ts +0 -1
- package/dist/es/src/modules/logger.d.ts +0 -117
- package/dist/es/src/utils/index.d.ts +0 -2
- package/dist/es/src/utils/object.d.ts +0 -6
- package/dist/es/src/utils/rgb.d.ts +0 -6
package/dist/cjs/zenflux-core.js
CHANGED
|
@@ -106,7 +106,7 @@ var devDependencies = {
|
|
|
106
106
|
"@types/jest": "^29.2.5",
|
|
107
107
|
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
108
108
|
"@typescript-eslint/parser": "^5.48.0",
|
|
109
|
-
"@zenflux/rollup-toolkit": "^0.0.0-alpha.
|
|
109
|
+
"@zenflux/rollup-toolkit": "^0.0.0-alpha.4",
|
|
110
110
|
"babel-jest": "^29.3.1",
|
|
111
111
|
"ts-jest": "^29.0.3",
|
|
112
112
|
tslib: "^2.4.1"
|
|
@@ -674,7 +674,13 @@ hexColorDelta: hexColorDelta
|
|
|
674
674
|
});
|
|
675
675
|
|
|
676
676
|
// TODO: Should by dynamic/configure-able.
|
|
677
|
-
var MAX_WRAPPING_RECURSIVE_DEPTH = 4
|
|
677
|
+
var MAX_WRAPPING_RECURSIVE_DEPTH = 4,
|
|
678
|
+
STACK_BACKWARD_CALLER_INDEX = 3,
|
|
679
|
+
UNKNOWN_CALLER_NAME = 'anonymous function',
|
|
680
|
+
BABEL_EXCLUDE_FUNCTIONS_NAMES = ['_callee', 'tryCatch', '<anonymous>', 'Generator.next', 'asyncGeneratorStep', '_next'];
|
|
681
|
+
|
|
682
|
+
// TODO: Should by dynamic/configure-able.
|
|
683
|
+
Error.stackTraceLimit = 50;
|
|
678
684
|
var Logger = /*#__PURE__*/function () {
|
|
679
685
|
/**
|
|
680
686
|
* Function constructor() : Create logger class.
|
|
@@ -1026,12 +1032,44 @@ var Logger = /*#__PURE__*/function () {
|
|
|
1026
1032
|
}, {
|
|
1027
1033
|
key: "getCallerName",
|
|
1028
1034
|
value: function getCallerName() {
|
|
1035
|
+
var _error$stack;
|
|
1029
1036
|
var error = new Error(),
|
|
1030
|
-
|
|
1037
|
+
errorsPerLine = ((_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : _error$stack.split("\n")) || [],
|
|
1038
|
+
caller = errorsPerLine.length ? errorsPerLine[STACK_BACKWARD_CALLER_INDEX].trim() : UNKNOWN_CALLER_NAME;
|
|
1031
1039
|
if (caller.startsWith("at new")) {
|
|
1032
1040
|
return "constructor";
|
|
1033
1041
|
}
|
|
1034
|
-
|
|
1042
|
+
var extractName = caller.split(".")[1].split(" ")[0],
|
|
1043
|
+
isBabelAsyncRuntime = false;
|
|
1044
|
+
|
|
1045
|
+
// Babel compatibility.
|
|
1046
|
+
if (extractName.includes('_callee')) {
|
|
1047
|
+
var _loop = function _loop() {
|
|
1048
|
+
var line = errorsPerLine[i];
|
|
1049
|
+
var isExcluded = BABEL_EXCLUDE_FUNCTIONS_NAMES.some(function (excludeName) {
|
|
1050
|
+
return line.includes(excludeName);
|
|
1051
|
+
});
|
|
1052
|
+
if (!isExcluded) {
|
|
1053
|
+
var format = line.trim().split(' ');
|
|
1054
|
+
if (format.length <= 2) {
|
|
1055
|
+
return "continue";
|
|
1056
|
+
}
|
|
1057
|
+
extractName = format[1].split(".")[1];
|
|
1058
|
+
isBabelAsyncRuntime = true;
|
|
1059
|
+
return "break";
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
// Run till find reliable function name.
|
|
1063
|
+
for (var i = STACK_BACKWARD_CALLER_INDEX; i < errorsPerLine.length; i++) {
|
|
1064
|
+
var _ret = _loop();
|
|
1065
|
+
if (_ret === "continue") continue;
|
|
1066
|
+
if (_ret === "break") break;
|
|
1067
|
+
}
|
|
1068
|
+
if (!isBabelAsyncRuntime) {
|
|
1069
|
+
extractName = UNKNOWN_CALLER_NAME;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return extractName;
|
|
1035
1073
|
}
|
|
1036
1074
|
|
|
1037
1075
|
/**
|
|
@@ -1040,7 +1078,7 @@ var Logger = /*#__PURE__*/function () {
|
|
|
1040
1078
|
}, {
|
|
1041
1079
|
key: "getFunctionView",
|
|
1042
1080
|
value: function getFunctionView(fn) {
|
|
1043
|
-
var fReturn =
|
|
1081
|
+
var fReturn = UNKNOWN_CALLER_NAME;
|
|
1044
1082
|
|
|
1045
1083
|
// TODO: Check if works.
|
|
1046
1084
|
if (typeof fn !== "string" && fn.name.length !== 0) {
|
package/dist/es/zenflux-core.js
CHANGED
|
@@ -102,7 +102,7 @@ var devDependencies = {
|
|
|
102
102
|
"@types/jest": "^29.2.5",
|
|
103
103
|
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
104
104
|
"@typescript-eslint/parser": "^5.48.0",
|
|
105
|
-
"@zenflux/rollup-toolkit": "^0.0.0-alpha.
|
|
105
|
+
"@zenflux/rollup-toolkit": "^0.0.0-alpha.4",
|
|
106
106
|
"babel-jest": "^29.3.1",
|
|
107
107
|
"ts-jest": "^29.0.3",
|
|
108
108
|
tslib: "^2.4.1"
|
|
@@ -670,7 +670,13 @@ hexColorDelta: hexColorDelta
|
|
|
670
670
|
});
|
|
671
671
|
|
|
672
672
|
// TODO: Should by dynamic/configure-able.
|
|
673
|
-
var MAX_WRAPPING_RECURSIVE_DEPTH = 4
|
|
673
|
+
var MAX_WRAPPING_RECURSIVE_DEPTH = 4,
|
|
674
|
+
STACK_BACKWARD_CALLER_INDEX = 3,
|
|
675
|
+
UNKNOWN_CALLER_NAME = 'anonymous function',
|
|
676
|
+
BABEL_EXCLUDE_FUNCTIONS_NAMES = ['_callee', 'tryCatch', '<anonymous>', 'Generator.next', 'asyncGeneratorStep', '_next'];
|
|
677
|
+
|
|
678
|
+
// TODO: Should by dynamic/configure-able.
|
|
679
|
+
Error.stackTraceLimit = 50;
|
|
674
680
|
var Logger = /*#__PURE__*/function () {
|
|
675
681
|
/**
|
|
676
682
|
* Function constructor() : Create logger class.
|
|
@@ -1022,12 +1028,44 @@ var Logger = /*#__PURE__*/function () {
|
|
|
1022
1028
|
}, {
|
|
1023
1029
|
key: "getCallerName",
|
|
1024
1030
|
value: function getCallerName() {
|
|
1031
|
+
var _error$stack;
|
|
1025
1032
|
var error = new Error(),
|
|
1026
|
-
|
|
1033
|
+
errorsPerLine = ((_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : _error$stack.split("\n")) || [],
|
|
1034
|
+
caller = errorsPerLine.length ? errorsPerLine[STACK_BACKWARD_CALLER_INDEX].trim() : UNKNOWN_CALLER_NAME;
|
|
1027
1035
|
if (caller.startsWith("at new")) {
|
|
1028
1036
|
return "constructor";
|
|
1029
1037
|
}
|
|
1030
|
-
|
|
1038
|
+
var extractName = caller.split(".")[1].split(" ")[0],
|
|
1039
|
+
isBabelAsyncRuntime = false;
|
|
1040
|
+
|
|
1041
|
+
// Babel compatibility.
|
|
1042
|
+
if (extractName.includes('_callee')) {
|
|
1043
|
+
var _loop = function _loop() {
|
|
1044
|
+
var line = errorsPerLine[i];
|
|
1045
|
+
var isExcluded = BABEL_EXCLUDE_FUNCTIONS_NAMES.some(function (excludeName) {
|
|
1046
|
+
return line.includes(excludeName);
|
|
1047
|
+
});
|
|
1048
|
+
if (!isExcluded) {
|
|
1049
|
+
var format = line.trim().split(' ');
|
|
1050
|
+
if (format.length <= 2) {
|
|
1051
|
+
return "continue";
|
|
1052
|
+
}
|
|
1053
|
+
extractName = format[1].split(".")[1];
|
|
1054
|
+
isBabelAsyncRuntime = true;
|
|
1055
|
+
return "break";
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
// Run till find reliable function name.
|
|
1059
|
+
for (var i = STACK_BACKWARD_CALLER_INDEX; i < errorsPerLine.length; i++) {
|
|
1060
|
+
var _ret = _loop();
|
|
1061
|
+
if (_ret === "continue") continue;
|
|
1062
|
+
if (_ret === "break") break;
|
|
1063
|
+
}
|
|
1064
|
+
if (!isBabelAsyncRuntime) {
|
|
1065
|
+
extractName = UNKNOWN_CALLER_NAME;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return extractName;
|
|
1031
1069
|
}
|
|
1032
1070
|
|
|
1033
1071
|
/**
|
|
@@ -1036,7 +1074,7 @@ var Logger = /*#__PURE__*/function () {
|
|
|
1036
1074
|
}, {
|
|
1037
1075
|
key: "getFunctionView",
|
|
1038
1076
|
value: function getFunctionView(fn) {
|
|
1039
|
-
var fReturn =
|
|
1077
|
+
var fReturn = UNKNOWN_CALLER_NAME;
|
|
1040
1078
|
|
|
1041
1079
|
// TODO: Check if works.
|
|
1042
1080
|
if (typeof fn !== "string" && fn.name.length !== 0) {
|
package/dist/es/zenflux-core.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function e(e){for(var r=1;arguments.length>r;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new N(n||[]);return o(i,"_invoke",{value:O(t,r,a)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function p(){}function v(){}function y(){}var g={};s(g,a,(function(){return this}));var d=Object.getPrototypeOf,m=d&&d(d(_([])));m&&m!==e&&n.call(m,a)&&(g=m);var b=y.prototype=p.prototype=Object.create(g);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return x()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=j(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function j(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return v.prototype=y,o(b,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=s(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,u,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},k(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(b),s(b,u,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=_,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function c(t){o(a,n,i,c,u,"next",t)}function u(t){o(a,n,i,c,u,"throw",t)}c(void 0)}))}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function u(t,e,r){return e&&c(t.prototype,e),r&&c(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=j(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function v(t,e,r){return v=p()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&h(o,r.prototype),o},v.apply(null,arguments)}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return v(t,arguments,f(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},y(t)}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return g(t)}function m(t){var e=p();return function(){var r,n=f(t);if(e){var o=f(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return d(this,r)}}function b(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=f(t)););return t}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=b(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(3>arguments.length?t:r):o.value}},k.apply(this,arguments)}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return O(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return O(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);e>r;r++)n[r]=t[r];return n}function j(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var C="0.0.0-alpha.5",E=function(){var t=new WeakSet;return function(e,r){if("object"===n(r)&&null!==r){if(t.has(r))return;t.add(r)}return r}},N=function(t,e){t=t.replace("#",""),e=e.replace("#","");var r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),i=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),c=parseInt(e.substring(4,6),16),u=255-Math.abs(r-i),s=255-Math.abs(n-a),l=255-Math.abs(o-c);return((u/=255)+(s/=255)+(l/=255))/3},_=Object.freeze({__proto__:null,getCircularReplacer:E,hexColorDelta:N}),x=function(){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a(this,t),s(this,"args",{}),s(this,"state",!1),"off"!==(null===(r=globalThis.process)||void 0===r?void 0:r.env.flow_modules_logger)&&(this.state=n,this.args=o,this.name="",this.name="string"==typeof e?e:e.constructor.name,n&&this.initialize())}return u(t,[{key:"initialize",value:function(){this.args.sameColor?(t.sharedData[this.name]||(t.sharedData[this.name]=this.getRandomColor()),this.color=t.sharedData[this.name]):(this.color=this.getRandomColor(),t.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: ".concat(this.color),"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}},{key:"setOutputHandler",value:function(t){this.outputHandler=t}},{key:"useWrapper",value:function(r){var o=this,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!r||"object"!==n(r)||Array.isArray(r))return r;t.wrapperDepth++;var a=e({},r);return Object.values(t.wrappers).forEach((function(t){var e=w(t,1)[0];r instanceof e.classType&&(a=e.callback(r)||a)})),4>t.wrapperDepth?(i&&a&&Object.entries(a).forEach((function(t){var e=w(t,2);a[e[0]]=o.useWrapper(e[1],!0)})),t.wrapperDepth--,a):(t.wrapperDepth--,a)}},{key:"startEmpty",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.state&&this.printFunctionNotify("se",t.getCallerName(),e)}},{key:"startWith",value:function(e){if(this.state){e=Object.assign({},e);var r="se",o=t.getCallerName();if("string"==typeof e)this.printInLineString(r,o,e);else if(1===Object.keys(e).length){var i=Object.keys(e)[0],a=Object.values(e)[0];"object"===n(a)?this.printNextLineObject(r,o,i,a||{}):"function"==typeof a?this.printInLineFunction(r,o,i,a):this.printInLineElement(r,o,i,a)}else this.printMultiLineObject(r,o,e)}}},{key:"object",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(this.state){var o=t.getCallerName();for(var i in e=Object.create(e))"object"===n(e[i])&&(e[i]=JSON.stringify(this.useWrapper(e[i]),E())),this.out.apply(this,["%c(ob)-> %c%c".concat(this.name,"%c::%c").concat(o,"%c() [").concat(r,"] ->> ").concat(i,": '").concat(e[i],"'%c")].concat(this.defaultStyle))}}},{key:"debug",value:function(e){this.state&&this.printFunctionNotify("db",t.getCallerName(),e)}},{key:"drop",value:function(e,r){if(this.state){var n=t.getCallerName();for(var o in e)this.out.apply(this,["%c(dr)-> %c%c".concat(this.name,"%c::%c").concat(n,"%c() ->> corresponding ").concat(o,": '").concat(e[o],"' RESULT: %c↓")].concat(this.defaultStyle));this.out(r)}}},{key:"throw",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"null",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};throw this.printFunctionNotify("tw",t.getCallerName(),e),n&&this.printNextLineObject("tw",t.getCallerName(),r,n),Error().stack}},{key:"clone",value:function(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}},{key:"printFunctionNotify",value:function(t,e,r){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ").concat(r,"%c")].concat(this.defaultStyle))}},{key:"printInLineElement",value:function(t,e,r,n){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(r,": '").concat(n,"'%c")].concat(this.defaultStyle))}},{key:"printInLineFunction",value:function(e,r,n,o){o=t.getFunctionView(o),this.printInLineElement(e,r,n,o)}},{key:"printInLineString",value:function(t,e,r){this.printInLineElement(t,e,"(string)",r)}},{key:"printNextLineObject",value:function(t,e,r,n){n=this.useWrapper(n),this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(r," %c↓")].concat(this.defaultStyle)),this.out(n)}},{key:"printMultiLineObject",value:function(e,r,o){for(var i in this.out.apply(this,["%c(".concat(e,")-> %c%c").concat(this.name,"%c::%c").concat(r,"%c(").concat(Object.keys(o).join(", "),") %c↓")].concat(this.defaultStyle)),o){var a=o[i];"object"===n(a)?a=JSON.stringify(this.useWrapper(a),E()):"function"==typeof o[i]&&(a=t.getFunctionView(a)),this.out.call(this,"%c"+i+": `"+this.useWrapper(a)+"`","color: #a3a3a3")}}},{key:"getRandomColor",value:function(){for(var e="#",r=0;6>r;r++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t.colorsInUse.some((function(t){return N(e,t)>=.8}))?this.getRandomColor():e}},{key:"out",value:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];this.outputHandler.apply(this,e)}}],[{key:"getName",value:function(){return"Core/Modules/Logger"}},{key:"reset",value:function(){t.wrappers={},t.wrapperDepth=0,t.colorsInUse=[],t.sharedData={}}},{key:"createCustomWrapper",value:function(e,r){t.wrappers[e]||(t.wrappers[e.name]=[]),t.wrappers[e.name].push({classType:e,callback:r})}},{key:"getCallerName",value:function(){var t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}},{key:"getFunctionView",value:function(t){var e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}}]),t}();s(x,"wrappers",{}),s(x,"wrapperDepth",0),s(x,"sharedData",{}),s(x,"colorsInUse",[]);var A=Object.freeze({__proto__:null,Logger:x}),I=function(t){l(r,y(Error));var e=m(r);function r(t){return a(this,r),e.call(this,"Command: '".concat(t.getName(),"' is already registered"))}return u(r)}(),L=function(t){l(r,y(Error));var e=m(r);function r(t){return a(this,r),e.call(this,"Command: '".concat(t,"' is not found"))}return u(r)}(),P=function(t){l(r,y(Error));var e=m(r);function r(t){return a(this,r),e.call(this,"Controller: '".concat(t.getName(),"' is already registered"))}return u(r)}(),H=function(t){l(r,y(Error));var e=m(r);function r(t,n){return a(this,r),e.call(this,"ForeMethod implementation: at '".concat(t,"' method: '").concat(n,"'"))}return u(r)}(),S=function(t){l(r,y(Error));var e=m(r);function r(t,n){return a(this,r),e.call(this,"ForeMethod implementation: at '".concat(t.getName(),"' method: '").concat(n,"'"))}return u(r)}(),T=Object.freeze({__proto__:null,CommandAlreadyRegistered:I,CommandNotFound:L,ControllerAlreadyRegistered:P,ForceMethod:S}),B=0,M=function(){function t(){a(this,t),s(this,"virtualId",0),this.virtualId=B,B++}return u(t,[{key:"getName",value:function(){return this.constructor.getName()}}],[{key:"getName",value:function(){throw new H("ObjectBase","getName")}}]),t}();var D=function(t){l(p,M);var n,o,c,f,h=m(p);function p(){var t;return a(this,p),s(g(t=h.call(this)),"current",{}),s(g(t),"currentArgs",{}),s(g(t),"trace",[]),s(g(t),"commands",{}),s(g(t),"onBeforeHooks",{}),s(g(t),"onBeforeUIHooks",{}),s(g(t),"onAfterHooks",{}),s(g(t),"onAfterOnceHooks",{}),s(g(t),"onAfterUIHooks",{}),s(g(t),"onAfterAffectHooks",{}),t.logger=new x(t.getName(),!0),t.logger.startEmpty(),t}return u(p,[{key:"run",value:(f=i(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},o=a.length>2&&void 0!==a[2]?a[2]:{},"string"==typeof e&&(e=this.getCommandInstance(e,n,o)),this.attachCurrent(e,n),t.next=6,this.runInstance(e,n,o);case 6:return i=t.sent,this.detachCurrent(e),t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"register",value:function(t,e){var r=this,n={};return Object.values(t).forEach((function(t){var e=t.getName();if(r.commands[e])throw new I(t);r.commands[e]=t,n[e]=t})),n}},{key:"getAll",value:function(){return this.commands}},{key:"getByName",value:function(t){return this.commands[t]}},{key:"getLogger",value:function(){return this.logger}},{key:"getCommandInstance",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.commands[t];if(!n)throw new L(t);return new n(e,r)}},{key:"onBefore",value:function(t,e){p.hookCommand(this.onBeforeHooks,t,e)}},{key:"onBeforeUI",value:function(t,e){p.hookCommand(this.onBeforeUIHooks,t,e)}},{key:"onAfter",value:function(t,e){p.hookCommand(this.onAfterHooks,t,e)}},{key:"onAfterUI",value:function(t,e){p.hookCommand(this.onAfterUIHooks,t,e)}},{key:"onAfterOnce",value:function(t,e){p.hookCommand(this.onAfterOnceHooks,t,e)}},{key:"onAfterAffect",value:function(t,e){p.hookCommand(this.onAfterAffectHooks,t,e)}},{key:"onBeforeRun",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.onBeforeHooks[t.getName()]){var n=this.onBeforeHooks[t.getName()];n.forEach((function(t){return t(e,r)}))}if(this.onBeforeUIHooks[t.getName()]){var o=this.onBeforeUIHooks[t.getName()];o.forEach((function(t){return t(e,r)}))}}},{key:"runInstance",value:(c=i(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=a.length>2&&void 0!==a[2]?a[2]:{},i=null,Object.keys(n=a.length>1&&void 0!==a[1]?a[1]:{}).length?(this.logger.startWith({command:e.getName(),options:o,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(n)):this.logger.startWith({command:e.getName(),options:o,args:n}),this.onBeforeRun(e,n,o),t.next=7,e.run();case 7:return i=t.sent,t.next=10,this.onAfterRun(e,n,o,i);case 10:return t.abrupt("return",i);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"onAfterRun",value:(o=i(r().mark((function t(n,o,i,a){var c=this;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=Object.assign({},i),!this.onAfterAffectHooks[n.getName()]){t.next=6;break}return this.onAfterAffectHooks[n.getName()].forEach((function(t){o.result=a,a=c.run(""+t,o,i)})),t.next=5,a;case 5:a=t.sent;case 6:if(!this.onAfterHooks){t.next=10;break}return o.result=a,t.next=10,p.runCallbacks(Object.assign([],this.onAfterHooks[n.getName()]),o,i);case 10:if(!this.onAfterOnceHooks){t.next=13;break}return t.next=13,p.runCallbacks(this.onAfterOnceHooks[n.getName()],o,e(e({},i),{},{pop:!0}));case 13:return this.onAfterUIHooks&&p.runCallbacks(Object.assign([],this.onAfterUIHooks[n.getName()]),o,i),t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,r,n){return o.apply(this,arguments)})},{key:"attachCurrent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),p.trace.push(t.getName())}},{key:"detachCurrent",value:function(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],p.trace.pop(),this.trace.pop()}}],[{key:"getName",value:function(){return"Core/Managers/Commands"}},{key:"runCallbacks",value:(n=i(r().mark((function t(e){var n,o,i,a,c,u=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2&&void 0!==u[2]?u[2]:{},i=(null==e?void 0:e.length)||0,a=0;case 4:if(a>=i){t.next=13;break}if(c=!0===o.pop?e.pop():e[a]){t.next=8;break}throw Error("Callback is not defined.");case 8:return t.next=10,c(n,o);case 10:++a,t.next=4;break;case 13:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"hookCommand",value:function(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}}]),p}();s(D,"trace",[]);var R,U=function(t){l(r,M);var e=m(r);function r(){var t;a(this,r);for(var n=arguments.length,o=Array(n),i=0;n>i;i++)o[i]=arguments[i];return s(g(t=e.call.apply(e,[this].concat(o))),"controllers",{}),t}return u(r,[{key:"get",value:function(t){return this.controllers[t]}},{key:"getAll",value:function(){return this.controllers}},{key:"register",value:function(t){if(this.controllers[t.getName()])throw new P(t);return this.controllers[t.getName()]=t,t}}],[{key:"getName",value:function(){return"Core/Managers/Controllers"}}]),r}();!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(R||(R={}));var F=function(t){l(o,M);var e,n=m(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"http://localhost";return a(this,o),(t=n.call(this)).logger=new x(o.getName(),!0),t.logger.startWith({apiBaseUrl:e}),t.apiBaseUrl=e+"/",t}return u(o,[{key:"fetch",value:(e=i(r().mark((function t(e,n){var o,i,a,c,u,s,l,f,h=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.logger.startWith({path:e,method:n,body:c=h.length>2&&void 0!==h[2]?h[2]:null}),u={credentials:"include"},s={},[R.POST,R.PUT,R.PATCH].includes(n)?(Object.assign(s,{"Content-Type":"application/json"}),Object.assign(u,{method:n,headers:s,body:JSON.stringify(c)})):Object.assign(u,{headers:s}),t.next=6,globalThis.fetch(this.apiBaseUrl+e,u);case 6:return l=t.sent,f=void 0,t.prev=8,t.next=11,l.json();case 11:f=t.sent,t.next=18;break;case 14:return t.prev=14,t.t0=t.catch(8),console.error(t.t0),t.abrupt("return",!1);case 18:if(!(null!==(o=f)&&void 0!==o&&o.error&&null!==(i=f)&&void 0!==i&&i.global&&null!==(a=f)&&void 0!==a&&a.message)){t.next=20;break}throw Error(f.message);case 20:return this.logger.drop({path:e},f),t.abrupt("return",f);case 22:case"end":return t.stop()}}),t,this,[[8,14]])}))),function(t,r){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Clients/Http"}}]),o}(),z=function(t){l(o,D);var e,n=m(o);function o(t){var e;return a(this,o),e=n.call(this),o.client=new F(t.baseURL),e}return u(o,[{key:"getClient",value:function(){return o.client}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=R.GET,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=R.PATCH,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=R.DELETE,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"create",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=R.POST,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"runInstance",value:(e=i(r().mark((function t(e){var n,i,a,c=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=c.length>1&&void 0!==c[1]?c[1]:{},i=c.length>2&&void 0!==c[2]?c[2]:{},this.currentHttpMethod){t.next=4;break}throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');case 4:return a={type:this.currentHttpMethod,args:{query:{},data:{}}},R.GET===this.currentHttpMethod?a.args.query=n:a.args.data=n,t.next=8,k(f(o.prototype),"runInstance",this).call(this,e,a,i);case 8:return n.result=t.sent,this.currentHttpMethod=R.__EMPTY__,t.abrupt("return",n.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Managers/Data"}}]),o}(),W=function(t){l(r,D);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,null,[{key:"getName",value:function(){return"Core/Managers/Internal"}}]),r}(),G=[];function Y(t){V=new D,Z=new U,q=new z(t),K=new W}function J(){V={},Z={},q={},K={}}var V={},Z={},q={},K={},$=Object.freeze({__proto__:null,afterInitializeCallbacks:G,get commands(){return V},get controllers(){return Z},get data(){return q},destroy:J,initialize:Y,get internal(){return K}}),Q=function(t){l(o,M);var e,n=m(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a(this,o),s(g(t=n.call(this)),"args",{}),s(g(t),"options",{});var i=t.constructor.getName();return t.logger=new x(i,!0,{sameColor:!0}),t.logger.startWith({args:e,options:r}),t.initialize(e,r),t}return u(o,[{key:"initialize",value:function(t,e){this.args=t,this.options=e}},{key:"apply",value:function(){throw new S(this,"apply")}},{key:"run",value:(e=i(r().mark((function t(){var e;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.onBeforeApply&&this.onBeforeApply(),t.next=3,this.apply(this.args,this.options);case 3:return e=t.sent,this.onAfterApply&&this.onAfterApply(),t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"getArgs",value:function(){return this.args}},{key:"getOptions",value:function(){return this.options}}]),o}(),X=function(t){l(r,Q);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandPublic"}}]),r}(),tt=Object.freeze({__proto__:null,CommandBase:Q,CommandData:function(t){l(r,Q);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,[{key:"getEndpoint",value:function(){throw new S(this,"getEndpoint")}},{key:"apply",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.args,e=this.applyEndpointFormat(this.getEndpoint(),t);return q.getClient().fetch(e,q.currentHttpMethod,t||null)}},{key:"applyEndpointFormat",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.includes("{")&&(t=t.split("/").map((function(t){var r=t.match("\\{(.*?)\\}");return null!=r&&r.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}}],[{key:"getName",value:function(){return"Core/CommandBases/CommandData"}}]),r}(),CommandInternal:function(t){l(r,Q);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandInternal"}}]),r}(),CommandPublic:X}),et=Object.freeze({__proto__:null,Controller:function(t){l(r,M);var e=m(r);function r(){var t;return a(this,r),(t=e.call(this)).initialize(),t}return u(r,[{key:"initialize",value:function(){this.register(),this.setupHooks&&this.setupHooks()}},{key:"register",value:function(){this.commands=V.register(this.getCommands(),this),this.data=q.register(this.getData(),this),this.internal=K.register(this.getInternal(),this)}},{key:"getCommands",value:function(){return{}}},{key:"getData",value:function(){return{}}},{key:"getInternal",value:function(){return{}}}],[{key:"getName",value:function(){return"Core/Core/Controller"}}]),r}(),ObjectBase:M}),rt=Object.freeze({__proto__:null,Commands:D,Controllers:U,Data:z,Internal:W}),nt=Object.freeze({__proto__:null,commandBases:tt,core:et,errors:T,managerBases:rt,managers:$,modules:A,utils:_}),ot=!1;function it(){if(ot)throw Error("ZenCore is already initialized.")}it();var at={version:C},ct=e({initialize:function(t){it(),Y(at=t||at),ot=!0},destroy:function(){J(),ot=!1},onAfterInitialize:function(t){G.push(t)},config:at},nt);null!==globalThis&&void 0!==globalThis&&globalThis.ZenCore||(globalThis.ZenCore=ct);export{tt as commandBases,et as core,ct as default,T as errors,rt as managerBases,$ as managers,A as modules,_ as utils};
|
|
1
|
+
function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function e(e){for(var r=1;arguments.length>r;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new N(n||[]);return o(i,"_invoke",{value:O(t,r,a)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function p(){}function v(){}function y(){}var g={};s(g,a,(function(){return this}));var d=Object.getPrototypeOf,m=d&&d(d(x([])));m&&m!==e&&n.call(m,a)&&(g=m);var b=y.prototype=p.prototype=Object.create(g);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return _()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=j(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function j(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function x(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:_}}function _(){return{value:void 0,done:!0}}return v.prototype=y,o(b,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=s(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,u,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},k(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(b),s(b,u,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=x,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:x(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function c(t){o(a,n,i,c,u,"next",t)}function u(t){o(a,n,i,c,u,"throw",t)}c(void 0)}))}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function u(t,e,r){return e&&c(t.prototype,e),r&&c(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=j(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function v(t,e,r){return v=p()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&h(o,r.prototype),o},v.apply(null,arguments)}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return v(t,arguments,f(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},y(t)}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return g(t)}function m(t){var e=p();return function(){var r,n=f(t);if(e){var o=f(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return d(this,r)}}function b(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=f(t)););return t}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=b(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(3>arguments.length?t:r):o.value}},k.apply(this,arguments)}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return O(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return O(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);e>r;r++)n[r]=t[r];return n}function j(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var C="0.0.0-alpha.5",E=function(){var t=new WeakSet;return function(e,r){if("object"===n(r)&&null!==r){if(t.has(r))return;t.add(r)}return r}},N=function(t,e){t=t.replace("#",""),e=e.replace("#","");var r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),i=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),c=parseInt(e.substring(4,6),16),u=255-Math.abs(r-i),s=255-Math.abs(n-a),l=255-Math.abs(o-c);return((u/=255)+(s/=255)+(l/=255))/3},x=Object.freeze({__proto__:null,getCircularReplacer:E,hexColorDelta:N}),_="anonymous function",A=["_callee","tryCatch","<anonymous>","Generator.next","asyncGeneratorStep","_next"];Error.stackTraceLimit=50;var I=function(){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a(this,t),s(this,"args",{}),s(this,"state",!1),"off"!==(null===(r=globalThis.process)||void 0===r?void 0:r.env.flow_modules_logger)&&(this.state=n,this.args=o,this.name="",this.name="string"==typeof e?e:e.constructor.name,n&&this.initialize())}return u(t,[{key:"initialize",value:function(){this.args.sameColor?(t.sharedData[this.name]||(t.sharedData[this.name]=this.getRandomColor()),this.color=t.sharedData[this.name]):(this.color=this.getRandomColor(),t.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: ".concat(this.color),"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}},{key:"setOutputHandler",value:function(t){this.outputHandler=t}},{key:"useWrapper",value:function(r){var o=this,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!r||"object"!==n(r)||Array.isArray(r))return r;t.wrapperDepth++;var a=e({},r);return Object.values(t.wrappers).forEach((function(t){var e=w(t,1)[0];r instanceof e.classType&&(a=e.callback(r)||a)})),4>t.wrapperDepth?(i&&a&&Object.entries(a).forEach((function(t){var e=w(t,2);a[e[0]]=o.useWrapper(e[1],!0)})),t.wrapperDepth--,a):(t.wrapperDepth--,a)}},{key:"startEmpty",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.state&&this.printFunctionNotify("se",t.getCallerName(),e)}},{key:"startWith",value:function(e){if(this.state){e=Object.assign({},e);var r="se",o=t.getCallerName();if("string"==typeof e)this.printInLineString(r,o,e);else if(1===Object.keys(e).length){var i=Object.keys(e)[0],a=Object.values(e)[0];"object"===n(a)?this.printNextLineObject(r,o,i,a||{}):"function"==typeof a?this.printInLineFunction(r,o,i,a):this.printInLineElement(r,o,i,a)}else this.printMultiLineObject(r,o,e)}}},{key:"object",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(this.state){var o=t.getCallerName();for(var i in e=Object.create(e))"object"===n(e[i])&&(e[i]=JSON.stringify(this.useWrapper(e[i]),E())),this.out.apply(this,["%c(ob)-> %c%c".concat(this.name,"%c::%c").concat(o,"%c() [").concat(r,"] ->> ").concat(i,": '").concat(e[i],"'%c")].concat(this.defaultStyle))}}},{key:"debug",value:function(e){this.state&&this.printFunctionNotify("db",t.getCallerName(),e)}},{key:"drop",value:function(e,r){if(this.state){var n=t.getCallerName();for(var o in e)this.out.apply(this,["%c(dr)-> %c%c".concat(this.name,"%c::%c").concat(n,"%c() ->> corresponding ").concat(o,": '").concat(e[o],"' RESULT: %c↓")].concat(this.defaultStyle));this.out(r)}}},{key:"throw",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"null",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};throw this.printFunctionNotify("tw",t.getCallerName(),e),n&&this.printNextLineObject("tw",t.getCallerName(),r,n),Error().stack}},{key:"clone",value:function(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}},{key:"printFunctionNotify",value:function(t,e,r){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ").concat(r,"%c")].concat(this.defaultStyle))}},{key:"printInLineElement",value:function(t,e,r,n){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(r,": '").concat(n,"'%c")].concat(this.defaultStyle))}},{key:"printInLineFunction",value:function(e,r,n,o){o=t.getFunctionView(o),this.printInLineElement(e,r,n,o)}},{key:"printInLineString",value:function(t,e,r){this.printInLineElement(t,e,"(string)",r)}},{key:"printNextLineObject",value:function(t,e,r,n){n=this.useWrapper(n),this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(r," %c↓")].concat(this.defaultStyle)),this.out(n)}},{key:"printMultiLineObject",value:function(e,r,o){for(var i in this.out.apply(this,["%c(".concat(e,")-> %c%c").concat(this.name,"%c::%c").concat(r,"%c(").concat(Object.keys(o).join(", "),") %c↓")].concat(this.defaultStyle)),o){var a=o[i];"object"===n(a)?a=JSON.stringify(this.useWrapper(a),E()):"function"==typeof o[i]&&(a=t.getFunctionView(a)),this.out.call(this,"%c"+i+": `"+this.useWrapper(a)+"`","color: #a3a3a3")}}},{key:"getRandomColor",value:function(){for(var e="#",r=0;6>r;r++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t.colorsInUse.some((function(t){return N(e,t)>=.8}))?this.getRandomColor():e}},{key:"out",value:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];this.outputHandler.apply(this,e)}}],[{key:"getName",value:function(){return"Core/Modules/Logger"}},{key:"reset",value:function(){t.wrappers={},t.wrapperDepth=0,t.colorsInUse=[],t.sharedData={}}},{key:"createCustomWrapper",value:function(e,r){t.wrappers[e]||(t.wrappers[e.name]=[]),t.wrappers[e.name].push({classType:e,callback:r})}},{key:"getCallerName",value:function(){var t,e=(null===(t=Error().stack)||void 0===t?void 0:t.split("\n"))||[],r=e.length?e[3].trim():_;if(r.startsWith("at new"))return"constructor";var n=r.split(".")[1].split(" ")[0],o=!1;if(n.includes("_callee")){for(var i=function(){var t=e[a];if(!A.some((function(e){return t.includes(e)}))){var r=t.trim().split(" ");return r.length>2?(n=r[1].split(".")[1],o=!0,"break"):"continue"}},a=3;e.length>a;a++){var c=i();if("continue"!==c&&"break"===c)break}o||(n=_)}return n}},{key:"getFunctionView",value:function(t){var e=_;return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}}]),t}();s(I,"wrappers",{}),s(I,"wrapperDepth",0),s(I,"sharedData",{}),s(I,"colorsInUse",[]);var L=Object.freeze({__proto__:null,Logger:I}),P=function(t){l(r,y(Error));var e=m(r);function r(t){return a(this,r),e.call(this,"Command: '".concat(t.getName(),"' is already registered"))}return u(r)}(),S=function(t){l(r,y(Error));var e=m(r);function r(t){return a(this,r),e.call(this,"Command: '".concat(t,"' is not found"))}return u(r)}(),H=function(t){l(r,y(Error));var e=m(r);function r(t){return a(this,r),e.call(this,"Controller: '".concat(t.getName(),"' is already registered"))}return u(r)}(),T=function(t){l(r,y(Error));var e=m(r);function r(t,n){return a(this,r),e.call(this,"ForeMethod implementation: at '".concat(t,"' method: '").concat(n,"'"))}return u(r)}(),B=function(t){l(r,y(Error));var e=m(r);function r(t,n){return a(this,r),e.call(this,"ForeMethod implementation: at '".concat(t.getName(),"' method: '").concat(n,"'"))}return u(r)}(),D=Object.freeze({__proto__:null,CommandAlreadyRegistered:P,CommandNotFound:S,ControllerAlreadyRegistered:H,ForceMethod:B}),M=0,F=function(){function t(){a(this,t),s(this,"virtualId",0),this.virtualId=M,M++}return u(t,[{key:"getName",value:function(){return this.constructor.getName()}}],[{key:"getName",value:function(){throw new T("ObjectBase","getName")}}]),t}();var R=function(t){l(p,F);var n,o,c,f,h=m(p);function p(){var t;return a(this,p),s(g(t=h.call(this)),"current",{}),s(g(t),"currentArgs",{}),s(g(t),"trace",[]),s(g(t),"commands",{}),s(g(t),"onBeforeHooks",{}),s(g(t),"onBeforeUIHooks",{}),s(g(t),"onAfterHooks",{}),s(g(t),"onAfterOnceHooks",{}),s(g(t),"onAfterUIHooks",{}),s(g(t),"onAfterAffectHooks",{}),t.logger=new I(t.getName(),!0),t.logger.startEmpty(),t}return u(p,[{key:"run",value:(f=i(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},o=a.length>2&&void 0!==a[2]?a[2]:{},"string"==typeof e&&(e=this.getCommandInstance(e,n,o)),this.attachCurrent(e,n),t.next=6,this.runInstance(e,n,o);case 6:return i=t.sent,this.detachCurrent(e),t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"register",value:function(t,e){var r=this,n={};return Object.values(t).forEach((function(t){var e=t.getName();if(r.commands[e])throw new P(t);r.commands[e]=t,n[e]=t})),n}},{key:"getAll",value:function(){return this.commands}},{key:"getByName",value:function(t){return this.commands[t]}},{key:"getLogger",value:function(){return this.logger}},{key:"getCommandInstance",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.commands[t];if(!n)throw new S(t);return new n(e,r)}},{key:"onBefore",value:function(t,e){p.hookCommand(this.onBeforeHooks,t,e)}},{key:"onBeforeUI",value:function(t,e){p.hookCommand(this.onBeforeUIHooks,t,e)}},{key:"onAfter",value:function(t,e){p.hookCommand(this.onAfterHooks,t,e)}},{key:"onAfterUI",value:function(t,e){p.hookCommand(this.onAfterUIHooks,t,e)}},{key:"onAfterOnce",value:function(t,e){p.hookCommand(this.onAfterOnceHooks,t,e)}},{key:"onAfterAffect",value:function(t,e){p.hookCommand(this.onAfterAffectHooks,t,e)}},{key:"onBeforeRun",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.onBeforeHooks[t.getName()]){var n=this.onBeforeHooks[t.getName()];n.forEach((function(t){return t(e,r)}))}if(this.onBeforeUIHooks[t.getName()]){var o=this.onBeforeUIHooks[t.getName()];o.forEach((function(t){return t(e,r)}))}}},{key:"runInstance",value:(c=i(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=a.length>2&&void 0!==a[2]?a[2]:{},i=null,Object.keys(n=a.length>1&&void 0!==a[1]?a[1]:{}).length?(this.logger.startWith({command:e.getName(),options:o,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(n)):this.logger.startWith({command:e.getName(),options:o,args:n}),this.onBeforeRun(e,n,o),t.next=7,e.run();case 7:return i=t.sent,t.next=10,this.onAfterRun(e,n,o,i);case 10:return t.abrupt("return",i);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"onAfterRun",value:(o=i(r().mark((function t(n,o,i,a){var c=this;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=Object.assign({},i),!this.onAfterAffectHooks[n.getName()]){t.next=6;break}return this.onAfterAffectHooks[n.getName()].forEach((function(t){o.result=a,a=c.run(""+t,o,i)})),t.next=5,a;case 5:a=t.sent;case 6:if(!this.onAfterHooks){t.next=10;break}return o.result=a,t.next=10,p.runCallbacks(Object.assign([],this.onAfterHooks[n.getName()]),o,i);case 10:if(!this.onAfterOnceHooks){t.next=13;break}return t.next=13,p.runCallbacks(this.onAfterOnceHooks[n.getName()],o,e(e({},i),{},{pop:!0}));case 13:return this.onAfterUIHooks&&p.runCallbacks(Object.assign([],this.onAfterUIHooks[n.getName()]),o,i),t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,r,n){return o.apply(this,arguments)})},{key:"attachCurrent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),p.trace.push(t.getName())}},{key:"detachCurrent",value:function(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],p.trace.pop(),this.trace.pop()}}],[{key:"getName",value:function(){return"Core/Managers/Commands"}},{key:"runCallbacks",value:(n=i(r().mark((function t(e){var n,o,i,a,c,u=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2&&void 0!==u[2]?u[2]:{},i=(null==e?void 0:e.length)||0,a=0;case 4:if(a>=i){t.next=13;break}if(c=!0===o.pop?e.pop():e[a]){t.next=8;break}throw Error("Callback is not defined.");case 8:return t.next=10,c(n,o);case 10:++a,t.next=4;break;case 13:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"hookCommand",value:function(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}}]),p}();s(R,"trace",[]);var U,z=function(t){l(r,F);var e=m(r);function r(){var t;a(this,r);for(var n=arguments.length,o=Array(n),i=0;n>i;i++)o[i]=arguments[i];return s(g(t=e.call.apply(e,[this].concat(o))),"controllers",{}),t}return u(r,[{key:"get",value:function(t){return this.controllers[t]}},{key:"getAll",value:function(){return this.controllers}},{key:"register",value:function(t){if(this.controllers[t.getName()])throw new H(t);return this.controllers[t.getName()]=t,t}}],[{key:"getName",value:function(){return"Core/Managers/Controllers"}}]),r}();!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(U||(U={}));var W=function(t){l(o,F);var e,n=m(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"http://localhost";return a(this,o),(t=n.call(this)).logger=new I(o.getName(),!0),t.logger.startWith({apiBaseUrl:e}),t.apiBaseUrl=e+"/",t}return u(o,[{key:"fetch",value:(e=i(r().mark((function t(e,n){var o,i,a,c,u,s,l,f,h=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.logger.startWith({path:e,method:n,body:c=h.length>2&&void 0!==h[2]?h[2]:null}),u={credentials:"include"},s={},[U.POST,U.PUT,U.PATCH].includes(n)?(Object.assign(s,{"Content-Type":"application/json"}),Object.assign(u,{method:n,headers:s,body:JSON.stringify(c)})):Object.assign(u,{headers:s}),t.next=6,globalThis.fetch(this.apiBaseUrl+e,u);case 6:return l=t.sent,f=void 0,t.prev=8,t.next=11,l.json();case 11:f=t.sent,t.next=18;break;case 14:return t.prev=14,t.t0=t.catch(8),console.error(t.t0),t.abrupt("return",!1);case 18:if(!(null!==(o=f)&&void 0!==o&&o.error&&null!==(i=f)&&void 0!==i&&i.global&&null!==(a=f)&&void 0!==a&&a.message)){t.next=20;break}throw Error(f.message);case 20:return this.logger.drop({path:e},f),t.abrupt("return",f);case 22:case"end":return t.stop()}}),t,this,[[8,14]])}))),function(t,r){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Clients/Http"}}]),o}(),G=function(t){l(o,R);var e,n=m(o);function o(t){var e;return a(this,o),e=n.call(this),o.client=new W(t.baseURL),e}return u(o,[{key:"getClient",value:function(){return o.client}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.GET,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.PATCH,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.DELETE,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"create",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.POST,k(f(o.prototype),"run",this).call(this,t,e,r)}},{key:"runInstance",value:(e=i(r().mark((function t(e){var n,i,a,c=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=c.length>1&&void 0!==c[1]?c[1]:{},i=c.length>2&&void 0!==c[2]?c[2]:{},this.currentHttpMethod){t.next=4;break}throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');case 4:return a={type:this.currentHttpMethod,args:{query:{},data:{}}},U.GET===this.currentHttpMethod?a.args.query=n:a.args.data=n,t.next=8,k(f(o.prototype),"runInstance",this).call(this,e,a,i);case 8:return n.result=t.sent,this.currentHttpMethod=U.__EMPTY__,t.abrupt("return",n.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Managers/Data"}}]),o}(),Y=function(t){l(r,R);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,null,[{key:"getName",value:function(){return"Core/Managers/Internal"}}]),r}(),J=[];function V(t){q=new R,$=new z,K=new G(t),Q=new Y}function Z(){q={},$={},K={},Q={}}var q={},$={},K={},Q={},X=Object.freeze({__proto__:null,afterInitializeCallbacks:J,get commands(){return q},get controllers(){return $},get data(){return K},destroy:Z,initialize:V,get internal(){return Q}}),tt=function(t){l(o,F);var e,n=m(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a(this,o),s(g(t=n.call(this)),"args",{}),s(g(t),"options",{});var i=t.constructor.getName();return t.logger=new I(i,!0,{sameColor:!0}),t.logger.startWith({args:e,options:r}),t.initialize(e,r),t}return u(o,[{key:"initialize",value:function(t,e){this.args=t,this.options=e}},{key:"apply",value:function(){throw new B(this,"apply")}},{key:"run",value:(e=i(r().mark((function t(){var e;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.onBeforeApply&&this.onBeforeApply(),t.next=3,this.apply(this.args,this.options);case 3:return e=t.sent,this.onAfterApply&&this.onAfterApply(),t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"getArgs",value:function(){return this.args}},{key:"getOptions",value:function(){return this.options}}]),o}(),et=function(t){l(r,tt);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandPublic"}}]),r}(),rt=Object.freeze({__proto__:null,CommandBase:tt,CommandData:function(t){l(r,tt);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,[{key:"getEndpoint",value:function(){throw new B(this,"getEndpoint")}},{key:"apply",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.args,e=this.applyEndpointFormat(this.getEndpoint(),t);return K.getClient().fetch(e,K.currentHttpMethod,t||null)}},{key:"applyEndpointFormat",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.includes("{")&&(t=t.split("/").map((function(t){var r=t.match("\\{(.*?)\\}");return null!=r&&r.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}}],[{key:"getName",value:function(){return"Core/CommandBases/CommandData"}}]),r}(),CommandInternal:function(t){l(r,tt);var e=m(r);function r(){return a(this,r),e.apply(this,arguments)}return u(r,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandInternal"}}]),r}(),CommandPublic:et}),nt=Object.freeze({__proto__:null,Controller:function(t){l(r,F);var e=m(r);function r(){var t;return a(this,r),(t=e.call(this)).initialize(),t}return u(r,[{key:"initialize",value:function(){this.register(),this.setupHooks&&this.setupHooks()}},{key:"register",value:function(){this.commands=q.register(this.getCommands(),this),this.data=K.register(this.getData(),this),this.internal=Q.register(this.getInternal(),this)}},{key:"getCommands",value:function(){return{}}},{key:"getData",value:function(){return{}}},{key:"getInternal",value:function(){return{}}}],[{key:"getName",value:function(){return"Core/Core/Controller"}}]),r}(),ObjectBase:F}),ot=Object.freeze({__proto__:null,Commands:R,Controllers:z,Data:G,Internal:Y}),it=Object.freeze({__proto__:null,commandBases:rt,core:nt,errors:D,managerBases:ot,managers:X,modules:L,utils:x}),at=!1;function ct(){if(at)throw Error("ZenCore is already initialized.")}ct();var ut={version:C},st=e({initialize:function(t){ct(),V(ut=t||ut),at=!0},destroy:function(){Z(),at=!1},onAfterInitialize:function(t){J.push(t)},config:ut},it);null!==globalThis&&void 0!==globalThis&&globalThis.ZenCore||(globalThis.ZenCore=st);export{rt as commandBases,nt as core,st as default,D as errors,ot as managerBases,X as managers,L as modules,x as utils};
|