@zenflux/core 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/bases/controller-base.d.ts +4 -4
- package/dist/src/bases/index.d.ts +5 -2
- package/dist/src/bases/initialize-base.d.ts +8 -0
- package/dist/src/bases/object-base.d.ts +3 -22
- package/dist/src/clients/http.d.ts +3 -3
- package/dist/src/command-bases/command-base.d.ts +3 -3
- package/dist/src/command-bases/command-internal.d.ts +1 -1
- package/dist/src/command-bases/command-public.d.ts +1 -1
- package/dist/src/command-bases/command-restful.d.ts +1 -1
- package/dist/src/command-bases/index.d.ts +4 -4
- package/dist/src/errors/command-already-registered.d.ts +1 -1
- package/dist/src/errors/controller-already-registered.d.ts +1 -1
- package/dist/src/errors/controller-already-set.d.ts +1 -1
- package/dist/src/errors/error-with-metadata.d.ts +4 -0
- package/dist/src/errors/force-method-implementation.d.ts +1 -7
- package/dist/src/errors/index-public.d.ts +1 -1
- package/dist/src/errors/index.d.ts +9 -5
- package/dist/src/exports-index.d.ts +5 -5
- package/dist/src/exports.d.ts +3 -16
- package/dist/src/index.d.ts +2 -2
- package/dist/src/interfaces/index.d.ts +4 -4
- package/dist/src/interfaces/logger.d.ts +3 -2
- package/dist/src/managers/commands.d.ts +4 -4
- package/dist/src/managers/controllers.d.ts +2 -2
- package/dist/src/managers/export.d.ts +5 -5
- package/dist/src/managers/index.d.ts +4 -4
- package/dist/src/managers/internal.d.ts +1 -1
- package/dist/src/managers/restful.d.ts +5 -5
- package/dist/src/modules/debugger.d.ts +17 -0
- package/dist/src/modules/event-bus/event-bus.d.ts +28 -0
- package/dist/src/modules/logger/config.d.ts +6 -0
- package/dist/src/modules/logger/implementation.d.ts +46 -0
- package/dist/src/modules/logger/index.d.ts +2 -0
- package/dist/src/modules/logger/logger-browser-infra.d.ts +60 -0
- package/dist/src/modules/logger/utils/index.d.ts +2 -0
- package/dist/src/modules/logger/utils/object.d.ts +6 -0
- package/dist/src/modules/logger/utils/rgb.d.ts +6 -0
- package/dist/src/modules/mcp-server/mcp-server.d.ts +10 -0
- package/dist/src/modules/mcp-server/mcp-service.d.ts +13 -0
- package/dist/src/modules/service/service-base.d.ts +15 -0
- package/dist/src/modules/service/service-locator.d.ts +34 -0
- package/dist/src/modules/service/service-with-dependencies-base.d.ts +17 -0
- package/dist/zenflux-core.cjs +58 -14
- package/dist/zenflux-core.d.ts +102 -42
- package/dist/zenflux-core.mjs +58 -14
- package/package.json +3 -3
- package/src/errors/index.ts +1 -0
- package/src/exports.ts +3 -15
- package/src/modules/debugger.ts +0 -24
- package/src/modules/logger/implementation.ts +287 -0
- package/src/modules/logger/index.ts +2 -82
- package/src/modules/logger/logger-browser-infra.ts +306 -0
- package/src/modules/logger/types/picocolors.d.ts +15 -0
- package/src/modules/logger/utils/index.ts +3 -0
- package/src/modules/logger/utils/object.ts +19 -0
- package/src/modules/logger/utils/rgb.ts +34 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InitializeBase } from "../../bases/initialize-base";
|
|
2
|
+
import type { ServiceBase } from "./service-base";
|
|
3
|
+
declare global {
|
|
4
|
+
var __zenflux_base_service_locator__: ServiceLocator | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare class ServiceLocator extends InitializeBase {
|
|
7
|
+
protected static instance: ServiceLocator | null;
|
|
8
|
+
private emitter;
|
|
9
|
+
private services;
|
|
10
|
+
private initializing;
|
|
11
|
+
static getName(): string;
|
|
12
|
+
static get $(): ServiceLocator;
|
|
13
|
+
register<T extends ServiceBase>(service: new (...args: any[]) => T, ...args: any[]): void;
|
|
14
|
+
unregister(serviceName: string): boolean;
|
|
15
|
+
get<T extends ServiceBase>(serviceName: string, options?: {
|
|
16
|
+
silent: boolean;
|
|
17
|
+
}): T;
|
|
18
|
+
waitFor<T extends ServiceBase>(serviceName: string, options?: {
|
|
19
|
+
timeout?: number;
|
|
20
|
+
metadata?: any;
|
|
21
|
+
internal?: boolean;
|
|
22
|
+
silent?: boolean;
|
|
23
|
+
}): Promise<T>;
|
|
24
|
+
waitForAll(options?: {
|
|
25
|
+
timeout?: number;
|
|
26
|
+
metadata?: any;
|
|
27
|
+
internal?: boolean;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
private createServicePromise;
|
|
30
|
+
private createTimeoutPromise;
|
|
31
|
+
private validateCircularDependencies;
|
|
32
|
+
private performDepthFirstSearch;
|
|
33
|
+
private getDependencies;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ServiceBase } from "./service-base";
|
|
2
|
+
type TServicesNonEmpty<T> = keyof T extends never ? "Error: Services are required" : T;
|
|
3
|
+
type TServiceName = string;
|
|
4
|
+
type TServiceNameDependencies<T> = {
|
|
5
|
+
[K in keyof T]: TServiceName;
|
|
6
|
+
};
|
|
7
|
+
export declare abstract class ServiceWithDependenciesBase<D extends {
|
|
8
|
+
[key: string]: ServiceBase;
|
|
9
|
+
}> extends ServiceBase {
|
|
10
|
+
protected services: Required<D>;
|
|
11
|
+
static getName(): string;
|
|
12
|
+
abstract getDependencies(): TServicesNonEmpty<TServiceNameDependencies<D>>;
|
|
13
|
+
protected initialize(): Promise<void>;
|
|
14
|
+
isWithDependencies(): boolean;
|
|
15
|
+
getServices(): Required<D>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
package/dist/zenflux-core.cjs
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bundled with love using the help of @zenflux/cli toolkit v0.1.
|
|
3
|
-
* Bundle name: @zenflux/core fileName: 'zenflux-core', built at Wed Nov 19 2025
|
|
2
|
+
* Bundled with love using the help of @zenflux/cli toolkit v0.1.30
|
|
3
|
+
* Bundle name: @zenflux/core fileName: 'zenflux-core', built at Wed Nov 19 2025 20:35:22 GMT+0200 (Israel Standard Time)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var util = require('node:util');
|
|
11
|
+
var process$1 = require('process');
|
|
12
|
+
var EventEmitter = require('events');
|
|
11
13
|
|
|
12
|
-
class
|
|
14
|
+
class CommandAlreadyRegistered extends Error{constructor(command){super(`Command: '${command.getName()}' is already registered`);}}
|
|
13
15
|
|
|
14
16
|
class CommandNotFound extends Error{constructor(command){super(`Command: '${command}' is not found`);}}
|
|
15
17
|
|
|
16
|
-
class
|
|
18
|
+
class ControllerAlreadyRegistered extends Error{constructor(controller){super(`Controller: '${controller.getName()}' is already registered`);}}
|
|
17
19
|
|
|
18
|
-
class
|
|
20
|
+
class ControllerAlreadySet extends Error{constructor(controller){super(`Controller: '${controller.getName()}' is already set`);}}
|
|
19
21
|
|
|
20
|
-
class
|
|
22
|
+
class ForceMethodBase extends Error{constructor(className,methodName){super(`ForceMethod implementation: at '${className}' method: '${methodName}'`);}}class ForceMethodImplementation extends Error{constructor(context,methodName){super(`ForceMethod implementation: at '${"string"===typeof context?context:context.getName()}' method: '${methodName}'`);}}
|
|
23
|
+
|
|
24
|
+
class ErrorWithMetadata extends Error{metadata;constructor(message,metadata=null){super(message);this.metadata=metadata;this.message=null!==metadata?`${message} - Metadata: ${util.inspect(metadata)}`:message;Object.setPrototypeOf(this,new.target.prototype);}}
|
|
25
|
+
|
|
26
|
+
class ObjectBase{id;name="__UNDEFINED_NAME__";constructor(){this.name=this.getName();const timestamp=performance.now()*1e6;const random1=BigInt(Math.floor(Math.random()*1e6));const random2=BigInt(Math.floor(Math.random()*1e6));this.id=`${timestamp}${random1}${random2}`;}static getName(){throw new ForceMethodBase(this.name,"getName")}static getSourcePath(){throw new ForceMethodBase(this.name,"getSourcePath")}getName(){return this.constructor.getName()}getUniqueId(){return this.id}getInitialName(){return this.name}getHierarchyNames(){const classNames=[];let obj=Object.getPrototypeOf(this);let className;while((className=obj.getName())!=="Object"){classNames.push(className);obj=Object.getPrototypeOf(obj);if(obj.constructor===ObjectBase){break}}return classNames}}
|
|
27
|
+
|
|
28
|
+
class Commands extends ObjectBase{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return "ZenFlux/Core/Managers/Commands"}static async runCallbacks(callbacks,args={},options={}){const callbacksLength=callbacks?.length||0;for(let i=0;i<callbacksLength;++i){const callback=options.pop===true?callbacks.pop():callbacks[i];if(!callback){throw new Error("Callback is not defined.")}await callback(args,options);}}static hookCommand(stack,hookCommand,context){if(!stack[hookCommand]){stack[hookCommand]=[];}stack[hookCommand].push(context);}constructor(){super();const type=this.constructor;this.logger=new zCore.classes.Logger(type);this.logger.startsEmpty(this.constructor);}async run(command,args={},options={}){if(typeof command==="string"){command=this.getCommandInstance(command,args,options);}this.attachCurrent(command,args);const result=await this.runInstance(command,args,options);this.detachCurrent(command);return result}register(commands,controller){const result={};Object.values(commands).forEach(command=>{const commandName=command.getName();if(this.commands[commandName]){throw new CommandAlreadyRegistered(command)}command.setController(controller);this.commands[commandName]=command;result[commandName]=command;});return result}getAll(){return this.commands}getByName(name){return this.commands[name]}getLogger(){return this.logger}getCommandInstance(name,args={},options={}){const CommandClass=this.commands[name];if(!CommandClass){throw new CommandNotFound(name)}return new CommandClass(args,options)}onBefore(hookCommand,callback){Commands.hookCommand(this.onBeforeHooks,hookCommand,callback);}onBeforeUI(hookCommand,callback){Commands.hookCommand(this.onBeforeUIHooks,hookCommand,callback);}onAfter(hookCommand,callback){Commands.hookCommand(this.onAfterHooks,hookCommand,callback);}onAfterUI(command,callback){Commands.hookCommand(this.onAfterUIHooks,command,callback);}onAfterOnce(command,callback){Commands.hookCommand(this.onAfterOnceHooks,command,callback);}onAfterAffect(hookCommand,affectCommand){Commands.hookCommand(this.onAfterAffectHooks,hookCommand,affectCommand);}onBeforeRun(command,args={},options={}){if(this.onBeforeHooks[command.getName()]){const callbacks=this.onBeforeHooks[command.getName()];callbacks.forEach(callback=>callback(args,options));}if(this.onBeforeUIHooks[command.getName()]){const callbacks=this.onBeforeUIHooks[command.getName()];callbacks.forEach(callback=>callback(args,options));}}async runInstance(command,args={},options={}){let result=null;this.logger.startsWith(this.runInstance,{command:command.getName(),options,args});this.onBeforeRun(command,args,options);result=await command.run();await this.onAfterRun(command,args,options,result);return result}async onAfterRun(command,args,options,result){options=Object.assign({},options);if(this.onAfterAffectHooks[command.getName()]){this.onAfterAffectHooks[command.getName()].forEach(command=>{args.result=result;result=this.run(command.toString(),args,options);});result=await result;}if(this.onAfterHooks){args.result=result;await Commands.runCallbacks(Object.assign([],this.onAfterHooks[command.getName()]),args,options);}if(this.onAfterOnceHooks){await Commands.runCallbacks(this.onAfterOnceHooks[command.getName()],args,{...options,pop:true});}if(this.onAfterUIHooks){Commands.runCallbacks(Object.assign([],this.onAfterUIHooks[command.getName()]),args,options);}return result}attachCurrent(command,args={}){this.current[command.getName()]=command;this.currentArgs[command.getName()]=args;this.trace.push(command.getName());Commands.trace.push(command.getName());}detachCurrent(command){delete this.current[command.getName()];delete this.currentArgs[command.getName()];Commands.trace.pop();this.trace.pop();}}
|
|
21
29
|
|
|
22
30
|
class Controllers extends ObjectBase{controllers={};constructor(){super();}static getName(){return "ZenFlux/Core/Managers/Controllers"}get(name){return this.controllers[name]}getAll(){return this.controllers}register(controller){if(this.controllers[controller.getName()]){throw new ControllerAlreadyRegistered(controller)}this.controllers[controller.getName()]=controller;return controller}}
|
|
23
31
|
|
|
@@ -56,8 +64,6 @@ ControllerBase: ControllerBase,
|
|
|
56
64
|
ObjectBase: ObjectBase
|
|
57
65
|
});
|
|
58
66
|
|
|
59
|
-
class ControllerAlreadySet extends Error{constructor(controller){super(`Controller: '${controller.getName()}' is already set`);}}
|
|
60
|
-
|
|
61
67
|
class CommandBase extends ObjectBase{static controller;args={};options={};logger;static getName(){return "ZenFlux/Core/CommandBases/CommandBase"}static setController(controller){if(this.controller){throw new ControllerAlreadySet(this.controller)}this.controller=controller;}static getController(){return this.controller}constructor(args={},options={}){super();const type=this.constructor;this.logger=new zCore.classes.Logger(type,{repeatedly:true});this.logger.startsWith(this.constructor,{args,options});this.initialize(args,options);}initialize(args,options){this.args=args;this.options=options;}apply(args=this.args,options=this.options){throw new ForceMethodImplementation(this,"apply")}async run(){return this.runInternal()}async runInternal(){this.onBeforeApply&&this.onBeforeApply();const result=await this.apply(this.args,this.options);this.onAfterApply&&this.onAfterApply();return result}}
|
|
62
68
|
|
|
63
69
|
class CommandPublic extends CommandBase{static getName(){return "ZenFlux/Core/CommandBases/CommandPublic"}}
|
|
@@ -79,9 +85,37 @@ __proto__: null,
|
|
|
79
85
|
ForceMethodImplementation: ForceMethodImplementation
|
|
80
86
|
});
|
|
81
87
|
|
|
88
|
+
const DEFAULT_LOG_LEVEL="5";function getLoggerDefaultLevel(){return DEFAULT_LOG_LEVEL}function getLoggerLogLevel(){return parseInt(process$1.env.LOGGER_LOG_LEVEL||DEFAULT_LOG_LEVEL,10)}function getLoggerLogLevelString(){switch(getLoggerLogLevel()){case 0:return "NONE";case 1:return "ERROR";case 2:return "WARN";case 3:return "ADMIN";case 4:return "INFO";case 5:return "LOG";case 6:return "DEBUG";default:return "UNKNOWN"}}function isLoggerDebugEnabled(){return getLoggerLogLevel()>=6}function isLoggerDisabled(){return process$1.env.LOGGER_DISABLED==="true"}function isLoggerPreviousSourceDisabled(){return process$1.env.LOGGER_LOG_PREVIOUS_CALLER_SOURCE_DISABLED==="true"}
|
|
89
|
+
|
|
90
|
+
var commonjsGlobal=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x}function getDefaultExportFromNamespaceIfPresent(n){return n&&Object.prototype.hasOwnProperty.call(n,"default")?n["default"]:n}function getDefaultExportFromNamespaceIfNotNamed(n){return n&&Object.prototype.hasOwnProperty.call(n,"default")&&Object.keys(n).length===1?n["default"]:n}function getAugmentedNamespace(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var f=n.default;if(typeof f=="function"){var a=function a(){var isInstance=false;try{isInstance=this instanceof a;}catch{}if(isInstance){return Reflect.construct(f,arguments,this.constructor)}return f.apply(this,arguments)};a.prototype=f.prototype;}else a={};Object.defineProperty(a,"__esModule",{value:true});Object.keys(n).forEach(function(k){var d=Object.getOwnPropertyDescriptor(n,k);Object.defineProperty(a,k,d.get?d:{enumerable:true,get:function(){return n[k]}});});return a}
|
|
91
|
+
|
|
92
|
+
var picocolors$1={exports:{}};
|
|
93
|
+
|
|
94
|
+
var picocolors=picocolors$1.exports;var hasRequiredPicocolors;function requirePicocolors(){if(hasRequiredPicocolors)return picocolors$1.exports;hasRequiredPicocolors=1;let p=process||{},argv=p.argv||[],env=p.env||{};let isColorSupported=!(!!env.NO_COLOR||argv.includes("--no-color"))&&(!!env.FORCE_COLOR||argv.includes("--color")||p.platform==="win32"||(p.stdout||{}).isTTY&&env.TERM!=="dumb"||!!env.CI);let formatter=(open,close,replace=open)=>input=>{let string=""+input,index=string.indexOf(close,open.length);return ~index?open+replaceClose(string,close,replace,index)+close:open+string+close};let replaceClose=(string,close,replace,index)=>{let result="",cursor=0;do{result+=string.substring(cursor,index)+replace;cursor=index+close.length;index=string.indexOf(close,cursor);}while(~index)return result+string.substring(cursor)};let createColors=(enabled=isColorSupported)=>{let f=enabled?formatter:()=>String;return {isColorSupported:enabled,reset:f("\x1b[0m","\x1b[0m"),bold:f("\x1b[1m","\x1b[22m","\x1b[22m\x1b[1m"),dim:f("\x1b[2m","\x1b[22m","\x1b[22m\x1b[2m"),italic:f("\x1b[3m","\x1b[23m"),underline:f("\x1b[4m","\x1b[24m"),inverse:f("\x1b[7m","\x1b[27m"),hidden:f("\x1b[8m","\x1b[28m"),strikethrough:f("\x1b[9m","\x1b[29m"),black:f("\x1b[30m","\x1b[39m"),red:f("\x1b[31m","\x1b[39m"),green:f("\x1b[32m","\x1b[39m"),yellow:f("\x1b[33m","\x1b[39m"),blue:f("\x1b[34m","\x1b[39m"),magenta:f("\x1b[35m","\x1b[39m"),cyan:f("\x1b[36m","\x1b[39m"),white:f("\x1b[37m","\x1b[39m"),gray:f("\x1b[90m","\x1b[39m"),bgBlack:f("\x1b[40m","\x1b[49m"),bgRed:f("\x1b[41m","\x1b[49m"),bgGreen:f("\x1b[42m","\x1b[49m"),bgYellow:f("\x1b[43m","\x1b[49m"),bgBlue:f("\x1b[44m","\x1b[49m"),bgMagenta:f("\x1b[45m","\x1b[49m"),bgCyan:f("\x1b[46m","\x1b[49m"),bgWhite:f("\x1b[47m","\x1b[49m"),blackBright:f("\x1b[90m","\x1b[39m"),redBright:f("\x1b[91m","\x1b[39m"),greenBright:f("\x1b[92m","\x1b[39m"),yellowBright:f("\x1b[93m","\x1b[39m"),blueBright:f("\x1b[94m","\x1b[39m"),magentaBright:f("\x1b[95m","\x1b[39m"),cyanBright:f("\x1b[96m","\x1b[39m"),whiteBright:f("\x1b[97m","\x1b[39m"),bgBlackBright:f("\x1b[100m","\x1b[49m"),bgRedBright:f("\x1b[101m","\x1b[49m"),bgGreenBright:f("\x1b[102m","\x1b[49m"),bgYellowBright:f("\x1b[103m","\x1b[49m"),bgBlueBright:f("\x1b[104m","\x1b[49m"),bgMagentaBright:f("\x1b[105m","\x1b[49m"),bgCyanBright:f("\x1b[106m","\x1b[49m"),bgWhiteBright:f("\x1b[107m","\x1b[49m")}};picocolors$1.exports=createColors();picocolors$1.exports.createColors=createColors;return picocolors$1.exports}
|
|
95
|
+
|
|
96
|
+
var picocolorsExports=requirePicocolors();var pc = getDefaultExportFromCjs(picocolorsExports);
|
|
97
|
+
|
|
98
|
+
class EventBus extends ObjectBase{static instance=null;objects=new Map;eventEmitter=new EventEmitter;lastEmittedEvents=new Map;static getName(){return "ZenFlux/Core/Modules/EventBus"}static getInstance(){if(!EventBus.instance){EventBus.instance=new EventBus;}return EventBus.instance}static get $(){return EventBus.getInstance()}getObjectNames(){return Array.from(this.objects.keys())}getEventNames(){this.eventEmitter.eventNames();}getEventName(objectName,methodName){return `${objectName}::${methodName}`}on(objectName,methodName,callback){if(!this.objects.has(objectName)){throw new Error(`Object ${objectName} is not registered`)}this.eventEmitter.on(this.getEventName(objectName,methodName),callback);}onCalledBeforeDoInvoke(objectName,methodName,callback){this.on(objectName,methodName,callback);if(this.objects.has(objectName)){const objectEntry=this.objects.get(objectName);if(objectEntry){const method=objectEntry.methods.find(method=>method.name===methodName);if(method&&this.lastEmittedEvents.has(this.getEventName(objectName,methodName))){callback(...this.lastEmittedEvents.get(this.getEventName(objectName,methodName)));}}}}off(objectName,methodName,callback){this.eventEmitter.off(this.getEventName(objectName,methodName),callback);}register(object,methods){if(this.objects.has(object.getName())){throw new Error(`Error in: '${this.getName()}', object: '${object.getName()}' is already registered`)}this.objects.set(object.getName(),{object,methods});this.hook(object,methods);}registerMultiInstances(object,methods){const objectName=object.getName();if(this.objects.has(objectName)){const existingEntry=this.objects.get(objectName);if(Array.isArray(existingEntry.object)){existingEntry.object.push(object);}else {existingEntry.object=[existingEntry.object,object];}}else {this.objects.set(objectName,{object,methods});}this.hook(object,methods);}unregister(objectName){const entry=this.objects.get(objectName);if(!entry){return false}if(Array.isArray(entry.object)){entry.object.forEach(obj=>{this.unhookObject(obj,entry.methods);});}else {this.unhookObject(entry.object,entry.methods);}this.objects.delete(objectName);}unhookObject(object,methods){methods.forEach(method=>{this.ensureFunction(object,method);this.eventEmitter.removeAllListeners(this.getEventName(object.getName(),method.name));object[method.name]=method;});}unhook(entry){if(Array.isArray(entry.object)){entry.object.forEach(obj=>{this.unhookObject(obj,entry.methods);});}else {this.unhookObject(entry.object,entry.methods);}}emit(object,method,...args){const eventName=this.getEventName(object.getName(),method.name);this.lastEmittedEvents.set(eventName,args);return this.eventEmitter.emit(eventName,...args)}hook(object,methods){methods.forEach(method=>{this.ensureFunction(object,method);const originalMethod=method;const eventBusHook=async(...args)=>{const result=await originalMethod.apply(object,args);this.emit(object,method,...args);return result};object[method.name]=new Proxy(eventBusHook,{get(target,prop){if(prop==="name"){return method.name}return target[prop]}});});}ensureFunction(object,method){if("function"!==typeof method){throw new Error(`Method ${method} is not a function on ${object.getName()}`)}}}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Reduce circular references.
|
|
102
|
+
*
|
|
103
|
+
* @copyright https://stackoverflow.com/a/53731154
|
|
104
|
+
*/const reduceCircularReferences=()=>{const seen=new WeakSet;return (key,value)=>{if(typeof value==="object"&&value!==null){if(seen.has(value)){return}seen.add(value);}return value}};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Function hexColorDelta() : Return color difference in ratio decimal point.
|
|
108
|
+
*
|
|
109
|
+
* @copyright http://jsfiddle.net/96sME/
|
|
110
|
+
*/const getHexColorDelta=function(hex1,hex2){hex1=hex1.replace("#","");hex2=hex2.replace("#","");const r1=parseInt(hex1.substring(0,2),16);const g1=parseInt(hex1.substring(2,4),16);const b1=parseInt(hex1.substring(4,6),16);const r2=parseInt(hex2.substring(0,2),16);const g2=parseInt(hex2.substring(2,4),16);const b2=parseInt(hex2.substring(4,6),16);let r=255-Math.abs(r1-r2);let g=255-Math.abs(g1-g2);let b=255-Math.abs(b1-b2);r/=255;g/=255;b/=255;return (r+g+b)/3};
|
|
111
|
+
|
|
112
|
+
const MAX_MAPPING_RECURSIVE_DEPTH=4,UNKNOWN_CALLER_NAME="anonymous function";Error.stackTraceLimit=50;class LoggerBrowserInfra extends ObjectBase{static mappers=[];static mapperDepth=0;static colorsOwners={};static colorsUsed=[];defaultStyle;owner;args;color;outputHandler=console.log;static getName(){return "ZenFlux/Logging/Modules/LoggerBrowserInfra"}static reset(){LoggerBrowserInfra.mappers=[];LoggerBrowserInfra.mapperDepth=0;LoggerBrowserInfra.colorsUsed=[];LoggerBrowserInfra.colorsOwners={};}static createObjectMapper(callback){LoggerBrowserInfra.mappers.push(callback);}static useObjectMapper(obj,shouldHandleChildren=true){if(!obj||Array.isArray(obj)||"object"!==typeof obj){return obj}LoggerBrowserInfra.mapperDepth++;let result={...obj};LoggerBrowserInfra.mappers.forEach(mapper=>{result=mapper(obj)||result;});if(LoggerBrowserInfra.mapperDepth>=MAX_MAPPING_RECURSIVE_DEPTH){LoggerBrowserInfra.mapperDepth--;return result}if(shouldHandleChildren&&result){Object.entries(result).forEach(([key,value])=>{result[key]=this.useObjectMapper(value,true);});}LoggerBrowserInfra.mapperDepth--;return result}constructor(owner,args={}){super();this.args={repeatedly:false,...args};this.owner=owner;this.initialize();}getOwnerName(){if(typeof this.owner==="string"){return this.owner}if(this.owner instanceof ObjectBase){return this.owner.getName()}if(this.owner&&typeof this.owner.getName==="function"){return this.owner.getName()}return "UnknownOwner"}initialize(){const ownerName=this.getOwnerName();if(this.args.repeatedly&&LoggerBrowserInfra.colorsOwners[ownerName]){this.color=LoggerBrowserInfra.colorsOwners[ownerName];}else {this.color=this.getRandomColor();LoggerBrowserInfra.colorsUsed.push(this.color);}LoggerBrowserInfra.colorsOwners[ownerName]=this.color;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"];}output(...args){this.outputHandler.apply(this,args);}setOutputHandler(outputHandler){this.outputHandler=outputHandler;}printFunctionNotify(prefix,caller,output){const callerName=this.getCallerName(caller);this.output.apply(this,[`%c(${prefix})-> %c%c${this.getOwnerName()}%c::%c${callerName}%c() ${output}%c`].concat(this.defaultStyle));}printObjectEfficient(prefix,caller,params){params=Object.assign({},params);if(typeof params==="string"){this.printInLineString(prefix,caller,params);return}if(Object.keys(params).length===1){const key=Object.keys(params)[0];let value=Object.values(params)[0];if("object"===typeof value){this.printInNextLineObject(prefix,caller,key,value||{});}else if("function"===typeof value){this.printInLineFunction(prefix,caller,key,value);}else {this.printInLineElement(prefix,caller,key,value);}return}this.printMultiLineObject(prefix,caller,params);}printInLineElement(prefix,caller,key,value,notice=""){const callerName=this.getCallerName(caller),ownerName=this.getOwnerName(),format=notice.length?`%c(${prefix})-> %c%c${ownerName}%c::%c${callerName}%c() ->> [${notice}] ->> ${key}: '${value}'%c`:`%c(${prefix})-> %c%c${ownerName}%c::%c${callerName}%c() ->> ${key}: '${value}'%c`;this.output.apply(this,[format].concat(this.defaultStyle));}printInLineFunction(prefix,caller,key,fn){fn=this.getFunctionView(fn);this.printInLineElement(prefix,caller,key,fn);}printInLineString(prefix,caller,string){this.printInLineElement(prefix,caller,"(string)",string);}printInNextLineObject(prefix,caller,key,obj){const mapped=LoggerBrowserInfra.useObjectMapper(obj),callerName=this.getCallerName(caller);this.output.apply(this,[`%c(${prefix})-> %c%c${this.getOwnerName()}%c::%c${callerName}%c() ->> ${key} %c↓`].concat(this.defaultStyle));this.output(mapped);}printMultiLineObject(prefix,caller,obj){const callerName=this.getCallerName(caller);this.output.apply(this,[`%c(${prefix})-> %c%c${this.getOwnerName()}%c::%c${callerName}%c(${Object.keys(obj).join(", ")}) %c↓`].concat(this.defaultStyle));for(let key in obj){let value=obj[key];if(typeof value==="object"){const mapped=LoggerBrowserInfra.useObjectMapper(value);value=JSON.stringify(mapped,reduceCircularReferences());}else if(typeof obj[key]=="function"){value=this.getFunctionView(value);}this.output.apply(this,["%c"+key+": `"+value+"`","color: #a3a3a3"]);}}getRandomColor(){const hex="0123456789ABCDEF";let color="#";for(let i=0;i<6;i++){color+=hex[Math.floor(Math.random()*16)];}let similar=LoggerBrowserInfra.colorsUsed.some(value=>{return getHexColorDelta(color,value)>=.8});if(similar){return this.getRandomColor()}return color}getCallerName(caller){if("function"===typeof caller){return caller.prototype instanceof ObjectBase?"constructor":caller.name}throw new Error("Invalid caller")}getFunctionView(fn){let fReturn=UNKNOWN_CALLER_NAME;if(typeof fn!=="string"&&fn.name.length!==0){fReturn=fn.name.split(" ")[1]+"()";}return fReturn}}
|
|
113
|
+
|
|
114
|
+
const DEFAULT_LOG_PREFIX=pc.white("⚪ - [LOG]"),DEFAULT_INFO_PREFIX=pc.blue("🔵 - [INFO]"),DEFAULT_DEBUG_PREFIX=pc.gray("🟤 - [DEBUG]"),DEFAULT_WARN_PREFIX=pc.yellow("🟡 - [WARN]"),DEFAULT_ERROR_PREFIX=pc.red("🔴 - [ERROR]"),DEFAULT_ADMIN_PREFIX=pc.bold("🟣 - [ADMIN]");const registeredNames={};class Logger extends LoggerBrowserInfra{static lastLogTime=Date.now();ownerName;messagePrefixes=[];config={};static getName(){return "ZenFlux/Core/Modules/Logger"}static getLogLevelString(){return getLoggerLogLevelString()}static getLogLevel(){return getLoggerLogLevel()}static isDebugEnabled(){return isLoggerDebugEnabled()}constructor(owner,options){const{repeatedly=false,skipEventBusHook}=options||{};super(owner,{repeatedly});this.config={skipEventBusHook};this.ownerName=Logger.resolveOwnerName(owner);if(registeredNames[this.ownerName]){throw new Error(`Logger for '${this.ownerName}' already exists`)}registeredNames[this.ownerName]=true;if(isLoggerDisabled()){this.disableLoggers();return}if(isLoggerPreviousSourceDisabled()){this.getPreviousSource=()=>"";}switch(getLoggerLogLevel()){case 0:this.error=()=>{};case 1:this.warn=()=>{};case 2:this.admin=()=>{};case 3:this.info=()=>{};case 4:this.log=()=>{};case 5:this.debug=()=>{};}if(!this.config.skipEventBusHook){EventBus.$.registerMultiInstances(this,[this.outputEvent]);}}addMessagePrefix(prefix){this.messagePrefixes.push(prefix);}log(caller,message,...params){this.writeLog(DEFAULT_LOG_PREFIX,caller,message,...params);}info(caller,message,...params){this.writeLog(DEFAULT_INFO_PREFIX,caller,message,...params);}debug(caller,message,...params){this.writeLog(DEFAULT_DEBUG_PREFIX,caller,message,...params);}warn(caller,message,...params){this.writeLog(DEFAULT_WARN_PREFIX,caller,message,...params);}error(caller,message,...params){this.writeLog(DEFAULT_ERROR_PREFIX,caller,message,...params);}admin(caller,message,...params){this.writeLog(DEFAULT_ADMIN_PREFIX,caller,message,...params);}startsEmpty(caller){this.printFunctionNotify("▶",caller,"");}startsWith(caller,params){this.printObjectEfficient("▶",caller,params);}dump(caller,params={},notice=""){for(const key in params){if(typeof params[key]==="object"){params[key]=JSON.stringify(LoggerBrowserInfra.useObjectMapper(params[key]),reduceCircularReferences());}this.printInLineElement("dp",caller,key,params[key],notice);}}drop(caller,according,data){for(const key in according){this.printInLineElement("dr",caller,key,according[key],"corresponding");}this.output(data);}throw(caller,output,name="null",params={}){this.printFunctionNotify("tw",caller,output);if(params){this.printInNextLineObject("tw",caller,name,params);}throw new Error().stack}beep(){console.log("\x07");}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}outputEvent(_prefix,_timeDiff,_source,_messagePrefix,_message,_params){}static resolveOwnerName(owner){if(typeof owner==="string"){return owner}if(owner instanceof ObjectBase){return owner.getName()}if(owner&&typeof owner.getName==="function"){return owner.getName()}return "UnknownOwner"}disableLoggers(){this.error=()=>{};this.warn=()=>{};this.admin=()=>{};this.info=()=>{};this.log=()=>{};this.debug=()=>{};}getStackTrace(){const stackTrace=(new Error().stack||"").split("\n");const stackLines=stackTrace.slice(1);const stackRegex=/ at (.+?) \((.+?)\)/;const result=[];for(const line of stackLines){const match=line.match(stackRegex);if(match){const[,context,file]=match;const parsedLine={context,file};if(line.startsWith("new")){parsedLine.isNew=true;parsedLine.object=context.split(" ")[1];}else if(context!=="Object.<anonymous>"){parsedLine.object=context;}result.push(parsedLine);}}return result}getPreviousSource(){const stack=this.getStackTrace().filter(line=>line.file.includes("/src/")).filter(line=>!line.file.includes("logger.ts")).filter(line=>!line.file.includes("debugger.ts")).filter(line=>!line.file.includes("/node_modules/"));let previousSource="";const previousCaller=stack[1]?.object?.split(".");if(previousCaller?.length>1){const previousCallerName=previousCaller[0],previousCallerMethod=previousCaller[1];previousSource=`${previousCallerName}::${previousCallerMethod}]`+"[";}return previousSource}writeLog(prefix,caller,message,...params){const source=this.getPreviousSource()+pc.white(`${this.ownerName}::${this.getCallerName(caller)}`);let messagePrefix="";if(this.messagePrefixes.length){messagePrefix=`[${this.messagePrefixes.join("][")}]`;}const timeDiff=(Date.now()-Logger.lastLogTime).toString().padStart(4,"0");this.outputEvent(prefix,timeDiff,source,messagePrefix,message,params);const output=`${prefix}[+${timeDiff}ms][${source}]${messagePrefix}: ${message}`;console.log(output,...params);Logger.lastLogTime=Date.now();}}
|
|
115
|
+
|
|
82
116
|
var _package = {
|
|
83
117
|
"name": "@zenflux/core",
|
|
84
|
-
"version": "0.1.
|
|
118
|
+
"version": "0.1.8",
|
|
85
119
|
"types": "dist/zenflux-core.d.ts",
|
|
86
120
|
"type": "module",
|
|
87
121
|
"files": [
|
|
@@ -102,32 +136,42 @@ var _package = {
|
|
|
102
136
|
"types": "./dist/zenflux-core.d.ts"
|
|
103
137
|
},
|
|
104
138
|
"./dist/src/*": "./src/*",
|
|
139
|
+
"./src/*": "./src/*",
|
|
105
140
|
"./src/bases": "./src/bases/index.ts",
|
|
106
141
|
"./src/clients": "./src/clients/index.ts",
|
|
107
142
|
"./src/command-bases": "./src/command-bases/index.ts",
|
|
108
143
|
"./src/errors": "./src/errors/index.ts",
|
|
109
144
|
"./src/interfaces": "./src/interfaces/index.ts",
|
|
110
145
|
"./src/managers": "./src/managers/index.ts",
|
|
146
|
+
"./src/modules/logger": "./src/modules/logger/index.ts",
|
|
111
147
|
"./package.json": "./package.json"
|
|
112
148
|
},
|
|
113
149
|
"devDependencies": {
|
|
150
|
+
"@jest/globals": "^29.7.0",
|
|
114
151
|
"@zenflux/cli": "workspace:*"
|
|
115
152
|
},
|
|
116
153
|
"publishConfig": {
|
|
117
154
|
"access": "public"
|
|
155
|
+
},
|
|
156
|
+
"dependencies": {
|
|
157
|
+
"fastmcp": "^3.23.1",
|
|
158
|
+
"zod": "^4.1.12",
|
|
159
|
+
"picocolors": "^1.0.0",
|
|
160
|
+
"@zenflux/utils": "workspace:*"
|
|
118
161
|
}
|
|
119
162
|
};
|
|
120
163
|
const name = "@zenflux/core";
|
|
121
|
-
const version = "0.1.
|
|
164
|
+
const version = "0.1.8";
|
|
122
165
|
const types = "dist/zenflux-core.d.ts";
|
|
123
166
|
const type = "module";
|
|
124
167
|
const files = ["dist","src","types"];
|
|
125
168
|
const scripts = {"@z-core--test":"jest","@z-core--build":"@z-cli @build","@z-core--dev":"@z-cli @watch --dev"};
|
|
126
|
-
const exports$1 = {".":{"import":"./dist/zenflux-core.mjs","default":"./dist/zenflux-core.cjs","require":"./dist/zenflux-core.mjs.js","types":"./dist/zenflux-core.d.ts"},"./dist/src/*":"./src/*","./src/bases":"./src/bases/index.ts","./src/clients":"./src/clients/index.ts","./src/command-bases":"./src/command-bases/index.ts","./src/errors":"./src/errors/index.ts","./src/interfaces":"./src/interfaces/index.ts","./src/managers":"./src/managers/index.ts","./package.json":"./package.json"};
|
|
127
|
-
const devDependencies = {"@zenflux/cli":"workspace:*"};
|
|
169
|
+
const exports$1 = {".":{"import":"./dist/zenflux-core.mjs","default":"./dist/zenflux-core.cjs","require":"./dist/zenflux-core.mjs.js","types":"./dist/zenflux-core.d.ts"},"./dist/src/*":"./src/*","./src/*":"./src/*","./src/bases":"./src/bases/index.ts","./src/clients":"./src/clients/index.ts","./src/command-bases":"./src/command-bases/index.ts","./src/errors":"./src/errors/index.ts","./src/interfaces":"./src/interfaces/index.ts","./src/managers":"./src/managers/index.ts","./src/modules/logger":"./src/modules/logger/index.ts","./package.json":"./package.json"};
|
|
170
|
+
const devDependencies = {"@jest/globals":"^29.7.0","@zenflux/cli":"workspace:*"};
|
|
128
171
|
const publishConfig = {"access":"public"};
|
|
172
|
+
const dependencies = {"fastmcp":"^3.23.1","zod":"^4.1.12","picocolors":"^1.0.0","@zenflux/utils":"workspace:*"};
|
|
129
173
|
|
|
130
|
-
const classes={Logger
|
|
174
|
+
const classes={Logger};let exportedConfig={version:version};function initialize(config){if("undefined"!==typeof __ZEN_CORE__IS_INITIALIZED__&&__ZEN_CORE__IS_INITIALIZED__){throw new Error("ZenCore is already initialized.")}exportedConfig=config||exportedConfig;initialize$1(exportedConfig);globalThis.__ZEN_CORE__IS_INITIALIZED__=true;}function destroy(){destroy$1();globalThis.__ZEN_CORE__IS_INITIALIZED__=false;}function onAfterInitialize(callback){afterInitializeCallbacks.push(callback);}const config=exportedConfig;
|
|
131
175
|
|
|
132
176
|
var ZenCore = /*#__PURE__*/Object.freeze({
|
|
133
177
|
__proto__: null,
|
package/dist/zenflux-core.d.ts
CHANGED
|
@@ -9,21 +9,7 @@ declare namespace bases {
|
|
|
9
9
|
export { bases }
|
|
10
10
|
|
|
11
11
|
declare const classes: {
|
|
12
|
-
Logger:
|
|
13
|
-
new (owner: typeof bases.ObjectBase, params?: any): {
|
|
14
|
-
log(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
15
|
-
warn(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
16
|
-
error(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
17
|
-
info(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
18
|
-
debug(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
19
|
-
startsEmpty(caller: interfaces.TCaller): void;
|
|
20
|
-
startsWith(caller: interfaces.TCaller, params: object): void;
|
|
21
|
-
dump(caller: interfaces.TCaller, data: any): void;
|
|
22
|
-
drop(caller: interfaces.TCaller, according: {
|
|
23
|
-
[key: string]: string;
|
|
24
|
-
}, data: any): void;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
12
|
+
Logger: typeof Logger;
|
|
27
13
|
};
|
|
28
14
|
|
|
29
15
|
declare abstract class CommandBase extends ObjectBase {
|
|
@@ -230,9 +216,6 @@ declare namespace errors {
|
|
|
230
216
|
}
|
|
231
217
|
export { errors }
|
|
232
218
|
|
|
233
|
-
/**
|
|
234
|
-
* @public
|
|
235
|
-
*/
|
|
236
219
|
declare class ForceMethodImplementation extends Error {
|
|
237
220
|
constructor(context: ObjectBase | typeof ObjectBase | string, methodName: string);
|
|
238
221
|
}
|
|
@@ -291,6 +274,8 @@ declare interface IAPIConfig {
|
|
|
291
274
|
requestInit?: RequestInit;
|
|
292
275
|
}
|
|
293
276
|
|
|
277
|
+
declare type ICaller = interfaces.TCaller;
|
|
278
|
+
|
|
294
279
|
declare interface ICommandArgsInterface {
|
|
295
280
|
[key: string]: any;
|
|
296
281
|
}
|
|
@@ -305,11 +290,12 @@ declare interface ILogger {
|
|
|
305
290
|
error(caller: TCaller, message: string, ...params: any[]): void;
|
|
306
291
|
info(caller: TCaller, message: string, ...params: any[]): void;
|
|
307
292
|
debug(caller: TCaller, message: string, ...params: any[]): void;
|
|
293
|
+
addMessagePrefix(prefix: string): void;
|
|
308
294
|
startsEmpty(caller: TCaller): void;
|
|
309
|
-
startsWith(caller: TCaller, params: object): void;
|
|
295
|
+
startsWith(caller: TCaller, params: object | string): void;
|
|
310
296
|
dump(caller: TCaller, params: {
|
|
311
297
|
[key: string]: object | string;
|
|
312
|
-
}): void;
|
|
298
|
+
}, notice?: string): void;
|
|
313
299
|
drop(caller: TCaller, according: {
|
|
314
300
|
[key: string]: string;
|
|
315
301
|
}, data: any): void;
|
|
@@ -353,6 +339,100 @@ declare interface IOnHookInterface {
|
|
|
353
339
|
[key: string]: Array<TCommandCallbackType>;
|
|
354
340
|
}
|
|
355
341
|
|
|
342
|
+
declare class Logger extends LoggerBrowserInfra implements interfaces.ILogger {
|
|
343
|
+
private static lastLogTime;
|
|
344
|
+
private readonly ownerName;
|
|
345
|
+
private messagePrefixes;
|
|
346
|
+
private config;
|
|
347
|
+
static getName(): string;
|
|
348
|
+
static getLogLevelString(): string;
|
|
349
|
+
static getLogLevel(): number;
|
|
350
|
+
static isDebugEnabled(): boolean;
|
|
351
|
+
constructor(owner: any, options?: LoggerOptions);
|
|
352
|
+
addMessagePrefix(prefix: string): void;
|
|
353
|
+
log(caller: ICaller, message: string, ...params: any[]): void;
|
|
354
|
+
info(caller: ICaller, message: string, ...params: any[]): void;
|
|
355
|
+
debug(caller: ICaller, message: string, ...params: any[]): void;
|
|
356
|
+
warn(caller: ICaller, message: string, ...params: any[]): void;
|
|
357
|
+
error(caller: ICaller, message: string, ...params: any[]): void;
|
|
358
|
+
admin(caller: ICaller, message: string, ...params: any[]): void;
|
|
359
|
+
startsEmpty(caller: interfaces.TCaller): void;
|
|
360
|
+
startsWith(caller: interfaces.TCaller, params: string | object): void;
|
|
361
|
+
dump(caller: interfaces.TCaller, params?: {
|
|
362
|
+
[key: string]: object | string;
|
|
363
|
+
}, notice?: string): void;
|
|
364
|
+
drop(caller: interfaces.TCaller, according: {
|
|
365
|
+
[key: string]: string;
|
|
366
|
+
}, data: any): void;
|
|
367
|
+
/**
|
|
368
|
+
* TODO: Should respect debug levels, when to throw...
|
|
369
|
+
*/
|
|
370
|
+
throw(caller: interfaces.TCaller, output: string, name?: string, params?: {}): void;
|
|
371
|
+
beep(): void;
|
|
372
|
+
clone(): any;
|
|
373
|
+
outputEvent(_prefix: string, _timeDiff: string, _source: string, _messagePrefix: string, _message: string, _params: any[]): void;
|
|
374
|
+
private static resolveOwnerName;
|
|
375
|
+
private disableLoggers;
|
|
376
|
+
private getStackTrace;
|
|
377
|
+
getPreviousSource(): string;
|
|
378
|
+
private writeLog;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
declare abstract class LoggerBrowserInfra extends ObjectBase {
|
|
382
|
+
static mappers: Function[];
|
|
383
|
+
static mapperDepth: number;
|
|
384
|
+
static colorsOwners: {
|
|
385
|
+
[key: string]: string;
|
|
386
|
+
};
|
|
387
|
+
static colorsUsed: string[];
|
|
388
|
+
defaultStyle: string[];
|
|
389
|
+
protected readonly owner: ObjectBase | typeof ObjectBase | string;
|
|
390
|
+
protected args: {
|
|
391
|
+
repeatedly: boolean;
|
|
392
|
+
};
|
|
393
|
+
protected color: string;
|
|
394
|
+
private outputHandler;
|
|
395
|
+
static getName(): string;
|
|
396
|
+
/**
|
|
397
|
+
* Reset logger globals.
|
|
398
|
+
*/
|
|
399
|
+
static reset(): void;
|
|
400
|
+
/**
|
|
401
|
+
* Creates a custom mapper for a specific class type.
|
|
402
|
+
*
|
|
403
|
+
* The mapper is a callback function that can modify or enhance objects mapping.
|
|
404
|
+
*/
|
|
405
|
+
static createObjectMapper(callback: Function): void;
|
|
406
|
+
/**
|
|
407
|
+
* Gets mapped version of the object by using custom created object mapper.
|
|
408
|
+
*/
|
|
409
|
+
static useObjectMapper(obj: object, shouldHandleChildren?: boolean): any[] | {
|
|
410
|
+
[key: string]: any;
|
|
411
|
+
};
|
|
412
|
+
constructor(owner: ObjectBase | typeof ObjectBase | string, args?: {});
|
|
413
|
+
protected getOwnerName(): string;
|
|
414
|
+
protected initialize(): void;
|
|
415
|
+
output(...args: any): void;
|
|
416
|
+
protected setOutputHandler(outputHandler: Function): void;
|
|
417
|
+
protected printFunctionNotify(prefix: string, caller: interfaces.TCaller, output: any): void;
|
|
418
|
+
protected printObjectEfficient(prefix: string, caller: interfaces.TCaller, params: string | object): void;
|
|
419
|
+
protected printInLineElement(prefix: string, caller: interfaces.TCaller, key: string, value: any, notice?: string): void;
|
|
420
|
+
protected printInLineFunction(prefix: string, caller: interfaces.TCaller, key: string, fn: string | Function): void;
|
|
421
|
+
protected printInLineString(prefix: string, caller: interfaces.TCaller, string: string): void;
|
|
422
|
+
protected printInNextLineObject(prefix: string, caller: interfaces.TCaller, key: string, obj: object): void;
|
|
423
|
+
protected printMultiLineObject(prefix: string, caller: interfaces.TCaller, obj: {
|
|
424
|
+
[key: string]: string | Function;
|
|
425
|
+
}): void;
|
|
426
|
+
private getRandomColor;
|
|
427
|
+
protected getCallerName(caller: interfaces.TCaller): string;
|
|
428
|
+
private getFunctionView;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
declare interface LoggerOptions {
|
|
432
|
+
skipEventBusHook?: boolean;
|
|
433
|
+
repeatedly?: boolean;
|
|
434
|
+
}
|
|
435
|
+
|
|
356
436
|
declare namespace managers {
|
|
357
437
|
export {
|
|
358
438
|
initialize_2 as initialize,
|
|
@@ -367,34 +447,14 @@ declare namespace managers {
|
|
|
367
447
|
export { managers }
|
|
368
448
|
|
|
369
449
|
declare abstract class ObjectBase {
|
|
370
|
-
private readonly
|
|
450
|
+
private readonly id;
|
|
371
451
|
private readonly name;
|
|
372
|
-
/**
|
|
373
|
-
* Initializes the name and unique identifier for the instance.
|
|
374
|
-
*/
|
|
375
452
|
protected constructor();
|
|
376
|
-
/**
|
|
377
|
-
* Static method to retrieve the name of the class. This method is abstract and must be implemented
|
|
378
|
-
* by derived classes.
|
|
379
|
-
*/
|
|
380
453
|
static getName(): string;
|
|
381
|
-
|
|
382
|
-
* Retrieves the name of the current instance by calling the static `getName()` method of the
|
|
383
|
-
* constructor (derived class).
|
|
384
|
-
*/
|
|
454
|
+
static getSourcePath(): string;
|
|
385
455
|
getName(): string;
|
|
386
|
-
/**
|
|
387
|
-
* Retrieves the unique identifier of the current instance.
|
|
388
|
-
*/
|
|
389
456
|
getUniqueId(): string;
|
|
390
|
-
/**
|
|
391
|
-
* Retrieves the initial name that was set during construction. This name may be "__UNDEFINED_NAME__"
|
|
392
|
-
* if the `getName()` method of the derived class does not provide a valid name.
|
|
393
|
-
*/
|
|
394
457
|
getInitialName(): string;
|
|
395
|
-
/**
|
|
396
|
-
* Retrieves an array of hierarchical class names from the current instance up to the `ObjectBase` class.
|
|
397
|
-
*/
|
|
398
458
|
getHierarchyNames(): string[];
|
|
399
459
|
}
|
|
400
460
|
|