diff --git a/.gitmodules b/.gitmodules
index 2f203261..918863a8 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
[submodule "app/Database"]
- path = src/database
+ path = src/database/contents
url = https://github.com/elyukai/optolith-data.git
diff --git a/src/database b/src/database/contents
similarity index 100%
rename from src/database
rename to src/database/contents
diff --git a/src/database.ts b/src/database/index.ts
similarity index 74%
rename from src/database.ts
rename to src/database/index.ts
index 76526113..96848eba 100644
--- a/src/database.ts
+++ b/src/database/index.ts
@@ -2,9 +2,9 @@ import { dirname, join } from "node:path"
import { parentPort } from "node:process"
import { fileURLToPath } from "node:url"
import { getAllValidData } from "optolith-database-schema"
-import { getAbsoluteEntityPaths } from "./database/src/config.js"
+import { getAbsoluteEntityPaths } from "./contents/src/config.js"
-const root = join(dirname(fileURLToPath(import.meta.url)), "database")
+const root = join(dirname(fileURLToPath(import.meta.url)), "contents")
getAllValidData(getAbsoluteEntityPaths(root))
.then(database => {
diff --git a/src/main.ts b/src/main/index.ts
similarity index 92%
rename from src/main.ts
rename to src/main/index.ts
index 43dc19a3..3adb1f4c 100644
--- a/src/main.ts
+++ b/src/main/index.ts
@@ -4,10 +4,10 @@ import { autoUpdater } from "electron-updater"
import { readFile } from "node:fs/promises"
import { join } from "node:path"
import * as process from "node:process"
-import type { Database } from "./database.ts"
-import { createMainWindow, showMainWindow } from "./main/mainWindow.ts"
-import { ensureUserDataPathExists } from "./main/saveData.ts"
-import { checkForUpdatesOnRequest, checkForUpdatesOnStartup } from "./main/updater.ts"
+import type { Database } from "../database/index.ts"
+import { createMainWindow, showMainWindow } from "./mainWindow.ts"
+import { ensureUserDataPathExists } from "./saveData.ts"
+import { checkForUpdatesOnRequest, checkForUpdatesOnStartup } from "./updater.ts"
app.setAppUserModelId("lukasobermann.optolith")
diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts
index bce72573..fc382d3b 100644
--- a/src/main/mainWindow.ts
+++ b/src/main/mainWindow.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, ipcMain, shell } from "electron"
import windowStateKeeper from "electron-window-state"
import * as path from "node:path"
import * as url from "node:url"
-import type { Database } from "../database.ts"
+import type { Database } from "../database/index.ts"
export const createMainWindow = async () => {
console.log("main: Create Window ...")
diff --git a/src/renderers/main/hooks/redux.ts b/src/main_window/hooks/redux.ts
similarity index 100%
rename from src/renderers/main/hooks/redux.ts
rename to src/main_window/hooks/redux.ts
diff --git a/src/renderers/main/hooks/translate.ts b/src/main_window/hooks/translate.ts
similarity index 100%
rename from src/renderers/main/hooks/translate.ts
rename to src/main_window/hooks/translate.ts
diff --git a/src/renderers/main/hooks/visibleTabs.ts b/src/main_window/hooks/visibleTabs.ts
similarity index 98%
rename from src/renderers/main/hooks/visibleTabs.ts
rename to src/main_window/hooks/visibleTabs.ts
index c1fa8231..5ff2314e 100644
--- a/src/renderers/main/hooks/visibleTabs.ts
+++ b/src/main_window/hooks/visibleTabs.ts
@@ -7,7 +7,7 @@ import { Route, selectRoute } from "../slices/routeSlice.ts"
// import { getIsSpellsTabAvailable } from "./spellsSelectors"
// import { getCurrentCultureId, getCurrentPhase, getCurrentTab, getRaceIdM, getWiki } from "./stateSelectors"
import { useMemo } from "react"
-import { filterNonNullable } from "../../../shared/helpers/array.ts"
+import { filterNonNullable } from "../../shared/utils/array.ts"
type RouteGroupName =
| "about"
diff --git a/src/renderers/main/entry.tsx b/src/main_window/index.tsx
similarity index 98%
rename from src/renderers/main/entry.tsx
rename to src/main_window/index.tsx
index b6d6fb48..16190efa 100644
--- a/src/renderers/main/entry.tsx
+++ b/src/main_window/index.tsx
@@ -33,8 +33,8 @@
// import { Unit } from "./Data/Unit"
import { createRoot } from "react-dom/client"
import { Provider } from "react-redux"
-import "../../shared/styles/index.scss"
-import { preloadApi } from "./preloadApi.ts"
+import "../shared/styles/index.scss"
+import { preloadApi } from "./preload.ts"
import { Root } from "./routes/Root.tsx"
import { initDatabase } from "./slices/databaseSlice.ts"
import { store } from "./store.ts"
diff --git a/src/renderers/updater/preloadApi.ts b/src/main_window/preload.ts
similarity index 69%
rename from src/renderers/updater/preloadApi.ts
rename to src/main_window/preload.ts
index 73a29f04..eec89235 100644
--- a/src/renderers/updater/preloadApi.ts
+++ b/src/main_window/preload.ts
@@ -1,4 +1,4 @@
-import { PreloadAPI } from "./preload.ts"
+import { PreloadAPI } from "../main_window_preload/index.ts"
type EnhancedWindow = Window & typeof globalThis & { optolith: PreloadAPI }
diff --git a/src/renderers/main/routes/NavigationBar.tsx b/src/main_window/routes/NavigationBar.tsx
similarity index 97%
rename from src/renderers/main/routes/NavigationBar.tsx
rename to src/main_window/routes/NavigationBar.tsx
index 00668803..2a6f8a41 100644
--- a/src/renderers/main/routes/NavigationBar.tsx
+++ b/src/main_window/routes/NavigationBar.tsx
@@ -1,8 +1,8 @@
import { FC } from "react"
-import { IconButton } from "../components/iconButton/IconButton.tsx"
+import { IconButton } from "../../shared/components/iconButton/IconButton.tsx"
import { useTranslate } from "../hooks/translate.ts"
import { useVisibleTabs } from "../hooks/visibleTabs.ts"
-import { preloadApi } from "../preloadApi.ts"
+import { preloadApi } from "../preload.ts"
import { NavigationBarLeft } from "./NavigationBarLeft.tsx"
import { NavigationBarRight } from "./NavigationBarRight.tsx"
import { NavigationBarSubTabs } from "./NavigationBarSubTabs.tsx"
diff --git a/src/renderers/main/routes/NavigationBarBack.scss b/src/main_window/routes/NavigationBarBack.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarBack.scss
rename to src/main_window/routes/NavigationBarBack.scss
diff --git a/src/renderers/main/routes/NavigationBarBack.tsx b/src/main_window/routes/NavigationBarBack.tsx
similarity index 100%
rename from src/renderers/main/routes/NavigationBarBack.tsx
rename to src/main_window/routes/NavigationBarBack.tsx
diff --git a/src/renderers/main/routes/NavigationBarForGroup.tsx b/src/main_window/routes/NavigationBarForGroup.tsx
similarity index 100%
rename from src/renderers/main/routes/NavigationBarForGroup.tsx
rename to src/main_window/routes/NavigationBarForGroup.tsx
diff --git a/src/renderers/main/routes/NavigationBarLeft.scss b/src/main_window/routes/NavigationBarLeft.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarLeft.scss
rename to src/main_window/routes/NavigationBarLeft.scss
diff --git a/src/renderers/main/routes/NavigationBarLeft.tsx b/src/main_window/routes/NavigationBarLeft.tsx
similarity index 74%
rename from src/renderers/main/routes/NavigationBarLeft.tsx
rename to src/main_window/routes/NavigationBarLeft.tsx
index a63cf264..2629e6a5 100644
--- a/src/renderers/main/routes/NavigationBarLeft.tsx
+++ b/src/main_window/routes/NavigationBarLeft.tsx
@@ -1,4 +1,4 @@
-import { FCC } from "../../../shared/helpers/react.js"
+import { FCC } from "../../shared/utils/react.js"
import "./NavigationBarLeft.scss"
export const NavigationBarLeft: FCC = ({ children }) => (
diff --git a/src/renderers/main/routes/NavigationBarRight.scss b/src/main_window/routes/NavigationBarRight.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarRight.scss
rename to src/main_window/routes/NavigationBarRight.scss
diff --git a/src/renderers/main/routes/NavigationBarRight.tsx b/src/main_window/routes/NavigationBarRight.tsx
similarity index 74%
rename from src/renderers/main/routes/NavigationBarRight.tsx
rename to src/main_window/routes/NavigationBarRight.tsx
index f5f44b3e..4b4101a0 100644
--- a/src/renderers/main/routes/NavigationBarRight.tsx
+++ b/src/main_window/routes/NavigationBarRight.tsx
@@ -1,4 +1,4 @@
-import { FCC } from "../../../shared/helpers/react.js"
+import { FCC } from "../../shared/utils/react.js"
import "./NavigationBarRight.scss"
export const NavigationBarRight: FCC = ({ children }) => (
diff --git a/src/renderers/main/routes/NavigationBarSubTabs.scss b/src/main_window/routes/NavigationBarSubTabs.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarSubTabs.scss
rename to src/main_window/routes/NavigationBarSubTabs.scss
diff --git a/src/renderers/main/routes/NavigationBarSubTabs.tsx b/src/main_window/routes/NavigationBarSubTabs.tsx
similarity index 100%
rename from src/renderers/main/routes/NavigationBarSubTabs.tsx
rename to src/main_window/routes/NavigationBarSubTabs.tsx
diff --git a/src/renderers/main/routes/NavigationBarTab.scss b/src/main_window/routes/NavigationBarTab.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarTab.scss
rename to src/main_window/routes/NavigationBarTab.scss
diff --git a/src/renderers/main/routes/NavigationBarTab.tsx b/src/main_window/routes/NavigationBarTab.tsx
similarity index 95%
rename from src/renderers/main/routes/NavigationBarTab.tsx
rename to src/main_window/routes/NavigationBarTab.tsx
index a4c50052..7b32e4d1 100644
--- a/src/renderers/main/routes/NavigationBarTab.tsx
+++ b/src/main_window/routes/NavigationBarTab.tsx
@@ -1,6 +1,6 @@
import { FC, useCallback } from "react"
-import { classList } from "../../../shared/helpers/classList.ts"
-import { Tab } from "../components/tab/Tab.tsx"
+import { Tab } from "../../shared/components/tab/Tab.tsx"
+import { classList } from "../../shared/utils/classList.ts"
import { useAppDispatch, useAppSelector } from "../hooks/redux.ts"
import { useTranslate } from "../hooks/translate.ts"
import { DisplayRoute } from "../hooks/visibleTabs.ts"
diff --git a/src/renderers/main/routes/NavigationBarTabs.scss b/src/main_window/routes/NavigationBarTabs.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarTabs.scss
rename to src/main_window/routes/NavigationBarTabs.scss
diff --git a/src/renderers/main/routes/NavigationBarTabs.tsx b/src/main_window/routes/NavigationBarTabs.tsx
similarity index 100%
rename from src/renderers/main/routes/NavigationBarTabs.tsx
rename to src/main_window/routes/NavigationBarTabs.tsx
diff --git a/src/renderers/main/routes/NavigationBarWrapper.scss b/src/main_window/routes/NavigationBarWrapper.scss
similarity index 100%
rename from src/renderers/main/routes/NavigationBarWrapper.scss
rename to src/main_window/routes/NavigationBarWrapper.scss
diff --git a/src/renderers/main/routes/NavigationBarWrapper.tsx b/src/main_window/routes/NavigationBarWrapper.tsx
similarity index 79%
rename from src/renderers/main/routes/NavigationBarWrapper.tsx
rename to src/main_window/routes/NavigationBarWrapper.tsx
index 2afd278e..ff86f965 100644
--- a/src/renderers/main/routes/NavigationBarWrapper.tsx
+++ b/src/main_window/routes/NavigationBarWrapper.tsx
@@ -1,4 +1,4 @@
-import { FCC } from "../../../shared/helpers/react.js"
+import { FCC } from "../../shared/utils/react.js"
import "./NavigationBarWrapper.scss"
export const NavigationBarWrapper: FCC = ({ children }) => (
diff --git a/src/renderers/main/routes/Root.scss b/src/main_window/routes/Root.scss
similarity index 98%
rename from src/renderers/main/routes/Root.scss
rename to src/main_window/routes/Root.scss
index 0031fdca..77e8b83d 100644
--- a/src/renderers/main/routes/Root.scss
+++ b/src/main_window/routes/Root.scss
@@ -1,4 +1,4 @@
-@use "../../../shared/styles/index.scss";
+@use "../../shared/styles/index.scss";
html,
body,
diff --git a/src/main_window/routes/Root.tsx b/src/main_window/routes/Root.tsx
new file mode 100644
index 00000000..085097e5
--- /dev/null
+++ b/src/main_window/routes/Root.tsx
@@ -0,0 +1,53 @@
+import { FC } from "react"
+import backgroundImg from "../../assets/images/background.svg"
+import { TitleBar } from "../../shared/components/titleBar/TitleBar.tsx"
+import { Theme } from "../../shared/schema/config.ts"
+import { classList } from "../../shared/utils/classList.ts"
+import { preloadApi } from "../preload.ts"
+import { NavigationBar } from "./NavigationBar.tsx"
+import "./Root.scss"
+import { Router } from "./Router.tsx"
+
+const handleMinimize = preloadApi.minimize
+const handleMaximize = preloadApi.maximize
+const handleRestore = preloadApi.restore
+const handleClose = preloadApi.close
+
+export const Root: FC = () => {
+ const theme = Theme.Dark
+ const areAnimationsEnabled = true
+ const language = "de-DE"
+
+ return (
+
+
+

+
+
+ {/*
*/}
+
+
+
+
+
+
+
+ )
+}
diff --git a/src/renderers/main/routes/Router.scss b/src/main_window/routes/Router.scss
similarity index 100%
rename from src/renderers/main/routes/Router.scss
rename to src/main_window/routes/Router.scss
diff --git a/src/renderers/main/routes/Router.tsx b/src/main_window/routes/Router.tsx
similarity index 97%
rename from src/renderers/main/routes/Router.tsx
rename to src/main_window/routes/Router.tsx
index 0ab61dd2..dfe324bf 100644
--- a/src/renderers/main/routes/Router.tsx
+++ b/src/main_window/routes/Router.tsx
@@ -1,5 +1,5 @@
import { FC } from "react"
-import { assertExhaustive } from "../../../shared/helpers/typeSafety.ts"
+import { assertExhaustive } from "../../shared/utils/typeSafety.ts"
import { useAppSelector } from "../hooks/redux.ts"
import { selectRoute } from "../slices/routeSlice.ts"
diff --git a/src/renderers/main/routes/about/Imprint.tsx b/src/main_window/routes/about/Imprint.tsx
similarity index 100%
rename from src/renderers/main/routes/about/Imprint.tsx
rename to src/main_window/routes/about/Imprint.tsx
diff --git a/src/renderers/main/routes/about/LastChanges.tsx b/src/main_window/routes/about/LastChanges.tsx
similarity index 80%
rename from src/renderers/main/routes/about/LastChanges.tsx
rename to src/main_window/routes/about/LastChanges.tsx
index c0f9746b..9815672b 100644
--- a/src/renderers/main/routes/about/LastChanges.tsx
+++ b/src/main_window/routes/about/LastChanges.tsx
@@ -1,6 +1,6 @@
import { FC, useEffect, useState } from "react"
-import { Markdown } from "../../components/markdown/Markdown.tsx"
-import { preloadApi } from "../../preloadApi.ts"
+import { Markdown } from "../../../shared/components/markdown/Markdown.tsx"
+import { preloadApi } from "../../preload.ts"
export const LastChanges: FC = () => {
const [ text, setText ] = useState("...")
diff --git a/src/renderers/main/routes/about/ThirdPartyLicenses.scss b/src/main_window/routes/about/ThirdPartyLicenses.scss
similarity index 100%
rename from src/renderers/main/routes/about/ThirdPartyLicenses.scss
rename to src/main_window/routes/about/ThirdPartyLicenses.scss
diff --git a/src/renderers/main/routes/about/ThirdPartyLicenses.tsx b/src/main_window/routes/about/ThirdPartyLicenses.tsx
similarity index 94%
rename from src/renderers/main/routes/about/ThirdPartyLicenses.tsx
rename to src/main_window/routes/about/ThirdPartyLicenses.tsx
index 401bdad2..a6e285c5 100644
--- a/src/renderers/main/routes/about/ThirdPartyLicenses.tsx
+++ b/src/main_window/routes/about/ThirdPartyLicenses.tsx
@@ -1,5 +1,5 @@
import { FC, useEffect, useState } from "react"
-import { preloadApi } from "../../preloadApi.ts"
+import { preloadApi } from "../../preload.ts"
export const ThirdPartyLicenses: FC = () => {
const [ version, setVersion ] = useState("0.0.0")
diff --git a/src/renderers/main/slices/databaseSlice.ts b/src/main_window/slices/databaseSlice.ts
similarity index 99%
rename from src/renderers/main/slices/databaseSlice.ts
rename to src/main_window/slices/databaseSlice.ts
index 80f1be1e..7106cac4 100644
--- a/src/renderers/main/slices/databaseSlice.ts
+++ b/src/main_window/slices/databaseSlice.ts
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import { PayloadAction, createSlice } from "@reduxjs/toolkit"
import { TypeId, TypeMap } from "optolith-database-schema/config/types"
-import { Database as RawDatabase } from "../../../database.ts"
+import { Database as RawDatabase } from "../../database/index.ts"
export type DatabaseState = {
[K in keyof TypeMap]: Record, TypeMap[K]>
diff --git a/src/renderers/main/slices/routeSlice.ts b/src/main_window/slices/routeSlice.ts
similarity index 100%
rename from src/renderers/main/slices/routeSlice.ts
rename to src/main_window/slices/routeSlice.ts
diff --git a/src/renderers/main/slices/settingsSlice.ts b/src/main_window/slices/settingsSlice.ts
similarity index 100%
rename from src/renderers/main/slices/settingsSlice.ts
rename to src/main_window/slices/settingsSlice.ts
diff --git a/src/renderers/main/store.ts b/src/main_window/store.ts
similarity index 100%
rename from src/renderers/main/store.ts
rename to src/main_window/store.ts
diff --git a/src/renderers/main/preload.ts b/src/main_window_preload/index.ts
similarity index 96%
rename from src/renderers/main/preload.ts
rename to src/main_window_preload/index.ts
index a97a01cd..c45215db 100644
--- a/src/renderers/main/preload.ts
+++ b/src/main_window_preload/index.ts
@@ -1,7 +1,7 @@
import { contextBridge, ipcRenderer } from "electron"
import EventEmitter from "events"
import { ValidResults } from "optolith-database-schema"
-import { TypedEventEmitterForEvent } from "../../shared/helpers/events.ts"
+import { TypedEventEmitterForEvent } from "../shared/utils/events.ts"
export type PreloadAPI = {
platform: NodeJS.Platform
diff --git a/src/renderers/main/components/titleBar/TitleBar.tsx b/src/renderers/main/components/titleBar/TitleBar.tsx
deleted file mode 100644
index 0efe3952..00000000
--- a/src/renderers/main/components/titleBar/TitleBar.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { FC, useCallback, useEffect, useState } from "react"
-import { preloadApi } from "../../preloadApi.ts"
-import "./TitleBar.scss"
-import { TitleBarButton } from "./TitleBarButton.tsx"
-import { TitleBarWrapper } from "./TitleBarWrapper.tsx"
-
-const useWindowState = (stateKey: "isMaximized" | "isFocused") => {
- const [ state, setState ] = useState(false)
-
- useEffect(() => {
- const updateState = () => {
- preloadApi[stateKey]()
- .then(setState)
- .catch(console.error)
- }
-
- updateState()
- }, [ stateKey ])
-
- const update = useCallback(() => {
- preloadApi[stateKey]()
- .then(setState)
- .catch(console.error)
- }, [ stateKey ])
-
- return [ state, update ] as const
-}
-
-const handleMinimize = preloadApi.minimize
-const handleMaximize = preloadApi.maximize
-const handleRestore = preloadApi.restore
-const handleClose = preloadApi.close
-
-export const TitleBar: FC = () => {
- const [ isMaximized, updateIsMaximized ] = useWindowState("isMaximized")
- const [ isFocused, updateIsFocused ] = useWindowState("isFocused")
-
- useEffect(
- () => {
- preloadApi.on("maximize", updateIsMaximized)
- preloadApi.on("unmaximize", updateIsMaximized)
- preloadApi.on("blur", updateIsFocused)
- preloadApi.on("focus", updateIsFocused)
-
- return () => {
- preloadApi.removeListener("maximize", updateIsMaximized)
- preloadApi.removeListener("unmaximize", updateIsMaximized)
- preloadApi.removeListener("blur", updateIsFocused)
- preloadApi.removeListener("focus", updateIsFocused)
- }
- },
- [ updateIsFocused, updateIsMaximized ]
- )
-
- if (preloadApi.platform === "darwin") {
- return (
-
-
-
- )
- }
-
- return (
-
-
- {isMaximized
- ? null
- : }
- {isMaximized
- ?
- : null}
-
-
- )
-}
diff --git a/src/renderers/main/routes/Root.tsx b/src/renderers/main/routes/Root.tsx
deleted file mode 100644
index d37a4fb2..00000000
--- a/src/renderers/main/routes/Root.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { FC } from "react"
-import backgroundImg from "../../../assets/images/background.svg"
-import { classList } from "../../../shared/helpers/classList.ts"
-import { Theme } from "../../../shared/schema/config.ts"
-import { TitleBar } from "../components/titleBar/TitleBar.tsx"
-import { preloadApi } from "../preloadApi.ts"
-import { NavigationBar } from "./NavigationBar.tsx"
-import "./Root.scss"
-import { Router } from "./Router.tsx"
-
-export const Root: FC = () => {
- const theme = Theme.Dark
- const areAnimationsEnabled = true
- const language = "de-DE"
-
- return (
-
-
-

-
-
- {/*
*/}
-
-
-
-
-
-
-
- )
-}
diff --git a/src/renderers/main/components/button/Button.scss b/src/shared/components/button/Button.scss
similarity index 100%
rename from src/renderers/main/components/button/Button.scss
rename to src/shared/components/button/Button.scss
diff --git a/src/renderers/main/components/button/Button.tsx b/src/shared/components/button/Button.tsx
similarity index 87%
rename from src/renderers/main/components/button/Button.tsx
rename to src/shared/components/button/Button.tsx
index e63354a1..9c3398c2 100644
--- a/src/renderers/main/components/button/Button.tsx
+++ b/src/shared/components/button/Button.tsx
@@ -1,5 +1,5 @@
-import { classList } from "../../../../shared/helpers/classList.ts"
-import { FCC } from "../../../../shared/helpers/react.js"
+import { classList } from "../../utils/classList.ts"
+import { FCC } from "../../utils/react.js"
import "./Button.scss"
interface Props {
diff --git a/src/renderers/main/components/icon/Icon.tsx b/src/shared/components/icon/Icon.tsx
similarity index 67%
rename from src/renderers/main/components/icon/Icon.tsx
rename to src/shared/components/icon/Icon.tsx
index b6ec080c..f1e30a62 100644
--- a/src/renderers/main/components/icon/Icon.tsx
+++ b/src/shared/components/icon/Icon.tsx
@@ -1,5 +1,5 @@
-import { classList } from "../../../../shared/helpers/classList.ts"
-import { FCC } from "../../../../shared/helpers/react.js"
+import { classList } from "../../utils/classList.ts"
+import { FCC } from "../../utils/react.js"
interface Props {
className?: string
diff --git a/src/renderers/main/components/iconButton/IconButton.scss b/src/shared/components/iconButton/IconButton.scss
similarity index 100%
rename from src/renderers/main/components/iconButton/IconButton.scss
rename to src/shared/components/iconButton/IconButton.scss
diff --git a/src/renderers/main/components/iconButton/IconButton.tsx b/src/shared/components/iconButton/IconButton.tsx
similarity index 100%
rename from src/renderers/main/components/iconButton/IconButton.tsx
rename to src/shared/components/iconButton/IconButton.tsx
diff --git a/src/renderers/main/components/markdown/Markdown.tsx b/src/shared/components/markdown/Markdown.tsx
similarity index 93%
rename from src/renderers/main/components/markdown/Markdown.tsx
rename to src/shared/components/markdown/Markdown.tsx
index 3e2d6c93..090b9be6 100644
--- a/src/renderers/main/components/markdown/Markdown.tsx
+++ b/src/shared/components/markdown/Markdown.tsx
@@ -4,7 +4,7 @@ import ReactMarkdown from "react-markdown"
import rehypeRaw from "rehype-raw"
import Ph from "remark-breaks"
import remarkGfm from "remark-gfm"
-import { classList } from "../../../../shared/helpers/classList.ts"
+import { classList } from "../../utils/classList.ts"
type Props = {
className?: string
diff --git a/src/renderers/main/components/tab/Tab.tsx b/src/shared/components/tab/Tab.tsx
similarity index 77%
rename from src/renderers/main/components/tab/Tab.tsx
rename to src/shared/components/tab/Tab.tsx
index 3a4e458b..acf863f6 100644
--- a/src/renderers/main/components/tab/Tab.tsx
+++ b/src/shared/components/tab/Tab.tsx
@@ -1,6 +1,6 @@
-import { classList } from "../../../../shared/helpers/classList.ts"
-import { FCC } from "../../../../shared/helpers/react.js"
-import { isNonEmptyString } from "../../../../shared/helpers/string.ts"
+import { classList } from "../../utils/classList.ts"
+import { FCC } from "../../utils/react.js"
+import { isNonEmptyString } from "../../utils/string.ts"
export interface TabBaseProps {
className?: string
diff --git a/src/renderers/main/components/titleBar/TitleBar.scss b/src/shared/components/titleBar/TitleBar.scss
similarity index 100%
rename from src/renderers/main/components/titleBar/TitleBar.scss
rename to src/shared/components/titleBar/TitleBar.scss
diff --git a/src/shared/components/titleBar/TitleBar.tsx b/src/shared/components/titleBar/TitleBar.tsx
new file mode 100644
index 00000000..9786f2de
--- /dev/null
+++ b/src/shared/components/titleBar/TitleBar.tsx
@@ -0,0 +1,96 @@
+import { FC, useCallback, useEffect, useState } from "react"
+import { TypedEventEmitterForEvent } from "../../utils/events.ts"
+import "./TitleBar.scss"
+import { TitleBarButton } from "./TitleBarButton.tsx"
+import { TitleBarWrapper } from "./TitleBarWrapper.tsx"
+
+const useWindowState = (getWindowState: () => Promise) => {
+ const [ state, setState ] = useState(false)
+
+ useEffect(() => {
+ const updateState = () => {
+ getWindowState()
+ .then(setState)
+ .catch(console.error)
+ }
+
+ updateState()
+ }, [ getWindowState ])
+
+ const update = useCallback(() => {
+ getWindowState()
+ .then(setState)
+ .catch(console.error)
+ }, [ getWindowState ])
+
+ return [ state, update ] as const
+}
+
+type Props = {
+ platform: NodeJS.Platform
+ windowEvents:
+ & TypedEventEmitterForEvent<"maximize", []>
+ & TypedEventEmitterForEvent<"unmaximize", []>
+ & TypedEventEmitterForEvent<"blur", []>
+ & TypedEventEmitterForEvent<"focus", []>
+ onMinimize: () => void
+ onMaximize: () => void
+ onRestore: () => void
+ onClose: () => void
+ isMaximized: () => Promise
+ isFocused: () => Promise
+}
+
+export const TitleBar: FC = props => {
+ const {
+ platform,
+ windowEvents,
+ onMinimize,
+ onMaximize,
+ onRestore,
+ onClose,
+ isMaximized: getIsMaximized,
+ isFocused: getIsFocused,
+ } = props
+
+ const [ isMaximized, updateIsMaximized ] = useWindowState(getIsMaximized)
+ const [ isFocused, updateIsFocused ] = useWindowState(getIsFocused)
+
+ useEffect(
+ () => {
+ windowEvents.on("maximize", updateIsMaximized)
+ windowEvents.on("unmaximize", updateIsMaximized)
+ windowEvents.on("blur", updateIsFocused)
+ windowEvents.on("focus", updateIsFocused)
+
+ return () => {
+ windowEvents.removeListener("maximize", updateIsMaximized)
+ windowEvents.removeListener("unmaximize", updateIsMaximized)
+ windowEvents.removeListener("blur", updateIsFocused)
+ windowEvents.removeListener("focus", updateIsFocused)
+ }
+ },
+ [ updateIsFocused, updateIsMaximized, windowEvents ]
+ )
+
+ if (platform === "darwin") {
+ return (
+
+
+
+ )
+ }
+
+ return (
+
+
+ {isMaximized
+ ? null
+ : }
+ {isMaximized
+ ?
+ : null}
+
+
+ )
+}
diff --git a/src/renderers/main/components/titleBar/TitleBarButton.tsx b/src/shared/components/titleBar/TitleBarButton.tsx
similarity index 82%
rename from src/renderers/main/components/titleBar/TitleBarButton.tsx
rename to src/shared/components/titleBar/TitleBarButton.tsx
index dd63feac..28c877c2 100644
--- a/src/renderers/main/components/titleBar/TitleBarButton.tsx
+++ b/src/shared/components/titleBar/TitleBarButton.tsx
@@ -1,5 +1,5 @@
import * as React from "react"
-import { classList } from "../../../../shared/helpers/classList.ts"
+import { classList } from "../../utils/classList.ts"
type Props = {
className?: string
diff --git a/src/renderers/main/components/titleBar/TitleBarWrapper.tsx b/src/shared/components/titleBar/TitleBarWrapper.tsx
similarity index 68%
rename from src/renderers/main/components/titleBar/TitleBarWrapper.tsx
rename to src/shared/components/titleBar/TitleBarWrapper.tsx
index 8767b03c..c24d6ea5 100644
--- a/src/renderers/main/components/titleBar/TitleBarWrapper.tsx
+++ b/src/shared/components/titleBar/TitleBarWrapper.tsx
@@ -1,5 +1,5 @@
-import { classList } from "../../../../shared/helpers/classList.ts"
-import { FCC } from "../../../../shared/helpers/react.js"
+import { classList } from "../../utils/classList.ts"
+import { FCC } from "../../utils/react.js"
type Props = {
isFocused: boolean
diff --git a/src/shared/helpers/array.ts b/src/shared/utils/array.ts
similarity index 100%
rename from src/shared/helpers/array.ts
rename to src/shared/utils/array.ts
diff --git a/src/shared/helpers/classList.test.ts b/src/shared/utils/classList.test.ts
similarity index 100%
rename from src/shared/helpers/classList.test.ts
rename to src/shared/utils/classList.test.ts
diff --git a/src/shared/helpers/classList.ts b/src/shared/utils/classList.ts
similarity index 100%
rename from src/shared/helpers/classList.ts
rename to src/shared/utils/classList.ts
diff --git a/src/shared/helpers/events.ts b/src/shared/utils/events.ts
similarity index 100%
rename from src/shared/helpers/events.ts
rename to src/shared/utils/events.ts
diff --git a/src/shared/helpers/maybe.ts b/src/shared/utils/maybe.ts
similarity index 100%
rename from src/shared/helpers/maybe.ts
rename to src/shared/utils/maybe.ts
diff --git a/src/shared/helpers/react.d.ts b/src/shared/utils/react.ts
similarity index 100%
rename from src/shared/helpers/react.d.ts
rename to src/shared/utils/react.ts
diff --git a/src/shared/helpers/result.ts b/src/shared/utils/result.ts
similarity index 100%
rename from src/shared/helpers/result.ts
rename to src/shared/utils/result.ts
diff --git a/src/shared/helpers/string.ts b/src/shared/utils/string.ts
similarity index 100%
rename from src/shared/helpers/string.ts
rename to src/shared/utils/string.ts
diff --git a/src/shared/helpers/typeSafety.ts b/src/shared/utils/typeSafety.ts
similarity index 100%
rename from src/shared/helpers/typeSafety.ts
rename to src/shared/utils/typeSafety.ts
diff --git a/src/renderers/template.html b/src/template.html
similarity index 100%
rename from src/renderers/template.html
rename to src/template.html
diff --git a/src/renderers/updater/entry.tsx b/src/updater_window/index.tsx
similarity index 90%
rename from src/renderers/updater/entry.tsx
rename to src/updater_window/index.tsx
index 23670b52..47789a59 100644
--- a/src/renderers/updater/entry.tsx
+++ b/src/updater_window/index.tsx
@@ -1,6 +1,6 @@
import type { UpdateInfo } from "electron-updater"
import { createRoot } from "react-dom/client"
-import { preloadApi } from "./preloadApi.ts"
+import { preloadApi } from "./preload.ts"
import { Root } from "./root.tsx"
const domNode = document.getElementById("root")!
diff --git a/src/renderers/main/preloadApi.ts b/src/updater_window/preload.ts
similarity index 68%
rename from src/renderers/main/preloadApi.ts
rename to src/updater_window/preload.ts
index 73a29f04..13c798c8 100644
--- a/src/renderers/main/preloadApi.ts
+++ b/src/updater_window/preload.ts
@@ -1,4 +1,4 @@
-import { PreloadAPI } from "./preload.ts"
+import { PreloadAPI } from "../updater_window_preload/index.ts"
type EnhancedWindow = Window & typeof globalThis & { optolith: PreloadAPI }
diff --git a/src/renderers/updater/root.tsx b/src/updater_window/root.tsx
similarity index 100%
rename from src/renderers/updater/root.tsx
rename to src/updater_window/root.tsx
diff --git a/src/renderers/updater/preload.ts b/src/updater_window_preload/index.ts
similarity index 89%
rename from src/renderers/updater/preload.ts
rename to src/updater_window_preload/index.ts
index abcdf91a..ec39da1c 100644
--- a/src/renderers/updater/preload.ts
+++ b/src/updater_window_preload/index.ts
@@ -1,7 +1,7 @@
import { contextBridge, ipcRenderer } from "electron"
import { UpdateInfo } from "electron-updater"
import EventEmitter from "events"
-import { TypedEventEmitterForEvent } from "../../shared/helpers/events.ts"
+import { TypedEventEmitterForEvent } from "../shared/utils/events.ts"
export type PreloadAPI = {
diff --git a/tsconfig.json b/tsconfig.json
index c5f29610..2c510a69 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -38,7 +38,7 @@
"src/Data/**/*",
"src/Debug/**/*",
"src/System/**/*",
- "src/database/Compatibility/**/*",
- "src/database/migration/**/*"
+ "src/database/contents/Compatibility/**/*",
+ "src/database/contents/migration/**/*"
]
}
diff --git a/webpack.config.js b/webpack.config.js
index c03fbc8e..21621fbc 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -13,7 +13,7 @@ export default [
name: "main",
mode,
entry: {
- main: "./src/main.ts"
+ main: "./src/main/index.ts"
},
target: "electron-main",
optimization: getOptimization("main"),
@@ -35,7 +35,7 @@ export default [
name: "database",
mode,
entry: {
- database: "./src/database.ts"
+ database: "./src/database/index.ts"
},
target: "electron-main",
optimization: getOptimization("database"),
@@ -57,7 +57,7 @@ export default [
name: "renderer_main",
mode,
entry: {
- renderer_main: "./src/renderers/main/entry.tsx",
+ renderer_main: "./src/main_window/index.tsx",
},
target: "electron-renderer",
module: {
@@ -80,7 +80,7 @@ export default [
name: "renderer_main_preload",
mode,
entry: {
- renderer_main_preload: "./src/renderers/main/preload.ts"
+ renderer_main_preload: "./src/main_window_preload/index.ts"
},
target: "electron-preload",
module: {
@@ -98,7 +98,7 @@ export default [
name: "renderer_updater",
mode,
entry: {
- renderer_updater: "./src/renderers/updater/entry.tsx"
+ renderer_updater: "./src/updater_window/index.tsx"
},
target: "electron-renderer",
module: {
@@ -121,7 +121,7 @@ export default [
name: "renderer_updater_preload",
mode,
entry: {
- renderer_updater_preload: "./src/renderers/updater/preload.ts"
+ renderer_updater_preload: "./src/updater_window_preload/index.ts"
},
target: "electron-preload",
module: {
diff --git a/webpack.plugins.js b/webpack.plugins.js
index 28a274e0..ea4ea1e6 100644
--- a/webpack.plugins.js
+++ b/webpack.plugins.js
@@ -10,7 +10,7 @@ import { isDevelopment } from "./webpack.env.js"
export const rendererPlugins = [
new HtmlWebpackPlugin({
filename: "[name].html",
- template: "./src/renderers/template.html"
+ template: "./src/template.html"
}),
new MiniCssExtractPlugin({
filename: `assets/css/${isDevelopment ? '[name].css' : '[name].[hash].css'}`,