Review collaborative cursor presence

src/presence-types.tsTypeScript
@@ -0,0 +1,36 @@
1+export interface CursorCoordinate {
2+ x: number;
3+ y: number;
4+}
5+
6+export interface PresenceMessage extends CursorCoordinate {
7+ documentId: string;
8+ participantId: string;
9+ connectionGeneration: number;
10+ sequence: number;
11+ sentAt: number;
12+}
13+
14+export interface PresenceConnection {
15+ generation: number;
16+ send(message: PresenceMessage): void;
17+ onOpen(listener: () => void): void;
18+ close(): void;
19+}
20+
21+export interface PresenceTransport {
22+ connect(
23+ documentId: string,
24+ onMessage: (message: PresenceMessage) => void,
25+ ): PresenceConnection;
26+}
27+
28+export interface MonotonicClock {
29+ now(): number;
30+}
31+
32+export interface VisibleParticipant extends CursorCoordinate {
33+ participantId: string;
34+ sequence: number;
35+ receivedAt: number;
36+}