import * as Party from 'partykit/server'; import * as awarenessProtocol from 'y-protocols/awareness'; import { Doc } from 'yjs'; import { YPartyKitStorage } from './storage.js'; declare class WSSharedDoc extends Doc { name: string; conns: Map>; awareness: awarenessProtocol.Awareness; storage: YPartyKitStorage | undefined; persist: YPartyKitPersistenceStrategy | undefined; persistMaxBytes: number; persistMaxUpdates: number; gc: boolean; constructor(room: Party.Room, options: YPartyKitOptions); bindState(): Promise; /** * Appends the entire document state as an update to the update log. */ writeState(): Promise; /** * Replaces the current update log with the current state of the document. */ compactUpdateLog(): Promise; } /** * Gets a Y.Doc by name, whether in memory or on disk */ declare function getYDoc(room: Party.Room, options: YPartyKitOptions): Promise; interface CallbackOptions { debounceWait?: number; debounceMaxWait?: number; timeout?: number; objects?: Record; } interface HandlerCallbackOptions extends CallbackOptions { handler: (doc: Doc) => void | Promise; url?: never; } interface UrlCallbackOptions extends CallbackOptions { handler?: never; url: string; headers?: Headers; } type YPartyKitCallbackOptions = HandlerCallbackOptions | UrlCallbackOptions; type YPartyKitPersistenceStrategy = { /** Persist document edit history */ mode: "history"; /** * Maximum number of updates to persist before compressing. * If value is not set, the update history length is capped by `maxBytes`. **/ maxUpdates?: number; /** * Maximum total update size to persist before compressing. * The default value, and the largest allowed value is 10MB (10_000_000 bytes). **/ maxBytes?: number; } | { /** * Persist document snapshot. * Keeps full document history as long as there are connected clients, * and compresses changes to a snapshot when last client disconnects. **/ mode: "snapshot"; }; type YPartyKitOptions = { /** * disable gc when using persist! * */ gc?: boolean; /** * Whether to persist the document to PartyKit room storage. * * - {mode: "snapshot"} — persist full document snapshot (recommended) * - {mode: "history", maxUpdates, maxBytes } — persist document edit history * - true — Equivalent to { mode: "history" } (deprecated, use { mode: "history "} instead) * - false — Do not persist document or history (default value) * * See https://docs.partykit.io/reference/y-partykit-api/#persistence */ persist?: YPartyKitPersistenceStrategy | boolean; callback?: YPartyKitCallbackOptions; load?: () => Promise; readOnly?: boolean; }; /** * Gets or loads the Y.Doc for given room. * @NOTE The options provided must match the options provided to `onConnect`. Once the document is loaded, changes to `options` are ignored. */ declare const unstable_getYDoc: typeof getYDoc; declare function onConnect(conn: Party.Connection, room: Party.Room, opts?: YPartyKitOptions): Promise; export { type YPartyKitOptions, type YPartyKitPersistenceStrategy, onConnect, unstable_getYDoc };