/** * Recent-edit attribution for collaborative documents. * * Every participant (human or agent) may publish a short ring of recent edits * in its awareness state under the `recentEdits` key. Clients render these as * lingering, fading highlights ("Google Docs / Figma collaborator just edited * this") for a few seconds after the edit lands, with the editor's name and * color next to the highlighted region. * * The descriptor is intentionally open-ended — each app publishes whatever its * surfaces can resolve back to a DOM rect: * - `{ kind: "text", quote }` rich-text apps resolve by text search * - `{ kind: "selector", selector }` canvas/DOM apps resolve by querySelector * - `{ kind: "paths", paths }` structured apps resolve JSON paths * (e.g. `slides.3.content`) to their rendered element * - `{ kind: "doc" }` whole-document change (no region) */ import { type AttributedRecentEdit, type RecentEdit } from "@agent-native/toolkit/collab-ui"; import type { OtherPresence } from "./presence.js"; export { RECENT_EDITS_MAX, RECENT_EDIT_TTL_MS, type AttributedRecentEdit, type RecentEdit, type RecentEditDescriptor, } from "@agent-native/toolkit/collab-ui"; /** * Append an edit to a recentEdits ring, keeping the newest * {@link RECENT_EDITS_MAX} entries. Pure — returns a new array. Descriptor * strings and the label are truncated to {@link RECENT_EDIT_STRING_MAX} * characters as a defensive cap on the awareness payload size. */ export declare function appendRecentEdit(existing: RecentEdit[] | undefined, edit: RecentEdit): RecentEdit[]; /** * Flatten non-expired recent edits from remote participants, newest last. * Pure — exported for tests and non-React consumers. */ export declare function collectRecentEdits(others: OtherPresence[], ttlMs: number, now: number): AttributedRecentEdit[]; export interface UseRecentEditsOptions { /** How long a highlight lingers after the edit. Default 6000ms. */ ttlMs?: number; } /** * Reactive list of remote participants' recent edits that haven't expired. * Ticks internally (~500ms) while any highlight is visible so consumers can * render a smooth fade-out without wiring their own timers. */ export declare function useRecentEdits(others: OtherPresence[], options?: UseRecentEditsOptions): AttributedRecentEdit[]; /** * Publish a local edit into this client's awareness ring so peers render a * lingering highlight for it. Call from app mutation paths (throttled by the * ring size + TTL; safe to call per committed edit, not per keystroke). */ export declare function publishRecentEdit(awareness: { getLocalState: () => Record | null; setLocalStateField: (field: string, value: unknown) => void; }, edit: Omit & { at?: number; }): void; //# sourceMappingURL=recent-edits.d.ts.map