UNPKG

@orbitinghail/sqlsync-worker

Version:

SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.

116 lines (96 loc) 4.7 kB
/* tslint:disable */ /* eslint-disable */ /** */ export function main(): void; import { JournalId } from "../../src/journal-id.ts"; import { PortRouter, PortId } from "../../src/port.ts"; export type HandlerId = number; export type PageIdx = number; export type QueryKey = string; interface WorkerApi { handle(msg: HostToWorkerMsg): Promise<void>; } export type DocId = JournalId; export interface HostToWorkerMsg { portId: PortId; handlerId: HandlerId; docId: DocId; req: DocRequest; } export type DocRequest = { tag: "Open"; reducerUrl: string } | { tag: "Query"; sql: string; params: SqlValue[] } | { tag: "QuerySubscribe"; key: QueryKey; sql: string; params: SqlValue[] } | { tag: "QueryUnsubscribe"; key: QueryKey } | { tag: "Mutate"; mutation: Uint8Array } | { tag: "RefreshConnectionStatus" } | { tag: "SetConnectionEnabled"; enabled: boolean }; export type WorkerToHostMsg = { tag: "Reply"; handlerId: HandlerId; reply: DocReply } | { tag: "Event"; docId: DocId; evt: DocEvent }; export type DocReply = { tag: "Ack" } | { tag: "RecordSet"; columns: string[]; rows: SqlValue[][] } | { tag: "Err"; err: string }; export type DocEvent = { tag: "ConnectionStatus"; status: ConnectionStatus } | { tag: "SubscriptionChanged"; key: QueryKey; columns: string[]; rows: SqlValue[][] } | { tag: "SubscriptionErr"; key: QueryKey; err: string }; export type SqlValue = | undefined | null | boolean | number | string | bigint | Uint8Array; export type ConnectionStatus = "disabled" | "disconnected" | "connecting" | "connected"; /** */ export class WorkerApi { free(): void; /** * @param {PortRouter} ports * @param {string | undefined} coordinator_url */ constructor(ports: PortRouter, coordinator_url?: string); } export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_workerapi_free: (a: number) => void; readonly workerapi_new: (a: number, b: number, c: number) => number; readonly workerapi_handle: (a: number, b: number) => number; readonly main: () => void; readonly sqlite3_os_init: () => number; readonly wasm_vfs_currenttime: (a: number, b: number) => number; readonly wasm_vfs_sleep: (a: number, b: number) => number; readonly wasm_vfs_randomness: (a: number, b: number, c: number) => number; readonly wasm_vfs_dlclose: (a: number, b: number) => void; readonly wasm_vfs_dlsym: (a: number, b: number, c: number) => number; readonly wasm_vfs_dlerror: (a: number, b: number, c: number) => void; readonly wasm_vfs_dlopen: (a: number, b: number) => number; readonly wasm_vfs_access: (a: number, b: number, c: number, d: number) => number; readonly wasm_vfs_delete: (a: number, b: number, c: number) => number; readonly wasm_vfs_open: (a: number, b: number, c: number, d: number, e: number) => number; readonly malloc: (a: number) => number; readonly free: (a: number) => void; readonly realloc: (a: number, b: number) => number; readonly wasm_vfs_fullpathname: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_malloc: (a: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; readonly __wbindgen_export_2: WebAssembly.Table; readonly wasm_bindgen__convert__closures__invoke0_mut__h2490b76af2ea92bd: (a: number, b: number) => void; readonly wasm_bindgen__convert__closures__invoke1_mut__h36fc7019e46c6e4b: (a: number, b: number, c: number) => void; readonly wasm_bindgen__convert__closures__invoke0_mut__ha0cfa2e0f3a9574c: (a: number, b: number) => void; readonly wasm_bindgen__convert__closures__invoke1_mut__h49a07c903463a6b6: (a: number, b: number, c: number) => void; readonly __wbindgen_exn_store: (a: number) => void; readonly __wbindgen_free: (a: number, b: number) => void; readonly wasm_bindgen__convert__closures__invoke2_mut__h827585beff2df891: (a: number, b: number, c: number, d: number) => void; readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {SyncInitInput} module * * @returns {InitOutput} */ export function initSync(module: SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {InitInput | Promise<InitInput>} module_or_path * * @returns {Promise<InitOutput>} */ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;