@behindthemusictree/app-kit 39.0.0 → 40.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.
@@ -3963,7 +3963,7 @@ interface UseGenreTreeViewStateOptions<O extends CriteriaOverview = CriteriaOver
3963
3963
  getBackendBaseUrl: () => string;
3964
3964
  /** Controlled view mode; when provided the hook never changes it. */
3965
3965
  viewMode?: GenreViewMode;
3966
- /** Narrows the tree to this artist's footprint (see `useVisibleGenrePlaylists`). */
3966
+ /** Projects this artist onto the tree (see `useVisibleGenrePlaylists`). */
3967
3967
  artistUuid?: string | null;
3968
3968
  /** Entity selection is independent of the visible renderer nodes. */
3969
3969
  selectedGenreUuid?: GenreUuid | null;
@@ -3975,9 +3975,11 @@ interface UseGenreTreeViewStateResult {
3975
3975
  /** The tree failed to load and nothing is cached. `genrePlaylists` is empty, which is not "no genres". */
3976
3976
  isError: boolean;
3977
3977
  refetch: () => void;
3978
- /** True while the visible tree is being refreshed or re-pruned; the previous tree stays in `genrePlaylists`. */
3978
+ /** True while the visible tree is being refreshed or re-projected; the previous tree stays in `genrePlaylists`. */
3979
3979
  isFetching: boolean;
3980
3980
  genrePlaylists: CriteriaPlaylistSimple[];
3981
+ /** The open artist's footprint; undefined without an artist. Nodes outside it are rendered muted. */
3982
+ focusUuids: ReadonlySet<string> | undefined;
3981
3983
  genrePlaylistByNodeId: Map<string, CriteriaPlaylistSimple>;
3982
3984
  /** Playlists the current view mode may show: unaccepted roots and, outside stacked/outline, criteria-less playlists are hidden. */
3983
3985
  visibleGenrePlaylists: CriteriaPlaylistSimple[];
@@ -4009,16 +4011,16 @@ declare function useGenreTreeViewState<O extends CriteriaOverview = CriteriaOver
4009
4011
  interface UseVisibleGenrePlaylistsOptions {
4010
4012
  scope: Scope;
4011
4013
  getBackendBaseUrl: () => string;
4012
- /** When set, the tree is pruned to this artist's footprint and carries the artist's counts. */
4014
+ /** When set, the tree carries this artist's counts and `focusUuids` marks their footprint. */
4013
4015
  artistUuid?: string | null;
4014
4016
  }
4015
4017
  /**
4016
- * The tree the user can navigate: the whole canonical tree, or the artist's footprint when
4017
- * `artistUuid` is set. Hosts validate URL state (selected genre, focus) against this list. While the
4018
- * artist's counts load the current tree stays (full, or the previous artist's footprint) and
4019
- * `isFetching` is true; `isLoading` is true only until the first tree arrives. If the counts fail
4020
- * (unknown artist, backend error) the whole tree is served, the artist panel being where that failure
4021
- * is shown.
4018
+ * The tree the user can navigate: always the whole canonical tree. When `artistUuid` is set it
4019
+ * carries the artist's counts and `focusUuids` names their footprint (undefined otherwise); genres
4020
+ * outside it stay navigable and renderers draw them muted. While the artist's counts load the
4021
+ * current tree stays (with the previous artist's projection) and `isFetching` is true; `isLoading`
4022
+ * is true only until the first tree arrives. If the counts fail (unknown artist, backend error) the
4023
+ * plain tree is served, the artist panel being where that failure is shown.
4022
4024
  */
4023
4025
  declare function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid }: UseVisibleGenrePlaylistsOptions): {
4024
4026
  isLoading: boolean;
@@ -4110,6 +4112,7 @@ declare function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid
4110
4112
  isUmbrella?: boolean | undefined;
4111
4113
  scene?: "commercial" | "underground" | null | undefined;
4112
4114
  }[];
4115
+ focusUuids: ReadonlySet<string> | undefined;
4113
4116
  };
4114
4117
 
4115
4118
  declare const SubgenreCountsSchema: z.ZodUnion<readonly [z.ZodObject<{
@@ -4277,6 +4280,13 @@ declare class TrackListFromArtist<T extends TrackBase = TrackBase> extends Track
4277
4280
  constructor(tracks: T[], origin: TrackListOriginFromArtist, total: number, nextPage: number | null);
4278
4281
  }
4279
4282
 
4283
+ /**
4284
+ * The tracks request failed and the global connectivity popup (or a newer request replacing this one) already
4285
+ * accounts for it; callers must not show a second popup.
4286
+ */
4287
+ declare class TracksFailureAlreadyReportedError extends Error {
4288
+ constructor();
4289
+ }
4280
4290
  declare function useListTracks<T>(scope: Scope | null, getBackendBaseUrl: () => string, schema: z.ZodType<T, unknown>, listEndpoint: (page: number) => string, listQueryKey: (page: number) => readonly unknown[], page?: number, pageSize?: number | string): _tanstack_react_query.UseQueryResult<NoInfer<{
4281
4291
  overallTotal: number;
4282
4292
  next: string | null;
@@ -4783,13 +4793,19 @@ declare const hasMainstreamPopRoot: (nodes: {
4783
4793
  name: string;
4784
4794
  }[]) => boolean;
4785
4795
 
4796
+ interface ArtistGenreProjection {
4797
+ /** Every canonical playlist, carrying the artist's counts (zero outside the footprint). */
4798
+ genrePlaylists: CriteriaPlaylistSimple[];
4799
+ /** The artist's footprint: renderers draw every other node muted instead of dropping it. */
4800
+ focusUuids: ReadonlySet<string>;
4801
+ }
4786
4802
  /**
4787
- * Narrows the canonical tree to an artist's footprint: nodes with songs in their subtree (which
4788
- * includes every ancestor of such a node) carry the artist's counts. Two structural exceptions are
4789
- * kept with zero counts: the "Mainstream Pop" root (pop-core needs it) and the scene children of a
4790
- * kept "Core electronic" (the scene stack needs one commercial and one underground child).
4803
+ * Projects an artist onto the canonical tree. No node is dropped: every playlist carries the
4804
+ * artist's counts (zero outside the footprint). The footprint is the nodes with songs in their
4805
+ * subtree, which includes every ancestor of such a node; an artist without genres has an empty
4806
+ * footprint. Since nothing is pruned, no structural node needs to be kept in focus.
4791
4807
  */
4792
- declare const pruneGenrePlaylistsForArtist: (playlists: CriteriaPlaylistSimple[], counts: ArtistGenreCount[]) => CriteriaPlaylistSimple[];
4808
+ declare const projectGenrePlaylistsForArtist: (playlists: CriteriaPlaylistSimple[], counts: ArtistGenreCount[]) => ArtistGenreProjection;
4793
4809
 
4794
4810
  /** Ranked, accent-insensitive name match (exact, prefix, substring, fuzzy). An empty/whitespace query matches nothing. */
4795
4811
  declare const searchGenrePlaylistsByName: <T extends CriteriaPlaylistSimple>(genrePlaylists: T[], query: string) => T[];
@@ -4987,4 +5003,4 @@ declare const ReferenceGenrePlaylistSchema: z.ZodObject<{
4987
5003
  type ReferenceGenreDetailed = z.infer<typeof ReferenceGenreDetailedSchema>;
4988
5004
  type ReferenceGenrePlaylist = z.infer<typeof ReferenceGenrePlaylistSchema>;
4989
5005
 
4990
- 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 };
5006
+ export { ARTIST_LINK_KINDS, type AlbumMinimum, AlbumMinimumSchema, type ArtistAlbum, type ArtistDetailed, ArtistDetailedSchema, type ArtistGenreCount, ArtistGenreCountSchema, type ArtistGenreProjection, 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, TracksFailureAlreadyReportedError, 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, projectGenrePlaylistsForArtist, 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 };
@@ -58,6 +58,7 @@ import {
58
58
  TrackListProvider,
59
59
  TrackListSidebarVisibilityProvider,
60
60
  TrackMinimumSchema,
61
+ TracksFailureAlreadyReportedError,
61
62
  UuidResourceSchema,
62
63
  YOUTUBE_UNPLAYABLE_REASON_LABELS,
63
64
  YoutubeAvailabilitySchema,
@@ -89,7 +90,7 @@ import {
89
90
  makeTrackPlaylistRelPageSchema,
90
91
  makeTrackPlaylistRelSchema,
91
92
  musicBrainzRecordingUrl,
92
- pruneGenrePlaylistsForArtist,
93
+ projectGenrePlaylistsForArtist,
93
94
  rankByName,
94
95
  rankNameIndex,
95
96
  searchGenrePlaylistsByName,
@@ -124,9 +125,9 @@ import {
124
125
  useTrackListSidebarVisibility,
125
126
  useUpdateGenre,
126
127
  useVisibleGenrePlaylists
127
- } from "../chunk-FNRF3IL3.js";
128
- import "../chunk-7S6EALIP.js";
129
- import "../chunk-T5D5T52J.js";
128
+ } from "../chunk-D5UFJF4K.js";
129
+ import "../chunk-AYAKFCBP.js";
130
+ import "../chunk-WL2TKQVN.js";
130
131
  import "../chunk-4MEK3CNF.js";
131
132
  import "../chunk-MAKY4YBN.js";
132
133
  import "../chunk-W4QTTNNA.js";
@@ -196,6 +197,7 @@ export {
196
197
  TrackListProvider,
197
198
  TrackListSidebarVisibilityProvider,
198
199
  TrackMinimumSchema,
200
+ TracksFailureAlreadyReportedError,
199
201
  UuidResourceSchema,
200
202
  YOUTUBE_UNPLAYABLE_REASON_LABELS,
201
203
  YoutubeAvailabilitySchema,
@@ -227,7 +229,7 @@ export {
227
229
  makeTrackPlaylistRelPageSchema,
228
230
  makeTrackPlaylistRelSchema,
229
231
  musicBrainzRecordingUrl,
230
- pruneGenrePlaylistsForArtist,
232
+ projectGenrePlaylistsForArtist,
231
233
  rankByName,
232
234
  rankNameIndex,
233
235
  searchGenrePlaylistsByName,
package/dist/index.cjs CHANGED
@@ -108,6 +108,7 @@ __export(src_exports, {
108
108
  TrackListSidebarVisibilityProvider: () => TrackListSidebarVisibilityProvider,
109
109
  TrackMinimumSchema: () => TrackMinimumSchema,
110
110
  TrackNounProvider: () => TrackNounProvider,
111
+ TracksFailureAlreadyReportedError: () => TracksFailureAlreadyReportedError,
111
112
  UuidResourceSchema: () => UuidResourceSchema,
112
113
  YOUTUBE_UNPLAYABLE_REASON_LABELS: () => YOUTUBE_UNPLAYABLE_REASON_LABELS,
113
114
  YoutubeAvailabilitySchema: () => YoutubeAvailabilitySchema,
@@ -155,7 +156,7 @@ __export(src_exports, {
155
156
  makeTrackPlaylistRelSchema: () => makeTrackPlaylistRelSchema,
156
157
  musicBrainzRecordingUrl: () => musicBrainzRecordingUrl,
157
158
  parseWithLog: () => parseWithLog,
158
- pruneGenrePlaylistsForArtist: () => pruneGenrePlaylistsForArtist,
159
+ projectGenrePlaylistsForArtist: () => projectGenrePlaylistsForArtist,
159
160
  queryClient: () => queryClient,
160
161
  rankByName: () => rankByName,
161
162
  rankNameIndex: () => rankNameIndex,
@@ -547,6 +548,12 @@ async function createAppErrorFromResult(result, backendBaseUrl) {
547
548
  } else {
548
549
  return createAppErrorFromErrorCode("SER5000" /* SERVICE_INTERNAL_ERROR */);
549
550
  }
551
+ } else if (result.status === 502 || result.status === 503 || result.status === 504) {
552
+ if (isBackendError) {
553
+ return createAppErrorFromErrorCode("BAC2000" /* BACKEND_UNAVAILABLE */);
554
+ } else {
555
+ return createAppErrorFromErrorCode("SER5000" /* SERVICE_INTERNAL_ERROR */);
556
+ }
550
557
  }
551
558
  return createAppErrorFromErrorCode("CLI5001" /* CLIENT_UNKNOWN */);
552
559
  }
@@ -3229,38 +3236,41 @@ var import_react21 = require("react");
3229
3236
  // src/genre-tree/useVisibleGenrePlaylists.ts
3230
3237
  var import_react20 = require("react");
3231
3238
 
3232
- // src/genre-tree/lib/prune-genre-playlists-for-artist.ts
3233
- var POP_ROOT_NAME = "Mainstream Pop";
3234
- var CORE_ELECTRONIC_NAME = "Core electronic";
3235
- var pruneGenrePlaylistsForArtist = (playlists, counts) => {
3239
+ // src/genre-tree/lib/project-genre-playlists-for-artist.ts
3240
+ var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { canonical: 0, regional: 0, all: 0 } };
3241
+ var ZERO_ALL = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { all: 0 } };
3242
+ var ZERO_SCOPED_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_SCOPED);
3243
+ var ZERO_ALL_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_ALL);
3244
+ var projectGenrePlaylistsForArtist = (playlists, counts) => {
3236
3245
  const countByPlaylist = new Map(counts.map((count) => [count.genrePlaylist, count]));
3237
- const kept = /* @__PURE__ */ new Set();
3238
- for (const playlist of playlists) {
3239
- const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
3240
- if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
3241
- }
3242
- const coreElectronicUuids = new Set(
3243
- playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
3246
+ const focusUuids = new Set(
3247
+ counts.filter((count) => count.catalogue.genreAndSubgenresTracksCount.all > 0).map((count) => count.genrePlaylist)
3244
3248
  );
3245
- for (const playlist of playlists) {
3246
- if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
3247
- }
3248
- return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => {
3249
+ const genrePlaylists = playlists.map((playlist) => {
3249
3250
  const count = countByPlaylist.get(playlist.uuid);
3250
- const catalogue = GenreCatalogueCountsSchema.parse(playlist.catalogue);
3251
+ if (count) {
3252
+ return {
3253
+ ...playlist,
3254
+ genreOnlyTracksCount: count.genreOnlyTracksCount,
3255
+ genreAndSubgenresTracksCount: count.genreAndSubgenresTracksCount,
3256
+ catalogue: count.catalogue,
3257
+ tracksCount: genreMusicCount(count),
3258
+ // Artist view totals are not served.
3259
+ viewsCount: void 0
3260
+ };
3261
+ }
3251
3262
  const scopes = playlist.genreAndSubgenresTracksCount;
3252
- if (!scopes) throw new Error("Artist projections require a reference genre summary");
3253
- const zero = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: "canonical" in scopes ? { canonical: 0, regional: 0, all: 0 } : { all: 0 } };
3263
+ if (!scopes) throw new Error(`Artist projections require a reference genre summary (genre playlist ${playlist.uuid})`);
3264
+ const isScoped = "canonical" in scopes;
3254
3265
  return {
3255
3266
  ...playlist,
3256
- genreOnlyTracksCount: count?.genreOnlyTracksCount ?? 0,
3257
- genreAndSubgenresTracksCount: count?.genreAndSubgenresTracksCount ?? zero.genreAndSubgenresTracksCount,
3258
- catalogue: count?.catalogue ?? { ...catalogue, ...zero },
3259
- tracksCount: count ? genreMusicCount(count) : 0,
3260
- // Artist view totals are not served.
3267
+ ...isScoped ? ZERO_SCOPED : ZERO_ALL,
3268
+ catalogue: isScoped ? ZERO_SCOPED_CATALOGUE : ZERO_ALL_CATALOGUE,
3269
+ tracksCount: 0,
3261
3270
  viewsCount: void 0
3262
3271
  };
3263
3272
  });
3273
+ return { genrePlaylists, focusUuids };
3264
3274
  };
3265
3275
 
3266
3276
  // src/genre-tree/useVisibleGenrePlaylists.ts
@@ -3269,9 +3279,9 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
3269
3279
  const counts = useArtistGenreCounts(artistUuid, getBackendBaseUrl);
3270
3280
  const artistCounts = artistUuid !== null ? counts.data : void 0;
3271
3281
  const isCountsLoading = artistUuid !== null && (counts.isPending || counts.isPlaceholderData);
3272
- const genrePlaylists = (0, import_react20.useMemo)(() => {
3273
- if (!tree) return [];
3274
- return artistCounts ? pruneGenrePlaylistsForArtist(tree, artistCounts) : tree;
3282
+ const projection = (0, import_react20.useMemo)(() => {
3283
+ if (!tree) return { genrePlaylists: [], focusUuids: void 0 };
3284
+ return artistCounts ? projectGenrePlaylistsForArtist(tree, artistCounts) : { genrePlaylists: tree, focusUuids: void 0 };
3275
3285
  }, [tree, artistCounts]);
3276
3286
  return {
3277
3287
  isLoading: isTreePending,
@@ -3279,7 +3289,8 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
3279
3289
  isError: isTreeError && !tree,
3280
3290
  refetch,
3281
3291
  isFetching: isCountsLoading || !isTreePending && isTreeFetching,
3282
- genrePlaylists
3292
+ genrePlaylists: projection.genrePlaylists,
3293
+ focusUuids: projection.focusUuids
3283
3294
  };
3284
3295
  }
3285
3296
 
@@ -3316,7 +3327,7 @@ function useGenreTreeViewState({
3316
3327
  },
3317
3328
  [isSelectionControlled, onSelectedGenreUuidChange]
3318
3329
  );
3319
- const { isLoading, isError, refetch, isFetching, genrePlaylists } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
3330
+ const { isLoading, isError, refetch, isFetching, genrePlaylists, focusUuids } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
3320
3331
  const genrePlaylistByNodeId = (0, import_react21.useMemo)(() => new Map(genrePlaylists.map((gp) => [gp.uuid, gp])), [genrePlaylists]);
3321
3332
  const selectedGenrePlaylist = (0, import_react21.useMemo)(
3322
3333
  () => genrePlaylists.find((gp) => gp.criteria?.uuid === selectedGenreUuid),
@@ -3382,6 +3393,7 @@ function useGenreTreeViewState({
3382
3393
  refetch: () => void refetch(),
3383
3394
  isFetching,
3384
3395
  genrePlaylists,
3396
+ focusUuids,
3385
3397
  genrePlaylistByNodeId,
3386
3398
  visibleGenrePlaylists,
3387
3399
  groupedGenrePlaylistsByRoot,
@@ -3576,6 +3588,12 @@ var AUTO_SKIP_DELAY_MS = 1e3;
3576
3588
  function isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure) {
3577
3589
  return !runtimeUnplayableTrackIds.has(track.uuid) && (!isSong(track) || songUnplayableReason(track) === null && (!track.youtubeVideo || !hasPlaybackFailure(track.youtubeVideo.id)));
3578
3590
  }
3591
+ var TracksFailureAlreadyReportedError = class extends Error {
3592
+ constructor() {
3593
+ super("Genre playlist tracks request failed; the failure was already reported globally");
3594
+ this.name = "TracksFailureAlreadyReportedError";
3595
+ }
3596
+ };
3579
3597
  function useListTracks(scope, getBackendBaseUrl, schema, listEndpoint, listQueryKey, page = 1, pageSize = 50) {
3580
3598
  const { session, sessionRestored } = useSession();
3581
3599
  return usePlaybackQuery({
@@ -3644,6 +3662,7 @@ function TrackListProvider({
3644
3662
  if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
3645
3663
  const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
3646
3664
  const response = await (page === 1 ? fetchLatest : fetchBound)(endpoint, true, scope === "me", {}, params, false, !!from);
3665
+ if (response === null && !from) throw new TracksFailureAlreadyReportedError();
3647
3666
  const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
3648
3667
  return {
3649
3668
  tracks: parsed.results.map((rel) => rel.track),
@@ -4215,6 +4234,7 @@ function editGenreSongPages(data, edit) {
4215
4234
  TrackListSidebarVisibilityProvider,
4216
4235
  TrackMinimumSchema,
4217
4236
  TrackNounProvider,
4237
+ TracksFailureAlreadyReportedError,
4218
4238
  UuidResourceSchema,
4219
4239
  YOUTUBE_UNPLAYABLE_REASON_LABELS,
4220
4240
  YoutubeAvailabilitySchema,
@@ -4262,7 +4282,7 @@ function editGenreSongPages(data, edit) {
4262
4282
  makeTrackPlaylistRelSchema,
4263
4283
  musicBrainzRecordingUrl,
4264
4284
  parseWithLog,
4265
- pruneGenrePlaylistsForArtist,
4285
+ projectGenrePlaylistsForArtist,
4266
4286
  queryClient,
4267
4287
  rankByName,
4268
4288
  rankNameIndex,