@behindthemusictree/app-kit 33.2.0 → 34.0.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-727PIKKR.js → chunk-3PITD62C.js} +477 -325
- package/dist/chunk-3PITD62C.js.map +1 -0
- package/dist/genre-tree/index.cjs +523 -355
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +1354 -226
- package/dist/genre-tree/index.js +29 -1
- package/dist/index.cjs +471 -303
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -1
- package/package.json +1 -1
- package/dist/chunk-727PIKKR.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,10 @@ __export(src_exports, {
|
|
|
56
56
|
FORM_RATING_NULL_VALUE: () => FORM_RATING_NULL_VALUE,
|
|
57
57
|
FUZZY_MIN_SIMILARITY: () => FUZZY_MIN_SIMILARITY,
|
|
58
58
|
GOOGLE_EXCHANGE_CONFIG: () => GOOGLE_EXCHANGE_CONFIG,
|
|
59
|
+
GenreCatalogueCountsSchema: () => GenreCatalogueCountsSchema,
|
|
60
|
+
GenreCountsSchema: () => GenreCountsSchema,
|
|
61
|
+
GenreCoverageSchema: () => GenreCoverageSchema,
|
|
62
|
+
GenrePlaylistSummarySchema: () => GenrePlaylistSummarySchema,
|
|
59
63
|
GenrePlaylistUuidSchema: () => GenrePlaylistUuidSchema,
|
|
60
64
|
GenreSearchResultSchema: () => GenreSearchResultSchema,
|
|
61
65
|
GenreSearchResultsSchema: () => GenreSearchResultsSchema,
|
|
@@ -73,6 +77,8 @@ __export(src_exports, {
|
|
|
73
77
|
PlayerProvider: () => PlayerProvider,
|
|
74
78
|
PlayerVideoSurface: () => PlayerVideoSurface,
|
|
75
79
|
PopupProvider: () => PopupProvider,
|
|
80
|
+
ReferenceGenreDetailedSchema: () => ReferenceGenreDetailedSchema,
|
|
81
|
+
ReferenceGenrePlaylistSchema: () => ReferenceGenrePlaylistSchema,
|
|
76
82
|
RegionGenreLexiconEntrySchema: () => RegionGenreLexiconEntrySchema,
|
|
77
83
|
RegionGenreLexiconSchema: () => RegionGenreLexiconSchema,
|
|
78
84
|
SEARCH_DEBOUNCE_MS: () => SEARCH_DEBOUNCE_MS,
|
|
@@ -85,6 +91,8 @@ __export(src_exports, {
|
|
|
85
91
|
SongHistorySchema: () => SongHistorySchema,
|
|
86
92
|
SongSearchResultSchema: () => SongSearchResultSchema,
|
|
87
93
|
SongSearchResultsSchema: () => SongSearchResultsSchema,
|
|
94
|
+
SubgenreCountsSchema: () => SubgenreCountsSchema,
|
|
95
|
+
SubgenreScopeSchema: () => SubgenreScopeSchema,
|
|
88
96
|
TrackBaseSchema: () => TrackBaseSchema,
|
|
89
97
|
TrackList: () => TrackList,
|
|
90
98
|
TrackListFromArtist: () => TrackListFromArtist,
|
|
@@ -93,6 +101,7 @@ __export(src_exports, {
|
|
|
93
101
|
TrackListOrigin: () => TrackListOrigin,
|
|
94
102
|
TrackListOriginFromArtist: () => TrackListOriginFromArtist,
|
|
95
103
|
TrackListOriginFromCriteriaPlaylist: () => TrackListOriginFromCriteriaPlaylist,
|
|
104
|
+
TrackListOriginFromGenreCatalogue: () => TrackListOriginFromGenreCatalogue,
|
|
96
105
|
TrackListOriginFromTrack: () => TrackListOriginFromTrack,
|
|
97
106
|
TrackListOriginType: () => TrackListOriginType,
|
|
98
107
|
TrackListProvider: () => TrackListProvider,
|
|
@@ -115,14 +124,19 @@ __export(src_exports, {
|
|
|
115
124
|
createAppErrorFromResult: () => createAppErrorFromResult,
|
|
116
125
|
createLogout: () => createLogout,
|
|
117
126
|
createNetworkOrBackendError: () => createNetworkOrBackendError,
|
|
127
|
+
defaultGenreMusicSelection: () => defaultGenreMusicSelection,
|
|
118
128
|
editGenreSongPages: () => editGenreSongPages,
|
|
119
129
|
exchangeCodeWithBackend: () => exchangeCodeWithBackend,
|
|
120
130
|
fetchWrapper: () => fetchWrapper,
|
|
121
131
|
foldSearchText: () => foldSearchText,
|
|
122
132
|
formatTime: () => formatTime,
|
|
123
133
|
genreEndpoints: () => genreEndpoints,
|
|
134
|
+
genreMusicCount: () => genreMusicCount,
|
|
135
|
+
genreMusicQueryParams: () => genreMusicQueryParams,
|
|
136
|
+
genreMusicSelectionKey: () => genreMusicSelectionKey,
|
|
124
137
|
genrePlaylistEndpoints: () => genrePlaylistEndpoints,
|
|
125
138
|
genrePlaylistQueryKeys: () => genrePlaylistQueryKeys,
|
|
139
|
+
genrePlaylistTrackCount: () => genrePlaylistTrackCount,
|
|
126
140
|
genreQueryKeys: () => genreQueryKeys,
|
|
127
141
|
genreSearchQueryKeys: () => genreSearchQueryKeys,
|
|
128
142
|
genreUpdateMutationKey: () => genreUpdateMutationKey,
|
|
@@ -1980,56 +1994,159 @@ function useCurrentTime() {
|
|
|
1980
1994
|
}
|
|
1981
1995
|
|
|
1982
1996
|
// src/genre-tree/useGenre.ts
|
|
1983
|
-
var
|
|
1984
|
-
var import_react_query5 = require("@tanstack/react-query");
|
|
1985
|
-
var import_react13 = require("react");
|
|
1997
|
+
var import_zod24 = require("zod");
|
|
1986
1998
|
|
|
1987
|
-
// src/genre-tree/
|
|
1988
|
-
var
|
|
1989
|
-
var import_react_query4 = require("@tanstack/react-query");
|
|
1999
|
+
// src/genre-tree/schemas/criteria/detailed.ts
|
|
2000
|
+
var import_zod15 = require("zod");
|
|
1990
2001
|
|
|
1991
|
-
// src/genre-tree/schemas/
|
|
1992
|
-
var
|
|
2002
|
+
// src/genre-tree/schemas/genre-music.ts
|
|
2003
|
+
var import_zod7 = require("zod");
|
|
1993
2004
|
|
|
1994
|
-
// src/genre-tree/schemas/criteria-playlist/
|
|
1995
|
-
var
|
|
2005
|
+
// src/genre-tree/schemas/criteria-playlist/minimum.ts
|
|
2006
|
+
var import_zod6 = require("zod");
|
|
1996
2007
|
|
|
1997
2008
|
// src/genre-tree/schemas/ids.ts
|
|
1998
2009
|
var import_zod5 = require("zod");
|
|
1999
2010
|
var GenreUuidSchema = import_zod5.z.string().uuid().brand();
|
|
2000
2011
|
var GenrePlaylistUuidSchema = import_zod5.z.string().uuid().brand();
|
|
2001
2012
|
|
|
2013
|
+
// src/genre-tree/schemas/criteria-playlist/minimum.ts
|
|
2014
|
+
var CriteriaPlaylistMinimumSchema = import_zod6.z.object({
|
|
2015
|
+
uuid: GenrePlaylistUuidSchema,
|
|
2016
|
+
name: import_zod6.z.string()
|
|
2017
|
+
});
|
|
2018
|
+
|
|
2019
|
+
// src/genre-tree/schemas/genre-music.ts
|
|
2020
|
+
var CountSchema = import_zod7.z.number().int().nonnegative();
|
|
2021
|
+
var SubgenreCountsSchema = import_zod7.z.union([
|
|
2022
|
+
import_zod7.z.object({ canonical: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
|
|
2023
|
+
import_zod7.z.object({ all: CountSchema }).strict()
|
|
2024
|
+
]).refine(
|
|
2025
|
+
(counts) => !("canonical" in counts) || counts.all >= counts.canonical && counts.all >= counts.regional,
|
|
2026
|
+
"The combined count must include both scoped selections"
|
|
2027
|
+
);
|
|
2028
|
+
var GenreCountsSchema = import_zod7.z.object({
|
|
2029
|
+
genreOnlyTracksCount: CountSchema,
|
|
2030
|
+
genreAndSubgenresTracksCount: SubgenreCountsSchema
|
|
2031
|
+
});
|
|
2032
|
+
var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTracksCount).every((count) => count >= counts.genreOnlyTracksCount);
|
|
2033
|
+
var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
|
|
2034
|
+
var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
|
|
2035
|
+
var GenreCoverageSchema = import_zod7.z.enum(["genreOnly", "genreAndSubgenres"]);
|
|
2036
|
+
var SubgenreScopeSchema = import_zod7.z.enum(["canonical", "regional", "all"]);
|
|
2037
|
+
|
|
2002
2038
|
// src/genre-tree/schemas/criteria/minimum.ts
|
|
2003
|
-
var
|
|
2004
|
-
var CriteriaMinimumSchema =
|
|
2039
|
+
var import_zod8 = require("zod");
|
|
2040
|
+
var CriteriaMinimumSchema = import_zod8.z.object({
|
|
2005
2041
|
uuid: GenreUuidSchema,
|
|
2006
|
-
name:
|
|
2007
|
-
side:
|
|
2008
|
-
wikidataId:
|
|
2042
|
+
name: import_zod8.z.string(),
|
|
2043
|
+
side: import_zod8.z.enum(["core", "pop"]).nullable().optional(),
|
|
2044
|
+
wikidataId: import_zod8.z.string().nullable().optional()
|
|
2009
2045
|
});
|
|
2010
2046
|
|
|
2011
|
-
// src/genre-tree/schemas/
|
|
2012
|
-
var
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2047
|
+
// src/genre-tree/schemas/track/base.ts
|
|
2048
|
+
var import_zod12 = require("zod");
|
|
2049
|
+
|
|
2050
|
+
// src/genre-tree/schemas/artist-minimum.ts
|
|
2051
|
+
var import_zod9 = require("zod");
|
|
2052
|
+
var ArtistMinimumSchema = import_zod9.z.object({
|
|
2053
|
+
uuid: import_zod9.z.string().uuid(),
|
|
2054
|
+
name: import_zod9.z.string(),
|
|
2055
|
+
isSpecialPurpose: import_zod9.z.boolean().optional()
|
|
2056
|
+
});
|
|
2057
|
+
|
|
2058
|
+
// src/genre-tree/schemas/album-minimum.ts
|
|
2059
|
+
var import_zod10 = require("zod");
|
|
2060
|
+
var AlbumMinimumSchema = import_zod10.z.object({
|
|
2061
|
+
uuid: import_zod10.z.string().uuid(),
|
|
2062
|
+
name: import_zod10.z.string(),
|
|
2063
|
+
albumArtists: import_zod10.z.array(ArtistMinimumSchema).nullable().optional()
|
|
2064
|
+
});
|
|
2065
|
+
|
|
2066
|
+
// src/genre-tree/schemas/uuid-resource.ts
|
|
2067
|
+
var import_zod11 = require("zod");
|
|
2068
|
+
var UuidResourceSchema = import_zod11.z.object({
|
|
2069
|
+
uuid: import_zod11.z.string().uuid()
|
|
2070
|
+
});
|
|
2071
|
+
|
|
2072
|
+
// src/genre-tree/schemas/track/base.ts
|
|
2073
|
+
var TrackBaseSchema = UuidResourceSchema.extend({
|
|
2074
|
+
title: import_zod12.z.string(),
|
|
2075
|
+
artists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional(),
|
|
2076
|
+
album: AlbumMinimumSchema.nullable().optional(),
|
|
2077
|
+
trackNumber: import_zod12.z.number().nullable().optional(),
|
|
2078
|
+
// null for a song not yet linked to a genre.
|
|
2079
|
+
genre: CriteriaMinimumSchema.nullable(),
|
|
2080
|
+
rating: import_zod12.z.number().min(0).max(10).nullable().optional(),
|
|
2081
|
+
language: import_zod12.z.string().nullable().optional(),
|
|
2082
|
+
playCount: import_zod12.z.number().min(0),
|
|
2083
|
+
createdOn: import_zod12.z.string().datetime(),
|
|
2084
|
+
updatedOn: import_zod12.z.string().datetime().nullable().optional()
|
|
2085
|
+
});
|
|
2086
|
+
|
|
2087
|
+
// src/genre-tree/schemas/track/minimum.ts
|
|
2088
|
+
var TrackMinimumSchema = TrackBaseSchema.pick({
|
|
2089
|
+
uuid: true,
|
|
2090
|
+
title: true,
|
|
2091
|
+
artists: true
|
|
2092
|
+
});
|
|
2093
|
+
|
|
2094
|
+
// src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
|
|
2095
|
+
var import_zod13 = require("zod");
|
|
2096
|
+
var CriteriaLineageRelWithoutAscendantSchema = import_zod13.z.object({
|
|
2097
|
+
descendant: CriteriaMinimumSchema,
|
|
2098
|
+
degree: import_zod13.z.number()
|
|
2099
|
+
});
|
|
2100
|
+
|
|
2101
|
+
// src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
|
|
2102
|
+
var import_zod14 = require("zod");
|
|
2103
|
+
var CriteriaLineageRelWithoutDescendantSchema = import_zod14.z.object({
|
|
2104
|
+
ascendant: CriteriaMinimumSchema,
|
|
2105
|
+
degree: import_zod14.z.number()
|
|
2016
2106
|
});
|
|
2017
2107
|
|
|
2108
|
+
// src/genre-tree/schemas/criteria/detailed.ts
|
|
2109
|
+
var CriteriaDetailedSchema = import_zod15.z.object({
|
|
2110
|
+
uuid: GenreUuidSchema,
|
|
2111
|
+
name: import_zod15.z.string(),
|
|
2112
|
+
summary: import_zod15.z.string().nullable(),
|
|
2113
|
+
// Optional until every deployed API serves it.
|
|
2114
|
+
wikidataId: import_zod15.z.string().nullable().optional(),
|
|
2115
|
+
parent: CriteriaMinimumSchema.nullable(),
|
|
2116
|
+
ascendants: import_zod15.z.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
2117
|
+
descendants: import_zod15.z.array(CriteriaLineageRelWithoutAscendantSchema),
|
|
2118
|
+
root: CriteriaMinimumSchema,
|
|
2119
|
+
children: import_zod15.z.array(CriteriaMinimumSchema),
|
|
2120
|
+
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
2121
|
+
criteriaPlaylist: import_zod15.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]),
|
|
2122
|
+
tracks: import_zod15.z.array(TrackMinimumSchema),
|
|
2123
|
+
essentialSongs: import_zod15.z.array(TrackMinimumSchema),
|
|
2124
|
+
tracksCount: import_zod15.z.number(),
|
|
2125
|
+
updatedOn: import_zod15.z.string().datetime().nullable()
|
|
2126
|
+
});
|
|
2127
|
+
|
|
2128
|
+
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
2129
|
+
var import_zod17 = require("zod");
|
|
2130
|
+
|
|
2018
2131
|
// src/genre-tree/schemas/criteria-playlist/detailed.ts
|
|
2019
|
-
var
|
|
2132
|
+
var import_zod16 = require("zod");
|
|
2133
|
+
var CriteriaPlaylistDetailedSchema = import_zod16.z.object({
|
|
2020
2134
|
uuid: GenrePlaylistUuidSchema,
|
|
2021
|
-
name:
|
|
2022
|
-
tracksCount:
|
|
2135
|
+
name: import_zod16.z.string(),
|
|
2136
|
+
tracksCount: import_zod16.z.number(),
|
|
2137
|
+
genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
|
|
2138
|
+
genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
|
|
2139
|
+
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
2023
2140
|
// Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
|
|
2024
|
-
viewsCount:
|
|
2025
|
-
durationInSec:
|
|
2026
|
-
durationStrInHourMinSec:
|
|
2141
|
+
viewsCount: import_zod16.z.number().optional(),
|
|
2142
|
+
durationInSec: import_zod16.z.number().min(0).nullable().optional(),
|
|
2143
|
+
durationStrInHourMinSec: import_zod16.z.string().nullable().optional(),
|
|
2027
2144
|
// Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
|
|
2028
2145
|
criteria: CriteriaMinimumSchema.nullable(),
|
|
2029
2146
|
parent: CriteriaPlaylistMinimumSchema.nullable(),
|
|
2030
2147
|
root: CriteriaPlaylistMinimumSchema,
|
|
2031
|
-
createdOn:
|
|
2032
|
-
updatedOn:
|
|
2148
|
+
createdOn: import_zod16.z.string(),
|
|
2149
|
+
updatedOn: import_zod16.z.string().nullable()
|
|
2033
2150
|
});
|
|
2034
2151
|
|
|
2035
2152
|
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
@@ -2040,18 +2157,42 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
|
|
|
2040
2157
|
parent: true,
|
|
2041
2158
|
root: true,
|
|
2042
2159
|
tracksCount: true,
|
|
2160
|
+
genreOnlyTracksCount: true,
|
|
2161
|
+
genreAndSubgenresTracksCount: true,
|
|
2162
|
+
catalogue: true,
|
|
2043
2163
|
viewsCount: true,
|
|
2044
2164
|
createdOn: true,
|
|
2045
2165
|
updatedOn: true
|
|
2046
2166
|
}).extend({
|
|
2047
2167
|
// Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
|
|
2048
|
-
isUnacceptedRoot:
|
|
2168
|
+
isUnacceptedRoot: import_zod17.z.boolean(),
|
|
2049
2169
|
// Optional: a backend that does not curate umbrella genres omits it.
|
|
2050
|
-
isUmbrella:
|
|
2170
|
+
isUmbrella: import_zod17.z.boolean().optional(),
|
|
2051
2171
|
// Optional: only the grow tree payload carries it; null when the genre has no scene.
|
|
2052
|
-
scene:
|
|
2172
|
+
scene: import_zod17.z.enum(["commercial", "underground"]).nullable().optional()
|
|
2173
|
+
});
|
|
2174
|
+
|
|
2175
|
+
// src/genre-tree/schemas/reference-genre.ts
|
|
2176
|
+
var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
|
|
2177
|
+
catalogue: GenreCatalogueCountsSchema,
|
|
2178
|
+
criteriaPlaylist: GenrePlaylistSummarySchema
|
|
2179
|
+
});
|
|
2180
|
+
var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
|
|
2181
|
+
...GenreCountsSchema.shape,
|
|
2182
|
+
catalogue: GenreCatalogueCountsSchema
|
|
2183
|
+
}).superRefine((playlist, ctx) => {
|
|
2184
|
+
const counts = GenreCatalogueCountsSchema.safeParse(playlist);
|
|
2185
|
+
if (!counts.success) for (const issue of counts.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
2053
2186
|
});
|
|
2054
2187
|
|
|
2188
|
+
// src/genre-tree/useGenre.ts
|
|
2189
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
2190
|
+
var import_react13 = require("react");
|
|
2191
|
+
|
|
2192
|
+
// src/genre-tree/useGenrePlaylist.ts
|
|
2193
|
+
var import_zod18 = require("zod");
|
|
2194
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
2195
|
+
|
|
2055
2196
|
// src/genre-tree/api/genre-playlists/queryKeys.ts
|
|
2056
2197
|
var genrePlaylistQueryKeys = {
|
|
2057
2198
|
me: {
|
|
@@ -2087,6 +2228,30 @@ var genrePlaylistEndpoints = {
|
|
|
2087
2228
|
reference: { ...makeGenrePlaylistEndpoints(""), tree: () => "genre-playlists/tree/" }
|
|
2088
2229
|
};
|
|
2089
2230
|
|
|
2231
|
+
// src/genre-tree/lib/genre-music-selection.ts
|
|
2232
|
+
function defaultGenreMusicSelection(counts) {
|
|
2233
|
+
return { coverage: "genreAndSubgenres", subgenres: "canonical" in counts.genreAndSubgenresTracksCount ? "canonical" : "all" };
|
|
2234
|
+
}
|
|
2235
|
+
function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
|
|
2236
|
+
if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
|
|
2237
|
+
const scopes = counts.genreAndSubgenresTracksCount;
|
|
2238
|
+
if (selection.subgenres === "all") return scopes.all;
|
|
2239
|
+
if (!("canonical" in scopes)) throw new Error("Regional genres only support all subgenres");
|
|
2240
|
+
return scopes[selection.subgenres];
|
|
2241
|
+
}
|
|
2242
|
+
function genreMusicQueryParams(selection) {
|
|
2243
|
+
if (!selection) return {};
|
|
2244
|
+
return selection.coverage === "genreOnly" ? { coverage: "genre_only" } : { coverage: "genre_and_subgenres", subgenres: selection.subgenres };
|
|
2245
|
+
}
|
|
2246
|
+
function genreMusicSelectionKey(selection) {
|
|
2247
|
+
return selection ? [selection.coverage, ...selection.coverage === "genreAndSubgenres" ? [selection.subgenres] : []] : [];
|
|
2248
|
+
}
|
|
2249
|
+
function genrePlaylistTrackCount(playlist) {
|
|
2250
|
+
if (playlist.genreOnlyTracksCount === void 0 && playlist.genreAndSubgenresTracksCount === void 0) return playlist.tracksCount;
|
|
2251
|
+
if (playlist.genreOnlyTracksCount === void 0 || playlist.genreAndSubgenresTracksCount === void 0) throw new Error("Incomplete genre playlist counts");
|
|
2252
|
+
return genreMusicCount({ genreOnlyTracksCount: playlist.genreOnlyTracksCount, genreAndSubgenresTracksCount: playlist.genreAndSubgenresTracksCount });
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2090
2255
|
// src/genre-tree/api/library/songs/queryKeys.ts
|
|
2091
2256
|
var makeSongQueryKeys = (prefix) => ({
|
|
2092
2257
|
all: [`${prefix}Songs`],
|
|
@@ -2095,7 +2260,7 @@ var makeSongQueryKeys = (prefix) => ({
|
|
|
2095
2260
|
history: (uuid) => [`${prefix}Songs`, "history", uuid],
|
|
2096
2261
|
search: (params) => [`${prefix}Songs`, "search", params],
|
|
2097
2262
|
// baseUrl keeps distinct backends sharing a scope (e.g. grow and its prototype proxy) apart.
|
|
2098
|
-
byGenre: (baseUrl, genreUuid) => [`${prefix}Songs`, baseUrl, "genre", genreUuid]
|
|
2263
|
+
byGenre: (baseUrl, genreUuid, selection) => [`${prefix}Songs`, baseUrl, "genre", genreUuid, ...genreMusicSelectionKey(selection)]
|
|
2099
2264
|
});
|
|
2100
2265
|
|
|
2101
2266
|
// src/genre-tree/api/library/songs/endpoints.ts
|
|
@@ -2165,7 +2330,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
|
|
|
2165
2330
|
const queryClient2 = (0, import_react_query4.useQueryClient)();
|
|
2166
2331
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2167
2332
|
const { session, sessionRestored } = useSession();
|
|
2168
|
-
const queryKey = scope === "reference" ? genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()) : genrePlaylistQueryKeys.me.full;
|
|
2333
|
+
const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
|
|
2169
2334
|
const query = useQueryWithParse({
|
|
2170
2335
|
queryKey,
|
|
2171
2336
|
queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "canonical" }) : fetchAllPages(
|
|
@@ -2177,7 +2342,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
|
|
|
2177
2342
|
{ page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
|
|
2178
2343
|
)
|
|
2179
2344
|
),
|
|
2180
|
-
schema:
|
|
2345
|
+
schema: scope === "reference" ? import_zod18.z.array(ReferenceGenrePlaylistSchema) : import_zod18.z.array(CriteriaPlaylistSimpleSchema),
|
|
2181
2346
|
context: "useListFullGenrePlaylists",
|
|
2182
2347
|
enabled: scope === "reference" || sessionRestored && !!session?.accessToken
|
|
2183
2348
|
});
|
|
@@ -2210,131 +2375,48 @@ var useInvalidateAllGenrePlaylistQueries = () => {
|
|
|
2210
2375
|
]);
|
|
2211
2376
|
};
|
|
2212
2377
|
|
|
2213
|
-
// src/genre-tree/schemas/criteria/detailed.ts
|
|
2214
|
-
var import_zod17 = require("zod");
|
|
2215
|
-
|
|
2216
|
-
// src/genre-tree/schemas/track/base.ts
|
|
2217
|
-
var import_zod14 = require("zod");
|
|
2218
|
-
|
|
2219
|
-
// src/genre-tree/schemas/artist-minimum.ts
|
|
2220
|
-
var import_zod11 = require("zod");
|
|
2221
|
-
var ArtistMinimumSchema = import_zod11.z.object({
|
|
2222
|
-
uuid: import_zod11.z.string().uuid(),
|
|
2223
|
-
name: import_zod11.z.string(),
|
|
2224
|
-
isSpecialPurpose: import_zod11.z.boolean().optional()
|
|
2225
|
-
});
|
|
2226
|
-
|
|
2227
|
-
// src/genre-tree/schemas/album-minimum.ts
|
|
2228
|
-
var import_zod12 = require("zod");
|
|
2229
|
-
var AlbumMinimumSchema = import_zod12.z.object({
|
|
2230
|
-
uuid: import_zod12.z.string().uuid(),
|
|
2231
|
-
name: import_zod12.z.string(),
|
|
2232
|
-
albumArtists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional()
|
|
2233
|
-
});
|
|
2234
|
-
|
|
2235
|
-
// src/genre-tree/schemas/uuid-resource.ts
|
|
2236
|
-
var import_zod13 = require("zod");
|
|
2237
|
-
var UuidResourceSchema = import_zod13.z.object({
|
|
2238
|
-
uuid: import_zod13.z.string().uuid()
|
|
2239
|
-
});
|
|
2240
|
-
|
|
2241
|
-
// src/genre-tree/schemas/track/base.ts
|
|
2242
|
-
var TrackBaseSchema = UuidResourceSchema.extend({
|
|
2243
|
-
title: import_zod14.z.string(),
|
|
2244
|
-
artists: import_zod14.z.array(ArtistMinimumSchema).nullable().optional(),
|
|
2245
|
-
album: AlbumMinimumSchema.nullable().optional(),
|
|
2246
|
-
trackNumber: import_zod14.z.number().nullable().optional(),
|
|
2247
|
-
// null for a song not yet linked to a genre.
|
|
2248
|
-
genre: CriteriaMinimumSchema.nullable(),
|
|
2249
|
-
rating: import_zod14.z.number().min(0).max(10).nullable().optional(),
|
|
2250
|
-
language: import_zod14.z.string().nullable().optional(),
|
|
2251
|
-
playCount: import_zod14.z.number().min(0),
|
|
2252
|
-
createdOn: import_zod14.z.string().datetime(),
|
|
2253
|
-
updatedOn: import_zod14.z.string().datetime().nullable().optional()
|
|
2254
|
-
});
|
|
2255
|
-
|
|
2256
|
-
// src/genre-tree/schemas/track/minimum.ts
|
|
2257
|
-
var TrackMinimumSchema = TrackBaseSchema.pick({
|
|
2258
|
-
uuid: true,
|
|
2259
|
-
title: true,
|
|
2260
|
-
artists: true
|
|
2261
|
-
});
|
|
2262
|
-
|
|
2263
|
-
// src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
|
|
2264
|
-
var import_zod15 = require("zod");
|
|
2265
|
-
var CriteriaLineageRelWithoutAscendantSchema = import_zod15.z.object({
|
|
2266
|
-
descendant: CriteriaMinimumSchema,
|
|
2267
|
-
degree: import_zod15.z.number()
|
|
2268
|
-
});
|
|
2269
|
-
|
|
2270
|
-
// src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
|
|
2271
|
-
var import_zod16 = require("zod");
|
|
2272
|
-
var CriteriaLineageRelWithoutDescendantSchema = import_zod16.z.object({
|
|
2273
|
-
ascendant: CriteriaMinimumSchema,
|
|
2274
|
-
degree: import_zod16.z.number()
|
|
2275
|
-
});
|
|
2276
|
-
|
|
2277
|
-
// src/genre-tree/schemas/criteria/detailed.ts
|
|
2278
|
-
var CriteriaDetailedSchema = import_zod17.z.object({
|
|
2279
|
-
uuid: GenreUuidSchema,
|
|
2280
|
-
name: import_zod17.z.string(),
|
|
2281
|
-
summary: import_zod17.z.string().nullable(),
|
|
2282
|
-
// Optional until every deployed API serves it.
|
|
2283
|
-
wikidataId: import_zod17.z.string().nullable().optional(),
|
|
2284
|
-
parent: CriteriaMinimumSchema.nullable(),
|
|
2285
|
-
ascendants: import_zod17.z.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
2286
|
-
descendants: import_zod17.z.array(CriteriaLineageRelWithoutAscendantSchema),
|
|
2287
|
-
root: CriteriaMinimumSchema,
|
|
2288
|
-
children: import_zod17.z.array(CriteriaMinimumSchema),
|
|
2289
|
-
criteriaPlaylist: CriteriaPlaylistMinimumSchema,
|
|
2290
|
-
tracks: import_zod17.z.array(TrackMinimumSchema),
|
|
2291
|
-
essentialSongs: import_zod17.z.array(TrackMinimumSchema),
|
|
2292
|
-
tracksCount: import_zod17.z.number(),
|
|
2293
|
-
updatedOn: import_zod17.z.string().datetime().nullable()
|
|
2294
|
-
});
|
|
2295
|
-
|
|
2296
2378
|
// src/genre-tree/schemas/criteria/overview.ts
|
|
2297
|
-
var
|
|
2379
|
+
var import_zod20 = require("zod");
|
|
2298
2380
|
|
|
2299
2381
|
// src/genre-tree/schemas/http-url.ts
|
|
2300
|
-
var
|
|
2301
|
-
var HttpUrlSchema =
|
|
2382
|
+
var import_zod19 = require("zod");
|
|
2383
|
+
var HttpUrlSchema = import_zod19.z.url({ protocol: /^https?$/ });
|
|
2302
2384
|
|
|
2303
2385
|
// src/genre-tree/schemas/criteria/overview.ts
|
|
2304
|
-
var CriteriaOverviewSchema =
|
|
2386
|
+
var CriteriaOverviewSchema = import_zod20.z.object({
|
|
2305
2387
|
uuid: GenreUuidSchema,
|
|
2306
|
-
name:
|
|
2307
|
-
summary:
|
|
2308
|
-
description:
|
|
2388
|
+
name: import_zod20.z.string(),
|
|
2389
|
+
summary: import_zod20.z.string().nullable(),
|
|
2390
|
+
description: import_zod20.z.string().nullable(),
|
|
2309
2391
|
summarySourceUrl: HttpUrlSchema.nullable(),
|
|
2310
|
-
essentialSongs:
|
|
2392
|
+
essentialSongs: import_zod20.z.array(TrackMinimumSchema).optional()
|
|
2311
2393
|
});
|
|
2312
2394
|
|
|
2313
2395
|
// src/genre-tree/schemas/criteria/simple.ts
|
|
2314
|
-
var
|
|
2315
|
-
var CriteriaSimpleSchema =
|
|
2396
|
+
var import_zod21 = require("zod");
|
|
2397
|
+
var CriteriaSimpleSchema = import_zod21.z.object({
|
|
2316
2398
|
uuid: GenreUuidSchema,
|
|
2317
|
-
name:
|
|
2399
|
+
name: import_zod21.z.string(),
|
|
2318
2400
|
parent: CriteriaMinimumSchema.nullable(),
|
|
2319
|
-
createdOn:
|
|
2320
|
-
summary:
|
|
2401
|
+
createdOn: import_zod21.z.string().datetime(),
|
|
2402
|
+
summary: import_zod21.z.string().nullable()
|
|
2321
2403
|
});
|
|
2322
2404
|
|
|
2323
2405
|
// src/genre-tree/schemas/criteria/creation.ts
|
|
2324
|
-
var
|
|
2325
|
-
var CriteriaCreationSchema =
|
|
2326
|
-
name:
|
|
2406
|
+
var import_zod22 = require("zod");
|
|
2407
|
+
var CriteriaCreationSchema = import_zod22.z.object({
|
|
2408
|
+
name: import_zod22.z.string().min(1, "Name is required"),
|
|
2327
2409
|
parent: GenreUuidSchema.optional(),
|
|
2328
|
-
essentialSongs:
|
|
2410
|
+
essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional()
|
|
2329
2411
|
});
|
|
2330
2412
|
|
|
2331
2413
|
// src/genre-tree/schemas/criteria/update.ts
|
|
2332
|
-
var
|
|
2333
|
-
var CriteriaUpdateSchema =
|
|
2334
|
-
name:
|
|
2414
|
+
var import_zod23 = require("zod");
|
|
2415
|
+
var CriteriaUpdateSchema = import_zod23.z.object({
|
|
2416
|
+
name: import_zod23.z.string().optional(),
|
|
2335
2417
|
parent: GenreUuidSchema.nullable().optional(),
|
|
2336
|
-
essentialSongs:
|
|
2337
|
-
side:
|
|
2418
|
+
essentialSongs: import_zod23.z.array(import_zod23.z.string().uuid()).optional(),
|
|
2419
|
+
side: import_zod23.z.enum(["core", "pop"]).optional()
|
|
2338
2420
|
});
|
|
2339
2421
|
|
|
2340
2422
|
// src/genre-tree/api/genres/queryKeys.ts
|
|
@@ -2395,18 +2477,18 @@ function useFetchGenre(scope, getBackendBaseUrl) {
|
|
|
2395
2477
|
async (id) => {
|
|
2396
2478
|
const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
|
|
2397
2479
|
const response = await fetch2(endpoint, true, scope === "me");
|
|
2398
|
-
return parseWithLog(CriteriaDetailedSchema, response, "useFetchGenre");
|
|
2480
|
+
return parseWithLog(scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema, response, "useFetchGenre");
|
|
2399
2481
|
},
|
|
2400
2482
|
[fetch2, scope]
|
|
2401
2483
|
);
|
|
2402
2484
|
}
|
|
2403
|
-
function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = CriteriaDetailedSchema) {
|
|
2485
|
+
function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema) {
|
|
2404
2486
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2405
2487
|
const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
|
|
2406
2488
|
const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
|
|
2407
2489
|
const genreUuid = id ?? "";
|
|
2408
2490
|
return useQueryWithParse({
|
|
2409
|
-
queryKey: queryKeys.detail(genreUuid),
|
|
2491
|
+
queryKey: scope === "reference" ? [...queryKeys.detail(genreUuid), getBackendBaseUrl(), "genreMusicV1"] : queryKeys.detail(genreUuid),
|
|
2410
2492
|
queryFn: () => fetch2(endpoints.detail(genreUuid), true, scope === "me"),
|
|
2411
2493
|
schema,
|
|
2412
2494
|
context: "useFetchGenreDetail",
|
|
@@ -2489,7 +2571,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
|
|
|
2489
2571
|
const refreshGenreTree = useRefreshGenreTree(scope);
|
|
2490
2572
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2491
2573
|
const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
|
|
2492
|
-
inputSchema:
|
|
2574
|
+
inputSchema: import_zod24.z.object({
|
|
2493
2575
|
uuid: GenreUuidSchema,
|
|
2494
2576
|
data: CriteriaUpdateSchema
|
|
2495
2577
|
}),
|
|
@@ -2519,8 +2601,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
|
|
|
2519
2601
|
const refreshGenreTree = useRefreshGenreTree(scope);
|
|
2520
2602
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2521
2603
|
return useValidatedMutation({
|
|
2522
|
-
inputSchema:
|
|
2523
|
-
outputSchema:
|
|
2604
|
+
inputSchema: import_zod24.z.object({ uuid: GenreUuidSchema }),
|
|
2605
|
+
outputSchema: import_zod24.z.null(),
|
|
2524
2606
|
mutationFn: async ({ uuid }) => {
|
|
2525
2607
|
const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
|
|
2526
2608
|
return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
|
|
@@ -2530,16 +2612,16 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
|
|
|
2530
2612
|
}
|
|
2531
2613
|
|
|
2532
2614
|
// src/genre-tree/useArtist.ts
|
|
2533
|
-
var
|
|
2615
|
+
var import_zod26 = require("zod");
|
|
2534
2616
|
|
|
2535
2617
|
// src/genre-tree/schemas/artist-detailed.ts
|
|
2536
|
-
var
|
|
2537
|
-
var ArtistMembershipSchema =
|
|
2618
|
+
var import_zod25 = require("zod");
|
|
2619
|
+
var ArtistMembershipSchema = import_zod25.z.object({
|
|
2538
2620
|
artist: ArtistMinimumSchema,
|
|
2539
|
-
beginYear:
|
|
2540
|
-
endYear:
|
|
2541
|
-
ended:
|
|
2542
|
-
roles:
|
|
2621
|
+
beginYear: import_zod25.z.number().int().nullable(),
|
|
2622
|
+
endYear: import_zod25.z.number().int().nullable(),
|
|
2623
|
+
ended: import_zod25.z.boolean(),
|
|
2624
|
+
roles: import_zod25.z.array(import_zod25.z.string())
|
|
2543
2625
|
});
|
|
2544
2626
|
var ARTIST_LINK_KINDS = [
|
|
2545
2627
|
"official",
|
|
@@ -2552,35 +2634,35 @@ var ARTIST_LINK_KINDS = [
|
|
|
2552
2634
|
"discogs",
|
|
2553
2635
|
"social"
|
|
2554
2636
|
];
|
|
2555
|
-
var ArtistImageSchema =
|
|
2637
|
+
var ArtistImageSchema = import_zod25.z.object({
|
|
2556
2638
|
url: HttpUrlSchema,
|
|
2557
2639
|
pageUrl: HttpUrlSchema,
|
|
2558
|
-
author:
|
|
2559
|
-
license:
|
|
2640
|
+
author: import_zod25.z.string().nullable(),
|
|
2641
|
+
license: import_zod25.z.string(),
|
|
2560
2642
|
licenseUrl: HttpUrlSchema.nullable()
|
|
2561
2643
|
});
|
|
2562
|
-
var ArtistDetailedSchema =
|
|
2563
|
-
uuid:
|
|
2564
|
-
name:
|
|
2565
|
-
musicbrainzArtistId:
|
|
2566
|
-
type:
|
|
2567
|
-
country:
|
|
2568
|
-
beginYear:
|
|
2569
|
-
endYear:
|
|
2570
|
-
ended:
|
|
2571
|
-
links:
|
|
2572
|
-
members:
|
|
2573
|
-
memberOf:
|
|
2574
|
-
albums:
|
|
2575
|
-
|
|
2576
|
-
uuid:
|
|
2577
|
-
name:
|
|
2578
|
-
year:
|
|
2579
|
-
primaryType:
|
|
2580
|
-
secondaryTypes:
|
|
2644
|
+
var ArtistDetailedSchema = import_zod25.z.object({
|
|
2645
|
+
uuid: import_zod25.z.string().uuid(),
|
|
2646
|
+
name: import_zod25.z.string(),
|
|
2647
|
+
musicbrainzArtistId: import_zod25.z.string().uuid().nullable(),
|
|
2648
|
+
type: import_zod25.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
|
|
2649
|
+
country: import_zod25.z.string().nullable(),
|
|
2650
|
+
beginYear: import_zod25.z.number().int().nullable(),
|
|
2651
|
+
endYear: import_zod25.z.number().int().nullable(),
|
|
2652
|
+
ended: import_zod25.z.boolean(),
|
|
2653
|
+
links: import_zod25.z.array(import_zod25.z.object({ kind: import_zod25.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
|
|
2654
|
+
members: import_zod25.z.array(ArtistMembershipSchema),
|
|
2655
|
+
memberOf: import_zod25.z.array(ArtistMembershipSchema),
|
|
2656
|
+
albums: import_zod25.z.array(
|
|
2657
|
+
import_zod25.z.object({
|
|
2658
|
+
uuid: import_zod25.z.string().uuid(),
|
|
2659
|
+
name: import_zod25.z.string(),
|
|
2660
|
+
year: import_zod25.z.string().nullable(),
|
|
2661
|
+
primaryType: import_zod25.z.string().nullable(),
|
|
2662
|
+
secondaryTypes: import_zod25.z.array(import_zod25.z.string())
|
|
2581
2663
|
})
|
|
2582
2664
|
),
|
|
2583
|
-
tracksCount:
|
|
2665
|
+
tracksCount: import_zod25.z.number().int(),
|
|
2584
2666
|
image: ArtistImageSchema.nullable()
|
|
2585
2667
|
});
|
|
2586
2668
|
|
|
@@ -2603,7 +2685,7 @@ var artistEndpoints = {
|
|
|
2603
2685
|
var isNotFound = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
|
|
2604
2686
|
function useArtist(uuid, getBackendBaseUrl) {
|
|
2605
2687
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2606
|
-
const isUuid = uuid !== null &&
|
|
2688
|
+
const isUuid = uuid !== null && import_zod26.z.string().uuid().safeParse(uuid).success;
|
|
2607
2689
|
const { data, isPending, error } = useQueryWithParse({
|
|
2608
2690
|
queryKey: artistQueryKeys.detail(uuid),
|
|
2609
2691
|
// A missing artist is shown in the panel, not raised as an app-wide connectivity error.
|
|
@@ -2621,26 +2703,26 @@ function useArtist(uuid, getBackendBaseUrl) {
|
|
|
2621
2703
|
}
|
|
2622
2704
|
|
|
2623
2705
|
// src/genre-tree/schemas/artist-search.ts
|
|
2624
|
-
var
|
|
2625
|
-
var ArtistSearchResultSchema =
|
|
2626
|
-
uuid:
|
|
2627
|
-
name:
|
|
2628
|
-
disambiguation:
|
|
2629
|
-
type:
|
|
2630
|
-
country:
|
|
2631
|
-
beginYear:
|
|
2632
|
-
endYear:
|
|
2633
|
-
matchedAlias:
|
|
2634
|
-
recordingCount:
|
|
2706
|
+
var import_zod27 = require("zod");
|
|
2707
|
+
var ArtistSearchResultSchema = import_zod27.z.object({
|
|
2708
|
+
uuid: import_zod27.z.string().uuid(),
|
|
2709
|
+
name: import_zod27.z.string(),
|
|
2710
|
+
disambiguation: import_zod27.z.string().nullable(),
|
|
2711
|
+
type: import_zod27.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
|
|
2712
|
+
country: import_zod27.z.string().nullable(),
|
|
2713
|
+
beginYear: import_zod27.z.number().int().nullable(),
|
|
2714
|
+
endYear: import_zod27.z.number().int().nullable(),
|
|
2715
|
+
matchedAlias: import_zod27.z.string().nullable(),
|
|
2716
|
+
recordingCount: import_zod27.z.number().int()
|
|
2635
2717
|
});
|
|
2636
|
-
var ArtistSearchResultsSchema =
|
|
2718
|
+
var ArtistSearchResultsSchema = import_zod27.z.array(ArtistSearchResultSchema);
|
|
2637
2719
|
|
|
2638
2720
|
// src/genre-tree/useRemoteSearch.ts
|
|
2639
2721
|
var import_react_query6 = require("@tanstack/react-query");
|
|
2640
2722
|
var import_react14 = require("react");
|
|
2641
2723
|
var SEARCH_DEBOUNCE_MS = 250;
|
|
2642
2724
|
var SEARCH_QUERY_MIN_LENGTH = 2;
|
|
2643
|
-
function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema, context, text, enabled: extraEnabled = true,
|
|
2725
|
+
function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema, context, text, enabled: extraEnabled = true, scope = "" }) {
|
|
2644
2726
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2645
2727
|
const trimmed = text.trim();
|
|
2646
2728
|
const [query, setQuery] = (0, import_react14.useState)("");
|
|
@@ -2648,15 +2730,19 @@ function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema
|
|
|
2648
2730
|
const timer = setTimeout(() => setQuery(trimmed), SEARCH_DEBOUNCE_MS);
|
|
2649
2731
|
return () => clearTimeout(timer);
|
|
2650
2732
|
}, [trimmed]);
|
|
2733
|
+
const dataScope = (0, import_react14.useRef)(null);
|
|
2651
2734
|
const enabled = query.length >= SEARCH_QUERY_MIN_LENGTH && extraEnabled;
|
|
2652
|
-
const { data, isFetching, isError } = useQueryWithParse({
|
|
2735
|
+
const { data, isFetching, isError, isPlaceholderData } = useQueryWithParse({
|
|
2653
2736
|
queryKey: queryKey(query),
|
|
2654
2737
|
queryFn: ({ signal }) => fetch2(endpoint, true, false, { signal }, params(query)),
|
|
2655
2738
|
schema,
|
|
2656
2739
|
context,
|
|
2657
2740
|
enabled,
|
|
2658
|
-
placeholderData:
|
|
2741
|
+
placeholderData: (previous) => dataScope.current === scope ? (0, import_react_query6.keepPreviousData)(previous) : void 0
|
|
2659
2742
|
});
|
|
2743
|
+
(0, import_react14.useEffect)(() => {
|
|
2744
|
+
if (data !== void 0 && !isPlaceholderData) dataScope.current = scope;
|
|
2745
|
+
}, [data, isPlaceholderData, scope]);
|
|
2660
2746
|
const settled = enabled && !isFetching && query === trimmed;
|
|
2661
2747
|
const failed = enabled && isError;
|
|
2662
2748
|
const long = trimmed.length >= SEARCH_QUERY_MIN_LENGTH;
|
|
@@ -2683,10 +2769,10 @@ function useArtistSearch(getBackendBaseUrl, text) {
|
|
|
2683
2769
|
}
|
|
2684
2770
|
|
|
2685
2771
|
// src/genre-tree/useSong.ts
|
|
2686
|
-
var
|
|
2772
|
+
var import_zod29 = require("zod");
|
|
2687
2773
|
|
|
2688
2774
|
// src/genre-tree/schemas/song/detailed.ts
|
|
2689
|
-
var
|
|
2775
|
+
var import_zod28 = require("zod");
|
|
2690
2776
|
var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
2691
2777
|
not_found: "Video unavailable",
|
|
2692
2778
|
not_embeddable: "Embedding disabled",
|
|
@@ -2695,23 +2781,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
|
2695
2781
|
region_whitelisted: "Region restricted"
|
|
2696
2782
|
};
|
|
2697
2783
|
var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
|
|
2698
|
-
var YoutubeAvailabilitySchema =
|
|
2699
|
-
status:
|
|
2700
|
-
reason:
|
|
2701
|
-
country:
|
|
2784
|
+
var YoutubeAvailabilitySchema = import_zod28.z.object({
|
|
2785
|
+
status: import_zod28.z.enum(["eligible", "blocked", "unknown"]),
|
|
2786
|
+
reason: import_zod28.z.string().nullable(),
|
|
2787
|
+
country: import_zod28.z.string().nullable()
|
|
2702
2788
|
});
|
|
2703
2789
|
var SongDetailedSchema = TrackBaseSchema.extend({
|
|
2704
|
-
youtubeVideo:
|
|
2705
|
-
id:
|
|
2790
|
+
youtubeVideo: import_zod28.z.object({
|
|
2791
|
+
id: import_zod28.z.string(),
|
|
2706
2792
|
availability: YoutubeAvailabilitySchema.optional(),
|
|
2707
2793
|
// null = playable
|
|
2708
|
-
unplayableReason:
|
|
2709
|
-
viewCount:
|
|
2794
|
+
unplayableReason: import_zod28.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
|
|
2795
|
+
viewCount: import_zod28.z.number().int().nullable().optional()
|
|
2710
2796
|
}).nullable(),
|
|
2711
2797
|
// null for hand-made/admin songs
|
|
2712
|
-
musicbrainzRecordingId:
|
|
2713
|
-
firstReleaseYear:
|
|
2714
|
-
essentialGenres:
|
|
2798
|
+
musicbrainzRecordingId: import_zod28.z.string().uuid().nullable(),
|
|
2799
|
+
firstReleaseYear: import_zod28.z.number().int().nullable().optional(),
|
|
2800
|
+
essentialGenres: import_zod28.z.array(CriteriaMinimumSchema).optional()
|
|
2715
2801
|
});
|
|
2716
2802
|
var NO_VIDEO_LABEL = "No video available";
|
|
2717
2803
|
function isSong(track) {
|
|
@@ -2732,7 +2818,7 @@ var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC404
|
|
|
2732
2818
|
function useSong(uuid, getBackendBaseUrl) {
|
|
2733
2819
|
const playback = usePlaybackContext();
|
|
2734
2820
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2735
|
-
const isUuid = uuid !== null &&
|
|
2821
|
+
const isUuid = uuid !== null && import_zod29.z.string().uuid().safeParse(uuid).success;
|
|
2736
2822
|
const { data, isPending, error } = useQueryWithParse({
|
|
2737
2823
|
queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
|
|
2738
2824
|
// A missing song is shown in the panel, not raised as an app-wide connectivity error.
|
|
@@ -2750,16 +2836,16 @@ function useSong(uuid, getBackendBaseUrl) {
|
|
|
2750
2836
|
}
|
|
2751
2837
|
|
|
2752
2838
|
// src/genre-tree/schemas/song-history.ts
|
|
2753
|
-
var
|
|
2754
|
-
var SongHistoryEntrySchema =
|
|
2755
|
-
uuid:
|
|
2756
|
-
action:
|
|
2757
|
-
actorPseudo:
|
|
2758
|
-
oldValue:
|
|
2759
|
-
newValue:
|
|
2760
|
-
createdOn:
|
|
2839
|
+
var import_zod30 = require("zod");
|
|
2840
|
+
var SongHistoryEntrySchema = import_zod30.z.object({
|
|
2841
|
+
uuid: import_zod30.z.string().uuid(),
|
|
2842
|
+
action: import_zod30.z.string(),
|
|
2843
|
+
actorPseudo: import_zod30.z.string().nullable(),
|
|
2844
|
+
oldValue: import_zod30.z.string().nullable(),
|
|
2845
|
+
newValue: import_zod30.z.string().nullable(),
|
|
2846
|
+
createdOn: import_zod30.z.string()
|
|
2761
2847
|
});
|
|
2762
|
-
var SongHistorySchema =
|
|
2848
|
+
var SongHistorySchema = import_zod30.z.array(SongHistoryEntrySchema);
|
|
2763
2849
|
|
|
2764
2850
|
// src/genre-tree/useSongHistory.ts
|
|
2765
2851
|
function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
@@ -2779,20 +2865,20 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
|
2779
2865
|
}
|
|
2780
2866
|
|
|
2781
2867
|
// src/genre-tree/schemas/song-search.ts
|
|
2782
|
-
var
|
|
2783
|
-
var SongSearchResultSchema =
|
|
2784
|
-
uuid:
|
|
2785
|
-
title:
|
|
2786
|
-
artists:
|
|
2868
|
+
var import_zod31 = require("zod");
|
|
2869
|
+
var SongSearchResultSchema = import_zod31.z.object({
|
|
2870
|
+
uuid: import_zod31.z.string().uuid(),
|
|
2871
|
+
title: import_zod31.z.string(),
|
|
2872
|
+
artists: import_zod31.z.array(ArtistMinimumSchema),
|
|
2787
2873
|
// null for songs not yet linked to a genre.
|
|
2788
2874
|
genre: CriteriaMinimumSchema.nullable(),
|
|
2789
|
-
youtubeVideo:
|
|
2790
|
-
id:
|
|
2791
|
-
unplayableReason:
|
|
2875
|
+
youtubeVideo: import_zod31.z.object({
|
|
2876
|
+
id: import_zod31.z.string(),
|
|
2877
|
+
unplayableReason: import_zod31.z.string().nullable()
|
|
2792
2878
|
}).nullable(),
|
|
2793
|
-
firstReleaseYear:
|
|
2879
|
+
firstReleaseYear: import_zod31.z.number().int().nullable()
|
|
2794
2880
|
});
|
|
2795
|
-
var SongSearchResultsSchema =
|
|
2881
|
+
var SongSearchResultsSchema = import_zod31.z.array(SongSearchResultSchema);
|
|
2796
2882
|
function isSongSearchResultPlayable(result) {
|
|
2797
2883
|
return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
|
|
2798
2884
|
}
|
|
@@ -2811,23 +2897,32 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
|
2811
2897
|
context: "useSongSearch",
|
|
2812
2898
|
text,
|
|
2813
2899
|
enabled: playback.ready,
|
|
2814
|
-
|
|
2900
|
+
scope: playback.key ?? ""
|
|
2815
2901
|
});
|
|
2816
2902
|
return { songs: results, isError, settled, pending };
|
|
2817
2903
|
}
|
|
2818
2904
|
|
|
2819
2905
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
2820
2906
|
var import_react_query7 = require("@tanstack/react-query");
|
|
2821
|
-
var
|
|
2907
|
+
var import_zod33 = require("zod");
|
|
2822
2908
|
|
|
2823
2909
|
// src/genre-tree/schemas/artist-genre-count.ts
|
|
2824
|
-
var
|
|
2825
|
-
var ArtistGenreCountSchema =
|
|
2910
|
+
var import_zod32 = require("zod");
|
|
2911
|
+
var ArtistGenreCountSchema = import_zod32.z.object({
|
|
2912
|
+
...GenreCountsSchema.shape,
|
|
2913
|
+
catalogue: GenreCatalogueCountsSchema,
|
|
2826
2914
|
genrePlaylist: GenrePlaylistUuidSchema,
|
|
2827
|
-
/**
|
|
2828
|
-
songsCount:
|
|
2829
|
-
/**
|
|
2830
|
-
tracksCount:
|
|
2915
|
+
/** Legacy catalogue count for the default selection. */
|
|
2916
|
+
songsCount: import_zod32.z.number().int().nonnegative(),
|
|
2917
|
+
/** Legacy playlist count for the default selection. */
|
|
2918
|
+
tracksCount: import_zod32.z.number().int().nonnegative()
|
|
2919
|
+
}).superRefine((row, ctx) => {
|
|
2920
|
+
const counts = GenreCatalogueCountsSchema.safeParse(row);
|
|
2921
|
+
if (!counts.success) {
|
|
2922
|
+
for (const issue of counts.error.issues) {
|
|
2923
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2831
2926
|
});
|
|
2832
2927
|
|
|
2833
2928
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
@@ -2835,10 +2930,10 @@ var isNotFound3 = (error) => error instanceof AppError && error.code === "BAC404
|
|
|
2835
2930
|
function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
2836
2931
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2837
2932
|
return useQueryWithParse({
|
|
2838
|
-
queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
|
|
2933
|
+
queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid), "genreMusicV1"],
|
|
2839
2934
|
// A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
|
|
2840
2935
|
queryFn: () => fetch2(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
|
|
2841
|
-
schema:
|
|
2936
|
+
schema: import_zod33.z.array(ArtistGenreCountSchema),
|
|
2842
2937
|
enabled: artistUuid !== null,
|
|
2843
2938
|
placeholderData: import_react_query7.keepPreviousData,
|
|
2844
2939
|
retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
|
|
@@ -2942,30 +3037,32 @@ function useGenreSearch({
|
|
|
2942
3037
|
}
|
|
2943
3038
|
|
|
2944
3039
|
// src/genre-tree/schemas/genre-search.ts
|
|
2945
|
-
var
|
|
2946
|
-
var GenreSearchTreeNameSchema =
|
|
2947
|
-
var GenreSearchResultSchema =
|
|
3040
|
+
var import_zod34 = require("zod");
|
|
3041
|
+
var GenreSearchTreeNameSchema = import_zod34.z.enum(["canonical", "regional"]);
|
|
3042
|
+
var GenreSearchResultSchema = import_zod34.z.object({
|
|
2948
3043
|
/** Criteria (genre) uuid. */
|
|
2949
3044
|
uuid: GenreUuidSchema,
|
|
2950
|
-
name:
|
|
2951
|
-
|
|
3045
|
+
name: import_zod34.z.string(),
|
|
3046
|
+
/** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
|
|
3047
|
+
wikidataId: import_zod34.z.string().nullable(),
|
|
3048
|
+
treeName: import_zod34.z.string(),
|
|
2952
3049
|
/** Null when the genre has no playlist in the tree, so it cannot be opened there. */
|
|
2953
3050
|
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
2954
|
-
root:
|
|
2955
|
-
isUmbrella:
|
|
2956
|
-
viewsCount:
|
|
3051
|
+
root: import_zod34.z.object({ uuid: GenreUuidSchema, name: import_zod34.z.string() }),
|
|
3052
|
+
isUmbrella: import_zod34.z.boolean(),
|
|
3053
|
+
viewsCount: import_zod34.z.number().int()
|
|
2957
3054
|
});
|
|
2958
|
-
var GenreSearchResultsSchema =
|
|
2959
|
-
var RegionGenreLexiconEntrySchema =
|
|
2960
|
-
wikidataId:
|
|
3055
|
+
var GenreSearchResultsSchema = import_zod34.z.array(GenreSearchResultSchema);
|
|
3056
|
+
var RegionGenreLexiconEntrySchema = import_zod34.z.object({
|
|
3057
|
+
wikidataId: import_zod34.z.string(),
|
|
2961
3058
|
uuid: GenreUuidSchema,
|
|
2962
|
-
name:
|
|
2963
|
-
treeName:
|
|
3059
|
+
name: import_zod34.z.string(),
|
|
3060
|
+
treeName: import_zod34.z.string(),
|
|
2964
3061
|
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
2965
|
-
isUmbrella:
|
|
2966
|
-
viewsCount:
|
|
3062
|
+
isUmbrella: import_zod34.z.boolean(),
|
|
3063
|
+
viewsCount: import_zod34.z.number().int()
|
|
2967
3064
|
});
|
|
2968
|
-
var RegionGenreLexiconSchema =
|
|
3065
|
+
var RegionGenreLexiconSchema = import_zod34.z.array(RegionGenreLexiconEntrySchema);
|
|
2969
3066
|
|
|
2970
3067
|
// src/genre-tree/useGenreRemoteSearch.ts
|
|
2971
3068
|
var DEFAULT_RESULT_LIMIT2 = 8;
|
|
@@ -3012,7 +3109,7 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
3012
3109
|
const kept = /* @__PURE__ */ new Set();
|
|
3013
3110
|
for (const playlist of playlists) {
|
|
3014
3111
|
const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
|
|
3015
|
-
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.
|
|
3112
|
+
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
|
|
3016
3113
|
}
|
|
3017
3114
|
const coreElectronicUuids = new Set(
|
|
3018
3115
|
playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
|
|
@@ -3020,12 +3117,22 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
3020
3117
|
for (const playlist of playlists) {
|
|
3021
3118
|
if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
|
|
3022
3119
|
}
|
|
3023
|
-
return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) =>
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3120
|
+
return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => {
|
|
3121
|
+
const count = countByPlaylist.get(playlist.uuid);
|
|
3122
|
+
const catalogue = GenreCatalogueCountsSchema.parse(playlist.catalogue);
|
|
3123
|
+
const scopes = playlist.genreAndSubgenresTracksCount;
|
|
3124
|
+
if (!scopes) throw new Error("Artist projections require a reference genre summary");
|
|
3125
|
+
const zero = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: "canonical" in scopes ? { canonical: 0, regional: 0, all: 0 } : { all: 0 } };
|
|
3126
|
+
return {
|
|
3127
|
+
...playlist,
|
|
3128
|
+
genreOnlyTracksCount: count?.genreOnlyTracksCount ?? 0,
|
|
3129
|
+
genreAndSubgenresTracksCount: count?.genreAndSubgenresTracksCount ?? zero.genreAndSubgenresTracksCount,
|
|
3130
|
+
catalogue: count?.catalogue ?? { ...catalogue, ...zero },
|
|
3131
|
+
tracksCount: count ? genreMusicCount(count) : 0,
|
|
3132
|
+
// Artist view totals are not served.
|
|
3133
|
+
viewsCount: void 0
|
|
3134
|
+
};
|
|
3135
|
+
});
|
|
3029
3136
|
};
|
|
3030
3137
|
|
|
3031
3138
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
@@ -3163,10 +3270,10 @@ function useGenreTreeViewState({
|
|
|
3163
3270
|
var import_react19 = require("react");
|
|
3164
3271
|
|
|
3165
3272
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
3166
|
-
var
|
|
3167
|
-
var makeTrackPlaylistRelSchema = (trackSchema) =>
|
|
3273
|
+
var import_zod35 = require("zod");
|
|
3274
|
+
var makeTrackPlaylistRelSchema = (trackSchema) => import_zod35.z.object({
|
|
3168
3275
|
track: trackSchema,
|
|
3169
|
-
position:
|
|
3276
|
+
position: import_zod35.z.number().min(0)
|
|
3170
3277
|
});
|
|
3171
3278
|
var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
|
|
3172
3279
|
|
|
@@ -3215,6 +3322,7 @@ var TrackListFromArtist = class extends TrackList {
|
|
|
3215
3322
|
var TrackListOriginType = /* @__PURE__ */ ((TrackListOriginType2) => {
|
|
3216
3323
|
TrackListOriginType2["TRACK"] = "TRACK";
|
|
3217
3324
|
TrackListOriginType2["GENRE_PLAYLIST"] = "GENRE_PLAYLIST";
|
|
3325
|
+
TrackListOriginType2["GENRE_CATALOGUE"] = "GENRE_CATALOGUE";
|
|
3218
3326
|
TrackListOriginType2["ARTIST"] = "ARTIST";
|
|
3219
3327
|
return TrackListOriginType2;
|
|
3220
3328
|
})(TrackListOriginType || {});
|
|
@@ -3246,27 +3354,48 @@ var TrackListOriginFromTrack = class extends TrackListOrigin {
|
|
|
3246
3354
|
};
|
|
3247
3355
|
var TrackListOriginFromCriteriaPlaylist = class extends TrackListOrigin {
|
|
3248
3356
|
/** `from`: the track the list starts at (server-side `?from=`), kept so later pages use it too. */
|
|
3249
|
-
constructor(criteriaPlaylist, scope, from) {
|
|
3357
|
+
constructor(criteriaPlaylist, scope, from, selection, artistUuid) {
|
|
3250
3358
|
super("GENRE_PLAYLIST" /* GENRE_PLAYLIST */, criteriaPlaylist.name, criteriaPlaylist.uuid, scope);
|
|
3251
3359
|
this.criteriaPlaylist = criteriaPlaylist;
|
|
3252
3360
|
this.from = from;
|
|
3361
|
+
this.selection = selection;
|
|
3362
|
+
this.artistUuid = artistUuid;
|
|
3253
3363
|
}
|
|
3254
3364
|
criteriaPlaylist;
|
|
3255
3365
|
from;
|
|
3366
|
+
selection;
|
|
3367
|
+
artistUuid;
|
|
3256
3368
|
};
|
|
3257
3369
|
var TrackListOriginFromArtist = class extends TrackListOrigin {
|
|
3258
3370
|
/** `ordering`/`from`: kept so later pages use the same order and start track. */
|
|
3259
|
-
constructor(artist, scope, ordering, from, genreUuid) {
|
|
3371
|
+
constructor(artist, scope, ordering, from, genreUuid, selection) {
|
|
3260
3372
|
super("ARTIST" /* ARTIST */, artist.name, artist.uuid, scope);
|
|
3261
3373
|
this.artist = artist;
|
|
3262
3374
|
this.ordering = ordering;
|
|
3263
3375
|
this.from = from;
|
|
3264
3376
|
this.genreUuid = genreUuid;
|
|
3377
|
+
this.selection = selection;
|
|
3265
3378
|
}
|
|
3266
3379
|
artist;
|
|
3267
3380
|
ordering;
|
|
3268
3381
|
from;
|
|
3269
3382
|
genreUuid;
|
|
3383
|
+
selection;
|
|
3384
|
+
};
|
|
3385
|
+
var TrackListOriginFromGenreCatalogue = class extends TrackListOrigin {
|
|
3386
|
+
constructor(genre, scope, from, selection) {
|
|
3387
|
+
super("GENRE_CATALOGUE" /* GENRE_CATALOGUE */, genre.name, genre.uuid, scope);
|
|
3388
|
+
this.genre = genre;
|
|
3389
|
+
this.from = from;
|
|
3390
|
+
this.selection = selection;
|
|
3391
|
+
}
|
|
3392
|
+
genre;
|
|
3393
|
+
from;
|
|
3394
|
+
selection;
|
|
3395
|
+
ordering = "title";
|
|
3396
|
+
get genreUuid() {
|
|
3397
|
+
return this.genre.uuid;
|
|
3398
|
+
}
|
|
3270
3399
|
};
|
|
3271
3400
|
|
|
3272
3401
|
// src/genre-tree/TrackListSidebarVisibilityContext.tsx
|
|
@@ -3375,9 +3504,10 @@ function TrackListProvider({
|
|
|
3375
3504
|
[clearDelayedTrackLoad, loadTrackForPlayer]
|
|
3376
3505
|
);
|
|
3377
3506
|
const fetchTracksPage = (0, import_react19.useCallback)(
|
|
3378
|
-
async (uuid, scope, page, from) => {
|
|
3507
|
+
async (uuid, scope, page, from, selection, artistUuid) => {
|
|
3379
3508
|
const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
|
|
3380
|
-
|
|
3509
|
+
if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
|
|
3510
|
+
const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
|
|
3381
3511
|
const response = await fetch2(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
|
|
3382
3512
|
const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
|
|
3383
3513
|
return {
|
|
@@ -3388,17 +3518,18 @@ function TrackListProvider({
|
|
|
3388
3518
|
},
|
|
3389
3519
|
[fetch2, pageSchema]
|
|
3390
3520
|
);
|
|
3391
|
-
const
|
|
3392
|
-
const
|
|
3521
|
+
const cataloguePageSchema = (0, import_react19.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
|
|
3522
|
+
const fetchCatalogueTracksPage = (0, import_react19.useCallback)(
|
|
3393
3523
|
async (origin, page) => {
|
|
3394
3524
|
const params = {
|
|
3395
|
-
artist: origin.uuid,
|
|
3525
|
+
...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
|
|
3396
3526
|
playable: true,
|
|
3397
3527
|
ordering: origin.ordering,
|
|
3398
3528
|
page,
|
|
3399
3529
|
pageSize: TRACKS_PAGE_SIZE,
|
|
3400
3530
|
...origin.from && { from: origin.from },
|
|
3401
|
-
...origin.genreUuid && { genre: origin.genreUuid }
|
|
3531
|
+
...origin.genreUuid && { genre: origin.genreUuid },
|
|
3532
|
+
...genreMusicQueryParams(origin.selection)
|
|
3402
3533
|
};
|
|
3403
3534
|
const response = await fetch2(
|
|
3404
3535
|
libraryEndpoints.reference.songs.list(),
|
|
@@ -3411,10 +3542,10 @@ function TrackListProvider({
|
|
|
3411
3542
|
page === 1 && !!origin.from,
|
|
3412
3543
|
page === 1
|
|
3413
3544
|
);
|
|
3414
|
-
const parsed = parseWithLog(
|
|
3545
|
+
const parsed = parseWithLog(cataloguePageSchema, response, "fetchCatalogueTracksPage");
|
|
3415
3546
|
return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
|
|
3416
3547
|
},
|
|
3417
|
-
[fetch2,
|
|
3548
|
+
[fetch2, cataloguePageSchema]
|
|
3418
3549
|
);
|
|
3419
3550
|
const advanceAfterTrackEnd = (0, import_react19.useCallback)(
|
|
3420
3551
|
(event) => {
|
|
@@ -3486,7 +3617,7 @@ function TrackListProvider({
|
|
|
3486
3617
|
const from = options?.startSongUuid;
|
|
3487
3618
|
let page;
|
|
3488
3619
|
try {
|
|
3489
|
-
page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
|
|
3620
|
+
page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from, options?.selection, options?.artistUuid);
|
|
3490
3621
|
} catch (error) {
|
|
3491
3622
|
if (request !== latestPlayRequestRef.current) return;
|
|
3492
3623
|
startingPlaybackRef.current = false;
|
|
@@ -3503,7 +3634,7 @@ function TrackListProvider({
|
|
|
3503
3634
|
console.warn("No playable tracks found in genre playlist");
|
|
3504
3635
|
return;
|
|
3505
3636
|
}
|
|
3506
|
-
const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from);
|
|
3637
|
+
const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from, options?.selection, options?.artistUuid);
|
|
3507
3638
|
setAutoAdvanceScrollRequest(null);
|
|
3508
3639
|
setTrackList(new TrackListFromCriteriaPlaylist(page.tracks, origin, page.total, page.nextPage));
|
|
3509
3640
|
setSelectedTrack(startTrack);
|
|
@@ -3512,17 +3643,15 @@ function TrackListProvider({
|
|
|
3512
3643
|
},
|
|
3513
3644
|
[clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
3514
3645
|
);
|
|
3515
|
-
const
|
|
3516
|
-
async (
|
|
3517
|
-
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
3646
|
+
const playCatalogue = (0, import_react19.useCallback)(
|
|
3647
|
+
async (origin) => {
|
|
3518
3648
|
clearDelayedTrackLoad();
|
|
3519
3649
|
const request = ++latestPlayRequestRef.current;
|
|
3520
3650
|
startingPlaybackRef.current = true;
|
|
3521
|
-
const from =
|
|
3522
|
-
const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
|
|
3651
|
+
const from = origin.from;
|
|
3523
3652
|
let page;
|
|
3524
3653
|
try {
|
|
3525
|
-
page = await
|
|
3654
|
+
page = await fetchCatalogueTracksPage(origin, 1);
|
|
3526
3655
|
} catch (error) {
|
|
3527
3656
|
if (request !== latestPlayRequestRef.current) return;
|
|
3528
3657
|
startingPlaybackRef.current = false;
|
|
@@ -3533,19 +3662,34 @@ function TrackListProvider({
|
|
|
3533
3662
|
loadedContextRef.current = playback.snapshot().key;
|
|
3534
3663
|
const startTrack = page.tracks[0];
|
|
3535
3664
|
if (from && startTrack?.uuid !== from) {
|
|
3536
|
-
throw new Error(
|
|
3665
|
+
throw new Error(`${origin instanceof TrackListOriginFromArtist ? "Artist" : "Catalogue"} ${origin.uuid} did not start at song ${from}`);
|
|
3537
3666
|
}
|
|
3538
3667
|
if (!startTrack) {
|
|
3539
|
-
console.warn("No playable songs found
|
|
3668
|
+
console.warn("No playable songs found in catalogue");
|
|
3540
3669
|
return;
|
|
3541
3670
|
}
|
|
3542
|
-
setTrackList(new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage));
|
|
3671
|
+
setTrackList(origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage) : new TrackList(page.tracks, origin, page.total, page.nextPage));
|
|
3543
3672
|
setAutoAdvanceScrollRequest(null);
|
|
3544
3673
|
setSelectedTrack(startTrack);
|
|
3545
3674
|
showTrackListSidebar();
|
|
3546
3675
|
loadTrackForPlayer(startTrack.uuid);
|
|
3547
3676
|
},
|
|
3548
|
-
[clearDelayedTrackLoad,
|
|
3677
|
+
[clearDelayedTrackLoad, fetchCatalogueTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
3678
|
+
);
|
|
3679
|
+
const playNewTrackListFromArtist = (0, import_react19.useCallback)(
|
|
3680
|
+
async (artist, scope, options) => {
|
|
3681
|
+
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
3682
|
+
if (options.selection && !options.genreUuid) throw new Error("A genre selection requires a genre");
|
|
3683
|
+
return playCatalogue(new TrackListOriginFromArtist(artist, scope, options.ordering, options.startSongUuid, options.genreUuid, options.selection));
|
|
3684
|
+
},
|
|
3685
|
+
[playCatalogue]
|
|
3686
|
+
);
|
|
3687
|
+
const playNewTrackListFromGenreCatalogue = (0, import_react19.useCallback)(
|
|
3688
|
+
async (genre, scope, options) => {
|
|
3689
|
+
if (scope !== "reference") throw new Error("Genre catalogues only support the reference scope");
|
|
3690
|
+
return playCatalogue(new TrackListOriginFromGenreCatalogue(genre, scope, options?.startSongUuid, options?.selection));
|
|
3691
|
+
},
|
|
3692
|
+
[playCatalogue]
|
|
3549
3693
|
);
|
|
3550
3694
|
const contextKeyRef = (0, import_react19.useRef)(playback.key);
|
|
3551
3695
|
(0, import_react19.useEffect)(() => {
|
|
@@ -3567,20 +3711,28 @@ function TrackListProvider({
|
|
|
3567
3711
|
setTrackList(null);
|
|
3568
3712
|
setSelectedTrack(null);
|
|
3569
3713
|
if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
|
|
3570
|
-
void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid }).catch((error) => {
|
|
3714
|
+
void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid, selection: origin.selection, artistUuid: origin.artistUuid }).catch((error) => {
|
|
3571
3715
|
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
3572
|
-
return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
|
|
3716
|
+
return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { selection: origin.selection, artistUuid: origin.artistUuid }).catch(() => {
|
|
3573
3717
|
});
|
|
3574
3718
|
}
|
|
3575
3719
|
});
|
|
3576
3720
|
} else if (origin instanceof TrackListOriginFromArtist) {
|
|
3577
|
-
const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
|
|
3721
|
+
const options = { ordering: origin.ordering, genreUuid: origin.genreUuid, selection: origin.selection };
|
|
3578
3722
|
void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
|
|
3579
3723
|
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
3580
3724
|
return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
|
|
3581
3725
|
});
|
|
3582
3726
|
}
|
|
3583
3727
|
});
|
|
3728
|
+
} else if (origin instanceof TrackListOriginFromGenreCatalogue) {
|
|
3729
|
+
const options = { selection: origin.selection };
|
|
3730
|
+
void playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
|
|
3731
|
+
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
3732
|
+
return playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, options).catch(() => {
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
3735
|
+
});
|
|
3584
3736
|
} else if (origin instanceof TrackListOriginFromTrack && selected) {
|
|
3585
3737
|
const request = latestPlayRequestRef.current;
|
|
3586
3738
|
void (async () => {
|
|
@@ -3591,7 +3743,7 @@ function TrackListProvider({
|
|
|
3591
3743
|
})().catch(() => {
|
|
3592
3744
|
});
|
|
3593
3745
|
}
|
|
3594
|
-
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch2]);
|
|
3746
|
+
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch2]);
|
|
3595
3747
|
const updateTrack = (0, import_react19.useCallback)((track) => {
|
|
3596
3748
|
setTrackList((prev) => {
|
|
3597
3749
|
if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
|
|
@@ -3603,22 +3755,22 @@ function TrackListProvider({
|
|
|
3603
3755
|
const loadMore = (0, import_react19.useCallback)(async () => {
|
|
3604
3756
|
if (!trackList || trackList.nextPage === null) return;
|
|
3605
3757
|
const origin = trackList.origin;
|
|
3606
|
-
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist)) return;
|
|
3758
|
+
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
|
|
3607
3759
|
if (loadingOriginRef.current === origin) return;
|
|
3608
3760
|
const requestedPage = trackList.nextPage;
|
|
3609
3761
|
loadingOriginRef.current = origin;
|
|
3610
3762
|
try {
|
|
3611
|
-
const page = origin instanceof TrackListOriginFromArtist ? await
|
|
3763
|
+
const page = origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue ? await fetchCatalogueTracksPage(origin, requestedPage) : await fetchTracksPage(origin.criteriaPlaylist.uuid, origin.scope, requestedPage, origin.from, origin.selection, origin.artistUuid);
|
|
3612
3764
|
setTrackList((prev) => {
|
|
3613
3765
|
if (prev?.origin !== origin || prev.nextPage !== requestedPage) return prev;
|
|
3614
3766
|
const loaded = new Set(prev.tracks.map((track) => track.uuid));
|
|
3615
3767
|
const tracks = [...prev.tracks, ...page.tracks.filter((track) => !loaded.has(track.uuid))];
|
|
3616
|
-
return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
|
|
3768
|
+
return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : origin instanceof TrackListOriginFromGenreCatalogue ? new TrackList(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
|
|
3617
3769
|
});
|
|
3618
3770
|
} finally {
|
|
3619
3771
|
if (loadingOriginRef.current === origin) loadingOriginRef.current = null;
|
|
3620
3772
|
}
|
|
3621
|
-
}, [trackList, fetchTracksPage,
|
|
3773
|
+
}, [trackList, fetchTracksPage, fetchCatalogueTracksPage]);
|
|
3622
3774
|
const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
|
|
3623
3775
|
const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
3624
3776
|
const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
@@ -3706,6 +3858,7 @@ function TrackListProvider({
|
|
|
3706
3858
|
playNewTrackListFromTrackUuid,
|
|
3707
3859
|
playNewTrackListFromGenrePlaylist,
|
|
3708
3860
|
playNewTrackListFromArtist,
|
|
3861
|
+
playNewTrackListFromGenreCatalogue,
|
|
3709
3862
|
fetchGenrePlaylistTracksPage: fetchTracksPage,
|
|
3710
3863
|
loadMore,
|
|
3711
3864
|
updateTrack
|
|
@@ -3723,6 +3876,7 @@ function TrackListProvider({
|
|
|
3723
3876
|
playNewTrackListFromTrackUuid,
|
|
3724
3877
|
playNewTrackListFromGenrePlaylist,
|
|
3725
3878
|
playNewTrackListFromArtist,
|
|
3879
|
+
playNewTrackListFromGenreCatalogue,
|
|
3726
3880
|
fetchTracksPage,
|
|
3727
3881
|
loadMore,
|
|
3728
3882
|
updateTrack
|
|
@@ -3753,24 +3907,24 @@ function ArtistNames({
|
|
|
3753
3907
|
}
|
|
3754
3908
|
|
|
3755
3909
|
// src/genre-tree/schemas/mb-artist.ts
|
|
3756
|
-
var
|
|
3757
|
-
var MbArtistDetailedSchema =
|
|
3758
|
-
musicbrainzId:
|
|
3759
|
-
name:
|
|
3910
|
+
var import_zod36 = require("zod");
|
|
3911
|
+
var MbArtistDetailedSchema = import_zod36.z.object({
|
|
3912
|
+
musicbrainzId: import_zod36.z.string().uuid(),
|
|
3913
|
+
name: import_zod36.z.string(),
|
|
3760
3914
|
musicbrainzLink: HttpUrlSchema
|
|
3761
3915
|
});
|
|
3762
3916
|
|
|
3763
3917
|
// src/genre-tree/schemas/mb-recording.ts
|
|
3764
|
-
var
|
|
3765
|
-
var MbRecordingDetailedSchema =
|
|
3766
|
-
musicbrainzId:
|
|
3767
|
-
title:
|
|
3768
|
-
score:
|
|
3769
|
-
musicbrainzArtists:
|
|
3918
|
+
var import_zod37 = require("zod");
|
|
3919
|
+
var MbRecordingDetailedSchema = import_zod37.z.object({
|
|
3920
|
+
musicbrainzId: import_zod37.z.string().uuid(),
|
|
3921
|
+
title: import_zod37.z.string(),
|
|
3922
|
+
score: import_zod37.z.number(),
|
|
3923
|
+
musicbrainzArtists: import_zod37.z.array(MbArtistDetailedSchema),
|
|
3770
3924
|
musicbrainzLink: HttpUrlSchema,
|
|
3771
|
-
durationInSec:
|
|
3772
|
-
durationStrInHourMinSec:
|
|
3773
|
-
releaseDate:
|
|
3925
|
+
durationInSec: import_zod37.z.number().min(0).nullable().optional(),
|
|
3926
|
+
durationStrInHourMinSec: import_zod37.z.string().nullable().optional(),
|
|
3927
|
+
releaseDate: import_zod37.z.union([import_zod37.z.string().datetime(), import_zod37.z.string()]).transform((val) => {
|
|
3774
3928
|
try {
|
|
3775
3929
|
const date = new Date(val);
|
|
3776
3930
|
if (isNaN(date.getTime())) {
|
|
@@ -3872,6 +4026,10 @@ function editGenreSongPages(data, edit) {
|
|
|
3872
4026
|
FORM_RATING_NULL_VALUE,
|
|
3873
4027
|
FUZZY_MIN_SIMILARITY,
|
|
3874
4028
|
GOOGLE_EXCHANGE_CONFIG,
|
|
4029
|
+
GenreCatalogueCountsSchema,
|
|
4030
|
+
GenreCountsSchema,
|
|
4031
|
+
GenreCoverageSchema,
|
|
4032
|
+
GenrePlaylistSummarySchema,
|
|
3875
4033
|
GenrePlaylistUuidSchema,
|
|
3876
4034
|
GenreSearchResultSchema,
|
|
3877
4035
|
GenreSearchResultsSchema,
|
|
@@ -3889,6 +4047,8 @@ function editGenreSongPages(data, edit) {
|
|
|
3889
4047
|
PlayerProvider,
|
|
3890
4048
|
PlayerVideoSurface,
|
|
3891
4049
|
PopupProvider,
|
|
4050
|
+
ReferenceGenreDetailedSchema,
|
|
4051
|
+
ReferenceGenrePlaylistSchema,
|
|
3892
4052
|
RegionGenreLexiconEntrySchema,
|
|
3893
4053
|
RegionGenreLexiconSchema,
|
|
3894
4054
|
SEARCH_DEBOUNCE_MS,
|
|
@@ -3901,6 +4061,8 @@ function editGenreSongPages(data, edit) {
|
|
|
3901
4061
|
SongHistorySchema,
|
|
3902
4062
|
SongSearchResultSchema,
|
|
3903
4063
|
SongSearchResultsSchema,
|
|
4064
|
+
SubgenreCountsSchema,
|
|
4065
|
+
SubgenreScopeSchema,
|
|
3904
4066
|
TrackBaseSchema,
|
|
3905
4067
|
TrackList,
|
|
3906
4068
|
TrackListFromArtist,
|
|
@@ -3909,6 +4071,7 @@ function editGenreSongPages(data, edit) {
|
|
|
3909
4071
|
TrackListOrigin,
|
|
3910
4072
|
TrackListOriginFromArtist,
|
|
3911
4073
|
TrackListOriginFromCriteriaPlaylist,
|
|
4074
|
+
TrackListOriginFromGenreCatalogue,
|
|
3912
4075
|
TrackListOriginFromTrack,
|
|
3913
4076
|
TrackListOriginType,
|
|
3914
4077
|
TrackListProvider,
|
|
@@ -3931,14 +4094,19 @@ function editGenreSongPages(data, edit) {
|
|
|
3931
4094
|
createAppErrorFromResult,
|
|
3932
4095
|
createLogout,
|
|
3933
4096
|
createNetworkOrBackendError,
|
|
4097
|
+
defaultGenreMusicSelection,
|
|
3934
4098
|
editGenreSongPages,
|
|
3935
4099
|
exchangeCodeWithBackend,
|
|
3936
4100
|
fetchWrapper,
|
|
3937
4101
|
foldSearchText,
|
|
3938
4102
|
formatTime,
|
|
3939
4103
|
genreEndpoints,
|
|
4104
|
+
genreMusicCount,
|
|
4105
|
+
genreMusicQueryParams,
|
|
4106
|
+
genreMusicSelectionKey,
|
|
3940
4107
|
genrePlaylistEndpoints,
|
|
3941
4108
|
genrePlaylistQueryKeys,
|
|
4109
|
+
genrePlaylistTrackCount,
|
|
3942
4110
|
genreQueryKeys,
|
|
3943
4111
|
genreSearchQueryKeys,
|
|
3944
4112
|
genreUpdateMutationKey,
|