import type { Router } from 'vue-router'; import type Cwa from '#cwa/cwa'; import type { CwaResourcesStoreInterface } from '#cwa/storage/stores/resources/resources-store'; export type PresenceActivity = 'viewing' | 'selected' | 'editing' | 'idle' | 'left'; export interface PresenceData { v: 1; page: string; state: PresenceActivity; component?: string; componentPosition?: string; pageData?: string; field?: string; device?: string; hello?: true; } export interface PresenceUser { id: string; name?: string; } export interface PresencePeer { clientId: string; user: PresenceUser; state: PresenceActivity; page: string; component?: string; componentPosition?: string; pageData?: string; field?: string; isSelf: boolean; device?: string; receivedAt: number; ttlMs: number; } export interface RealtimePeer { clientId: string; user: PresenceUser; name: string; state: PresenceActivity; field?: string; expiresAt: number; colour: string; isSelf: boolean; idle: boolean; device?: string; } export interface FocusedPeer { user: PresenceUser; name: string; colour: string; isSelf: boolean; clientIds: string[]; } export interface RealtimeMessage { clientId: string; user: PresenceUser; name: string; isSelf: boolean; colour: string; event: string; data: Data; sentAt?: string; } export type RealtimeEventHandler = (message: RealtimeMessage) => void; export interface RealtimeEvent { '@type'?: string; 'v'?: number; 'clientId'?: string; 'user'?: PresenceUser; 'event'?: string; 'iri'?: string | null; 'data'?: Partial | null; 'sentAt'?: string; 'expiresAt'?: string; } export declare const SELF_COLOUR = "#a8a29e"; export declare function presenceColour(userId: string): string; export declare function peerColour(peer: { user: PresenceUser; isSelf: boolean; }): string; export declare function peerName(name: string | undefined, isSelf: boolean): string; export declare function deviceLabel(userAgent: string): string | undefined; export declare function usePresence($cwa: Cwa): { active: import("vue").ComputedRef; paused: import("vue").ComputedRef; onThisPage: import("vue").ComputedRef; elsewhere: import("vue").ComputedRef; nameOf: (userId: string) => string | undefined; peers: (iri: string) => RealtimePeer[]; focusedBy: (iri: string, field: string) => FocusedPeer[]; focus: (owner: symbol, iri: string, field: string) => void; blur: (owner: symbol) => void; send: (iri: string, event: string, data: unknown) => boolean; on: (iri: () => string | undefined, event: string, handler: RealtimeEventHandler) => () => void; }; export declare class Presence { private readonly $cwa; private readonly store; private readonly router; private readonly clientId; private readonly state; private readonly warned; private readonly outbox; private readonly device; private lastActivity; private running; private disabled; private dirty; private inFlight; private hello; private repeat; private lastKey; private lastSent; private lastPresence; private blockedUntil; private failures; private sendTimer?; private helloTimer?; private heartbeat?; private pruner?; private unwatch?; private readonly onPageHide; private readonly onPageShow; private readonly onVisibilityChange; private readonly onActivity; constructor($cwa: Cwa, store: CwaResourcesStoreInterface, router: Router, clientId: string); start(connected: boolean): void; stop(): void; paused(): void; resumed(): void; emit(iri: string, event: string, data: unknown): boolean; receive(event: RealtimeEvent): void; private page; private current; private idled; private setIdle; private beat; private announce; private schedule; private send; private presenceRequest; private eventRequest; private dispatch; private failed; private warnOnce; private prune; private schedulePrune; private sendLeft; }