2023-03-19 18:01:08 +01:00
|
|
|
import "core-js/stable";
|
2023-03-19 20:53:44 +01:00
|
|
|
import React, { Suspense } from "react";
|
2022-02-16 21:30:12 +01:00
|
|
|
import ReactDOM from "react-dom";
|
2023-02-19 16:05:19 +01:00
|
|
|
import { BrowserRouter, HashRouter } from "react-router-dom";
|
2023-03-19 20:53:44 +01:00
|
|
|
import type { ReactNode } from "react-router-dom/node_modules/@types/react/index";
|
2023-02-24 20:12:20 +01:00
|
|
|
import { registerSW } from "virtual:pwa-register";
|
2023-01-07 21:36:18 +01:00
|
|
|
|
2023-04-24 17:41:54 +02:00
|
|
|
import { ErrorBoundary } from "@/components/layout/ErrorBoundary";
|
2023-01-07 21:36:18 +01:00
|
|
|
import App from "@/setup/App";
|
2023-04-24 17:41:54 +02:00
|
|
|
import { conf } from "@/setup/config";
|
|
|
|
|
2023-02-21 21:45:14 +01:00
|
|
|
import "@/setup/ga";
|
2023-04-21 20:49:47 +02:00
|
|
|
import "@/setup/sentry";
|
2023-01-07 21:36:18 +01:00
|
|
|
import "@/setup/i18n";
|
|
|
|
import "@/setup/index.css";
|
2023-01-11 21:16:48 +01:00
|
|
|
import "@/backend";
|
2023-01-25 21:44:15 +01:00
|
|
|
import { initializeChromecast } from "./setup/chromecast";
|
2023-02-12 00:41:55 +01:00
|
|
|
import { initializeStores } from "./utils/storage";
|
2022-12-29 18:25:57 +01:00
|
|
|
|
|
|
|
// initialize
|
|
|
|
const key =
|
|
|
|
(window as any)?.__CONFIG__?.VITE_KEY ?? import.meta.env.VITE_KEY ?? null;
|
|
|
|
if (key) {
|
2023-02-22 21:41:13 +01:00
|
|
|
(window as any).initMW(conf().PROXY_URLS, key);
|
2022-12-29 18:25:57 +01:00
|
|
|
}
|
2023-01-25 21:44:15 +01:00
|
|
|
initializeChromecast();
|
2023-02-24 20:12:20 +01:00
|
|
|
registerSW({
|
2023-03-19 18:01:08 +01:00
|
|
|
immediate: true,
|
2023-02-24 20:12:20 +01:00
|
|
|
});
|
2021-07-14 00:31:37 +02:00
|
|
|
|
2023-02-12 00:41:55 +01:00
|
|
|
const LazyLoadedApp = React.lazy(async () => {
|
|
|
|
await initializeStores();
|
|
|
|
return {
|
|
|
|
default: App,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2023-02-19 16:05:19 +01:00
|
|
|
function TheRouter(props: { children: ReactNode }) {
|
|
|
|
const normalRouter = conf().NORMAL_ROUTER;
|
2023-02-19 18:03:54 +01:00
|
|
|
|
|
|
|
if (normalRouter) return <BrowserRouter>{props.children}</BrowserRouter>;
|
|
|
|
return <HashRouter>{props.children}</HashRouter>;
|
2023-02-19 16:05:19 +01:00
|
|
|
}
|
|
|
|
|
2021-07-14 00:31:37 +02:00
|
|
|
ReactDOM.render(
|
2022-02-16 21:30:12 +01:00
|
|
|
<React.StrictMode>
|
|
|
|
<ErrorBoundary>
|
2023-02-19 16:05:19 +01:00
|
|
|
<TheRouter>
|
2022-12-17 09:54:27 +01:00
|
|
|
<Suspense fallback="">
|
2023-02-12 00:41:55 +01:00
|
|
|
<LazyLoadedApp />
|
2022-12-17 09:54:27 +01:00
|
|
|
</Suspense>
|
2023-02-19 16:05:19 +01:00
|
|
|
</TheRouter>
|
2022-02-16 21:30:12 +01:00
|
|
|
</ErrorBoundary>
|
|
|
|
</React.StrictMode>,
|
|
|
|
document.getElementById("root")
|
2021-07-14 00:31:37 +02:00
|
|
|
);
|