@behindthemusictree/app-kit 34.0.0 → 34.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3PITD62C.js → chunk-QZXZHP4R.js} +84 -22
- package/dist/chunk-QZXZHP4R.js.map +1 -0
- package/dist/genre-tree/index.cjs +143 -79
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +11 -1
- package/dist/genre-tree/index.js +5 -1
- package/dist/index.cjs +140 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
- package/dist/chunk-3PITD62C.js.map +0 -1
|
@@ -4755,6 +4755,16 @@ declare const FUZZY_MIN_SIMILARITY = 0.3;
|
|
|
4755
4755
|
* then accent-folded trigram similarity; ties break on `getViews` (descending) then name. An empty query matches nothing.
|
|
4756
4756
|
*/
|
|
4757
4757
|
declare function rankByName<T>(items: readonly T[], query: string, getName: (item: T) => string, getViews?: (item: T) => number): T[];
|
|
4758
|
+
type NameIndex<T> = readonly {
|
|
4759
|
+
item: T;
|
|
4760
|
+
name: string;
|
|
4761
|
+
grams: ReadonlySet<string>;
|
|
4762
|
+
views: number;
|
|
4763
|
+
}[];
|
|
4764
|
+
/** Build once per immutable item collection, rather than folding every name on each keystroke. */
|
|
4765
|
+
declare function createNameIndex<T>(items: readonly T[], getName: (item: T) => string, getViews?: (item: T) => number): NameIndex<T>;
|
|
4766
|
+
/** Same ranking and stable tie order as rankByName; a limit keeps only the best requested entries. */
|
|
4767
|
+
declare function rankNameIndex<T>(index: NameIndex<T>, query: string, limit?: number): T[];
|
|
4758
4768
|
|
|
4759
4769
|
type ReparentCandidate = CriteriaPlaylistSimple & {
|
|
4760
4770
|
criteria: CriteriaMinimum;
|
|
@@ -4928,4 +4938,4 @@ declare const ReferenceGenrePlaylistSchema: z.ZodObject<{
|
|
|
4928
4938
|
type ReferenceGenreDetailed = z.infer<typeof ReferenceGenreDetailedSchema>;
|
|
4929
4939
|
type ReferenceGenrePlaylist = z.infer<typeof ReferenceGenrePlaylistSchema>;
|
|
4930
4940
|
|
|
4931
|
-
export { ARTIST_LINK_KINDS, type AlbumMinimum, AlbumMinimumSchema, type ArtistAlbum, type ArtistDetailed, ArtistDetailedSchema, type ArtistGenreCount, ArtistGenreCountSchema, type ArtistImage, ArtistImageSchema, type ArtistLink, type ArtistMembership, type ArtistMinimum, ArtistMinimumSchema, ArtistNames, type ArtistSearchResult, ArtistSearchResultSchema, ArtistSearchResultsSchema, type ArtistSongsOrdering, type ArtistTrackListOriginInput, CriteriaCreationSchema, type CriteriaCreationValues, type CriteriaDetailed, CriteriaDetailedSchema, type CriteriaLineageRelWithoutAscendant, CriteriaLineageRelWithoutAscendantSchema, type CriteriaLineageRelWithoutDescendant, CriteriaLineageRelWithoutDescendantSchema, type CriteriaMinimum, CriteriaMinimumSchema, type CriteriaOverview, CriteriaOverviewSchema, type CriteriaPlaylistDetailed, CriteriaPlaylistDetailedSchema, type CriteriaPlaylistMinimum, CriteriaPlaylistMinimumSchema, type CriteriaPlaylistSimple, CriteriaPlaylistSimpleSchema, type CriteriaSimple, CriteriaSimpleSchema, CriteriaUpdateSchema, type CriteriaUpdateValues, FORM_RATING_NULL_VALUE, FUZZY_MIN_SIMILARITY, type GenreCatalogueCounts, GenreCatalogueCountsSchema, GenreCountsSchema, type GenreCoverage, GenreCoverageSchema, type GenreMusicCounts, type GenreMusicSelection, type GenrePlaylistSummary, GenrePlaylistSummarySchema, type GenrePlaylistTracksPage, GenrePlaylistUuid, type GenreSearchParams, type GenreSearchResult, GenreSearchResultSchema, GenreSearchResultsSchema, type GenreSearchTreeName, GenreSearchTreeNameSchema, GenreUuid, type GenreViewMode, MbArtistDetailedSchema, MbRecordingDetailedSchema, type MusicbrainzArtistDetailed, type MusicbrainzRecordingDetailed, NO_VIDEO_LABEL, type PlayArtistOptions, type PlayGenrePlaylistOptions, type ReferenceGenreDetailed, ReferenceGenreDetailedSchema, type ReferenceGenrePlaylist, ReferenceGenrePlaylistSchema, type RegionGenreLexiconEntry, RegionGenreLexiconEntrySchema, RegionGenreLexiconSchema, type RenderArtistLink, type RenderSongLink, type ReparentCandidate, SEARCH_DEBOUNCE_MS, SEARCH_QUERY_MIN_LENGTH, type SongDetailed, SongDetailedSchema, type SongHistoryEntry, SongHistoryEntrySchema, SongHistorySchema, type SongSearchGenreFilter, type SongSearchParams, type SongSearchResult, SongSearchResultSchema, SongSearchResultsSchema, SubgenreCountsSchema, type SubgenreScope, SubgenreScopeSchema, type TrackBase, TrackBaseSchema, TrackList, TrackListFromArtist, TrackListFromCriteriaPlaylist, TrackListFromTrack, TrackListOrigin, TrackListOriginFromArtist, TrackListOriginFromCriteriaPlaylist, TrackListOriginFromGenreCatalogue, TrackListOriginFromTrack, TrackListOriginType, TrackListProvider, TrackListSidebarVisibilityProvider, type TrackMinimum, TrackMinimumSchema, type TrackPlaylistRel, type UseArtistResult, type UseArtistSearchResult, type UseGenreRemoteSearchOptions, type UseGenreRemoteSearchResult, type UseGenreSearchOptions, type UseGenreSearchResult, type UseGenreTreeViewStateOptions, type UseGenreTreeViewStateResult, type UseRemoteSearchOptions, type UseRemoteSearchResult, type UseSearchQueryStateOptions, type UseSearchQueryStateResult, type UseSongHistoryResult, type UseSongResult, type UseSongSearchResult, type UseVisibleGenrePlaylistsOptions, type UuidResource, UuidResourceSchema, YOUTUBE_UNPLAYABLE_REASON_LABELS, YoutubeAvailabilitySchema, type YoutubeUnplayableReason, artistEndpoints, artistQueryKeys, capitalizeFirstLetter, defaultGenreMusicSelection, editGenreSongPages, foldSearchText, formatTime, genreEndpoints, genreMusicCount, genreMusicQueryParams, genreMusicSelectionKey, genrePlaylistEndpoints, genrePlaylistQueryKeys, genrePlaylistTrackCount, genreQueryKeys, genreSearchQueryKeys, genreUpdateMutationKey, getGenrePlaylistsGroupedByRoot, getReparentCandidates, hasMainstreamPopRoot, isSong, isSongSearchResultPlayable, libraryEndpoints, libraryQueryKeys, makeTrackPlaylistRelPageSchema, makeTrackPlaylistRelSchema, musicBrainzRecordingUrl, pruneGenrePlaylistsForArtist, rankByName, searchGenrePlaylistsByName, songUnplayableReason, trigramSimilarity, useArtist, useArtistGenreCounts, useArtistSearch, useCreateGenre, useDeleteGenre, useFetchGenre, useFetchGenreDetail, useFetchGenreOverview, useFetchGenrePlaylist, useGenreByWikidataId, useGenreRemoteSearch, useGenreSearch, useGenreTreeViewState, useInvalidateAllGenrePlaylistQueries, useListFullGenrePlaylists, useListGenrePlaylists, useListGenres, useListTracks, usePrefetchGenreOverview, useRegionGenreLexicon, useRemoteSearch, useSearchQueryState, useSong, useSongHistory, useSongSearch, useTrackList, useTrackListSidebarVisibility, useUpdateGenre, useVisibleGenrePlaylists };
|
|
4941
|
+
export { ARTIST_LINK_KINDS, type AlbumMinimum, AlbumMinimumSchema, type ArtistAlbum, type ArtistDetailed, ArtistDetailedSchema, type ArtistGenreCount, ArtistGenreCountSchema, type ArtistImage, ArtistImageSchema, type ArtistLink, type ArtistMembership, type ArtistMinimum, ArtistMinimumSchema, ArtistNames, type ArtistSearchResult, ArtistSearchResultSchema, ArtistSearchResultsSchema, type ArtistSongsOrdering, type ArtistTrackListOriginInput, CriteriaCreationSchema, type CriteriaCreationValues, type CriteriaDetailed, CriteriaDetailedSchema, type CriteriaLineageRelWithoutAscendant, CriteriaLineageRelWithoutAscendantSchema, type CriteriaLineageRelWithoutDescendant, CriteriaLineageRelWithoutDescendantSchema, type CriteriaMinimum, CriteriaMinimumSchema, type CriteriaOverview, CriteriaOverviewSchema, type CriteriaPlaylistDetailed, CriteriaPlaylistDetailedSchema, type CriteriaPlaylistMinimum, CriteriaPlaylistMinimumSchema, type CriteriaPlaylistSimple, CriteriaPlaylistSimpleSchema, type CriteriaSimple, CriteriaSimpleSchema, CriteriaUpdateSchema, type CriteriaUpdateValues, FORM_RATING_NULL_VALUE, FUZZY_MIN_SIMILARITY, type GenreCatalogueCounts, GenreCatalogueCountsSchema, GenreCountsSchema, type GenreCoverage, GenreCoverageSchema, type GenreMusicCounts, type GenreMusicSelection, type GenrePlaylistSummary, GenrePlaylistSummarySchema, type GenrePlaylistTracksPage, GenrePlaylistUuid, type GenreSearchParams, type GenreSearchResult, GenreSearchResultSchema, GenreSearchResultsSchema, type GenreSearchTreeName, GenreSearchTreeNameSchema, GenreUuid, type GenreViewMode, MbArtistDetailedSchema, MbRecordingDetailedSchema, type MusicbrainzArtistDetailed, type MusicbrainzRecordingDetailed, NO_VIDEO_LABEL, type NameIndex, type PlayArtistOptions, type PlayGenrePlaylistOptions, type ReferenceGenreDetailed, ReferenceGenreDetailedSchema, type ReferenceGenrePlaylist, ReferenceGenrePlaylistSchema, type RegionGenreLexiconEntry, RegionGenreLexiconEntrySchema, RegionGenreLexiconSchema, type RenderArtistLink, type RenderSongLink, type ReparentCandidate, SEARCH_DEBOUNCE_MS, SEARCH_QUERY_MIN_LENGTH, type SongDetailed, SongDetailedSchema, type SongHistoryEntry, SongHistoryEntrySchema, SongHistorySchema, type SongSearchGenreFilter, type SongSearchParams, type SongSearchResult, SongSearchResultSchema, SongSearchResultsSchema, SubgenreCountsSchema, type SubgenreScope, SubgenreScopeSchema, type TrackBase, TrackBaseSchema, TrackList, TrackListFromArtist, TrackListFromCriteriaPlaylist, TrackListFromTrack, TrackListOrigin, TrackListOriginFromArtist, TrackListOriginFromCriteriaPlaylist, TrackListOriginFromGenreCatalogue, TrackListOriginFromTrack, TrackListOriginType, TrackListProvider, TrackListSidebarVisibilityProvider, type TrackMinimum, TrackMinimumSchema, type TrackPlaylistRel, type UseArtistResult, type UseArtistSearchResult, type UseGenreRemoteSearchOptions, type UseGenreRemoteSearchResult, type UseGenreSearchOptions, type UseGenreSearchResult, type UseGenreTreeViewStateOptions, type UseGenreTreeViewStateResult, type UseRemoteSearchOptions, type UseRemoteSearchResult, type UseSearchQueryStateOptions, type UseSearchQueryStateResult, type UseSongHistoryResult, type UseSongResult, type UseSongSearchResult, type UseVisibleGenrePlaylistsOptions, type UuidResource, UuidResourceSchema, YOUTUBE_UNPLAYABLE_REASON_LABELS, YoutubeAvailabilitySchema, type YoutubeUnplayableReason, artistEndpoints, artistQueryKeys, capitalizeFirstLetter, createNameIndex, defaultGenreMusicSelection, editGenreSongPages, foldSearchText, formatTime, genreEndpoints, genreMusicCount, genreMusicQueryParams, genreMusicSelectionKey, genrePlaylistEndpoints, genrePlaylistQueryKeys, genrePlaylistTrackCount, genreQueryKeys, genreSearchQueryKeys, genreUpdateMutationKey, getGenrePlaylistsGroupedByRoot, getReparentCandidates, hasMainstreamPopRoot, isSong, isSongSearchResultPlayable, libraryEndpoints, libraryQueryKeys, makeTrackPlaylistRelPageSchema, makeTrackPlaylistRelSchema, musicBrainzRecordingUrl, pruneGenrePlaylistsForArtist, rankByName, rankNameIndex, searchGenrePlaylistsByName, songUnplayableReason, trigramSimilarity, useArtist, useArtistGenreCounts, useArtistSearch, useCreateGenre, useDeleteGenre, useFetchGenre, useFetchGenreDetail, useFetchGenreOverview, useFetchGenrePlaylist, useGenreByWikidataId, useGenreRemoteSearch, useGenreSearch, useGenreTreeViewState, useInvalidateAllGenrePlaylistQueries, useListFullGenrePlaylists, useListGenrePlaylists, useListGenres, useListTracks, usePrefetchGenreOverview, useRegionGenreLexicon, useRemoteSearch, useSearchQueryState, useSong, useSongHistory, useSongSearch, useTrackList, useTrackListSidebarVisibility, useUpdateGenre, useVisibleGenrePlaylists };
|
package/dist/genre-tree/index.js
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
artistEndpoints,
|
|
65
65
|
artistQueryKeys,
|
|
66
66
|
capitalizeFirstLetter,
|
|
67
|
+
createNameIndex,
|
|
67
68
|
defaultGenreMusicSelection,
|
|
68
69
|
editGenreSongPages,
|
|
69
70
|
foldSearchText,
|
|
@@ -90,6 +91,7 @@ import {
|
|
|
90
91
|
musicBrainzRecordingUrl,
|
|
91
92
|
pruneGenrePlaylistsForArtist,
|
|
92
93
|
rankByName,
|
|
94
|
+
rankNameIndex,
|
|
93
95
|
searchGenrePlaylistsByName,
|
|
94
96
|
songUnplayableReason,
|
|
95
97
|
trigramSimilarity,
|
|
@@ -122,7 +124,7 @@ import {
|
|
|
122
124
|
useTrackListSidebarVisibility,
|
|
123
125
|
useUpdateGenre,
|
|
124
126
|
useVisibleGenrePlaylists
|
|
125
|
-
} from "../chunk-
|
|
127
|
+
} from "../chunk-QZXZHP4R.js";
|
|
126
128
|
import "../chunk-4TE4OSOM.js";
|
|
127
129
|
import "../chunk-T5D5T52J.js";
|
|
128
130
|
import "../chunk-4MEK3CNF.js";
|
|
@@ -200,6 +202,7 @@ export {
|
|
|
200
202
|
artistEndpoints,
|
|
201
203
|
artistQueryKeys,
|
|
202
204
|
capitalizeFirstLetter,
|
|
205
|
+
createNameIndex,
|
|
203
206
|
defaultGenreMusicSelection,
|
|
204
207
|
editGenreSongPages,
|
|
205
208
|
foldSearchText,
|
|
@@ -226,6 +229,7 @@ export {
|
|
|
226
229
|
musicBrainzRecordingUrl,
|
|
227
230
|
pruneGenrePlaylistsForArtist,
|
|
228
231
|
rankByName,
|
|
232
|
+
rankNameIndex,
|
|
229
233
|
searchGenrePlaylistsByName,
|
|
230
234
|
songUnplayableReason,
|
|
231
235
|
trigramSimilarity,
|
package/dist/index.cjs
CHANGED
|
@@ -123,6 +123,7 @@ __export(src_exports, {
|
|
|
123
123
|
createAppErrorFromErrorCode: () => createAppErrorFromErrorCode,
|
|
124
124
|
createAppErrorFromResult: () => createAppErrorFromResult,
|
|
125
125
|
createLogout: () => createLogout,
|
|
126
|
+
createNameIndex: () => createNameIndex,
|
|
126
127
|
createNetworkOrBackendError: () => createNetworkOrBackendError,
|
|
127
128
|
defaultGenreMusicSelection: () => defaultGenreMusicSelection,
|
|
128
129
|
editGenreSongPages: () => editGenreSongPages,
|
|
@@ -157,6 +158,7 @@ __export(src_exports, {
|
|
|
157
158
|
pruneGenrePlaylistsForArtist: () => pruneGenrePlaylistsForArtist,
|
|
158
159
|
queryClient: () => queryClient,
|
|
159
160
|
rankByName: () => rankByName,
|
|
161
|
+
rankNameIndex: () => rankNameIndex,
|
|
160
162
|
resolveRedirectUri: () => resolveRedirectUri,
|
|
161
163
|
searchGenrePlaylistsByName: () => searchGenrePlaylistsByName,
|
|
162
164
|
setSpotifyRequiredCached: () => setSpotifyRequiredCached,
|
|
@@ -2941,6 +2943,9 @@ function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
|
2941
2943
|
});
|
|
2942
2944
|
}
|
|
2943
2945
|
|
|
2946
|
+
// src/genre-tree/useGenreSearch.ts
|
|
2947
|
+
var import_react16 = require("react");
|
|
2948
|
+
|
|
2944
2949
|
// src/genre-tree/lib/search-text.ts
|
|
2945
2950
|
var foldSearchText = (text) => text.normalize("NFD").replace(/\p{M}+/gu, "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
2946
2951
|
var trigrams = (folded) => {
|
|
@@ -2986,9 +2991,54 @@ function rankByName(items, query, getName, getViews) {
|
|
|
2986
2991
|
);
|
|
2987
2992
|
return scored.map((entry) => entry.item);
|
|
2988
2993
|
}
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2994
|
+
function createNameIndex(items, getName, getViews) {
|
|
2995
|
+
return items.map((item) => {
|
|
2996
|
+
const name = foldSearchText(getName(item));
|
|
2997
|
+
return { item, name, grams: trigrams(name), views: getViews?.(item) ?? 0 };
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
function rankNameIndex(index, query, limit = Infinity) {
|
|
3001
|
+
if (limit !== Infinity && (!Number.isInteger(limit) || limit < 0)) {
|
|
3002
|
+
throw new RangeError("Search limit must be a nonnegative integer or Infinity");
|
|
3003
|
+
}
|
|
3004
|
+
const folded = foldSearchText(query);
|
|
3005
|
+
if (!folded || limit === 0) return [];
|
|
3006
|
+
const queryGrams = trigrams(folded);
|
|
3007
|
+
const scored = [];
|
|
3008
|
+
const compare = (a, b) => a.tier - b.tier || b.similarity - a.similarity || b.views - a.views || a.name.localeCompare(b.name);
|
|
3009
|
+
for (const entry of index) {
|
|
3010
|
+
let tier;
|
|
3011
|
+
let similarity = 0;
|
|
3012
|
+
if (entry.name === folded) tier = TIER_EXACT;
|
|
3013
|
+
else if (entry.name.startsWith(folded)) tier = TIER_PREFIX;
|
|
3014
|
+
else if (entry.name.includes(folded)) tier = TIER_SUBSTRING;
|
|
3015
|
+
else {
|
|
3016
|
+
let shared = 0;
|
|
3017
|
+
for (const gram of queryGrams) if (entry.grams.has(gram)) shared++;
|
|
3018
|
+
const union = entry.grams.size + queryGrams.size - shared;
|
|
3019
|
+
similarity = union === 0 ? 0 : shared / union;
|
|
3020
|
+
if (similarity < FUZZY_MIN_SIMILARITY) continue;
|
|
3021
|
+
tier = TIER_FUZZY;
|
|
3022
|
+
}
|
|
3023
|
+
const candidate = { ...entry, tier, similarity };
|
|
3024
|
+
if (limit === Infinity) scored.push(candidate);
|
|
3025
|
+
else {
|
|
3026
|
+
let low = 0;
|
|
3027
|
+
let high = scored.length;
|
|
3028
|
+
while (low < high) {
|
|
3029
|
+
const mid = low + high >>> 1;
|
|
3030
|
+
if (compare(candidate, scored[mid]) < 0) high = mid;
|
|
3031
|
+
else low = mid + 1;
|
|
3032
|
+
}
|
|
3033
|
+
if (low < limit) {
|
|
3034
|
+
scored.splice(low, 0, candidate);
|
|
3035
|
+
if (scored.length > limit) scored.pop();
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
if (limit === Infinity) scored.sort(compare);
|
|
3040
|
+
return scored.map((entry) => entry.item);
|
|
3041
|
+
}
|
|
2992
3042
|
|
|
2993
3043
|
// src/genre-tree/useSearchQueryState.ts
|
|
2994
3044
|
var import_react15 = require("react");
|
|
@@ -3022,7 +3072,15 @@ function useGenreSearch({
|
|
|
3022
3072
|
onClear
|
|
3023
3073
|
}) {
|
|
3024
3074
|
const { query, setQuery, isTyping, canClear, clear, notifyPick } = useSearchQueryState({ selectedName, onClear });
|
|
3025
|
-
const
|
|
3075
|
+
const index = (0, import_react16.useMemo)(
|
|
3076
|
+
() => createNameIndex(genrePlaylists, (playlist) => playlist.name, (playlist) => playlist.viewsCount ?? 0),
|
|
3077
|
+
[genrePlaylists]
|
|
3078
|
+
);
|
|
3079
|
+
const deferredQuery = (0, import_react16.useDeferredValue)(query);
|
|
3080
|
+
const results = (0, import_react16.useMemo)(
|
|
3081
|
+
() => isTyping ? rankNameIndex(index, deferredQuery) : [],
|
|
3082
|
+
[index, deferredQuery, isTyping]
|
|
3083
|
+
);
|
|
3026
3084
|
return {
|
|
3027
3085
|
query,
|
|
3028
3086
|
setQuery,
|
|
@@ -3081,6 +3139,7 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
|
|
|
3081
3139
|
}
|
|
3082
3140
|
|
|
3083
3141
|
// src/genre-tree/useRegionGenreLexicon.ts
|
|
3142
|
+
var EMPTY_ENTRIES = [];
|
|
3084
3143
|
function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
3085
3144
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
3086
3145
|
const { data, isError, isPending } = useQueryWithParse({
|
|
@@ -3091,15 +3150,15 @@ function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
|
3091
3150
|
enabled,
|
|
3092
3151
|
staleTime: Infinity
|
|
3093
3152
|
});
|
|
3094
|
-
const entries = data ??
|
|
3153
|
+
const entries = data ?? EMPTY_ENTRIES;
|
|
3095
3154
|
return { entries, isError, isPending: enabled && isPending };
|
|
3096
3155
|
}
|
|
3097
3156
|
|
|
3098
3157
|
// src/genre-tree/useGenreTreeViewState.ts
|
|
3099
|
-
var
|
|
3158
|
+
var import_react18 = require("react");
|
|
3100
3159
|
|
|
3101
3160
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
3102
|
-
var
|
|
3161
|
+
var import_react17 = require("react");
|
|
3103
3162
|
|
|
3104
3163
|
// src/genre-tree/lib/prune-genre-playlists-for-artist.ts
|
|
3105
3164
|
var POP_ROOT_NAME = "Mainstream Pop";
|
|
@@ -3141,7 +3200,7 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
|
|
|
3141
3200
|
const counts = useArtistGenreCounts(artistUuid, getBackendBaseUrl);
|
|
3142
3201
|
const artistCounts = artistUuid !== null ? counts.data : void 0;
|
|
3143
3202
|
const isCountsLoading = artistUuid !== null && (counts.isPending || counts.isPlaceholderData);
|
|
3144
|
-
const genrePlaylists = (0,
|
|
3203
|
+
const genrePlaylists = (0, import_react17.useMemo)(() => {
|
|
3145
3204
|
if (!tree) return [];
|
|
3146
3205
|
return artistCounts ? pruneGenrePlaylistsForArtist(tree, artistCounts) : tree;
|
|
3147
3206
|
}, [tree, artistCounts]);
|
|
@@ -3169,12 +3228,12 @@ function useGenreTreeViewState({
|
|
|
3169
3228
|
onSelectedNodeIdChange,
|
|
3170
3229
|
criteriaOverviewSchema
|
|
3171
3230
|
}) {
|
|
3172
|
-
const [internalViewMode, setInternalViewMode] = (0,
|
|
3173
|
-
const [allowWheelRotation, setAllowWheelRotation] = (0,
|
|
3174
|
-
const [internalSelectedNodeId, setInternalSelectedNodeId] = (0,
|
|
3231
|
+
const [internalViewMode, setInternalViewMode] = (0, import_react18.useState)("pop-core");
|
|
3232
|
+
const [allowWheelRotation, setAllowWheelRotation] = (0, import_react18.useState)(false);
|
|
3233
|
+
const [internalSelectedNodeId, setInternalSelectedNodeId] = (0, import_react18.useState)(null);
|
|
3175
3234
|
const isSelectionControlled = controlledSelectedNodeId !== void 0;
|
|
3176
3235
|
const requestedSelectedNodeId = isSelectionControlled ? controlledSelectedNodeId : internalSelectedNodeId;
|
|
3177
|
-
const setSelectedNodeId = (0,
|
|
3236
|
+
const setSelectedNodeId = (0, import_react18.useCallback)(
|
|
3178
3237
|
(nodeId) => {
|
|
3179
3238
|
if (!isSelectionControlled) setInternalSelectedNodeId(nodeId);
|
|
3180
3239
|
onSelectedNodeIdChange?.(nodeId);
|
|
@@ -3182,35 +3241,35 @@ function useGenreTreeViewState({
|
|
|
3182
3241
|
[isSelectionControlled, onSelectedNodeIdChange]
|
|
3183
3242
|
);
|
|
3184
3243
|
const { isLoading, isFetching, genrePlaylists } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
|
|
3185
|
-
const genrePlaylistByNodeId = (0,
|
|
3186
|
-
const selectedGenrePlaylist = (0,
|
|
3244
|
+
const genrePlaylistByNodeId = (0, import_react18.useMemo)(() => new Map(genrePlaylists.map((gp) => [gp.uuid, gp])), [genrePlaylists]);
|
|
3245
|
+
const selectedGenrePlaylist = (0, import_react18.useMemo)(
|
|
3187
3246
|
() => genrePlaylists.find((gp) => gp.uuid === requestedSelectedNodeId) ?? // Older shared links stored the criteria UUID in `genre`; resolve that alias while preserving
|
|
3188
3247
|
// the playlist UUID as the canonical tree selection identity.
|
|
3189
3248
|
genrePlaylists.find((gp) => gp.criteria?.uuid === requestedSelectedNodeId),
|
|
3190
3249
|
[genrePlaylists, requestedSelectedNodeId]
|
|
3191
3250
|
);
|
|
3192
3251
|
const selectedNodeId = selectedGenrePlaylist?.uuid ?? requestedSelectedNodeId;
|
|
3193
|
-
(0,
|
|
3252
|
+
(0, import_react18.useEffect)(() => {
|
|
3194
3253
|
if (!isSelectionControlled || requestedSelectedNodeId == null || selectedGenrePlaylist == null || requestedSelectedNodeId === selectedGenrePlaylist.uuid) {
|
|
3195
3254
|
return;
|
|
3196
3255
|
}
|
|
3197
3256
|
onSelectedNodeIdChange?.(selectedGenrePlaylist.uuid);
|
|
3198
3257
|
}, [isSelectionControlled, onSelectedNodeIdChange, requestedSelectedNodeId, selectedGenrePlaylist]);
|
|
3199
|
-
const selectNode = (0,
|
|
3200
|
-
const clearSelection = (0,
|
|
3201
|
-
const selectGenrePlaylist = (0,
|
|
3258
|
+
const selectNode = (0, import_react18.useCallback)((node) => setSelectedNodeId(node?.id ?? null), [setSelectedNodeId]);
|
|
3259
|
+
const clearSelection = (0, import_react18.useCallback)(() => setSelectedNodeId(null), [setSelectedNodeId]);
|
|
3260
|
+
const selectGenrePlaylist = (0, import_react18.useCallback)(
|
|
3202
3261
|
(genrePlaylist) => setSelectedNodeId(genrePlaylist.uuid),
|
|
3203
3262
|
[setSelectedNodeId]
|
|
3204
3263
|
);
|
|
3205
3264
|
const prefetchGenreOverview = usePrefetchGenreOverview(scope, getBackendBaseUrl, criteriaOverviewSchema);
|
|
3206
|
-
const hoverPrefetchTimerRef = (0,
|
|
3207
|
-
(0,
|
|
3265
|
+
const hoverPrefetchTimerRef = (0, import_react18.useRef)(null);
|
|
3266
|
+
(0, import_react18.useEffect)(
|
|
3208
3267
|
() => () => {
|
|
3209
3268
|
if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
|
|
3210
3269
|
},
|
|
3211
3270
|
[]
|
|
3212
3271
|
);
|
|
3213
|
-
const onNodeHover = (0,
|
|
3272
|
+
const onNodeHover = (0, import_react18.useCallback)(
|
|
3214
3273
|
(node) => {
|
|
3215
3274
|
if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
|
|
3216
3275
|
const genreUuid = genrePlaylistByNodeId.get(node.id)?.criteria?.uuid;
|
|
@@ -3221,8 +3280,8 @@ function useGenreTreeViewState({
|
|
|
3221
3280
|
},
|
|
3222
3281
|
[genrePlaylistByNodeId, prefetchGenreOverview]
|
|
3223
3282
|
);
|
|
3224
|
-
const groupedGenrePlaylistsByRoot = (0,
|
|
3225
|
-
const canShowPopCore = (0,
|
|
3283
|
+
const groupedGenrePlaylistsByRoot = (0, import_react18.useMemo)(() => getGenrePlaylistsGroupedByRoot(genrePlaylists), [genrePlaylists]);
|
|
3284
|
+
const canShowPopCore = (0, import_react18.useMemo)(
|
|
3226
3285
|
() => hasMainstreamPopRoot(
|
|
3227
3286
|
genrePlaylists.map((genrePlaylist) => ({
|
|
3228
3287
|
parentId: genrePlaylist.parent?.uuid ?? null,
|
|
@@ -3231,14 +3290,14 @@ function useGenreTreeViewState({
|
|
|
3231
3290
|
),
|
|
3232
3291
|
[genrePlaylists]
|
|
3233
3292
|
);
|
|
3234
|
-
(0,
|
|
3293
|
+
(0, import_react18.useEffect)(() => {
|
|
3235
3294
|
if (!isLoading && needsPopCore(internalViewMode) && !canShowPopCore) {
|
|
3236
3295
|
setInternalViewMode("wheel");
|
|
3237
3296
|
}
|
|
3238
3297
|
}, [isLoading, canShowPopCore, internalViewMode]);
|
|
3239
3298
|
const selectedViewMode = controlledViewMode ?? internalViewMode;
|
|
3240
3299
|
const viewMode = needsPopCore(selectedViewMode) && !canShowPopCore ? "wheel" : selectedViewMode;
|
|
3241
|
-
const visibleGenrePlaylists = (0,
|
|
3300
|
+
const visibleGenrePlaylists = (0, import_react18.useMemo)(() => {
|
|
3242
3301
|
if (viewMode === "stacked") return genrePlaylists;
|
|
3243
3302
|
const unacceptedRootUuids = new Set(genrePlaylists.filter((gp) => gp.isUnacceptedRoot).map((gp) => gp.uuid));
|
|
3244
3303
|
const accepted = genrePlaylists.filter((gp) => !gp.isUnacceptedRoot && !unacceptedRootUuids.has(gp.root.uuid));
|
|
@@ -3267,7 +3326,7 @@ function useGenreTreeViewState({
|
|
|
3267
3326
|
}
|
|
3268
3327
|
|
|
3269
3328
|
// src/genre-tree/TrackListContext.tsx
|
|
3270
|
-
var
|
|
3329
|
+
var import_react20 = require("react");
|
|
3271
3330
|
|
|
3272
3331
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
3273
3332
|
var import_zod35 = require("zod");
|
|
@@ -3399,21 +3458,21 @@ var TrackListOriginFromGenreCatalogue = class extends TrackListOrigin {
|
|
|
3399
3458
|
};
|
|
3400
3459
|
|
|
3401
3460
|
// src/genre-tree/TrackListSidebarVisibilityContext.tsx
|
|
3402
|
-
var
|
|
3461
|
+
var import_react19 = require("react");
|
|
3403
3462
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3404
|
-
var TrackListSidebarVisibilityContext = (0,
|
|
3463
|
+
var TrackListSidebarVisibilityContext = (0, import_react19.createContext)(void 0);
|
|
3405
3464
|
function TrackListSidebarVisibilityProvider({ children }) {
|
|
3406
|
-
const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0,
|
|
3407
|
-
const toggleTrackListSidebar = (0,
|
|
3465
|
+
const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0, import_react19.useState)(false);
|
|
3466
|
+
const toggleTrackListSidebar = (0, import_react19.useCallback)(() => {
|
|
3408
3467
|
setIsTrackListSidebarVisible((prev) => !prev);
|
|
3409
3468
|
}, []);
|
|
3410
|
-
const showTrackListSidebar = (0,
|
|
3469
|
+
const showTrackListSidebar = (0, import_react19.useCallback)(() => {
|
|
3411
3470
|
setIsTrackListSidebarVisible(true);
|
|
3412
3471
|
}, []);
|
|
3413
|
-
const hideTrackListSidebar = (0,
|
|
3472
|
+
const hideTrackListSidebar = (0, import_react19.useCallback)(() => {
|
|
3414
3473
|
setIsTrackListSidebarVisible(false);
|
|
3415
3474
|
}, []);
|
|
3416
|
-
const value = (0,
|
|
3475
|
+
const value = (0, import_react19.useMemo)(
|
|
3417
3476
|
() => ({
|
|
3418
3477
|
isTrackListSidebarVisible,
|
|
3419
3478
|
toggleTrackListSidebar,
|
|
@@ -3425,7 +3484,7 @@ function TrackListSidebarVisibilityProvider({ children }) {
|
|
|
3425
3484
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TrackListSidebarVisibilityContext.Provider, { value, children });
|
|
3426
3485
|
}
|
|
3427
3486
|
function useTrackListSidebarVisibility() {
|
|
3428
|
-
const context = (0,
|
|
3487
|
+
const context = (0, import_react19.useContext)(TrackListSidebarVisibilityContext);
|
|
3429
3488
|
if (context === void 0) {
|
|
3430
3489
|
throw new Error("useTrackListSidebarVisibility must be used within a TrackListSidebarVisibilityProvider");
|
|
3431
3490
|
}
|
|
@@ -3455,45 +3514,45 @@ function useListTracks(scope, getBackendBaseUrl, schema, listEndpoint, listQuery
|
|
|
3455
3514
|
enabled: playback.ready && scope != null && (scope === "reference" || sessionRestored && !!session?.accessToken)
|
|
3456
3515
|
});
|
|
3457
3516
|
}
|
|
3458
|
-
var TrackListContext = (0,
|
|
3517
|
+
var TrackListContext = (0, import_react20.createContext)(void 0);
|
|
3459
3518
|
function TrackListProvider({
|
|
3460
3519
|
children,
|
|
3461
3520
|
getBackendBaseUrl,
|
|
3462
3521
|
schema
|
|
3463
3522
|
}) {
|
|
3464
|
-
const [trackList, setTrackList] = (0,
|
|
3465
|
-
const [selectedTrack, setSelectedTrack] = (0,
|
|
3466
|
-
const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0,
|
|
3523
|
+
const [trackList, setTrackList] = (0, import_react20.useState)(null);
|
|
3524
|
+
const [selectedTrack, setSelectedTrack] = (0, import_react20.useState)(null);
|
|
3525
|
+
const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0, import_react20.useState)(null);
|
|
3467
3526
|
const { loadTrackForPlayer, setOnTrackEnd, hasPlaybackFailure, playerTrackObject } = usePlayer();
|
|
3468
|
-
const [failureClock, setFailureClock] = (0,
|
|
3469
|
-
(0,
|
|
3527
|
+
const [failureClock, setFailureClock] = (0, import_react20.useState)(0);
|
|
3528
|
+
(0, import_react20.useEffect)(() => {
|
|
3470
3529
|
const timer = setInterval(() => setFailureClock((tick) => tick + 1), 3e4);
|
|
3471
3530
|
return () => clearInterval(timer);
|
|
3472
3531
|
}, []);
|
|
3473
|
-
const runtimeUnplayableTrackIds = (0,
|
|
3532
|
+
const runtimeUnplayableTrackIds = (0, import_react20.useMemo)(() => new Set(
|
|
3474
3533
|
(trackList?.tracks ?? []).filter((track) => isSong(track) && track.youtubeVideo && hasPlaybackFailure(track.youtubeVideo.id)).map((track) => track.uuid)
|
|
3475
3534
|
), [trackList, hasPlaybackFailure, playerTrackObject, failureClock]);
|
|
3476
3535
|
const { showTrackListSidebar } = useTrackListSidebarVisibility();
|
|
3477
3536
|
const playback = usePlaybackContext();
|
|
3478
3537
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
3479
|
-
const pageSchema = (0,
|
|
3480
|
-
const latestPlayRequestRef = (0,
|
|
3481
|
-
const startingPlaybackRef = (0,
|
|
3482
|
-
const loadedContextRef = (0,
|
|
3483
|
-
const autoAdvanceScrollRequestIdRef = (0,
|
|
3484
|
-
const delayedTrackLoadRef = (0,
|
|
3485
|
-
const loadingOriginRef = (0,
|
|
3486
|
-
const pendingAdvanceRef = (0,
|
|
3487
|
-
const clearDelayedTrackLoad = (0,
|
|
3538
|
+
const pageSchema = (0, import_react20.useMemo)(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
|
|
3539
|
+
const latestPlayRequestRef = (0, import_react20.useRef)(0);
|
|
3540
|
+
const startingPlaybackRef = (0, import_react20.useRef)(false);
|
|
3541
|
+
const loadedContextRef = (0, import_react20.useRef)(playback.key);
|
|
3542
|
+
const autoAdvanceScrollRequestIdRef = (0, import_react20.useRef)(0);
|
|
3543
|
+
const delayedTrackLoadRef = (0, import_react20.useRef)(null);
|
|
3544
|
+
const loadingOriginRef = (0, import_react20.useRef)(null);
|
|
3545
|
+
const pendingAdvanceRef = (0, import_react20.useRef)(null);
|
|
3546
|
+
const clearDelayedTrackLoad = (0, import_react20.useCallback)(() => {
|
|
3488
3547
|
if (delayedTrackLoadRef.current !== null) {
|
|
3489
3548
|
clearTimeout(delayedTrackLoadRef.current);
|
|
3490
3549
|
delayedTrackLoadRef.current = null;
|
|
3491
3550
|
}
|
|
3492
3551
|
}, []);
|
|
3493
|
-
const requestAutoAdvanceScroll = (0,
|
|
3552
|
+
const requestAutoAdvanceScroll = (0, import_react20.useCallback)((trackUuid) => {
|
|
3494
3553
|
setAutoAdvanceScrollRequest({ id: ++autoAdvanceScrollRequestIdRef.current, trackUuid });
|
|
3495
3554
|
}, []);
|
|
3496
|
-
const loadTrackAfterSkipDelay = (0,
|
|
3555
|
+
const loadTrackAfterSkipDelay = (0, import_react20.useCallback)(
|
|
3497
3556
|
(trackUuid) => {
|
|
3498
3557
|
clearDelayedTrackLoad();
|
|
3499
3558
|
delayedTrackLoadRef.current = setTimeout(() => {
|
|
@@ -3503,7 +3562,7 @@ function TrackListProvider({
|
|
|
3503
3562
|
},
|
|
3504
3563
|
[clearDelayedTrackLoad, loadTrackForPlayer]
|
|
3505
3564
|
);
|
|
3506
|
-
const fetchTracksPage = (0,
|
|
3565
|
+
const fetchTracksPage = (0, import_react20.useCallback)(
|
|
3507
3566
|
async (uuid, scope, page, from, selection, artistUuid) => {
|
|
3508
3567
|
const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
|
|
3509
3568
|
if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
|
|
@@ -3518,8 +3577,8 @@ function TrackListProvider({
|
|
|
3518
3577
|
},
|
|
3519
3578
|
[fetch2, pageSchema]
|
|
3520
3579
|
);
|
|
3521
|
-
const cataloguePageSchema = (0,
|
|
3522
|
-
const fetchCatalogueTracksPage = (0,
|
|
3580
|
+
const cataloguePageSchema = (0, import_react20.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
|
|
3581
|
+
const fetchCatalogueTracksPage = (0, import_react20.useCallback)(
|
|
3523
3582
|
async (origin, page) => {
|
|
3524
3583
|
const params = {
|
|
3525
3584
|
...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
|
|
@@ -3547,7 +3606,7 @@ function TrackListProvider({
|
|
|
3547
3606
|
},
|
|
3548
3607
|
[fetch2, cataloguePageSchema]
|
|
3549
3608
|
);
|
|
3550
|
-
const advanceAfterTrackEnd = (0,
|
|
3609
|
+
const advanceAfterTrackEnd = (0, import_react20.useCallback)(
|
|
3551
3610
|
(event) => {
|
|
3552
3611
|
const completedTrackId = event?.trackId ?? selectedTrack?.uuid;
|
|
3553
3612
|
if (!completedTrackId || !trackList) return;
|
|
@@ -3579,11 +3638,11 @@ function TrackListProvider({
|
|
|
3579
3638
|
selectedTrack
|
|
3580
3639
|
]
|
|
3581
3640
|
);
|
|
3582
|
-
(0,
|
|
3641
|
+
(0, import_react20.useEffect)(() => {
|
|
3583
3642
|
setOnTrackEnd(trackList && selectedTrack ? advanceAfterTrackEnd : null);
|
|
3584
3643
|
return () => setOnTrackEnd(null);
|
|
3585
3644
|
}, [advanceAfterTrackEnd, trackList, selectedTrack, setOnTrackEnd]);
|
|
3586
|
-
const toTrackAtPosition = (0,
|
|
3645
|
+
const toTrackAtPosition = (0, import_react20.useCallback)(
|
|
3587
3646
|
(position) => {
|
|
3588
3647
|
if (trackList && position >= 0 && position < trackList.tracks.length) {
|
|
3589
3648
|
clearDelayedTrackLoad();
|
|
@@ -3593,7 +3652,7 @@ function TrackListProvider({
|
|
|
3593
3652
|
},
|
|
3594
3653
|
[clearDelayedTrackLoad, trackList]
|
|
3595
3654
|
);
|
|
3596
|
-
const playNewTrackListFromTrackUuid = (0,
|
|
3655
|
+
const playNewTrackListFromTrackUuid = (0, import_react20.useCallback)(
|
|
3597
3656
|
(track, scope) => {
|
|
3598
3657
|
latestPlayRequestRef.current++;
|
|
3599
3658
|
startingPlaybackRef.current = false;
|
|
@@ -3609,7 +3668,7 @@ function TrackListProvider({
|
|
|
3609
3668
|
},
|
|
3610
3669
|
[clearDelayedTrackLoad, showTrackListSidebar, loadTrackForPlayer]
|
|
3611
3670
|
);
|
|
3612
|
-
const playNewTrackListFromGenrePlaylist = (0,
|
|
3671
|
+
const playNewTrackListFromGenrePlaylist = (0, import_react20.useCallback)(
|
|
3613
3672
|
async (genrePlaylist, scope, options) => {
|
|
3614
3673
|
clearDelayedTrackLoad();
|
|
3615
3674
|
const request = ++latestPlayRequestRef.current;
|
|
@@ -3643,7 +3702,7 @@ function TrackListProvider({
|
|
|
3643
3702
|
},
|
|
3644
3703
|
[clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
3645
3704
|
);
|
|
3646
|
-
const playCatalogue = (0,
|
|
3705
|
+
const playCatalogue = (0, import_react20.useCallback)(
|
|
3647
3706
|
async (origin) => {
|
|
3648
3707
|
clearDelayedTrackLoad();
|
|
3649
3708
|
const request = ++latestPlayRequestRef.current;
|
|
@@ -3676,7 +3735,7 @@ function TrackListProvider({
|
|
|
3676
3735
|
},
|
|
3677
3736
|
[clearDelayedTrackLoad, fetchCatalogueTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
3678
3737
|
);
|
|
3679
|
-
const playNewTrackListFromArtist = (0,
|
|
3738
|
+
const playNewTrackListFromArtist = (0, import_react20.useCallback)(
|
|
3680
3739
|
async (artist, scope, options) => {
|
|
3681
3740
|
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
3682
3741
|
if (options.selection && !options.genreUuid) throw new Error("A genre selection requires a genre");
|
|
@@ -3684,15 +3743,15 @@ function TrackListProvider({
|
|
|
3684
3743
|
},
|
|
3685
3744
|
[playCatalogue]
|
|
3686
3745
|
);
|
|
3687
|
-
const playNewTrackListFromGenreCatalogue = (0,
|
|
3746
|
+
const playNewTrackListFromGenreCatalogue = (0, import_react20.useCallback)(
|
|
3688
3747
|
async (genre, scope, options) => {
|
|
3689
3748
|
if (scope !== "reference") throw new Error("Genre catalogues only support the reference scope");
|
|
3690
3749
|
return playCatalogue(new TrackListOriginFromGenreCatalogue(genre, scope, options?.startSongUuid, options?.selection));
|
|
3691
3750
|
},
|
|
3692
3751
|
[playCatalogue]
|
|
3693
3752
|
);
|
|
3694
|
-
const contextKeyRef = (0,
|
|
3695
|
-
(0,
|
|
3753
|
+
const contextKeyRef = (0, import_react20.useRef)(playback.key);
|
|
3754
|
+
(0, import_react20.useEffect)(() => {
|
|
3696
3755
|
if (contextKeyRef.current === playback.key) return;
|
|
3697
3756
|
contextKeyRef.current = playback.key;
|
|
3698
3757
|
if (loadedContextRef.current === playback.key) return;
|
|
@@ -3744,7 +3803,7 @@ function TrackListProvider({
|
|
|
3744
3803
|
});
|
|
3745
3804
|
}
|
|
3746
3805
|
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch2]);
|
|
3747
|
-
const updateTrack = (0,
|
|
3806
|
+
const updateTrack = (0, import_react20.useCallback)((track) => {
|
|
3748
3807
|
setTrackList((prev) => {
|
|
3749
3808
|
if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
|
|
3750
3809
|
const tracks = prev.tracks.map((listed) => listed.uuid === track.uuid ? track : listed);
|
|
@@ -3752,7 +3811,7 @@ function TrackListProvider({
|
|
|
3752
3811
|
});
|
|
3753
3812
|
setSelectedTrack((prev) => prev?.uuid === track.uuid ? track : prev);
|
|
3754
3813
|
}, []);
|
|
3755
|
-
const loadMore = (0,
|
|
3814
|
+
const loadMore = (0, import_react20.useCallback)(async () => {
|
|
3756
3815
|
if (!trackList || trackList.nextPage === null) return;
|
|
3757
3816
|
const origin = trackList.origin;
|
|
3758
3817
|
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
|
|
@@ -3776,7 +3835,7 @@ function TrackListProvider({
|
|
|
3776
3835
|
const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
3777
3836
|
const hasNextTrack = nextTrack !== null || selectedTrackIndex >= 0 && trackList?.nextPage != null;
|
|
3778
3837
|
const hasPreviousTrack = previousTrack !== null;
|
|
3779
|
-
const playNextTrack = (0,
|
|
3838
|
+
const playNextTrack = (0, import_react20.useCallback)(() => {
|
|
3780
3839
|
if (!trackList || !selectedTrack || selectedTrackIndex < 0) return;
|
|
3781
3840
|
clearDelayedTrackLoad();
|
|
3782
3841
|
if (nextTrack) {
|
|
@@ -3793,7 +3852,7 @@ function TrackListProvider({
|
|
|
3793
3852
|
console.error("Failed to load more tracks:", error);
|
|
3794
3853
|
});
|
|
3795
3854
|
}, [clearDelayedTrackLoad, trackList, loadMore, loadTrackForPlayer, nextTrack, selectedTrack, selectedTrackIndex]);
|
|
3796
|
-
const playPreviousTrack = (0,
|
|
3855
|
+
const playPreviousTrack = (0, import_react20.useCallback)(() => {
|
|
3797
3856
|
if (!previousTrack) return;
|
|
3798
3857
|
clearDelayedTrackLoad();
|
|
3799
3858
|
pendingAdvanceRef.current = null;
|
|
@@ -3801,7 +3860,7 @@ function TrackListProvider({
|
|
|
3801
3860
|
setSelectedTrack(previousTrack);
|
|
3802
3861
|
loadTrackForPlayer(previousTrack.uuid);
|
|
3803
3862
|
}, [clearDelayedTrackLoad, loadTrackForPlayer, previousTrack, requestAutoAdvanceScroll]);
|
|
3804
|
-
(0,
|
|
3863
|
+
(0, import_react20.useEffect)(() => {
|
|
3805
3864
|
const pending = pendingAdvanceRef.current;
|
|
3806
3865
|
if (!pending) return;
|
|
3807
3866
|
if (!trackList || trackList.origin !== pending.origin || selectedTrack?.uuid !== pending.trackId) {
|
|
@@ -3835,15 +3894,15 @@ function TrackListProvider({
|
|
|
3835
3894
|
hasPlaybackFailure,
|
|
3836
3895
|
selectedTrack
|
|
3837
3896
|
]);
|
|
3838
|
-
(0,
|
|
3839
|
-
(0,
|
|
3897
|
+
(0, import_react20.useEffect)(() => clearDelayedTrackLoad, [clearDelayedTrackLoad]);
|
|
3898
|
+
(0, import_react20.useEffect)(() => {
|
|
3840
3899
|
if (!trackList || trackList.nextPage === null || !selectedTrack) return;
|
|
3841
3900
|
const index = trackList.tracks.findIndex((track) => track.uuid === selectedTrack.uuid);
|
|
3842
3901
|
if (index !== -1 && trackList.tracks.length - index <= AUTO_LOAD_REMAINING_TRACKS) {
|
|
3843
3902
|
loadMore().catch((error) => console.error("Failed to load more tracks:", error));
|
|
3844
3903
|
}
|
|
3845
3904
|
}, [trackList, selectedTrack, loadMore]);
|
|
3846
|
-
const value = (0,
|
|
3905
|
+
const value = (0, import_react20.useMemo)(
|
|
3847
3906
|
() => ({
|
|
3848
3907
|
trackList,
|
|
3849
3908
|
selectedTrack,
|
|
@@ -3885,7 +3944,7 @@ function TrackListProvider({
|
|
|
3885
3944
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TrackListContext.Provider, { value, children });
|
|
3886
3945
|
}
|
|
3887
3946
|
function useTrackList() {
|
|
3888
|
-
const context = (0,
|
|
3947
|
+
const context = (0, import_react20.useContext)(TrackListContext);
|
|
3889
3948
|
if (!context) {
|
|
3890
3949
|
throw new Error("useTrackList must be used within a TrackListProvider");
|
|
3891
3950
|
}
|
|
@@ -3893,14 +3952,14 @@ function useTrackList() {
|
|
|
3893
3952
|
}
|
|
3894
3953
|
|
|
3895
3954
|
// src/genre-tree/ArtistNames.tsx
|
|
3896
|
-
var
|
|
3955
|
+
var import_react21 = require("react");
|
|
3897
3956
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3898
3957
|
function ArtistNames({
|
|
3899
3958
|
artists,
|
|
3900
3959
|
renderArtistLink
|
|
3901
3960
|
}) {
|
|
3902
3961
|
if (!renderArtistLink) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: artists.map((artist) => artist.name).join(", ") });
|
|
3903
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
3962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react21.Fragment, { children: [
|
|
3904
3963
|
index > 0 && ", ",
|
|
3905
3964
|
renderArtistLink(artist)
|
|
3906
3965
|
] }, artist.uuid)) });
|
|
@@ -3954,6 +4013,9 @@ var capitalizeFirstLetter = (string) => {
|
|
|
3954
4013
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
3955
4014
|
};
|
|
3956
4015
|
|
|
4016
|
+
// src/genre-tree/lib/genre-search.ts
|
|
4017
|
+
var searchGenrePlaylistsByName = (genrePlaylists, query) => rankByName(genrePlaylists, query, (genrePlaylist) => genrePlaylist.name, (genrePlaylist) => genrePlaylist.viewsCount ?? 0);
|
|
4018
|
+
|
|
3957
4019
|
// src/genre-tree/lib/reparent-candidates.ts
|
|
3958
4020
|
var hasCriteria = (genrePlaylist) => genrePlaylist.criteria !== null;
|
|
3959
4021
|
var getReparentCandidates = (genrePlaylists, genrePlaylistUuid) => {
|
|
@@ -4093,6 +4155,7 @@ function editGenreSongPages(data, edit) {
|
|
|
4093
4155
|
createAppErrorFromErrorCode,
|
|
4094
4156
|
createAppErrorFromResult,
|
|
4095
4157
|
createLogout,
|
|
4158
|
+
createNameIndex,
|
|
4096
4159
|
createNetworkOrBackendError,
|
|
4097
4160
|
defaultGenreMusicSelection,
|
|
4098
4161
|
editGenreSongPages,
|
|
@@ -4127,6 +4190,7 @@ function editGenreSongPages(data, edit) {
|
|
|
4127
4190
|
pruneGenrePlaylistsForArtist,
|
|
4128
4191
|
queryClient,
|
|
4129
4192
|
rankByName,
|
|
4193
|
+
rankNameIndex,
|
|
4130
4194
|
resolveRedirectUri,
|
|
4131
4195
|
searchGenrePlaylistsByName,
|
|
4132
4196
|
setSpotifyRequiredCached,
|