UNPKG

tiny-electron-essentials

Version:

A lightweight and modular utility library for Electron apps, offering simplified window management, tray support, IPC channels, and custom frameless window styling.

66 lines 2.69 kB
export default TinyDb; /** * TinyDb provides a secure bridge between the Electron renderer process and the main process * to perform database queries over IPC. It exposes simple database-like methods (`run`, `all`, * `get`, and `query`) to the renderer process using `contextBridge.exposeInMainWorld`. * * This class is designed to work alongside a `TinyIpcRequestManager` instance * and requires an identifier (`id`) to namespace IPC events. */ declare class TinyDb { /** * Creates a new TinyDb instance. * * @param {TinyIpcRequestManager} ipcRequest - The IPC request manager instance for communication. * @param {string} id - A unique identifier to namespace the IPC events. * * @throws {Error} If `ipcRequest` is not an instance of `TinyIpcRequestManager`. * @throws {Error} If `id` is not a string. */ constructor(ipcRequest: TinyIpcRequestManager, id: string); /** * Exposes the TinyDb API to the renderer process via `window[apiName]`. * * @param {string} [apiName='tinyDb'] - The name under which the API will be exposed in `window`. * * @throws {Error} If the API is already exposed. * @throws {Error} If `apiName` is not a valid non-empty string. */ exposeInMainWorld(apiName?: string): void; /** * Executes an SQL command that modifies data (`INSERT`, `UPDATE`, `DELETE`) * or runs any command without returning rows. * * @param {string} query - SQL query string. * @param {any[]} params - Query parameters. * @returns {Promise<any>} Result of the query execution. */ run(query: string, params: any[]): Promise<any>; /** * Executes a SQL `SELECT` query that returns all matching rows. * * @param {string} query - SQL query string. * @param {any[]} params - Query parameters. * @returns {Promise<any[]>} Array of matching rows. */ all(query: string, params: any[]): Promise<any[]>; /** * Executes a SQL `SELECT` query that returns a single row. * * @param {string} query - SQL query string. * @param {any[]} params - Query parameters. * @returns {Promise<any>} The first row matching the query. */ get(query: string, params: any[]): Promise<any>; /** * Executes a generic SQL query. The result depends on the query type. * * @param {string} query - SQL query string. * @param {any[]} params - Query parameters. * @returns {Promise<any>} Result of the query. */ query(query: string, params: any[]): Promise<any>; #private; } import TinyIpcRequestManager from './TinyIpcRequestManager.mjs'; //# sourceMappingURL=TinyDb.d.mts.map