import React from 'react'; export interface IGunChainReference { get(key: string): IGunChainReference; put(data: T, callback?: (ack: { err?: string; ok?: any; }) => void): IGunChainReference; on(callback: (data: T, key: string, message?: any, event?: any) => void): () => void; once(callback: (data: T, key: string) => void): void; set(data: T, callback?: (ack: { err?: string; ok?: any; }) => void): IGunChainReference; map(): IGunChainReference; open?(callback: (data: T, key: string, message?: any, event?: any) => void): void; user(soul?: string): IGunUserReference; off(): void; toString(): string; } export interface IGunUserReference extends IGunChainReference { is: KeyPair | null; auth(keypair: KeyPair, callback?: (ack: any) => void): void; create(keypair: KeyPair, callback?: (ack: any) => void): void; leave(): void; } export interface GunError { err: string; code?: string | number; context?: string; } export type ValidGunData = string | number | boolean | object | null; export type GunStatic = any; export type GunRef = IGunChainReference | null; export type NamespacedRef = IGunUserReference; export type KeyPair = { pub: string; priv: string; epub: string; epriv: string; }; export type Storage = { getItem: (key: string) => any; setItem: (key: string, data: string) => any; removeItem: (key: string) => any; }; export type AuthContextType = { gun: IGunChainReference; user: IGunUserReference; login: (keys?: undefined | string | KeyPair) => void; logout: (onLoggedOut?: () => void) => void; sea: any; appKeys: undefined | string | KeyPair; isLoggedIn: boolean; newGunInstance: (opts?: GunOptions) => IGunChainReference; }; export type AuthProviderOpts = { Gun: any; sea: any; keyFieldName?: string; storage: Storage; gunOpts: GunOptions; children: React.ReactNode; }; export type Options = { appKeys?: undefined | string | KeyPair; sea?: any; interval?: number; useOpen?: boolean; }; export type NodeData = T & { readonly nodeID: string; readonly _?: { '#': string; '>': Record; }; }; export type NodeT = T & { nodeID: string; [key: string]: any; }; export type ActionType = { type: 'add'; data: NodeT | NodeT[]; } | { type: 'update'; data: NodeT; } | { type: 'remove'; data: { nodeID: string; }; }; export type UpdateType = { id: string; data: any; }; export interface GunOptions extends Partial<{ file: string; web: any; s3: { key: any; secret: any; bucket: any; }; peers: string[] | Record; radisk: boolean; localStorage: boolean; uuid(): string; [key: string]: any; }> { } export interface CollectionState { collection: Map; sorted?: T[]; infiniteScrolling?: { isFetching: boolean; lastFetched: string; reverse: boolean; }; } export interface UseGunStateReturn { fields: T; put: (data: Partial) => Promise; remove: (field: string) => Promise; error: GunError | null; isLoading: boolean; isConnected: boolean; } export interface UseGunCollectionReturn { collection: Map>; items: NodeT[]; addToSet: (data: T, nodeID?: string) => Promise; updateInSet: (nodeID: string, data: Partial) => Promise; removeFromSet: (nodeID: string) => Promise; error: GunError | null; isLoading: boolean; count: number; } export interface PaginationOptions extends Options { pageSize?: number; currentPage?: number; sortBy?: keyof T | ((a: NodeT, b: NodeT) => number); sortOrder?: 'asc' | 'desc'; filter?: (item: NodeT) => boolean; preloadPages?: number; } export interface UsePaginatedCollectionReturn extends UseGunCollectionReturn { currentPage: number; totalPages: number; hasNextPage: boolean; hasPrevPage: boolean; pageSize: number; nextPage: () => void; prevPage: () => void; goToPage: (page: number) => void; setPageSize: (size: number) => void; currentPageItems: NodeT[]; currentPageCount: number; isLoadingPage: boolean; preloadedPages: Set; } export declare const encryptData: (data: any, keys: undefined | string | KeyPair, sea: any) => Promise; export declare const decryptData: (data: any, keys: undefined | string | KeyPair, sea: any) => Promise; export declare const debouncedUpdates: (dispatcher: any, type?: string, timeout?: number) => { (update: UpdateType): () => void; cleanup(): void; }; export declare const useIsMounted: () => any; export declare const nodeReducer: (state: NodeT, { data, type }: ActionType) => T; export declare const collectionReducer: (state: CollectionState, { data, type }: ActionType) => CollectionState; export declare const useSafeReducer: (reducer: any, initialState: T) => [T, Function]; export declare const useGun: (Gun: GunStatic, opts: GunOptions) => any; export declare const useGunNamespace: (gun: GunRef, soul?: string) => any; export declare const useGunKeyAuth: (gun: GunRef, keys: KeyPair, triggerAuth?: boolean) => readonly [any, any, any]; export declare const useGunKeys: (sea: any, existingKeys?: KeyPair | undefined | null) => any; export declare const useGunOnNodeUpdated: (ref: GunRef, opts: Options | undefined, cb: (data: T, nodeID: string) => void, cleanup?: () => void) => void; export declare const useGunState: (ref: GunRef, opts?: Options) => UseGunStateReturn; export declare const useGunCollectionState: >(ref: GunRef, opts?: Options) => UseGunCollectionReturn; export declare const useGunCollectionStatePaginated: >(ref: GunRef, paginationOpts?: PaginationOptions) => UsePaginatedCollectionReturn; export declare const AuthContext: any; export declare const AuthProvider: React.FC; export declare const useAuth: () => AuthContextType; export declare const GunContext: any; export declare const GunProvider: React.FC<{ gun: GunStatic; options: GunOptions; children: React.ReactNode; }>; export declare const useGunContext: () => IGunChainReference; export declare const useGunDebug: (ref: IGunChainReference | null, label: string, enabled?: boolean) => void; export declare const useGunConnection: (ref: IGunChainReference) => { isConnected: boolean; lastSeen: Date | null; error: GunError | null; };