UNPKG

sqlocal

Version:

SQLocal makes it easy to run SQLite3 in the browser, backed by the origin private file system.

47 lines (46 loc) 2.55 kB
import type { ProcessorConfig, UserFunction, QueryKey, ConnectReason, SQLocalDriver } from './types.js'; import type { BatchMessage, ConfigMessage, DeleteMessage, DestroyMessage, ExportMessage, FunctionMessage, GetInfoMessage, ImportMessage, InputMessage, OutputMessage, QueryMessage, TransactionMessage, WorkerProxy } from './messages.js'; import { type Mutex } from './lib/create-mutex.js'; import { type DebouncedFunction } from './lib/debounce.js'; /** * The `SQLocal` client exchanges messages with a paired instance * of `SQLocalProcessor` to interact with databases. * @see {@link https://sqlocal.dev/guide/setup} */ export declare class SQLocalProcessor { protected driver: SQLocalDriver; protected config: ProcessorConfig; protected userFunctions: Map<string, UserFunction>; protected initMutex: Mutex; protected transactionMutex: Mutex; protected transactionKey: QueryKey | null; protected proxy: WorkerProxy; protected dirtyTables: Set<string>; protected effectsChannel?: BroadcastChannel; protected reinitChannel?: BroadcastChannel; /** * After an `InputMessage` has been processed, the resulting * `OutputMessage` is emitted to the function passed to `onmessage`. */ onmessage?: (message: OutputMessage, transfer: Transferable[]) => void; constructor(driver: SQLocalDriver); protected init: (reason: ConnectReason) => Promise<void>; /** * To interact with a database, an `InputMessage` is passed to * `postMessage` for processing. */ postMessage: (event: InputMessage | MessageEvent<InputMessage>, _transfer?: Transferable) => Promise<void>; protected emitMessage: (message: OutputMessage, transfer?: Transferable[]) => void; protected emitEffects: () => void; protected emitEffectsDebounced: DebouncedFunction<() => void>; protected editConfig: (message: ConfigMessage) => void; protected exec: (message: QueryMessage | BatchMessage | TransactionMessage) => Promise<void>; protected execInitStatements: () => Promise<void>; protected getDatabaseInfo: (message: GetInfoMessage) => Promise<void>; protected createUserFunction: (message: FunctionMessage) => Promise<void>; protected initUserFunction: (fn: UserFunction) => Promise<void>; protected importDb: (message: ImportMessage) => Promise<void>; protected exportDb: (message: ExportMessage) => Promise<void>; protected deleteDb: (message: DeleteMessage) => Promise<void>; protected destroy: (message?: DestroyMessage) => Promise<void>; }