From a7b0f14a7c5a092703ef3e6f00d8b28007e5c893 Mon Sep 17 00:00:00 2001 From: OmegaRogue Date: Sat, 16 Sep 2023 16:55:24 +0200 Subject: [PATCH] :recycle: Cleanup code --- .github/workflows/build.yml | 1 + .github/workflows/fork.yml | 1 + forge.config.ts | 3 ++- index.html | 31 ++++++++++++++++--------------- src/main.ts | 4 +++- src/preload.ts | 22 +++++++++++++++------- src/renderer.ts | 2 ++ src/style.css | 14 +++++++------- src/window.d.ts | 4 +++- vite.main.config.ts | 5 +++-- vite.preload.config.ts | 4 +++- vite.renderer.config.ts | 4 +++- 12 files changed, 59 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2182a9e..75df41f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,4 @@ +#file: noinspection SpellCheckingInspection name: Build and Release on: release: diff --git a/.github/workflows/fork.yml b/.github/workflows/fork.yml index e335f57..279b208 100644 --- a/.github/workflows/fork.yml +++ b/.github/workflows/fork.yml @@ -1,3 +1,4 @@ +#file: noinspection SpellCheckingInspection name: Merge to fork on: push: diff --git a/forge.config.ts b/forge.config.ts index 45808df..4043bd3 100644 --- a/forge.config.ts +++ b/forge.config.ts @@ -1,9 +1,10 @@ +// noinspection JSUnusedGlobalSymbols + import type {ForgeConfig} from '@electron-forge/shared-types'; import {MakerSquirrel} from '@electron-forge/maker-squirrel'; import {MakerZIP} from '@electron-forge/maker-zip'; import {MakerDeb} from '@electron-forge/maker-deb'; import {MakerRpm} from '@electron-forge/maker-rpm'; -import {MakerFlatpak} from '@electron-forge/maker-flatpak'; import {MakerDMG} from '@electron-forge/maker-dmg'; import {VitePlugin} from '@electron-forge/plugin-vite'; diff --git a/index.html b/index.html index a50c19d..4de1580 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,13 @@ - + + VTT Desktop Client - - + + + \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index f09de49..9e2a6ab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,5 @@ +// noinspection ES6MissingAwait,JSIgnoredPromiseFromCall + import {app, BrowserWindow, ipcMain, safeStorage,} from 'electron'; import path from 'path'; import fs from 'fs'; @@ -33,7 +35,7 @@ const createWindow = () => { win.setTitle(app.getName()); win.setProgressBar(-1); }); - win.webContents.setWindowOpenHandler((e) => { + win.webContents.setWindowOpenHandler(() => { return { action: 'allow', overrideBrowserWindowOptions: { diff --git a/src/preload.ts b/src/preload.ts index 472a96e..8c2aa2d 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -2,6 +2,7 @@ // @ts-ignore: no nodejs in preload // eslint-disable-next-line @typescript-eslint/no-var-requires import {contextBridge, ipcRenderer} from 'electron'; +import {versions} from 'node:process'; window.addEventListener("DOMContentLoaded", () => { const replaceText = (selector: string, text: string) => { @@ -10,17 +11,24 @@ window.addEventListener("DOMContentLoaded", () => { }; for (const dependency of ["chrome", "node", "electron"]) { - replaceText(`${dependency}-version`, process.versions[dependency]); + replaceText(`${dependency}-version`, versions[dependency]); } }); -type SendChannels = "toMain" | "open-game" | "save-user-data" | "return-select" | "app-version" | "cache-path" | "clear-cache"; +type SendChannels = + "toMain" + | "open-game" + | "save-user-data" + | "return-select" + | "app-version" + | "cache-path" + | "clear-cache"; type ReceiveChannels = "fromMain" | "save-user-data" | "app-version" | "cache-path"; type RequestChannels = "app-version" | "cache-path" | "get-user-data"; type SendOnChannel = (channel: SendChannels, data?: number | string | SaveUserData) => void; -type ReceiveOnChannel = ((channel: ReceiveChannels, func: (...args: any[]) => void) => void) -type RequestOnChannel = ((channel: RequestChannels, ...args: any[]) => Promise) +type ReceiveOnChannel = ((channel: ReceiveChannels, func: (...args: unknown[]) => void) => void) +type RequestOnChannel = ((channel: RequestChannels, ...args: unknown[]) => Promise) export type ContextBridgeApi = { send: SendOnChannel; @@ -28,7 +36,7 @@ export type ContextBridgeApi = { request: RequestOnChannel; } const exposedApi: ContextBridgeApi = { - request: (channel: RequestChannels, ...args: any[]): Promise => { + request: (channel: RequestChannels, ...args: unknown[]): Promise => { if (channel === "get-user-data") { if (args.length !== 1 || typeof args[0] !== "string") throw new Error("Invalid arguments for get-user-data"); @@ -46,9 +54,9 @@ const exposedApi: ContextBridgeApi = { throw new Error("No arguments allowed for cache-path"); return ipcRenderer.invoke(channel) as Promise; } - return ipcRenderer.invoke(channel, ...args); + return ipcRenderer.invoke(channel, ...args); }, - receive: (channel: ReceiveChannels, func: (...args: any[]) => void) => { + receive: (channel: ReceiveChannels, func: (...args: unknown[]) => void) => { // Deliberately strip event as it includes `sender` ipcRenderer.on(channel, (event, ...args) => func(...args)); }, diff --git a/src/renderer.ts b/src/renderer.ts index c5c9419..420762e 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -1,3 +1,5 @@ +// noinspection JSIgnoredPromiseFromCall + import './style.css'; let appVersion: string; diff --git a/src/style.css b/src/style.css index 1eb3f65..b4fa50d 100644 --- a/src/style.css +++ b/src/style.css @@ -76,8 +76,7 @@ input[type=checkbox]:after { display: block; width: 30px; height: 30px; - border: solid #FFCB9A; - border-width: 0 0px 0px 0; + border: 0 solid #FFCB9A; } input[type=checkbox]:checked:after { @@ -194,7 +193,7 @@ table, th, td { border-collapse: collapse; } -.menu-container{ +.menu-container { display: flex; align-items: center; justify-content: center; @@ -206,7 +205,7 @@ table, th, td { gap: 1rem; } -.field{ +.field { display: flex; justify-content: space-between; } @@ -217,7 +216,7 @@ table, th, td { box-shadow: 0 0 5px black; } -.help td{ +.help td { padding: 0.3rem 0.5rem; } @@ -226,6 +225,7 @@ table, th, td { top: 2rem; right: 2rem; } + .app-configuration { box-shadow: 0 0 5px black; display: flex; @@ -237,13 +237,13 @@ table, th, td { pointer-events: all; } -.update-available{ +.update-available { position: absolute; bottom: 0; left: 0; } -.update-available a{ +.update-available a { font-size: 1rem; color: var(--color-accent); } diff --git a/src/window.d.ts b/src/window.d.ts index 4d094cf..1ca5772 100644 --- a/src/window.d.ts +++ b/src/window.d.ts @@ -1,4 +1,6 @@ -import type { ContextBridgeApi } from './preload' +// noinspection JSUnusedGlobalSymbols + +import type {ContextBridgeApi} from './preload' declare global { interface Window { diff --git a/vite.main.config.ts b/vite.main.config.ts index 23ded1e..8ef80b8 100644 --- a/vite.main.config.ts +++ b/vite.main.config.ts @@ -1,10 +1,11 @@ -import { defineConfig } from 'vite'; +// noinspection JSUnusedGlobalSymbols + +import {defineConfig} from 'vite'; // https://vitejs.dev/config export default defineConfig({ resolve: { // Some libs that can run in both Web and Node.js, such as `axios`, we need to tell Vite to build them in Node.js. - browserField: false, mainFields: ['module', 'jsnext:main', 'jsnext'], }, }); \ No newline at end of file diff --git a/vite.preload.config.ts b/vite.preload.config.ts index cb271aa..887360f 100644 --- a/vite.preload.config.ts +++ b/vite.preload.config.ts @@ -1,4 +1,6 @@ -import { defineConfig } from 'vite'; +// noinspection JSUnusedGlobalSymbols + +import {defineConfig} from 'vite'; // https://vitejs.dev/config export default defineConfig({}); \ No newline at end of file diff --git a/vite.renderer.config.ts b/vite.renderer.config.ts index cb271aa..887360f 100644 --- a/vite.renderer.config.ts +++ b/vite.renderer.config.ts @@ -1,4 +1,6 @@ -import { defineConfig } from 'vite'; +// noinspection JSUnusedGlobalSymbols + +import {defineConfig} from 'vite'; // https://vitejs.dev/config export default defineConfig({}); \ No newline at end of file