import { Awareness } from 'y-protocols/awareness'; import * as Y from 'yjs'; import { type CollaborationRole } from './identity.js'; import { type TeardownOptions } from './lifecycle.js'; import { type SyncGate } from './policy.js'; import { type PresenceIdentity, type RemotePresence } from './presence.js'; import { type ConnectionStatus, type ProviderFactory, type SyncProvider } from './provider.js'; export interface SessionOptions

{ roomId: string; provider: ProviderFactory; user: { name: string; /** Defaults to a stable palette colour derived from the client id. */ color?: string; avatar?: string; role?: CollaborationRole; }; /** Bring your own document (for example one a viewer already populated). */ doc?: Y.Doc; /** The local "where am I" payload published with the identity. */ initialPresence?: P; /** Validate a remote payload; return `null` to hide that peer. Defaults to accepting `{}`. */ sanitizePayload?: (raw: Record) => P | null; /** Start connecting immediately. Default true. */ autoConnect?: boolean; connectionTimeoutMs?: number; /** Fallback gate opening for transports that never signal sync (mesh). Default 3 s. */ syncGraceMs?: number; /** Called once when local writes become allowed; seed the document here. */ onReady?: (state: { synced: boolean; }) => void; /** Register pagehide/beforeunload leave handling and the same-browser departure channel. */ teardown?: boolean | Pick; /** Heartbeat (ms) that republishes presence and ages out stale peers. Default 10 s; 0 disables. */ heartbeatMs?: number; } export interface SessionEvents

{ status: ConnectionStatus; synced: boolean; /** The remote presence list changed (join, leave, move, staleness). */ peers: RemotePresence

[]; /** Local writes just became allowed (once per connection epoch). */ ready: undefined; error: Error; } export interface CollabSession

{ readonly roomId: string; readonly doc: Y.Doc; readonly awareness: Awareness; readonly clientId: number; readonly role: CollaborationRole | undefined; readonly identity: PresenceIdentity; readonly gate: SyncGate; readonly provider: SyncProvider; readonly status: ConnectionStatus; readonly synced: boolean; /** Writes are allowed: the gate opened (synced, or the grace period passed), not a viewer, not destroyed. */ canWrite: () => boolean; peers: () => RemotePresence

[]; /** Merge a patch into the published local presence payload (throttled). */ updatePresence: (patch: Partial

) => void; on: >(event: K, listener: (payload: SessionEvents

[K]) => void) => () => void; connect: () => void; disconnect: () => void; /** Leave the room and release everything; a session created with `doc` leaves that doc alive. */ destroy: () => void; } export declare function createCollabSession

(options: SessionOptions

): CollabSession

; //# sourceMappingURL=session.d.ts.map