import { DependencyList, EffectCallback } from "react"; //#region src/react-util/useAsyncFn.d.ts interface UseAsyncFnOptions { initialValue?: InferValue; debounceMs?: number; debounceType?: "leading" | "trailing"; } type UseAsyncFn = (signal: AbortSignal, ...args: any[]) => Promise; type UseAsyncFnRun = Args extends unknown[] ? (...args: Args) => Promise : () => Promise; interface UseAsyncFnStateBase { run: UseAsyncFnRun; } interface UseAsyncFnStateLoading extends UseAsyncFnStateBase { loading: true; error?: Error | undefined; value?: Value; } interface UseAsyncFnStateError extends UseAsyncFnStateBase { loading: false; error: Error; value?: undefined; } interface UseAsyncFnStateResolved extends UseAsyncFnStateBase { loading: false; error?: undefined; value: Value; } type InferValue = Awaited>; type InferArgs = Parameters extends [any, ...infer Rest] ? Rest : []; type UseAsyncFnState = UseAsyncFnStateLoading | UseAsyncFnStateError | UseAsyncFnStateResolved; declare const useAsyncFn: , Args = InferArgs>(fn: F, deps?: DependencyList, options?: UseAsyncFnOptions) => UseAsyncFnState; //#endregion //#region src/react-util/useAsync.d.ts declare const useAsync: (fn: F, deps?: DependencyList, options?: UseAsyncFnOptions & { runImmediately?: boolean; }) => UseAsyncFnState>, Parameters extends [any, ...infer Rest] ? Rest : []>; //#endregion //#region src/react-util/useDebouncedCallback.d.ts interface UseDebouncedCallbackOptions { leading?: boolean; delayMs?: number; } declare function useDebouncedCallback any>(callback: T, deps: DependencyList, options?: UseDebouncedCallbackOptions): T; //#endregion //#region src/react-util/useDebouncedEffect.d.ts declare function useDebouncedEffect(callback: EffectCallback, deps: DependencyList, options?: UseDebouncedCallbackOptions): void; //#endregion //#region src/react-util/useMergedRef.d.ts /** * Combines several refs into one callback ref, so a component can keep its own internal ref while * still handing the element to a caller. * * The point is composition: a component that owns a ref for its own measurement or event wiring * can't simply accept a `ref` prop and forward it, because only one can win. Merging lets both * hold the same element, which is what makes a component usable as the child of a primitive that * needs the DOM node too — `asChild`-style composition being the usual reason. * * Nulls are skipped, so an optional incoming `ref` needs no guard at the call site. Callback refs * get their cleanup handled by React 19's return-value contract; object refs are assigned directly. * * The merged callback is stable as long as the refs passed in are, so it does not detach and * re-attach the element on every render. Pass a stable `ref` from props (React does this already) * rather than a fresh inline arrow. */ declare const useMergedRef: (...refs: (React.Ref | undefined)[]) => React.RefCallback; //#endregion //#region src/react-util/useMountEffect.d.ts declare const useMountEffect: (effectFn: React.EffectCallback) => void; //#endregion //#region src/react-util/useMountedState.d.ts declare const useMountedState: () => (() => boolean); //#endregion //#region src/react-util/useResize.d.ts interface UseResizeOptions { /** * Which box to report. Defaults to `"content"`. * * `"border"` includes padding and border, and is what you want when the number has to account * for space a *consumer* controls — measuring an element whose padding is part of the layout * budget, for instance. A padding change alters the border-box size, so the observer fires on it * and the measurement stays complete with no extra trigger. * * It still can't see a *margin*, which sits outside the border box. If margins matter, they have * to be part of the contract rather than measured. */ box?: "content" | "border"; } /** * Reports an element's size whenever it changes, including the initial measurement. * * The default content box means padding, border and scrollbars are all excluded — so a width fed * back into layout math can't feed back into its own overflow, and a gutter appearing or * disappearing is reported as a real size change. Pass `{ box: "border" }` when padding and border * should be included instead. Values are fractional; round at the point of use if you need * integers. * * `onResize` is read through a ref, so passing an inline arrow does not tear down and re-create the * observer on every render. */ declare const useResize: (ref: React.RefObject, onResize: (width: number, height: number) => void, options?: UseResizeOptions) => void; //#endregion //#region src/react-util/useStable.d.ts /** * Build a value once and keep it until `deps` change — the guarantee `useMemo` does not make. * * `useMemo` is a performance hint: React may discard a cached value and recompute it whenever it * likes. That is harmless for a derived number and quietly wrong for anything holding state, which * would be silently rebuilt mid-life — a lazy observable dropping what it had loaded, a store losing * its subscriptions. Reach for this whenever the value *is* the state rather than a view of it. * * ```ts * const controller = useStable(() => new AbortController(), [requestId]); * ``` * * `deps` are compared with `Object.is`, exactly as React compares its own. */ declare function useStable(create: () => T, deps: React.DependencyList): T; //#endregion export { UseAsyncFn, UseAsyncFnOptions, UseAsyncFnRun, UseAsyncFnState, UseAsyncFnStateBase, UseAsyncFnStateError, UseAsyncFnStateLoading, UseAsyncFnStateResolved, UseDebouncedCallbackOptions, UseResizeOptions, useAsync, useAsyncFn, useDebouncedCallback, useDebouncedEffect, useMergedRef, useMountEffect, useMountedState, useResize, useStable }; //# sourceMappingURL=react-util.d.mts.map