/** These apply to all hooks */ /** * @external */ export type StandardDefineHookOptions = { /** A set of tags for this hook - e.g., "direct" or "raw" - which can be provided as one of the options to all operations to filter which hooks run at a high level*/ tags?: string[]; /** The name - only useful for debugging purposes, e.g., with instrumentation */ name?: string; }; /** * @external */ export type StandardInvokeHookOptions = { /** Filter the hooks to only run those which include one of these tags */ includeTags?: string[]; /** Filter the hooks to only run those which don't include one of these tags */ excludeTags?: string[]; /** A function to run to determine whether a hook should be ran or not */ includeHook?: (hookName: HK, hook: ChainedListenerCallback, options?: EM[K]["options"]) => boolean; /** An abort signal to allow interuption of long running operations - particularly useful in the case of *Many operations with individual hooks */ signal?: AbortSignal; }; export type ChainedCallbackEntry = { callbackArgs: CBARGS; returns: any; isPromise: boolean; emitArgs: EMITARGS; options: StandardDefineHookOptions; returnEmitName?: string | undefined; }; export type ChainedCallbackEventMap = Record; type DefaultChainedCallbackEventMap = ChainedCallbackEventMap; export type CallbackAndOptionsOfEm = { options?: EM[K]["options"]; listener: ChainedListenerCallback; }; export type ChainedListenerCallback = (EM[K]["callbackArgs"] extends object ? (...args: [EM[K]["callbackArgs"]]) => EM[K]["isPromise"] extends true ? EM[K]["returns"] | void | Promise : EM[K]["returns"] | void : never); export type ExtraEvent = K | { event: K; emitArgs?: Partial; }; export declare class ChainedAwaiatableEventEmitter { #private; callSyncChainWithKey(eventName: K, // weird - but this is what enforces the keyof SYNCEM emitArgs: EM[K]["emitArgs"], chainKey: CK | undefined, options: StandardInvokeHookOptions | undefined): EM[K]["returns"]; callAllSyncChainWithKey(emitArgs: EM[MK]["emitArgs"], chainKey: CK | undefined, options: StandardInvokeHookOptions | undefined, masterEventName: MK, ...otherEventNames: K[]): void; callAllSync(emitArgs: EM[MK]["emitArgs"], options: StandardInvokeHookOptions | undefined, masterEventName: MK, ...additionalEvents: ExtraEvent[]): void; callAwaitableChainWithKey(eventName: K, emitArgs: EM[K]["emitArgs"], chainKey: CK, options: StandardInvokeHookOptions | undefined): Promise; callAllAwaitableInParallel(emitArgs: EM[MK]["emitArgs"], options: StandardInvokeHookOptions | undefined, masterEventName: MK, ...additionalEvents: ExtraEvent[]): Promise : void | EM[K]["returns"]>[]>; callAllAwaitableChainWithKey(emitArgs: EM[MK]["emitArgs"], chainKey: CK, options: StandardInvokeHookOptions | undefined, masterEventName: MK, ...additionalEvents: ExtraEvent[]): Promise; callExplicitAwaitableListenersChainWithKey(masterEventName: MK, emitArgs: EM[MK]["emitArgs"], chainKey: CK, listenersWithOptions: CallbackAndOptionsOfEm[], signal: AbortSignal | undefined): Promise; allListenersWithOptions(): { listener: ChainedListenerCallback; options: EM[keyof EM]["options"] | undefined; eventName: keyof EM; }[]; relevantAwaitableListeners(eventName: K, options?: StandardInvokeHookOptions): ChainedListenerCallback[]; relevantAwaitableListenersWithOptions(eventName: K, options?: StandardInvokeHookOptions): CallbackAndOptionsOfEm[]; awaitableListenersWithOptions(eventName: K): CallbackAndOptionsOfEm[]; awaitableListeners(eventName: K): ChainedListenerCallback[]; addListener(eventName: K, listener: ChainedListenerCallback, options?: EM[K]["options"]): this; awaitableOn(eventName: K, listener: ChainedListenerCallback, options?: EM[K]["options"]): this; awaitableOff(eventName: K, listener: ChainedListenerCallback): this; listenerCount(eventName: keyof EM): number; eventNames(): (keyof EM)[]; } export {};