@behindthemusictree/app-kit 33.3.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-HHE6VK67.js → chunk-3PITD62C.js} +456 -310
- package/dist/chunk-3PITD62C.js.map +1 -0
- package/dist/genre-tree/index.cjs +514 -352
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +1346 -223
- package/dist/genre-tree/index.js +29 -1
- package/dist/index.cjs +462 -300
- 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-HHE6VK67.js.map +0 -1
|
@@ -24,51 +24,152 @@ import {
|
|
|
24
24
|
} from "./chunk-JMFEWI53.js";
|
|
25
25
|
|
|
26
26
|
// src/genre-tree/useGenre.ts
|
|
27
|
-
import { z as
|
|
28
|
-
import { useQuery, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
29
|
-
import { useCallback } from "react";
|
|
27
|
+
import { z as z19 } from "zod";
|
|
30
28
|
|
|
31
|
-
// src/genre-tree/
|
|
32
|
-
import { z as
|
|
33
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
29
|
+
// src/genre-tree/schemas/criteria/detailed.ts
|
|
30
|
+
import { z as z10 } from "zod";
|
|
34
31
|
|
|
35
|
-
// src/genre-tree/schemas/
|
|
36
|
-
import { z as
|
|
32
|
+
// src/genre-tree/schemas/genre-music.ts
|
|
33
|
+
import { z as z2 } from "zod";
|
|
37
34
|
|
|
38
|
-
// src/genre-tree/schemas/criteria-playlist/
|
|
39
|
-
import { z
|
|
35
|
+
// src/genre-tree/schemas/criteria-playlist/minimum.ts
|
|
36
|
+
import { z } from "zod";
|
|
37
|
+
var CriteriaPlaylistMinimumSchema = z.object({
|
|
38
|
+
uuid: GenrePlaylistUuidSchema,
|
|
39
|
+
name: z.string()
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/genre-tree/schemas/genre-music.ts
|
|
43
|
+
var CountSchema = z2.number().int().nonnegative();
|
|
44
|
+
var SubgenreCountsSchema = z2.union([
|
|
45
|
+
z2.object({ canonical: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
|
|
46
|
+
z2.object({ all: CountSchema }).strict()
|
|
47
|
+
]).refine(
|
|
48
|
+
(counts) => !("canonical" in counts) || counts.all >= counts.canonical && counts.all >= counts.regional,
|
|
49
|
+
"The combined count must include both scoped selections"
|
|
50
|
+
);
|
|
51
|
+
var GenreCountsSchema = z2.object({
|
|
52
|
+
genreOnlyTracksCount: CountSchema,
|
|
53
|
+
genreAndSubgenresTracksCount: SubgenreCountsSchema
|
|
54
|
+
});
|
|
55
|
+
var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTracksCount).every((count) => count >= counts.genreOnlyTracksCount);
|
|
56
|
+
var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
|
|
57
|
+
var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
|
|
58
|
+
var GenreCoverageSchema = z2.enum(["genreOnly", "genreAndSubgenres"]);
|
|
59
|
+
var SubgenreScopeSchema = z2.enum(["canonical", "regional", "all"]);
|
|
40
60
|
|
|
41
61
|
// src/genre-tree/schemas/criteria/minimum.ts
|
|
42
|
-
import { z } from "zod";
|
|
43
|
-
var CriteriaMinimumSchema =
|
|
62
|
+
import { z as z3 } from "zod";
|
|
63
|
+
var CriteriaMinimumSchema = z3.object({
|
|
44
64
|
uuid: GenreUuidSchema,
|
|
45
|
-
name:
|
|
46
|
-
side:
|
|
47
|
-
wikidataId:
|
|
65
|
+
name: z3.string(),
|
|
66
|
+
side: z3.enum(["core", "pop"]).nullable().optional(),
|
|
67
|
+
wikidataId: z3.string().nullable().optional()
|
|
48
68
|
});
|
|
49
69
|
|
|
50
|
-
// src/genre-tree/schemas/
|
|
51
|
-
import { z as
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
// src/genre-tree/schemas/track/base.ts
|
|
71
|
+
import { z as z7 } from "zod";
|
|
72
|
+
|
|
73
|
+
// src/genre-tree/schemas/artist-minimum.ts
|
|
74
|
+
import { z as z4 } from "zod";
|
|
75
|
+
var ArtistMinimumSchema = z4.object({
|
|
76
|
+
uuid: z4.string().uuid(),
|
|
77
|
+
name: z4.string(),
|
|
78
|
+
isSpecialPurpose: z4.boolean().optional()
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// src/genre-tree/schemas/album-minimum.ts
|
|
82
|
+
import { z as z5 } from "zod";
|
|
83
|
+
var AlbumMinimumSchema = z5.object({
|
|
84
|
+
uuid: z5.string().uuid(),
|
|
85
|
+
name: z5.string(),
|
|
86
|
+
albumArtists: z5.array(ArtistMinimumSchema).nullable().optional()
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// src/genre-tree/schemas/uuid-resource.ts
|
|
90
|
+
import { z as z6 } from "zod";
|
|
91
|
+
var UuidResourceSchema = z6.object({
|
|
92
|
+
uuid: z6.string().uuid()
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/genre-tree/schemas/track/base.ts
|
|
96
|
+
var TrackBaseSchema = UuidResourceSchema.extend({
|
|
97
|
+
title: z7.string(),
|
|
98
|
+
artists: z7.array(ArtistMinimumSchema).nullable().optional(),
|
|
99
|
+
album: AlbumMinimumSchema.nullable().optional(),
|
|
100
|
+
trackNumber: z7.number().nullable().optional(),
|
|
101
|
+
// null for a song not yet linked to a genre.
|
|
102
|
+
genre: CriteriaMinimumSchema.nullable(),
|
|
103
|
+
rating: z7.number().min(0).max(10).nullable().optional(),
|
|
104
|
+
language: z7.string().nullable().optional(),
|
|
105
|
+
playCount: z7.number().min(0),
|
|
106
|
+
createdOn: z7.string().datetime(),
|
|
107
|
+
updatedOn: z7.string().datetime().nullable().optional()
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// src/genre-tree/schemas/track/minimum.ts
|
|
111
|
+
var TrackMinimumSchema = TrackBaseSchema.pick({
|
|
112
|
+
uuid: true,
|
|
113
|
+
title: true,
|
|
114
|
+
artists: true
|
|
55
115
|
});
|
|
56
116
|
|
|
117
|
+
// src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
|
|
118
|
+
import { z as z8 } from "zod";
|
|
119
|
+
var CriteriaLineageRelWithoutAscendantSchema = z8.object({
|
|
120
|
+
descendant: CriteriaMinimumSchema,
|
|
121
|
+
degree: z8.number()
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
|
|
125
|
+
import { z as z9 } from "zod";
|
|
126
|
+
var CriteriaLineageRelWithoutDescendantSchema = z9.object({
|
|
127
|
+
ascendant: CriteriaMinimumSchema,
|
|
128
|
+
degree: z9.number()
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// src/genre-tree/schemas/criteria/detailed.ts
|
|
132
|
+
var CriteriaDetailedSchema = z10.object({
|
|
133
|
+
uuid: GenreUuidSchema,
|
|
134
|
+
name: z10.string(),
|
|
135
|
+
summary: z10.string().nullable(),
|
|
136
|
+
// Optional until every deployed API serves it.
|
|
137
|
+
wikidataId: z10.string().nullable().optional(),
|
|
138
|
+
parent: CriteriaMinimumSchema.nullable(),
|
|
139
|
+
ascendants: z10.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
140
|
+
descendants: z10.array(CriteriaLineageRelWithoutAscendantSchema),
|
|
141
|
+
root: CriteriaMinimumSchema,
|
|
142
|
+
children: z10.array(CriteriaMinimumSchema),
|
|
143
|
+
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
144
|
+
criteriaPlaylist: z10.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]),
|
|
145
|
+
tracks: z10.array(TrackMinimumSchema),
|
|
146
|
+
essentialSongs: z10.array(TrackMinimumSchema),
|
|
147
|
+
tracksCount: z10.number(),
|
|
148
|
+
updatedOn: z10.string().datetime().nullable()
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
152
|
+
import { z as z12 } from "zod";
|
|
153
|
+
|
|
57
154
|
// src/genre-tree/schemas/criteria-playlist/detailed.ts
|
|
58
|
-
|
|
155
|
+
import { z as z11 } from "zod";
|
|
156
|
+
var CriteriaPlaylistDetailedSchema = z11.object({
|
|
59
157
|
uuid: GenrePlaylistUuidSchema,
|
|
60
|
-
name:
|
|
61
|
-
tracksCount:
|
|
158
|
+
name: z11.string(),
|
|
159
|
+
tracksCount: z11.number(),
|
|
160
|
+
genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
|
|
161
|
+
genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
|
|
162
|
+
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
62
163
|
// Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
|
|
63
|
-
viewsCount:
|
|
64
|
-
durationInSec:
|
|
65
|
-
durationStrInHourMinSec:
|
|
164
|
+
viewsCount: z11.number().optional(),
|
|
165
|
+
durationInSec: z11.number().min(0).nullable().optional(),
|
|
166
|
+
durationStrInHourMinSec: z11.string().nullable().optional(),
|
|
66
167
|
// Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
|
|
67
168
|
criteria: CriteriaMinimumSchema.nullable(),
|
|
68
169
|
parent: CriteriaPlaylistMinimumSchema.nullable(),
|
|
69
170
|
root: CriteriaPlaylistMinimumSchema,
|
|
70
|
-
createdOn:
|
|
71
|
-
updatedOn:
|
|
171
|
+
createdOn: z11.string(),
|
|
172
|
+
updatedOn: z11.string().nullable()
|
|
72
173
|
});
|
|
73
174
|
|
|
74
175
|
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
@@ -79,18 +180,42 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
|
|
|
79
180
|
parent: true,
|
|
80
181
|
root: true,
|
|
81
182
|
tracksCount: true,
|
|
183
|
+
genreOnlyTracksCount: true,
|
|
184
|
+
genreAndSubgenresTracksCount: true,
|
|
185
|
+
catalogue: true,
|
|
82
186
|
viewsCount: true,
|
|
83
187
|
createdOn: true,
|
|
84
188
|
updatedOn: true
|
|
85
189
|
}).extend({
|
|
86
190
|
// Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
|
|
87
|
-
isUnacceptedRoot:
|
|
191
|
+
isUnacceptedRoot: z12.boolean(),
|
|
88
192
|
// Optional: a backend that does not curate umbrella genres omits it.
|
|
89
|
-
isUmbrella:
|
|
193
|
+
isUmbrella: z12.boolean().optional(),
|
|
90
194
|
// Optional: only the grow tree payload carries it; null when the genre has no scene.
|
|
91
|
-
scene:
|
|
195
|
+
scene: z12.enum(["commercial", "underground"]).nullable().optional()
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// src/genre-tree/schemas/reference-genre.ts
|
|
199
|
+
var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
|
|
200
|
+
catalogue: GenreCatalogueCountsSchema,
|
|
201
|
+
criteriaPlaylist: GenrePlaylistSummarySchema
|
|
202
|
+
});
|
|
203
|
+
var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
|
|
204
|
+
...GenreCountsSchema.shape,
|
|
205
|
+
catalogue: GenreCatalogueCountsSchema
|
|
206
|
+
}).superRefine((playlist, ctx) => {
|
|
207
|
+
const counts = GenreCatalogueCountsSchema.safeParse(playlist);
|
|
208
|
+
if (!counts.success) for (const issue of counts.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
92
209
|
});
|
|
93
210
|
|
|
211
|
+
// src/genre-tree/useGenre.ts
|
|
212
|
+
import { useQuery, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
213
|
+
import { useCallback } from "react";
|
|
214
|
+
|
|
215
|
+
// src/genre-tree/useGenrePlaylist.ts
|
|
216
|
+
import { z as z13 } from "zod";
|
|
217
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
218
|
+
|
|
94
219
|
// src/genre-tree/api/genre-playlists/queryKeys.ts
|
|
95
220
|
var genrePlaylistQueryKeys = {
|
|
96
221
|
me: {
|
|
@@ -126,6 +251,30 @@ var genrePlaylistEndpoints = {
|
|
|
126
251
|
reference: { ...makeGenrePlaylistEndpoints(""), tree: () => "genre-playlists/tree/" }
|
|
127
252
|
};
|
|
128
253
|
|
|
254
|
+
// src/genre-tree/lib/genre-music-selection.ts
|
|
255
|
+
function defaultGenreMusicSelection(counts) {
|
|
256
|
+
return { coverage: "genreAndSubgenres", subgenres: "canonical" in counts.genreAndSubgenresTracksCount ? "canonical" : "all" };
|
|
257
|
+
}
|
|
258
|
+
function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
|
|
259
|
+
if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
|
|
260
|
+
const scopes = counts.genreAndSubgenresTracksCount;
|
|
261
|
+
if (selection.subgenres === "all") return scopes.all;
|
|
262
|
+
if (!("canonical" in scopes)) throw new Error("Regional genres only support all subgenres");
|
|
263
|
+
return scopes[selection.subgenres];
|
|
264
|
+
}
|
|
265
|
+
function genreMusicQueryParams(selection) {
|
|
266
|
+
if (!selection) return {};
|
|
267
|
+
return selection.coverage === "genreOnly" ? { coverage: "genre_only" } : { coverage: "genre_and_subgenres", subgenres: selection.subgenres };
|
|
268
|
+
}
|
|
269
|
+
function genreMusicSelectionKey(selection) {
|
|
270
|
+
return selection ? [selection.coverage, ...selection.coverage === "genreAndSubgenres" ? [selection.subgenres] : []] : [];
|
|
271
|
+
}
|
|
272
|
+
function genrePlaylistTrackCount(playlist) {
|
|
273
|
+
if (playlist.genreOnlyTracksCount === void 0 && playlist.genreAndSubgenresTracksCount === void 0) return playlist.tracksCount;
|
|
274
|
+
if (playlist.genreOnlyTracksCount === void 0 || playlist.genreAndSubgenresTracksCount === void 0) throw new Error("Incomplete genre playlist counts");
|
|
275
|
+
return genreMusicCount({ genreOnlyTracksCount: playlist.genreOnlyTracksCount, genreAndSubgenresTracksCount: playlist.genreAndSubgenresTracksCount });
|
|
276
|
+
}
|
|
277
|
+
|
|
129
278
|
// src/genre-tree/api/library/songs/queryKeys.ts
|
|
130
279
|
var makeSongQueryKeys = (prefix) => ({
|
|
131
280
|
all: [`${prefix}Songs`],
|
|
@@ -134,7 +283,7 @@ var makeSongQueryKeys = (prefix) => ({
|
|
|
134
283
|
history: (uuid) => [`${prefix}Songs`, "history", uuid],
|
|
135
284
|
search: (params) => [`${prefix}Songs`, "search", params],
|
|
136
285
|
// baseUrl keeps distinct backends sharing a scope (e.g. grow and its prototype proxy) apart.
|
|
137
|
-
byGenre: (baseUrl, genreUuid) => [`${prefix}Songs`, baseUrl, "genre", genreUuid]
|
|
286
|
+
byGenre: (baseUrl, genreUuid, selection) => [`${prefix}Songs`, baseUrl, "genre", genreUuid, ...genreMusicSelectionKey(selection)]
|
|
138
287
|
});
|
|
139
288
|
|
|
140
289
|
// src/genre-tree/api/library/songs/endpoints.ts
|
|
@@ -204,7 +353,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
|
|
|
204
353
|
const queryClient = useQueryClient();
|
|
205
354
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
206
355
|
const { session, sessionRestored } = useSession();
|
|
207
|
-
const queryKey = scope === "reference" ? genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()) : genrePlaylistQueryKeys.me.full;
|
|
356
|
+
const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
|
|
208
357
|
const query = useQueryWithParse({
|
|
209
358
|
queryKey,
|
|
210
359
|
queryFn: () => scope === "reference" ? fetch(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "canonical" }) : fetchAllPages(
|
|
@@ -216,7 +365,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
|
|
|
216
365
|
{ page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
|
|
217
366
|
)
|
|
218
367
|
),
|
|
219
|
-
schema:
|
|
368
|
+
schema: scope === "reference" ? z13.array(ReferenceGenrePlaylistSchema) : z13.array(CriteriaPlaylistSimpleSchema),
|
|
220
369
|
context: "useListFullGenrePlaylists",
|
|
221
370
|
enabled: scope === "reference" || sessionRestored && !!session?.accessToken
|
|
222
371
|
});
|
|
@@ -249,131 +398,48 @@ var useInvalidateAllGenrePlaylistQueries = () => {
|
|
|
249
398
|
]);
|
|
250
399
|
};
|
|
251
400
|
|
|
252
|
-
// src/genre-tree/schemas/criteria/detailed.ts
|
|
253
|
-
import { z as z12 } from "zod";
|
|
254
|
-
|
|
255
|
-
// src/genre-tree/schemas/track/base.ts
|
|
256
|
-
import { z as z9 } from "zod";
|
|
257
|
-
|
|
258
|
-
// src/genre-tree/schemas/artist-minimum.ts
|
|
259
|
-
import { z as z6 } from "zod";
|
|
260
|
-
var ArtistMinimumSchema = z6.object({
|
|
261
|
-
uuid: z6.string().uuid(),
|
|
262
|
-
name: z6.string(),
|
|
263
|
-
isSpecialPurpose: z6.boolean().optional()
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// src/genre-tree/schemas/album-minimum.ts
|
|
267
|
-
import { z as z7 } from "zod";
|
|
268
|
-
var AlbumMinimumSchema = z7.object({
|
|
269
|
-
uuid: z7.string().uuid(),
|
|
270
|
-
name: z7.string(),
|
|
271
|
-
albumArtists: z7.array(ArtistMinimumSchema).nullable().optional()
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
// src/genre-tree/schemas/uuid-resource.ts
|
|
275
|
-
import { z as z8 } from "zod";
|
|
276
|
-
var UuidResourceSchema = z8.object({
|
|
277
|
-
uuid: z8.string().uuid()
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
// src/genre-tree/schemas/track/base.ts
|
|
281
|
-
var TrackBaseSchema = UuidResourceSchema.extend({
|
|
282
|
-
title: z9.string(),
|
|
283
|
-
artists: z9.array(ArtistMinimumSchema).nullable().optional(),
|
|
284
|
-
album: AlbumMinimumSchema.nullable().optional(),
|
|
285
|
-
trackNumber: z9.number().nullable().optional(),
|
|
286
|
-
// null for a song not yet linked to a genre.
|
|
287
|
-
genre: CriteriaMinimumSchema.nullable(),
|
|
288
|
-
rating: z9.number().min(0).max(10).nullable().optional(),
|
|
289
|
-
language: z9.string().nullable().optional(),
|
|
290
|
-
playCount: z9.number().min(0),
|
|
291
|
-
createdOn: z9.string().datetime(),
|
|
292
|
-
updatedOn: z9.string().datetime().nullable().optional()
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
// src/genre-tree/schemas/track/minimum.ts
|
|
296
|
-
var TrackMinimumSchema = TrackBaseSchema.pick({
|
|
297
|
-
uuid: true,
|
|
298
|
-
title: true,
|
|
299
|
-
artists: true
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
// src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
|
|
303
|
-
import { z as z10 } from "zod";
|
|
304
|
-
var CriteriaLineageRelWithoutAscendantSchema = z10.object({
|
|
305
|
-
descendant: CriteriaMinimumSchema,
|
|
306
|
-
degree: z10.number()
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
// src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
|
|
310
|
-
import { z as z11 } from "zod";
|
|
311
|
-
var CriteriaLineageRelWithoutDescendantSchema = z11.object({
|
|
312
|
-
ascendant: CriteriaMinimumSchema,
|
|
313
|
-
degree: z11.number()
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
// src/genre-tree/schemas/criteria/detailed.ts
|
|
317
|
-
var CriteriaDetailedSchema = z12.object({
|
|
318
|
-
uuid: GenreUuidSchema,
|
|
319
|
-
name: z12.string(),
|
|
320
|
-
summary: z12.string().nullable(),
|
|
321
|
-
// Optional until every deployed API serves it.
|
|
322
|
-
wikidataId: z12.string().nullable().optional(),
|
|
323
|
-
parent: CriteriaMinimumSchema.nullable(),
|
|
324
|
-
ascendants: z12.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
325
|
-
descendants: z12.array(CriteriaLineageRelWithoutAscendantSchema),
|
|
326
|
-
root: CriteriaMinimumSchema,
|
|
327
|
-
children: z12.array(CriteriaMinimumSchema),
|
|
328
|
-
criteriaPlaylist: CriteriaPlaylistMinimumSchema,
|
|
329
|
-
tracks: z12.array(TrackMinimumSchema),
|
|
330
|
-
essentialSongs: z12.array(TrackMinimumSchema),
|
|
331
|
-
tracksCount: z12.number(),
|
|
332
|
-
updatedOn: z12.string().datetime().nullable()
|
|
333
|
-
});
|
|
334
|
-
|
|
335
401
|
// src/genre-tree/schemas/criteria/overview.ts
|
|
336
|
-
import { z as
|
|
402
|
+
import { z as z15 } from "zod";
|
|
337
403
|
|
|
338
404
|
// src/genre-tree/schemas/http-url.ts
|
|
339
|
-
import { z as
|
|
340
|
-
var HttpUrlSchema =
|
|
405
|
+
import { z as z14 } from "zod";
|
|
406
|
+
var HttpUrlSchema = z14.url({ protocol: /^https?$/ });
|
|
341
407
|
|
|
342
408
|
// src/genre-tree/schemas/criteria/overview.ts
|
|
343
|
-
var CriteriaOverviewSchema =
|
|
409
|
+
var CriteriaOverviewSchema = z15.object({
|
|
344
410
|
uuid: GenreUuidSchema,
|
|
345
|
-
name:
|
|
346
|
-
summary:
|
|
347
|
-
description:
|
|
411
|
+
name: z15.string(),
|
|
412
|
+
summary: z15.string().nullable(),
|
|
413
|
+
description: z15.string().nullable(),
|
|
348
414
|
summarySourceUrl: HttpUrlSchema.nullable(),
|
|
349
|
-
essentialSongs:
|
|
415
|
+
essentialSongs: z15.array(TrackMinimumSchema).optional()
|
|
350
416
|
});
|
|
351
417
|
|
|
352
418
|
// src/genre-tree/schemas/criteria/simple.ts
|
|
353
|
-
import { z as
|
|
354
|
-
var CriteriaSimpleSchema =
|
|
419
|
+
import { z as z16 } from "zod";
|
|
420
|
+
var CriteriaSimpleSchema = z16.object({
|
|
355
421
|
uuid: GenreUuidSchema,
|
|
356
|
-
name:
|
|
422
|
+
name: z16.string(),
|
|
357
423
|
parent: CriteriaMinimumSchema.nullable(),
|
|
358
|
-
createdOn:
|
|
359
|
-
summary:
|
|
424
|
+
createdOn: z16.string().datetime(),
|
|
425
|
+
summary: z16.string().nullable()
|
|
360
426
|
});
|
|
361
427
|
|
|
362
428
|
// src/genre-tree/schemas/criteria/creation.ts
|
|
363
|
-
import { z as
|
|
364
|
-
var CriteriaCreationSchema =
|
|
365
|
-
name:
|
|
429
|
+
import { z as z17 } from "zod";
|
|
430
|
+
var CriteriaCreationSchema = z17.object({
|
|
431
|
+
name: z17.string().min(1, "Name is required"),
|
|
366
432
|
parent: GenreUuidSchema.optional(),
|
|
367
|
-
essentialSongs:
|
|
433
|
+
essentialSongs: z17.array(z17.string().uuid()).optional()
|
|
368
434
|
});
|
|
369
435
|
|
|
370
436
|
// src/genre-tree/schemas/criteria/update.ts
|
|
371
|
-
import { z as
|
|
372
|
-
var CriteriaUpdateSchema =
|
|
373
|
-
name:
|
|
437
|
+
import { z as z18 } from "zod";
|
|
438
|
+
var CriteriaUpdateSchema = z18.object({
|
|
439
|
+
name: z18.string().optional(),
|
|
374
440
|
parent: GenreUuidSchema.nullable().optional(),
|
|
375
|
-
essentialSongs:
|
|
376
|
-
side:
|
|
441
|
+
essentialSongs: z18.array(z18.string().uuid()).optional(),
|
|
442
|
+
side: z18.enum(["core", "pop"]).optional()
|
|
377
443
|
});
|
|
378
444
|
|
|
379
445
|
// src/genre-tree/api/genres/queryKeys.ts
|
|
@@ -434,18 +500,18 @@ function useFetchGenre(scope, getBackendBaseUrl) {
|
|
|
434
500
|
async (id) => {
|
|
435
501
|
const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
|
|
436
502
|
const response = await fetch(endpoint, true, scope === "me");
|
|
437
|
-
return parseWithLog(CriteriaDetailedSchema, response, "useFetchGenre");
|
|
503
|
+
return parseWithLog(scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema, response, "useFetchGenre");
|
|
438
504
|
},
|
|
439
505
|
[fetch, scope]
|
|
440
506
|
);
|
|
441
507
|
}
|
|
442
|
-
function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = CriteriaDetailedSchema) {
|
|
508
|
+
function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema) {
|
|
443
509
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
444
510
|
const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
|
|
445
511
|
const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
|
|
446
512
|
const genreUuid = id ?? "";
|
|
447
513
|
return useQueryWithParse({
|
|
448
|
-
queryKey: queryKeys.detail(genreUuid),
|
|
514
|
+
queryKey: scope === "reference" ? [...queryKeys.detail(genreUuid), getBackendBaseUrl(), "genreMusicV1"] : queryKeys.detail(genreUuid),
|
|
449
515
|
queryFn: () => fetch(endpoints.detail(genreUuid), true, scope === "me"),
|
|
450
516
|
schema,
|
|
451
517
|
context: "useFetchGenreDetail",
|
|
@@ -528,7 +594,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
|
|
|
528
594
|
const refreshGenreTree = useRefreshGenreTree(scope);
|
|
529
595
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
530
596
|
const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
|
|
531
|
-
inputSchema:
|
|
597
|
+
inputSchema: z19.object({
|
|
532
598
|
uuid: GenreUuidSchema,
|
|
533
599
|
data: CriteriaUpdateSchema
|
|
534
600
|
}),
|
|
@@ -558,8 +624,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
|
|
|
558
624
|
const refreshGenreTree = useRefreshGenreTree(scope);
|
|
559
625
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
560
626
|
return useValidatedMutation({
|
|
561
|
-
inputSchema:
|
|
562
|
-
outputSchema:
|
|
627
|
+
inputSchema: z19.object({ uuid: GenreUuidSchema }),
|
|
628
|
+
outputSchema: z19.null(),
|
|
563
629
|
mutationFn: async ({ uuid }) => {
|
|
564
630
|
const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
|
|
565
631
|
return fetch(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
|
|
@@ -569,16 +635,16 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
|
|
|
569
635
|
}
|
|
570
636
|
|
|
571
637
|
// src/genre-tree/useArtist.ts
|
|
572
|
-
import { z as
|
|
638
|
+
import { z as z21 } from "zod";
|
|
573
639
|
|
|
574
640
|
// src/genre-tree/schemas/artist-detailed.ts
|
|
575
|
-
import { z as
|
|
576
|
-
var ArtistMembershipSchema =
|
|
641
|
+
import { z as z20 } from "zod";
|
|
642
|
+
var ArtistMembershipSchema = z20.object({
|
|
577
643
|
artist: ArtistMinimumSchema,
|
|
578
|
-
beginYear:
|
|
579
|
-
endYear:
|
|
580
|
-
ended:
|
|
581
|
-
roles:
|
|
644
|
+
beginYear: z20.number().int().nullable(),
|
|
645
|
+
endYear: z20.number().int().nullable(),
|
|
646
|
+
ended: z20.boolean(),
|
|
647
|
+
roles: z20.array(z20.string())
|
|
582
648
|
});
|
|
583
649
|
var ARTIST_LINK_KINDS = [
|
|
584
650
|
"official",
|
|
@@ -591,35 +657,35 @@ var ARTIST_LINK_KINDS = [
|
|
|
591
657
|
"discogs",
|
|
592
658
|
"social"
|
|
593
659
|
];
|
|
594
|
-
var ArtistImageSchema =
|
|
660
|
+
var ArtistImageSchema = z20.object({
|
|
595
661
|
url: HttpUrlSchema,
|
|
596
662
|
pageUrl: HttpUrlSchema,
|
|
597
|
-
author:
|
|
598
|
-
license:
|
|
663
|
+
author: z20.string().nullable(),
|
|
664
|
+
license: z20.string(),
|
|
599
665
|
licenseUrl: HttpUrlSchema.nullable()
|
|
600
666
|
});
|
|
601
|
-
var ArtistDetailedSchema =
|
|
602
|
-
uuid:
|
|
603
|
-
name:
|
|
604
|
-
musicbrainzArtistId:
|
|
605
|
-
type:
|
|
606
|
-
country:
|
|
607
|
-
beginYear:
|
|
608
|
-
endYear:
|
|
609
|
-
ended:
|
|
610
|
-
links:
|
|
611
|
-
members:
|
|
612
|
-
memberOf:
|
|
613
|
-
albums:
|
|
614
|
-
|
|
615
|
-
uuid:
|
|
616
|
-
name:
|
|
617
|
-
year:
|
|
618
|
-
primaryType:
|
|
619
|
-
secondaryTypes:
|
|
667
|
+
var ArtistDetailedSchema = z20.object({
|
|
668
|
+
uuid: z20.string().uuid(),
|
|
669
|
+
name: z20.string(),
|
|
670
|
+
musicbrainzArtistId: z20.string().uuid().nullable(),
|
|
671
|
+
type: z20.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
|
|
672
|
+
country: z20.string().nullable(),
|
|
673
|
+
beginYear: z20.number().int().nullable(),
|
|
674
|
+
endYear: z20.number().int().nullable(),
|
|
675
|
+
ended: z20.boolean(),
|
|
676
|
+
links: z20.array(z20.object({ kind: z20.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
|
|
677
|
+
members: z20.array(ArtistMembershipSchema),
|
|
678
|
+
memberOf: z20.array(ArtistMembershipSchema),
|
|
679
|
+
albums: z20.array(
|
|
680
|
+
z20.object({
|
|
681
|
+
uuid: z20.string().uuid(),
|
|
682
|
+
name: z20.string(),
|
|
683
|
+
year: z20.string().nullable(),
|
|
684
|
+
primaryType: z20.string().nullable(),
|
|
685
|
+
secondaryTypes: z20.array(z20.string())
|
|
620
686
|
})
|
|
621
687
|
),
|
|
622
|
-
tracksCount:
|
|
688
|
+
tracksCount: z20.number().int(),
|
|
623
689
|
image: ArtistImageSchema.nullable()
|
|
624
690
|
});
|
|
625
691
|
|
|
@@ -642,7 +708,7 @@ var artistEndpoints = {
|
|
|
642
708
|
var isNotFound = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
|
|
643
709
|
function useArtist(uuid, getBackendBaseUrl) {
|
|
644
710
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
645
|
-
const isUuid = uuid !== null &&
|
|
711
|
+
const isUuid = uuid !== null && z21.string().uuid().safeParse(uuid).success;
|
|
646
712
|
const { data, isPending, error } = useQueryWithParse({
|
|
647
713
|
queryKey: artistQueryKeys.detail(uuid),
|
|
648
714
|
// A missing artist is shown in the panel, not raised as an app-wide connectivity error.
|
|
@@ -660,19 +726,19 @@ function useArtist(uuid, getBackendBaseUrl) {
|
|
|
660
726
|
}
|
|
661
727
|
|
|
662
728
|
// src/genre-tree/schemas/artist-search.ts
|
|
663
|
-
import { z as
|
|
664
|
-
var ArtistSearchResultSchema =
|
|
665
|
-
uuid:
|
|
666
|
-
name:
|
|
667
|
-
disambiguation:
|
|
668
|
-
type:
|
|
669
|
-
country:
|
|
670
|
-
beginYear:
|
|
671
|
-
endYear:
|
|
672
|
-
matchedAlias:
|
|
673
|
-
recordingCount:
|
|
729
|
+
import { z as z22 } from "zod";
|
|
730
|
+
var ArtistSearchResultSchema = z22.object({
|
|
731
|
+
uuid: z22.string().uuid(),
|
|
732
|
+
name: z22.string(),
|
|
733
|
+
disambiguation: z22.string().nullable(),
|
|
734
|
+
type: z22.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
|
|
735
|
+
country: z22.string().nullable(),
|
|
736
|
+
beginYear: z22.number().int().nullable(),
|
|
737
|
+
endYear: z22.number().int().nullable(),
|
|
738
|
+
matchedAlias: z22.string().nullable(),
|
|
739
|
+
recordingCount: z22.number().int()
|
|
674
740
|
});
|
|
675
|
-
var ArtistSearchResultsSchema =
|
|
741
|
+
var ArtistSearchResultsSchema = z22.array(ArtistSearchResultSchema);
|
|
676
742
|
|
|
677
743
|
// src/genre-tree/useRemoteSearch.ts
|
|
678
744
|
import { keepPreviousData } from "@tanstack/react-query";
|
|
@@ -726,10 +792,10 @@ function useArtistSearch(getBackendBaseUrl, text) {
|
|
|
726
792
|
}
|
|
727
793
|
|
|
728
794
|
// src/genre-tree/useSong.ts
|
|
729
|
-
import { z as
|
|
795
|
+
import { z as z24 } from "zod";
|
|
730
796
|
|
|
731
797
|
// src/genre-tree/schemas/song/detailed.ts
|
|
732
|
-
import { z as
|
|
798
|
+
import { z as z23 } from "zod";
|
|
733
799
|
var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
734
800
|
not_found: "Video unavailable",
|
|
735
801
|
not_embeddable: "Embedding disabled",
|
|
@@ -738,23 +804,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
|
738
804
|
region_whitelisted: "Region restricted"
|
|
739
805
|
};
|
|
740
806
|
var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
|
|
741
|
-
var YoutubeAvailabilitySchema =
|
|
742
|
-
status:
|
|
743
|
-
reason:
|
|
744
|
-
country:
|
|
807
|
+
var YoutubeAvailabilitySchema = z23.object({
|
|
808
|
+
status: z23.enum(["eligible", "blocked", "unknown"]),
|
|
809
|
+
reason: z23.string().nullable(),
|
|
810
|
+
country: z23.string().nullable()
|
|
745
811
|
});
|
|
746
812
|
var SongDetailedSchema = TrackBaseSchema.extend({
|
|
747
|
-
youtubeVideo:
|
|
748
|
-
id:
|
|
813
|
+
youtubeVideo: z23.object({
|
|
814
|
+
id: z23.string(),
|
|
749
815
|
availability: YoutubeAvailabilitySchema.optional(),
|
|
750
816
|
// null = playable
|
|
751
|
-
unplayableReason:
|
|
752
|
-
viewCount:
|
|
817
|
+
unplayableReason: z23.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
|
|
818
|
+
viewCount: z23.number().int().nullable().optional()
|
|
753
819
|
}).nullable(),
|
|
754
820
|
// null for hand-made/admin songs
|
|
755
|
-
musicbrainzRecordingId:
|
|
756
|
-
firstReleaseYear:
|
|
757
|
-
essentialGenres:
|
|
821
|
+
musicbrainzRecordingId: z23.string().uuid().nullable(),
|
|
822
|
+
firstReleaseYear: z23.number().int().nullable().optional(),
|
|
823
|
+
essentialGenres: z23.array(CriteriaMinimumSchema).optional()
|
|
758
824
|
});
|
|
759
825
|
var NO_VIDEO_LABEL = "No video available";
|
|
760
826
|
function isSong(track) {
|
|
@@ -775,7 +841,7 @@ var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC404
|
|
|
775
841
|
function useSong(uuid, getBackendBaseUrl) {
|
|
776
842
|
const playback = usePlaybackContext();
|
|
777
843
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
778
|
-
const isUuid = uuid !== null &&
|
|
844
|
+
const isUuid = uuid !== null && z24.string().uuid().safeParse(uuid).success;
|
|
779
845
|
const { data, isPending, error } = useQueryWithParse({
|
|
780
846
|
queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
|
|
781
847
|
// A missing song is shown in the panel, not raised as an app-wide connectivity error.
|
|
@@ -793,16 +859,16 @@ function useSong(uuid, getBackendBaseUrl) {
|
|
|
793
859
|
}
|
|
794
860
|
|
|
795
861
|
// src/genre-tree/schemas/song-history.ts
|
|
796
|
-
import { z as
|
|
797
|
-
var SongHistoryEntrySchema =
|
|
798
|
-
uuid:
|
|
799
|
-
action:
|
|
800
|
-
actorPseudo:
|
|
801
|
-
oldValue:
|
|
802
|
-
newValue:
|
|
803
|
-
createdOn:
|
|
862
|
+
import { z as z25 } from "zod";
|
|
863
|
+
var SongHistoryEntrySchema = z25.object({
|
|
864
|
+
uuid: z25.string().uuid(),
|
|
865
|
+
action: z25.string(),
|
|
866
|
+
actorPseudo: z25.string().nullable(),
|
|
867
|
+
oldValue: z25.string().nullable(),
|
|
868
|
+
newValue: z25.string().nullable(),
|
|
869
|
+
createdOn: z25.string()
|
|
804
870
|
});
|
|
805
|
-
var SongHistorySchema =
|
|
871
|
+
var SongHistorySchema = z25.array(SongHistoryEntrySchema);
|
|
806
872
|
|
|
807
873
|
// src/genre-tree/useSongHistory.ts
|
|
808
874
|
function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
@@ -822,20 +888,20 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
|
822
888
|
}
|
|
823
889
|
|
|
824
890
|
// src/genre-tree/schemas/song-search.ts
|
|
825
|
-
import { z as
|
|
826
|
-
var SongSearchResultSchema =
|
|
827
|
-
uuid:
|
|
828
|
-
title:
|
|
829
|
-
artists:
|
|
891
|
+
import { z as z26 } from "zod";
|
|
892
|
+
var SongSearchResultSchema = z26.object({
|
|
893
|
+
uuid: z26.string().uuid(),
|
|
894
|
+
title: z26.string(),
|
|
895
|
+
artists: z26.array(ArtistMinimumSchema),
|
|
830
896
|
// null for songs not yet linked to a genre.
|
|
831
897
|
genre: CriteriaMinimumSchema.nullable(),
|
|
832
|
-
youtubeVideo:
|
|
833
|
-
id:
|
|
834
|
-
unplayableReason:
|
|
898
|
+
youtubeVideo: z26.object({
|
|
899
|
+
id: z26.string(),
|
|
900
|
+
unplayableReason: z26.string().nullable()
|
|
835
901
|
}).nullable(),
|
|
836
|
-
firstReleaseYear:
|
|
902
|
+
firstReleaseYear: z26.number().int().nullable()
|
|
837
903
|
});
|
|
838
|
-
var SongSearchResultsSchema =
|
|
904
|
+
var SongSearchResultsSchema = z26.array(SongSearchResultSchema);
|
|
839
905
|
function isSongSearchResultPlayable(result) {
|
|
840
906
|
return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
|
|
841
907
|
}
|
|
@@ -861,16 +927,25 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
|
861
927
|
|
|
862
928
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
863
929
|
import { keepPreviousData as keepPreviousData2 } from "@tanstack/react-query";
|
|
864
|
-
import { z as
|
|
930
|
+
import { z as z28 } from "zod";
|
|
865
931
|
|
|
866
932
|
// src/genre-tree/schemas/artist-genre-count.ts
|
|
867
|
-
import { z as
|
|
868
|
-
var ArtistGenreCountSchema =
|
|
933
|
+
import { z as z27 } from "zod";
|
|
934
|
+
var ArtistGenreCountSchema = z27.object({
|
|
935
|
+
...GenreCountsSchema.shape,
|
|
936
|
+
catalogue: GenreCatalogueCountsSchema,
|
|
869
937
|
genrePlaylist: GenrePlaylistUuidSchema,
|
|
870
|
-
/**
|
|
871
|
-
songsCount:
|
|
872
|
-
/**
|
|
873
|
-
tracksCount:
|
|
938
|
+
/** Legacy catalogue count for the default selection. */
|
|
939
|
+
songsCount: z27.number().int().nonnegative(),
|
|
940
|
+
/** Legacy playlist count for the default selection. */
|
|
941
|
+
tracksCount: z27.number().int().nonnegative()
|
|
942
|
+
}).superRefine((row, ctx) => {
|
|
943
|
+
const counts = GenreCatalogueCountsSchema.safeParse(row);
|
|
944
|
+
if (!counts.success) {
|
|
945
|
+
for (const issue of counts.error.issues) {
|
|
946
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
947
|
+
}
|
|
948
|
+
}
|
|
874
949
|
});
|
|
875
950
|
|
|
876
951
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
@@ -878,10 +953,10 @@ var isNotFound3 = (error) => error instanceof AppError && error.code === "BAC404
|
|
|
878
953
|
function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
879
954
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
880
955
|
return useQueryWithParse({
|
|
881
|
-
queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
|
|
956
|
+
queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid), "genreMusicV1"],
|
|
882
957
|
// A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
|
|
883
958
|
queryFn: () => fetch(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
|
|
884
|
-
schema:
|
|
959
|
+
schema: z28.array(ArtistGenreCountSchema),
|
|
885
960
|
enabled: artistUuid !== null,
|
|
886
961
|
placeholderData: keepPreviousData2,
|
|
887
962
|
retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
|
|
@@ -985,32 +1060,32 @@ function useGenreSearch({
|
|
|
985
1060
|
}
|
|
986
1061
|
|
|
987
1062
|
// src/genre-tree/schemas/genre-search.ts
|
|
988
|
-
import { z as
|
|
989
|
-
var GenreSearchTreeNameSchema =
|
|
990
|
-
var GenreSearchResultSchema =
|
|
1063
|
+
import { z as z29 } from "zod";
|
|
1064
|
+
var GenreSearchTreeNameSchema = z29.enum(["canonical", "regional"]);
|
|
1065
|
+
var GenreSearchResultSchema = z29.object({
|
|
991
1066
|
/** Criteria (genre) uuid. */
|
|
992
1067
|
uuid: GenreUuidSchema,
|
|
993
|
-
name:
|
|
1068
|
+
name: z29.string(),
|
|
994
1069
|
/** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
|
|
995
|
-
wikidataId:
|
|
996
|
-
treeName:
|
|
1070
|
+
wikidataId: z29.string().nullable(),
|
|
1071
|
+
treeName: z29.string(),
|
|
997
1072
|
/** Null when the genre has no playlist in the tree, so it cannot be opened there. */
|
|
998
1073
|
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
999
|
-
root:
|
|
1000
|
-
isUmbrella:
|
|
1001
|
-
viewsCount:
|
|
1074
|
+
root: z29.object({ uuid: GenreUuidSchema, name: z29.string() }),
|
|
1075
|
+
isUmbrella: z29.boolean(),
|
|
1076
|
+
viewsCount: z29.number().int()
|
|
1002
1077
|
});
|
|
1003
|
-
var GenreSearchResultsSchema =
|
|
1004
|
-
var RegionGenreLexiconEntrySchema =
|
|
1005
|
-
wikidataId:
|
|
1078
|
+
var GenreSearchResultsSchema = z29.array(GenreSearchResultSchema);
|
|
1079
|
+
var RegionGenreLexiconEntrySchema = z29.object({
|
|
1080
|
+
wikidataId: z29.string(),
|
|
1006
1081
|
uuid: GenreUuidSchema,
|
|
1007
|
-
name:
|
|
1008
|
-
treeName:
|
|
1082
|
+
name: z29.string(),
|
|
1083
|
+
treeName: z29.string(),
|
|
1009
1084
|
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
1010
|
-
isUmbrella:
|
|
1011
|
-
viewsCount:
|
|
1085
|
+
isUmbrella: z29.boolean(),
|
|
1086
|
+
viewsCount: z29.number().int()
|
|
1012
1087
|
});
|
|
1013
|
-
var RegionGenreLexiconSchema =
|
|
1088
|
+
var RegionGenreLexiconSchema = z29.array(RegionGenreLexiconEntrySchema);
|
|
1014
1089
|
|
|
1015
1090
|
// src/genre-tree/useGenreRemoteSearch.ts
|
|
1016
1091
|
var DEFAULT_RESULT_LIMIT2 = 8;
|
|
@@ -1057,7 +1132,7 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
1057
1132
|
const kept = /* @__PURE__ */ new Set();
|
|
1058
1133
|
for (const playlist of playlists) {
|
|
1059
1134
|
const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
|
|
1060
|
-
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.
|
|
1135
|
+
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
|
|
1061
1136
|
}
|
|
1062
1137
|
const coreElectronicUuids = new Set(
|
|
1063
1138
|
playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
|
|
@@ -1065,12 +1140,22 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
1065
1140
|
for (const playlist of playlists) {
|
|
1066
1141
|
if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
|
|
1067
1142
|
}
|
|
1068
|
-
return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) =>
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1143
|
+
return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => {
|
|
1144
|
+
const count = countByPlaylist.get(playlist.uuid);
|
|
1145
|
+
const catalogue = GenreCatalogueCountsSchema.parse(playlist.catalogue);
|
|
1146
|
+
const scopes = playlist.genreAndSubgenresTracksCount;
|
|
1147
|
+
if (!scopes) throw new Error("Artist projections require a reference genre summary");
|
|
1148
|
+
const zero = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: "canonical" in scopes ? { canonical: 0, regional: 0, all: 0 } : { all: 0 } };
|
|
1149
|
+
return {
|
|
1150
|
+
...playlist,
|
|
1151
|
+
genreOnlyTracksCount: count?.genreOnlyTracksCount ?? 0,
|
|
1152
|
+
genreAndSubgenresTracksCount: count?.genreAndSubgenresTracksCount ?? zero.genreAndSubgenresTracksCount,
|
|
1153
|
+
catalogue: count?.catalogue ?? { ...catalogue, ...zero },
|
|
1154
|
+
tracksCount: count ? genreMusicCount(count) : 0,
|
|
1155
|
+
// Artist view totals are not served.
|
|
1156
|
+
viewsCount: void 0
|
|
1157
|
+
};
|
|
1158
|
+
});
|
|
1074
1159
|
};
|
|
1075
1160
|
|
|
1076
1161
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
@@ -1208,10 +1293,10 @@ function useGenreTreeViewState({
|
|
|
1208
1293
|
import { createContext as createContext2, useState as useState5, useContext as useContext2, useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo4, useRef as useRef3 } from "react";
|
|
1209
1294
|
|
|
1210
1295
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
1211
|
-
import { z as
|
|
1212
|
-
var makeTrackPlaylistRelSchema = (trackSchema) =>
|
|
1296
|
+
import { z as z30 } from "zod";
|
|
1297
|
+
var makeTrackPlaylistRelSchema = (trackSchema) => z30.object({
|
|
1213
1298
|
track: trackSchema,
|
|
1214
|
-
position:
|
|
1299
|
+
position: z30.number().min(0)
|
|
1215
1300
|
});
|
|
1216
1301
|
var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
|
|
1217
1302
|
|
|
@@ -1260,6 +1345,7 @@ var TrackListFromArtist = class extends TrackList {
|
|
|
1260
1345
|
var TrackListOriginType = /* @__PURE__ */ ((TrackListOriginType2) => {
|
|
1261
1346
|
TrackListOriginType2["TRACK"] = "TRACK";
|
|
1262
1347
|
TrackListOriginType2["GENRE_PLAYLIST"] = "GENRE_PLAYLIST";
|
|
1348
|
+
TrackListOriginType2["GENRE_CATALOGUE"] = "GENRE_CATALOGUE";
|
|
1263
1349
|
TrackListOriginType2["ARTIST"] = "ARTIST";
|
|
1264
1350
|
return TrackListOriginType2;
|
|
1265
1351
|
})(TrackListOriginType || {});
|
|
@@ -1291,27 +1377,48 @@ var TrackListOriginFromTrack = class extends TrackListOrigin {
|
|
|
1291
1377
|
};
|
|
1292
1378
|
var TrackListOriginFromCriteriaPlaylist = class extends TrackListOrigin {
|
|
1293
1379
|
/** `from`: the track the list starts at (server-side `?from=`), kept so later pages use it too. */
|
|
1294
|
-
constructor(criteriaPlaylist, scope, from) {
|
|
1380
|
+
constructor(criteriaPlaylist, scope, from, selection, artistUuid) {
|
|
1295
1381
|
super("GENRE_PLAYLIST" /* GENRE_PLAYLIST */, criteriaPlaylist.name, criteriaPlaylist.uuid, scope);
|
|
1296
1382
|
this.criteriaPlaylist = criteriaPlaylist;
|
|
1297
1383
|
this.from = from;
|
|
1384
|
+
this.selection = selection;
|
|
1385
|
+
this.artistUuid = artistUuid;
|
|
1298
1386
|
}
|
|
1299
1387
|
criteriaPlaylist;
|
|
1300
1388
|
from;
|
|
1389
|
+
selection;
|
|
1390
|
+
artistUuid;
|
|
1301
1391
|
};
|
|
1302
1392
|
var TrackListOriginFromArtist = class extends TrackListOrigin {
|
|
1303
1393
|
/** `ordering`/`from`: kept so later pages use the same order and start track. */
|
|
1304
|
-
constructor(artist, scope, ordering, from, genreUuid) {
|
|
1394
|
+
constructor(artist, scope, ordering, from, genreUuid, selection) {
|
|
1305
1395
|
super("ARTIST" /* ARTIST */, artist.name, artist.uuid, scope);
|
|
1306
1396
|
this.artist = artist;
|
|
1307
1397
|
this.ordering = ordering;
|
|
1308
1398
|
this.from = from;
|
|
1309
1399
|
this.genreUuid = genreUuid;
|
|
1400
|
+
this.selection = selection;
|
|
1310
1401
|
}
|
|
1311
1402
|
artist;
|
|
1312
1403
|
ordering;
|
|
1313
1404
|
from;
|
|
1314
1405
|
genreUuid;
|
|
1406
|
+
selection;
|
|
1407
|
+
};
|
|
1408
|
+
var TrackListOriginFromGenreCatalogue = class extends TrackListOrigin {
|
|
1409
|
+
constructor(genre, scope, from, selection) {
|
|
1410
|
+
super("GENRE_CATALOGUE" /* GENRE_CATALOGUE */, genre.name, genre.uuid, scope);
|
|
1411
|
+
this.genre = genre;
|
|
1412
|
+
this.from = from;
|
|
1413
|
+
this.selection = selection;
|
|
1414
|
+
}
|
|
1415
|
+
genre;
|
|
1416
|
+
from;
|
|
1417
|
+
selection;
|
|
1418
|
+
ordering = "title";
|
|
1419
|
+
get genreUuid() {
|
|
1420
|
+
return this.genre.uuid;
|
|
1421
|
+
}
|
|
1315
1422
|
};
|
|
1316
1423
|
|
|
1317
1424
|
// src/genre-tree/TrackListSidebarVisibilityContext.tsx
|
|
@@ -1420,9 +1527,10 @@ function TrackListProvider({
|
|
|
1420
1527
|
[clearDelayedTrackLoad, loadTrackForPlayer]
|
|
1421
1528
|
);
|
|
1422
1529
|
const fetchTracksPage = useCallback4(
|
|
1423
|
-
async (uuid, scope, page, from) => {
|
|
1530
|
+
async (uuid, scope, page, from, selection, artistUuid) => {
|
|
1424
1531
|
const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
|
|
1425
|
-
|
|
1532
|
+
if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
|
|
1533
|
+
const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
|
|
1426
1534
|
const response = await fetch(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
|
|
1427
1535
|
const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
|
|
1428
1536
|
return {
|
|
@@ -1433,17 +1541,18 @@ function TrackListProvider({
|
|
|
1433
1541
|
},
|
|
1434
1542
|
[fetch, pageSchema]
|
|
1435
1543
|
);
|
|
1436
|
-
const
|
|
1437
|
-
const
|
|
1544
|
+
const cataloguePageSchema = useMemo4(() => PaginatedResponseSchema(schema), [schema]);
|
|
1545
|
+
const fetchCatalogueTracksPage = useCallback4(
|
|
1438
1546
|
async (origin, page) => {
|
|
1439
1547
|
const params = {
|
|
1440
|
-
artist: origin.uuid,
|
|
1548
|
+
...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
|
|
1441
1549
|
playable: true,
|
|
1442
1550
|
ordering: origin.ordering,
|
|
1443
1551
|
page,
|
|
1444
1552
|
pageSize: TRACKS_PAGE_SIZE,
|
|
1445
1553
|
...origin.from && { from: origin.from },
|
|
1446
|
-
...origin.genreUuid && { genre: origin.genreUuid }
|
|
1554
|
+
...origin.genreUuid && { genre: origin.genreUuid },
|
|
1555
|
+
...genreMusicQueryParams(origin.selection)
|
|
1447
1556
|
};
|
|
1448
1557
|
const response = await fetch(
|
|
1449
1558
|
libraryEndpoints.reference.songs.list(),
|
|
@@ -1456,10 +1565,10 @@ function TrackListProvider({
|
|
|
1456
1565
|
page === 1 && !!origin.from,
|
|
1457
1566
|
page === 1
|
|
1458
1567
|
);
|
|
1459
|
-
const parsed = parseWithLog(
|
|
1568
|
+
const parsed = parseWithLog(cataloguePageSchema, response, "fetchCatalogueTracksPage");
|
|
1460
1569
|
return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
|
|
1461
1570
|
},
|
|
1462
|
-
[fetch,
|
|
1571
|
+
[fetch, cataloguePageSchema]
|
|
1463
1572
|
);
|
|
1464
1573
|
const advanceAfterTrackEnd = useCallback4(
|
|
1465
1574
|
(event) => {
|
|
@@ -1531,7 +1640,7 @@ function TrackListProvider({
|
|
|
1531
1640
|
const from = options?.startSongUuid;
|
|
1532
1641
|
let page;
|
|
1533
1642
|
try {
|
|
1534
|
-
page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
|
|
1643
|
+
page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from, options?.selection, options?.artistUuid);
|
|
1535
1644
|
} catch (error) {
|
|
1536
1645
|
if (request !== latestPlayRequestRef.current) return;
|
|
1537
1646
|
startingPlaybackRef.current = false;
|
|
@@ -1548,7 +1657,7 @@ function TrackListProvider({
|
|
|
1548
1657
|
console.warn("No playable tracks found in genre playlist");
|
|
1549
1658
|
return;
|
|
1550
1659
|
}
|
|
1551
|
-
const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from);
|
|
1660
|
+
const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from, options?.selection, options?.artistUuid);
|
|
1552
1661
|
setAutoAdvanceScrollRequest(null);
|
|
1553
1662
|
setTrackList(new TrackListFromCriteriaPlaylist(page.tracks, origin, page.total, page.nextPage));
|
|
1554
1663
|
setSelectedTrack(startTrack);
|
|
@@ -1557,17 +1666,15 @@ function TrackListProvider({
|
|
|
1557
1666
|
},
|
|
1558
1667
|
[clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
1559
1668
|
);
|
|
1560
|
-
const
|
|
1561
|
-
async (
|
|
1562
|
-
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
1669
|
+
const playCatalogue = useCallback4(
|
|
1670
|
+
async (origin) => {
|
|
1563
1671
|
clearDelayedTrackLoad();
|
|
1564
1672
|
const request = ++latestPlayRequestRef.current;
|
|
1565
1673
|
startingPlaybackRef.current = true;
|
|
1566
|
-
const from =
|
|
1567
|
-
const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
|
|
1674
|
+
const from = origin.from;
|
|
1568
1675
|
let page;
|
|
1569
1676
|
try {
|
|
1570
|
-
page = await
|
|
1677
|
+
page = await fetchCatalogueTracksPage(origin, 1);
|
|
1571
1678
|
} catch (error) {
|
|
1572
1679
|
if (request !== latestPlayRequestRef.current) return;
|
|
1573
1680
|
startingPlaybackRef.current = false;
|
|
@@ -1578,19 +1685,34 @@ function TrackListProvider({
|
|
|
1578
1685
|
loadedContextRef.current = playback.snapshot().key;
|
|
1579
1686
|
const startTrack = page.tracks[0];
|
|
1580
1687
|
if (from && startTrack?.uuid !== from) {
|
|
1581
|
-
throw new Error(
|
|
1688
|
+
throw new Error(`${origin instanceof TrackListOriginFromArtist ? "Artist" : "Catalogue"} ${origin.uuid} did not start at song ${from}`);
|
|
1582
1689
|
}
|
|
1583
1690
|
if (!startTrack) {
|
|
1584
|
-
console.warn("No playable songs found
|
|
1691
|
+
console.warn("No playable songs found in catalogue");
|
|
1585
1692
|
return;
|
|
1586
1693
|
}
|
|
1587
|
-
setTrackList(new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage));
|
|
1694
|
+
setTrackList(origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage) : new TrackList(page.tracks, origin, page.total, page.nextPage));
|
|
1588
1695
|
setAutoAdvanceScrollRequest(null);
|
|
1589
1696
|
setSelectedTrack(startTrack);
|
|
1590
1697
|
showTrackListSidebar();
|
|
1591
1698
|
loadTrackForPlayer(startTrack.uuid);
|
|
1592
1699
|
},
|
|
1593
|
-
[clearDelayedTrackLoad,
|
|
1700
|
+
[clearDelayedTrackLoad, fetchCatalogueTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
1701
|
+
);
|
|
1702
|
+
const playNewTrackListFromArtist = useCallback4(
|
|
1703
|
+
async (artist, scope, options) => {
|
|
1704
|
+
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
1705
|
+
if (options.selection && !options.genreUuid) throw new Error("A genre selection requires a genre");
|
|
1706
|
+
return playCatalogue(new TrackListOriginFromArtist(artist, scope, options.ordering, options.startSongUuid, options.genreUuid, options.selection));
|
|
1707
|
+
},
|
|
1708
|
+
[playCatalogue]
|
|
1709
|
+
);
|
|
1710
|
+
const playNewTrackListFromGenreCatalogue = useCallback4(
|
|
1711
|
+
async (genre, scope, options) => {
|
|
1712
|
+
if (scope !== "reference") throw new Error("Genre catalogues only support the reference scope");
|
|
1713
|
+
return playCatalogue(new TrackListOriginFromGenreCatalogue(genre, scope, options?.startSongUuid, options?.selection));
|
|
1714
|
+
},
|
|
1715
|
+
[playCatalogue]
|
|
1594
1716
|
);
|
|
1595
1717
|
const contextKeyRef = useRef3(playback.key);
|
|
1596
1718
|
useEffect3(() => {
|
|
@@ -1612,20 +1734,28 @@ function TrackListProvider({
|
|
|
1612
1734
|
setTrackList(null);
|
|
1613
1735
|
setSelectedTrack(null);
|
|
1614
1736
|
if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
|
|
1615
|
-
void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid }).catch((error) => {
|
|
1737
|
+
void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid, selection: origin.selection, artistUuid: origin.artistUuid }).catch((error) => {
|
|
1616
1738
|
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
1617
|
-
return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
|
|
1739
|
+
return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { selection: origin.selection, artistUuid: origin.artistUuid }).catch(() => {
|
|
1618
1740
|
});
|
|
1619
1741
|
}
|
|
1620
1742
|
});
|
|
1621
1743
|
} else if (origin instanceof TrackListOriginFromArtist) {
|
|
1622
|
-
const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
|
|
1744
|
+
const options = { ordering: origin.ordering, genreUuid: origin.genreUuid, selection: origin.selection };
|
|
1623
1745
|
void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
|
|
1624
1746
|
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
1625
1747
|
return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
|
|
1626
1748
|
});
|
|
1627
1749
|
}
|
|
1628
1750
|
});
|
|
1751
|
+
} else if (origin instanceof TrackListOriginFromGenreCatalogue) {
|
|
1752
|
+
const options = { selection: origin.selection };
|
|
1753
|
+
void playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
|
|
1754
|
+
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
1755
|
+
return playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, options).catch(() => {
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1629
1759
|
} else if (origin instanceof TrackListOriginFromTrack && selected) {
|
|
1630
1760
|
const request = latestPlayRequestRef.current;
|
|
1631
1761
|
void (async () => {
|
|
@@ -1636,7 +1766,7 @@ function TrackListProvider({
|
|
|
1636
1766
|
})().catch(() => {
|
|
1637
1767
|
});
|
|
1638
1768
|
}
|
|
1639
|
-
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch]);
|
|
1769
|
+
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch]);
|
|
1640
1770
|
const updateTrack = useCallback4((track) => {
|
|
1641
1771
|
setTrackList((prev) => {
|
|
1642
1772
|
if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
|
|
@@ -1648,22 +1778,22 @@ function TrackListProvider({
|
|
|
1648
1778
|
const loadMore = useCallback4(async () => {
|
|
1649
1779
|
if (!trackList || trackList.nextPage === null) return;
|
|
1650
1780
|
const origin = trackList.origin;
|
|
1651
|
-
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist)) return;
|
|
1781
|
+
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
|
|
1652
1782
|
if (loadingOriginRef.current === origin) return;
|
|
1653
1783
|
const requestedPage = trackList.nextPage;
|
|
1654
1784
|
loadingOriginRef.current = origin;
|
|
1655
1785
|
try {
|
|
1656
|
-
const page = origin instanceof TrackListOriginFromArtist ? await
|
|
1786
|
+
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);
|
|
1657
1787
|
setTrackList((prev) => {
|
|
1658
1788
|
if (prev?.origin !== origin || prev.nextPage !== requestedPage) return prev;
|
|
1659
1789
|
const loaded = new Set(prev.tracks.map((track) => track.uuid));
|
|
1660
1790
|
const tracks = [...prev.tracks, ...page.tracks.filter((track) => !loaded.has(track.uuid))];
|
|
1661
|
-
return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
|
|
1791
|
+
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);
|
|
1662
1792
|
});
|
|
1663
1793
|
} finally {
|
|
1664
1794
|
if (loadingOriginRef.current === origin) loadingOriginRef.current = null;
|
|
1665
1795
|
}
|
|
1666
|
-
}, [trackList, fetchTracksPage,
|
|
1796
|
+
}, [trackList, fetchTracksPage, fetchCatalogueTracksPage]);
|
|
1667
1797
|
const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
|
|
1668
1798
|
const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
1669
1799
|
const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
@@ -1751,6 +1881,7 @@ function TrackListProvider({
|
|
|
1751
1881
|
playNewTrackListFromTrackUuid,
|
|
1752
1882
|
playNewTrackListFromGenrePlaylist,
|
|
1753
1883
|
playNewTrackListFromArtist,
|
|
1884
|
+
playNewTrackListFromGenreCatalogue,
|
|
1754
1885
|
fetchGenrePlaylistTracksPage: fetchTracksPage,
|
|
1755
1886
|
loadMore,
|
|
1756
1887
|
updateTrack
|
|
@@ -1768,6 +1899,7 @@ function TrackListProvider({
|
|
|
1768
1899
|
playNewTrackListFromTrackUuid,
|
|
1769
1900
|
playNewTrackListFromGenrePlaylist,
|
|
1770
1901
|
playNewTrackListFromArtist,
|
|
1902
|
+
playNewTrackListFromGenreCatalogue,
|
|
1771
1903
|
fetchTracksPage,
|
|
1772
1904
|
loadMore,
|
|
1773
1905
|
updateTrack
|
|
@@ -1798,24 +1930,24 @@ function ArtistNames({
|
|
|
1798
1930
|
}
|
|
1799
1931
|
|
|
1800
1932
|
// src/genre-tree/schemas/mb-artist.ts
|
|
1801
|
-
import { z as
|
|
1802
|
-
var MbArtistDetailedSchema =
|
|
1803
|
-
musicbrainzId:
|
|
1804
|
-
name:
|
|
1933
|
+
import { z as z31 } from "zod";
|
|
1934
|
+
var MbArtistDetailedSchema = z31.object({
|
|
1935
|
+
musicbrainzId: z31.string().uuid(),
|
|
1936
|
+
name: z31.string(),
|
|
1805
1937
|
musicbrainzLink: HttpUrlSchema
|
|
1806
1938
|
});
|
|
1807
1939
|
|
|
1808
1940
|
// src/genre-tree/schemas/mb-recording.ts
|
|
1809
|
-
import { z as
|
|
1810
|
-
var MbRecordingDetailedSchema =
|
|
1811
|
-
musicbrainzId:
|
|
1812
|
-
title:
|
|
1813
|
-
score:
|
|
1814
|
-
musicbrainzArtists:
|
|
1941
|
+
import { z as z32 } from "zod";
|
|
1942
|
+
var MbRecordingDetailedSchema = z32.object({
|
|
1943
|
+
musicbrainzId: z32.string().uuid(),
|
|
1944
|
+
title: z32.string(),
|
|
1945
|
+
score: z32.number(),
|
|
1946
|
+
musicbrainzArtists: z32.array(MbArtistDetailedSchema),
|
|
1815
1947
|
musicbrainzLink: HttpUrlSchema,
|
|
1816
|
-
durationInSec:
|
|
1817
|
-
durationStrInHourMinSec:
|
|
1818
|
-
releaseDate:
|
|
1948
|
+
durationInSec: z32.number().min(0).nullable().optional(),
|
|
1949
|
+
durationStrInHourMinSec: z32.string().nullable().optional(),
|
|
1950
|
+
releaseDate: z32.union([z32.string().datetime(), z32.string()]).transform((val) => {
|
|
1819
1951
|
try {
|
|
1820
1952
|
const date = new Date(val);
|
|
1821
1953
|
if (isNaN(date.getTime())) {
|
|
@@ -1881,26 +2013,39 @@ function editGenreSongPages(data, edit) {
|
|
|
1881
2013
|
}
|
|
1882
2014
|
|
|
1883
2015
|
export {
|
|
1884
|
-
CriteriaMinimumSchema,
|
|
1885
2016
|
CriteriaPlaylistMinimumSchema,
|
|
2017
|
+
SubgenreCountsSchema,
|
|
2018
|
+
GenreCountsSchema,
|
|
2019
|
+
GenreCatalogueCountsSchema,
|
|
2020
|
+
GenrePlaylistSummarySchema,
|
|
2021
|
+
GenreCoverageSchema,
|
|
2022
|
+
SubgenreScopeSchema,
|
|
2023
|
+
CriteriaMinimumSchema,
|
|
2024
|
+
ArtistMinimumSchema,
|
|
2025
|
+
AlbumMinimumSchema,
|
|
2026
|
+
UuidResourceSchema,
|
|
2027
|
+
TrackBaseSchema,
|
|
2028
|
+
TrackMinimumSchema,
|
|
2029
|
+
CriteriaLineageRelWithoutAscendantSchema,
|
|
2030
|
+
CriteriaLineageRelWithoutDescendantSchema,
|
|
2031
|
+
CriteriaDetailedSchema,
|
|
1886
2032
|
CriteriaPlaylistDetailedSchema,
|
|
1887
2033
|
CriteriaPlaylistSimpleSchema,
|
|
2034
|
+
ReferenceGenreDetailedSchema,
|
|
2035
|
+
ReferenceGenrePlaylistSchema,
|
|
1888
2036
|
genrePlaylistQueryKeys,
|
|
1889
2037
|
genrePlaylistEndpoints,
|
|
2038
|
+
defaultGenreMusicSelection,
|
|
2039
|
+
genreMusicCount,
|
|
2040
|
+
genreMusicQueryParams,
|
|
2041
|
+
genreMusicSelectionKey,
|
|
2042
|
+
genrePlaylistTrackCount,
|
|
1890
2043
|
libraryQueryKeys,
|
|
1891
2044
|
libraryEndpoints,
|
|
1892
2045
|
useListGenrePlaylists,
|
|
1893
2046
|
useListFullGenrePlaylists,
|
|
1894
2047
|
useFetchGenrePlaylist,
|
|
1895
2048
|
useInvalidateAllGenrePlaylistQueries,
|
|
1896
|
-
ArtistMinimumSchema,
|
|
1897
|
-
AlbumMinimumSchema,
|
|
1898
|
-
UuidResourceSchema,
|
|
1899
|
-
TrackBaseSchema,
|
|
1900
|
-
TrackMinimumSchema,
|
|
1901
|
-
CriteriaLineageRelWithoutAscendantSchema,
|
|
1902
|
-
CriteriaLineageRelWithoutDescendantSchema,
|
|
1903
|
-
CriteriaDetailedSchema,
|
|
1904
2049
|
CriteriaOverviewSchema,
|
|
1905
2050
|
CriteriaSimpleSchema,
|
|
1906
2051
|
CriteriaCreationSchema,
|
|
@@ -1977,6 +2122,7 @@ export {
|
|
|
1977
2122
|
TrackListOriginFromTrack,
|
|
1978
2123
|
TrackListOriginFromCriteriaPlaylist,
|
|
1979
2124
|
TrackListOriginFromArtist,
|
|
2125
|
+
TrackListOriginFromGenreCatalogue,
|
|
1980
2126
|
TrackListSidebarVisibilityProvider,
|
|
1981
2127
|
useTrackListSidebarVisibility,
|
|
1982
2128
|
useListTracks,
|
|
@@ -1991,4 +2137,4 @@ export {
|
|
|
1991
2137
|
getReparentCandidates,
|
|
1992
2138
|
editGenreSongPages
|
|
1993
2139
|
};
|
|
1994
|
-
//# sourceMappingURL=chunk-
|
|
2140
|
+
//# sourceMappingURL=chunk-3PITD62C.js.map
|