import { LockContext, DBLockOptions, DBAdapterListener, ConnectionPool, BaseObserver, SQLOpenOptions } from '@powersync/common'; import { SharedConnectionWorker, WebDBAdapterConfiguration } from '../WebDBAdapter.js'; import { ClientConnectionView } from './DatabaseServer.js'; import * as Comlink from 'comlink'; import { WorkerDBOpenerOptions } from './WASQLiteOpenFactory.js'; export interface OpenWorkerConnection { connect(config: WorkerDBOpenerOptions): Promise; connectToExisting(options: { identifier: string; lockName: string; }): Promise; } export interface ClientOptions { connection: ClientConnectionView; /** * The remote from which the {@link connection} has been obtained. * * We use this to be able to expose this port to other clients wanting to connect to the database (e.g. the shared * sync worker). * * For sources not based on workers, returns null. */ source: Comlink.Remote | null; /** * Whether the remote we're connecting to can close unexpectedly (e.g. because we're a shared worker connecting to a * dedicated worker handle we've received from a tab). */ remoteCanCloseUnexpectedly: boolean; onClose?: () => void; } /** * A single-connection {@link ConnectionPool} implementation based on a worker connection. */ export declare class DatabaseClient extends BaseObserver implements ConnectionPool { #private; private readonly options; private readonly config; constructor(options: ClientOptions, config: Config); get name(): string; /** * 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 outstanding requests on this pool would never resolve. To avoid livelocks in this scenario, we * throw on all outstanding promises and forbid new calls. */ markRemoteClosed(): void; close(): Promise; readLock(fn: (tx: LockContext) => Promise, options?: DBLockOptions): Promise; writeLock(fn: (tx: LockContext) => Promise, options?: DBLockOptions): Promise; refreshSchema(): Promise; shareConnection(): Promise; getConfiguration(): Config; }