diff --git a/src/main/features/core/remote/index.ts b/src/main/features/core/remote/index.ts index fe3f80684..0a73c019d 100644 --- a/src/main/features/core/remote/index.ts +++ b/src/main/features/core/remote/index.ts @@ -11,8 +11,8 @@ import manifest from './manifest.json'; import { getMainWindow } from '/@/main/index'; import { isLinux } from '/@/main/utils'; -import { QueueSong } from '/@/shared/types/domain-types'; -import { ClientEvent, ServerEvent } from '/@/shared/types/remote-types'; +import { QueueSong } from '/@/shared/types/domain/player-domain-types'; +import { ClientEvent, ServerEvent } from '/@/shared/types/domain/remote-types'; import { PlayerRepeat, PlayerStatus, SongState } from '/@/shared/types/types'; let mprisPlayer: any | undefined; diff --git a/src/main/features/linux/mpris.ts b/src/main/features/linux/mpris.ts index 035db8e7f..9bfdcffe6 100644 --- a/src/main/features/linux/mpris.ts +++ b/src/main/features/linux/mpris.ts @@ -2,7 +2,7 @@ import { ipcMain } from 'electron'; import Player from 'mpris-service'; import { getMainWindow } from '/@/main/index'; -import { QueueSong } from '/@/shared/types/domain-types'; +import { QueueSong } from '/@/shared/types/domain/player-domain-types'; import { PlayerRepeat, PlayerStatus } from '/@/shared/types/types'; const mprisPlayer = Player({ diff --git a/src/preload/lyrics.ts b/src/preload/lyrics.ts index b69ab3842..060d1fa57 100644 --- a/src/preload/lyrics.ts +++ b/src/preload/lyrics.ts @@ -7,7 +7,7 @@ import { LyricSource, } from '../main/features/core/lyrics'; -import { QueueSong } from '/@/shared/types/domain-types'; +import { QueueSong } from '/@/shared/types/domain/player-domain-types'; const getRemoteLyricsBySong = (song: QueueSong) => { const result = ipcRenderer.invoke('lyric-by-song', song); diff --git a/src/preload/mpv-player.ts b/src/preload/mpv-player.ts index b393fca5c..9dba41d5a 100644 --- a/src/preload/mpv-player.ts +++ b/src/preload/mpv-player.ts @@ -1,6 +1,6 @@ import { ipcRenderer, IpcRendererEvent } from 'electron'; -import { PlayerData } from '/@/shared/types/domain-types'; +import { PlayerData } from '/@/shared/types/domain/player-domain-types'; const initialize = (data: { extraParameters?: string[]; properties?: Record }) => { return ipcRenderer.invoke('player-initialize', data); diff --git a/src/preload/remote.ts b/src/preload/remote.ts index dd5f348e9..848fddd63 100644 --- a/src/preload/remote.ts +++ b/src/preload/remote.ts @@ -1,6 +1,6 @@ import { ipcRenderer, IpcRendererEvent } from 'electron'; -import { QueueSong } from '/@/shared/types/domain-types'; +import { QueueSong, QueueSong } from '/@/shared/types/domain/player-domain-types'; import { PlayerStatus } from '/@/shared/types/types'; const requestFavorite = ( diff --git a/src/renderer/api/jellyfin/jellyfin-api.ts b/src/renderer/api/jellyfin/jellyfin-api.ts index a204e109b..22eb9d479 100644 --- a/src/renderer/api/jellyfin/jellyfin-api.ts +++ b/src/renderer/api/jellyfin/jellyfin-api.ts @@ -11,7 +11,7 @@ import { authenticationFailure } from '/@/renderer/api/utils'; import { useAuthStore } from '/@/renderer/store'; import { jfType } from '/@/shared/api/jellyfin/jellyfin-types'; import { getClientType } from '/@/shared/api/utils'; -import { ServerListItem } from '/@/shared/types/domain-types'; +import { ServerListItem } from '/@/shared/types/domain/server-domain-types'; const c = initContract(); diff --git a/src/renderer/api/jellyfin/jellyfin-controller.ts b/src/renderer/api/jellyfin/jellyfin-controller.ts index 6aaff4329..5743fec9e 100644 --- a/src/renderer/api/jellyfin/jellyfin-controller.ts +++ b/src/renderer/api/jellyfin/jellyfin-controller.ts @@ -6,19 +6,15 @@ import { JFSongListSort, JFSortOrder } from '/@/shared/api/jellyfin.types'; import { jfNormalize } from '/@/shared/api/jellyfin/jellyfin-normalize'; import { jfType } from '/@/shared/api/jellyfin/jellyfin-types'; import { getFeatures, hasFeature, VersionInfo } from '/@/shared/api/utils'; -import { - albumArtistListSortMap, - albumListSortMap, - ControllerEndpoint, - genreListSortMap, - LibraryItem, - Played, - playlistListSortMap, - Song, - songListSortMap, - sortOrderMap, -} from '/@/shared/types/domain-types'; -import { ServerFeature } from '/@/shared/types/features-types'; +import { albumListSortMap } from '/@/shared/types/domain/album-domain-types'; +import { ControllerEndpoint } from '/@/shared/types/domain/api-domain-types'; +import { albumArtistListSortMap } from '/@/shared/types/domain/artist-domain-types'; +import { genreListSortMap } from '/@/shared/types/domain/genre-domain-types'; +import { Played } from '/@/shared/types/domain/player-domain-types'; +import { playlistListSortMap } from '/@/shared/types/domain/playlist-domain-types'; +import { ServerFeature } from '/@/shared/types/domain/server-domain-types'; +import { LibraryItem, sortOrderMap } from '/@/shared/types/domain/shared-domain-types'; +import { Song, songListSortMap } from '/@/shared/types/domain/song-domain-types'; const formatCommaDelimitedString = (value: string[]) => { return value.join(','); diff --git a/src/renderer/api/navidrome/navidrome-api.ts b/src/renderer/api/navidrome/navidrome-api.ts index 34b24db0a..ed00623d1 100644 --- a/src/renderer/api/navidrome/navidrome-api.ts +++ b/src/renderer/api/navidrome/navidrome-api.ts @@ -11,7 +11,7 @@ import { useAuthStore } from '/@/renderer/store'; import { ndType } from '/@/shared/api/navidrome/navidrome-types'; import { resultWithHeaders } from '/@/shared/api/utils'; import { toast } from '/@/shared/components/toast/toast'; -import { ServerListItem } from '/@/shared/types/domain-types'; +import { ServerListItem } from '/@/shared/types/domain/server-domain-types'; const localSettings = isElectron() ? window.api.localSettings : null; diff --git a/src/renderer/api/navidrome/navidrome-controller.ts b/src/renderer/api/navidrome/navidrome-controller.ts index 27e31e54f..e8fb1689d 100644 --- a/src/renderer/api/navidrome/navidrome-controller.ts +++ b/src/renderer/api/navidrome/navidrome-controller.ts @@ -7,22 +7,24 @@ import { ndType } from '/@/shared/api/navidrome/navidrome-types'; import { ssNormalize } from '/@/shared/api/subsonic/subsonic-normalize'; import { SubsonicExtensions } from '/@/shared/api/subsonic/subsonic-types'; import { getFeatures, hasFeature, VersionInfo } from '/@/shared/api/utils'; +import { albumListSortMap } from '/@/shared/types/domain/album-domain-types'; +import { ControllerEndpoint } from '/@/shared/types/domain/api-domain-types'; +import { albumArtistListSortMap } from '/@/shared/types/domain/artist-domain-types'; +import { AuthenticationResponse } from '/@/shared/types/domain/auth-domain-types'; +import { genreListSortMap } from '/@/shared/types/domain/genre-domain-types'; import { - albumArtistListSortMap, - albumListSortMap, - AuthenticationResponse, - ControllerEndpoint, - genreListSortMap, playlistListSortMap, PlaylistSongListArgs, PlaylistSongListResponse, +} from '/@/shared/types/domain/playlist-domain-types'; +import { + ServerFeature, + ServerFeatures, ServerListItem, - Song, - songListSortMap, - sortOrderMap, - userListSortMap, -} from '/@/shared/types/domain-types'; -import { ServerFeature, ServerFeatures } from '/@/shared/types/features-types'; +} from '/@/shared/types/domain/server-domain-types'; +import { sortOrderMap } from '/@/shared/types/domain/shared-domain-types'; +import { Song, songListSortMap } from '/@/shared/types/domain/song-domain-types'; +import { userListSortMap } from '/@/shared/types/domain/user-domain-types'; const VERSION_INFO: VersionInfo = [ ['0.55.0', { [ServerFeature.BFR]: [1] }], diff --git a/src/renderer/api/subsonic/subsonic-api.ts b/src/renderer/api/subsonic/subsonic-api.ts index 0e7b09135..b087a7f38 100644 --- a/src/renderer/api/subsonic/subsonic-api.ts +++ b/src/renderer/api/subsonic/subsonic-api.ts @@ -7,7 +7,7 @@ import { z } from 'zod'; import i18n from '/@/i18n/i18n'; import { ssType } from '/@/shared/api/subsonic/subsonic-types'; import { toast } from '/@/shared/components/toast/toast'; -import { ServerListItem } from '/@/shared/types/domain-types'; +import { ServerListItem } from '/@/shared/types/domain/server-domain-types'; const c = initContract(); diff --git a/src/renderer/api/subsonic/subsonic-controller.ts b/src/renderer/api/subsonic/subsonic-controller.ts index 12fa23993..65b6b79c0 100644 --- a/src/renderer/api/subsonic/subsonic-controller.ts +++ b/src/renderer/api/subsonic/subsonic-controller.ts @@ -14,19 +14,14 @@ import { ssType, SubsonicExtensions, } from '/@/shared/api/subsonic/subsonic-types'; -import { - AlbumListSort, - ControllerEndpoint, - GenreListSort, - LibraryItem, - PlaylistListSort, - Song, - sortAlbumArtistList, - sortAlbumList, - SortOrder, - sortSongList, -} from '/@/shared/types/domain-types'; -import { ServerFeatures } from '/@/shared/types/features-types'; +import { AlbumListSort, sortAlbumList } from '/@/shared/types/domain/album-domain-types'; +import { ControllerEndpoint } from '/@/shared/types/domain/api-domain-types'; +import { sortAlbumArtistList } from '/@/shared/types/domain/artist-domain-types'; +import { GenreListSort } from '/@/shared/types/domain/genre-domain-types'; +import { PlaylistListSort } from '/@/shared/types/domain/playlist-domain-types'; +import { ServerFeatures } from '/@/shared/types/domain/server-domain-types'; +import { LibraryItem, ListSortOrder } from '/@/shared/types/domain/shared-domain-types'; +import { Song, sortSongList } from '/@/shared/types/domain/song-domain-types'; const ALBUM_LIST_SORT_MAPPING: Record = { [AlbumListSort.ALBUM_ARTIST]: AlbumListSortType.ALPHABETICAL_BY_ARTIST, @@ -381,7 +376,7 @@ export const SubsonicController: ControllerEndpoint = { } if (type === AlbumListSortType.BY_YEAR && !fromYear && !toYear) { - if (query.sortOrder === SortOrder.ASC) { + if (query.sortOrder === ListSortOrder.ASC) { fromYear = 0; toYear = dayjs().year(); } else { diff --git a/src/shared/api/jellyfin/jellyfin-normalize.ts b/src/shared/api/jellyfin/jellyfin-normalize.ts index 7af54bbf1..d3b6ae0fa 100644 --- a/src/shared/api/jellyfin/jellyfin-normalize.ts +++ b/src/shared/api/jellyfin/jellyfin-normalize.ts @@ -13,6 +13,7 @@ import { ServerMusicFolder, ServerType, } from '/@/shared/types/domain/server-domain-types'; +import { LibraryItem } from '/@/shared/types/domain/shared-domain-types'; import { Song } from '/@/shared/types/domain/song-domain-types'; const getStreamUrl = (args: { diff --git a/src/shared/api/navidrome/navidrome-normalize.ts b/src/shared/api/navidrome/navidrome-normalize.ts index 1fb768add..f3e6ce3b6 100644 --- a/src/shared/api/navidrome/navidrome-normalize.ts +++ b/src/shared/api/navidrome/navidrome-normalize.ts @@ -10,6 +10,7 @@ import { AlbumArtist, RelatedArtist } from '/@/shared/types/domain/artist-domain import { Genre } from '/@/shared/types/domain/genre-domain-types'; import { Playlist } from '/@/shared/types/domain/playlist-domain-types'; import { ServerListItem, ServerType } from '/@/shared/types/domain/server-domain-types'; +import { LibraryItem } from '/@/shared/types/domain/shared-domain-types'; import { Song } from '/@/shared/types/domain/song-domain-types'; import { User } from '/@/shared/types/domain/user-domain-types'; diff --git a/src/shared/api/subsonic/subsonic-normalize.ts b/src/shared/api/subsonic/subsonic-normalize.ts index 267d12bcf..6dbb01ffb 100644 --- a/src/shared/api/subsonic/subsonic-normalize.ts +++ b/src/shared/api/subsonic/subsonic-normalize.ts @@ -2,12 +2,13 @@ import { nanoid } from 'nanoid'; import { z } from 'zod'; import { ssType } from '/@/shared/api/subsonic/subsonic-types'; -import { LibraryItem, QueueSong } from '/@/shared/types/domain-types'; import { Album } from '/@/shared/types/domain/album-domain-types'; import { AlbumArtist, RelatedArtist } from '/@/shared/types/domain/artist-domain-types'; import { Genre } from '/@/shared/types/domain/genre-domain-types'; +import { QueueSong } from '/@/shared/types/domain/player-domain-types'; import { Playlist } from '/@/shared/types/domain/playlist-domain-types'; import { ServerListItem, ServerType } from '/@/shared/types/domain/server-domain-types'; +import { LibraryItem } from '/@/shared/types/domain/shared-domain-types'; const getCoverArtUrl = (args: { baseUrl: string | undefined; diff --git a/src/shared/api/utils.ts b/src/shared/api/utils.ts index 568b84b20..bd24f3d12 100644 --- a/src/shared/api/utils.ts +++ b/src/shared/api/utils.ts @@ -4,8 +4,7 @@ import semverCoerce from 'semver/functions/coerce'; import semverGte from 'semver/functions/gte'; import { z } from 'zod'; -import { ServerListItem } from '/@/shared/types/domain/server-domain-types'; -import { ServerFeature } from '/@/shared/types/features-types'; +import { ServerFeature, ServerListItem } from '/@/shared/types/domain/server-domain-types'; // Since ts-rest client returns a strict response type, we need to add the headers to the body object export const resultWithHeaders = (itemSchema: ItemType) => { diff --git a/src/shared/types/drag-and-drop.ts b/src/shared/types/drag-and-drop.ts index 169855b1c..e2648cce7 100644 --- a/src/shared/types/drag-and-drop.ts +++ b/src/shared/types/drag-and-drop.ts @@ -1,6 +1,6 @@ import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'; -import { LibraryItem } from '/@/shared/types/domain-types'; +import { LibraryItem } from '/@/shared/types/domain/shared-domain-types'; export enum DragTarget { ALBUM = LibraryItem.ALBUM, diff --git a/src/shared/types/remote-types.ts b/src/shared/types/remote-types.ts deleted file mode 100644 index f1f5b2777..000000000 --- a/src/shared/types/remote-types.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { QueueSong } from '/@/shared/types/domain-types'; -import { PlayerRepeat, PlayerStatus, SongState } from '/@/shared/types/types'; - -export interface ClientAuth { - event: 'authenticate'; - header: string; -} - -export type ClientEvent = - | ClientAuth - | ClientFavorite - | ClientPosition - | ClientRating - | ClientSimpleEvent - | ClientVolume; - -export interface ClientFavorite { - event: 'favorite'; - favorite: boolean; - id: string; -} - -export interface ClientPosition { - event: 'position'; - position: number; -} - -export interface ClientRating { - event: 'rating'; - id: string; - rating: number; -} -export interface ClientSimpleEvent { - event: 'next' | 'pause' | 'play' | 'previous' | 'proxy' | 'repeat' | 'shuffle'; -} - -export interface ClientVolume { - event: 'volume'; - volume: number; -} - -export interface ServerError { - data: string; - event: 'error'; -} - -export type ServerEvent = - | ServerError - | ServerFavorite - | ServerPlayStatus - | ServerPosition - | ServerProxy - | ServerRating - | ServerRepeat - | ServerShuffle - | ServerSong - | ServerState - | ServerVolume; - -export interface ServerFavorite { - data: { favorite: boolean; id: string }; - event: 'favorite'; -} - -export interface ServerPlayStatus { - data: PlayerStatus; - event: 'playback'; -} - -export interface ServerPosition { - data: number; - event: 'position'; -} - -export interface ServerProxy { - data: string; - event: 'proxy'; -} - -export interface ServerRating { - data: { id: string; rating: number }; - event: 'rating'; -} - -export interface ServerRepeat { - data: PlayerRepeat; - event: 'repeat'; -} - -export interface ServerShuffle { - data: boolean; - event: 'shuffle'; -} - -export interface ServerSong { - data: null | QueueSong; - event: 'song'; -} - -export interface ServerState { - data: SongState; - event: 'state'; -} - -export interface ServerVolume { - data: number; - event: 'volume'; -} - -export interface SongUpdateSocket extends Omit { - position?: number; - song?: null | QueueSong; -} diff --git a/src/shared/types/types.ts b/src/shared/types/types.ts index c0eac335e..ca5992de0 100644 --- a/src/shared/types/types.ts +++ b/src/shared/types/types.ts @@ -2,11 +2,12 @@ import { AppRoute } from '@ts-rest/core'; import { ReactNode } from 'react'; import { Song } from 'src/main/features/core/lyrics/netease'; -import { LibraryItem, QueueSong } from '/@/shared/types/domain-types'; import { Album } from '/@/shared/types/domain/album-domain-types'; import { AlbumArtist, Artist } from '/@/shared/types/domain/artist-domain-types'; +import { QueueSong } from '/@/shared/types/domain/player-domain-types'; import { Playlist } from '/@/shared/types/domain/playlist-domain-types'; import { ServerType } from '/@/shared/types/domain/server-domain-types'; +import { LibraryItem } from '/@/shared/types/domain/shared-domain-types'; export enum ListDisplayType { CARD = 'card',