// node:sqlite, loaded at run time — for reading a browser's cookie store // (xBrowserLogin.ts) and for the tests' fixture stores. // // The specifier is assembled so no bundler tries to resolve it (the same reason // playwrightRuntime.ts assembles its own): `node:sqlite` exists only with the // prefix, and Node 22.13+ loads it without a flag (with an ExperimentalWarning, // once per process). Structural types, because the repo's @types/node predates // the module. No imports, so a test harness can load it on its own. type SqliteStatement = { all: (...params: unknown[]) => unknown[]; run: (...params: unknown[]) => unknown; }; export type SqliteDb = { prepare: (sql: string) => SqliteStatement; exec: (sql: string) => void; close: () => void; }; export type SqliteModule = { DatabaseSync: new (file: string, opts?: Record) => SqliteDb; }; const SQLITE = ["node", "sqlite"].join(":"); export async function loadSqlite(): Promise { const mod = (await import(/* webpackIgnore: true */ SQLITE)) as Partial & { default?: SqliteModule; }; const m = mod.DatabaseSync ? (mod as SqliteModule) : mod.default; if (!m?.DatabaseSync) { throw new Error("node:sqlite is not available in this Node (22.13 or later loads it without a flag)."); } return m; }