import { lazy, Suspense } from "react"; import { Navigate, Route, Routes } from "react-router-dom"; import { Center, Loader } from "@mantine/core"; import { Error404 } from "@/components/ui/error-404.tsx"; import Layout from "@/components/layouts/global/layout.tsx"; import { useTrackOrigin } from "@/hooks/use-track-origin"; // ShareLayout is route-split: its ShareShell chrome pulls in the table of // contents (and thus TipTap), so keeping it out of the eager graph removes the // editor engine from startup for authenticated users too. const ShareLayout = lazy( () => import("@/features/share/components/share-layout.tsx"), ); // Auth / entry pages stay eager: they are the first paint for an unauthenticated // visitor (e.g. /login) and are already small, so code-splitting them would only // add a cold-chunk round trip to the most common cold-start path. import SetupWorkspace from "@/pages/auth/setup-workspace.tsx"; import LoginPage from "@/pages/auth/login"; import InviteSignup from "@/pages/auth/invite-signup.tsx"; import ForgotPassword from "@/pages/auth/forgot-password.tsx"; import PasswordReset from "./pages/auth/password-reset"; import PageRedirect from "@/pages/page/page-redirect.tsx"; import ShareRedirect from "@/pages/share/share-redirect.tsx"; // Heavy / leaf pages are route-split with React.lazy so their code (most // importantly the whole TipTap editor + KaTeX + lowlight grammars + drawio that // the page editor and the readonly share editor pull in) is fetched only when // the matching route is actually visited. The boundaries live inside // each Layout (around its ), so the app shell stays mounted while a // route chunk loads. const Home = lazy(() => import("@/pages/dashboard/home")); const Page = lazy(() => import("@/pages/page/page")); const SpaceHome = lazy(() => import("@/pages/space/space-home.tsx")); const SpaceTrash = lazy(() => import("@/pages/space/space-trash.tsx")); const SpacesPage = lazy(() => import("@/pages/spaces/spaces.tsx")); const FavoritesPage = lazy(() => import("@/pages/favorites/favorites-page")); const LabelPage = lazy(() => import("@/pages/label/label-page")); const SharedPage = lazy(() => import("@/pages/share/shared-page.tsx")); const AccountSettings = lazy( () => import("@/pages/settings/account/account-settings"), ); const AccountPreferences = lazy( () => import("@/pages/settings/account/account-preferences.tsx"), ); const WorkspaceSettings = lazy( () => import("@/pages/settings/workspace/workspace-settings"), ); const AiSettings = lazy(() => import("@/pages/settings/workspace/ai-settings")); const WorkspaceMembers = lazy( () => import("@/pages/settings/workspace/workspace-members"), ); const Groups = lazy(() => import("@/pages/settings/group/groups")); const GroupInfo = lazy(() => import("./pages/settings/group/group-info")); const Spaces = lazy(() => import("@/pages/settings/space/spaces.tsx")); const Shares = lazy(() => import("@/pages/settings/shares/shares.tsx")); export default function App() { useTrackOrigin(); return ( } > } /> } /> } /> } /> } /> } /> }> } /> } /> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }