chore(deps); update and migrate to latest node and cargo packages
This commit is contained in:
100 files changed
+7417
-8802
No files matched your search
@@ -7,12 +7,11 @@ import {
|
||||
LocationType,
|
||||
SortOrder,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { getMediaSegmentApi } from "@jellyfin/sdk/lib/utils/api/media-segment-api";
|
||||
import { getPlaylistApi } from "@jellyfin/sdk/lib/utils/api/playlist-api";
|
||||
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
||||
import playbackProfile from "@/utils/playback-profiles";
|
||||
|
||||
export async function getNextEpisode(
|
||||
@@ -22,7 +21,7 @@ export async function getNextEpisode(
|
||||
season: number,
|
||||
) {
|
||||
const episode = (
|
||||
await getTvShowsApi(api).getEpisodes({
|
||||
await getShowApi(api).getEpisodes({
|
||||
seriesId: seriesId,
|
||||
userId: userId,
|
||||
enableUserData: true,
|
||||
@@ -36,7 +35,7 @@ export async function getNextEpisode(
|
||||
}
|
||||
|
||||
const allEpisodes = (
|
||||
await getTvShowsApi(api).getEpisodes({
|
||||
await getShowApi(api).getEpisodes({
|
||||
seriesId: seriesId,
|
||||
userId: userId,
|
||||
enableUserData: true,
|
||||
@@ -79,7 +78,7 @@ export async function getPlaybackInfo(
|
||||
let index = 0;
|
||||
|
||||
if (playlistItem && playlistItemId) {
|
||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||
result = await getPlaylistApi(api).getPlaylistItems({
|
||||
userId: userId,
|
||||
playlistId: playlistItemId,
|
||||
});
|
||||
@@ -87,7 +86,7 @@ export async function getPlaybackInfo(
|
||||
switch (item.Type) {
|
||||
case BaseItemKind.Episode:
|
||||
if (item.SeriesId && item.SeasonId) {
|
||||
result = await getTvShowsApi(api).getEpisodes({
|
||||
result = await getShowApi(api).getEpisodes({
|
||||
seriesId: item.SeriesId,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
@@ -116,7 +115,7 @@ export async function getPlaybackInfo(
|
||||
}
|
||||
break;
|
||||
case BaseItemKind.Series:
|
||||
result = await getTvShowsApi(api).getEpisodes({
|
||||
result = await getShowApi(api).getEpisodes({
|
||||
seriesId: item.Id || "",
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
@@ -140,7 +139,7 @@ export async function getPlaybackInfo(
|
||||
break;
|
||||
case BaseItemKind.Playlist:
|
||||
case BaseItemKind.MusicAlbum:
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
parentId: item.Id,
|
||||
userId: userId,
|
||||
fields: [ItemFields.MediaSources, ItemFields.MediaStreams],
|
||||
@@ -149,7 +148,7 @@ export async function getPlaybackInfo(
|
||||
});
|
||||
break;
|
||||
case BaseItemKind.MusicArtist:
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
artistIds: [item.Id ?? ""],
|
||||
recursive: true,
|
||||
includeItemTypes: [BaseItemKind.Audio],
|
||||
@@ -160,7 +159,7 @@ export async function getPlaybackInfo(
|
||||
});
|
||||
break;
|
||||
case BaseItemKind.BoxSet:
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
parentId: item.Id,
|
||||
userId,
|
||||
fields: [
|
||||
@@ -175,11 +174,11 @@ export async function getPlaybackInfo(
|
||||
break;
|
||||
case BaseItemKind.Photo: {
|
||||
const photo = (
|
||||
await getUserLibraryApi(api).getItem({
|
||||
await getLibraryApi(api).getItem({
|
||||
itemId: item.Id || "",
|
||||
})
|
||||
).data;
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
parentId: photo.ParentId ?? "",
|
||||
filters: [ItemFilter.IsNotFolder],
|
||||
recursive: false,
|
||||
@@ -191,7 +190,7 @@ export async function getPlaybackInfo(
|
||||
break;
|
||||
}
|
||||
default:
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
ids: [item.Id ?? ""],
|
||||
userId: userId,
|
||||
fields: [
|
||||
@@ -232,7 +231,7 @@ export async function getPlaybackInfo(
|
||||
},
|
||||
});
|
||||
|
||||
const segmentsPromise = await getMediaSegmentsApi(api).getItemSegments({
|
||||
const segmentsPromise = await getMediaSegmentApi(api).getItemSegments({
|
||||
itemId: targetItem.Id,
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { linkOptions } from "@tanstack/react-router";
|
||||
|
||||
/**
|
||||
* Returns navigation options for an item's detail page.
|
||||
* Music items get their dedicated music pages, everything else goes to the unified
|
||||
* `/item/$id` page with the item type as a hint so the loader can prefetch in parallel.
|
||||
*/
|
||||
export const getItemLinkOptions = (
|
||||
id: string,
|
||||
type: BaseItemKind | null | undefined,
|
||||
) => {
|
||||
switch (type) {
|
||||
case BaseItemKind.MusicAlbum:
|
||||
return linkOptions({ to: "/music/album/$id", params: { id } });
|
||||
case BaseItemKind.MusicArtist:
|
||||
return linkOptions({ to: "/music/artist/$id", params: { id } });
|
||||
case BaseItemKind.Playlist:
|
||||
return linkOptions({ to: "/music/playlist/$id", params: { id } });
|
||||
default:
|
||||
return linkOptions({
|
||||
to: "/item/$id",
|
||||
params: { id },
|
||||
search: { type: type ?? undefined },
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -2,10 +2,13 @@
|
||||
* @deprecated - Check @/utils/playback-profiles/index
|
||||
*/
|
||||
|
||||
import {
|
||||
DlnaProfileType,
|
||||
type ResponseProfile
|
||||
} from '@jellyfin/sdk/lib/generated-client';
|
||||
import { DlnaProfileType } from "@jellyfin/sdk/lib/generated-client";
|
||||
|
||||
type ResponseProfile = {
|
||||
Type: DlnaProfileType;
|
||||
Container: string;
|
||||
MimeType: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a valid ResponseProfile for the current platform.
|
||||
@@ -13,13 +16,13 @@ import {
|
||||
* @returns An array of subtitle profiles for the current platform.
|
||||
*/
|
||||
export function getResponseProfiles(): ResponseProfile[] {
|
||||
const ResponseProfiles = [];
|
||||
const ResponseProfiles = [];
|
||||
|
||||
ResponseProfiles.push({
|
||||
Type: DlnaProfileType.Video,
|
||||
Container: 'm4v',
|
||||
MimeType: 'video/mp4'
|
||||
});
|
||||
ResponseProfiles.push({
|
||||
Type: DlnaProfileType.Video,
|
||||
Container: "m4v",
|
||||
MimeType: "video/mp4",
|
||||
});
|
||||
|
||||
return ResponseProfiles;
|
||||
return ResponseProfiles;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
LocationType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
||||
import { type QueryClient, queryOptions } from "@tanstack/react-query";
|
||||
|
||||
/**
|
||||
* Query options shared by the unified `/item/$id` route loader and its sections,
|
||||
* so data prefetched in the loader is picked up by the components.
|
||||
*/
|
||||
|
||||
export const getSimilarItemsQueryOptions = (
|
||||
api: Api | undefined,
|
||||
userId: string | undefined,
|
||||
id: string,
|
||||
type: BaseItemKind | undefined,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["item", id, "similarItem"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const request = { userId, itemId: id, limit: 16 };
|
||||
const result =
|
||||
type === BaseItemKind.Series
|
||||
? await getLibraryApi(api).getSimilarShows(request)
|
||||
: await getLibraryApi(api).getSimilarItems(request);
|
||||
return result.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
export const getSeasonsQueryOptions = (
|
||||
api: Api | undefined,
|
||||
userId: string | undefined,
|
||||
seriesId: string,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["item", seriesId, "seasons"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getShowApi(api).getSeasons({
|
||||
userId,
|
||||
seriesId,
|
||||
isMissing: false,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
|
||||
export const getSpecialFeaturesQueryOptions = (
|
||||
api: Api | undefined,
|
||||
userId: string | undefined,
|
||||
id: string,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["item", id, "specialFeatures"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getLibraryApi(api).getSpecialFeatures({
|
||||
itemId: id,
|
||||
userId,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
|
||||
export const getCollectionItemsQueryOptions = (
|
||||
api: Api | undefined,
|
||||
userId: string | undefined,
|
||||
id: string,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["item", id, "collection"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getLibraryApi(api).getItems({
|
||||
userId,
|
||||
parentId: id,
|
||||
fields: [ItemFields.SeasonUserData, ItemFields.Overview],
|
||||
excludeLocationTypes: [LocationType.Virtual],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
export const getUpcomingEpisodesQueryOptions = (
|
||||
api: Api | undefined,
|
||||
userId: string | undefined,
|
||||
episode: BaseItemDto,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["item", episode.Id ?? "", "episode", "upcomingEpisodes"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getLibraryApi(api).getItems({
|
||||
userId,
|
||||
parentId: episode.ParentId ?? "",
|
||||
startIndex: episode.IndexNumber ?? 0,
|
||||
excludeLocationTypes: [LocationType.Virtual],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
export const personTabs = [
|
||||
{ title: "Movies", key: "personMovies", kind: BaseItemKind.Movie },
|
||||
{ title: "TV Shows", key: "personShows", kind: BaseItemKind.Series },
|
||||
{ title: "Books", key: "personBooks", kind: BaseItemKind.Book },
|
||||
{ title: "Photos", key: "personPhotos", kind: BaseItemKind.Photo },
|
||||
{ title: "Episodes", key: "personEpisodes", kind: BaseItemKind.Episode },
|
||||
] as const;
|
||||
|
||||
export type PersonTab = (typeof personTabs)[number];
|
||||
|
||||
export const getPersonItemsQueryOptions = (
|
||||
api: Api | undefined,
|
||||
userId: string | undefined,
|
||||
personId: string,
|
||||
tab: PersonTab,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["item", personId, tab.key],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getLibraryApi(api).getItems({
|
||||
userId,
|
||||
personIds: [personId],
|
||||
includeItemTypes: [tab.kind],
|
||||
recursive: true,
|
||||
fields:
|
||||
tab.kind === BaseItemKind.Episode
|
||||
? [ItemFields.SeasonUserData, ItemFields.Overview]
|
||||
: undefined,
|
||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||
sortOrder:
|
||||
tab.kind === BaseItemKind.Photo || tab.kind === BaseItemKind.Episode
|
||||
? undefined
|
||||
: ["Descending"],
|
||||
excludeLocationTypes: [LocationType.Virtual],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
/**
|
||||
* Starts fetching the data a given item type's page needs. Safe to call before the
|
||||
* item itself has loaded (when the type is known from a link hint).
|
||||
*/
|
||||
export const prefetchItemDetail = (
|
||||
queryClient: QueryClient,
|
||||
api: Api,
|
||||
userId: string,
|
||||
id: string,
|
||||
type: BaseItemKind | undefined,
|
||||
) => {
|
||||
switch (type) {
|
||||
case BaseItemKind.Person:
|
||||
for (const tab of personTabs) {
|
||||
queryClient.prefetchQuery(
|
||||
getPersonItemsQueryOptions(api, userId, id, tab),
|
||||
);
|
||||
}
|
||||
return;
|
||||
case BaseItemKind.Episode:
|
||||
// Upcoming episodes depend on the episode's parent, so they are prefetched once it loads.
|
||||
return;
|
||||
case BaseItemKind.Series:
|
||||
queryClient.prefetchQuery(getSeasonsQueryOptions(api, userId, id));
|
||||
queryClient.prefetchQuery(
|
||||
getSpecialFeaturesQueryOptions(api, userId, id),
|
||||
);
|
||||
break;
|
||||
case BaseItemKind.BoxSet:
|
||||
queryClient.prefetchQuery(
|
||||
getCollectionItemsQueryOptions(api, userId, id),
|
||||
);
|
||||
break;
|
||||
}
|
||||
queryClient.prefetchQuery(getSimilarItemsQueryOptions(api, userId, id, type));
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
|
||||
/**
|
||||
@@ -24,7 +24,7 @@ export const getItemQueryOptions = (
|
||||
if (!userId) {
|
||||
throw Error("User ID is not defined");
|
||||
}
|
||||
const result = await getUserLibraryApi(api).getItem({
|
||||
const result = await getLibraryApi(api).getItem({
|
||||
userId: userId,
|
||||
itemId: id,
|
||||
});
|
||||
@@ -51,7 +51,7 @@ export const getLatestItemsQueryOptions = (
|
||||
if (!userId) {
|
||||
throw Error("User ID is not defined");
|
||||
}
|
||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||
const media = await getLibraryApi(api).getLatestMedia({
|
||||
userId: userId,
|
||||
fields: [
|
||||
ItemFields.Overview,
|
||||
@@ -72,3 +72,29 @@ export const getLatestItemsQueryOptions = (
|
||||
return media.data;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* @param api api instance
|
||||
* @param userId user's id
|
||||
* @param libraryId the library (user view) id
|
||||
* @returns query options for the latest items of a single library
|
||||
*/
|
||||
export const getLibraryLatestQueryOptions = (
|
||||
api: Api | null | undefined,
|
||||
userId: string | null | undefined,
|
||||
libraryId: string | null | undefined,
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ["home", "latestMedia", libraryId],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId) return null;
|
||||
const media = await getLibraryApi(api).getLatestMedia({
|
||||
userId,
|
||||
parentId: libraryId ?? undefined,
|
||||
limit: 16,
|
||||
fields: [ItemFields.PrimaryImageAspectRatio, ItemFields.ParentId],
|
||||
});
|
||||
return media.data;
|
||||
},
|
||||
enabled: !!userId,
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ export const getLibraryQueryOptions = (
|
||||
queryKey: ["library", "currentLib", id],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId) throw Error("API or User ID is not defined");
|
||||
const result = await getUserLibraryApi(api).getItem({
|
||||
const result = await getLibraryApi(api).getItem({
|
||||
userId: userId,
|
||||
itemId: id,
|
||||
});
|
||||
|
||||
@@ -9,10 +9,10 @@ import {
|
||||
SortOrder,
|
||||
VideoType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||
import { getArtistApi } from "@jellyfin/sdk/lib/utils/api/artist-api";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getPersonApi } from "@jellyfin/sdk/lib/utils/api/person-api";
|
||||
import { getStudioApi } from "@jellyfin/sdk/lib/utils/api/studio-api";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
|
||||
export interface LibraryItemsParams {
|
||||
@@ -91,31 +91,31 @@ export const getLibraryItemsQueryOptions = (
|
||||
};
|
||||
let result: { data: BaseItemDtoQueryResult };
|
||||
if (currentViewType === "MusicArtist") {
|
||||
result = await getArtistsApi(api).getAlbumArtists({
|
||||
result = await getArtistApi(api).getAlbumArtists({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "Artist") {
|
||||
result = await getArtistsApi(api).getArtists({
|
||||
result = await getArtistApi(api).getArtists({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "Person") {
|
||||
result = await getPersonsApi(api).getPersons({
|
||||
result = await getPersonApi(api).getPersons({
|
||||
userId: userId,
|
||||
personTypes: ["Actor"],
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "Studio") {
|
||||
result = await getStudiosApi(api).getStudios({
|
||||
result = await getStudioApi(api).getStudios({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "BoxSet") {
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
recursive: params.collectionType === "boxsets" ? undefined : true,
|
||||
@@ -142,7 +142,7 @@ export const getLibraryItemsQueryOptions = (
|
||||
limit: params.limit,
|
||||
});
|
||||
} else {
|
||||
result = await getItemsApi(api).getItems({
|
||||
result = await getLibraryApi(api).getItems({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
recursive: true,
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
PlayMethod,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||
import { getMediaSegmentApi } from "@jellyfin/sdk/lib/utils/api/media-segment-api";
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { create } from "zustand";
|
||||
@@ -927,11 +927,11 @@ export const playItemFromQueue = async (
|
||||
},
|
||||
});
|
||||
|
||||
const segmentsPromise = getMediaSegmentsApi(api).getItemSegments({
|
||||
const segmentsPromise = getMediaSegmentApi(api).getItemSegments({
|
||||
itemId: item.Id,
|
||||
});
|
||||
|
||||
const stopReportPromise = getPlaystateApi(api).reportPlaybackStopped({
|
||||
const stopReportPromise = getSessionApi(api).reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
Failed: false,
|
||||
ItemId: prevItem?.Id,
|
||||
@@ -1065,4 +1065,4 @@ export const changeAudioTrack = async (trackIndex: number, api: Api) => {
|
||||
});
|
||||
// const currentItemIndex = useQueue.getState().currentItemIndex;
|
||||
// playItemFromQueue(currentItemIndex, prevState.userId, api);
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user