2025-03-04 17:53:05 +01:00
|
|
|
import './polyfills.js';
|
2024-02-27 17:58:08 +01:00
|
|
|
import React from 'react';
|
|
|
|
|
import ReactDOM from 'react-dom/client';
|
|
|
|
|
import App from './app';
|
|
|
|
|
import { HashRouter as Router } from 'react-router-dom';
|
2024-02-29 11:41:57 +01:00
|
|
|
import './lib/init-translations';
|
2024-02-27 17:58:08 +01:00
|
|
|
import './index.css';
|
2024-02-28 21:18:37 +01:00
|
|
|
import './themes.css';
|
2024-02-27 17:58:08 +01:00
|
|
|
import { App as CapacitorApp } from '@capacitor/app';
|
2026-01-22 17:28:22 +01:00
|
|
|
import { Analytics } from '@vercel/analytics/react';
|
|
|
|
|
|
|
|
|
|
// Only enable analytics on 5chan.app (Vercel deployment)
|
|
|
|
|
// Exclude Electron (file:// or localhost), Capacitor/APK (capacitor:// or localhost), and IPFS (ipfs:// or different domain)
|
|
|
|
|
const isVercelDeployment =
|
|
|
|
|
typeof window !== 'undefined' && (window.location.hostname === '5chan.app' || window.location.hostname === 'www.5chan.app') && !window.isElectron;
|
2024-02-27 17:58:08 +01:00
|
|
|
|
|
|
|
|
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
|
|
|
root.render(
|
|
|
|
|
<React.StrictMode>
|
|
|
|
|
<Router>
|
|
|
|
|
<App />
|
2026-01-22 17:28:22 +01:00
|
|
|
{isVercelDeployment && <Analytics />}
|
2024-02-27 17:58:08 +01:00
|
|
|
</Router>
|
|
|
|
|
</React.StrictMode>,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// add back button in android app
|
|
|
|
|
CapacitorApp.addListener('backButton', ({ canGoBack }) => {
|
|
|
|
|
if (canGoBack) {
|
|
|
|
|
window.history.back();
|
|
|
|
|
} else {
|
|
|
|
|
CapacitorApp.exitApp();
|
|
|
|
|
}
|
|
|
|
|
});
|