@adaas/a-utils 0.1.32 → 0.1.34
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/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Signal/A-Signal.constants.ts +3 -3
- package/src/lib/A-Signal/A-Signal.types.ts +3 -0
- package/src/lib/A-Signal/components/A-SignalBus.component.ts +3 -20
- package/src/lib/A-Signal/entities/A-Signal.entity.ts +2 -2
- package/src/lib/A-Signal/entities/A-SignalVector.entity.ts +54 -9
- package/tests/A-Signal.test.ts +63 -8
package/dist/index.d.mts
CHANGED
|
@@ -2471,6 +2471,7 @@ type A_SignalConfig_Init = {
|
|
|
2471
2471
|
* OR "A_RouterWatcher,A_ScopeWatcher,A_LoggerWatcher"
|
|
2472
2472
|
*/
|
|
2473
2473
|
stringStructure?: string;
|
|
2474
|
+
propagateSignals?: boolean;
|
|
2474
2475
|
};
|
|
2475
2476
|
type A_SignalVector_Init<_TSignals extends Array<A_Signal> = Array<A_Signal>, _TVectorStructure extends Array<A_TYPES__Entity_Constructor<_TSignals[number]>> = Array<A_TYPES__Entity_Constructor<_TSignals[number]>>> = {
|
|
2476
2477
|
structure: _TVectorStructure;
|
|
@@ -2530,7 +2531,7 @@ declare class A_Signal<_TSignalDataType extends Record<string, any> = Record<str
|
|
|
2530
2531
|
*
|
|
2531
2532
|
* @param scope
|
|
2532
2533
|
*/
|
|
2533
|
-
|
|
2534
|
+
next(scope: A_Scope): Promise<void>;
|
|
2534
2535
|
toJSON(): A_Signal_Serialized<_TSignalDataType>;
|
|
2535
2536
|
}
|
|
2536
2537
|
|
|
@@ -2569,6 +2570,18 @@ declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
|
2569
2570
|
*/
|
|
2570
2571
|
get structure(): TSignalsConstructors;
|
|
2571
2572
|
get length(): number;
|
|
2573
|
+
/**
|
|
2574
|
+
* Enables iteration over the signals in the vector.
|
|
2575
|
+
*
|
|
2576
|
+
* @returns
|
|
2577
|
+
*/
|
|
2578
|
+
[Symbol.iterator](): Iterator<TSignals[number]>;
|
|
2579
|
+
/**
|
|
2580
|
+
* Emits the signal vector to the specified scope.
|
|
2581
|
+
*
|
|
2582
|
+
* @param scope
|
|
2583
|
+
*/
|
|
2584
|
+
next(scope: A_Scope): Promise<void>;
|
|
2572
2585
|
/**
|
|
2573
2586
|
* Checks if the vector contains a signal of the specified type.
|
|
2574
2587
|
*
|
|
@@ -2576,8 +2589,13 @@ declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
|
2576
2589
|
*/
|
|
2577
2590
|
has(signal: A_Signal): boolean;
|
|
2578
2591
|
has(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): boolean;
|
|
2579
|
-
|
|
2580
|
-
|
|
2592
|
+
/**
|
|
2593
|
+
* Retrieves the signal of the specified type from the vector.
|
|
2594
|
+
*
|
|
2595
|
+
* @param signal
|
|
2596
|
+
*/
|
|
2597
|
+
get<T extends A_Signal>(signal: T): T | undefined;
|
|
2598
|
+
get<T extends A_Signal>(signalConstructor: A_TYPES__Entity_Constructor<T>): T | undefined;
|
|
2581
2599
|
/**
|
|
2582
2600
|
* Converts to Array of values of signals in the vector
|
|
2583
2601
|
* Maintains the order specified in the structure/generic type
|
|
@@ -2623,10 +2641,10 @@ declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
|
2623
2641
|
}
|
|
2624
2642
|
|
|
2625
2643
|
declare enum A_SignalFeatures {
|
|
2626
|
-
|
|
2644
|
+
Next = "_A_SignalFeatures_Next"
|
|
2627
2645
|
}
|
|
2628
|
-
declare enum
|
|
2629
|
-
|
|
2646
|
+
declare enum A_SignalVectorFeatures {
|
|
2647
|
+
Next = "_A_SignalVectorFeatures_Next"
|
|
2630
2648
|
}
|
|
2631
2649
|
|
|
2632
2650
|
/**
|
|
@@ -2777,7 +2795,7 @@ declare class A_SignalBus extends A_Component {
|
|
|
2777
2795
|
* @param config
|
|
2778
2796
|
* @returns
|
|
2779
2797
|
*/
|
|
2780
|
-
[A_SignalFeatures.
|
|
2798
|
+
[A_SignalFeatures.Next](signal: A_Signal, scope: A_Scope, globalConfig?: A_Config<['A_SIGNAL_VECTOR_STRUCTURE']>, logger?: A_Logger, state?: A_SignalState, config?: A_SignalConfig): Promise<void>;
|
|
2781
2799
|
}
|
|
2782
2800
|
|
|
2783
2801
|
type A_UTILS_TYPES__ScheduleObjectConfig = {
|
|
@@ -2893,4 +2911,4 @@ declare class A_StateMachineError extends A_Error {
|
|
|
2893
2911
|
static readonly TransitionError = "A-StateMachine Transition Error";
|
|
2894
2912
|
}
|
|
2895
2913
|
|
|
2896
|
-
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, type A_Command_ExecutionContext, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_ExecutionContext, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperationContextMeta, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus,
|
|
2914
|
+
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, type A_Command_ExecutionContext, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_ExecutionContext, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperationContextMeta, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus, A_SignalConfig, type A_SignalConfig_Init, A_SignalFeatures, A_SignalState, A_SignalVector, A_SignalVectorFeatures, type A_SignalVector_Init, type A_SignalVector_Serialized, type A_Signal_Init, type A_Signal_Serialized, A_StateMachine, A_StateMachineError, A_StateMachineFeatures, A_StateMachineTransition, type A_StateMachineTransitionParams, type A_StateMachineTransitionStorage, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|
package/dist/index.d.ts
CHANGED
|
@@ -2471,6 +2471,7 @@ type A_SignalConfig_Init = {
|
|
|
2471
2471
|
* OR "A_RouterWatcher,A_ScopeWatcher,A_LoggerWatcher"
|
|
2472
2472
|
*/
|
|
2473
2473
|
stringStructure?: string;
|
|
2474
|
+
propagateSignals?: boolean;
|
|
2474
2475
|
};
|
|
2475
2476
|
type A_SignalVector_Init<_TSignals extends Array<A_Signal> = Array<A_Signal>, _TVectorStructure extends Array<A_TYPES__Entity_Constructor<_TSignals[number]>> = Array<A_TYPES__Entity_Constructor<_TSignals[number]>>> = {
|
|
2476
2477
|
structure: _TVectorStructure;
|
|
@@ -2530,7 +2531,7 @@ declare class A_Signal<_TSignalDataType extends Record<string, any> = Record<str
|
|
|
2530
2531
|
*
|
|
2531
2532
|
* @param scope
|
|
2532
2533
|
*/
|
|
2533
|
-
|
|
2534
|
+
next(scope: A_Scope): Promise<void>;
|
|
2534
2535
|
toJSON(): A_Signal_Serialized<_TSignalDataType>;
|
|
2535
2536
|
}
|
|
2536
2537
|
|
|
@@ -2569,6 +2570,18 @@ declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
|
2569
2570
|
*/
|
|
2570
2571
|
get structure(): TSignalsConstructors;
|
|
2571
2572
|
get length(): number;
|
|
2573
|
+
/**
|
|
2574
|
+
* Enables iteration over the signals in the vector.
|
|
2575
|
+
*
|
|
2576
|
+
* @returns
|
|
2577
|
+
*/
|
|
2578
|
+
[Symbol.iterator](): Iterator<TSignals[number]>;
|
|
2579
|
+
/**
|
|
2580
|
+
* Emits the signal vector to the specified scope.
|
|
2581
|
+
*
|
|
2582
|
+
* @param scope
|
|
2583
|
+
*/
|
|
2584
|
+
next(scope: A_Scope): Promise<void>;
|
|
2572
2585
|
/**
|
|
2573
2586
|
* Checks if the vector contains a signal of the specified type.
|
|
2574
2587
|
*
|
|
@@ -2576,8 +2589,13 @@ declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
|
2576
2589
|
*/
|
|
2577
2590
|
has(signal: A_Signal): boolean;
|
|
2578
2591
|
has(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): boolean;
|
|
2579
|
-
|
|
2580
|
-
|
|
2592
|
+
/**
|
|
2593
|
+
* Retrieves the signal of the specified type from the vector.
|
|
2594
|
+
*
|
|
2595
|
+
* @param signal
|
|
2596
|
+
*/
|
|
2597
|
+
get<T extends A_Signal>(signal: T): T | undefined;
|
|
2598
|
+
get<T extends A_Signal>(signalConstructor: A_TYPES__Entity_Constructor<T>): T | undefined;
|
|
2581
2599
|
/**
|
|
2582
2600
|
* Converts to Array of values of signals in the vector
|
|
2583
2601
|
* Maintains the order specified in the structure/generic type
|
|
@@ -2623,10 +2641,10 @@ declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
|
2623
2641
|
}
|
|
2624
2642
|
|
|
2625
2643
|
declare enum A_SignalFeatures {
|
|
2626
|
-
|
|
2644
|
+
Next = "_A_SignalFeatures_Next"
|
|
2627
2645
|
}
|
|
2628
|
-
declare enum
|
|
2629
|
-
|
|
2646
|
+
declare enum A_SignalVectorFeatures {
|
|
2647
|
+
Next = "_A_SignalVectorFeatures_Next"
|
|
2630
2648
|
}
|
|
2631
2649
|
|
|
2632
2650
|
/**
|
|
@@ -2777,7 +2795,7 @@ declare class A_SignalBus extends A_Component {
|
|
|
2777
2795
|
* @param config
|
|
2778
2796
|
* @returns
|
|
2779
2797
|
*/
|
|
2780
|
-
[A_SignalFeatures.
|
|
2798
|
+
[A_SignalFeatures.Next](signal: A_Signal, scope: A_Scope, globalConfig?: A_Config<['A_SIGNAL_VECTOR_STRUCTURE']>, logger?: A_Logger, state?: A_SignalState, config?: A_SignalConfig): Promise<void>;
|
|
2781
2799
|
}
|
|
2782
2800
|
|
|
2783
2801
|
type A_UTILS_TYPES__ScheduleObjectConfig = {
|
|
@@ -2893,4 +2911,4 @@ declare class A_StateMachineError extends A_Error {
|
|
|
2893
2911
|
static readonly TransitionError = "A-StateMachine Transition Error";
|
|
2894
2912
|
}
|
|
2895
2913
|
|
|
2896
|
-
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, type A_Command_ExecutionContext, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_ExecutionContext, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperationContextMeta, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus,
|
|
2914
|
+
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, type A_Command_ExecutionContext, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_ExecutionContext, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperationContextMeta, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus, A_SignalConfig, type A_SignalConfig_Init, A_SignalFeatures, A_SignalState, A_SignalVector, A_SignalVectorFeatures, type A_SignalVector_Init, type A_SignalVector_Serialized, type A_Signal_Init, type A_Signal_Serialized, A_StateMachine, A_StateMachineError, A_StateMachineFeatures, A_StateMachineTransition, type A_StateMachineTransitionParams, type A_StateMachineTransitionStorage, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {A_Feature,A_Inject,A_Scope,A_Error,A_Dependency,A_Concept,A_Container,A_Caller,A_TypeGuards,A_Component,A_IdentityHelper,A_Context,A_FormatterHelper,A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,A_Entity,A_Fragment,A_Meta,A_ScopeError,A_CommonHelper}from'@adaas/a-concept';var wt=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var i=(j,t)=>wt(j,"name",{value:t,configurable:true});var c=(j,t,e,r)=>{for(var o=r>1?void 0:r?zt(t,e):t,n=j.length-1,s;n>=0;n--)(s=j[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&wt(t,e,o),o},l=(j,t)=>(e,r)=>t(e,r,j);var Ge=class Ge extends A_Fragment{constructor(t,e){super({name:t}),this._meta=new A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){this._meta.set(t,e);}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){this._meta.clear();}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i(Ge,"A_ExecutionContext");var b=Ge;var Ue=class Ue extends b{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(Ue,"A_OperationContext");var d=Ue;var ye=class ye extends A_Error{constructor(t,e){A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof d&&(this._context=e);}get context(){return this._context}};i(ye,"A_ChannelError"),ye.MethodNotImplemented="A-Channel Method Not Implemented";var q=ye;var jt=(u=>(u.onTimeout="_A_Channel_onTimeout",u.onRetry="_A_Channel_onRetry",u.onCircuitBreakerOpen="_A_Channel_onCircuitBreakerOpen",u.onCache="_A_Channel_onCache",u.onConnect="_A_Channel_onConnect",u.onDisconnect="_A_Channel_onDisconnect",u.onBeforeRequest="_A_Channel_onBeforeRequest",u.onRequest="_A_Channel_onRequest",u.onAfterRequest="_A_Channel_onAfterRequest",u.onError="_A_Channel_onError",u.onSend="_A_Channel_onSend",u.onConsume="_A_Channel_onConsume",u))(jt||{}),qt=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(qt||{});var Ye=class Ye extends d{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(Ye,"A_ChannelRequest");var le=Ye;var M=class M extends A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("_A_Channel_onConnect");}async disconnect(){await this.call("_A_Channel_onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:request:${A_IdentityHelper.generateTimeId()}`}).inherit(A_Context.scope(this)),o=new le(e);try{return r.register(o),await this.call("_A_Channel_onBeforeRequest",r),await this.call("_A_Channel_onRequest",r),await this.call("_A_Channel_onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new q(n);throw o.fail(s),r.register(s),await this.call("_A_Channel_onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:send:${A_IdentityHelper.generateTimeId()}`}).inherit(A_Context.scope(this)),o=new d("send",e);try{r.inherit(A_Context.scope(this)),r.register(o),await this.call("_A_Channel_onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new q(n);r.register(s),o.fail(s),await this.call("_A_Channel_onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new A_Scope({name:`a-channel@scope:consume:${A_IdentityHelper.generateTimeId()}`}).inherit(A_Context.scope(this)),r=new d("consume",{});try{return e.inherit(A_Context.scope(this)),e.register(r),await this.call("_A_Channel_onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new q(o);return r.fail(n),await this.call("_A_Channel_onError",e),r}}};i(M,"A_Channel"),c([A_Feature.Extend({name:"_A_Channel_onConnect"})],M.prototype,"onConnect",1),c([A_Feature.Extend({name:"_A_Channel_onDisconnect"})],M.prototype,"onDisconnect",1),c([A_Feature.Extend({name:"_A_Channel_onBeforeRequest"})],M.prototype,"onBeforeRequest",1),c([A_Feature.Extend({name:"_A_Channel_onRequest"})],M.prototype,"onRequest",1),c([A_Feature.Extend({name:"_A_Channel_onAfterRequest"})],M.prototype,"onAfterRequest",1),c([A_Feature.Extend({name:"_A_Channel_onError"})],M.prototype,"onError",1),c([A_Feature.Extend({name:"_A_Channel_onSend"})],M.prototype,"onSend",1);var Be=M;var Wt=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))(Wt||{}),Jt=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(Jt||{}),Xt=(a=>(a.onInit="_A_Command_onInit",a.onBeforeExecute="_A_Command_onBeforeExecute",a.onExecute="_A_Command_onExecute",a.onAfterExecute="_A_Command_onAfterExecute",a.onComplete="_A_Command_onComplete",a.onFail="_A_Command_onFail",a.onError="_A_Command_onError",a))(Xt||{}),Zt=(a=>(a.onInit="onInit",a.onBeforeExecute="onBeforeExecute",a.onExecute="onExecute",a.onAfterExecute="onAfterExecute",a.onComplete="onComplete",a.onFail="onFail",a.onError="onError",a))(Zt||{});var W=class W extends A_Error{};i(W,"A_CommandError"),W.CommandScopeBindingError="A-Command Scope Binding Error",W.ExecutionError="A-Command Execution Error",W.ResultProcessingError="A-Command Result Processing Error",W.CommandInterruptedError="A-Command Interrupted Error";var Y=W;var pe=class pe extends A_Error{};i(pe,"A_StateMachineError"),pe.InitializationError="A-StateMachine Initialization Error",pe.TransitionError="A-StateMachine Transition Error";var Z=pe;var tr=(o=>(o.onError="_A_StateMachine_onError",o.onInitialize="_A_StateMachine_onInitialize",o.onBeforeTransition="_A_StateMachine_onBeforeTransition",o.onAfterTransition="_A_StateMachine_onAfterTransition",o))(tr||{});var Ve=class Ve extends d{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(Ve,"A_StateMachineTransition");var D=Ve;var ir,sr,ar,cr,J=class J extends A_Component{get ready(){return this._initialized||(this._initialized=this.call("_A_StateMachine_onInitialize")),this._initialized}async[cr="_A_StateMachine_onInitialize"](...t){}async[ar="_A_StateMachine_onBeforeTransition"](...t){}async[sr="_A_StateMachine_onAfterTransition"](...t){}async[ir="_A_StateMachine_onError"](...t){}async transition(t,e,r){await this.ready;let o=`${A_FormatterHelper.toCamelCase(String(t))}_${A_FormatterHelper.toCamelCase(String(e))}`,n=new D({from:String(t),to:String(e),props:r}),s=new A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]}).inherit(A_Context.scope(this));try{return await this.call("_A_StateMachine_onBeforeTransition",s),await this.call(o,s),await this.call("_A_StateMachine_onAfterTransition",s),s.destroy(),n.result}catch(a){let _=new Z({title:Z.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:a});throw s.register(_),await this.call("_A_StateMachine_onError",s),s.destroy(),_}}};i(J,"A_StateMachine"),c([A_Feature.Extend()],J.prototype,cr,1),c([A_Feature.Extend()],J.prototype,ar,1),c([A_Feature.Extend()],J.prototype,sr,1),c([A_Feature.Extend()],J.prototype,ir,1);var $=J;var bn={},Q=[];var Ee=class Ee extends A_Error{};i(Ee,"A_ConfigError"),Ee.InitializationError="A-Config Initialization Error";var G=Ee;var je=class je extends b{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...Q];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(A_FormatterHelper.toUpperSnakeCase(e));throw new G("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o)super.set(A_FormatterHelper.toUpperSnakeCase(n),s);}};i(je,"A_Config");var A=je;var Lt=20,Vn="all",vt={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},It=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],V={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},ee={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},y={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},te={DEFAULT_WIDTH:80,MIN_WIDTH:40,MAX_LINE_LENGTH_RATIO:.8,BROWSER_DEFAULT_WIDTH:120},me={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};var T=class extends A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=vt,this.STANDARD_SCOPE_LENGTH=r?.get(me.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(me.DEFAULT_SCOPE_COLOR),n=r?.get(me.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}this.TERMINAL_WIDTH=this.detectTerminalWidth(),this.MAX_CONTENT_WIDTH=Math.floor(this.TERMINAL_WIDTH*te.MAX_LINE_LENGTH_RATIO);}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=It,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}detectTerminalWidth(){try{if(A_Context.environment==="browser")return te.BROWSER_DEFAULT_WIDTH;if(typeof process<"u"&&process.stdout&&process.stdout.columns){let e=process.stdout.columns;return Math.max(e,te.MIN_WIDTH)}return te.DEFAULT_WIDTH}catch{return te.DEFAULT_WIDTH}}wrapText(e,r,o=true){if(A_Context.environment==="browser")return [e];let n=this.formattedScope.length+4+this.getTime().length+4,s=`${r}${y.PIPE}`,a=Math.max(this.TERMINAL_WIDTH-n-1,20),_=Math.max(this.TERMINAL_WIDTH-s.length,20);if(o&&e.length<=a)return [e];let m=[],p=e.split(" "),h="",u=o?a:_;for(let k of p){let Me=h?1:0;if(h.length+Me+k.length>u)if(h)m.push(h),h=k,u=_;else {if(k.length>u){let $e=this.splitLongWord(k,u);m.push(...$e.slice(0,-1)),h=$e[$e.length-1];}else h=k;u=_;}else h+=(h?" ":"")+k;}return h&&m.push(h),m.length?m:[e]}splitLongWord(e,r){let o=[];for(let n=0;n<e.length;n+=r)o.push(e.slice(n,n+r));return o}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.STANDARD_SCOPE_LENGTH+3),s=r.length>1;return [`${V.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${V.SUFFIX}${y.SCOPE_OPEN}${this.formattedScope}${y.SCOPE_CLOSE}${V.RESET} ${V.PREFIX}${this.COLORS[e]}${V.SUFFIX}${y.TIME_OPEN}${o}${y.TIME_CLOSE}`,s?`
|
|
2
|
-
${n}${y.TIME_OPEN}${y.SEPARATOR}`:"",...r.map((a,_)=>{let
|
|
1
|
+
import {A_Feature,A_Inject,A_Scope,A_Error,A_Dependency,A_Concept,A_Container,A_Caller,A_TypeGuards,A_Component,A_IdentityHelper,A_Context,A_FormatterHelper,A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,A_Entity,A_Fragment,A_Meta,A_ScopeError,A_CommonHelper}from'@adaas/a-concept';var wt=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var i=(j,t)=>wt(j,"name",{value:t,configurable:true});var c=(j,t,e,r)=>{for(var o=r>1?void 0:r?Yt(t,e):t,n=j.length-1,s;n>=0;n--)(s=j[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&wt(t,e,o),o},l=(j,t)=>(e,r)=>t(e,r,j);var $e=class $e extends A_Fragment{constructor(t,e){super({name:t}),this._meta=new A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){this._meta.set(t,e);}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){this._meta.clear();}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i($e,"A_ExecutionContext");var b=$e;var Ue=class Ue extends b{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(Ue,"A_OperationContext");var u=Ue;var ye=class ye extends A_Error{constructor(t,e){A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof u&&(this._context=e);}get context(){return this._context}};i(ye,"A_ChannelError"),ye.MethodNotImplemented="A-Channel Method Not Implemented";var q=ye;var Ht=(m=>(m.onTimeout="_A_Channel_onTimeout",m.onRetry="_A_Channel_onRetry",m.onCircuitBreakerOpen="_A_Channel_onCircuitBreakerOpen",m.onCache="_A_Channel_onCache",m.onConnect="_A_Channel_onConnect",m.onDisconnect="_A_Channel_onDisconnect",m.onBeforeRequest="_A_Channel_onBeforeRequest",m.onRequest="_A_Channel_onRequest",m.onAfterRequest="_A_Channel_onAfterRequest",m.onError="_A_Channel_onError",m.onSend="_A_Channel_onSend",m.onConsume="_A_Channel_onConsume",m))(Ht||{}),jt=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(jt||{});var Ye=class Ye extends u{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(Ye,"A_ChannelRequest");var le=Ye;var M=class M extends A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("_A_Channel_onConnect");}async disconnect(){await this.call("_A_Channel_onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:request:${A_IdentityHelper.generateTimeId()}`}).inherit(A_Context.scope(this)),o=new le(e);try{return r.register(o),await this.call("_A_Channel_onBeforeRequest",r),await this.call("_A_Channel_onRequest",r),await this.call("_A_Channel_onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new q(n);throw o.fail(s),r.register(s),await this.call("_A_Channel_onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:send:${A_IdentityHelper.generateTimeId()}`}).inherit(A_Context.scope(this)),o=new u("send",e);try{r.inherit(A_Context.scope(this)),r.register(o),await this.call("_A_Channel_onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new q(n);r.register(s),o.fail(s),await this.call("_A_Channel_onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new A_Scope({name:`a-channel@scope:consume:${A_IdentityHelper.generateTimeId()}`}).inherit(A_Context.scope(this)),r=new u("consume",{});try{return e.inherit(A_Context.scope(this)),e.register(r),await this.call("_A_Channel_onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new q(o);return r.fail(n),await this.call("_A_Channel_onError",e),r}}};i(M,"A_Channel"),c([A_Feature.Extend({name:"_A_Channel_onConnect"})],M.prototype,"onConnect",1),c([A_Feature.Extend({name:"_A_Channel_onDisconnect"})],M.prototype,"onDisconnect",1),c([A_Feature.Extend({name:"_A_Channel_onBeforeRequest"})],M.prototype,"onBeforeRequest",1),c([A_Feature.Extend({name:"_A_Channel_onRequest"})],M.prototype,"onRequest",1),c([A_Feature.Extend({name:"_A_Channel_onAfterRequest"})],M.prototype,"onAfterRequest",1),c([A_Feature.Extend({name:"_A_Channel_onError"})],M.prototype,"onError",1),c([A_Feature.Extend({name:"_A_Channel_onSend"})],M.prototype,"onSend",1);var Be=M;var Kt=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))(Kt||{}),Wt=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(Wt||{}),Jt=(a=>(a.onInit="_A_Command_onInit",a.onBeforeExecute="_A_Command_onBeforeExecute",a.onExecute="_A_Command_onExecute",a.onAfterExecute="_A_Command_onAfterExecute",a.onComplete="_A_Command_onComplete",a.onFail="_A_Command_onFail",a.onError="_A_Command_onError",a))(Jt||{}),Xt=(a=>(a.onInit="onInit",a.onBeforeExecute="onBeforeExecute",a.onExecute="onExecute",a.onAfterExecute="onAfterExecute",a.onComplete="onComplete",a.onFail="onFail",a.onError="onError",a))(Xt||{});var W=class W extends A_Error{};i(W,"A_CommandError"),W.CommandScopeBindingError="A-Command Scope Binding Error",W.ExecutionError="A-Command Execution Error",W.ResultProcessingError="A-Command Result Processing Error",W.CommandInterruptedError="A-Command Interrupted Error";var Y=W;var pe=class pe extends A_Error{};i(pe,"A_StateMachineError"),pe.InitializationError="A-StateMachine Initialization Error",pe.TransitionError="A-StateMachine Transition Error";var Z=pe;var er=(o=>(o.onError="_A_StateMachine_onError",o.onInitialize="_A_StateMachine_onInitialize",o.onBeforeTransition="_A_StateMachine_onBeforeTransition",o.onAfterTransition="_A_StateMachine_onAfterTransition",o))(er||{});var Ve=class Ve extends u{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(Ve,"A_StateMachineTransition");var N=Ve;var nr,ir,sr,ar,J=class J extends A_Component{get ready(){return this._initialized||(this._initialized=this.call("_A_StateMachine_onInitialize")),this._initialized}async[ar="_A_StateMachine_onInitialize"](...t){}async[sr="_A_StateMachine_onBeforeTransition"](...t){}async[ir="_A_StateMachine_onAfterTransition"](...t){}async[nr="_A_StateMachine_onError"](...t){}async transition(t,e,r){await this.ready;let o=`${A_FormatterHelper.toCamelCase(String(t))}_${A_FormatterHelper.toCamelCase(String(e))}`,n=new N({from:String(t),to:String(e),props:r}),s=new A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]}).inherit(A_Context.scope(this));try{return await this.call("_A_StateMachine_onBeforeTransition",s),await this.call(o,s),await this.call("_A_StateMachine_onAfterTransition",s),s.destroy(),n.result}catch(a){let _=new Z({title:Z.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:a});throw s.register(_),await this.call("_A_StateMachine_onError",s),s.destroy(),_}}};i(J,"A_StateMachine"),c([A_Feature.Extend()],J.prototype,ar,1),c([A_Feature.Extend()],J.prototype,sr,1),c([A_Feature.Extend()],J.prototype,ir,1),c([A_Feature.Extend()],J.prototype,nr,1);var G=J;var bn={},Q=[];var Ee=class Ee extends A_Error{};i(Ee,"A_ConfigError"),Ee.InitializationError="A-Config Initialization Error";var $=Ee;var je=class je extends b{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...Q];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(A_FormatterHelper.toUpperSnakeCase(e));throw new $("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o)super.set(A_FormatterHelper.toUpperSnakeCase(n),s);}};i(je,"A_Config");var A=je;var vt=20,Vn="all",Lt={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},It=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],V={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},ee={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},y={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},te={DEFAULT_WIDTH:80,MIN_WIDTH:40,MAX_LINE_LENGTH_RATIO:.8,BROWSER_DEFAULT_WIDTH:120},de={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};var T=class extends A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=Lt,this.STANDARD_SCOPE_LENGTH=r?.get(de.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(de.DEFAULT_SCOPE_COLOR),n=r?.get(de.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}this.TERMINAL_WIDTH=this.detectTerminalWidth(),this.MAX_CONTENT_WIDTH=Math.floor(this.TERMINAL_WIDTH*te.MAX_LINE_LENGTH_RATIO);}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=It,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}detectTerminalWidth(){try{if(A_Context.environment==="browser")return te.BROWSER_DEFAULT_WIDTH;if(typeof process<"u"&&process.stdout&&process.stdout.columns){let e=process.stdout.columns;return Math.max(e,te.MIN_WIDTH)}return te.DEFAULT_WIDTH}catch{return te.DEFAULT_WIDTH}}wrapText(e,r,o=true){if(A_Context.environment==="browser")return [e];let n=this.formattedScope.length+4+this.getTime().length+4,s=`${r}${y.PIPE}`,a=Math.max(this.TERMINAL_WIDTH-n-1,20),_=Math.max(this.TERMINAL_WIDTH-s.length,20);if(o&&e.length<=a)return [e];let d=[],p=e.split(" "),h="",m=o?a:_;for(let k of p){let Me=h?1:0;if(h.length+Me+k.length>m)if(h)d.push(h),h=k,m=_;else {if(k.length>m){let Ge=this.splitLongWord(k,m);d.push(...Ge.slice(0,-1)),h=Ge[Ge.length-1];}else h=k;m=_;}else h+=(h?" ":"")+k;}return h&&d.push(h),d.length?d:[e]}splitLongWord(e,r){let o=[];for(let n=0;n<e.length;n+=r)o.push(e.slice(n,n+r));return o}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.STANDARD_SCOPE_LENGTH+3),s=r.length>1;return [`${V.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${V.SUFFIX}${y.SCOPE_OPEN}${this.formattedScope}${y.SCOPE_CLOSE}${V.RESET} ${V.PREFIX}${this.COLORS[e]}${V.SUFFIX}${y.TIME_OPEN}${o}${y.TIME_CLOSE}`,s?`
|
|
2
|
+
${n}${y.TIME_OPEN}${y.SEPARATOR}`:"",...r.map((a,_)=>{let d=_>0||s;switch(true){case a instanceof A_Error:return this.compile_A_Error(a);case a instanceof Error:return this.compile_Error(a);case(typeof a=="object"&&a!==null):return this.formatObject(a,d,n);default:return this.formatString(String(a),d,n)}}),s?`
|
|
3
3
|
${n}${y.TIME_OPEN}${y.SEPARATOR}${V.RESET}`:V.RESET]}formatObject(e,r,o){if(A_Context.environment==="browser")return e;if(e===null)return r?`
|
|
4
4
|
${o}${y.PIPE}null`:"null";if(e===void 0)return r?`
|
|
5
|
-
${o}${y.PIPE}undefined`:"undefined";let n;try{n=JSON.stringify(e,null,2);}catch{try{let h=new WeakSet;n=JSON.stringify(e,(
|
|
6
|
-
`).map(p=>{let h=p.match(/^(\s*"[^"]+":\s*")([^"]+)(".*)?$/);if(h&&h[2].length>a-h[1].length-(h[3]||"").length){let[,
|
|
5
|
+
${o}${y.PIPE}undefined`:"undefined";let n;try{n=JSON.stringify(e,null,2);}catch{try{let h=new WeakSet;n=JSON.stringify(e,(m,O)=>{if(typeof O=="object"&&O!==null){if(h.has(O))return "[Circular Reference]";h.add(O);}return O},2);}catch{n=String(e);}}let s=`${o}${y.PIPE}`,a=this.TERMINAL_WIDTH-s.length-4,d=n.split(`
|
|
6
|
+
`).map(p=>{let h=p.match(/^(\s*"[^"]+":\s*")([^"]+)(".*)?$/);if(h&&h[2].length>a-h[1].length-(h[3]||"").length){let[,m,O,k=""]=h;if(O.length>a-m.length-k.length){let Me=this.wrapJsonStringValue(O,a-m.length-k.length);return m+Me+k}}return p}).join(`
|
|
7
7
|
`+s);return r?`
|
|
8
|
-
`+s+
|
|
8
|
+
`+s+d:d}wrapJsonStringValue(e,r){return e.length<=r?e:r>6?e.substring(0,r-3)+"...":e.substring(0,Math.max(1,r))}formatString(e,r,o){if(A_Context.environment==="browser")return ((r?`
|
|
9
9
|
`:"")+e).replace(/\n/g,`
|
|
10
|
-
${o}${y.PIPE}`);let n=this.wrapText(e,o,!r),s=`${o}${y.PIPE}`,a=n.map((_,
|
|
10
|
+
${o}${y.PIPE}`);let n=this.wrapText(e,o,!r),s=`${o}${y.PIPE}`,a=n.map((_,d)=>d===0&&!r?_:`${s}${_}`);return r?`
|
|
11
11
|
`+a.join(`
|
|
12
12
|
`):a.join(`
|
|
13
|
-
`)}shouldLog(e){switch(this.config?.get(
|
|
13
|
+
`)}shouldLog(e){switch(this.config?.get(de.LOG_LEVEL)||"info"){case "debug":return true;case "info":return e==="info"||e==="warning"||e==="error";case "warn":return e==="warning"||e==="error";case "error":return e==="error";case "all":return true;default:return false}}debug(e,...r){this.shouldLog("debug")&&(typeof e=="string"&&this.COLORS[e]?console.log(...this.compile(e,...r)):console.log(...this.compile(this.DEFAULT_LOG_COLOR,e,...r)));}info(e,...r){this.shouldLog("info")&&(typeof e=="string"&&this.COLORS[e]?console.log(...this.compile(e,...r)):console.log(...this.compile(this.DEFAULT_LOG_COLOR,e,...r)));}log(e,...r){this.info(e,...r);}warning(...e){this.shouldLog("warning")&&console.log(...this.compile("yellow",...e));}error(...e){this.shouldLog("error")&&console.log(...this.compile("red",...e));}log_A_Error(e){let r=this.getTime(),o=" ".repeat(this.STANDARD_SCOPE_LENGTH+3);console.log(`\x1B[31m[${this.formattedScope}] |${r}| ERROR ${e.code}
|
|
14
14
|
${o}| ${e.message}
|
|
15
15
|
${o}| ${e.description}
|
|
16
16
|
${o}|-------------------------------
|
|
@@ -26,10 +26,10 @@ ${o}| ${e.originalError.stack?.split(`
|
|
|
26
26
|
${o}|-------------------------------
|
|
27
27
|
\x1B[0m`:"")+(e.link?`\x1B[31m${o}| Read in docs: ${e.link}
|
|
28
28
|
${o}|-------------------------------
|
|
29
|
-
\x1B[0m`:""));}compile_A_Error(e){let r=`${" ".repeat(this.STANDARD_SCOPE_LENGTH+3)}${y.PIPE}`,o=`${r}-------------------------------`,n=[];n.push(""),n.push(o),n.push(`${r}A_ERROR: ${e.code}`),n.push(o);let s=this.wrapText(`Message: ${e.message}`,r,false),a=this.wrapText(`Description: ${e.description}`,r,false);if(n.push(...s.map(_=>`${r}${_}`)),n.push(...a.map(_=>`${r}${_}`)),e.originalError){n.push(o),n.push(`${r}ORIGINAL ERROR:`),n.push(o);let _=this.wrapText(`${e.originalError.name}: ${e.originalError.message}`,r,false);if(n.push(..._.map(
|
|
29
|
+
\x1B[0m`:""));}compile_A_Error(e){let r=`${" ".repeat(this.STANDARD_SCOPE_LENGTH+3)}${y.PIPE}`,o=`${r}-------------------------------`,n=[];n.push(""),n.push(o),n.push(`${r}A_ERROR: ${e.code}`),n.push(o);let s=this.wrapText(`Message: ${e.message}`,r,false),a=this.wrapText(`Description: ${e.description}`,r,false);if(n.push(...s.map(_=>`${r}${_}`)),n.push(...a.map(_=>`${r}${_}`)),e.originalError){n.push(o),n.push(`${r}ORIGINAL ERROR:`),n.push(o);let _=this.wrapText(`${e.originalError.name}: ${e.originalError.message}`,r,false);if(n.push(..._.map(d=>`${r}${d}`)),e.originalError.stack){n.push(`${r}Stack trace:`);let d=this.formatStackTrace(e.originalError.stack,r);n.push(...d);}}if(e.stack){n.push(o),n.push(`${r}A_ERROR STACK:`),n.push(o);let _=this.formatStackTrace(e.stack,r);n.push(..._);}if(e.link){n.push(o);let _=this.wrapText(`Documentation: ${e.link}`,r,false);n.push(..._.map(d=>`${r}${d}`));}return n.push(o),n.join(`
|
|
30
30
|
`)}formatStackTrace(e,r){let o=e.split(`
|
|
31
|
-
`),n=[];return o.forEach((s,a)=>{if(s.trim()){let _=a===0?r:`${r} `,
|
|
32
|
-
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(ee.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(ee.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(ee.MILLISECONDS_PAD,"0");return `${r}${ee.SEPARATOR}${o}${ee.SEPARATOR}${n}`}};i(T,"A_Logger"),T=c([l(0,A_Inject(A_Scope)),l(1,A_Inject(A))],T);var hr,gr,fr,yr,Ar,Er,Tr,Sr,Cr,xr,Rr,x=class x extends A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(b)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[Rr="_A_StateMachine_onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[xr="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[Cr="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[Sr="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[Tr="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[Er="_A_Command_onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[Ar="_A_Command_onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[yr="_A_Command_onExecute"](...e){}async[fr="_A_Command_onAfterExecute"](...e){}async[gr="_A_Command_onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[hr="_A_Command_onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("_A_Command_onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new b("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new A_Feature({name:"_A_Command_onBeforeExecute",component:this,scope:this.scope}),s=new A_Feature({name:"_A_Command_onExecute",component:this,scope:this.scope}),a=new A_Feature({name:"_A_Command_onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),a.interrupt(),r();}),this.on("onFail",()=>{n.interrupt(),s.interrupt(),a.interrupt(),o(this.error);}),await n.process(this.scope),await s.process(this.scope),await a.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof A_Error?e:new Y({title:Y.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("_A_Command_onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("_A_Command_onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[$]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[$]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new Y(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=A_Context.scope(this);}catch(r){throw new Y({title:Y.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(A_Context.scope(this))||this.scope.inherit(A_Context.scope(this));}};i(x,"A_Command"),c([A_Feature.Extend(),l(0,A_Inject(D)),l(1,A_Inject(T))],x.prototype,Rr,1),c([A_Feature.Extend(),l(0,A_Inject(D))],x.prototype,xr,1),c([A_Feature.Extend(),l(0,A_Inject(D))],x.prototype,Cr,1),c([A_Feature.Extend(),l(0,A_Inject(D))],x.prototype,Sr,1),c([A_Feature.Extend(),l(0,A_Inject(D)),l(1,A_Inject(A_Error))],x.prototype,Tr,1),c([A_Feature.Extend(),l(0,A_Inject($))],x.prototype,Er,1),c([A_Feature.Extend({after:/.*/}),l(0,A_Dependency.Required()),l(0,A_Inject($))],x.prototype,Ar,1),c([A_Feature.Extend()],x.prototype,yr,1),c([A_Feature.Extend()],x.prototype,fr,1),c([A_Feature.Extend({after:/.*/}),l(0,A_Inject($))],x.prototype,gr,1),c([A_Feature.Extend({after:/.*/}),l(0,A_Dependency.Required()),l(0,A_Inject($)),l(1,A_Inject(b))],x.prototype,hr,1);var Ke=x;var We=class We{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(We,"A_FSPolyfillClass");var Se=We;var Je=class Je{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),a=this._fsPolyfill.createReadStream(e);a.on("data",_=>s.update(_)),a.on("end",()=>o(`${r}-${s.digest("base64")}`)),a.on("error",_=>n(_));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),a=await crypto.subtle.digest(e,s),_=Array.from(new Uint8Array(a)),m=btoa(String.fromCharCode(..._));r(`${e}-${m}`);}catch(n){o(n);}}),"createTextHash")};}};i(Je,"A_CryptoPolyfillClass");var Ce=Je;var Xe=class Xe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,a)=>{s==="data"?setTimeout(()=>a("mock data"),0):s==="end"&&setTimeout(()=>a(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Xe,"A_HttpPolyfillClass");var xe=Xe;var Ze=class Ze{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,a)=>{s==="data"?setTimeout(()=>a("mock data"),0):s==="end"&&setTimeout(()=>a(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Ze,"A_HttpsPolyfillClass");var Re=Ze;var Qe=class Qe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(Qe,"A_PathPolyfillClass");var we=Qe;var et=class et{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(et,"A_UrlPolyfillClass");var Pe=et;var tt=class tt{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,a)=>s+a.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(tt,"A_BufferPolyfillClass");var Le=tt;var rt=class rt{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(rt,"A_ProcessPolyfillClass");var ve=rt;var f=class extends A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new Se(this.logger),this._cryptoPolyfill=new Ce(this.logger),this._httpPolyfill=new xe(this.logger),this._httpsPolyfill=new Re(this.logger),this._pathPolyfill=new we(this.logger),this._urlPolyfill=new Pe(this.logger),this._bufferPolyfill=new Le(this.logger),this._processPolyfill=new ve(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(f,"A_Polyfill"),c([A_Concept.Load()],f.prototype,"load",1),c([A_Concept.Load()],f.prototype,"attachToWindow",1),f=c([l(0,A_Inject(T))],f);var R=class extends A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...Q];}async attachContext(e,r,o){o||(o=new A({defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read();for(let o in r)e.set(o,r[o]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(R,"ConfigReader"),c([A_Concept.Load(),l(0,A_Inject(A_Container)),l(1,A_Inject(A_Scope)),l(2,A_Inject(A))],R.prototype,"attachContext",1),c([A_Concept.Load(),l(0,A_Dependency.Required()),l(0,A_Inject(A))],R.prototype,"initialize",1),R=c([l(0,A_Dependency.Required()),l(0,A_Inject(f))],R);var ot=class ot extends R{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(ot,"FileConfigReader");var ue=ot;var Ie=class Ie extends R{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
33
|
-
`).forEach(n=>{let[s,a]=n.split("=");s&&a&&(process.env[s.trim()]=a.trim());});}getConfigurationProperty_ENV_Alias(t){return A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(Ie,"ENVConfigReader"),c([A_Concept.Load({before:["ENVConfigReader.initialize"]}),l(0,A_Inject(A)),l(1,A_Inject(f)),l(2,A_Inject(A_Feature))],Ie.prototype,"readEnvFile",1);var re=Ie;var Oe=class Oe extends A_Container{async prepare(t){if(!this.scope.has(A)){let r=new A({variables:[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...Q],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(A_Context.environment==="server"&&!!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(ue);break;case(A_Context.environment==="server"&&!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(re);break;case A_Context.environment==="browser":this.reader=this.scope.resolve(re);break;default:throw new G(G.InitializationError,`Environment ${A_Context.environment} is not supported`)}}catch(r){if(r instanceof A_ScopeError)throw new G({title:G.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${A_Context.environment}`,originalError:r})}}};i(Oe,"A_ConfigLoader"),c([A_Concept.Load({before:/.*/}),l(0,A_Inject(f))],Oe.prototype,"prepare",1);var it=Oe;var Xr=(j=>j)(Xr||{});var be={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},As=[be.A_LOGGER_LEVEL,be.A_LOGGER_DEFAULT_SCOPE_LENGTH,be.A_LOGGER_DEFAULT_SCOPE_COLOR,be.A_LOGGER_DEFAULT_LOG_COLOR];var De=class De extends A_Error{};i(De,"A_ManifestError"),De.ManifestInitializationError="A-Manifest Initialization Error";var H=De;var st=class st{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(st,"A_ManifestChecker");var oe=st;var ct=class ct extends A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!A_TypeGuards.isArray(e))throw new H(H.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!A_TypeGuards.isComponentConstructor(e.component))throw new H(H.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new oe(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(a=>a.componentRegex.test(r)&&a.methodRegex.test(o)).sort((a,_)=>{let m=a.methodRegex.source===".*",p=_.methodRegex.source===".*";return m&&!p?1:!m&&p?-1:0});if(s.length===0)return true;for(let a of s){if(a.excludeRegex&&a.excludeRegex.test(n))return false;if(a.applyRegex)return a.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new oe(this,o,r,true)}};i(ct,"A_Manifest");var at=ct;var eo=(p=>(p.onInit="_A_Memory_onInit",p.onDestroy="_A_Memory_onDestroy",p.onExpire="_A_Memory_onExpire",p.onError="_A_Memory_onError",p.onSerialize="_A_Memory_onSerialize",p.onSet="_A_Memory_onSet",p.onGet="_A_Memory_onGet",p.onDrop="_A_Memory_onDrop",p.onClear="_A_Memory_onClear",p.onHas="_A_Memory_onHas",p))(eo||{});var lt=class lt extends A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(lt,"A_MemoryContext");var v=lt;var N=class N extends A_Error{};i(N,"A_MemoryError"),N.MemoryInitializationError="Memory initialization error",N.MemoryDestructionError="Memory destruction error",N.MemoryGetError="Memory GET operation failed",N.MemorySetError="Memory SET operation failed",N.MemoryDropError="Memory DROP operation failed",N.MemoryClearError="Memory CLEAR operation failed",N.MemoryHasError="Memory HAS operation failed",N.MemorySerializeError="Memory toJSON operation failed";var g=N;var no,io,so,ao,co,lo,_o,po,mo,I=class I extends A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[mo="_A_Memory_onError"](...t){}async[po="_A_Memory_onExpire"](...t){}async[_o="_A_Memory_onInit"](t,...e){t||(t=new v,A_Context.scope(this).register(t));}async[lo="_A_Memory_onDestroy"](t,...e){t.clear();}async[co="_A_Memory_onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[ao="_A_Memory_onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[so="_A_Memory_onSet"](t,e,r,...o){e.set(t.params.key,t.params.value);}async[io="_A_Memory_onDrop"](t,e,...r){e.delete(t.params.key);}async[no="_A_Memory_onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new A_Scope({name:"A-Memory-Init-Scope"}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onInit",t);}catch(e){let r=new g({title:g.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async destroy(){let t=new A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(A_Context.scope(this));try{this._ready=void 0,await this.call("_A_Memory_onDestroy",t);}catch(e){let r=new g({title:g.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async get(t){let e=new d("get",{key:t}),r=new A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]}).inherit(A_Context.scope(this));try{return await this.call("_A_Memory_onGet",r),r.destroy(),e.result}catch(o){let n=new g({title:g.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async has(t){let e=new d("has",{key:t}),r=new A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]}).inherit(A_Context.scope(this));try{return await this.call("_A_Memory_onHas",r),r.destroy(),e.result}catch(o){let n=new g({title:g.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async set(t,e){let r=new d("set",{key:t,value:e}),o=new A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onSet",o);}catch(n){let s=new g({title:g.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("_A_Memory_onError",o),o.destroy(),s}}async drop(t){let e=new d("drop",{key:t}),r=new A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onDrop",r);}catch(o){let n=new g({title:g.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async clear(){let t=new d("clear"),e=new A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onClear",e);}catch(r){let o=new g({title:g.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}async toJSON(){let t=new d("serialize"),e=new A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]}).inherit(A_Context.scope(this));try{return await this.call("_A_Memory_onSerialize",e),t.result}catch(r){let o=new g({title:g.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}};i(I,"A_Memory"),c([A_Feature.Extend()],I.prototype,mo,1),c([A_Feature.Extend()],I.prototype,po,1),c([A_Feature.Extend(),l(0,A_Inject(v))],I.prototype,_o,1),c([A_Feature.Extend(),l(0,A_Inject(v))],I.prototype,lo,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(d)),l(1,A_Inject(v))],I.prototype,co,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(d)),l(1,A_Inject(v))],I.prototype,ao,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(d)),l(1,A_Inject(v)),l(2,A_Inject(A_Scope))],I.prototype,so,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(d)),l(1,A_Inject(v))],I.prototype,io,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(d)),l(1,A_Inject(v))],I.prototype,no,1);var _t=I;var uo=(p=>(p.onBeforeLoad="_A_Service_onBeforeLoad",p.onLoad="_A_Service_onLoad",p.onAfterLoad="_A_Service_onAfterLoad",p.onBeforeStart="_A_Service_onBeforeStart",p.onStart="_A_Service_onStart",p.onAfterStart="_A_Service_onAfterStart",p.onBeforeStop="_A_Service_onBeforeStop",p.onStop="_A_Service_onStop",p.onAfterStop="_A_Service_onAfterStop",p.onError="_A_Service_onError",p))(uo||{});var ne=class ne extends A_Error{};i(ne,"A_Service_Error"),ne.ServiceLoadError="Service load error",ne.ServiceStartError="Service start error",ne.ServiceStopError="Service stop error";var S=ne;var fo,yo,Ao,Eo,To,So,Co,xo,Ro,wo,E=class E extends A_Container{async load(){try{await this.call("_A_Service_onBeforeLoad"),await this.call("_A_Service_onLoad"),await this.call("_A_Service_onAfterLoad");}catch(t){let e;switch(true){case t instanceof S:e=t;break;case(t instanceof A_Error&&t.originalError instanceof S):e=t.originalError;break;default:e=new S({title:S.ServiceLoadError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async start(){try{await this.call("_A_Service_onBeforeStart"),await this.call("_A_Service_onStart"),await this.call("_A_Service_onAfterStart");}catch(t){let e;switch(true){case t instanceof S:e=t;break;case(t instanceof A_Error&&t.originalError instanceof S):e=t.originalError;break;default:e=new S({title:S.ServiceStartError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async stop(){try{await this.call("_A_Service_onBeforeStop"),await this.call("_A_Service_onStop"),await this.call("_A_Service_onAfterStop");}catch(t){let e;switch(true){case t instanceof S:e=t;break;case(t instanceof A_Error&&t.originalError instanceof S):e=t.originalError;break;default:e=new S({title:S.ServiceStopError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async[wo="_A_Service_onBeforeLoad"](t,...e){t||(this.scope.register(f),t=this.scope.resolve(f));}async[Ro="_A_Service_onLoad"](...t){}async[xo="_A_Service_onAfterLoad"](...t){}async[Co="_A_Service_onBeforeStart"](...t){}async[So="_A_Service_onStart"](...t){}async[To="_A_Service_onAfterStart"](...t){}async[Eo="_A_Service_onBeforeStop"](...t){}async[Ao="_A_Service_onStop"](...t){}async[yo="_A_Service_onAfterStop"](...t){}async[fo="_A_Service_onError"](t,e,...r){e?.error(t);}};i(E,"A_Service"),c([A_Concept.Load()],E.prototype,"load",1),c([A_Concept.Start()],E.prototype,"start",1),c([A_Concept.Stop()],E.prototype,"stop",1),c([A_Feature.Extend(),l(0,A_Inject(f))],E.prototype,wo,1),c([A_Feature.Extend()],E.prototype,Ro,1),c([A_Feature.Extend()],E.prototype,xo,1),c([A_Feature.Extend()],E.prototype,Co,1),c([A_Feature.Extend()],E.prototype,So,1),c([A_Feature.Extend()],E.prototype,To,1),c([A_Feature.Extend()],E.prototype,Eo,1),c([A_Feature.Extend()],E.prototype,Ao,1),c([A_Feature.Extend()],E.prototype,yo,1),c([A_Feature.Extend({before:/.*/}),l(0,A_Inject(A_Error)),l(1,A_Inject(T))],E.prototype,fo,1);var dt=E;var ht=class ht extends A_Fragment{constructor(t){super(),this.url=t instanceof RegExp?t.source:t;}get path(){let t=this.url.split("?")[0].split("#")[0];if(t.includes("://")){let e=t.indexOf("/",t.indexOf("://")+3);if(e===-1)return "/";{let r=t.slice(e);return r.endsWith("/")?r.slice(0,-1):r}}return t.endsWith("/")?t.slice(0,-1):t}get params(){return this.path.match(/:([^\/]+)/g)?.map(t=>t.slice(1))||[]}get protocol(){switch(true){case this.url.startsWith("http://"):return "http";case this.url.startsWith("https://"):return "https";case this.url.startsWith("ws://"):return "ws";case this.url.startsWith("wss://"):return "wss";default:return this.url.includes("://")?this.url.split("://")[0]:"http"}}extractParams(t){let r=t.split("?")[0].split("/").filter(Boolean),o=this.path.split("/").filter(Boolean),n={};for(let s=0;s<o.length;s++){let a=o[s],_=r[s];if(a.startsWith(":")){let m=a.slice(1);n[m]=_;}else if(a!==_)return {}}return n}extractQuery(t){let e={},r=t.split("?")[1];if(!r)return e;let o=r.split("#")[0];for(let n of o.split("&")){if(!n)continue;let[s,a=""]=n.split("=");e[decodeURIComponent(s)]=decodeURIComponent(a);}return e}toString(){return `${this.path}`}toRegExp(){return new RegExp(`^${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}toAFeatureExtension(t=[]){return new RegExp(`^${t.length?`(${t.join("|")})`:".*"}\\.${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}};i(ht,"A_Route");var ut=ht;var Lo=(t=>(t.Emit="_A_SignalFeatures_Emit",t))(Lo||{}),vo=(t=>(t.Emit="_A_SignalBusFeatures_Emit",t))(vo||{});var gt=class gt extends A_Entity{static async default(){}fromJSON(t){super.fromJSON(t),this.data=t.data;}fromNew(t){this.aseid=this.generateASEID({entity:t.name}),this.data=t.data;}async emit(t){await this.call("_A_SignalFeatures_Emit",t);}toJSON(){return {...super.toJSON(),data:this.data}}};i(gt,"A_Signal");var P=gt;var yt=class yt extends A_Entity{fromNew(t){super.fromNew(t),this._structure=t.structure,this._signals=t.values;}get structure(){return this._structure||this._signals.map(t=>t.constructor)}get length(){return this.structure.length}has(t){let e;return t instanceof A_Entity?e=t.constructor:e=t,this.structure.includes(e)}get(t){let e;t instanceof A_Entity?e=t.constructor:e=t;let r=this._signals.findIndex(o=>o.constructor===e);if(r!==-1)return this._signals[r]}async toVector(t){return (t||this.structure).map(r=>{let o=this._signals.findIndex(n=>n.constructor===r);return o!==-1?this._signals[o]:void 0})}async toDataVector(t){let e=t||this.structure,r=[];for(let o of e){let n=this._signals.findIndex(a=>a.constructor===o),s;n===-1?s=await o.default():s=this._signals[n],r.push(s?.toJSON().data);}return r}async toObject(t){let e=t||this.structure,r={};return e.forEach(o=>{let n=o.name,s=this._signals.findIndex(a=>a.constructor===o);if(s!==-1){let a=this._signals[s];r[n]=a.toJSON().data;}else r[n]=void 0;}),r}toJSON(){return {...super.toJSON(),structure:this.structure.map(t=>t.name),values:this._signals.map(t=>t.toJSON())}}};i(yt,"A_SignalVector");var ge=yt;var At=class At extends A_Fragment{constructor(e){super({name:"A_SignalState"});this._state=new Map;this._structure=e;}get structure(){return this._structure||[]}set(e,r){let o=e instanceof P?e.constructor:e,n=e instanceof P?e:r;this._state.set(o,n);}get(e){let r=e instanceof P?e.constructor:e;return this._state.get(r)}has(e){let r=e instanceof P?e.constructor:e;return this.structure.includes(r)}delete(e){let r=e instanceof P?e.constructor:e;return this._state.delete(r)}toVector(){let e=[];return this._state.forEach((r,o)=>{e.push(r);}),new ge({structure:this.structure,values:e})}toObject(){let e={};return this.structure.forEach(r=>{let o=this._state.get(r);if(o===void 0)throw new Error(`Signal ${r.name} has no value in state`);e[r.name]=o;}),e}};i(At,"A_SignalState");var ie=At;var Et=class Et extends A_Fragment{get structure(){if(this._structure)return this._structure;let t=A_Context.scope(this);return [...t.allowedEntities].filter(r=>A_CommonHelper.isInheritedFrom(r,P)).sort((r,o)=>r.constructor.name.localeCompare(o.name)).map(r=>t.resolveConstructor(r.name)).filter(r=>r)}get ready(){return this._ready}constructor(t){super({name:"A_SignalConfig"}),this._config=t;}async initialize(){return this._ready||(this._ready=this._initialize()),this._ready}async _initialize(){if(this._config.structure)this._structure=this._config.structure;else if(this._config.stringStructure){let t=this._config.stringStructure.split(",").map(e=>e.trim());this._structure=t.map(e=>A_Context.scope(this).resolveConstructor(e)).filter(e=>e);}}};i(Et,"A_SignalConfig");var se=Et;var Go,ke=class ke extends A_Component{async[Go="_A_SignalFeatures_Emit"](t,e,r,o,n,s){let a=A_Context.scope(this);if(s||(s=new se({stringStructure:r?.get("A_SIGNAL_VECTOR_STRUCTURE")||void 0}),a.register(s)),s.ready||await s.initialize(),n||(n=new ie(s.structure),a.register(n)),!n.has(t))return;o?.debug(`A_SignalBus: Updating state for signal '${t.constructor.name}' with data:`,t.data),n.set(t);let _=n.toVector(),m=new A_Scope({name:`A_SignalBus_Next_Scope_of_${this.constructor.name}`,entities:[_]}).inherit(e);try{await this.call("_A_SignalBusFeatures_Emit",m),m.destroy();}catch(p){throw m.destroy(),p}}};i(ke,"A_SignalBus"),c([A_Feature.Extend({scope:[P]}),l(0,A_Inject(A_Caller)),l(1,A_Inject(A_Scope)),l(2,A_Inject(A)),l(3,A_Inject(T)),l(4,A_Inject(ie)),l(5,A_Inject(se))],ke.prototype,Go,1);var Tt=ke;var St=class St{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(St,"A_Deferred");var fe=St;var Ct=class Ct{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new fe,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new A_Error("Timeout Cleared")));}};i(Ct,"A_ScheduleObject");var ce=Ct;var Rt=class Rt extends A_Component{async schedule(t,e,r){let o=A_TypeGuards.isString(t)?new Date(t).getTime():t;return new ce(o-Date.now(),e,r)}async delay(t,e,r){return new ce(t,e,r)}};i(Rt,"A_Schedule");var xt=Rt;
|
|
34
|
-
export{bn as A_CONSTANTS__CONFIG_ENV_VARIABLES,Q as A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY,Be as A_Channel,q as A_ChannelError,
|
|
31
|
+
`),n=[];return o.forEach((s,a)=>{if(s.trim()){let _=a===0?r:`${r} `,d=this.wrapText(s.trim(),_,false);n.push(...d.map(p=>a===0&&p===d[0]?`${r}${p}`:`${r} ${p}`));}}),n}compile_Error(e){let r=`${" ".repeat(this.STANDARD_SCOPE_LENGTH+3)}${y.PIPE}`,o=`${r}-------------------------------`,n=[];n.push(""),n.push(o),n.push(`${r}ERROR: ${e.name}`),n.push(o);let s=this.wrapText(`Message: ${e.message}`,r,false);if(n.push(...s.map(a=>`${r}${a}`)),e.stack){n.push(o),n.push(`${r}STACK TRACE:`),n.push(o);let a=this.formatStackTrace(e.stack,r);n.push(...a);}return n.push(o),n.join(`
|
|
32
|
+
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(ee.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(ee.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(ee.MILLISECONDS_PAD,"0");return `${r}${ee.SEPARATOR}${o}${ee.SEPARATOR}${n}`}};i(T,"A_Logger"),T=c([l(0,A_Inject(A_Scope)),l(1,A_Inject(A))],T);var mr,hr,gr,fr,yr,Ar,Er,Tr,Sr,xr,Cr,C=class C extends A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(b)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[Cr="_A_StateMachine_onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[xr="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[Sr="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[Tr="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[Er="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[Ar="_A_Command_onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[yr="_A_Command_onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[fr="_A_Command_onExecute"](...e){}async[gr="_A_Command_onAfterExecute"](...e){}async[hr="_A_Command_onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[mr="_A_Command_onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("_A_Command_onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new b("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new A_Feature({name:"_A_Command_onBeforeExecute",component:this,scope:this.scope}),s=new A_Feature({name:"_A_Command_onExecute",component:this,scope:this.scope}),a=new A_Feature({name:"_A_Command_onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),a.interrupt(),r();}),this.on("onFail",()=>{n.interrupt(),s.interrupt(),a.interrupt(),o(this.error);}),await n.process(this.scope),await s.process(this.scope),await a.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof A_Error?e:new Y({title:Y.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("_A_Command_onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("_A_Command_onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[G]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[G]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new Y(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=A_Context.scope(this);}catch(r){throw new Y({title:Y.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(A_Context.scope(this))||this.scope.inherit(A_Context.scope(this));}};i(C,"A_Command"),c([A_Feature.Extend(),l(0,A_Inject(N)),l(1,A_Inject(T))],C.prototype,Cr,1),c([A_Feature.Extend(),l(0,A_Inject(N))],C.prototype,xr,1),c([A_Feature.Extend(),l(0,A_Inject(N))],C.prototype,Sr,1),c([A_Feature.Extend(),l(0,A_Inject(N))],C.prototype,Tr,1),c([A_Feature.Extend(),l(0,A_Inject(N)),l(1,A_Inject(A_Error))],C.prototype,Er,1),c([A_Feature.Extend(),l(0,A_Inject(G))],C.prototype,Ar,1),c([A_Feature.Extend({after:/.*/}),l(0,A_Dependency.Required()),l(0,A_Inject(G))],C.prototype,yr,1),c([A_Feature.Extend()],C.prototype,fr,1),c([A_Feature.Extend()],C.prototype,gr,1),c([A_Feature.Extend({after:/.*/}),l(0,A_Inject(G))],C.prototype,hr,1),c([A_Feature.Extend({after:/.*/}),l(0,A_Dependency.Required()),l(0,A_Inject(G)),l(1,A_Inject(b))],C.prototype,mr,1);var Ke=C;var We=class We{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(We,"A_FSPolyfillClass");var Se=We;var Je=class Je{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),a=this._fsPolyfill.createReadStream(e);a.on("data",_=>s.update(_)),a.on("end",()=>o(`${r}-${s.digest("base64")}`)),a.on("error",_=>n(_));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),a=await crypto.subtle.digest(e,s),_=Array.from(new Uint8Array(a)),d=btoa(String.fromCharCode(..._));r(`${e}-${d}`);}catch(n){o(n);}}),"createTextHash")};}};i(Je,"A_CryptoPolyfillClass");var xe=Je;var Xe=class Xe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,a)=>{s==="data"?setTimeout(()=>a("mock data"),0):s==="end"&&setTimeout(()=>a(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Xe,"A_HttpPolyfillClass");var Ce=Xe;var Ze=class Ze{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,a)=>{s==="data"?setTimeout(()=>a("mock data"),0):s==="end"&&setTimeout(()=>a(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Ze,"A_HttpsPolyfillClass");var Re=Ze;var Qe=class Qe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(Qe,"A_PathPolyfillClass");var we=Qe;var et=class et{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(et,"A_UrlPolyfillClass");var Pe=et;var tt=class tt{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,a)=>s+a.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(tt,"A_BufferPolyfillClass");var ve=tt;var rt=class rt{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(rt,"A_ProcessPolyfillClass");var Le=rt;var f=class extends A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new Se(this.logger),this._cryptoPolyfill=new xe(this.logger),this._httpPolyfill=new Ce(this.logger),this._httpsPolyfill=new Re(this.logger),this._pathPolyfill=new we(this.logger),this._urlPolyfill=new Pe(this.logger),this._bufferPolyfill=new ve(this.logger),this._processPolyfill=new Le(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(f,"A_Polyfill"),c([A_Concept.Load()],f.prototype,"load",1),c([A_Concept.Load()],f.prototype,"attachToWindow",1),f=c([l(0,A_Inject(T))],f);var R=class extends A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...Q];}async attachContext(e,r,o){o||(o=new A({defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read();for(let o in r)e.set(o,r[o]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(R,"ConfigReader"),c([A_Concept.Load(),l(0,A_Inject(A_Container)),l(1,A_Inject(A_Scope)),l(2,A_Inject(A))],R.prototype,"attachContext",1),c([A_Concept.Load(),l(0,A_Dependency.Required()),l(0,A_Inject(A))],R.prototype,"initialize",1),R=c([l(0,A_Dependency.Required()),l(0,A_Inject(f))],R);var ot=class ot extends R{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(ot,"FileConfigReader");var me=ot;var Ie=class Ie extends R{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
33
|
+
`).forEach(n=>{let[s,a]=n.split("=");s&&a&&(process.env[s.trim()]=a.trim());});}getConfigurationProperty_ENV_Alias(t){return A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(Ie,"ENVConfigReader"),c([A_Concept.Load({before:["ENVConfigReader.initialize"]}),l(0,A_Inject(A)),l(1,A_Inject(f)),l(2,A_Inject(A_Feature))],Ie.prototype,"readEnvFile",1);var re=Ie;var Oe=class Oe extends A_Container{async prepare(t){if(!this.scope.has(A)){let r=new A({variables:[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...Q],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(A_Context.environment==="server"&&!!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(me);break;case(A_Context.environment==="server"&&!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(re);break;case A_Context.environment==="browser":this.reader=this.scope.resolve(re);break;default:throw new $($.InitializationError,`Environment ${A_Context.environment} is not supported`)}}catch(r){if(r instanceof A_ScopeError)throw new $({title:$.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${A_Context.environment}`,originalError:r})}}};i(Oe,"A_ConfigLoader"),c([A_Concept.Load({before:/.*/}),l(0,A_Inject(f))],Oe.prototype,"prepare",1);var it=Oe;var Jr=(j=>j)(Jr||{});var be={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},As=[be.A_LOGGER_LEVEL,be.A_LOGGER_DEFAULT_SCOPE_LENGTH,be.A_LOGGER_DEFAULT_SCOPE_COLOR,be.A_LOGGER_DEFAULT_LOG_COLOR];var Ne=class Ne extends A_Error{};i(Ne,"A_ManifestError"),Ne.ManifestInitializationError="A-Manifest Initialization Error";var H=Ne;var st=class st{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(st,"A_ManifestChecker");var oe=st;var ct=class ct extends A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!A_TypeGuards.isArray(e))throw new H(H.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!A_TypeGuards.isComponentConstructor(e.component))throw new H(H.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new oe(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(a=>a.componentRegex.test(r)&&a.methodRegex.test(o)).sort((a,_)=>{let d=a.methodRegex.source===".*",p=_.methodRegex.source===".*";return d&&!p?1:!d&&p?-1:0});if(s.length===0)return true;for(let a of s){if(a.excludeRegex&&a.excludeRegex.test(n))return false;if(a.applyRegex)return a.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new oe(this,o,r,true)}};i(ct,"A_Manifest");var at=ct;var Qr=(p=>(p.onInit="_A_Memory_onInit",p.onDestroy="_A_Memory_onDestroy",p.onExpire="_A_Memory_onExpire",p.onError="_A_Memory_onError",p.onSerialize="_A_Memory_onSerialize",p.onSet="_A_Memory_onSet",p.onGet="_A_Memory_onGet",p.onDrop="_A_Memory_onDrop",p.onClear="_A_Memory_onClear",p.onHas="_A_Memory_onHas",p))(Qr||{});var lt=class lt extends A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(lt,"A_MemoryContext");var L=lt;var D=class D extends A_Error{};i(D,"A_MemoryError"),D.MemoryInitializationError="Memory initialization error",D.MemoryDestructionError="Memory destruction error",D.MemoryGetError="Memory GET operation failed",D.MemorySetError="Memory SET operation failed",D.MemoryDropError="Memory DROP operation failed",D.MemoryClearError="Memory CLEAR operation failed",D.MemoryHasError="Memory HAS operation failed",D.MemorySerializeError="Memory toJSON operation failed";var g=D;var oo,no,io,so,ao,co,lo,_o,po,I=class I extends A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[po="_A_Memory_onError"](...t){}async[_o="_A_Memory_onExpire"](...t){}async[lo="_A_Memory_onInit"](t,...e){t||(t=new L,A_Context.scope(this).register(t));}async[co="_A_Memory_onDestroy"](t,...e){t.clear();}async[ao="_A_Memory_onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[so="_A_Memory_onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[io="_A_Memory_onSet"](t,e,r,...o){e.set(t.params.key,t.params.value);}async[no="_A_Memory_onDrop"](t,e,...r){e.delete(t.params.key);}async[oo="_A_Memory_onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new A_Scope({name:"A-Memory-Init-Scope"}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onInit",t);}catch(e){let r=new g({title:g.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async destroy(){let t=new A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(A_Context.scope(this));try{this._ready=void 0,await this.call("_A_Memory_onDestroy",t);}catch(e){let r=new g({title:g.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async get(t){let e=new u("get",{key:t}),r=new A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]}).inherit(A_Context.scope(this));try{return await this.call("_A_Memory_onGet",r),r.destroy(),e.result}catch(o){let n=new g({title:g.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async has(t){let e=new u("has",{key:t}),r=new A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]}).inherit(A_Context.scope(this));try{return await this.call("_A_Memory_onHas",r),r.destroy(),e.result}catch(o){let n=new g({title:g.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async set(t,e){let r=new u("set",{key:t,value:e}),o=new A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onSet",o);}catch(n){let s=new g({title:g.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("_A_Memory_onError",o),o.destroy(),s}}async drop(t){let e=new u("drop",{key:t}),r=new A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onDrop",r);}catch(o){let n=new g({title:g.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async clear(){let t=new u("clear"),e=new A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]}).inherit(A_Context.scope(this));try{await this.call("_A_Memory_onClear",e);}catch(r){let o=new g({title:g.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}async toJSON(){let t=new u("serialize"),e=new A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]}).inherit(A_Context.scope(this));try{return await this.call("_A_Memory_onSerialize",e),t.result}catch(r){let o=new g({title:g.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}};i(I,"A_Memory"),c([A_Feature.Extend()],I.prototype,po,1),c([A_Feature.Extend()],I.prototype,_o,1),c([A_Feature.Extend(),l(0,A_Inject(L))],I.prototype,lo,1),c([A_Feature.Extend(),l(0,A_Inject(L))],I.prototype,co,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(u)),l(1,A_Inject(L))],I.prototype,ao,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(u)),l(1,A_Inject(L))],I.prototype,so,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(u)),l(1,A_Inject(L)),l(2,A_Inject(A_Scope))],I.prototype,io,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(u)),l(1,A_Inject(L))],I.prototype,no,1),c([A_Feature.Extend(),l(0,A_Dependency.Required()),l(0,A_Inject(u)),l(1,A_Inject(L))],I.prototype,oo,1);var _t=I;var uo=(p=>(p.onBeforeLoad="_A_Service_onBeforeLoad",p.onLoad="_A_Service_onLoad",p.onAfterLoad="_A_Service_onAfterLoad",p.onBeforeStart="_A_Service_onBeforeStart",p.onStart="_A_Service_onStart",p.onAfterStart="_A_Service_onAfterStart",p.onBeforeStop="_A_Service_onBeforeStop",p.onStop="_A_Service_onStop",p.onAfterStop="_A_Service_onAfterStop",p.onError="_A_Service_onError",p))(uo||{});var ne=class ne extends A_Error{};i(ne,"A_Service_Error"),ne.ServiceLoadError="Service load error",ne.ServiceStartError="Service start error",ne.ServiceStopError="Service stop error";var S=ne;var go,fo,yo,Ao,Eo,To,So,xo,Co,Ro,E=class E extends A_Container{async load(){try{await this.call("_A_Service_onBeforeLoad"),await this.call("_A_Service_onLoad"),await this.call("_A_Service_onAfterLoad");}catch(t){let e;switch(true){case t instanceof S:e=t;break;case(t instanceof A_Error&&t.originalError instanceof S):e=t.originalError;break;default:e=new S({title:S.ServiceLoadError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async start(){try{await this.call("_A_Service_onBeforeStart"),await this.call("_A_Service_onStart"),await this.call("_A_Service_onAfterStart");}catch(t){let e;switch(true){case t instanceof S:e=t;break;case(t instanceof A_Error&&t.originalError instanceof S):e=t.originalError;break;default:e=new S({title:S.ServiceStartError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async stop(){try{await this.call("_A_Service_onBeforeStop"),await this.call("_A_Service_onStop"),await this.call("_A_Service_onAfterStop");}catch(t){let e;switch(true){case t instanceof S:e=t;break;case(t instanceof A_Error&&t.originalError instanceof S):e=t.originalError;break;default:e=new S({title:S.ServiceStopError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async[Ro="_A_Service_onBeforeLoad"](t,...e){t||(this.scope.register(f),t=this.scope.resolve(f));}async[Co="_A_Service_onLoad"](...t){}async[xo="_A_Service_onAfterLoad"](...t){}async[So="_A_Service_onBeforeStart"](...t){}async[To="_A_Service_onStart"](...t){}async[Eo="_A_Service_onAfterStart"](...t){}async[Ao="_A_Service_onBeforeStop"](...t){}async[yo="_A_Service_onStop"](...t){}async[fo="_A_Service_onAfterStop"](...t){}async[go="_A_Service_onError"](t,e,...r){e?.error(t);}};i(E,"A_Service"),c([A_Concept.Load()],E.prototype,"load",1),c([A_Concept.Start()],E.prototype,"start",1),c([A_Concept.Stop()],E.prototype,"stop",1),c([A_Feature.Extend(),l(0,A_Inject(f))],E.prototype,Ro,1),c([A_Feature.Extend()],E.prototype,Co,1),c([A_Feature.Extend()],E.prototype,xo,1),c([A_Feature.Extend()],E.prototype,So,1),c([A_Feature.Extend()],E.prototype,To,1),c([A_Feature.Extend()],E.prototype,Eo,1),c([A_Feature.Extend()],E.prototype,Ao,1),c([A_Feature.Extend()],E.prototype,yo,1),c([A_Feature.Extend()],E.prototype,fo,1),c([A_Feature.Extend({before:/.*/}),l(0,A_Inject(A_Error)),l(1,A_Inject(T))],E.prototype,go,1);var ut=E;var ht=class ht extends A_Fragment{constructor(t){super(),this.url=t instanceof RegExp?t.source:t;}get path(){let t=this.url.split("?")[0].split("#")[0];if(t.includes("://")){let e=t.indexOf("/",t.indexOf("://")+3);if(e===-1)return "/";{let r=t.slice(e);return r.endsWith("/")?r.slice(0,-1):r}}return t.endsWith("/")?t.slice(0,-1):t}get params(){return this.path.match(/:([^\/]+)/g)?.map(t=>t.slice(1))||[]}get protocol(){switch(true){case this.url.startsWith("http://"):return "http";case this.url.startsWith("https://"):return "https";case this.url.startsWith("ws://"):return "ws";case this.url.startsWith("wss://"):return "wss";default:return this.url.includes("://")?this.url.split("://")[0]:"http"}}extractParams(t){let r=t.split("?")[0].split("/").filter(Boolean),o=this.path.split("/").filter(Boolean),n={};for(let s=0;s<o.length;s++){let a=o[s],_=r[s];if(a.startsWith(":")){let d=a.slice(1);n[d]=_;}else if(a!==_)return {}}return n}extractQuery(t){let e={},r=t.split("?")[1];if(!r)return e;let o=r.split("#")[0];for(let n of o.split("&")){if(!n)continue;let[s,a=""]=n.split("=");e[decodeURIComponent(s)]=decodeURIComponent(a);}return e}toString(){return `${this.path}`}toRegExp(){return new RegExp(`^${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}toAFeatureExtension(t=[]){return new RegExp(`^${t.length?`(${t.join("|")})`:".*"}\\.${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}};i(ht,"A_Route");var mt=ht;var Po=(t=>(t.Next="_A_SignalFeatures_Next",t))(Po||{}),vo=(t=>(t.Next="_A_SignalVectorFeatures_Next",t))(vo||{});var gt=class gt extends A_Entity{static async default(){}fromJSON(t){super.fromJSON(t),this.data=t.data;}fromNew(t){this.aseid=this.generateASEID({entity:t.name}),this.data=t.data;}async next(t){await this.call("_A_SignalFeatures_Next",t);}toJSON(){return {...super.toJSON(),data:this.data}}};i(gt,"A_Signal");var P=gt;var yt=class yt extends A_Entity{fromNew(t){super.fromNew(t),this._structure=t.structure,this._signals=t.values;}get structure(){return this._structure||this._signals.map(t=>t.constructor)}get length(){return this.structure.length}[Symbol.iterator](){let t=0,e=this.structure.map(r=>{let o=this._signals.findIndex(n=>n.constructor===r);return o!==-1?this._signals[o]:void 0});return {next(){return t<e.length?{done:false,value:e[t++]}:{done:true,value:void 0}}}}async next(t){return await this.call("_A_SignalVectorFeatures_Next",t)}has(t){let e;return t instanceof A_Entity?e=t.constructor:e=t,this.structure.includes(e)}get(t){let e;t instanceof A_Entity?e=t.constructor:e=t;let r=this._signals.findIndex(o=>o.constructor===e);if(r!==-1)return this._signals[r]}async toVector(t){return (t||this.structure).map(r=>{let o=this._signals.findIndex(n=>n.constructor===r);return o!==-1?this._signals[o]:void 0})}async toDataVector(t){let e=t||this.structure,r=[];for(let o of e){let n=this._signals.findIndex(a=>a.constructor===o),s;n===-1?s=await o.default():s=this._signals[n],r.push(s?.toJSON().data);}return r}async toObject(t){let e=t||this.structure,r={};return e.forEach(o=>{let n=o.name,s=this._signals.findIndex(a=>a.constructor===o);if(s!==-1){let a=this._signals[s];r[n]=a.toJSON().data;}else r[n]=void 0;}),r}toJSON(){return {...super.toJSON(),structure:this.structure.map(t=>t.name),values:this._signals.map(t=>t.toJSON())}}};i(yt,"A_SignalVector");var ge=yt;var At=class At extends A_Fragment{constructor(e){super({name:"A_SignalState"});this._state=new Map;this._structure=e;}get structure(){return this._structure||[]}set(e,r){let o=e instanceof P?e.constructor:e,n=e instanceof P?e:r;this._state.set(o,n);}get(e){let r=e instanceof P?e.constructor:e;return this._state.get(r)}has(e){let r=e instanceof P?e.constructor:e;return this.structure.includes(r)}delete(e){let r=e instanceof P?e.constructor:e;return this._state.delete(r)}toVector(){let e=[];return this._state.forEach((r,o)=>{e.push(r);}),new ge({structure:this.structure,values:e})}toObject(){let e={};return this.structure.forEach(r=>{let o=this._state.get(r);if(o===void 0)throw new Error(`Signal ${r.name} has no value in state`);e[r.name]=o;}),e}};i(At,"A_SignalState");var ie=At;var Et=class Et extends A_Fragment{get structure(){if(this._structure)return this._structure;let t=A_Context.scope(this);return [...t.allowedEntities].filter(r=>A_CommonHelper.isInheritedFrom(r,P)).sort((r,o)=>r.constructor.name.localeCompare(o.name)).map(r=>t.resolveConstructor(r.name)).filter(r=>r)}get ready(){return this._ready}constructor(t){super({name:"A_SignalConfig"}),this._config=t;}async initialize(){return this._ready||(this._ready=this._initialize()),this._ready}async _initialize(){if(this._config.structure)this._structure=this._config.structure;else if(this._config.stringStructure){let t=this._config.stringStructure.split(",").map(e=>e.trim());this._structure=t.map(e=>A_Context.scope(this).resolveConstructor(e)).filter(e=>e);}}};i(Et,"A_SignalConfig");var se=Et;var $o,ke=class ke extends A_Component{async[$o="_A_SignalFeatures_Next"](t,e,r,o,n,s){let a=A_Context.scope(this);if(s||(s=new se({stringStructure:r?.get("A_SIGNAL_VECTOR_STRUCTURE")||void 0}),a.register(s)),s.ready||await s.initialize(),n||(n=new ie(s.structure),a.register(n)),!n.has(t))return;o?.debug(`A_SignalBus: Updating state for signal '${t.constructor.name}' with data:`,t.data),n.set(t),await n.toVector().next(e);}};i(ke,"A_SignalBus"),c([A_Feature.Extend({scope:[P]}),l(0,A_Inject(A_Caller)),l(1,A_Inject(A_Scope)),l(2,A_Inject(A)),l(3,A_Inject(T)),l(4,A_Inject(ie)),l(5,A_Inject(se))],ke.prototype,$o,1);var Tt=ke;var St=class St{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(St,"A_Deferred");var fe=St;var xt=class xt{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new fe,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new A_Error("Timeout Cleared")));}};i(xt,"A_ScheduleObject");var ce=xt;var Rt=class Rt extends A_Component{async schedule(t,e,r){let o=A_TypeGuards.isString(t)?new Date(t).getTime():t;return new ce(o-Date.now(),e,r)}async delay(t,e,r){return new ce(t,e,r)}};i(Rt,"A_Schedule");var Ct=Rt;
|
|
34
|
+
export{bn as A_CONSTANTS__CONFIG_ENV_VARIABLES,Q as A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY,Be as A_Channel,q as A_ChannelError,Ht as A_ChannelFeatures,le as A_ChannelRequest,jt as A_ChannelRequestStatuses,Ke as A_Command,Y as A_CommandError,Xt as A_CommandEvent,Jt as A_CommandFeatures,Wt as A_CommandTransitions,Kt as A_Command_Status,A as A_Config,$ as A_ConfigError,it as A_ConfigLoader,fe as A_Deferred,b as A_ExecutionContext,V as A_LOGGER_ANSI,Lt as A_LOGGER_COLORS,Vn as A_LOGGER_DEFAULT_LEVEL,vt as A_LOGGER_DEFAULT_SCOPE_LENGTH,de as A_LOGGER_ENV_KEYS,y as A_LOGGER_FORMAT,It as A_LOGGER_SAFE_RANDOM_COLORS,te as A_LOGGER_TERMINAL,ee as A_LOGGER_TIME_FORMAT,T as A_Logger,be as A_LoggerEnvVariables,As as A_LoggerEnvVariablesArray,at as A_Manifest,oe as A_ManifestChecker,H as A_ManifestError,_t as A_Memory,L as A_MemoryContext,g as A_MemoryError,Qr as A_MemoryFeatures,u as A_OperationContext,f as A_Polyfill,mt as A_Route,Ct as A_Schedule,ce as A_ScheduleObject,ut as A_Service,uo as A_ServiceFeatures,P as A_Signal,Tt as A_SignalBus,se as A_SignalConfig,Po as A_SignalFeatures,ie as A_SignalState,ge as A_SignalVector,vo as A_SignalVectorFeatures,G as A_StateMachine,Z as A_StateMachineError,er as A_StateMachineFeatures,N as A_StateMachineTransition,Jr as A_TYPES__ConfigFeature,R as ConfigReader,re as ENVConfigReader,me as FileConfigReader};//# sourceMappingURL=index.mjs.map
|
|
35
35
|
//# sourceMappingURL=index.mjs.map
|