/* eslint-disable import/first */ import React from 'react'; import { createRoot } from 'react-dom/client'; import { enableMapSet } from 'immer'; import '@fontsource-variable/inter/index.css'; import '@fontsource/caveat/500.css'; import '@fontsource/caveat/600.css'; import '@fontsource/caveat/700.css'; import 'folds/dist/style.css'; import { configClass, varsClass } from 'folds'; enableMapSet(); import './index.css'; import { trimTrailingSlash } from './app/utils/common'; import App from './app/pages/App'; import { applySafeAreaInsets } from './app/utils/tauri'; import { enableViewTransitionsForNavigation } from './app/utils/viewTransitions'; import { registerDesktopMediaSaver } from './app/utils/registerDesktopMediaSaver'; // import i18n (needs to be bundled ;)) import './app/i18n'; document.body.classList.add(configClass, varsClass); // Apply safe area insets for mobile devices applySafeAreaInsets(); // Enable View Transitions API for smooth navigation enableViewTransitionsForNavigation(); // Desktop shells: native Save dialog instead of browser FileSaver downloads. registerDesktopMediaSaver(); // Register Service Worker if ('serviceWorker' in navigator) { const swUrl = import.meta.env.MODE === 'production' ? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js` : `/dev-sw.js?dev-sw`; navigator.serviceWorker.register(swUrl); navigator.serviceWorker.addEventListener('message', (event) => { if (event.data?.type === 'token' && event.data?.responseKey) { // Use the centralized token utility to get the current access token // This ensures we always use the most up-to-date token from the MatrixClient const getCurrentAccessToken = async () => { const { getCurrentAccessToken: getToken } = await import('./app/utils/auth'); return getToken(); }; getCurrentAccessToken().then((token) => { event.source!.postMessage({ responseKey: event.data.responseKey, token, }); }); } }); } const mountApp = () => { const rootContainer = document.getElementById('root'); if (rootContainer === null) { console.error('Root container element not found!'); return; } const root = createRoot(rootContainer); root.render(); }; mountApp();