fastevent 2.2.6 → 2.2.8

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
@@ -272,6 +272,9 @@ type Overloads<T> = Unique<T extends {
272
272
  T
273
273
  ]>;
274
274
  type Dict<V = any> = Record<Exclude<string, number | symbol>, V>;
275
+ type Union<T> = T extends infer O ? {
276
+ [K in keyof O]: O[K];
277
+ } : never;
275
278
 
276
279
  type FastListenerExecutor = (listeners: FastListenerMeta[], message: TypedFastEventMessage, args: FastEventListenerArgs, execute: (listener: TypedFastEventListener, message: TypedFastEventMessage, args: FastEventListenerArgs, catchErrors?: boolean) => Promise<any> | any) => Promise<any[]> | any[];
277
280
 
@@ -296,7 +299,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
296
299
  anyListener: TypedFastEventAnyListener<Events, FinalMeta, Fallback<Context, typeof this>>;
297
300
  };
298
301
  prefix: string;
299
- emitter: FastEvent<Events>;
302
+ emitter: FastEvent<any>;
300
303
  constructor(options?: DeepPartial<FastEventScopeOptions<FinalMeta, Context>>);
301
304
  get context(): Fallback<Context, typeof this>;
302
305
  get options(): FastEventScopeOptions<FinalMeta, Context>;
@@ -343,12 +346,16 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
343
346
  clear(): void;
344
347
  emit(type: Types, directive: symbol): void;
345
348
  emit(type: string, directive: symbol): void;
349
+ emit<R = any, T extends Types = Types>(type: T, payload?: Events[T], retain?: boolean): R[];
350
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, retain?: boolean): R[];
346
351
  emit<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): R[];
347
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[Types] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
352
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
348
353
  emit<R = any>(message: FastEventEmitMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
349
354
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
350
355
  [K in T]: K extends Types ? Events[K] : any;
351
356
  }, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
357
+ emitAsync<R = any>(type: Types, payload?: Events[Types], retain?: boolean): Promise<[R | Error][]>;
358
+ emitAsync<R = any>(type: string, payload?: any, retain?: boolean): Promise<[R | Error][]>;
352
359
  emitAsync<R = any>(type: string, payload?: any, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
353
360
  emitAsync<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
354
361
  emitAsync<R = any>(message: TypedFastEventMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
@@ -409,7 +416,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
409
416
  * @template Meta - 事件元数据类型,默认为任意键值对对象
410
417
  * @template Types - 事件类型的键名类型,默认为Events的键名类型
411
418
  */
412
- declare class FastEvent<Events extends Record<string, any> = Record<string, any>, Meta extends Record<string, any> = Record<string, any>, Context = never, AllEvents extends Record<string, any> = Events & FastEvents, Types extends keyof AllEvents = Expand<Exclude<keyof (AllEvents), number | symbol>>> {
419
+ declare class FastEvent<Events extends Record<string, any> = Record<string, any>, Meta extends Record<string, any> = Record<string, any>, Context = never, AllEvents extends Record<string, any> = Expand<Events & FastEvents>, Types extends keyof AllEvents = Expand<Exclude<keyof AllEvents, number | symbol>>> {
413
420
  __FastEvent__: boolean;
414
421
  /** 事件监听器树结构,存储所有注册的事件监听器 */
415
422
  listeners: FastListeners;
@@ -731,13 +738,13 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
731
738
  emit<T extends Types = Types>(type: T, directive: symbol): any[];
732
739
  emit(type: string, directive: symbol): any[];
733
740
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], retain?: boolean): R[];
734
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, retain?: boolean): R[];
741
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, retain?: boolean): R[];
735
742
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
736
743
  [K in T]: K extends Types ? AllEvents[K] : any;
737
744
  }, Meta>, retain?: boolean): R[];
738
745
  emit<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, retain?: boolean): R[];
739
746
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], options?: FastEventListenerArgs<Meta>): R[];
740
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, options?: FastEventListenerArgs<Meta>): R[];
747
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, options?: FastEventListenerArgs<Meta>): R[];
741
748
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
742
749
  [K in T]: K extends Types ? AllEvents[K] : any;
743
750
  }, Meta>, options?: FastEventListenerArgs<Meta>): R[];
@@ -971,4 +978,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
971
978
 
972
979
  declare function isFastEvent(target: any): target is FastEvent;
973
980
 
974
- export { AbortError, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, 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 Merge, type ObjectKeys, type OptionalItems, type Overloads, type OverrideOptions, type PickScopeEvents, QueueOverflowError, type RequiredItems, type ScopeEvents, TimeoutError, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Unique, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
981
+ export { AbortError, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, 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 Merge, type ObjectKeys, type OptionalItems, type Overloads, type OverrideOptions, type PickScopeEvents, QueueOverflowError, type RequiredItems, type ScopeEvents, TimeoutError, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Union, type Unique, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
package/dist/index.d.ts CHANGED
@@ -272,6 +272,9 @@ type Overloads<T> = Unique<T extends {
272
272
  T
273
273
  ]>;
274
274
  type Dict<V = any> = Record<Exclude<string, number | symbol>, V>;
275
+ type Union<T> = T extends infer O ? {
276
+ [K in keyof O]: O[K];
277
+ } : never;
275
278
 
276
279
  type FastListenerExecutor = (listeners: FastListenerMeta[], message: TypedFastEventMessage, args: FastEventListenerArgs, execute: (listener: TypedFastEventListener, message: TypedFastEventMessage, args: FastEventListenerArgs, catchErrors?: boolean) => Promise<any> | any) => Promise<any[]> | any[];
277
280
 
@@ -296,7 +299,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
296
299
  anyListener: TypedFastEventAnyListener<Events, FinalMeta, Fallback<Context, typeof this>>;
297
300
  };
298
301
  prefix: string;
299
- emitter: FastEvent<Events>;
302
+ emitter: FastEvent<any>;
300
303
  constructor(options?: DeepPartial<FastEventScopeOptions<FinalMeta, Context>>);
301
304
  get context(): Fallback<Context, typeof this>;
302
305
  get options(): FastEventScopeOptions<FinalMeta, Context>;
@@ -343,12 +346,16 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
343
346
  clear(): void;
344
347
  emit(type: Types, directive: symbol): void;
345
348
  emit(type: string, directive: symbol): void;
349
+ emit<R = any, T extends Types = Types>(type: T, payload?: Events[T], retain?: boolean): R[];
350
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, retain?: boolean): R[];
346
351
  emit<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): R[];
347
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[Types] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
352
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
348
353
  emit<R = any>(message: FastEventEmitMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
349
354
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
350
355
  [K in T]: K extends Types ? Events[K] : any;
351
356
  }, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
357
+ emitAsync<R = any>(type: Types, payload?: Events[Types], retain?: boolean): Promise<[R | Error][]>;
358
+ emitAsync<R = any>(type: string, payload?: any, retain?: boolean): Promise<[R | Error][]>;
352
359
  emitAsync<R = any>(type: string, payload?: any, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
353
360
  emitAsync<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
354
361
  emitAsync<R = any>(message: TypedFastEventMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
@@ -409,7 +416,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
409
416
  * @template Meta - 事件元数据类型,默认为任意键值对对象
410
417
  * @template Types - 事件类型的键名类型,默认为Events的键名类型
411
418
  */
412
- declare class FastEvent<Events extends Record<string, any> = Record<string, any>, Meta extends Record<string, any> = Record<string, any>, Context = never, AllEvents extends Record<string, any> = Events & FastEvents, Types extends keyof AllEvents = Expand<Exclude<keyof (AllEvents), number | symbol>>> {
419
+ declare class FastEvent<Events extends Record<string, any> = Record<string, any>, Meta extends Record<string, any> = Record<string, any>, Context = never, AllEvents extends Record<string, any> = Expand<Events & FastEvents>, Types extends keyof AllEvents = Expand<Exclude<keyof AllEvents, number | symbol>>> {
413
420
  __FastEvent__: boolean;
414
421
  /** 事件监听器树结构,存储所有注册的事件监听器 */
415
422
  listeners: FastListeners;
@@ -731,13 +738,13 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
731
738
  emit<T extends Types = Types>(type: T, directive: symbol): any[];
732
739
  emit(type: string, directive: symbol): any[];
733
740
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], retain?: boolean): R[];
734
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, retain?: boolean): R[];
741
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, retain?: boolean): R[];
735
742
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
736
743
  [K in T]: K extends Types ? AllEvents[K] : any;
737
744
  }, Meta>, retain?: boolean): R[];
738
745
  emit<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, retain?: boolean): R[];
739
746
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], options?: FastEventListenerArgs<Meta>): R[];
740
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, options?: FastEventListenerArgs<Meta>): R[];
747
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, options?: FastEventListenerArgs<Meta>): R[];
741
748
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
742
749
  [K in T]: K extends Types ? AllEvents[K] : any;
743
750
  }, Meta>, options?: FastEventListenerArgs<Meta>): R[];
@@ -971,4 +978,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
971
978
 
972
979
  declare function isFastEvent(target: any): target is FastEvent;
973
980
 
974
- export { AbortError, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, 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 Merge, type ObjectKeys, type OptionalItems, type Overloads, type OverrideOptions, type PickScopeEvents, QueueOverflowError, type RequiredItems, type ScopeEvents, TimeoutError, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Unique, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
981
+ export { AbortError, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, 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 Merge, type ObjectKeys, type OptionalItems, type Overloads, type OverrideOptions, type PickScopeEvents, QueueOverflowError, type RequiredItems, type ScopeEvents, TimeoutError, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Union, type Unique, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };