@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.
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/{chunk-7S6EALIP.js → chunk-AYAKFCBP.js} +2 -2
- package/dist/{chunk-FNRF3IL3.js → chunk-D5UFJF4K.js} +45 -32
- package/dist/chunk-D5UFJF4K.js.map +1 -0
- package/dist/{chunk-5YLNSX34.js → chunk-MF7SJIEY.js} +2 -2
- package/dist/{chunk-T5D5T52J.js → chunk-WL2TKQVN.js} +7 -1
- package/dist/chunk-WL2TKQVN.js.map +1 -0
- package/dist/genre-tree/index.cjs +50 -30
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +31 -15
- package/dist/genre-tree/index.js +7 -5
- package/dist/index.cjs +50 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -6
- package/dist/transport/index.cjs +6 -0
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-FNRF3IL3.js.map +0 -1
- package/dist/chunk-T5D5T52J.js.map +0 -1
- /package/dist/{chunk-7S6EALIP.js.map → chunk-AYAKFCBP.js.map} +0 -0
- /package/dist/{chunk-5YLNSX34.js.map → chunk-MF7SJIEY.js.map} +0 -0
|
@@ -81,6 +81,7 @@ __export(genre_tree_exports, {
|
|
|
81
81
|
TrackListProvider: () => TrackListProvider,
|
|
82
82
|
TrackListSidebarVisibilityProvider: () => TrackListSidebarVisibilityProvider,
|
|
83
83
|
TrackMinimumSchema: () => TrackMinimumSchema,
|
|
84
|
+
TracksFailureAlreadyReportedError: () => TracksFailureAlreadyReportedError,
|
|
84
85
|
UuidResourceSchema: () => UuidResourceSchema,
|
|
85
86
|
YOUTUBE_UNPLAYABLE_REASON_LABELS: () => YOUTUBE_UNPLAYABLE_REASON_LABELS,
|
|
86
87
|
YoutubeAvailabilitySchema: () => YoutubeAvailabilitySchema,
|
|
@@ -112,7 +113,7 @@ __export(genre_tree_exports, {
|
|
|
112
113
|
makeTrackPlaylistRelPageSchema: () => makeTrackPlaylistRelPageSchema,
|
|
113
114
|
makeTrackPlaylistRelSchema: () => makeTrackPlaylistRelSchema,
|
|
114
115
|
musicBrainzRecordingUrl: () => musicBrainzRecordingUrl,
|
|
115
|
-
|
|
116
|
+
projectGenrePlaylistsForArtist: () => projectGenrePlaylistsForArtist,
|
|
116
117
|
rankByName: () => rankByName,
|
|
117
118
|
rankNameIndex: () => rankNameIndex,
|
|
118
119
|
searchGenrePlaylistsByName: () => searchGenrePlaylistsByName,
|
|
@@ -647,6 +648,12 @@ async function createAppErrorFromResult(result, backendBaseUrl) {
|
|
|
647
648
|
} else {
|
|
648
649
|
return createAppErrorFromErrorCode("SER5000" /* SERVICE_INTERNAL_ERROR */);
|
|
649
650
|
}
|
|
651
|
+
} else if (result.status === 502 || result.status === 503 || result.status === 504) {
|
|
652
|
+
if (isBackendError) {
|
|
653
|
+
return createAppErrorFromErrorCode("BAC2000" /* BACKEND_UNAVAILABLE */);
|
|
654
|
+
} else {
|
|
655
|
+
return createAppErrorFromErrorCode("SER5000" /* SERVICE_INTERNAL_ERROR */);
|
|
656
|
+
}
|
|
650
657
|
}
|
|
651
658
|
return createAppErrorFromErrorCode("CLI5001" /* CLIENT_UNKNOWN */);
|
|
652
659
|
}
|
|
@@ -2001,38 +2008,41 @@ var import_react14 = require("react");
|
|
|
2001
2008
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
2002
2009
|
var import_react13 = require("react");
|
|
2003
2010
|
|
|
2004
|
-
// src/genre-tree/lib/
|
|
2005
|
-
var
|
|
2006
|
-
var
|
|
2007
|
-
var
|
|
2011
|
+
// src/genre-tree/lib/project-genre-playlists-for-artist.ts
|
|
2012
|
+
var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { canonical: 0, regional: 0, all: 0 } };
|
|
2013
|
+
var ZERO_ALL = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { all: 0 } };
|
|
2014
|
+
var ZERO_SCOPED_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_SCOPED);
|
|
2015
|
+
var ZERO_ALL_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_ALL);
|
|
2016
|
+
var projectGenrePlaylistsForArtist = (playlists, counts) => {
|
|
2008
2017
|
const countByPlaylist = new Map(counts.map((count) => [count.genrePlaylist, count]));
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2011
|
-
const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
|
|
2012
|
-
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
|
|
2013
|
-
}
|
|
2014
|
-
const coreElectronicUuids = new Set(
|
|
2015
|
-
playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
|
|
2018
|
+
const focusUuids = new Set(
|
|
2019
|
+
counts.filter((count) => count.catalogue.genreAndSubgenresTracksCount.all > 0).map((count) => count.genrePlaylist)
|
|
2016
2020
|
);
|
|
2017
|
-
|
|
2018
|
-
if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
|
|
2019
|
-
}
|
|
2020
|
-
return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => {
|
|
2021
|
+
const genrePlaylists = playlists.map((playlist) => {
|
|
2021
2022
|
const count = countByPlaylist.get(playlist.uuid);
|
|
2022
|
-
|
|
2023
|
+
if (count) {
|
|
2024
|
+
return {
|
|
2025
|
+
...playlist,
|
|
2026
|
+
genreOnlyTracksCount: count.genreOnlyTracksCount,
|
|
2027
|
+
genreAndSubgenresTracksCount: count.genreAndSubgenresTracksCount,
|
|
2028
|
+
catalogue: count.catalogue,
|
|
2029
|
+
tracksCount: genreMusicCount(count),
|
|
2030
|
+
// Artist view totals are not served.
|
|
2031
|
+
viewsCount: void 0
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2023
2034
|
const scopes = playlist.genreAndSubgenresTracksCount;
|
|
2024
|
-
if (!scopes) throw new Error(
|
|
2025
|
-
const
|
|
2035
|
+
if (!scopes) throw new Error(`Artist projections require a reference genre summary (genre playlist ${playlist.uuid})`);
|
|
2036
|
+
const isScoped = "canonical" in scopes;
|
|
2026
2037
|
return {
|
|
2027
2038
|
...playlist,
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
tracksCount: count ? genreMusicCount(count) : 0,
|
|
2032
|
-
// Artist view totals are not served.
|
|
2039
|
+
...isScoped ? ZERO_SCOPED : ZERO_ALL,
|
|
2040
|
+
catalogue: isScoped ? ZERO_SCOPED_CATALOGUE : ZERO_ALL_CATALOGUE,
|
|
2041
|
+
tracksCount: 0,
|
|
2033
2042
|
viewsCount: void 0
|
|
2034
2043
|
};
|
|
2035
2044
|
});
|
|
2045
|
+
return { genrePlaylists, focusUuids };
|
|
2036
2046
|
};
|
|
2037
2047
|
|
|
2038
2048
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
@@ -2041,9 +2051,9 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
|
|
|
2041
2051
|
const counts = useArtistGenreCounts(artistUuid, getBackendBaseUrl);
|
|
2042
2052
|
const artistCounts = artistUuid !== null ? counts.data : void 0;
|
|
2043
2053
|
const isCountsLoading = artistUuid !== null && (counts.isPending || counts.isPlaceholderData);
|
|
2044
|
-
const
|
|
2045
|
-
if (!tree) return [];
|
|
2046
|
-
return artistCounts ?
|
|
2054
|
+
const projection = (0, import_react13.useMemo)(() => {
|
|
2055
|
+
if (!tree) return { genrePlaylists: [], focusUuids: void 0 };
|
|
2056
|
+
return artistCounts ? projectGenrePlaylistsForArtist(tree, artistCounts) : { genrePlaylists: tree, focusUuids: void 0 };
|
|
2047
2057
|
}, [tree, artistCounts]);
|
|
2048
2058
|
return {
|
|
2049
2059
|
isLoading: isTreePending,
|
|
@@ -2051,7 +2061,8 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
|
|
|
2051
2061
|
isError: isTreeError && !tree,
|
|
2052
2062
|
refetch,
|
|
2053
2063
|
isFetching: isCountsLoading || !isTreePending && isTreeFetching,
|
|
2054
|
-
genrePlaylists
|
|
2064
|
+
genrePlaylists: projection.genrePlaylists,
|
|
2065
|
+
focusUuids: projection.focusUuids
|
|
2055
2066
|
};
|
|
2056
2067
|
}
|
|
2057
2068
|
|
|
@@ -2088,7 +2099,7 @@ function useGenreTreeViewState({
|
|
|
2088
2099
|
},
|
|
2089
2100
|
[isSelectionControlled, onSelectedGenreUuidChange]
|
|
2090
2101
|
);
|
|
2091
|
-
const { isLoading, isError, refetch, isFetching, genrePlaylists } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
|
|
2102
|
+
const { isLoading, isError, refetch, isFetching, genrePlaylists, focusUuids } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
|
|
2092
2103
|
const genrePlaylistByNodeId = (0, import_react14.useMemo)(() => new Map(genrePlaylists.map((gp) => [gp.uuid, gp])), [genrePlaylists]);
|
|
2093
2104
|
const selectedGenrePlaylist = (0, import_react14.useMemo)(
|
|
2094
2105
|
() => genrePlaylists.find((gp) => gp.criteria?.uuid === selectedGenreUuid),
|
|
@@ -2154,6 +2165,7 @@ function useGenreTreeViewState({
|
|
|
2154
2165
|
refetch: () => void refetch(),
|
|
2155
2166
|
isFetching,
|
|
2156
2167
|
genrePlaylists,
|
|
2168
|
+
focusUuids,
|
|
2157
2169
|
genrePlaylistByNodeId,
|
|
2158
2170
|
visibleGenrePlaylists,
|
|
2159
2171
|
groupedGenrePlaylistsByRoot,
|
|
@@ -2365,6 +2377,12 @@ var AUTO_SKIP_DELAY_MS = 1e3;
|
|
|
2365
2377
|
function isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure) {
|
|
2366
2378
|
return !runtimeUnplayableTrackIds.has(track.uuid) && (!isSong(track) || songUnplayableReason(track) === null && (!track.youtubeVideo || !hasPlaybackFailure(track.youtubeVideo.id)));
|
|
2367
2379
|
}
|
|
2380
|
+
var TracksFailureAlreadyReportedError = class extends Error {
|
|
2381
|
+
constructor() {
|
|
2382
|
+
super("Genre playlist tracks request failed; the failure was already reported globally");
|
|
2383
|
+
this.name = "TracksFailureAlreadyReportedError";
|
|
2384
|
+
}
|
|
2385
|
+
};
|
|
2368
2386
|
function useListTracks(scope, getBackendBaseUrl, schema, listEndpoint, listQueryKey, page = 1, pageSize = 50) {
|
|
2369
2387
|
const { session, sessionRestored } = useSession();
|
|
2370
2388
|
return usePlaybackQuery({
|
|
@@ -2433,6 +2451,7 @@ function TrackListProvider({
|
|
|
2433
2451
|
if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
|
|
2434
2452
|
const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
|
|
2435
2453
|
const response = await (page === 1 ? fetchLatest : fetchBound)(endpoint, true, scope === "me", {}, params, false, !!from);
|
|
2454
|
+
if (response === null && !from) throw new TracksFailureAlreadyReportedError();
|
|
2436
2455
|
const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
|
|
2437
2456
|
return {
|
|
2438
2457
|
tracks: parsed.results.map((rel) => rel.track),
|
|
@@ -2977,6 +2996,7 @@ function editGenreSongPages(data, edit) {
|
|
|
2977
2996
|
TrackListProvider,
|
|
2978
2997
|
TrackListSidebarVisibilityProvider,
|
|
2979
2998
|
TrackMinimumSchema,
|
|
2999
|
+
TracksFailureAlreadyReportedError,
|
|
2980
3000
|
UuidResourceSchema,
|
|
2981
3001
|
YOUTUBE_UNPLAYABLE_REASON_LABELS,
|
|
2982
3002
|
YoutubeAvailabilitySchema,
|
|
@@ -3008,7 +3028,7 @@ function editGenreSongPages(data, edit) {
|
|
|
3008
3028
|
makeTrackPlaylistRelPageSchema,
|
|
3009
3029
|
makeTrackPlaylistRelSchema,
|
|
3010
3030
|
musicBrainzRecordingUrl,
|
|
3011
|
-
|
|
3031
|
+
projectGenrePlaylistsForArtist,
|
|
3012
3032
|
rankByName,
|
|
3013
3033
|
rankNameIndex,
|
|
3014
3034
|
searchGenrePlaylistsByName,
|