/** * Shared data-provider contract used by components that render a list of items. * * A provider is a simple callable — the consuming component (via DataController) * manages the request lifecycle, cancellation, and reactive state. */ /** * One batch of items within a streaming provider response. * * For sync and async one-shot providers, the DataController synthesises a single * DataBatch internally — you only need this type when writing a streaming provider. */ type DataBatch = { /** Items delivered in this batch. */ readonly items: readonly T[]; /** * When true, replace all previously accumulated items with this batch instead * of appending. Useful for re-ranked or filtered results mid-stream. * Default: false (append). */ replace?: boolean; /** * Provider's current estimate of the total number of items that will be * delivered across all batches. Enables progress percentage in the consumer. * May be refined in subsequent batches as the estimate improves. * Omit when the total is unknown. */ total?: number; }; /** * The three return modes a provider may use. * DataController normalises all three — callers can mix modes freely. * * - `readonly T[]` — sync, items available immediately * - `Promise` — async one-shot, resolves to the full result * - `AsyncIterable>` — streaming, batches arrive over time */ type DataProviderResult = readonly T[] | Promise | AsyncIterable>; /** * A data provider callable. * * @typeParam TQuery - The input that scopes the request (e.g. `string` for * autocomplete, `{ node, depth }` for a tree branch, `void` for a plain list). * @typeParam TItem - The item type produced. * * The AbortSignal is cancelled when the consumer supersedes the request (e.g. * a new query arrives before the previous one completes). Streaming providers * should check `signal.aborted` between yields or pass the signal to their * underlying fetch calls. */ type IDataProvider = (query: TQuery, signal: AbortSignal) => DataProviderResult; /** * Collects all items from any DataProviderResult into a flat array. * Useful for components that need a complete list before rendering (e.g. tree branches). * Respects the AbortSignal — stops accumulating if cancelled mid-stream. */ declare function collectDataResult(result: DataProviderResult, signal: AbortSignal): Promise; export { collectDataResult as i, DataProviderResult as n, IDataProvider as r, DataBatch as t };