import { type AwarenessStatesLike } from './awareness.js'; /** `postMessage` payload an embedding page can send into a frame to make it leave its room first. */ export declare const COLLAB_LEAVE_MESSAGE = "ooxml-core:collab-leave"; /** BroadcastChannel shared by every session in the browser. */ export declare const DEPARTURE_CHANNEL = "ooxml-core:collab-departures"; /** Names used by pptx-viewer before the extraction; pass them to stay wire-compatible. */ export declare const LEGACY_PPTX_LEAVE_MESSAGE = "pptx-viewer:collab-leave"; export declare const LEGACY_PPTX_DEPARTURE_CHANNEL = "pptx-viewer:collab-departures"; export interface TeardownEventLike { readonly persisted?: boolean; readonly data?: unknown; } export type TeardownListener = (event: TeardownEventLike) => void; export interface TeardownWindowLike { addEventListener: (type: string, listener: TeardownListener) => void; removeEventListener: (type: string, listener: TeardownListener) => void; } export interface TeardownOptions { /** Clear local awareness and destroy the transport. Called at most once per departure. */ leave: () => void; /** Re-establish the session after a bfcache restore; also opts into leaving on persisted pagehide. */ rejoin?: () => void; /** Borrowed sessions wait for `pagehide`, since `beforeunload` may be cancelled. */ leaveOnBeforeUnload?: boolean | (() => boolean); /** Window to listen on; defaults to the ambient `window` when present. */ target?: TeardownWindowLike; /** The leave `postMessage` payload type; defaults to {@link COLLAB_LEAVE_MESSAGE}. */ leaveMessage?: string; } /** * Register `pagehide`, `beforeunload`, `pageshow` and `message` listeners that make the local peer * leave its room when the document goes away (tab close, navigation, or an embedder detaching the * frame, which fires `pagehide` but never `beforeunload`). Returns a disposer; a no-op outside a * browser. */ export declare function registerTeardown(options: TeardownOptions): () => void; export interface DepartureNotice { channel: string; roomId: string; clientId: number; } export interface DepartureChannelLike { postMessage: (message: DepartureNotice) => void; close: () => void; onmessage: ((event: { data: unknown; }) => void) | null; } export type DepartureChannelFactory = (name: string) => DepartureChannelLike; export interface DepartureChannel { /** Announce that this client is leaving. Synchronous on purpose (usable from `pagehide`). */ announce: () => void; dispose: () => void; } /** * Same-browser departure channel: peers announcing their exit are dropped from `awareness` at once * instead of lingering as ghosts until the awareness timeout (y-webrtc broadcasts removals one * microtask too late for a document being destroyed). Cross-device peers still rely on the * transport. A no-op where `BroadcastChannel` is unavailable. */ export declare function createDepartureChannel(roomId: string, awareness: AwarenessStatesLike, factory?: DepartureChannelFactory, channelName?: string): DepartureChannel; //# sourceMappingURL=lifecycle.d.ts.map