import { Binding } from "@rbxts/react"; export interface BindingApi { subscribe: (callback: (newValue: T) => void) => () => void; update: (newValue: T) => void; getValue: () => T; } export interface Lerpable { Lerp: (this: T, to: T, alpha: number) => T; } export type BindingOrValue = Binding | T; type Bindable = Binding | NonNullable; type ComposeBindings = { [K in keyof T]: T[K] extends Bindable ? U : T[K]; }; type BindingCombiner = (...values: ComposeBindings) => U; /** * Returns whether the given value is a binding. * @param value The value to check. * @returns Whether the value is a binding. */ export declare function isBinding(value: T | Binding): value is Binding; export declare function isBinding(value: unknown): value is Binding; /** * Converts a value to a binding. If the given value is already a binding, it * will be returned as-is. * @param value The value to convert. * @returns The converted binding. */ export declare function toBinding(value: T | Binding): Binding; /** * Returns the value of a binding. If the given value is not a binding, it will * be returned as-is. * @param binding The binding to get the value of. * @returns The value of the binding. */ export declare function getBindingValue(binding: T | Binding): T; /** * Maps a binding to a new binding. If the given value is not a binding, it will * be passed to the mapper function and returned as a new binding. * @param binding The binding to map. * @param callback The mapper function. * @returns The mapped binding. */ export declare function mapBinding(binding: T | Binding, callback: (value: T) => U): Binding; /** * Joins a map of bindings into a single binding. If any of the given values * are not bindings, they will be wrapped in a new binding. * @param bindings The bindings to join. * @returns The joined binding. */ export declare function joinAnyBindings>>(bindings: T): Binding<{ [K in keyof T]: T[K] extends BindingOrValue ? U : T[K]; }>; export declare function joinAnyBindings(bindings: readonly [...T]): Binding<{ [K in keyof T]: T[K] extends BindingOrValue ? U : T[K]; }>; /** * Gets the internal API of a binding. This is a hacky way to get access to the * `BindingInternalApi` object of a binding, which is not exposed by React. * @param binding The binding to get the internal API of. * @returns The binding's API. */ export declare function getBindingApi(binding: Binding): BindingApi | undefined; /** * Returns a binding that lerps between two values using the given binding as * the alpha. * @param binding The binding to use as the alpha. * @param from The value to lerp from. * @param to The value to lerp to. * @returns A binding that lerps between two values. */ export declare function lerpBinding>(binding: Binding | number, from: T, to: T): Binding; /** * Composes multiple bindings or values together into a single binding. * Calls the combiner function with the values of the bindings when any * of the bindings change. * @param ...bindings A list of bindings or values. * @param combiner The function that maps the bindings to a new value. * @returns A binding that returns the result of the combiner. */ export declare function composeBindings(...bindings: [...T, BindingCombiner]): Binding; export {};