import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import { registerPublicAssetServiceWorker } from "./public-asset-cache.js"; import { AdminAuthPage } from "./admin-auth.js"; import { UserAuthPage } from "./user-auth.js"; import { AccountSettingsPage } from "./account-settings.js"; import { AdminUsersPage } from "./admin-users.js"; import { CreditsPage } from "./credits-page.js"; import { ProjectDetailPage, ProjectsPage, WorkspacePage } from "./project-pages.js"; const root = document.getElementById("root"); if (!root) { throw new Error("Dada web root element is missing."); } // Cache failure leaves public assets network-backed and must not create alternate persistence. void registerPublicAssetServiceWorker().catch(() => undefined); const appRoot = createRoot(root); let authRevision = 0; function renderAuthenticationEntry() { authRevision += 1; const projectDetail = window.location.pathname.match(/^\/app\/projects\/([0-9a-f-]{36})$/i); let authenticationPage; if (window.location.pathname === "/app/settings") authenticationPage = ; else if (window.location.pathname === "/app/credits") authenticationPage = ; else if (projectDetail?.[1]) authenticationPage = ; else if (window.location.pathname === "/app/projects") authenticationPage = ; else if (window.location.pathname === "/app") authenticationPage = ; else if (window.location.pathname === "/admin/users") authenticationPage = ; else if (window.location.pathname.startsWith("/admin")) authenticationPage = ; else authenticationPage = ; appRoot.render( {authenticationPage} , ); } // Any authenticated surface can dispatch this after a revoked/invalid session response. window.addEventListener("dada:session-invalid", () => { if (window.location.pathname.startsWith("/app")) window.history.replaceState(null, "", "/"); renderAuthenticationEntry(); }); renderAuthenticationEntry();