forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.ts
41 lines (35 loc) · 1002 Bytes
/
sync.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { LobeDBSchemaMap } from '@/database/core/db';
export type OnSyncEvent = (tableKey: keyof LobeDBSchemaMap) => void;
export type OnSyncStatusChange = (status: PeerSyncStatus) => void;
export type OnAwarenessChange = (state: SyncAwarenessState[]) => void;
// export type PeerSyncStatus = 'syncing' | 'synced' | 'ready' | 'unconnected';
export enum PeerSyncStatus {
Connecting = 'connecting',
Disabled = 'disabled',
Ready = 'ready',
Synced = 'synced',
Syncing = 'syncing',
Unconnected = 'unconnected',
}
export interface StartDataSyncParams {
channel: {
name: string;
password?: string;
};
onAwarenessChange: OnAwarenessChange;
onSyncEvent: OnSyncEvent;
onSyncStatusChange: OnSyncStatusChange;
signaling?: string;
user: SyncUserInfo;
}
export interface SyncUserInfo {
browser?: string;
id: string;
isMobile: boolean;
name?: string;
os?: string;
}
export interface SyncAwarenessState extends SyncUserInfo {
clientID: number;
current: boolean;
}