fastevent 2.3.3 → 2.3.4

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.d.mts CHANGED
@@ -359,6 +359,8 @@ type TransformedEvents<Events extends Record<string, any>> = {
359
359
  [K in keyof Events]: NotPayload<Events[K]>;
360
360
  };
361
361
 
362
+ type Class = (new (...args: any[]) => any) | (abstract new (...args: any[]) => any);
363
+
362
364
  type FastListenerExecutor = (listeners: FastListenerMeta[], message: TypedFastEventMessage, args: FastEventListenerArgs, execute: (listener: TypedFastEventListener, message: TypedFastEventMessage, args: FastEventListenerArgs, catchErrors?: boolean) => Promise<any> | any) => Promise<any[]> | any[];
363
365
 
364
366
  type FastEventScopeOptions<Meta = Record<string, any>, Context = never> = {
@@ -425,8 +427,8 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
425
427
  once<T extends Types = Types>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
426
428
  once<T extends Exclude<string, Types>>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
427
429
  once<T extends keyof OmitTransformedEvents<Events>>(type: T, listener: TypedFastEventListener<Exclude<T, number | symbol>, Events[T], FinalMeta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
428
- once<T extends keyof PickTransformedEvents<Events>>(type: T, listener: (message: PickPayload<RecordValues<WildcardEvents<Events, Exclude<T, number | symbol>>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<Events, Meta>): FastEventSubscriber;
429
- once<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<WildcardEvents<Events, T>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
430
+ once<T extends keyof PickTransformedEvents<Events>>(type: T, listener: (message: PickPayload<RecordValues<ClosestWildcardEvents<Events, Exclude<T, number | symbol>>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<Events, Meta>): FastEventSubscriber;
431
+ once<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<ClosestWildcardEvents<Events, T>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
430
432
  onAny(options?: Pick<FastEventListenOptions, 'prepend'>): FastEventSubscriber;
431
433
  onAny<P = any>(listener: TypedFastEventAnyListener<{
432
434
  [K: string]: P;
@@ -497,6 +499,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
497
499
  * ```
498
500
  */
499
501
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context>(prefix: P, options?: DeepPartial<FastEventScopeOptions<Partial<FinalMeta> & M, C>>): FastEventScope<ScopeEvents<Events, P> & E, FinalMeta & M, C>;
502
+ scope<E extends Record<string, any> = Record<string, any>, P extends string = string, C = Context, ScopeObject extends InstanceType<Class> = InstanceType<Class>>(prefix: P, scopeObj: ScopeObject, options?: DeepPartial<FastEventScopeOptions<Meta>>): FastEventScopeExtend<Events, P, ScopeObject>;
500
503
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context, ScopeInstance extends FastEventScope<Record<string, any>, any, any> = FastEventScope<Record<string, any>, any, any>>(prefix: P, scopeObj: ScopeInstance, options?: DeepPartial<FastEventScopeOptions<Partial<FinalMeta> & M, C>>): ScopeInstance & FastEventScope<ScopeEvents<Events, P> & E, FinalMeta & M, C>;
501
504
  /**
502
505
  * 当on/once/onAny未指定监听器时,此为默认监听器
@@ -504,6 +507,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
504
507
  */
505
508
  onMessage(message: TypedFastEventMessage<Events, FinalMeta>, args: FastEventListenerArgs<FinalMeta>): void;
506
509
  }
510
+ type FastEventScopeExtend<Events extends Record<string, any>, Prefix extends string, T extends InstanceType<Class> = never> = FastEventScope<ScopeEvents<Events, Prefix>> & T;
507
511
 
508
512
  /**
509
513
  * FastEvent 事件发射器类
@@ -978,6 +982,7 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
978
982
  */
979
983
  scope<P extends string>(prefix: P, options?: DeepPartial<FastEventScopeOptions<Meta, Context>>): FastEventScope<ScopeEvents<AllEvents, P>, Meta, Context>;
980
984
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context>(prefix: P, options?: DeepPartial<FastEventScopeOptions<Meta & M, C>>): FastEventScope<ScopeEvents<AllEvents, P> & E, Meta & M, C>;
985
+ scope<E extends Record<string, any> = Record<string, any>, P extends string = string, C = Context, ScopeObject extends InstanceType<Class> = InstanceType<Class>>(prefix: P, scopeObj: ScopeObject, options?: DeepPartial<FastEventScopeOptions<Meta>>): FastEventScopeExtend<AllEvents, P, ScopeObject>;
981
986
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context, ScopeObject extends FastEventScope<any, any, any> = FastEventScope<any, any, any>>(prefix: P, scopeObj: ScopeObject, options?: DeepPartial<FastEventScopeOptions<Meta & M, C>>): ScopeObject & FastEventScope<ScopeEvents<AllEvents, P> & E, Meta & M, C>;
982
987
  }
983
988
 
@@ -1078,4 +1083,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
1078
1083
 
1079
1084
  declare function isFastEvent(target: any): target is FastEvent;
1080
1085
 
1081
- export { AbortError, type AssertFastMessage, type AtPayloads, CancelError, type ChangeFieldType, type ClosestWildcardEvents, type DeepPartial, type Dict, type Expand, type ExpandWildcard, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, FastEventListenerFlags, type FastEventListeners, type FastEventMessage, type FastEventMessageExtends, type FastEventMeta, type FastEventOptions, FastEventScope, type FastEventScopeMeta, type FastEventScopeOptions, type FastEventSubscriber, type FastEvents, type FastListenerMeta, type FastListenerNode, type FastListeners, type FastMessagePayload, type Keys, type Merge, type MergeUnion, type NotPayload, type ObjectKeys, type OmitTransformedEvents, type OptionalItems, type Overloads, type OverrideOptions, type PickPayload, type PickTransformedEvents, QueueOverflowError, type RecordPrefix, type RecordValues, type RequiredItems, type ScopeEvents, TimeoutError, type TransformedEvents, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Unique, type WildcardEvents, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
1086
+ export { AbortError, type AssertFastMessage, type AtPayloads, CancelError, type ChangeFieldType, type Class, type ClosestWildcardEvents, type DeepPartial, type Dict, type Expand, type ExpandWildcard, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, FastEventListenerFlags, type FastEventListeners, type FastEventMessage, type FastEventMessageExtends, type FastEventMeta, type FastEventOptions, FastEventScope, type FastEventScopeExtend, type FastEventScopeMeta, type FastEventScopeOptions, type FastEventSubscriber, type FastEvents, type FastListenerMeta, type FastListenerNode, type FastListeners, type FastMessagePayload, type Keys, type Merge, type MergeUnion, type NotPayload, type ObjectKeys, type OmitTransformedEvents, type OptionalItems, type Overloads, type OverrideOptions, type PickPayload, type PickTransformedEvents, QueueOverflowError, type RecordPrefix, type RecordValues, type RequiredItems, type ScopeEvents, TimeoutError, type TransformedEvents, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Unique, type WildcardEvents, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
package/dist/index.d.ts CHANGED
@@ -359,6 +359,8 @@ type TransformedEvents<Events extends Record<string, any>> = {
359
359
  [K in keyof Events]: NotPayload<Events[K]>;
360
360
  };
361
361
 
362
+ type Class = (new (...args: any[]) => any) | (abstract new (...args: any[]) => any);
363
+
362
364
  type FastListenerExecutor = (listeners: FastListenerMeta[], message: TypedFastEventMessage, args: FastEventListenerArgs, execute: (listener: TypedFastEventListener, message: TypedFastEventMessage, args: FastEventListenerArgs, catchErrors?: boolean) => Promise<any> | any) => Promise<any[]> | any[];
363
365
 
364
366
  type FastEventScopeOptions<Meta = Record<string, any>, Context = never> = {
@@ -425,8 +427,8 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
425
427
  once<T extends Types = Types>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
426
428
  once<T extends Exclude<string, Types>>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
427
429
  once<T extends keyof OmitTransformedEvents<Events>>(type: T, listener: TypedFastEventListener<Exclude<T, number | symbol>, Events[T], FinalMeta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
428
- once<T extends keyof PickTransformedEvents<Events>>(type: T, listener: (message: PickPayload<RecordValues<WildcardEvents<Events, Exclude<T, number | symbol>>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<Events, Meta>): FastEventSubscriber;
429
- once<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<WildcardEvents<Events, T>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
430
+ once<T extends keyof PickTransformedEvents<Events>>(type: T, listener: (message: PickPayload<RecordValues<ClosestWildcardEvents<Events, Exclude<T, number | symbol>>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<Events, Meta>): FastEventSubscriber;
431
+ once<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<ClosestWildcardEvents<Events, T>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
430
432
  onAny(options?: Pick<FastEventListenOptions, 'prepend'>): FastEventSubscriber;
431
433
  onAny<P = any>(listener: TypedFastEventAnyListener<{
432
434
  [K: string]: P;
@@ -497,6 +499,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
497
499
  * ```
498
500
  */
499
501
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context>(prefix: P, options?: DeepPartial<FastEventScopeOptions<Partial<FinalMeta> & M, C>>): FastEventScope<ScopeEvents<Events, P> & E, FinalMeta & M, C>;
502
+ scope<E extends Record<string, any> = Record<string, any>, P extends string = string, C = Context, ScopeObject extends InstanceType<Class> = InstanceType<Class>>(prefix: P, scopeObj: ScopeObject, options?: DeepPartial<FastEventScopeOptions<Meta>>): FastEventScopeExtend<Events, P, ScopeObject>;
500
503
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context, ScopeInstance extends FastEventScope<Record<string, any>, any, any> = FastEventScope<Record<string, any>, any, any>>(prefix: P, scopeObj: ScopeInstance, options?: DeepPartial<FastEventScopeOptions<Partial<FinalMeta> & M, C>>): ScopeInstance & FastEventScope<ScopeEvents<Events, P> & E, FinalMeta & M, C>;
501
504
  /**
502
505
  * 当on/once/onAny未指定监听器时,此为默认监听器
@@ -504,6 +507,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
504
507
  */
505
508
  onMessage(message: TypedFastEventMessage<Events, FinalMeta>, args: FastEventListenerArgs<FinalMeta>): void;
506
509
  }
510
+ type FastEventScopeExtend<Events extends Record<string, any>, Prefix extends string, T extends InstanceType<Class> = never> = FastEventScope<ScopeEvents<Events, Prefix>> & T;
507
511
 
508
512
  /**
509
513
  * FastEvent 事件发射器类
@@ -978,6 +982,7 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
978
982
  */
979
983
  scope<P extends string>(prefix: P, options?: DeepPartial<FastEventScopeOptions<Meta, Context>>): FastEventScope<ScopeEvents<AllEvents, P>, Meta, Context>;
980
984
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context>(prefix: P, options?: DeepPartial<FastEventScopeOptions<Meta & M, C>>): FastEventScope<ScopeEvents<AllEvents, P> & E, Meta & M, C>;
985
+ scope<E extends Record<string, any> = Record<string, any>, P extends string = string, C = Context, ScopeObject extends InstanceType<Class> = InstanceType<Class>>(prefix: P, scopeObj: ScopeObject, options?: DeepPartial<FastEventScopeOptions<Meta>>): FastEventScopeExtend<AllEvents, P, ScopeObject>;
981
986
  scope<E extends Record<string, any> = Record<string, any>, P extends string = string, M extends Record<string, any> = Record<string, any>, C = Context, ScopeObject extends FastEventScope<any, any, any> = FastEventScope<any, any, any>>(prefix: P, scopeObj: ScopeObject, options?: DeepPartial<FastEventScopeOptions<Meta & M, C>>): ScopeObject & FastEventScope<ScopeEvents<AllEvents, P> & E, Meta & M, C>;
982
987
  }
983
988
 
@@ -1078,4 +1083,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
1078
1083
 
1079
1084
  declare function isFastEvent(target: any): target is FastEvent;
1080
1085
 
1081
- export { AbortError, type AssertFastMessage, type AtPayloads, CancelError, type ChangeFieldType, type ClosestWildcardEvents, type DeepPartial, type Dict, type Expand, type ExpandWildcard, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, FastEventListenerFlags, type FastEventListeners, type FastEventMessage, type FastEventMessageExtends, type FastEventMeta, type FastEventOptions, FastEventScope, type FastEventScopeMeta, type FastEventScopeOptions, type FastEventSubscriber, type FastEvents, type FastListenerMeta, type FastListenerNode, type FastListeners, type FastMessagePayload, type Keys, type Merge, type MergeUnion, type NotPayload, type ObjectKeys, type OmitTransformedEvents, type OptionalItems, type Overloads, type OverrideOptions, type PickPayload, type PickTransformedEvents, QueueOverflowError, type RecordPrefix, type RecordValues, type RequiredItems, type ScopeEvents, TimeoutError, type TransformedEvents, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Unique, type WildcardEvents, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
1086
+ export { AbortError, type AssertFastMessage, type AtPayloads, CancelError, type ChangeFieldType, type Class, type ClosestWildcardEvents, type DeepPartial, type Dict, type Expand, type ExpandWildcard, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, FastEventListenerFlags, type FastEventListeners, type FastEventMessage, type FastEventMessageExtends, type FastEventMeta, type FastEventOptions, FastEventScope, type FastEventScopeExtend, type FastEventScopeMeta, type FastEventScopeOptions, type FastEventSubscriber, type FastEvents, type FastListenerMeta, type FastListenerNode, type FastListeners, type FastMessagePayload, type Keys, type Merge, type MergeUnion, type NotPayload, type ObjectKeys, type OmitTransformedEvents, type OptionalItems, type Overloads, type OverrideOptions, type PickPayload, type PickTransformedEvents, QueueOverflowError, type RecordPrefix, type RecordValues, type RequiredItems, type ScopeEvents, TimeoutError, type TransformedEvents, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Unique, type WildcardEvents, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };