From d823f07ed897ef44bd634179ac85c4f947c1d9ed Mon Sep 17 00:00:00 2001 From: Mastermindzh Date: Sun, 7 May 2023 16:13:30 +0200 Subject: [PATCH] last files transformed from js -> ts --- src/constants/{flags.js => flags.ts} | 4 +--- src/constants/{globalEvents.js => globalEvents.ts} | 4 +--- src/constants/{mediaKeys.js => mediaKeys.ts} | 6 ++---- src/constants/{statuses.js => statuses.ts} | 2 +- src/constants/{values.js => values.ts} | 2 +- src/main.ts | 12 ++++++------ src/pages/settings/preload.ts | 2 +- src/preload.ts | 6 +++--- src/scripts/discord.ts | 2 +- src/scripts/express.ts | 4 ++-- src/scripts/mediaInfo.ts | 2 +- src/scripts/menu.ts | 4 ++-- 12 files changed, 22 insertions(+), 28 deletions(-) rename src/constants/{flags.js => flags.ts} (70%) rename src/constants/{globalEvents.js => globalEvents.ts} (83%) rename src/constants/{mediaKeys.js => mediaKeys.ts} (56%) rename src/constants/{statuses.js => statuses.ts} (63%) rename src/constants/{values.js => values.ts} (56%) diff --git a/src/constants/flags.js b/src/constants/flags.ts similarity index 70% rename from src/constants/flags.js rename to src/constants/flags.ts index 88813ae..64c36ae 100644 --- a/src/constants/flags.js +++ b/src/constants/flags.ts @@ -1,6 +1,4 @@ -const flags = { +export const flags: { [key: string]: { flag: string; value?: any }[] } = { gpuRasterization: [{ flag: "enable-gpu-rasterization", value: undefined }], disableHardwareMediaKeys: [{ flag: "disable-features", value: "HardwareMediaKeyHandling" }], }; - -module.exports = flags; diff --git a/src/constants/globalEvents.js b/src/constants/globalEvents.ts similarity index 83% rename from src/constants/globalEvents.js rename to src/constants/globalEvents.ts index c330be4..b60b5c9 100644 --- a/src/constants/globalEvents.js +++ b/src/constants/globalEvents.ts @@ -1,4 +1,4 @@ -const globalEvents = { +export const globalEvents = { play: "play", pause: "pause", playPause: "playPause", @@ -11,5 +11,3 @@ const globalEvents = { storeChanged: "storeChanged", error: "error", }; - -module.exports = globalEvents; diff --git a/src/constants/mediaKeys.js b/src/constants/mediaKeys.ts similarity index 56% rename from src/constants/mediaKeys.js rename to src/constants/mediaKeys.ts index cc0828a..ba8b719 100644 --- a/src/constants/mediaKeys.js +++ b/src/constants/mediaKeys.ts @@ -1,9 +1,7 @@ -const globalEvents = require("./globalEvents"); +import { globalEvents } from "./globalEvents"; -const mediaKeys = { +export const mediaKeys = { MediaPlayPause: globalEvents.playPause, MediaNextTrack: globalEvents.next, MediaPreviousTrack: globalEvents.previous, }; - -module.exports = mediaKeys; diff --git a/src/constants/statuses.js b/src/constants/statuses.ts similarity index 63% rename from src/constants/statuses.js rename to src/constants/statuses.ts index 33ae17a..3209307 100644 --- a/src/constants/statuses.js +++ b/src/constants/statuses.ts @@ -1,4 +1,4 @@ -module.exports = { +export const statuses = { playing: "playing", paused: "paused", }; diff --git a/src/constants/values.js b/src/constants/values.ts similarity index 56% rename from src/constants/values.js rename to src/constants/values.ts index 267a8b4..a4e2764 100644 --- a/src/constants/values.js +++ b/src/constants/values.ts @@ -1,3 +1,3 @@ -module.exports = { +export default { name: "tidal-hifi", }; diff --git a/src/main.ts b/src/main.ts index 9d7ea4f..6a040e7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,9 +9,9 @@ import { session, } from "electron"; import path from "path"; -import flagValues from "./constants/flags"; -import globalEvents from "./constants/globalEvents"; -import mediaKeys from "./constants/mediaKeys"; +import { flags } from "./constants/flags"; +import { globalEvents } from "./constants/globalEvents"; +import { mediaKeys } from "./constants/mediaKeys"; import { initRPC, rpc, unRPC } from "./scripts/discord"; import { startExpress } from "./scripts/express"; import { updateMediaInfo } from "./scripts/mediaInfo"; @@ -37,11 +37,11 @@ const PROTOCOL_PREFIX = "tidal"; setFlags(); function setFlags() { - const flags = settingsStore.get(settings.flags.root); - if (flags) { + const flagsFromSettings = settingsStore.get(settings.flags.root); + if (flagsFromSettings) { for (const [key, value] of Object.entries(flags)) { if (value) { - (flagValues as any)[key].forEach((flag: any) => { + flags[key].forEach((flag) => { console.log(`enabling command line switch ${flag.flag} with value ${flag.value}`); app.commandLine.appendSwitch(flag.flag, flag.value); }); diff --git a/src/pages/settings/preload.ts b/src/pages/settings/preload.ts index c2e569d..fb64769 100644 --- a/src/pages/settings/preload.ts +++ b/src/pages/settings/preload.ts @@ -1,6 +1,6 @@ import remote from "@electron/remote"; import { ipcRenderer, shell } from "electron"; -import globalEvents from "../../constants/globalEvents"; +import { globalEvents } from "../../constants/globalEvents"; import { settings } from "../../constants/settings"; import { settingsStore } from "./../../scripts/settings"; diff --git a/src/preload.ts b/src/preload.ts index 5e17004..f35474f 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -1,15 +1,15 @@ import { Notification, app, dialog } from "@electron/remote"; import { ipcRenderer } from "electron"; import Player from "mpris-service"; -import globalEvents from "./constants/globalEvents"; +import { globalEvents } from "./constants/globalEvents"; import { settings } from "./constants/settings"; -import statuses from "./constants/statuses"; +import { statuses } from "./constants/statuses"; import { Options } from "./models/options"; import { downloadFile } from "./scripts/download"; import { addHotkey } from "./scripts/hotkeys"; -import { setTitle } from "./scripts/window-functions"; import { settingsStore } from "./scripts/settings"; +import { setTitle } from "./scripts/window-functions"; const notificationPath = `${app.getPath("userData")}/notification.jpg`; const appName = "Tidal Hifi"; let currentSong = ""; diff --git a/src/scripts/discord.ts b/src/scripts/discord.ts index 4d07a21..909c5b8 100644 --- a/src/scripts/discord.ts +++ b/src/scripts/discord.ts @@ -1,6 +1,6 @@ import { Client } from "discord-rpc"; import { app, ipcMain } from "electron"; -import globalEvents from "../constants/globalEvents"; +import { globalEvents } from "../constants/globalEvents"; import { MediaStatus } from "../models/mediaStatus"; import { mediaInfo } from "./mediaInfo"; diff --git a/src/scripts/express.ts b/src/scripts/express.ts index 3667621..6097a6f 100644 --- a/src/scripts/express.ts +++ b/src/scripts/express.ts @@ -1,8 +1,8 @@ import { BrowserWindow, dialog } from "electron"; import express, { Response } from "express"; import fs from "fs"; -import globalEvents from "./../constants/globalEvents"; -import statuses from "./../constants/statuses"; +import { globalEvents } from "./../constants/globalEvents"; +import { statuses } from "./../constants/statuses"; import { mediaInfo } from "./mediaInfo"; import { settingsStore } from "./settings"; import { settings } from "../constants/settings"; diff --git a/src/scripts/mediaInfo.ts b/src/scripts/mediaInfo.ts index e35f7cc..1341a08 100644 --- a/src/scripts/mediaInfo.ts +++ b/src/scripts/mediaInfo.ts @@ -1,5 +1,5 @@ import { MediaInfo } from "../models/mediaInfo"; -import statuses from "./../constants/statuses"; +import { statuses } from "./../constants/statuses"; export const mediaInfo = { title: "", diff --git a/src/scripts/menu.ts b/src/scripts/menu.ts index 9319b42..786842b 100644 --- a/src/scripts/menu.ts +++ b/src/scripts/menu.ts @@ -1,7 +1,7 @@ import { BrowserWindow, Menu, app } from "electron"; -const { showSettingsWindow } = require("./settings"); +import { showSettingsWindow } from "./settings"; const isMac = process.platform === "darwin"; -const { name } = require("./../constants/values"); +import name from "./../constants/values"; const settingsMenuEntry = { label: "Settings",