@zenflux/core 0.0.0-abc.2 → 0.0.0-abc.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1 @@
1
- class t extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let r=0;class s{virtualId=0;static getName(){throw new t("ObjectBase","getName")}constructor(){this.virtualId=r,r++}getName(){return this.constructor.getName()}}
2
- /**
3
- * Function getCircularReplacer() : Reduce circular references.
4
- *
5
- * @copyright https://stackoverflow.com/a/53731154
6
- */
7
- const o=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},n=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),n=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);let c=255-Math.abs(r-n),l=255-Math.abs(s-a),h=255-Math.abs(o-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
8
- /**
9
- * Function hexColorDelta() : Return color difference in ratio decimal point.
10
- *
11
- * @copyright http://jsfiddle.net/96sME/
12
- */var a=Object.freeze({__proto__:null,getCircularReplacer:o,hexColorDelta:n});class i{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){i.wrappers={},i.wrapperDepth=0,i.colorsInUse=[],i.sharedData={}}static createCustomWrapper(t,e){i.wrappers[t]||(i.wrappers[t.name]=[]),i.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const 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]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(i.sharedData[this.name]||(i.sharedData[this.name]=this.getRandomColor()),this.color=i.sharedData[this.name]):(this.color=this.getRandomColor(),i.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;i.wrapperDepth++;let r={...t};return Object.values(i.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>i.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),i.wrapperDepth--,r):(i.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",i.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=i.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let o=Object.values(t)[0];"object"==typeof o?this.printNextLineObject(e,r,s,o||{}):"function"==typeof o?this.printInLineFunction(e,r,s,o):this.printInLineElement(e,r,s,o)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=i.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),o())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",i.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=i.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",i.getCallerName(),t),r&&this.printNextLineObject("tw",i.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=i.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),o()):"function"==typeof r[t]&&(e=i.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return i.colorsInUse.some((e=>n(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class c extends s{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new i(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,r=this.options){throw new e(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}const l={commands:{},controllers:{},data:{},internal:{}};var h=Object.freeze({__proto__:null,CommandBase:c,CommandData:class extends c{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new e(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return l.data.getClient().fetch(r,l.data.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends c{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends c{static getName(){return"Core/CommandBases/CommandPublic"}}});var u=Object.freeze({__proto__:null,Controller:class extends s{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=l.commands.register(this.getCommands(),this),this.data=l.data.register(this.getData(),this),this.internal=l.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:s});class p extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class g extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class m extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var d,f=Object.freeze({__proto__:null,CommandAlreadyRegistered:p,CommandNotFound:g,ControllerAlreadyRegistered:m,ForceMethod:e}),C=Object.freeze({__proto__:null,Logger:i});class y extends s{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let o=0;s>o;++o){const s=!0===r.pop?t.pop():t[o];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new i(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new p(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new g(t);return new s(e,r)}onBefore(t,e){y.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){y.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){y.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){y.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){y.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){y.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await y.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await y.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&y.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),y.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],y.trace.pop(),this.trace.pop()}}class b extends s{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new m(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(d||(d={}));class N extends s{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new i(N.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},o={};[d.POST,d.PUT,d.PATCH].includes(e)?(Object.assign(o,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:o,body:JSON.stringify(r)})):Object.assign(s,{headers:o});const n=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await n.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class w extends y{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),w.client=new N(t.baseURL)}getClient(){return w.client}get(t,e={},r={}){return this.currentHttpMethod=d.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=d.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=d.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=d.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return d.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=d.__EMPTY__,e.result}}class A extends y{static getName(){return"Core/Managers/Internal"}}var O=Object.freeze({__proto__:null,Commands:y,Controllers:b,Data:w,Internal:A}),k=Object.freeze({__proto__:null,commandBases:h,core:u,errors:f,managerBases:O,modules:C,utils:a}),E="0.0.0-abc.1";let H=!1;function I(){if(H)throw Error("ZenCore is already initialized.")}I();let j={version:E};const _=[],$={initialize:t=>{I(),j=t||j,l.commands=new y,l.controllers=new b,l.data=new w(j),l.internal=new A,H=!0,_.forEach((t=>t()))},destroy:()=>{H=!1,l.commands={},l.controllers={},l.data={},l.internal={}},onAfterInitialize:t=>{_.push(t)},config:j,...k};globalThis?.ZenCore||(globalThis.ZenCore=$);export{h as commandBases,u as core,$ as default,f as errors,O as managerBases,C as modules,a 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(_([])));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.0",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,12 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@zenflux/core"]={})}(this,(function(t){"use strict";class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class r extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let s=0;class o{virtualId=0;static getName(){throw new e("ObjectBase","getName")}constructor(){this.virtualId=s,s++}getName(){return this.constructor.getName()}}
2
- /**
3
- * Function getCircularReplacer() : Reduce circular references.
4
- *
5
- * @copyright https://stackoverflow.com/a/53731154
6
- */
7
- const n=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},a=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),n=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);let c=255-Math.abs(r-n),l=255-Math.abs(s-a),h=255-Math.abs(o-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
8
- /**
9
- * Function hexColorDelta() : Return color difference in ratio decimal point.
10
- *
11
- * @copyright http://jsfiddle.net/96sME/
12
- */var i=Object.freeze({__proto__:null,getCircularReplacer:n,hexColorDelta:a});class c{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){c.wrappers={},c.wrapperDepth=0,c.colorsInUse=[],c.sharedData={}}static createCustomWrapper(t,e){c.wrappers[t]||(c.wrappers[t.name]=[]),c.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const 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]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(c.sharedData[this.name]||(c.sharedData[this.name]=this.getRandomColor()),this.color=c.sharedData[this.name]):(this.color=this.getRandomColor(),c.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;c.wrapperDepth++;let r={...t};return Object.values(c.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>c.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),c.wrapperDepth--,r):(c.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",c.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=c.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let o=Object.values(t)[0];"object"==typeof o?this.printNextLineObject(e,r,s,o||{}):"function"==typeof o?this.printInLineFunction(e,r,s,o):this.printInLineElement(e,r,s,o)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=c.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),n())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",c.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=c.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",c.getCallerName(),t),r&&this.printNextLineObject("tw",c.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=c.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),n()):"function"==typeof r[t]&&(e=c.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return c.colorsInUse.some((e=>a(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class l extends o{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new c(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,e=this.options){throw new r(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}const h={commands:{},controllers:{},data:{},internal:{}};var u=Object.freeze({__proto__:null,CommandBase:l,CommandData:class extends l{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new r(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return h.data.getClient().fetch(r,h.data.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends l{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends l{static getName(){return"Core/CommandBases/CommandPublic"}}});var p=Object.freeze({__proto__:null,Controller:class extends o{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=h.commands.register(this.getCommands(),this),this.data=h.data.register(this.getData(),this),this.internal=h.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:o});class g extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class m extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class d extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var f,C=Object.freeze({__proto__:null,CommandAlreadyRegistered:g,CommandNotFound:m,ControllerAlreadyRegistered:d,ForceMethod:r}),y=Object.freeze({__proto__:null,Logger:c});class b extends o{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let o=0;s>o;++o){const s=!0===r.pop?t.pop():t[o];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new c(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new g(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new m(t);return new s(e,r)}onBefore(t,e){b.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){b.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){b.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){b.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){b.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){b.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await b.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await b.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&b.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),b.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],b.trace.pop(),this.trace.pop()}}class N extends o{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new d(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(f||(f={}));class w extends o{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new c(w.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},o={};[f.POST,f.PUT,f.PATCH].includes(e)?(Object.assign(o,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:o,body:JSON.stringify(r)})):Object.assign(s,{headers:o});const n=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await n.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class O extends b{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),O.client=new w(t.baseURL)}getClient(){return O.client}get(t,e={},r={}){return this.currentHttpMethod=f.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=f.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=f.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=f.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return f.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=f.__EMPTY__,e.result}}class A extends b{static getName(){return"Core/Managers/Internal"}}var k=Object.freeze({__proto__:null,Commands:b,Controllers:N,Data:O,Internal:A}),E=Object.freeze({__proto__:null,commandBases:u,core:p,errors:C,managerBases:k,modules:y,utils:i}),j="0.0.0-abc.1";let H=!1;function I(){if(H)throw Error("ZenCore is already initialized.")}I();let _={version:j};const $=[],T={initialize:t=>{I(),_=t||_,h.commands=new b,h.controllers=new N,h.data=new O(_),h.internal=new A,H=!0,$.forEach((t=>t()))},destroy:()=>{H=!1,h.commands={},h.controllers={},h.data={},h.internal={}},onAfterInitialize:t=>{$.push(t)},config:_,...E};globalThis?.ZenCore||(globalThis.ZenCore=T),t.commandBases=u,t.core=p,t.default=T,t.errors=C,t.managerBases=k,t.modules=y,t.utils=i,Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@zenflux/core"]={})}(this,(function(t){"use strict";function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;arguments.length>n;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){l(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new N(r||[]);return o(i,"_invoke",{value:O(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}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,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return x()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=j(a,n);if(c){if(c===h)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function j(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=f(r,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,n,r,o,i){void 0===i&&(i=Promise);var a=new w(l(e,n,r,o),i);return t.isGeneratorFunction(n)?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),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,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(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}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 n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),E(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:_(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}function o(t){return o="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},o(t)}function i(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function c(t){i(a,r,o,c,u,"next",t)}function u(t){i(a,r,o,c,u,"throw",t)}c(void 0)}))}}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,C(r.key),r)}}function s(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,n){return(e=C(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(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&&p(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function v(){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 y(t,e,n){return y=v()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&p(o,n.prototype),o},y.apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return g=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,n)}function n(){return y(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)},g(t)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(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 d(t)}function b(t){var e=v();return function(){var n,r=h(t);if(e){var o=h(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return m(this,n)}}function k(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}function w(){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=k(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(3>arguments.length?t:n):o.value}},w.apply(this,arguments)}function O(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.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 j(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(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 j(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r}function C(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var E="0.0.0-alpha.0",N=function(){var t=new WeakSet;return function(e,n){if("object"===o(n)&&null!==n){if(t.has(n))return;t.add(n)}return n}},_=function(t,e){t=t.replace("#",""),e=e.replace("#","");var n=parseInt(t.substring(0,2),16),r=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(n-i),s=255-Math.abs(r-a),l=255-Math.abs(o-c);return((u/=255)+(s/=255)+(l/=255))/3},x=Object.freeze({__proto__:null,getCircularReplacer:N,hexColorDelta:_}),A=function(){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),l(this,"args",{}),l(this,"state",!1),"off"!==(null===(n=globalThis.process)||void 0===n?void 0:n.env.flow_modules_logger)&&(this.state=r,this.args=o,this.name="",this.name="string"==typeof e?e:e.constructor.name,r&&this.initialize())}return s(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(e){var r=this,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e||"object"!==o(e)||Array.isArray(e))return e;t.wrapperDepth++;var a=n({},e);return Object.values(t.wrappers).forEach((function(t){var n=O(t,1)[0];e instanceof n.classType&&(a=n.callback(e)||a)})),4>t.wrapperDepth?(i&&a&&Object.entries(a).forEach((function(t){var e=O(t,2);a[e[0]]=r.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 n="se",r=t.getCallerName();if("string"==typeof e)this.printInLineString(n,r,e);else if(1===Object.keys(e).length){var i=Object.keys(e)[0],a=Object.values(e)[0];"object"===o(a)?this.printNextLineObject(n,r,i,a||{}):"function"==typeof a?this.printInLineFunction(n,r,i,a):this.printInLineElement(n,r,i,a)}else this.printMultiLineObject(n,r,e)}}},{key:"object",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(this.state){var r=t.getCallerName();for(var i in e=Object.create(e))"object"===o(e[i])&&(e[i]=JSON.stringify(this.useWrapper(e[i]),N())),this.out.apply(this,["%c(ob)-> %c%c".concat(this.name,"%c::%c").concat(r,"%c() [").concat(n,"] ->> ").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,n){if(this.state){var r=t.getCallerName();for(var o in e)this.out.apply(this,["%c(dr)-> %c%c".concat(this.name,"%c::%c").concat(r,"%c() ->> corresponding ").concat(o,": '").concat(e[o],"' RESULT: %c↓")].concat(this.defaultStyle));this.out(n)}}},{key:"throw",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"null",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};throw this.printFunctionNotify("tw",t.getCallerName(),e),r&&this.printNextLineObject("tw",t.getCallerName(),n,r),Error().stack}},{key:"clone",value:function(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}},{key:"printFunctionNotify",value:function(t,e,n){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ").concat(n,"%c")].concat(this.defaultStyle))}},{key:"printInLineElement",value:function(t,e,n,r){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(n,": '").concat(r,"'%c")].concat(this.defaultStyle))}},{key:"printInLineFunction",value:function(e,n,r,o){o=t.getFunctionView(o),this.printInLineElement(e,n,r,o)}},{key:"printInLineString",value:function(t,e,n){this.printInLineElement(t,e,"(string)",n)}},{key:"printNextLineObject",value:function(t,e,n,r){r=this.useWrapper(r),this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(n," %c↓")].concat(this.defaultStyle)),this.out(r)}},{key:"printMultiLineObject",value:function(e,n,r){for(var i in this.out.apply(this,["%c(".concat(e,")-> %c%c").concat(this.name,"%c::%c").concat(n,"%c(").concat(Object.keys(r).join(", "),") %c↓")].concat(this.defaultStyle)),r){var a=r[i];"object"===o(a)?a=JSON.stringify(this.useWrapper(a),N()):"function"==typeof r[i]&&(a=t.getFunctionView(a)),this.out.call(this,"%c"+i+": `"+this.useWrapper(a)+"`","color: #a3a3a3")}}},{key:"getRandomColor",value:function(){for(var e="#",n=0;6>n;n++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t.colorsInUse.some((function(t){return _(e,t)>=.8}))?this.getRandomColor():e}},{key:"out",value:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];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,n){t.wrappers[e]||(t.wrappers[e.name]=[]),t.wrappers[e.name].push({classType:e,callback:n})}},{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}();l(A,"wrappers",{}),l(A,"wrapperDepth",0),l(A,"sharedData",{}),l(A,"colorsInUse",[]);var I=Object.freeze({__proto__:null,Logger:A}),L=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Command: '".concat(t.getName(),"' is already registered"))}return s(n)}(g(Error)),P=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Command: '".concat(t,"' is not found"))}return s(n)}(g(Error)),T=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Controller: '".concat(t.getName(),"' is already registered"))}return s(n)}(g(Error)),H=function(t){f(n,t);var e=b(n);function n(t,r){return c(this,n),e.call(this,"ForeMethod implementation: at '".concat(t,"' method: '").concat(r,"'"))}return s(n)}(g(Error)),S=function(t){f(n,t);var e=b(n);function n(t,r){return c(this,n),e.call(this,"ForeMethod implementation: at '".concat(t.getName(),"' method: '").concat(r,"'"))}return s(n)}(g(Error)),B=Object.freeze({__proto__:null,CommandAlreadyRegistered:L,CommandNotFound:P,ControllerAlreadyRegistered:T,ForceMethod:S}),M=0,D=function(){function t(){c(this,t),l(this,"virtualId",0),this.virtualId=M,M++}return s(t,[{key:"getName",value:function(){return this.constructor.getName()}}],[{key:"getName",value:function(){throw new H("ObjectBase","getName")}}]),t}();var R=function(t){f(p,t);var e,o,i,u,h=b(p);function p(){var t;return c(this,p),l(d(t=h.call(this)),"current",{}),l(d(t),"currentArgs",{}),l(d(t),"trace",[]),l(d(t),"commands",{}),l(d(t),"onBeforeHooks",{}),l(d(t),"onBeforeUIHooks",{}),l(d(t),"onAfterHooks",{}),l(d(t),"onAfterOnceHooks",{}),l(d(t),"onAfterUIHooks",{}),l(d(t),"onAfterAffectHooks",{}),t.logger=new A(t.getName(),!0),t.logger.startEmpty(),t}return s(p,[{key:"run",value:(u=a(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 u.apply(this,arguments)})},{key:"register",value:function(t,e){var n=this,r={};return Object.values(t).forEach((function(t){var e=t.getName();if(n.commands[e])throw new L(t);n.commands[e]=t,r[e]=t})),r}},{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]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.commands[t];if(!r)throw new P(t);return new r(e,n)}},{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]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.onBeforeHooks[t.getName()]){var r=this.onBeforeHooks[t.getName()];r.forEach((function(t){return t(e,n)}))}if(this.onBeforeUIHooks[t.getName()]){var o=this.onBeforeUIHooks[t.getName()];o.forEach((function(t){return t(e,n)}))}}},{key:"runInstance",value:(i=a(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 i.apply(this,arguments)})},{key:"onAfterRun",value:(o=a(r().mark((function t(e,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[e.getName()]){t.next=6;break}return this.onAfterAffectHooks[e.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[e.getName()]),o,i);case 10:if(!this.onAfterOnceHooks){t.next=13;break}return t.next=13,p.runCallbacks(this.onAfterOnceHooks[e.getName()],o,n(n({},i),{},{pop:!0}));case 13:return this.onAfterUIHooks&&p.runCallbacks(Object.assign([],this.onAfterUIHooks[e.getName()]),o,i),t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){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:(e=a(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 e.apply(this,arguments)})},{key:"hookCommand",value:function(t,e,n){t[e]||(t[e]=[]),t[e].push(n)}}]),p}(D);l(R,"trace",[]);var U,F=function(t){f(n,t);var e=b(n);function n(){var t;c(this,n);for(var r=arguments.length,o=Array(r),i=0;r>i;i++)o[i]=arguments[i];return l(d(t=e.call.apply(e,[this].concat(o))),"controllers",{}),t}return s(n,[{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 T(t);return this.controllers[t.getName()]=t,t}}],[{key:"getName",value:function(){return"Core/Managers/Controllers"}}]),n}(D);!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 z=function(t){f(o,t);var e,n=b(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"http://localhost";return c(this,o),(t=n.call(this)).logger=new A(o.getName(),!0),t.logger.startWith({apiBaseUrl:e}),t.apiBaseUrl=e+"/",t}return s(o,[{key:"fetch",value:(e=a(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,n){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Clients/Http"}}]),o}(D),W=function(t){f(o,t);var e,n=b(o);function o(t){var e;return c(this,o),e=n.call(this),o.client=new z(t.baseURL),e}return s(o,[{key:"getClient",value:function(){return o.client}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.GET,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.PATCH,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.DELETE,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"create",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.POST,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"runInstance",value:(e=a(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,w(h(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}(R),G=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/Managers/Internal"}}]),n}(R),Y=[];function J(t){Z=new R,q=new F,K=new W(t),$=new G}function V(){Z={},q={},K={},$={}}var Z={},q={},K={},$={},Q=Object.freeze({__proto__:null,afterInitializeCallbacks:Y,get commands(){return Z},get controllers(){return q},get data(){return K},destroy:V,initialize:J,get internal(){return $}}),X=function(t){f(o,t);var e,n=b(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]:{};c(this,o),l(d(t=n.call(this)),"args",{}),l(d(t),"options",{});var i=t.constructor.getName();return t.logger=new A(i,!0,{sameColor:!0}),t.logger.startWith({args:e,options:r}),t.initialize(e,r),t}return s(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=a(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}(D),tt=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandPublic"}}]),n}(X),et=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,[{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 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 n=t.match("\\{(.*?)\\}");return null!=n&&n.length&&void 0!==e[n[1]]?e[n[1]]:t})).join("/")),t}}],[{key:"getName",value:function(){return"Core/CommandBases/CommandData"}}]),n}(X),nt=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandInternal"}}]),n}(X),rt=Object.freeze({__proto__:null,CommandBase:X,CommandData:et,CommandInternal:nt,CommandPublic:tt}),ot=Object.freeze({__proto__:null,Controller:function(t){f(n,t);var e=b(n);function n(){var t;return c(this,n),(t=e.call(this)).initialize(),t}return s(n,[{key:"initialize",value:function(){this.register(),this.setupHooks&&this.setupHooks()}},{key:"register",value:function(){this.commands=Z.register(this.getCommands(),this),this.data=K.register(this.getData(),this),this.internal=$.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"}}]),n}(D),ObjectBase:D}),it=Object.freeze({__proto__:null,Commands:R,Controllers:F,Data:W,Internal:G}),at=Object.freeze({__proto__:null,commandBases:rt,core:ot,errors:B,managerBases:it,managers:Q,modules:I,utils:x}),ct=!1;function ut(){if(ct)throw Error("ZenCore is already initialized.")}ut();var st={version:E},lt=n({initialize:function(t){ut(),J(st=t||st),ct=!0},destroy:function(){V(),ct=!1},onAfterInitialize:function(t){Y.push(t)},config:st},at);null!==globalThis&&void 0!==globalThis&&globalThis.ZenCore||(globalThis.ZenCore=lt),t.commandBases=rt,t.core=ot,t.default=lt,t.errors=B,t.managerBases=it,t.managers=Q,t.modules=I,t.utils=x,Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,55 +1,48 @@
1
1
  {
2
2
  "name": "@zenflux/core",
3
- "version": "0.0.0-abc.2",
3
+ "version": "0.0.0-abc.24",
4
4
  "description": "ZenFlux core",
5
- "author": "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)",
6
- "scripts": {
7
- "test": "export flow_modules_logger=off && jest",
8
- "build": "rollup --config rollup.config.ts --configPlugin typescript"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/zenflux/core.git"
13
- },
14
5
  "keywords": [
15
6
  "zenflux",
16
7
  "zen",
17
8
  "flux",
18
9
  "commands",
19
10
  "manager",
20
- "commands manager"
21
- ],
22
- "files": [
23
- "dist",
24
- "src",
25
- "types"
11
+ "commands manager",
12
+ "core",
13
+ "zenflux-core"
26
14
  ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/zenflux/core.git"
18
+ },
27
19
  "license": "MIT",
20
+ "author": "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)",
28
21
  "main": "dist/cjs/zenflux-core.js",
29
22
  "unpkg": "dist/umd/zenflux-core.js",
30
23
  "module": "dist/es/zenflux-core.js",
31
24
  "types": "types/index.d.ts",
25
+ "files": [
26
+ "dist",
27
+ "src",
28
+ "types"
29
+ ],
30
+ "scripts": {
31
+ "test": "export flow_modules_logger=off && jest",
32
+ "toolkit-build": "node_modules/@zenflux/rollup-toolkit/bin/run @build",
33
+ "toolkit-build-dev": "node_modules/@zenflux/rollup-toolkit/bin/dev @build",
34
+ "toolkit-watch": "node_modules/@zenflux/rollup-toolkit/bin/run @watch",
35
+ "toolkit-watch-dev": "node_modules/@zenflux/rollup-toolkit/bin/dev @watch"
36
+ },
32
37
  "devDependencies": {
33
- "@babel/core": "^7.20.7",
34
- "@babel/plugin-transform-runtime": "^7.19.6",
35
38
  "@babel/preset-env": "^7.20.2",
36
39
  "@babel/preset-typescript": "^7.18.6",
37
- "@babel/runtime": "^7.20.7",
38
- "@rollup/plugin-babel": "^6.0.3",
39
- "@rollup/plugin-json": "^6.0.0",
40
- "@rollup/plugin-node-resolve": "^15.0.1",
41
- "@rollup/plugin-replace": "^5.0.2",
42
- "@rollup/plugin-terser": "^0.2.1",
43
- "@rollup/plugin-typescript": "^10.0.1",
44
40
  "@types/jest": "^29.2.5",
45
41
  "@typescript-eslint/eslint-plugin": "^5.48.0",
46
42
  "@typescript-eslint/parser": "^5.48.0",
43
+ "@zenflux/rollup-toolkit": "^0.0.0-alpha.0",
47
44
  "babel-jest": "^29.3.1",
48
- "rollup": "^3.9.1",
49
45
  "ts-jest": "^29.0.3",
50
46
  "tslib": "^2.4.1"
51
- },
52
- "dependencies": {
53
- "@babel/runtime": "^7.19.0"
54
47
  }
55
48
  }
@@ -5,7 +5,7 @@
5
5
  import { ForceMethod } from '../errors/force-method';
6
6
  import { CommandBase } from './command-base';
7
7
 
8
- import managers from '../managers/';
8
+ import * as managers from '../managers';
9
9
 
10
10
  export abstract class CommandData extends CommandBase {
11
11
  static getName() {
@@ -6,7 +6,7 @@ import ObjectBase from "./object-base";
6
6
 
7
7
  import { CommandData, CommandInternal, CommandPublic } from "../command-bases";
8
8
 
9
- import managers from "../managers/";
9
+ import * as managers from "../managers/";
10
10
 
11
11
  export abstract class Controller extends ObjectBase {
12
12
  commands: { [ key: string ]: typeof CommandPublic };
package/src/exports.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  export * as commandBases from "./command-bases";
5
5
  export * as core from "./core";
6
6
  export * as errors from "./errors";
7
+ export * as managers from "./managers";
7
8
  export * as managerBases from "./manager-bases";
8
9
  export * as modules from "./modules";
9
10
  export * as utils from "./utils";
10
-
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
+ export { CoreAPI as default } from "./initializer";
5
+
4
6
  export * from './exports';
5
7
 
6
- export { CoreAPI as default } from "./initializer";
7
8
 
@@ -1,10 +1,11 @@
1
1
  import pkg from "../package.json";
2
2
 
3
- import * as exported from './exports';
4
- import managers from './managers';
5
-
6
3
  import { IAPIConfig } from "./interfaces/config";
7
4
 
5
+ import { destroy, initialize, afterInitializeCallbacks } from "./managers";
6
+
7
+ import * as exported from './exports';
8
+
8
9
  declare global {
9
10
  var ZenCore: any;
10
11
  }
@@ -23,7 +24,6 @@ export let config: IAPIConfig = {
23
24
  version: pkg.version,
24
25
  }
25
26
 
26
- const afterInitializeCallbacks: ( () => void )[] = [];
27
27
 
28
28
  export const CoreAPI = {
29
29
  initialize: ( configuration?: IAPIConfig ) => {
@@ -31,23 +31,16 @@ export const CoreAPI = {
31
31
 
32
32
  config = configuration || config;
33
33
 
34
- managers.commands = new exported.managerBases.Commands();
35
- managers.controllers = new exported.managerBases.Controllers();
36
- managers.data = new exported.managerBases.Data( config );
37
- managers.internal = new exported.managerBases.Internal();
34
+ initialize( config )
38
35
 
39
36
  isInitialized = true;
40
37
 
41
- afterInitializeCallbacks.forEach( ( callback ) => callback() );
42
38
  },
43
39
 
44
40
  destroy: () => {
45
- isInitialized = false;
41
+ destroy();
46
42
 
47
- managers.commands = {} as exported.managerBases.Commands;
48
- managers.controllers = {} as exported.managerBases.Controllers
49
- managers.data = {} as exported.managerBases.Data;
50
- managers.internal = {} as exported.managerBases.Internal;
43
+ isInitialized = false;
51
44
  },
52
45
 
53
46
  onAfterInitialize: ( callback: () => void ) => {
@@ -0,0 +1,16 @@
1
+ import Commands from "../manager-bases/commands";
2
+ import Controllers from "../manager-bases/controllers";
3
+ import Data from "../manager-bases/data";
4
+ import Internal from "../manager-bases/internal";
5
+
6
+ import { IAPIConfig } from "./config";
7
+
8
+ export interface IManagers {
9
+ initialize: ( config: IAPIConfig ) => void;
10
+ destroy: () => void;
11
+
12
+ commands: Commands;
13
+ controllers: Controllers;
14
+ data: Data;
15
+ internal: Internal;
16
+ }
@@ -4,9 +4,11 @@
4
4
  */
5
5
  import { Logger } from "../modules/";
6
6
  import { CommandBase } from "../command-bases";
7
- import { Controller, ObjectBase } from "../core";
8
7
  import { CommandAlreadyRegistered, CommandNotFound } from "../errors/";
9
8
 
9
+ import ObjectBase from "../core/object-base";
10
+ import Controller from "../core/controller";
11
+
10
12
  import {
11
13
  ICommandArgsInterface,
12
14
  CommandCallbackType,
@@ -2,7 +2,8 @@
2
2
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description: Responsible for manging controllers, each controller is global singleton instance.
4
4
  */
5
- import { Controller, ObjectBase } from "../core";
5
+ import ObjectBase from "../core/object-base";
6
+ import Controller from "../core/controller";
6
7
 
7
8
  import { ControllerAlreadyRegistered } from "../errors/controller-already-registered";
8
9
 
@@ -1,13 +1,30 @@
1
1
  /**
2
2
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import * as managersBases from "../manager-bases";
4
+ import Commands from "../manager-bases/commands";
5
+ import Controllers from "../manager-bases/controllers";
6
+ import Data from "../manager-bases/data";
7
+ import Internal from "../manager-bases/internal";
5
8
 
6
- export const managers = {
7
- commands: {} as managersBases.Commands,
8
- controllers: {} as managersBases.Controllers,
9
- data: {} as managersBases.Data,
10
- internal: {} as managersBases.Internal,
9
+ import { IAPIConfig } from "../interfaces/config";
10
+
11
+ export const afterInitializeCallbacks: ( () => void )[] = [];
12
+
13
+ export function initialize( config: IAPIConfig ) {
14
+ commands = new Commands();
15
+ controllers = new Controllers();
16
+ data = new Data( config );
17
+ internal = new Internal();
18
+ }
19
+
20
+ export function destroy() {
21
+ commands = {} as Commands;
22
+ controllers = {} as Controllers;
23
+ data = {} as Data;
24
+ internal = {} as Internal;
11
25
  }
12
26
 
13
- export default managers;
27
+ export var commands = {} as Commands;
28
+ export var controllers = {} as Controllers;
29
+ export var data = {} as Data;
30
+ export var internal = {} as Internal;
package/types/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
- export * from '../dist/es/src/exports';
2
1
  export { initialize, destroy, onAfterInitialize } from "../dist/es/src/initializer";
2
+
3
+ export * from '../dist/es/src/exports';
4
+
5
+ export * as managers from "../dist/es/src/managers";
6
+