import type { SyncularChangedRow, SyncularCrdtDocumentSnapshot, SyncularCrdtFieldCompactionReceipt, SyncularCrdtFieldDescriptor, SyncularCrdtFieldMaterialization, SyncularCrdtFieldRequest, SyncularCrdtFieldWriteReceipt, SyncularCrdtFieldYjsUpdateRequest, SyncularCrdtUpdateLogEntry, SyncularRowsChangedEvent } from '@syncular/client';
import type { SyncularCrdtProjectionHost } from './yjs-document-field-adapter';
export declare const SYNCULAR_CRDT_WEBVIEW_PROTOCOL = "syncular.crdt.host.v1";
export declare const SYNCULAR_CRDT_WEBVIEW_REQUEST = "syncular.crdt.host.request";
export declare const SYNCULAR_CRDT_WEBVIEW_RESPONSE = "syncular.crdt.host.response";
export declare const SYNCULAR_CRDT_WEBVIEW_ROWS_CHANGED = "syncular.crdt.host.rowsChanged";
export interface SyncularCrdtWebViewTransport {
    postMessage(message: SyncularCrdtHostMessage): void;
    addMessageListener(listener: (message: unknown) => void): () => void;
}
export interface SyncularCrdtJsonTransportOptions {
    postJsonMessage(message: string): void;
    addJsonMessageListener(listener: (message: string) => void): () => void;
    onInvalidMessage?: (error: unknown, message: string) => void;
}
export interface SyncularCrdtWebViewHostOptions {
    transport: SyncularCrdtWebViewTransport;
    requestId?: () => string;
    timeoutMs?: number;
}
export interface SyncularCrdtWebViewHostResponderOptions {
    transport: SyncularCrdtWebViewTransport;
    host: SyncularCrdtProjectionHost;
    publishRowsChanged?: boolean;
}
export interface SyncularCrdtWebViewHost {
    host: SyncularCrdtProjectionHost;
    close(): void;
}
export interface SyncularCrdtWebViewHostResponder {
    close(): void;
}
export interface SyncularCrdtHostErrorPayload {
    message: string;
    name?: string;
    code?: string;
    details?: unknown;
}
export interface SyncularCrdtHostMethodMap {
    openCrdtField: {
        request: SyncularCrdtFieldRequest;
        response: SyncularCrdtFieldDescriptor;
    };
    applyCrdtFieldYjsUpdate: {
        request: SyncularCrdtFieldYjsUpdateRequest;
        response: SyncularCrdtFieldWriteReceipt;
    };
    enqueueCrdtFieldYjsUpdate: {
        request: SyncularCrdtFieldYjsUpdateRequest;
        response: string;
    };
    materializeCrdtField: {
        request: SyncularCrdtFieldRequest;
        response: SyncularCrdtFieldMaterialization;
    };
    crdtDocumentSnapshot: {
        request: SyncularCrdtFieldRequest;
        response: SyncularCrdtDocumentSnapshot;
    };
    crdtUpdateLog: {
        request: SyncularCrdtFieldRequest & {
            limit?: number;
        };
        response: SyncularCrdtUpdateLogEntry[];
    };
    snapshotCrdtFieldStateVector: {
        request: SyncularCrdtFieldRequest;
        response: {
            stateVectorBase64: string;
        };
    };
    compactCrdtField: {
        request: SyncularCrdtFieldRequest & {
            minUncheckpointedUpdates?: number;
        };
        response: SyncularCrdtFieldCompactionReceipt;
    };
}
export type SyncularCrdtHostMethod = keyof SyncularCrdtHostMethodMap;
export type SyncularCrdtHostRequestMessage = {
    [Method in SyncularCrdtHostMethod]: {
        protocol: typeof SYNCULAR_CRDT_WEBVIEW_PROTOCOL;
        type: typeof SYNCULAR_CRDT_WEBVIEW_REQUEST;
        id: string;
        method: Method;
        request: SyncularCrdtHostMethodMap[Method]['request'];
    };
}[SyncularCrdtHostMethod];
export type SyncularCrdtHostResponseMessage = {
    protocol: typeof SYNCULAR_CRDT_WEBVIEW_PROTOCOL;
    type: typeof SYNCULAR_CRDT_WEBVIEW_RESPONSE;
    id: string;
    ok: true;
    response: unknown;
} | {
    protocol: typeof SYNCULAR_CRDT_WEBVIEW_PROTOCOL;
    type: typeof SYNCULAR_CRDT_WEBVIEW_RESPONSE;
    id: string;
    ok: false;
    error: SyncularCrdtHostErrorPayload;
};
export interface SyncularCrdtHostRowsChangedMessage {
    protocol: typeof SYNCULAR_CRDT_WEBVIEW_PROTOCOL;
    type: typeof SYNCULAR_CRDT_WEBVIEW_ROWS_CHANGED;
    event: SyncularRowsChangedEvent;
}
export type SyncularCrdtHostMessage = SyncularCrdtHostRequestMessage | SyncularCrdtHostResponseMessage | SyncularCrdtHostRowsChangedMessage;
export interface SyncularNativeRowsChangedEventLike {
    kind: string;
    tables?: string[];
    changedRows?: SyncularChangedRow[];
    payload_json?: {
        source?: string | null;
        changedRows?: SyncularChangedRow[];
    };
}
export declare function createSyncularCrdtJsonTransport(options: SyncularCrdtJsonTransportOptions): SyncularCrdtWebViewTransport;
export declare function createSyncularCrdtWebViewHost(options: SyncularCrdtWebViewHostOptions): SyncularCrdtWebViewHost;
export declare function createSyncularCrdtWebViewHostResponder(options: SyncularCrdtWebViewHostResponderOptions): SyncularCrdtWebViewHostResponder;
export declare function createSyncularCrdtHostResponseMessage(host: SyncularCrdtProjectionHost, message: SyncularCrdtHostRequestMessage): Promise<SyncularCrdtHostResponseMessage>;
export declare function createSyncularCrdtRowsChangedMessage(event: SyncularRowsChangedEvent): SyncularCrdtHostRowsChangedMessage;
export declare function syncularCrdtRowsChangedMessageFromNativeEvent(event: unknown): SyncularCrdtHostRowsChangedMessage | undefined;
export declare function syncularCrdtRowsChangedMessageFromNativeEventJson(eventJson: string): SyncularCrdtHostRowsChangedMessage | undefined;
export declare function isSyncularCrdtHostMessage(message: unknown): message is SyncularCrdtHostMessage;
export declare function dispatchSyncularCrdtHostRequest(host: SyncularCrdtProjectionHost, message: SyncularCrdtHostRequestMessage): Promise<unknown>;
//# sourceMappingURL=webview-host-facade.d.ts.map