diff --git a/bun.lockb b/bun.lockb index fe2e851e..35e091ef 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 2ab6be3c..4afc2ef7 100644 --- a/package.json +++ b/package.json @@ -70,11 +70,13 @@ "@mantine/hooks": "^7.7.0", "@tanstack/react-router": "^1.29.2", "@tauri-apps/api": "^1", + "@types/sql.js": "^1.4.9", "bits-ui": "^0.14.0", "clsx": "^2.1.0", "mantine-datatable": "^7.6.1", "react": "18.2", "react-dom": "18.2", + "sql.js": "^1.10.3", "tailwind-merge": "^2.2.0", "tailwind-variants": "^0.1.20", "tauri-settings": "^0.3.4" diff --git a/src/App.tsx b/src/App.tsx index 1a06c79e..aeaa8dce 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import { safeAsyncEventHandler } from "$lib/async"; -import { LibraryProvider } from "$lib/contexts/library"; +import { LocalCalibreLibraryProvider, WebCalibreLibraryProvider } from "$lib/contexts/library"; import { SettingsProvider } from "$lib/contexts/settings"; import { theme } from "$lib/theme"; import { ColorSchemeScript, MantineProvider } from "@mantine/core"; @@ -21,6 +21,9 @@ declare module "@tanstack/react-router" { export const App = () => { const [libraryPath, setLibraryPath] = useState(null); + const [libraryFSDirectoryHandle, setLibraryFSDirectoryHandle] = useState( + null + ); const updateLibraryPath = useCallback(async () => { const libPath = await settings.get("calibreLibraryPath"); setLibraryPath(libPath); @@ -39,19 +42,31 @@ export const App = () => { onLibraryPathPicked={() => { safeAsyncEventHandler(updateLibraryPath)(); }} + onLibraryFSDirectoryHandlePicked={setLibraryFSDirectoryHandle} /> ); } + if (libraryFSDirectoryHandle) { + return + + + + + + + ; + } + return ( - + - + ); }; diff --git a/src/components/pages/firstTimeSetup.tsx b/src/components/pages/firstTimeSetup.tsx index a834ba0b..9444bdad 100644 --- a/src/components/pages/firstTimeSetup.tsx +++ b/src/components/pages/firstTimeSetup.tsx @@ -1,5 +1,6 @@ import { commands } from "@/bindings"; import { safeAsyncEventHandler } from "@/lib/async"; +import { isDesktop } from "@/lib/platform"; import { pickLibrary } from "@/lib/services/library"; import { createLibrary } from "@/lib/services/library/_internal/pickLibrary"; import { settings } from "@/stores/settings"; @@ -23,7 +24,11 @@ const openFilePicker = async (): Promise< export const FirstTimeSetup = ({ onLibraryPathPicked, -}: { onLibraryPathPicked: () => void }) => { + onLibraryFSDirectoryHandlePicked, +}: { + onLibraryPathPicked: () => void; + onLibraryFSDirectoryHandlePicked: (handle: FileSystemDirectoryHandle) => void; +}) => { return ( Welcome to Citadel! @@ -34,16 +39,33 @@ export const FirstTimeSetup = ({