import { S as lazyPages, _ as LazyPagesOptions, a as LazyArrayApi, b as lazy, c as LazyFetchOptions, d as LazyOptionsWithInitialValue, f as LazyPageRequest, g as LazyPagesFetch, h as LazyPagesApi, i as LazyArray, l as LazyInvalidateOptions, m as LazyPages, n as Lazy, o as LazyArrayOptions, p as LazyPageResult, r as LazyApi, s as LazyFetch, t as InferLazy, u as LazyOptions, v as LoadedLazy, x as lazyArray, y as LoadedLazyArray } from "./lazy-C0Y_eCnB.mjs"; import { r as SlowLoadingOptions } from "./use-slow-loading-D5q4M47N.mjs"; import React$1 from "react"; //#region src/lazy/use-lazy.d.ts /** * A lazy observable that belongs to one component, for an async read whose inputs are the * component's own — a route param, a prop, a piece of local state. * * ```tsx * const study = useLazy((options) => StudyModel.get({ id: studyId }, options), [studyId]); * ``` * * What comes back is an ordinary `lazy`: it loads when something observes it, keeps its * value while it reloads, and aborts a request it supersedes. Nothing reading one can tell whether * it came from a hook, a store, or a hand-rolled construction — which is the point. * * `deps` say *which* lazy this is, so changing them builds a new one, exactly as constructing a * second lazy by hand would: the value starts empty and loads again. That is what you want for a * record — showing the study you navigated away from while the next one loads would be a lie. When * the inputs are filters over a single list rather than a different list, `useCollection`'s `params` * are the other shape: same lazy, refetched, rows readable throughout. * * Held through {@link useStable} rather than `useMemo`, which React may discard — that would rebuild * the lazy and silently drop what it had loaded. * * An `initialValue` seeds it, exactly as it does for a hand-built lazy, and narrows the result so * `value` reads without a `loaded` check. The seed belongs to *this* lazy, so changing `deps` * builds a new one starting from the seed again — which is what you want, since the seed describes * the inputs it was written for. */ declare function useLazy(fetch: LazyFetch, deps: React.DependencyList, options: LazyOptionsWithInitialValue & { initialValue: T; }): LoadedLazy; declare function useLazy(fetch: LazyFetch, deps: React.DependencyList, options?: LazyOptions): Lazy; /** * {@link useLazy} for a value that is a list. * * ```tsx * const rows = useLazyArray((options) => api.listSections({ studyId }, options), [studyId]); * ``` * * The lazy owns one observable array for its lifetime, so loads replace its *contents* — but `deps` * changing ends that lifetime and builds a new lazy with a new array, just as constructing one by * hand would. Anything watching array identity should watch the lazy's `loadedAt` instead. * * An `initialValue` seeds the list and narrows the result, so `value` reads without a `loaded` * check — `initialValue: []` included, which is how you say "there are none yet, and that is a * fact" rather than "not known yet". */ declare function useLazyArray(fetch: LazyFetch, deps: React.DependencyList, options: LazyArrayOptions & { initialValue: T[]; }): LoadedLazyArray; declare function useLazyArray(fetch: LazyFetch, deps: React.DependencyList, options?: LazyArrayOptions): LazyArray; /** * {@link useLazyArray} for a list that grows a page at a time — an infinite feed or a load-more * list whose inputs are the component's own. * * ```tsx * const feed = useLazyPages( * ({ cursor, limit, signal }) => api.listComments({ postId, cursor, limit, signal }), * [postId], * ); * ``` * * `deps` say *which* list this is, so changing them builds a new one from page one — the right * answer for a different post, where continuing to show the previous one's comments while the next * arrive would be a lie. * * For inputs that select *within* one list — a filter, a sort, a search box — reach for * `setQuery` instead and leave `deps` alone. That keeps the same list and requeries it, so the rows * stay readable while page one of the new query loads: * * ```tsx * const feed = useLazyPages(fetchPage, [postId]); * useEffect(() => feed.setQuery({ sort }), [feed, sort]); * ``` * * A structurally equal query is a no-op, which is what makes that effect safe to run every render. */ declare function useLazyPages(fetch: LazyPagesFetch, deps: React.DependencyList, options?: LazyPagesOptions): LazyPages; //#endregion //#region src/lazy/components/lazy-observer.d.ts type LO = Lazy | LazyArray; type ObserveTuple = { [K in keyof O]: InferLazy }; interface LazyObserverBaseProps { placeholder?: React$1.ReactNode; /** * Hold the `placeholder` back until the wait is long enough to be worth showing, and then keep it * up long enough to read — see `useSlowLoading`. On by default, so a fast load renders no * placeholder at all rather than flashing one. * * The clock runs off the *combined* gate, not per-lazy: it starts when the first value is missing * and resets once they are all present. * * Pass `false` to render the placeholder the instant anything is missing, or an object to override * the timings — a dashboard tile and a full-page route need not agree. */ sustain?: boolean | SlowLoadingOptions; } interface LazyObserverTupleProps extends LazyObserverBaseProps { observe: [...O]; children: (...value: ObserveTuple) => React$1.ReactNode; } interface LazyObserverSingleProps extends LazyObserverBaseProps { observe: O; children: (value: InferLazy) => React$1.ReactNode; } /** * Renders `children` once every observed lazy holds a value, a `placeholder` while they don't, and * re-throws a failure that leaves nothing to render so an error boundary can take over. * * Two behaviours worth knowing, both aimed at not destroying a screen that is working: * * - The gate is `loaded`, not `fetching`. A reload that keeps its value renders `children` * throughout, so a refresh never blanks the page. * - Only a failure with **nothing loaded** is thrown. A failed refresh keeps rendering the value it * still has. */ declare const LazyObserver: { (props: LazyObserverTupleProps): React$1.ReactNode; (props: LazyObserverSingleProps): React$1.ReactNode; }; //#endregion //#region src/lazy/deprecated.d.ts /** @deprecated Renamed to `lazy`. Removed at 1.0. */ declare const lazyObservable: typeof lazy; /** @deprecated Renamed to `lazyArray`. Removed at 1.0. */ declare const lazyObservableArray: typeof lazyArray; /** @deprecated Renamed to `Lazy`. Removed at 1.0. */ type LazyObservable = Lazy; /** @deprecated Renamed to `LazyArray`. Removed at 1.0. */ type LazyObservableArray = LazyArray; /** @deprecated Renamed to `LazyApi`. Removed at 1.0. */ type LazyObservableApi = LazyApi; /** @deprecated Renamed to `LazyOptions`. Removed at 1.0. */ type LazyObservableOptions = LazyOptions; /** @deprecated Renamed to `LazyOptionsWithInitialValue`. Removed at 1.0. */ type LazyObservableOptionsWithInitialValue = LazyOptionsWithInitialValue; /** @deprecated Renamed to `LazyArrayOptions`. Removed at 1.0. */ type LazyObservableArrayOptions = LazyArrayOptions; /** @deprecated Renamed to `LoadedLazy`. Removed at 1.0. */ type LoadedLazyObservable = LoadedLazy; /** @deprecated Renamed to `LoadedLazyArray`. Removed at 1.0. */ type LoadedLazyObservableArray = LoadedLazyArray; /** @deprecated Renamed to `InferLazy`. Removed at 1.0. */ type InferLazyObservable = InferLazy; //#endregion export { InferLazy, InferLazyObservable, Lazy, LazyApi, LazyArray, LazyArrayApi, LazyArrayOptions, LazyFetch, LazyFetchOptions, LazyInvalidateOptions, LazyObservable, LazyObservableApi, LazyObservableArray, LazyObservableArrayOptions, LazyObservableOptions, LazyObservableOptionsWithInitialValue, LazyObserver, LazyObserverBaseProps, LazyObserverSingleProps, LazyObserverTupleProps, LazyOptions, LazyOptionsWithInitialValue, LazyPageRequest, LazyPageResult, LazyPages, LazyPagesApi, LazyPagesFetch, LazyPagesOptions, LoadedLazy, LoadedLazyArray, LoadedLazyObservable, LoadedLazyObservableArray, lazy, lazyArray, lazyObservable, lazyObservableArray, lazyPages, useLazy, useLazyArray, useLazyPages }; //# sourceMappingURL=lazy.d.mts.map