import { WidgetType } from '@codemirror/view'; export interface PresenceUser { name?: string; color?: string; } export interface CursorRenderOpts { /** Milliseconds after which the name label is faded (default 3000). */ fadeAfterMs?: number; /** Milliseconds of inactivity after which the caret is dimmed (default 30000). */ dimAfterMs?: number; /** Milliseconds of inactivity after which the selection highlight is hidden * and the caret is dimmed (default 60000). */ hideAfterMs?: number; } /** Factory that produces a cursor DOM element for a given peer. */ export type CursorRenderer = (peerId: string, user: PresenceUser | undefined, opts: CursorRenderOpts) => HTMLElement; /** Factory that returns inline decoration attributes for a selection range. */ export type SelectionRenderer = (peerId: string, user?: PresenceUser) => { style: string; }; /** Which horizontal edge the label is anchored to. */ export type LabelSide = 'left' | 'center' | 'right'; /** Adjust the label's CSS inline styles so it stays inside the viewport. */ export declare const positionLabel: (label: HTMLElement, isFirstLine: boolean, side: LabelSide) => void; /** * Default cursor renderer — a colored caret line with a floating name label. * All lifecycle stages (blink, label fade, dim, disappear) are driven by CSS * animations so no JS timers are needed. The element is designed to be cached * and reused by {@link CursorManager} across decoration rebuilds. */ export declare const renderCursor: CursorRenderer; /** * CodeMirror 6 `WidgetType` wrapper that holds a single cached `` DOM * element. The same element is returned from every `toDOM()` call for the same * peer so that CSS lifecycle animations survive decoration rebuilds. */ export declare class CursorWidget extends WidgetType { readonly el: HTMLElement; constructor(el: HTMLElement); /** True when both widgets wrap the *same* cached DOM node — CM6 will not * call `toDOM()` again and will reuse the existing DOM for widget updates. */ eq(other: CursorWidget): boolean; toDOM(): HTMLElement; /** Prevent CM6 from removing the element from the document on destruction — * {@link CursorManager} owns the element lifetime. */ destroy(): void; ignoreEvent(): boolean; } /** * Manages cached cursor DOM elements keyed by remote peer id. * * By caching elements we ensure: * * 1. CSS animations survive CodeMirror decoration rebuilds (the same * `HTMLElement` is returned from `toDOM()`). * 2. When a remote cursor moves, the lifecycle animation is restarted so the * cursor re-appears at full opacity and the label is re-shown. * 3. No JS timers need to be managed — everything is CSS-driven. */ export declare class CursorManager { private cache; getOrCreate(processId: string, pos: number, isFirstLine: boolean, side: LabelSide, user: PresenceUser | undefined, opts: CursorRenderOpts, receivedAt: number, renderFn: CursorRenderer): HTMLElement; prune(activeIds: Set): void; destroy(): void; /** Restart all CSS animations on a cached cursor so it re-appears at full * opacity with the label visible — called when the remote cursor moves. */ private resetLifecycle; } /** Default selection renderer — returns an inline CSS style string for a * semi-transparent background. Used with `Decoration.mark({attributes: ...})`. */ export declare const renderSelection: SelectionRenderer; //# sourceMappingURL=view.d.ts.map