import { type MapFunction } from '../value/map'; import { type ArrayOrValue } from '../array/array'; import { type PrimativeKey } from '../key'; import { type HandleResult, type InternalHandlerFunction, type Handler, type HandlerAccessor, type HandlerSetAccessor } from './handler'; /** * Wraps a HandlerAccessor and the item it is bound to in order to be a HandlerSetAccessor. */ export interface HandlerBindAccessor extends HandlerSetAccessor { readonly accessor: HandlerAccessor; readonly boundTo: unknown; } /** * Creates a {@link HandlerBindAccessor} that automatically binds handler functions to the given object * when registering them via `set`. * * @param boundTo - The object to bind handler functions to. * @param accessor - The underlying handler accessor to delegate to. * @returns A HandlerBindAccessor wrapping the accessor with automatic binding. */ export declare function handlerBindAccessor(boundTo: unknown, accessor: HandlerAccessor): HandlerBindAccessor; /** * Contextual function that configures the context's Handler with the input function for the context's key. */ export type HandlerSetFunction = (handlerFunction: InternalHandlerFunction) => void; /** * Creates a {@link HandlerSetFunction} that registers a handler function on a pre-defined key. * * @param accessor - The handler set accessor to register on. * @param key - The key (or keys) to associate the handler with. * @returns A function that accepts a handler function and registers it for the given key. */ export declare function handlerSetFunction(accessor: HandlerSetAccessor, key: ArrayOrValue): HandlerSetFunction; /** * A function that registers a handler function whose input type differs from the handler's native type, * using a mapping function to convert between them. */ export type HandlerMappedSetFunction = (handlerFunction: InternalHandlerFunction) => void; /** * Creates a {@link HandlerMappedSetFunction} that maps the handler's native input type to a different * type before invoking the registered handler function. * * @param accessor - The handler set accessor to register on. * @param key - The key (or keys) to associate the handler with. * @param mapFn - Function to map from the handler's native type to the handler function's expected type. * @returns A function that accepts a mapped handler function and registers it. */ export declare function handlerMappedSetFunction(accessor: HandlerSetAccessor, key: ArrayOrValue, mapFn: MapFunction): HandlerMappedSetFunction; /** * Factory for a HandlerMappedSetFunction. */ export type HandlerMappedSetFunctionFactory = (key: ArrayOrValue) => HandlerMappedSetFunction; /** * Creates a {@link HandlerMappedSetFunctionFactory} that produces mapped set functions for any given key. * * @param accessor - The handler set accessor to register on. * @param mapFn - Function to map from the handler's native type to the handler function's expected type. * @returns A factory that creates HandlerMappedSetFunctions for specific keys. */ export declare function handlerMappedSetFunctionFactory(accessor: HandlerSetAccessor, mapFn: MapFunction): HandlerMappedSetFunctionFactory; /** * A function that configures handler bindings via a configurer object. */ export type HandlerConfigurerFunction, T, K extends PrimativeKey = string, R = HandleResult> = (configurer: C) => void; /** * A function that binds an object to a handler and invokes a configure callback. */ export type HandlerConfigurer, T, K extends PrimativeKey = string, R = HandleResult> = (bindTo: unknown, configure: HandlerConfigurerFunction) => void; /** * Factory that creates a {@link HandlerConfigurer} for a given handler. */ export type HandlerConfigurerFactory, T, K extends PrimativeKey = string, R = HandleResult> = (handler: Handler) => HandlerConfigurer; /** * Configuration for {@link handlerConfigurerFactory}. */ export interface HandlerConfigurerFactoryConfig, T, K extends PrimativeKey = string, R = HandleResult> { /** * Creates a typed configurer from a bind accessor. */ configurerForAccessor: (accessor: HandlerBindAccessor) => C; } /** * Creates a {@link HandlerConfigurerFactory} that produces configurers for binding handler functions * to a handler instance with automatic `this` binding. * * @param config - Configuration providing the accessor-to-configurer mapping. * @returns A factory that creates HandlerConfigurers for specific handlers. */ export declare function handlerConfigurerFactory, T, K extends PrimativeKey = string, R = HandleResult>(config: HandlerConfigurerFactoryConfig): HandlerConfigurerFactory;