diff --git a/.editorconfig b/.editorconfig index acb0460..0b0b41a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,10 @@ insert_final_newline = true indent_style = space indent_size = 2 +[**.ts] +indent_style = space +indent_size = 2 + [**.json] indent_style = space indent_size = 2 @@ -50,4 +54,4 @@ trim_trailing_whitespace = ignore charset = ignore [{test/fixtures,deps,tools/eslint,tools/gyp,tools/icu,tools/msvs}/**] -insert_final_newline = false \ No newline at end of file +insert_final_newline = false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44d728f..152d5fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,10 @@ on: branches-ignore: - master - develop + pull_request: + branches-ignore: + - master + - develop jobs: build_on_linux: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8bda4ca..e934f81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ on: branches: - master - develop + pull_request: + branches: + - master + jobs: build_on_linux: runs-on: ubuntu-latest @@ -16,7 +20,7 @@ jobs: - uses: actions/checkout@master - uses: actions/setup-node@master with: - node-version: 16 + node-version: 19 - run: npm install - run: npm run build - uses: actions/upload-artifact@master @@ -25,12 +29,12 @@ jobs: path: dist/ build_on_mac: - runs-on: macOS-latest + runs-on: macos-latest steps: - uses: actions/checkout@master - uses: actions/setup-node@master with: - node-version: 16 + node-version: 19 - run: npm install - run: npm run build - uses: actions/upload-artifact@master @@ -44,7 +48,7 @@ jobs: - uses: actions/checkout@master - uses: actions/setup-node@master with: - node-version: 16 + node-version: 19 - run: npm install - run: npm run build - uses: actions/upload-artifact@master diff --git a/src/constants/flags.ts b/src/constants/flags.ts index 64c36ae..7968aff 100644 --- a/src/constants/flags.ts +++ b/src/constants/flags.ts @@ -1,4 +1,4 @@ -export const flags: { [key: string]: { flag: string; value?: any }[] } = { +export const flags: { [key: string]: { flag: string; value?: string }[] } = { gpuRasterization: [{ flag: "enable-gpu-rasterization", value: undefined }], disableHardwareMediaKeys: [{ flag: "disable-features", value: "HardwareMediaKeyHandling" }], }; diff --git a/src/preload.ts b/src/preload.ts index cc6a682..a3d7d31 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -14,7 +14,7 @@ import { setTitle } from "./scripts/window-functions"; const notificationPath = `${app.getPath("userData")}/notification.jpg`; const appName = "Tidal Hifi"; let currentSong = ""; -let player: any; +let player: Player; let currentPlayStatus = statuses.paused; const elements = { diff --git a/src/scripts/express.ts b/src/scripts/express.ts index 6097a6f..68c9fd8 100644 --- a/src/scripts/express.ts +++ b/src/scripts/express.ts @@ -18,7 +18,7 @@ export const startExpress = (mainWindow: BrowserWindow) => { * @param {*} res * @param {*} action */ - function handleGlobalEvent(res: Response, action: any) { + function handleGlobalEvent(res: Response, action: string) { mainWindow.webContents.send("globalEvent", action); res.sendStatus(200); } diff --git a/src/scripts/settings.ts b/src/scripts/settings.ts index b20b6ae..9fa27b4 100644 --- a/src/scripts/settings.ts +++ b/src/scripts/settings.ts @@ -67,7 +67,7 @@ export const createSettingsWindow = function () { }, }); - settingsWindow.on("close", (event: any) => { + settingsWindow.on("close", (event: Event) => { if (settingsWindow != null) { event.preventDefault(); settingsWindow.hide(); diff --git a/src/types/mpris-service.d.ts b/src/types/mpris-service.d.ts new file mode 100644 index 0000000..40bf530 --- /dev/null +++ b/src/types/mpris-service.d.ts @@ -0,0 +1,60 @@ +declare class InitOptions { + name: string; + identity: string; + supportedUriSchemes: string[]; + supportedMimeTypes: string[]; + supportedInterfaces: string[]; + desktopEntry: string; +} + +declare class Player { + metadata: { + "xesam:title": string; + "xesam:artist": string[]; + "xesam:album": string; + "mpris:artUrl": string; + "mpris:length": number; + "mpris:trackid": string; + // other options + [key: string]: string | number | string[] | object; + }; + playbackStatus: string; + identity: string; + fullscreen: boolean; + supportedUriSchemes: string[]; + supportedMimeTypes: string[]; + canQuit: boolean; + canRaise: boolean; + canSetFullscreen: boolean; + hasTrackList: boolean; + desktopEntry: string; + loopStatus: string; + shuffle: boolean; + volume: number; + canControl: boolean; + canPause: boolean; + canPlay: boolean; + canSeek: boolean; + canGoNext: boolean; + canGoPrevious: boolean; + rate: number; + minimumRate: number; + maximumRate: number; + playlists: string[]; + activePlaylist: string; + + constructor(opts: { name: string; supportedInterfaces?: string[] }); + constructor(opts: InitOptions); + + getPosition(): number; + seeked(): void; + getTrackIndex(trackId: number): number; + getTrack(trackId: number): string; + addTrack(track: object): void; + removeTrack(trackId: number): number; + getPlaylistIndex(playlistId: number): number; + setPlaylists(playlists: object): void; + setActivePlaylist(playlistId: number): void; + + on(event: string | symbol, listener: (...args: object[]) => void): this; +} diff --git a/tsconfig.json b/tsconfig.json index 2343e42..25baf7d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "typeRoots": ["src/types"], "module": "commonjs", "target": "ES6", "noImplicitAny": true,