import { type PresenceIdentity } from './presence.js'; /** The slice of y-protocols `Awareness` the publisher needs; the real class satisfies it. */ export interface AwarenessLike { clientID?: number; setLocalStateField: (field: string, value: unknown) => void; getStates: () => Map>; on: (event: string, cb: (...args: never[]) => void) => void; off?: (event: string, cb: (...args: never[]) => void) => void; } export interface PresencePublisher { /** Merge a partial state patch and publish (throttled; a no-op patch is dropped). */ update: (patch: Partial) => void; /** Re-publish immediately (heartbeat). Never dropped, or peers would time us out. */ flush: () => void; /** Cancel any pending throttled publish. */ dispose: () => void; } export interface PresencePublisherOptions { throttleMs?: number; now?: () => number; } /** * Throttled writer of the local `presence` awareness field: identity (fixed) merged with the * product payload `S` (cursor, selection, page...). Leading edge plus a trailing flush; patches that * change nothing never reach the wire (they would re-stamp `lastUpdated` and re-render every peer). * The initial presence is announced synchronously. */ export declare function createPresencePublisher(awareness: AwarenessLike, identity: PresenceIdentity, initial: S, options?: PresencePublisherOptions): PresencePublisher; /** The public y-protocols Awareness surface a borrowed session needs. */ export interface HostAwareness extends AwarenessLike { clientID: number; getLocalState: () => Record | null; setLocalState: (state: Record | null) => void; off: (event: string, cb: (...args: never[]) => void) => void; } /** Listener/publisher view of a host awareness, deliberately without lifecycle methods. */ export interface BorrowedAwareness extends AwarenessLike { clientID: number; off: (event: string, cb: (...args: never[]) => void) => void; } /** * Give a presence publisher a borrowed view of a host-owned awareness. Only the `presence` field * last written through the lease is restored on dispose; unrelated host fields and later host * presence writes are preserved, and a departed host is never brought back by viewer cleanup. */ export declare function borrowAwareness(host: HostAwareness): { awareness: BorrowedAwareness; dispose: () => void; }; /** Withdraw the local awareness state so peers drop us at once (call before destroying the provider). */ export declare function clearLocalAwareness(awareness: { setLocalState?: (state: null) => void; } | null | undefined): void; /** The slice of an `Awareness` needed to drop a departed peer locally. */ export interface AwarenessStatesLike { clientID?: number; states?: Map>; emit?: (name: string, args: unknown[]) => void; } /** * Drop `clients` from `awareness` locally and notify its observers, mirroring y-protocols' * `removeAwarenessStates` for remote clients. Returns the ids actually removed. */ export declare function removeAwarenessStatesLocally(awareness: AwarenessStatesLike | null | undefined, clients: readonly number[]): number[]; //# sourceMappingURL=awareness.d.ts.map