diff --git a/src/index.tsx b/src/index.tsx index e41faff..d6a0139 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,5 +3,63 @@ if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { } import "./css/main.scss"; -import("./main"); import("./css/font-awesome.css"); + +const [ + { LiveSplit }, + React, + ReactDOM, + { toast, ToastContainer }, +] = await Promise.all([ + import("./ui/LiveSplit"), + import("react"), + import("react-dom"), + import("react-toastify"), +]); + +try { + const { + splits, + splitsKey, + layout, + hotkeys, + layoutWidth, + } = await LiveSplit.loadStoredData(); + + try { + ReactDOM.render( +
+ + +
, + document.getElementById("base"), + ); + } catch (_) { + alert(`Couldn't load LiveSplit One. \ +You may be using a browser that is not up to date. \ +Please update your browser or your iOS version and try again. \ +Another reason might be that a browser extension, such as an adblocker, \ +is blocking access to important scripts.`); + } +} catch (e) { + if (e.name === "InvalidStateError") { + alert(`Couldn't load LiveSplit One. \ +You may be in private browsing mode. \ +LiveSplit One cannot store any splits, layouts, or other settings because of the limitations of the browser's private browsing mode. \ +These limitations may be lifted in the future. \ +To run LiveSplit One for now, please disable private browsing in your settings.\n`); + } +} diff --git a/src/main.tsx b/src/main.tsx deleted file mode 100644 index 5a428b2..0000000 --- a/src/main.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { LiveSplit } from "./ui/LiveSplit"; -import * as React from "react"; -import * as ReactDOM from "react-dom"; -import { toast, ToastContainer } from "react-toastify"; - -try { - const { - splits, - splitsKey, - layout, - hotkeys, - layoutWidth, - } = await LiveSplit.loadStoredData(); - - try { - ReactDOM.render( -
- - -
, - document.getElementById("base"), - ); - } catch (_) { - alert(`Couldn't load LiveSplit One. \ -You may be using a browser that is not up to date. \ -Please update your browser or your iOS version and try again. \ -Another reason might be that a browser extension, such as an adblocker, \ -is blocking access to important scripts.`); - } -} catch (e) { - if (e.name === "InvalidStateError") { - alert(`Couldn't load LiveSplit One. \ -You may be in private browsing mode. \ -LiveSplit One cannot store any splits, layouts, or other settings because of the limitations of the browser's private browsing mode. \ -These limitations may be lifted in the future. \ -To run LiveSplit One for now, please disable private browsing in your settings.\n`); - } -}