/** * bQuery plugin hooks system (1.14+). * * Implements WordPress-style synchronous `filter` and `action` pipelines that * can be exercised by plugins via the {@link PluginInstallContext} or directly * by core/application code. * * @module bquery/plugin */ type FilterCallback = (value: T, ...args: unknown[]) => T; type ActionCallback = (...args: unknown[]) => void; /** * Register a filter callback for a named filter hook. * * Each filter receives the current value and any contextual arguments and * **must** return the (possibly transformed) value. * * @param name - Filter name (e.g. `'view:render'`). * @param fn - Filter callback `(value, ...args) => value`. * @param priority - Sort priority, lower runs first. Defaults to `10`. * @returns A function that removes the filter when called. * * @example * ```ts * addFilter('greeting', (text: string) => text.toUpperCase()); * applyFilters('greeting', 'hello'); // 'HELLO' * ``` */ export declare const addFilter: (name: string, fn: (value: T, ...args: unknown[]) => T, priority?: number) => (() => void); /** @internal */ export declare const registerFilter: (name: string, fn: FilterCallback, priority?: number, owner?: string) => (() => void); /** * Apply all registered filters for the given name to `value`. * * @param name - Filter name. * @param value - Initial value. * @param args - Additional arguments forwarded to every filter callback. * @returns The value after all filters have been applied. */ export declare const applyFilters: (name: string, value: T, ...args: unknown[]) => T; /** * Remove a previously registered filter callback by reference. Returns `true` * if the callback was found and removed. */ export declare const removeFilter: (name: string, fn: (value: T, ...args: unknown[]) => T) => boolean; /** Remove every filter associated with the given plugin owner. @internal */ export declare const removeFiltersByOwner: (owner: string) => void; /** * Register an action callback for a named action hook. * * Actions are fire-and-forget; their return value is ignored. * * @param name - Action name (e.g. `'router:before-navigate'`). * @param fn - Action callback `(...args) => void`. * @param priority - Sort priority, lower runs first. Defaults to `10`. * @returns A function that removes the action when called. */ export declare const addAction: (name: string, fn: (...args: unknown[]) => void, priority?: number) => (() => void); /** @internal */ export declare const registerAction: (name: string, fn: ActionCallback, priority?: number, owner?: string) => (() => void); /** Dispatch every registered action callback in priority order. */ export declare const doAction: (name: string, ...args: unknown[]) => void; /** Remove a previously registered action callback. */ export declare const removeAction: (name: string, fn: (...args: unknown[]) => void) => boolean; /** Remove every action associated with the given plugin owner. @internal */ export declare const removeActionsByOwner: (owner: string) => void; /** Remove every registered filter and action. Test-only. @internal */ export declare const resetHooks: () => void; /** Returns the list of currently registered filter names. */ export declare const listFilters: () => readonly string[]; /** Returns the list of currently registered action names. */ export declare const listActions: () => readonly string[]; export {}; //# sourceMappingURL=hooks.d.ts.map