import { Awareness } from 'y-protocols/awareness'; declare type ClientId = Awareness['clientID']; interface DefaultClientData { } declare type EventHandler = (...args: any[]) => void; declare type DefaultEvents = { [eventName: string]: EventHandler; }; declare type EventNameWithScope = `${Scope}:${Type}`; declare type DataScope = 'data'; declare type RoomScope = 'room'; declare type YDocScope = 'doc'; declare type AwarenessScope = 'awareness'; declare type ObservableScope = YDocScope | AwarenessScope; declare type ObservableEventName = EventNameWithScope; declare type ValidEventScope = DataScope | RoomScope | ObservableScope; declare type ValidateEvents ? EventScope extends ValidEventScope ? Events[EventName] : never : Events[EventName]; }> = Events; declare type DefaultServerToClientEvents = ValidateEvents<{ ['data:update']: (data: ClientData) => void; ['doc:diff']: (diff: ArrayBuffer) => void; ['doc:update']: (updateV2: ArrayBuffer) => void; ['awareness:update']: (update: ArrayBuffer) => void; }>; interface ServerToClientEvents extends DefaultServerToClientEvents { } declare type DefaultClientToServerEvents = ValidateEvents<{ ['room:close']: () => void; ['doc:diff']: (diff: Uint8Array) => void; ['doc:update']: (updateV2: Uint8Array, callback?: () => void) => void; ['awareness:update']: (update: Uint8Array) => void; }>; interface ClientToServerEvents extends DefaultClientToServerEvents { } declare type ClientToServerEventNames = keyof ClientToServerEvents; declare type BroadcastChannelMessageData = (EventName extends ObservableEventName ? [eventName: EventName, payload: Uint8Array, clientId?: ClientId] : never) | [eventName: `${AwarenessScope}:query`, clientId: ClientId]; declare type BroadcastChannelMessageEvent = MessageEvent; export { BroadcastChannelMessageData, BroadcastChannelMessageEvent, ClientToServerEvents, DefaultClientToServerEvents, DefaultEvents, DefaultServerToClientEvents, ServerToClientEvents };