/** * SQLite 适配层:让 UsageStore 同时跑在多种 runtime / Node 版本。 * * 优先级: * - Bun runtime → `bun:sqlite`(Bun 内置) * - Node.js >= 22.5 + `--experimental-sqlite` flag → `node:sqlite` * - Node.js < 22.5 或无 flag → `better-sqlite3`(跨版本、prebuilt binaries) * * 三个驱动的 API 在我们用到的范围内一致: * - db.prepare(sql).run(...args) -> { changes, lastInsertRowid } * - db.prepare(sql).all(...args) -> Row[] * - db.prepare(sql).get(...args) -> Row | undefined * - db.exec(sql) * - db.close() * * Bun 下用 createRequire 动态加载 bun:sqlite;Node 下逐个尝试。 */ export interface SqliteRunResult { changes: number; lastInsertRowid: number | bigint; } export interface SqliteStatement { run(...args: unknown[]): SqliteRunResult; all(...args: unknown[]): Record[]; get(...args: unknown[]): Record | undefined; } export interface SqliteDatabase { prepare(sql: string): SqliteStatement; exec(sql: string): void; close(): void; } /** * 加载当前 runtime 对应的 SQLite driver,返回一个 SQLite database 连接。 * * @internal 仅在 UsageStore 内部使用 */ export declare function openSqliteDatabase(path: string): SqliteDatabase; /** * 判断当前 runtime 是否为 Bun。供 caller 决定是否需要处理 runtime-specific 行为。 */ export declare function isBunRuntime(): boolean; //# sourceMappingURL=sqlite-client.d.ts.map