import { BaseObserver } from '@powersync/common';
import * as Comlink from 'comlink';
import { AsyncDatabaseConnection, OnTableChangeCallback, OpenAsyncDatabaseConnection, ProxiedQueryResult } from './AsyncDatabaseConnection';
import { ResolvedWebSQLOpenOptions } from './web-sql-flags';
export type SharedConnectionWorker = {
    identifier: string;
    port: MessagePort;
};
export type WrappedWorkerConnectionOptions<Config extends ResolvedWebSQLOpenOptions = ResolvedWebSQLOpenOptions> = {
    baseConnection: AsyncDatabaseConnection;
    identifier: string;
    remoteCanCloseUnexpectedly: boolean;
    /**
     * Need a remote in order to keep a reference to the Proxied worker
     */
    remote: Comlink.Remote<OpenAsyncDatabaseConnection<Config>>;
    onClose?: () => void;
};
export type WorkerWrappedAsyncDatabaseConnectionListener = {
    closing: () => void;
};
/**
 * Wraps a provided instance of {@link AsyncDatabaseConnection}, providing necessary proxy
 * functions for worker listeners.
 */
export declare class WorkerWrappedAsyncDatabaseConnection<Config extends ResolvedWebSQLOpenOptions = ResolvedWebSQLOpenOptions> extends BaseObserver<WorkerWrappedAsyncDatabaseConnectionListener> implements AsyncDatabaseConnection {
    protected options: WrappedWorkerConnectionOptions<Config>;
    protected lockAbortController: AbortController;
    protected notifyRemoteClosed: AbortController | undefined;
    constructor(options: WrappedWorkerConnectionOptions<Config>);
    protected get baseConnection(): AsyncDatabaseConnection<ResolvedWebSQLOpenOptions>;
    init(): Promise<void>;
    /**
     * Marks the remote as closed.
     *
     * This can sometimes happen outside of our control, e.g. when a shared worker requests a connection from a tab. When
     * it happens, all methods on the {@link baseConnection} would never resolve. To avoid livelocks in this scenario, we
     * throw on all outstanding promises and forbid new calls.
     */
    markRemoteClosed(): void;
    markHold(): Promise<string>;
    releaseHold(holdId: string): Promise<void>;
    isAutoCommit(): Promise<boolean>;
    private withRemote;
    /**
     * Get a MessagePort which can be used to share the internals of this connection.
     */
    shareConnection(): Promise<SharedConnectionWorker>;
    /**
     * Registers a table change notification callback with the base database.
     * This can be extended by custom implementations in order to handle proxy events.
     */
    registerOnTableChange(callback: OnTableChangeCallback): Promise<() => void>;
    close(): Promise<void>;
    execute(sql: string, params?: any[]): Promise<ProxiedQueryResult>;
    executeRaw(sql: string, params?: any[]): Promise<any[][]>;
    executeBatch(sql: string, params?: any[]): Promise<ProxiedQueryResult>;
    getConfig(): Promise<ResolvedWebSQLOpenOptions>;
}
