this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: make main a bit nicer

+18 -14
+18 -14
mast-react-vite/src/main.tsx
··· 2 2 import './index.css' 3 3 import App from "./App.tsx"; 4 4 5 + import { DBAsync } from "@vlcn.io/xplat-api"; 5 6 import initWasm from '@vlcn.io/crsqlite-wasm'; 6 7 import wasmUrl from '@vlcn.io/crsqlite-wasm/crsqlite.wasm?url'; 7 8 import tblrx from '@vlcn.io/rx-tbl'; 8 9 9 - const sqlite = await initWasm(() => wasmUrl); 10 - 11 - const db = await sqlite.open("todo.db"); 12 - await db.exec(` 10 + const initDb = async () => { 11 + const sqlite = await initWasm(() => wasmUrl); 12 + const db: DBAsync = await sqlite.open("todo.db"); 13 + await db.exec(` 13 14 CREATE TABLE IF NOT EXISTS todos ( 14 15 id BLOB PRIMARY KEY NOT NULL, 15 16 description TEXT, ··· 22 23 completed INTEGER NOT NULL DEFAULT 0 23 24 ); 24 25 SELECT crsql_as_crr('todos'); 25 - `); 26 + `); 27 + const rx = tblrx(db); 28 + return {db, rx}; 29 + } 26 30 27 - const rx = tblrx(db); 28 - const ctx = { db, rx }; 31 + const init = async () => { 32 + const ctx = await initDb(); 33 + createRoot(document.getElementById("root") as HTMLElement).render( 34 + <main className="min-h-screen flex flex-col py-12 bg-background text-gray-200"> 35 + <App ctx={ctx} /> 36 + </main> 37 + ); 38 + } 29 39 30 40 document.getElementById("root")!.classList.add("dark"); 31 - 32 - createRoot(document.getElementById("root") as HTMLElement).render( 33 - <main className="min-h-screen flex flex-col py-12 bg-background text-gray-200"> 34 - <App ctx={ctx} /> 35 - </main> 36 - ); 37 - 41 + init();