@zenflux/core 0.0.0-abc.13 → 0.0.0-abc.15

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@zenflux/core";
6
- var version = "0.0.0-abc.12";
6
+ var version = "0.0.0-abc.14";
7
7
  var description = "ZenFlux core";
8
8
  var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
9
9
  var scripts = {
@@ -74,6 +74,17 @@ var pkg = {
74
74
  dependencies: dependencies
75
75
  };
76
76
 
77
+ if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
78
+ globalThis.__ZEN_MANAGERS__ = {
79
+ initialize: () => {},
80
+ destroy: () => {},
81
+ commands: {},
82
+ controllers: {},
83
+ data: {},
84
+ internal: {}
85
+ };
86
+ }
87
+
77
88
  /**
78
89
  * Function getCircularReplacer() : Reduce circular references.
79
90
  *
@@ -904,15 +915,7 @@ class Internal extends Commands {
904
915
  /**
905
916
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
906
917
  */
907
- if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
908
- // @ts-ignore
909
- globalThis.__ZEN_MANAGERS__ = {
910
- commands: {},
911
- controllers: {},
912
- data: {},
913
- internal: {}
914
- };
915
- }
918
+ const afterInitializeCallbacks = [];
916
919
  function initialize(config) {
917
920
  __ZEN_MANAGERS__.commands = new Commands();
918
921
  __ZEN_MANAGERS__.controllers = new Controllers();
@@ -929,9 +932,12 @@ const controllers = __ZEN_MANAGERS__.controllers;
929
932
  const commands = __ZEN_MANAGERS__.commands;
930
933
  const data = __ZEN_MANAGERS__.data;
931
934
  const internal = __ZEN_MANAGERS__.internal;
935
+ __ZEN_MANAGERS__.initialize = initialize;
936
+ __ZEN_MANAGERS__.destroy = destroy;
932
937
 
933
938
  var index$2 = /*#__PURE__*/Object.freeze({
934
939
  __proto__: null,
940
+ afterInitializeCallbacks: afterInitializeCallbacks,
935
941
  commands: commands,
936
942
  controllers: controllers,
937
943
  data: data,
@@ -1091,14 +1097,12 @@ errorInitTwice();
1091
1097
  let config = {
1092
1098
  version: pkg.version
1093
1099
  };
1094
- const afterInitializeCallbacks = [];
1095
1100
  const CoreAPI = {
1096
1101
  initialize: configuration => {
1097
1102
  errorInitTwice();
1098
1103
  config = configuration || config;
1099
1104
  initialize(config);
1100
1105
  isInitialized = true;
1101
- afterInitializeCallbacks.forEach(callback => callback());
1102
1106
  },
1103
1107
  destroy: () => {
1104
1108
  destroy();
@@ -7,6 +7,8 @@ declare global {
7
7
  }
8
8
  declare global {
9
9
  var __ZEN_MANAGERS__: {
10
+ initialize: (config: any) => void;
11
+ destroy: () => void;
10
12
  commands: Commands;
11
13
  controllers: Controllers;
12
14
  data: Data;
@@ -1,11 +1,11 @@
1
+ import './globals';
1
2
  import { IAPIConfig } from "./interfaces/config";
2
3
  import * as exported from './exports';
3
- declare global {
4
- var ZenCore: any;
5
- }
6
4
  export declare let config: IAPIConfig;
7
5
  export declare const CoreAPI: {
8
6
  managers: {
7
+ initialize: (config: any) => void;
8
+ destroy: () => void;
9
9
  commands: exported.managerBases.Commands;
10
10
  controllers: exported.managerBases.Controllers;
11
11
  data: exported.managerBases.Data;
@@ -0,0 +1,13 @@
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
+ import { IAPIConfig } from "./config";
6
+ export interface IManagers {
7
+ initialize: (config: IAPIConfig) => void;
8
+ destroy: () => void;
9
+ commands: Commands;
10
+ controllers: Controllers;
11
+ data: Data;
12
+ internal: Internal;
13
+ }
@@ -6,14 +6,8 @@ import Controllers from "../manager-bases/controllers";
6
6
  import Data from "../manager-bases/data";
7
7
  import Internal from "../manager-bases/internal";
8
8
  import { IAPIConfig } from "../interfaces/config";
9
- declare global {
10
- var __ZEN_MANAGERS__: {
11
- commands: Commands;
12
- controllers: Controllers;
13
- data: Data;
14
- internal: Internal;
15
- };
16
- }
9
+ import '../globals';
10
+ export declare const afterInitializeCallbacks: (() => void)[];
17
11
  export declare function initialize(config: IAPIConfig): void;
18
12
  export declare function destroy(): void;
19
13
  export declare const controllers: Controllers;
@@ -1,5 +1,5 @@
1
1
  var name = "@zenflux/core";
2
- var version = "0.0.0-abc.12";
2
+ var version = "0.0.0-abc.14";
3
3
  var description = "ZenFlux core";
4
4
  var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
5
5
  var scripts = {
@@ -70,6 +70,17 @@ var pkg = {
70
70
  dependencies: dependencies
71
71
  };
72
72
 
73
+ if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
74
+ globalThis.__ZEN_MANAGERS__ = {
75
+ initialize: () => {},
76
+ destroy: () => {},
77
+ commands: {},
78
+ controllers: {},
79
+ data: {},
80
+ internal: {}
81
+ };
82
+ }
83
+
73
84
  /**
74
85
  * Function getCircularReplacer() : Reduce circular references.
75
86
  *
@@ -900,15 +911,7 @@ class Internal extends Commands {
900
911
  /**
901
912
  * @author: Leonid Vinikov <leonidvinikov@gmail.com>
902
913
  */
903
- if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
904
- // @ts-ignore
905
- globalThis.__ZEN_MANAGERS__ = {
906
- commands: {},
907
- controllers: {},
908
- data: {},
909
- internal: {}
910
- };
911
- }
914
+ const afterInitializeCallbacks = [];
912
915
  function initialize(config) {
913
916
  __ZEN_MANAGERS__.commands = new Commands();
914
917
  __ZEN_MANAGERS__.controllers = new Controllers();
@@ -925,9 +928,12 @@ const controllers = __ZEN_MANAGERS__.controllers;
925
928
  const commands = __ZEN_MANAGERS__.commands;
926
929
  const data = __ZEN_MANAGERS__.data;
927
930
  const internal = __ZEN_MANAGERS__.internal;
931
+ __ZEN_MANAGERS__.initialize = initialize;
932
+ __ZEN_MANAGERS__.destroy = destroy;
928
933
 
929
934
  var index$2 = /*#__PURE__*/Object.freeze({
930
935
  __proto__: null,
936
+ afterInitializeCallbacks: afterInitializeCallbacks,
931
937
  commands: commands,
932
938
  controllers: controllers,
933
939
  data: data,
@@ -1087,14 +1093,12 @@ errorInitTwice();
1087
1093
  let config = {
1088
1094
  version: pkg.version
1089
1095
  };
1090
- const afterInitializeCallbacks = [];
1091
1096
  const CoreAPI = {
1092
1097
  initialize: configuration => {
1093
1098
  errorInitTwice();
1094
1099
  config = configuration || config;
1095
1100
  initialize(config);
1096
1101
  isInitialized = true;
1097
- afterInitializeCallbacks.forEach(callback => callback());
1098
1102
  },
1099
1103
  destroy: () => {
1100
1104
  destroy();
@@ -1,12 +1,11 @@
1
- var t="0.0.0-abc.12";
1
+ var t="0.0.0-abc.14";"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={initialize:()=>{},destroy:()=>{},commands:{},controllers:{},data:{},internal:{}})
2
2
  /**
3
3
  * Function getCircularReplacer() : Reduce circular references.
4
4
  *
5
5
  * @copyright https://stackoverflow.com/a/53731154
6
- */
7
- const e=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},r=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=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-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
6
+ */;const e=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},r=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=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-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
8
7
  /**
9
8
  * Function hexColorDelta() : Return color difference in ratio decimal point.
10
9
  *
11
10
  * @copyright http://jsfiddle.net/96sME/
12
- */var s=Object.freeze({__proto__:null,getCircularReplacer:e,hexColorDelta:r});class n{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){n.wrappers={},n.wrapperDepth=0,n.colorsInUse=[],n.sharedData={}}static createCustomWrapper(t,e){n.wrappers[t]||(n.wrappers[t.name]=[]),n.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?(n.sharedData[this.name]||(n.sharedData[this.name]=this.getRandomColor()),this.color=n.sharedData[this.name]):(this.color=this.getRandomColor(),n.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;n.wrapperDepth++;let r={...t};return Object.values(n.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>n.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),n.wrapperDepth--,r):(n.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",n.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=n.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},r=""){if(!this.state)return;const s=n.getCallerName();t=Object.create(t);for(let n in t)"object"==typeof t[n]&&(t[n]=JSON.stringify(this.useWrapper(t[n]),e())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${s}%c() [${r}] ->> ${n}: '${t[n]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",n.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=n.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",n.getCallerName(),t),r&&this.printNextLineObject("tw",n.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=n.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,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${r}%c(${Object.keys(s).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in s){let r=s[t];"object"==typeof r?r=JSON.stringify(this.useWrapper(r),e()):"function"==typeof s[t]&&(r=n.getFunctionView(r)),this.out.call(this,"%c"+t+": `"+this.useWrapper(r)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return n.colorsInUse.some((e=>r(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}var o=Object.freeze({__proto__:null,Logger:n});class a extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class i extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let c=0;class l{virtualId=0;static getName(){throw new a("ObjectBase","getName")}constructor(){this.virtualId=c,c++}getName(){return this.constructor.getName()}}var h=Object.freeze({__proto__:null,Controller:class extends l{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:l});class u extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class p extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class g extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var m,d=Object.freeze({__proto__:null,CommandAlreadyRegistered:u,CommandNotFound:p,ControllerAlreadyRegistered:g,ForceMethod:i});class _ extends l{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 n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];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 n(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 u(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 p(t);return new s(e,r)}onBefore(t,e){_.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){_.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){_.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){_.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){_.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){_.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 _.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await _.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&_.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()),_.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],_.trace.pop(),this.trace.pop()}}class f extends l{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 g(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__=""}(m||(m={}));class N extends l{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new n(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"},n={};[m.POST,m.PUT,m.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.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 A extends _{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),A.client=new N(t.baseURL)}getClient(){return A.client}get(t,e={},r={}){return this.currentHttpMethod=m.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=m.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=m.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=m.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 m.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=m.__EMPTY__,e.result}}class E extends _{static getName(){return"Core/Managers/Internal"}}function C(t){__ZEN_MANAGERS__.commands=new _,__ZEN_MANAGERS__.controllers=new f,__ZEN_MANAGERS__.data=new A(t),__ZEN_MANAGERS__.internal=new E}function y(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}}"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={commands:{},controllers:{},data:{},internal:{}});const b=__ZEN_MANAGERS__.controllers,w=__ZEN_MANAGERS__.commands,O=__ZEN_MANAGERS__.data,M=__ZEN_MANAGERS__.internal;var k=Object.freeze({__proto__:null,commands:w,controllers:b,data:O,destroy:y,initialize:C,internal:M});class H extends l{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new n(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 i(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}}var j=Object.freeze({__proto__:null,CommandBase:H,CommandData:class extends H{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new i(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.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 H{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends H{static getName(){return"Core/CommandBases/CommandPublic"}}}),I=Object.freeze({__proto__:null,Commands:_,Controllers:f,Data:A,Internal:E}),S=Object.freeze({__proto__:null,commandBases:j,core:h,errors:d,managerBases:I,managers:k,modules:o,utils:s});let R=!1;function $(){if(R)throw Error("ZenCore is already initialized.")}$();let B={version:t};const T=[],G={initialize:t=>{$(),B=t||B,C(B),R=!0,T.forEach((t=>t()))},destroy:()=>{y(),R=!1},onAfterInitialize:t=>{T.push(t)},config:B,...S,managers:"undefined"!=typeof __ZEN_MANAGERS__?__ZEN_MANAGERS__:void 0};globalThis?.ZenCore||(globalThis.ZenCore=G);export{j as commandBases,h as core,G as default,d as errors,I as managerBases,k as managers,o as modules,s as utils};
11
+ */var s=Object.freeze({__proto__:null,getCircularReplacer:e,hexColorDelta:r});class n{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){n.wrappers={},n.wrapperDepth=0,n.colorsInUse=[],n.sharedData={}}static createCustomWrapper(t,e){n.wrappers[t]||(n.wrappers[t.name]=[]),n.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?(n.sharedData[this.name]||(n.sharedData[this.name]=this.getRandomColor()),this.color=n.sharedData[this.name]):(this.color=this.getRandomColor(),n.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;n.wrapperDepth++;let r={...t};return Object.values(n.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>n.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),n.wrapperDepth--,r):(n.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",n.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=n.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},r=""){if(!this.state)return;const s=n.getCallerName();t=Object.create(t);for(let n in t)"object"==typeof t[n]&&(t[n]=JSON.stringify(this.useWrapper(t[n]),e())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${s}%c() [${r}] ->> ${n}: '${t[n]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",n.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=n.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",n.getCallerName(),t),r&&this.printNextLineObject("tw",n.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=n.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,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${r}%c(${Object.keys(s).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in s){let r=s[t];"object"==typeof r?r=JSON.stringify(this.useWrapper(r),e()):"function"==typeof s[t]&&(r=n.getFunctionView(r)),this.out.call(this,"%c"+t+": `"+this.useWrapper(r)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return n.colorsInUse.some((e=>r(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}var o=Object.freeze({__proto__:null,Logger:n});class a extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class i extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let c=0;class l{virtualId=0;static getName(){throw new a("ObjectBase","getName")}constructor(){this.virtualId=c,c++}getName(){return this.constructor.getName()}}var h=Object.freeze({__proto__:null,Controller:class extends l{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:l});class u extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class p extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class g extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var m,d=Object.freeze({__proto__:null,CommandAlreadyRegistered:u,CommandNotFound:p,ControllerAlreadyRegistered:g,ForceMethod:i});class _ extends l{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 n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];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 n(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 u(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 p(t);return new s(e,r)}onBefore(t,e){_.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){_.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){_.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){_.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){_.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){_.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 _.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await _.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&_.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()),_.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],_.trace.pop(),this.trace.pop()}}class f extends l{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 g(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__=""}(m||(m={}));class N extends l{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new n(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"},n={};[m.POST,m.PUT,m.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.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 A extends _{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),A.client=new N(t.baseURL)}getClient(){return A.client}get(t,e={},r={}){return this.currentHttpMethod=m.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=m.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=m.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=m.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 m.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=m.__EMPTY__,e.result}}class E extends _{static getName(){return"Core/Managers/Internal"}}const C=[];function y(t){__ZEN_MANAGERS__.commands=new _,__ZEN_MANAGERS__.controllers=new f,__ZEN_MANAGERS__.data=new A(t),__ZEN_MANAGERS__.internal=new E}function b(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}}const w=__ZEN_MANAGERS__.controllers,O=__ZEN_MANAGERS__.commands,M=__ZEN_MANAGERS__.data,k=__ZEN_MANAGERS__.internal;__ZEN_MANAGERS__.initialize=y,__ZEN_MANAGERS__.destroy=b;var H=Object.freeze({__proto__:null,afterInitializeCallbacks:C,commands:O,controllers:w,data:M,destroy:b,initialize:y,internal:k});class I extends l{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new n(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 i(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}}var j=Object.freeze({__proto__:null,CommandBase:I,CommandData:class extends I{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new i(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.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 I{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends I{static getName(){return"Core/CommandBases/CommandPublic"}}}),S=Object.freeze({__proto__:null,Commands:_,Controllers:f,Data:A,Internal:E}),R=Object.freeze({__proto__:null,commandBases:j,core:h,errors:d,managerBases:S,managers:H,modules:o,utils:s});let $=!1;function B(){if($)throw Error("ZenCore is already initialized.")}B();let T={version:t};const G={initialize:t=>{B(),T=t||T,y(T),$=!0},destroy:()=>{b(),$=!1},onAfterInitialize:t=>{C.push(t)},config:T,...R,managers:"undefined"!=typeof __ZEN_MANAGERS__?__ZEN_MANAGERS__:void 0};globalThis?.ZenCore||(globalThis.ZenCore=G);export{j as commandBases,h as core,G as default,d as errors,S as managerBases,H as managers,o as modules,s as utils};
@@ -1,12 +1,11 @@
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";var e="0.0.0-abc.12";
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";var e="0.0.0-abc.14";"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={initialize:()=>{},destroy:()=>{},commands:{},controllers:{},data:{},internal:{}})
2
2
  /**
3
3
  * Function getCircularReplacer() : Reduce circular references.
4
4
  *
5
5
  * @copyright https://stackoverflow.com/a/53731154
6
- */
7
- const r=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},s=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=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-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
6
+ */;const r=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},s=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=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-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
8
7
  /**
9
8
  * Function hexColorDelta() : Return color difference in ratio decimal point.
10
9
  *
11
10
  * @copyright http://jsfiddle.net/96sME/
12
- */var n=Object.freeze({__proto__:null,getCircularReplacer:r,hexColorDelta:s});class o{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){o.wrappers={},o.wrapperDepth=0,o.colorsInUse=[],o.sharedData={}}static createCustomWrapper(t,e){o.wrappers[t]||(o.wrappers[t.name]=[]),o.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?(o.sharedData[this.name]||(o.sharedData[this.name]=this.getRandomColor()),this.color=o.sharedData[this.name]):(this.color=this.getRandomColor(),o.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;o.wrapperDepth++;let r={...t};return Object.values(o.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>o.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),o.wrapperDepth--,r):(o.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",o.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=o.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const s=o.getCallerName();t=Object.create(t);for(let n in t)"object"==typeof t[n]&&(t[n]=JSON.stringify(this.useWrapper(t[n]),r())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${s}%c() [${e}] ->> ${n}: '${t[n]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",o.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=o.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",o.getCallerName(),t),r&&this.printNextLineObject("tw",o.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=o.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,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(s).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in s){let e=s[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),r()):"function"==typeof s[t]&&(e=o.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 o.colorsInUse.some((e=>s(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}var a=Object.freeze({__proto__:null,Logger:o});class i extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class c extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let l=0;class h{virtualId=0;static getName(){throw new i("ObjectBase","getName")}constructor(){this.virtualId=l,l++}getName(){return this.constructor.getName()}}var u=Object.freeze({__proto__:null,Controller:class extends h{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:h});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,_=Object.freeze({__proto__:null,CommandAlreadyRegistered:p,CommandNotFound:g,ControllerAlreadyRegistered:m,ForceMethod:c});class f extends h{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 n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];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 o(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){f.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){f.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){f.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){f.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){f.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){f.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 f.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await f.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&f.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()),f.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],f.trace.pop(),this.trace.pop()}}class N extends h{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 A extends h{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new o(A.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"},n={};[d.POST,d.PUT,d.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.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 E extends f{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),E.client=new A(t.baseURL)}getClient(){return E.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 y extends f{static getName(){return"Core/Managers/Internal"}}function C(t){__ZEN_MANAGERS__.commands=new f,__ZEN_MANAGERS__.controllers=new N,__ZEN_MANAGERS__.data=new E(t),__ZEN_MANAGERS__.internal=new y}function b(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}}"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={commands:{},controllers:{},data:{},internal:{}});const w=__ZEN_MANAGERS__.controllers,O=__ZEN_MANAGERS__.commands,M=__ZEN_MANAGERS__.data,k=__ZEN_MANAGERS__.internal;var j=Object.freeze({__proto__:null,commands:O,controllers:w,data:M,destroy:b,initialize:C,internal:k});class H extends h{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new o(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 c(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}}var I=Object.freeze({__proto__:null,CommandBase:H,CommandData:class extends H{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new c(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.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 H{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends H{static getName(){return"Core/CommandBases/CommandPublic"}}}),S=Object.freeze({__proto__:null,Commands:f,Controllers:N,Data:E,Internal:y}),R=Object.freeze({__proto__:null,commandBases:I,core:u,errors:_,managerBases:S,managers:j,modules:a,utils:n});let T=!1;function $(){if(T)throw Error("ZenCore is already initialized.")}$();let B={version:e};const G=[],x={initialize:t=>{$(),B=t||B,C(B),T=!0,G.forEach((t=>t()))},destroy:()=>{b(),T=!1},onAfterInitialize:t=>{G.push(t)},config:B,...R,managers:"undefined"!=typeof __ZEN_MANAGERS__?__ZEN_MANAGERS__:void 0};globalThis?.ZenCore||(globalThis.ZenCore=x),t.commandBases=I,t.core=u,t.default=x,t.errors=_,t.managerBases=S,t.managers=j,t.modules=a,t.utils=n,Object.defineProperty(t,"__esModule",{value:!0})}));
11
+ */var n=Object.freeze({__proto__:null,getCircularReplacer:r,hexColorDelta:s});class o{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){o.wrappers={},o.wrapperDepth=0,o.colorsInUse=[],o.sharedData={}}static createCustomWrapper(t,e){o.wrappers[t]||(o.wrappers[t.name]=[]),o.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?(o.sharedData[this.name]||(o.sharedData[this.name]=this.getRandomColor()),this.color=o.sharedData[this.name]):(this.color=this.getRandomColor(),o.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;o.wrapperDepth++;let r={...t};return Object.values(o.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>o.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),o.wrapperDepth--,r):(o.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",o.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=o.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const s=o.getCallerName();t=Object.create(t);for(let n in t)"object"==typeof t[n]&&(t[n]=JSON.stringify(this.useWrapper(t[n]),r())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${s}%c() [${e}] ->> ${n}: '${t[n]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",o.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=o.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",o.getCallerName(),t),r&&this.printNextLineObject("tw",o.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=o.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,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(s).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in s){let e=s[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),r()):"function"==typeof s[t]&&(e=o.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 o.colorsInUse.some((e=>s(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}var a=Object.freeze({__proto__:null,Logger:o});class i extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class c extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let l=0;class h{virtualId=0;static getName(){throw new i("ObjectBase","getName")}constructor(){this.virtualId=l,l++}getName(){return this.constructor.getName()}}var u=Object.freeze({__proto__:null,Controller:class extends h{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:h});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,_=Object.freeze({__proto__:null,CommandAlreadyRegistered:p,CommandNotFound:g,ControllerAlreadyRegistered:m,ForceMethod:c});class f extends h{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 n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];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 o(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){f.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){f.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){f.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){f.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){f.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){f.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 f.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await f.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&f.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()),f.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],f.trace.pop(),this.trace.pop()}}class N extends h{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 A extends h{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new o(A.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"},n={};[d.POST,d.PUT,d.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.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 E extends f{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),E.client=new A(t.baseURL)}getClient(){return E.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 y extends f{static getName(){return"Core/Managers/Internal"}}const C=[];function b(t){__ZEN_MANAGERS__.commands=new f,__ZEN_MANAGERS__.controllers=new N,__ZEN_MANAGERS__.data=new E(t),__ZEN_MANAGERS__.internal=new y}function w(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}}const O=__ZEN_MANAGERS__.controllers,M=__ZEN_MANAGERS__.commands,k=__ZEN_MANAGERS__.data,j=__ZEN_MANAGERS__.internal;__ZEN_MANAGERS__.initialize=b,__ZEN_MANAGERS__.destroy=w;var H=Object.freeze({__proto__:null,afterInitializeCallbacks:C,commands:M,controllers:O,data:k,destroy:w,initialize:b,internal:j});class I extends h{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new o(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 c(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}}var S=Object.freeze({__proto__:null,CommandBase:I,CommandData:class extends I{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new c(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.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 I{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends I{static getName(){return"Core/CommandBases/CommandPublic"}}}),R=Object.freeze({__proto__:null,Commands:f,Controllers:N,Data:E,Internal:y}),T=Object.freeze({__proto__:null,commandBases:S,core:u,errors:_,managerBases:R,managers:H,modules:a,utils:n});let $=!1;function B(){if($)throw Error("ZenCore is already initialized.")}B();let G={version:e};const Z={initialize:t=>{B(),G=t||G,b(G),$=!0},destroy:()=>{w(),$=!1},onAfterInitialize:t=>{C.push(t)},config:G,...T,managers:"undefined"!=typeof __ZEN_MANAGERS__?__ZEN_MANAGERS__:void 0};globalThis?.ZenCore||(globalThis.ZenCore=Z),t.commandBases=S,t.core=u,t.default=Z,t.errors=_,t.managerBases=R,t.managers=H,t.modules=a,t.utils=n,Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenflux/core",
3
- "version": "0.0.0-abc.13",
3
+ "version": "0.0.0-abc.15",
4
4
  "description": "ZenFlux core",
5
5
  "author": "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)",
6
6
  "scripts": {
package/src/globals.ts ADDED
@@ -0,0 +1,34 @@
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 { IManagers } from "./interfaces/managers";
7
+
8
+ if ( typeof __ZEN_MANAGERS__ === 'undefined' || ! __ZEN_MANAGERS__ ) {
9
+ globalThis.__ZEN_MANAGERS__ = {
10
+ initialize: () => {},
11
+ destroy: () => {},
12
+
13
+ commands: {} as Commands,
14
+ controllers: {} as Controllers,
15
+ data: {} as Data,
16
+ internal: {} as Internal,
17
+ } as IManagers;
18
+ }
19
+
20
+ declare global {
21
+ var ZenCore: any;
22
+ }
23
+
24
+ declare global {
25
+ var __ZEN_MANAGERS__: {
26
+ initialize: ( config: any ) => void;
27
+ destroy: () => void;
28
+
29
+ commands: Commands;
30
+ controllers: Controllers;
31
+ data: Data;
32
+ internal: Internal;
33
+ }
34
+ }
@@ -1,15 +1,13 @@
1
1
  import pkg from "../package.json";
2
2
 
3
+ import './globals'
4
+
3
5
  import { IAPIConfig } from "./interfaces/config";
4
6
 
5
- import { destroy, initialize } from "./managers";
7
+ import { destroy, initialize, afterInitializeCallbacks } from "./managers";
6
8
 
7
9
  import * as exported from './exports';
8
10
 
9
- declare global {
10
- var ZenCore: any;
11
- }
12
-
13
11
  let isInitialized = false;
14
12
 
15
13
  function errorInitTwice() {
@@ -24,7 +22,6 @@ export let config: IAPIConfig = {
24
22
  version: pkg.version,
25
23
  }
26
24
 
27
- const afterInitializeCallbacks: ( () => void )[] = [];
28
25
 
29
26
  export const CoreAPI = {
30
27
  initialize: ( configuration?: IAPIConfig ) => {
@@ -36,7 +33,6 @@ export const CoreAPI = {
36
33
 
37
34
  isInitialized = true;
38
35
 
39
- afterInitializeCallbacks.forEach( ( callback ) => callback() );
40
36
  },
41
37
 
42
38
  destroy: () => {
@@ -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
+ }
@@ -7,24 +7,9 @@ import Data from "../manager-bases/data";
7
7
  import Internal from "../manager-bases/internal";
8
8
  import { IAPIConfig } from "../interfaces/config";
9
9
 
10
- if ( typeof __ZEN_MANAGERS__ === 'undefined' || ! __ZEN_MANAGERS__ ) {
11
- // @ts-ignore
12
- globalThis.__ZEN_MANAGERS__ = {
13
- commands: {} as Commands,
14
- controllers: {} as Controllers,
15
- data: {} as Data,
16
- internal: {} as Internal,
17
- };
18
- }
10
+ import '../globals';
19
11
 
20
- declare global {
21
- var __ZEN_MANAGERS__: {
22
- commands: Commands;
23
- controllers: Controllers;
24
- data: Data;
25
- internal: Internal;
26
- }
27
- }
12
+ export const afterInitializeCallbacks: ( () => void )[] = [];
28
13
 
29
14
  export function initialize( config: IAPIConfig ) {
30
15
  __ZEN_MANAGERS__.commands = new Commands();
@@ -44,3 +29,6 @@ export const controllers = __ZEN_MANAGERS__.controllers;
44
29
  export const commands = __ZEN_MANAGERS__.commands;
45
30
  export const data = __ZEN_MANAGERS__.data;
46
31
  export const internal = __ZEN_MANAGERS__.internal;
32
+
33
+ __ZEN_MANAGERS__.initialize = initialize;
34
+ __ZEN_MANAGERS__.destroy = destroy;