import { PresenceConfig, DocHandle, PeerStateView, PresenceState } from '@automerge/automerge-repo/slim'; export type UsePresenceConfig = PresenceConfig & { handle: DocHandle; }; export type UsePresenceResult = { /** * Presence view of our peers. */ peerStates: PeerStateView; /** * Our own presence state, as last set by `update` or the initial value. */ localState: State | undefined; /** * Update our presence state for the given channel and broadcast * it to our peers. * * @param channel * @param value */ update: (channel: Channel, value: State[Channel]) => void; /** * Resume presence broadcasting and listening to peer presence. * * Note that this only needs to be called after `stop` has been called: * usePresence starts running immediately. */ start: (config?: Partial>) => void; /** * Stop broadcasting presence state and listening to peer presence. */ stop: () => void; }; /** * This hook encapsulates ephemeral state communication for a specific doc * handle. It tracks caller-provided local state and broadcasts that state to * all peers. It sends periodic heartbeats when there are no state updates. * * It also tracks ephemeral state broadcast by peers and forces a re-render when * the state of a peer changes. * * It cleans up (stops sending heartbeats and processing ephemeral messages) * when it unmounts. * * It is implemented using {@link Presence}. * * @param config - see {@link UsePresenceConfig}. Note that initialState only * determines the initial value. Updates to this param will not trigger a * re-render of the hook. * * @returns see {@link UsePresenceResult} */ export declare function usePresence({ handle, initialState, heartbeatMs, peerTtlMs, }: UsePresenceConfig): UsePresenceResult; //# sourceMappingURL=usePresence.d.ts.map