import { type PresenceOpts, type PresenceResponse, type RoomSchemaShape, InstantCoreDatabase, InstantSchemaDef } from '@instantdb/core'; export type PresenceHandle = PresenceResponse & { publishPresence: (data: Partial) => void; }; export type TypingIndicatorOpts = { timeout?: number | null; stopOnEnter?: boolean; writeOnly?: boolean; }; export type TypingIndicatorHandle = { active: PresenceShape[]; setActive(active: boolean): void; inputProps: { onKeyDown: (e: KeyboardEvent) => void; onBlur: () => void; }; }; export declare const defaultActivityStopTimeout = 1000; /** * Listen for broadcasted events given a room and topic. * * @see https://instantdb.com/docs/presence-and-topics * @example * const room = db.room('chats', roomId); * db.rooms.useTopicEffect(room, 'emoji', (message, peer) => { * console.log(peer.name, 'sent', message); * }); */ export declare function useTopicEffect(room: InstantSvelteRoom, topic: TopicType, onEvent: (event: RoomSchema[RoomType]['topics'][TopicType], peer: RoomSchema[RoomType]['presence']) => any): void; /** * Broadcast an event to a room. * * @see https://instantdb.com/docs/presence-and-topics * @example * const room = db.room('chat', roomId); * const publishTopic = db.rooms.usePublishTopic(room, 'emoji'); * publishTopic({ emoji: "🔥" }); */ export declare function usePublishTopic(room: InstantSvelteRoom, topic: TopicType): (data: RoomSchema[RoomType]['topics'][TopicType]) => void; /** * Listen for peer's presence data in a room, and publish the current user's presence. * * @see https://instantdb.com/docs/presence-and-topics * @example * const room = db.room('chat', roomId); * const presence = db.rooms.usePresence(room, { keys: ["name", "avatar"] }); * // presence.peers, presence.isLoading, presence.publishPresence */ export declare function usePresence(room: InstantSvelteRoom, opts?: PresenceOpts): PresenceHandle; /** * Publishes presence data to a room * * @see https://instantdb.com/docs/presence-and-topics * @example * const room = db.room('chat', roomId); * db.rooms.useSyncPresence(room, { nickname }); */ export declare function useSyncPresence(room: InstantSvelteRoom, data: Partial, deps?: any[]): void; /** * Manage typing indicator state * * @see https://instantdb.com/docs/presence-and-topics * @example * const room = db.room('chat', roomId); * const typing = db.rooms.useTypingIndicator(room, 'chat-input'); * // typing.active, typing.setActive(bool), typing.inputProps */ export declare function useTypingIndicator(room: InstantSvelteRoom, inputName: string, opts?: TypingIndicatorOpts): TypingIndicatorHandle; export declare const rooms: { useTopicEffect: typeof useTopicEffect; usePublishTopic: typeof usePublishTopic; usePresence: typeof usePresence; useSyncPresence: typeof useSyncPresence; useTypingIndicator: typeof useTypingIndicator; }; export declare class InstantSvelteRoom, RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema> { core: InstantCoreDatabase; type: RoomType; id: string; constructor(core: InstantCoreDatabase, type: RoomType, id: string); } //# sourceMappingURL=InstantSvelteRoom.svelte.d.ts.map