UNPKG

use-bluesky

Version:

React hooks to interact with the Bluesky API

109 lines (95 loc) 4.2 kB
import * as react from 'react'; import { PropsWithChildren } from 'react'; import { Agent } from '@atproto/api'; import { NodeOAuthClient } from '@atproto/oauth-client-node'; import * as react_jsx_runtime from 'react/jsx-runtime'; import * as _tanstack_react_query from '@tanstack/react-query'; import { QueryClient } from '@tanstack/react-query'; import * as _tanstack_query_core from '@tanstack/query-core'; type BlueskyContextValue = { agent?: Agent; client?: NodeOAuthClient; baseUrl: string; session?: any; token?: string; }; declare const BlueskyContext: react.Context<BlueskyContextValue>; type BlueskyProviderProps = PropsWithChildren & { baseUrl?: string; queryClient?: QueryClient; session?: any; token?: string; }; declare const BlueskyProvider: ({ children, baseUrl, queryClient: queryClientProp, session, token, }: BlueskyProviderProps) => react_jsx_runtime.JSX.Element; type UseStarterPacksOptions = { actor?: string; cursor?: string; enabled?: boolean; initialData?: any; limit?: number; refetchOnMount?: boolean; }; declare const useActorStarterPacks: (options: UseStarterPacksOptions) => _tanstack_react_query.UseInfiniteQueryResult<_tanstack_query_core.InfiniteData<any, unknown>, Error>; declare const useBluesky: () => BlueskyContextValue; type UseFollowProps = { did: string; onSuccess: () => void; followUri: string; }; declare const useFollow: ({ did, onSuccess, followUri }: UseFollowProps) => { follow: () => void; isPending: boolean; unfollow: () => void; }; type UseFollowersProps = { actor?: string; cursor?: string; initialData?: any; limit?: number; refetchOnMount?: boolean; }; declare const useFollowers: (options: UseFollowersProps) => _tanstack_react_query.DefinedUseInfiniteQueryResult<_tanstack_query_core.InfiniteData<any, unknown>, Error>; type UseFollowsProps = { actor?: string; cursor?: string; initialData?: any; limit?: number; refetchOnMount?: boolean; }; declare const useFollows: (options: UseFollowsProps) => _tanstack_react_query.DefinedUseInfiniteQueryResult<_tanstack_query_core.InfiniteData<any, unknown>, Error>; type UseListOptions = { initialData?: any; initialPageParam?: string; list?: string; limit?: number; refetchOnMount?: boolean; }; declare const useList: (options: UseListOptions) => _tanstack_react_query.DefinedUseInfiniteQueryResult<_tanstack_query_core.InfiniteData<any, unknown>, Error>; type UseProfileProps = { actor?: string; enabled?: boolean; }; declare const useProfile: ({ actor, enabled }: UseProfileProps) => _tanstack_react_query.UseQueryResult<any, Error>; type UseSearchActorProps = { cursor?: string; limit: number; search: string; }; declare const useSearchActors: ({ cursor, limit, search, }: UseSearchActorProps) => _tanstack_react_query.UseQueryResult<any, Error>; declare const useStarterPack: ({ enabled, uri, }: { enabled?: boolean; uri: string; }) => _tanstack_react_query.UseQueryResult<any, Error>; declare const BLUESKY_API_URL = "https://public.api.bsky.app"; declare const ACTOR_STARTER_PACKS_ROUTE = "/xrpc/app.bsky.graph.getActorStarterPacks"; declare const PROFILE_ROUTE = "/xrpc/app.bsky.actor.getProfile"; declare const FOLLOWERS_ROUTE = "/xrpc/app.bsky.graph.getFollowers"; declare const FOLLOWS_ROUTE = "/xrpc/app.bsky.graph.getFollows"; declare const LIST_ROUTE = "/xrpc/app.bsky.graph.getList"; declare const RESOLVE_HANDLE_ROUTE = "/xrpc/com.atproto.identity.resolveHandle"; declare const STARTER_PACK_ROUTE = "/xrpc/app.bsky.graph.getStarterPack"; declare const SEARCH_ACTORS_ROUTE = "/xrpc/app.bsky.actor.searchActors"; declare const FOLLOW_ROUTE = "/follow"; declare const UNFOLLOW_ROUTE = "/unfollow"; export { ACTOR_STARTER_PACKS_ROUTE, BLUESKY_API_URL, BlueskyContext, BlueskyProvider, FOLLOWERS_ROUTE, FOLLOWS_ROUTE, FOLLOW_ROUTE, LIST_ROUTE, PROFILE_ROUTE, RESOLVE_HANDLE_ROUTE, SEARCH_ACTORS_ROUTE, STARTER_PACK_ROUTE, UNFOLLOW_ROUTE, useActorStarterPacks, useBluesky, useFollow, useFollowers, useFollows, useList, useProfile, useSearchActors, useStarterPack }; export type { BlueskyContextValue };