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.
@@ -274,6 +274,9 @@ type Overloads<T> = Unique<T extends {
274
274
  T
275
275
  ]>;
276
276
  type Dict<V = any> = Record<Exclude<string, number | symbol>, V>;
277
+ type Union<T> = T extends infer O ? {
278
+ [K in keyof O]: O[K];
279
+ } : never;
277
280
 
278
281
  type FastEventBusMessage<Events extends Record<string, any> = Record<string, any>, M = any> = FastEventEmitMessage<Events, M> & {
279
282
  from?: string;
@@ -311,7 +314,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
311
314
  anyListener: TypedFastEventAnyListener<Events, FinalMeta, Fallback<Context, typeof this>>;
312
315
  };
313
316
  prefix: string;
314
- emitter: FastEvent<Events>;
317
+ emitter: FastEvent<any>;
315
318
  constructor(options?: DeepPartial<FastEventScopeOptions<FinalMeta, Context>>);
316
319
  get context(): Fallback<Context, typeof this>;
317
320
  get options(): FastEventScopeOptions<FinalMeta, Context>;
@@ -358,12 +361,16 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
358
361
  clear(): void;
359
362
  emit(type: Types, directive: symbol): void;
360
363
  emit(type: string, directive: symbol): void;
364
+ emit<R = any, T extends Types = Types>(type: T, payload?: Events[T], retain?: boolean): R[];
365
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, retain?: boolean): R[];
361
366
  emit<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): R[];
362
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[Types] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
367
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
363
368
  emit<R = any>(message: FastEventEmitMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
364
369
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
365
370
  [K in T]: K extends Types ? Events[K] : any;
366
371
  }, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
372
+ emitAsync<R = any>(type: Types, payload?: Events[Types], retain?: boolean): Promise<[R | Error][]>;
373
+ emitAsync<R = any>(type: string, payload?: any, retain?: boolean): Promise<[R | Error][]>;
367
374
  emitAsync<R = any>(type: string, payload?: any, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
368
375
  emitAsync<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
369
376
  emitAsync<R = any>(message: TypedFastEventMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
@@ -424,7 +431,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
424
431
  * @template Meta - 事件元数据类型,默认为任意键值对对象
425
432
  * @template Types - 事件类型的键名类型,默认为Events的键名类型
426
433
  */
427
- 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>>> {
434
+ 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>>> {
428
435
  __FastEvent__: boolean;
429
436
  /** 事件监听器树结构,存储所有注册的事件监听器 */
430
437
  listeners: FastListeners;
@@ -746,13 +753,13 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
746
753
  emit<T extends Types = Types>(type: T, directive: symbol): any[];
747
754
  emit(type: string, directive: symbol): any[];
748
755
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], retain?: boolean): R[];
749
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, retain?: boolean): R[];
756
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, retain?: boolean): R[];
750
757
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
751
758
  [K in T]: K extends Types ? AllEvents[K] : any;
752
759
  }, Meta>, retain?: boolean): R[];
753
760
  emit<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, retain?: boolean): R[];
754
761
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], options?: FastEventListenerArgs<Meta>): R[];
755
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, options?: FastEventListenerArgs<Meta>): R[];
762
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, options?: FastEventListenerArgs<Meta>): R[];
756
763
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
757
764
  [K in T]: K extends Types ? AllEvents[K] : any;
758
765
  }, Meta>, options?: FastEventListenerArgs<Meta>): R[];
@@ -1145,4 +1152,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
1145
1152
 
1146
1153
  declare function isFastEvent(target: any): target is FastEvent;
1147
1154
 
1148
- export { AbortError, BroadcastEvent, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventBus, type FastEventBusEventTypes, type FastEventBusEvents, type FastEventBusMessage, FastEventBusNode, type FastEventBusNodeIds, type FastEventBusNodeOptions, type FastEventBusNodes, type FastEventBusOptions, 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, NamespaceDelimiter, NodeDataEvent, 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 };
1155
+ export { AbortError, BroadcastEvent, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventBus, type FastEventBusEventTypes, type FastEventBusEvents, type FastEventBusMessage, FastEventBusNode, type FastEventBusNodeIds, type FastEventBusNodeOptions, type FastEventBusNodes, type FastEventBusOptions, 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, NamespaceDelimiter, NodeDataEvent, 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 };
@@ -274,6 +274,9 @@ type Overloads<T> = Unique<T extends {
274
274
  T
275
275
  ]>;
276
276
  type Dict<V = any> = Record<Exclude<string, number | symbol>, V>;
277
+ type Union<T> = T extends infer O ? {
278
+ [K in keyof O]: O[K];
279
+ } : never;
277
280
 
278
281
  type FastEventBusMessage<Events extends Record<string, any> = Record<string, any>, M = any> = FastEventEmitMessage<Events, M> & {
279
282
  from?: string;
@@ -311,7 +314,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
311
314
  anyListener: TypedFastEventAnyListener<Events, FinalMeta, Fallback<Context, typeof this>>;
312
315
  };
313
316
  prefix: string;
314
- emitter: FastEvent<Events>;
317
+ emitter: FastEvent<any>;
315
318
  constructor(options?: DeepPartial<FastEventScopeOptions<FinalMeta, Context>>);
316
319
  get context(): Fallback<Context, typeof this>;
317
320
  get options(): FastEventScopeOptions<FinalMeta, Context>;
@@ -358,12 +361,16 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
358
361
  clear(): void;
359
362
  emit(type: Types, directive: symbol): void;
360
363
  emit(type: string, directive: symbol): void;
364
+ emit<R = any, T extends Types = Types>(type: T, payload?: Events[T], retain?: boolean): R[];
365
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, retain?: boolean): R[];
361
366
  emit<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): R[];
362
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[Types] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
367
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : any, options?: FastEventListenerArgs<FinalMeta>): R[];
363
368
  emit<R = any>(message: FastEventEmitMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
364
369
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
365
370
  [K in T]: K extends Types ? Events[K] : any;
366
371
  }, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
372
+ emitAsync<R = any>(type: Types, payload?: Events[Types], retain?: boolean): Promise<[R | Error][]>;
373
+ emitAsync<R = any>(type: string, payload?: any, retain?: boolean): Promise<[R | Error][]>;
367
374
  emitAsync<R = any>(type: string, payload?: any, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
368
375
  emitAsync<R = any>(type: Types, payload?: Events[Types], options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
369
376
  emitAsync<R = any>(message: TypedFastEventMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
@@ -424,7 +431,7 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
424
431
  * @template Meta - 事件元数据类型,默认为任意键值对对象
425
432
  * @template Types - 事件类型的键名类型,默认为Events的键名类型
426
433
  */
427
- 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>>> {
434
+ 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>>> {
428
435
  __FastEvent__: boolean;
429
436
  /** 事件监听器树结构,存储所有注册的事件监听器 */
430
437
  listeners: FastListeners;
@@ -746,13 +753,13 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
746
753
  emit<T extends Types = Types>(type: T, directive: symbol): any[];
747
754
  emit(type: string, directive: symbol): any[];
748
755
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], retain?: boolean): R[];
749
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, retain?: boolean): R[];
756
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, retain?: boolean): R[];
750
757
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
751
758
  [K in T]: K extends Types ? AllEvents[K] : any;
752
759
  }, Meta>, retain?: boolean): R[];
753
760
  emit<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, retain?: boolean): R[];
754
761
  emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T], options?: FastEventListenerArgs<Meta>): R[];
755
- emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[Types] : any, options?: FastEventListenerArgs<Meta>): R[];
762
+ emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any, options?: FastEventListenerArgs<Meta>): R[];
756
763
  emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
757
764
  [K in T]: K extends Types ? AllEvents[K] : any;
758
765
  }, Meta>, options?: FastEventListenerArgs<Meta>): R[];
@@ -1145,4 +1152,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
1145
1152
 
1146
1153
  declare function isFastEvent(target: any): target is FastEvent;
1147
1154
 
1148
- export { AbortError, BroadcastEvent, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventBus, type FastEventBusEventTypes, type FastEventBusEvents, type FastEventBusMessage, FastEventBusNode, type FastEventBusNodeIds, type FastEventBusNodeOptions, type FastEventBusNodes, type FastEventBusOptions, 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, NamespaceDelimiter, NodeDataEvent, 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 };
1155
+ export { AbortError, BroadcastEvent, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventBus, type FastEventBusEventTypes, type FastEventBusEvents, type FastEventBusMessage, FastEventBusNode, type FastEventBusNodeIds, type FastEventBusNodeOptions, type FastEventBusNodes, type FastEventBusOptions, 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, NamespaceDelimiter, NodeDataEvent, 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 };