import * as _sanity_client4 from "@sanity/client"; import { ClientPerspective, ContentSourceMap, ContentSourceMap as ContentSourceMap$1, QueryParams, ResponseQueryOptions } from "@sanity/client"; import * as _sanity_client_stega0 from "@sanity/client/stega"; import * as _sanity_core_loader1 from "@sanity/core-loader"; import { CreateQueryStoreOptions, EnableLiveModeOptions, QueryStoreState, createQueryStore as createQueryStore$1 } from "@sanity/core-loader"; import { ResolveStudioUrl, ResolveStudioUrl as ResolveStudioUrl$1, StudioPathLike, StudioPathLike as StudioPathLike$1, StudioUrl, StudioUrl as StudioUrl$1 } from "@sanity/client/csm"; export * from "@sanity/core-loader"; /** * @public */ type EncodeDataAttributeFunction = { (path: StudioPathLike$1): string | undefined; scope: (path: StudioPathLike$1) => EncodeDataAttributeFunction; }; /** * @public */ type WithEncodeDataAttribute = { encodeDataAttribute: EncodeDataAttributeFunction; }; type UseQueryHook = (query: string, params?: QueryParams, options?: UseQueryOptions) => QueryStoreState & WithEncodeDataAttribute; interface QueryResponseInitial { data: QueryResponseResult; sourceMap: ContentSourceMap$1 | undefined; /** * The perspective used to fetch the data, if not provided it'll assume 'published' */ perspective?: ClientPerspective; } interface UseQueryOptions { /** * Initial `data` and `sourceMap`, used with SSR hydration and is required if `ssr: true` * and an optional speed optimization if `ssr: false`. * It's recommended to set `initial` to the return value of `loadQuery()`. * @example * ```ts * const query = `*[_type == "author" && slug.current == $slug][0]` * export const getServerSideProps = async ({params}) => { * const initial = await loadQuery(query, params) * return { props: { params, initial } } * } * export default function Page({params, initial}) { * const {data} = useQuery(query, params, {initial}) * } * ``` */ initial?: QueryResponseInitial; } interface UseQueryOptionsUndefinedInitial { /** * Initial `data` and `sourceMap`, used with SSR hydration and is required if `ssr: true` * and an optional speed optimization if `ssr: false`. * It's recommended to set `initial` to the return value of `loadQuery()`. * @example * ```ts * const query = `*[_type == "author" && slug.current == $slug][0]` * export const getServerSideProps = async ({params}) => { * const initial = await loadQuery(query, params) * return { props: { params, initial } } * } * export default function Page({params, initial}) { * const {data} = useQuery(query, params, {initial}) * } * ``` */ initial?: undefined; } type NonUndefinedGuard = T extends undefined ? never : T; interface UseQueryOptionsDefinedInitial { /** * Initial `data` and `sourceMap`, used with SSR hydration and is required if `ssr: true` * and an optional speed optimization if `ssr: false`. * It's recommended to set `initial` to the return value of `loadQuery()`. * @example * ```ts * const query = `*[_type == "author" && slug.current == $slug][0]` * export const getServerSideProps = async ({params}) => { * const initial = await loadQuery(query, params) * return { props: { params, initial } } * } * export default function Page({params, initial}) { * const {data} = useQuery(query, params, {initial}) * } * ``` */ initial: NonUndefinedGuard>; } type UseLiveModeHook = (options: EnableLiveModeOptions & { /** * Set this option to activate `encodeDataAttribute` on `useQuery` hooks when stega isn't used. */ studioUrl?: StudioUrl$1 | ResolveStudioUrl$1 | undefined; }) => void; interface QueryStore { loadQuery: (query: string, params?: QueryParams, options?: Pick) => Promise>; setServerClient: ReturnType['setServerClient']; useQuery: { (query: string, params?: QueryParams, options?: UseQueryOptionsUndefinedInitial): QueryStoreState & WithEncodeDataAttribute; (query: string, params?: QueryParams, options?: UseQueryOptionsDefinedInitial): Omit, 'data'> & { data: QueryResponseResult; } & WithEncodeDataAttribute; }; useLiveMode: UseLiveModeHook; } declare namespace client_only_d_exports { export { NonUndefinedGuard, QueryResponseInitial, QueryStore, UseLiveModeHook, UseQueryHook, UseQueryOptions, UseQueryOptionsDefinedInitial, UseQueryOptionsUndefinedInitial, createQueryStore, loadQuery, setServerClient, useLiveMode, useQuery }; } declare const createQueryStore: (options: CreateQueryStoreOptions) => QueryStore; /** * Shortcut setup for the main SSR use-case. * @public */ declare const loadQuery: (query: string, params?: _sanity_client4.QueryParams, options?: Pick<_sanity_client4.ResponseQueryOptions, "perspective" | "cache" | "next" | "useCdn" | "stega" | "tag" | "headers">) => Promise>, setServerClient: (client: _sanity_client4.SanityClient | _sanity_client_stega0.SanityStegaClient) => void, useLiveMode: UseLiveModeHook, useQuery: { (query: string, params?: _sanity_client4.QueryParams, options?: UseQueryOptionsUndefinedInitial): _sanity_core_loader1.QueryStoreState & { encodeDataAttribute: EncodeDataAttributeFunction; }; (query: string, params?: _sanity_client4.QueryParams, options?: UseQueryOptionsDefinedInitial): Omit<_sanity_core_loader1.QueryStoreState, "data"> & { data: QueryResponseResult; } & { encodeDataAttribute: EncodeDataAttributeFunction; }; }; /** @public */ type EncodeDataAttributeCallback = (path: StudioPathLike) => string | undefined; /** @public */ declare function useEncodeDataAttribute(result: QueryResponseResult, sourceMap: ContentSourceMap | undefined, studioUrl: StudioUrl | ResolveStudioUrl | undefined): EncodeDataAttributeFunction; declare namespace index_browser_d_exports { export { ContentSourceMap, EncodeDataAttributeCallback, NonUndefinedGuard, QueryResponseInitial, QueryStore, ResolveStudioUrl, StudioPathLike, StudioUrl, UseLiveModeHook, UseQueryHook, UseQueryOptions, UseQueryOptionsDefinedInitial, UseQueryOptionsUndefinedInitial, createQueryStore, loadQuery, setServerClient, useEncodeDataAttribute, useLiveMode, useQuery }; } export { type ContentSourceMap, EncodeDataAttributeCallback, type NonUndefinedGuard, type QueryResponseInitial, type QueryStore, type ResolveStudioUrl, type StudioPathLike, type StudioUrl, type UseLiveModeHook, UseQueryHook, UseQueryOptions, type UseQueryOptionsDefinedInitial, type UseQueryOptionsUndefinedInitial, createQueryStore, loadQuery, setServerClient, useEncodeDataAttribute, useLiveMode, useQuery }; //# sourceMappingURL=index.browser.d.ts.map