Initialize absurd-sql on the main thread
masterBecause absurd-sql must run in a worker, you need to initialize a backend handler on the main thread. This is specifically required for Safari to support nested workers by proxying worker creation through the main thread.
Use initBackend from absurd-sql/dist/indexeddb-main-thread and pass your worker instance to it.
import { initBackend } from 'absurd-sql/dist/indexeddb-main-thread';
function init() {
let worker = new Worker(new URL('./index.worker.js', import.meta.url));
// This is only required because Safari doesn't support nested
// workers. This installs a handler that will proxy creating web
// workers through the main thread
initBackend(worker);
}
init();