@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
|
@@ -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
|
|
115
|
+
});
|
|
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()
|
|
55
149
|
});
|
|
56
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,17 +180,41 @@ 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
|
|
92
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 });
|
|
209
|
+
});
|
|
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";
|
|
93
218
|
|
|
94
219
|
// src/genre-tree/api/genre-playlists/queryKeys.ts
|
|
95
220
|
var genrePlaylistQueryKeys = {
|
|
@@ -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,26 +726,26 @@ 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";
|
|
679
|
-
import { useEffect, useState } from "react";
|
|
745
|
+
import { useEffect, useRef, useState } from "react";
|
|
680
746
|
var SEARCH_DEBOUNCE_MS = 250;
|
|
681
747
|
var SEARCH_QUERY_MIN_LENGTH = 2;
|
|
682
|
-
function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema, context, text, enabled: extraEnabled = true,
|
|
748
|
+
function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema, context, text, enabled: extraEnabled = true, scope = "" }) {
|
|
683
749
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
684
750
|
const trimmed = text.trim();
|
|
685
751
|
const [query, setQuery] = useState("");
|
|
@@ -687,15 +753,19 @@ function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema
|
|
|
687
753
|
const timer = setTimeout(() => setQuery(trimmed), SEARCH_DEBOUNCE_MS);
|
|
688
754
|
return () => clearTimeout(timer);
|
|
689
755
|
}, [trimmed]);
|
|
756
|
+
const dataScope = useRef(null);
|
|
690
757
|
const enabled = query.length >= SEARCH_QUERY_MIN_LENGTH && extraEnabled;
|
|
691
|
-
const { data, isFetching, isError } = useQueryWithParse({
|
|
758
|
+
const { data, isFetching, isError, isPlaceholderData } = useQueryWithParse({
|
|
692
759
|
queryKey: queryKey(query),
|
|
693
760
|
queryFn: ({ signal }) => fetch(endpoint, true, false, { signal }, params(query)),
|
|
694
761
|
schema,
|
|
695
762
|
context,
|
|
696
763
|
enabled,
|
|
697
|
-
placeholderData:
|
|
764
|
+
placeholderData: (previous) => dataScope.current === scope ? keepPreviousData(previous) : void 0
|
|
698
765
|
});
|
|
766
|
+
useEffect(() => {
|
|
767
|
+
if (data !== void 0 && !isPlaceholderData) dataScope.current = scope;
|
|
768
|
+
}, [data, isPlaceholderData, scope]);
|
|
699
769
|
const settled = enabled && !isFetching && query === trimmed;
|
|
700
770
|
const failed = enabled && isError;
|
|
701
771
|
const long = trimmed.length >= SEARCH_QUERY_MIN_LENGTH;
|
|
@@ -722,10 +792,10 @@ function useArtistSearch(getBackendBaseUrl, text) {
|
|
|
722
792
|
}
|
|
723
793
|
|
|
724
794
|
// src/genre-tree/useSong.ts
|
|
725
|
-
import { z as
|
|
795
|
+
import { z as z24 } from "zod";
|
|
726
796
|
|
|
727
797
|
// src/genre-tree/schemas/song/detailed.ts
|
|
728
|
-
import { z as
|
|
798
|
+
import { z as z23 } from "zod";
|
|
729
799
|
var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
730
800
|
not_found: "Video unavailable",
|
|
731
801
|
not_embeddable: "Embedding disabled",
|
|
@@ -734,23 +804,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
|
734
804
|
region_whitelisted: "Region restricted"
|
|
735
805
|
};
|
|
736
806
|
var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
|
|
737
|
-
var YoutubeAvailabilitySchema =
|
|
738
|
-
status:
|
|
739
|
-
reason:
|
|
740
|
-
country:
|
|
807
|
+
var YoutubeAvailabilitySchema = z23.object({
|
|
808
|
+
status: z23.enum(["eligible", "blocked", "unknown"]),
|
|
809
|
+
reason: z23.string().nullable(),
|
|
810
|
+
country: z23.string().nullable()
|
|
741
811
|
});
|
|
742
812
|
var SongDetailedSchema = TrackBaseSchema.extend({
|
|
743
|
-
youtubeVideo:
|
|
744
|
-
id:
|
|
813
|
+
youtubeVideo: z23.object({
|
|
814
|
+
id: z23.string(),
|
|
745
815
|
availability: YoutubeAvailabilitySchema.optional(),
|
|
746
816
|
// null = playable
|
|
747
|
-
unplayableReason:
|
|
748
|
-
viewCount:
|
|
817
|
+
unplayableReason: z23.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
|
|
818
|
+
viewCount: z23.number().int().nullable().optional()
|
|
749
819
|
}).nullable(),
|
|
750
820
|
// null for hand-made/admin songs
|
|
751
|
-
musicbrainzRecordingId:
|
|
752
|
-
firstReleaseYear:
|
|
753
|
-
essentialGenres:
|
|
821
|
+
musicbrainzRecordingId: z23.string().uuid().nullable(),
|
|
822
|
+
firstReleaseYear: z23.number().int().nullable().optional(),
|
|
823
|
+
essentialGenres: z23.array(CriteriaMinimumSchema).optional()
|
|
754
824
|
});
|
|
755
825
|
var NO_VIDEO_LABEL = "No video available";
|
|
756
826
|
function isSong(track) {
|
|
@@ -771,7 +841,7 @@ var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC404
|
|
|
771
841
|
function useSong(uuid, getBackendBaseUrl) {
|
|
772
842
|
const playback = usePlaybackContext();
|
|
773
843
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
774
|
-
const isUuid = uuid !== null &&
|
|
844
|
+
const isUuid = uuid !== null && z24.string().uuid().safeParse(uuid).success;
|
|
775
845
|
const { data, isPending, error } = useQueryWithParse({
|
|
776
846
|
queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
|
|
777
847
|
// A missing song is shown in the panel, not raised as an app-wide connectivity error.
|
|
@@ -789,16 +859,16 @@ function useSong(uuid, getBackendBaseUrl) {
|
|
|
789
859
|
}
|
|
790
860
|
|
|
791
861
|
// src/genre-tree/schemas/song-history.ts
|
|
792
|
-
import { z as
|
|
793
|
-
var SongHistoryEntrySchema =
|
|
794
|
-
uuid:
|
|
795
|
-
action:
|
|
796
|
-
actorPseudo:
|
|
797
|
-
oldValue:
|
|
798
|
-
newValue:
|
|
799
|
-
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()
|
|
800
870
|
});
|
|
801
|
-
var SongHistorySchema =
|
|
871
|
+
var SongHistorySchema = z25.array(SongHistoryEntrySchema);
|
|
802
872
|
|
|
803
873
|
// src/genre-tree/useSongHistory.ts
|
|
804
874
|
function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
@@ -818,20 +888,20 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
|
818
888
|
}
|
|
819
889
|
|
|
820
890
|
// src/genre-tree/schemas/song-search.ts
|
|
821
|
-
import { z as
|
|
822
|
-
var SongSearchResultSchema =
|
|
823
|
-
uuid:
|
|
824
|
-
title:
|
|
825
|
-
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),
|
|
826
896
|
// null for songs not yet linked to a genre.
|
|
827
897
|
genre: CriteriaMinimumSchema.nullable(),
|
|
828
|
-
youtubeVideo:
|
|
829
|
-
id:
|
|
830
|
-
unplayableReason:
|
|
898
|
+
youtubeVideo: z26.object({
|
|
899
|
+
id: z26.string(),
|
|
900
|
+
unplayableReason: z26.string().nullable()
|
|
831
901
|
}).nullable(),
|
|
832
|
-
firstReleaseYear:
|
|
902
|
+
firstReleaseYear: z26.number().int().nullable()
|
|
833
903
|
});
|
|
834
|
-
var SongSearchResultsSchema =
|
|
904
|
+
var SongSearchResultsSchema = z26.array(SongSearchResultSchema);
|
|
835
905
|
function isSongSearchResultPlayable(result) {
|
|
836
906
|
return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
|
|
837
907
|
}
|
|
@@ -850,23 +920,32 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
|
850
920
|
context: "useSongSearch",
|
|
851
921
|
text,
|
|
852
922
|
enabled: playback.ready,
|
|
853
|
-
|
|
923
|
+
scope: playback.key ?? ""
|
|
854
924
|
});
|
|
855
925
|
return { songs: results, isError, settled, pending };
|
|
856
926
|
}
|
|
857
927
|
|
|
858
928
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
859
929
|
import { keepPreviousData as keepPreviousData2 } from "@tanstack/react-query";
|
|
860
|
-
import { z as
|
|
930
|
+
import { z as z28 } from "zod";
|
|
861
931
|
|
|
862
932
|
// src/genre-tree/schemas/artist-genre-count.ts
|
|
863
|
-
import { z as
|
|
864
|
-
var ArtistGenreCountSchema =
|
|
933
|
+
import { z as z27 } from "zod";
|
|
934
|
+
var ArtistGenreCountSchema = z27.object({
|
|
935
|
+
...GenreCountsSchema.shape,
|
|
936
|
+
catalogue: GenreCatalogueCountsSchema,
|
|
865
937
|
genrePlaylist: GenrePlaylistUuidSchema,
|
|
866
|
-
/**
|
|
867
|
-
songsCount:
|
|
868
|
-
/**
|
|
869
|
-
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
|
+
}
|
|
870
949
|
});
|
|
871
950
|
|
|
872
951
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
@@ -874,10 +953,10 @@ var isNotFound3 = (error) => error instanceof AppError && error.code === "BAC404
|
|
|
874
953
|
function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
875
954
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
876
955
|
return useQueryWithParse({
|
|
877
|
-
queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
|
|
956
|
+
queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid), "genreMusicV1"],
|
|
878
957
|
// A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
|
|
879
958
|
queryFn: () => fetch(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
|
|
880
|
-
schema:
|
|
959
|
+
schema: z28.array(ArtistGenreCountSchema),
|
|
881
960
|
enabled: artistUuid !== null,
|
|
882
961
|
placeholderData: keepPreviousData2,
|
|
883
962
|
retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
|
|
@@ -981,30 +1060,32 @@ function useGenreSearch({
|
|
|
981
1060
|
}
|
|
982
1061
|
|
|
983
1062
|
// src/genre-tree/schemas/genre-search.ts
|
|
984
|
-
import { z as
|
|
985
|
-
var GenreSearchTreeNameSchema =
|
|
986
|
-
var GenreSearchResultSchema =
|
|
1063
|
+
import { z as z29 } from "zod";
|
|
1064
|
+
var GenreSearchTreeNameSchema = z29.enum(["canonical", "regional"]);
|
|
1065
|
+
var GenreSearchResultSchema = z29.object({
|
|
987
1066
|
/** Criteria (genre) uuid. */
|
|
988
1067
|
uuid: GenreUuidSchema,
|
|
989
|
-
name:
|
|
990
|
-
|
|
1068
|
+
name: z29.string(),
|
|
1069
|
+
/** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
|
|
1070
|
+
wikidataId: z29.string().nullable(),
|
|
1071
|
+
treeName: z29.string(),
|
|
991
1072
|
/** Null when the genre has no playlist in the tree, so it cannot be opened there. */
|
|
992
1073
|
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
993
|
-
root:
|
|
994
|
-
isUmbrella:
|
|
995
|
-
viewsCount:
|
|
1074
|
+
root: z29.object({ uuid: GenreUuidSchema, name: z29.string() }),
|
|
1075
|
+
isUmbrella: z29.boolean(),
|
|
1076
|
+
viewsCount: z29.number().int()
|
|
996
1077
|
});
|
|
997
|
-
var GenreSearchResultsSchema =
|
|
998
|
-
var RegionGenreLexiconEntrySchema =
|
|
999
|
-
wikidataId:
|
|
1078
|
+
var GenreSearchResultsSchema = z29.array(GenreSearchResultSchema);
|
|
1079
|
+
var RegionGenreLexiconEntrySchema = z29.object({
|
|
1080
|
+
wikidataId: z29.string(),
|
|
1000
1081
|
uuid: GenreUuidSchema,
|
|
1001
|
-
name:
|
|
1002
|
-
treeName:
|
|
1082
|
+
name: z29.string(),
|
|
1083
|
+
treeName: z29.string(),
|
|
1003
1084
|
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
1004
|
-
isUmbrella:
|
|
1005
|
-
viewsCount:
|
|
1085
|
+
isUmbrella: z29.boolean(),
|
|
1086
|
+
viewsCount: z29.number().int()
|
|
1006
1087
|
});
|
|
1007
|
-
var RegionGenreLexiconSchema =
|
|
1088
|
+
var RegionGenreLexiconSchema = z29.array(RegionGenreLexiconEntrySchema);
|
|
1008
1089
|
|
|
1009
1090
|
// src/genre-tree/useGenreRemoteSearch.ts
|
|
1010
1091
|
var DEFAULT_RESULT_LIMIT2 = 8;
|
|
@@ -1038,7 +1119,7 @@ function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
|
1038
1119
|
}
|
|
1039
1120
|
|
|
1040
1121
|
// src/genre-tree/useGenreTreeViewState.ts
|
|
1041
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState3 } from "react";
|
|
1122
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
1042
1123
|
|
|
1043
1124
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
1044
1125
|
import { useMemo } from "react";
|
|
@@ -1051,7 +1132,7 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
1051
1132
|
const kept = /* @__PURE__ */ new Set();
|
|
1052
1133
|
for (const playlist of playlists) {
|
|
1053
1134
|
const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
|
|
1054
|
-
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.
|
|
1135
|
+
if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
|
|
1055
1136
|
}
|
|
1056
1137
|
const coreElectronicUuids = new Set(
|
|
1057
1138
|
playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
|
|
@@ -1059,12 +1140,22 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
1059
1140
|
for (const playlist of playlists) {
|
|
1060
1141
|
if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
|
|
1061
1142
|
}
|
|
1062
|
-
return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) =>
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
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
|
+
});
|
|
1068
1159
|
};
|
|
1069
1160
|
|
|
1070
1161
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
@@ -1135,7 +1226,7 @@ function useGenreTreeViewState({
|
|
|
1135
1226
|
[setSelectedNodeId]
|
|
1136
1227
|
);
|
|
1137
1228
|
const prefetchGenreOverview = usePrefetchGenreOverview(scope, getBackendBaseUrl, criteriaOverviewSchema);
|
|
1138
|
-
const hoverPrefetchTimerRef =
|
|
1229
|
+
const hoverPrefetchTimerRef = useRef2(null);
|
|
1139
1230
|
useEffect2(
|
|
1140
1231
|
() => () => {
|
|
1141
1232
|
if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
|
|
@@ -1199,13 +1290,13 @@ function useGenreTreeViewState({
|
|
|
1199
1290
|
}
|
|
1200
1291
|
|
|
1201
1292
|
// src/genre-tree/TrackListContext.tsx
|
|
1202
|
-
import { createContext as createContext2, useState as useState5, useContext as useContext2, useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo4, useRef as
|
|
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";
|
|
1203
1294
|
|
|
1204
1295
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
1205
|
-
import { z as
|
|
1206
|
-
var makeTrackPlaylistRelSchema = (trackSchema) =>
|
|
1296
|
+
import { z as z30 } from "zod";
|
|
1297
|
+
var makeTrackPlaylistRelSchema = (trackSchema) => z30.object({
|
|
1207
1298
|
track: trackSchema,
|
|
1208
|
-
position:
|
|
1299
|
+
position: z30.number().min(0)
|
|
1209
1300
|
});
|
|
1210
1301
|
var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
|
|
1211
1302
|
|
|
@@ -1254,6 +1345,7 @@ var TrackListFromArtist = class extends TrackList {
|
|
|
1254
1345
|
var TrackListOriginType = /* @__PURE__ */ ((TrackListOriginType2) => {
|
|
1255
1346
|
TrackListOriginType2["TRACK"] = "TRACK";
|
|
1256
1347
|
TrackListOriginType2["GENRE_PLAYLIST"] = "GENRE_PLAYLIST";
|
|
1348
|
+
TrackListOriginType2["GENRE_CATALOGUE"] = "GENRE_CATALOGUE";
|
|
1257
1349
|
TrackListOriginType2["ARTIST"] = "ARTIST";
|
|
1258
1350
|
return TrackListOriginType2;
|
|
1259
1351
|
})(TrackListOriginType || {});
|
|
@@ -1285,27 +1377,48 @@ var TrackListOriginFromTrack = class extends TrackListOrigin {
|
|
|
1285
1377
|
};
|
|
1286
1378
|
var TrackListOriginFromCriteriaPlaylist = class extends TrackListOrigin {
|
|
1287
1379
|
/** `from`: the track the list starts at (server-side `?from=`), kept so later pages use it too. */
|
|
1288
|
-
constructor(criteriaPlaylist, scope, from) {
|
|
1380
|
+
constructor(criteriaPlaylist, scope, from, selection, artistUuid) {
|
|
1289
1381
|
super("GENRE_PLAYLIST" /* GENRE_PLAYLIST */, criteriaPlaylist.name, criteriaPlaylist.uuid, scope);
|
|
1290
1382
|
this.criteriaPlaylist = criteriaPlaylist;
|
|
1291
1383
|
this.from = from;
|
|
1384
|
+
this.selection = selection;
|
|
1385
|
+
this.artistUuid = artistUuid;
|
|
1292
1386
|
}
|
|
1293
1387
|
criteriaPlaylist;
|
|
1294
1388
|
from;
|
|
1389
|
+
selection;
|
|
1390
|
+
artistUuid;
|
|
1295
1391
|
};
|
|
1296
1392
|
var TrackListOriginFromArtist = class extends TrackListOrigin {
|
|
1297
1393
|
/** `ordering`/`from`: kept so later pages use the same order and start track. */
|
|
1298
|
-
constructor(artist, scope, ordering, from, genreUuid) {
|
|
1394
|
+
constructor(artist, scope, ordering, from, genreUuid, selection) {
|
|
1299
1395
|
super("ARTIST" /* ARTIST */, artist.name, artist.uuid, scope);
|
|
1300
1396
|
this.artist = artist;
|
|
1301
1397
|
this.ordering = ordering;
|
|
1302
1398
|
this.from = from;
|
|
1303
1399
|
this.genreUuid = genreUuid;
|
|
1400
|
+
this.selection = selection;
|
|
1304
1401
|
}
|
|
1305
1402
|
artist;
|
|
1306
1403
|
ordering;
|
|
1307
1404
|
from;
|
|
1308
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
|
+
}
|
|
1309
1422
|
};
|
|
1310
1423
|
|
|
1311
1424
|
// src/genre-tree/TrackListSidebarVisibilityContext.tsx
|
|
@@ -1387,13 +1500,13 @@ function TrackListProvider({
|
|
|
1387
1500
|
const playback = usePlaybackContext();
|
|
1388
1501
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
1389
1502
|
const pageSchema = useMemo4(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
|
|
1390
|
-
const latestPlayRequestRef =
|
|
1391
|
-
const startingPlaybackRef =
|
|
1392
|
-
const loadedContextRef =
|
|
1393
|
-
const autoAdvanceScrollRequestIdRef =
|
|
1394
|
-
const delayedTrackLoadRef =
|
|
1395
|
-
const loadingOriginRef =
|
|
1396
|
-
const pendingAdvanceRef =
|
|
1503
|
+
const latestPlayRequestRef = useRef3(0);
|
|
1504
|
+
const startingPlaybackRef = useRef3(false);
|
|
1505
|
+
const loadedContextRef = useRef3(playback.key);
|
|
1506
|
+
const autoAdvanceScrollRequestIdRef = useRef3(0);
|
|
1507
|
+
const delayedTrackLoadRef = useRef3(null);
|
|
1508
|
+
const loadingOriginRef = useRef3(null);
|
|
1509
|
+
const pendingAdvanceRef = useRef3(null);
|
|
1397
1510
|
const clearDelayedTrackLoad = useCallback4(() => {
|
|
1398
1511
|
if (delayedTrackLoadRef.current !== null) {
|
|
1399
1512
|
clearTimeout(delayedTrackLoadRef.current);
|
|
@@ -1414,9 +1527,10 @@ function TrackListProvider({
|
|
|
1414
1527
|
[clearDelayedTrackLoad, loadTrackForPlayer]
|
|
1415
1528
|
);
|
|
1416
1529
|
const fetchTracksPage = useCallback4(
|
|
1417
|
-
async (uuid, scope, page, from) => {
|
|
1530
|
+
async (uuid, scope, page, from, selection, artistUuid) => {
|
|
1418
1531
|
const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
|
|
1419
|
-
|
|
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 } };
|
|
1420
1534
|
const response = await fetch(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
|
|
1421
1535
|
const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
|
|
1422
1536
|
return {
|
|
@@ -1427,17 +1541,18 @@ function TrackListProvider({
|
|
|
1427
1541
|
},
|
|
1428
1542
|
[fetch, pageSchema]
|
|
1429
1543
|
);
|
|
1430
|
-
const
|
|
1431
|
-
const
|
|
1544
|
+
const cataloguePageSchema = useMemo4(() => PaginatedResponseSchema(schema), [schema]);
|
|
1545
|
+
const fetchCatalogueTracksPage = useCallback4(
|
|
1432
1546
|
async (origin, page) => {
|
|
1433
1547
|
const params = {
|
|
1434
|
-
artist: origin.uuid,
|
|
1548
|
+
...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
|
|
1435
1549
|
playable: true,
|
|
1436
1550
|
ordering: origin.ordering,
|
|
1437
1551
|
page,
|
|
1438
1552
|
pageSize: TRACKS_PAGE_SIZE,
|
|
1439
1553
|
...origin.from && { from: origin.from },
|
|
1440
|
-
...origin.genreUuid && { genre: origin.genreUuid }
|
|
1554
|
+
...origin.genreUuid && { genre: origin.genreUuid },
|
|
1555
|
+
...genreMusicQueryParams(origin.selection)
|
|
1441
1556
|
};
|
|
1442
1557
|
const response = await fetch(
|
|
1443
1558
|
libraryEndpoints.reference.songs.list(),
|
|
@@ -1450,10 +1565,10 @@ function TrackListProvider({
|
|
|
1450
1565
|
page === 1 && !!origin.from,
|
|
1451
1566
|
page === 1
|
|
1452
1567
|
);
|
|
1453
|
-
const parsed = parseWithLog(
|
|
1568
|
+
const parsed = parseWithLog(cataloguePageSchema, response, "fetchCatalogueTracksPage");
|
|
1454
1569
|
return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
|
|
1455
1570
|
},
|
|
1456
|
-
[fetch,
|
|
1571
|
+
[fetch, cataloguePageSchema]
|
|
1457
1572
|
);
|
|
1458
1573
|
const advanceAfterTrackEnd = useCallback4(
|
|
1459
1574
|
(event) => {
|
|
@@ -1525,7 +1640,7 @@ function TrackListProvider({
|
|
|
1525
1640
|
const from = options?.startSongUuid;
|
|
1526
1641
|
let page;
|
|
1527
1642
|
try {
|
|
1528
|
-
page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
|
|
1643
|
+
page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from, options?.selection, options?.artistUuid);
|
|
1529
1644
|
} catch (error) {
|
|
1530
1645
|
if (request !== latestPlayRequestRef.current) return;
|
|
1531
1646
|
startingPlaybackRef.current = false;
|
|
@@ -1542,7 +1657,7 @@ function TrackListProvider({
|
|
|
1542
1657
|
console.warn("No playable tracks found in genre playlist");
|
|
1543
1658
|
return;
|
|
1544
1659
|
}
|
|
1545
|
-
const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from);
|
|
1660
|
+
const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from, options?.selection, options?.artistUuid);
|
|
1546
1661
|
setAutoAdvanceScrollRequest(null);
|
|
1547
1662
|
setTrackList(new TrackListFromCriteriaPlaylist(page.tracks, origin, page.total, page.nextPage));
|
|
1548
1663
|
setSelectedTrack(startTrack);
|
|
@@ -1551,17 +1666,15 @@ function TrackListProvider({
|
|
|
1551
1666
|
},
|
|
1552
1667
|
[clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
1553
1668
|
);
|
|
1554
|
-
const
|
|
1555
|
-
async (
|
|
1556
|
-
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
1669
|
+
const playCatalogue = useCallback4(
|
|
1670
|
+
async (origin) => {
|
|
1557
1671
|
clearDelayedTrackLoad();
|
|
1558
1672
|
const request = ++latestPlayRequestRef.current;
|
|
1559
1673
|
startingPlaybackRef.current = true;
|
|
1560
|
-
const from =
|
|
1561
|
-
const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
|
|
1674
|
+
const from = origin.from;
|
|
1562
1675
|
let page;
|
|
1563
1676
|
try {
|
|
1564
|
-
page = await
|
|
1677
|
+
page = await fetchCatalogueTracksPage(origin, 1);
|
|
1565
1678
|
} catch (error) {
|
|
1566
1679
|
if (request !== latestPlayRequestRef.current) return;
|
|
1567
1680
|
startingPlaybackRef.current = false;
|
|
@@ -1572,21 +1685,36 @@ function TrackListProvider({
|
|
|
1572
1685
|
loadedContextRef.current = playback.snapshot().key;
|
|
1573
1686
|
const startTrack = page.tracks[0];
|
|
1574
1687
|
if (from && startTrack?.uuid !== from) {
|
|
1575
|
-
throw new Error(
|
|
1688
|
+
throw new Error(`${origin instanceof TrackListOriginFromArtist ? "Artist" : "Catalogue"} ${origin.uuid} did not start at song ${from}`);
|
|
1576
1689
|
}
|
|
1577
1690
|
if (!startTrack) {
|
|
1578
|
-
console.warn("No playable songs found
|
|
1691
|
+
console.warn("No playable songs found in catalogue");
|
|
1579
1692
|
return;
|
|
1580
1693
|
}
|
|
1581
|
-
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));
|
|
1582
1695
|
setAutoAdvanceScrollRequest(null);
|
|
1583
1696
|
setSelectedTrack(startTrack);
|
|
1584
1697
|
showTrackListSidebar();
|
|
1585
1698
|
loadTrackForPlayer(startTrack.uuid);
|
|
1586
1699
|
},
|
|
1587
|
-
[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]
|
|
1588
1716
|
);
|
|
1589
|
-
const contextKeyRef =
|
|
1717
|
+
const contextKeyRef = useRef3(playback.key);
|
|
1590
1718
|
useEffect3(() => {
|
|
1591
1719
|
if (contextKeyRef.current === playback.key) return;
|
|
1592
1720
|
contextKeyRef.current = playback.key;
|
|
@@ -1606,20 +1734,28 @@ function TrackListProvider({
|
|
|
1606
1734
|
setTrackList(null);
|
|
1607
1735
|
setSelectedTrack(null);
|
|
1608
1736
|
if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
|
|
1609
|
-
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) => {
|
|
1610
1738
|
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
1611
|
-
return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
|
|
1739
|
+
return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { selection: origin.selection, artistUuid: origin.artistUuid }).catch(() => {
|
|
1612
1740
|
});
|
|
1613
1741
|
}
|
|
1614
1742
|
});
|
|
1615
1743
|
} else if (origin instanceof TrackListOriginFromArtist) {
|
|
1616
|
-
const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
|
|
1744
|
+
const options = { ordering: origin.ordering, genreUuid: origin.genreUuid, selection: origin.selection };
|
|
1617
1745
|
void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
|
|
1618
1746
|
if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
|
|
1619
1747
|
return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
|
|
1620
1748
|
});
|
|
1621
1749
|
}
|
|
1622
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
|
+
});
|
|
1623
1759
|
} else if (origin instanceof TrackListOriginFromTrack && selected) {
|
|
1624
1760
|
const request = latestPlayRequestRef.current;
|
|
1625
1761
|
void (async () => {
|
|
@@ -1630,7 +1766,7 @@ function TrackListProvider({
|
|
|
1630
1766
|
})().catch(() => {
|
|
1631
1767
|
});
|
|
1632
1768
|
}
|
|
1633
|
-
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch]);
|
|
1769
|
+
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch]);
|
|
1634
1770
|
const updateTrack = useCallback4((track) => {
|
|
1635
1771
|
setTrackList((prev) => {
|
|
1636
1772
|
if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
|
|
@@ -1642,22 +1778,22 @@ function TrackListProvider({
|
|
|
1642
1778
|
const loadMore = useCallback4(async () => {
|
|
1643
1779
|
if (!trackList || trackList.nextPage === null) return;
|
|
1644
1780
|
const origin = trackList.origin;
|
|
1645
|
-
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist)) return;
|
|
1781
|
+
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
|
|
1646
1782
|
if (loadingOriginRef.current === origin) return;
|
|
1647
1783
|
const requestedPage = trackList.nextPage;
|
|
1648
1784
|
loadingOriginRef.current = origin;
|
|
1649
1785
|
try {
|
|
1650
|
-
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);
|
|
1651
1787
|
setTrackList((prev) => {
|
|
1652
1788
|
if (prev?.origin !== origin || prev.nextPage !== requestedPage) return prev;
|
|
1653
1789
|
const loaded = new Set(prev.tracks.map((track) => track.uuid));
|
|
1654
1790
|
const tracks = [...prev.tracks, ...page.tracks.filter((track) => !loaded.has(track.uuid))];
|
|
1655
|
-
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);
|
|
1656
1792
|
});
|
|
1657
1793
|
} finally {
|
|
1658
1794
|
if (loadingOriginRef.current === origin) loadingOriginRef.current = null;
|
|
1659
1795
|
}
|
|
1660
|
-
}, [trackList, fetchTracksPage,
|
|
1796
|
+
}, [trackList, fetchTracksPage, fetchCatalogueTracksPage]);
|
|
1661
1797
|
const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
|
|
1662
1798
|
const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
1663
1799
|
const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
@@ -1745,6 +1881,7 @@ function TrackListProvider({
|
|
|
1745
1881
|
playNewTrackListFromTrackUuid,
|
|
1746
1882
|
playNewTrackListFromGenrePlaylist,
|
|
1747
1883
|
playNewTrackListFromArtist,
|
|
1884
|
+
playNewTrackListFromGenreCatalogue,
|
|
1748
1885
|
fetchGenrePlaylistTracksPage: fetchTracksPage,
|
|
1749
1886
|
loadMore,
|
|
1750
1887
|
updateTrack
|
|
@@ -1762,6 +1899,7 @@ function TrackListProvider({
|
|
|
1762
1899
|
playNewTrackListFromTrackUuid,
|
|
1763
1900
|
playNewTrackListFromGenrePlaylist,
|
|
1764
1901
|
playNewTrackListFromArtist,
|
|
1902
|
+
playNewTrackListFromGenreCatalogue,
|
|
1765
1903
|
fetchTracksPage,
|
|
1766
1904
|
loadMore,
|
|
1767
1905
|
updateTrack
|
|
@@ -1792,24 +1930,24 @@ function ArtistNames({
|
|
|
1792
1930
|
}
|
|
1793
1931
|
|
|
1794
1932
|
// src/genre-tree/schemas/mb-artist.ts
|
|
1795
|
-
import { z as
|
|
1796
|
-
var MbArtistDetailedSchema =
|
|
1797
|
-
musicbrainzId:
|
|
1798
|
-
name:
|
|
1933
|
+
import { z as z31 } from "zod";
|
|
1934
|
+
var MbArtistDetailedSchema = z31.object({
|
|
1935
|
+
musicbrainzId: z31.string().uuid(),
|
|
1936
|
+
name: z31.string(),
|
|
1799
1937
|
musicbrainzLink: HttpUrlSchema
|
|
1800
1938
|
});
|
|
1801
1939
|
|
|
1802
1940
|
// src/genre-tree/schemas/mb-recording.ts
|
|
1803
|
-
import { z as
|
|
1804
|
-
var MbRecordingDetailedSchema =
|
|
1805
|
-
musicbrainzId:
|
|
1806
|
-
title:
|
|
1807
|
-
score:
|
|
1808
|
-
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),
|
|
1809
1947
|
musicbrainzLink: HttpUrlSchema,
|
|
1810
|
-
durationInSec:
|
|
1811
|
-
durationStrInHourMinSec:
|
|
1812
|
-
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) => {
|
|
1813
1951
|
try {
|
|
1814
1952
|
const date = new Date(val);
|
|
1815
1953
|
if (isNaN(date.getTime())) {
|
|
@@ -1875,26 +2013,39 @@ function editGenreSongPages(data, edit) {
|
|
|
1875
2013
|
}
|
|
1876
2014
|
|
|
1877
2015
|
export {
|
|
1878
|
-
CriteriaMinimumSchema,
|
|
1879
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,
|
|
1880
2032
|
CriteriaPlaylistDetailedSchema,
|
|
1881
2033
|
CriteriaPlaylistSimpleSchema,
|
|
2034
|
+
ReferenceGenreDetailedSchema,
|
|
2035
|
+
ReferenceGenrePlaylistSchema,
|
|
1882
2036
|
genrePlaylistQueryKeys,
|
|
1883
2037
|
genrePlaylistEndpoints,
|
|
2038
|
+
defaultGenreMusicSelection,
|
|
2039
|
+
genreMusicCount,
|
|
2040
|
+
genreMusicQueryParams,
|
|
2041
|
+
genreMusicSelectionKey,
|
|
2042
|
+
genrePlaylistTrackCount,
|
|
1884
2043
|
libraryQueryKeys,
|
|
1885
2044
|
libraryEndpoints,
|
|
1886
2045
|
useListGenrePlaylists,
|
|
1887
2046
|
useListFullGenrePlaylists,
|
|
1888
2047
|
useFetchGenrePlaylist,
|
|
1889
2048
|
useInvalidateAllGenrePlaylistQueries,
|
|
1890
|
-
ArtistMinimumSchema,
|
|
1891
|
-
AlbumMinimumSchema,
|
|
1892
|
-
UuidResourceSchema,
|
|
1893
|
-
TrackBaseSchema,
|
|
1894
|
-
TrackMinimumSchema,
|
|
1895
|
-
CriteriaLineageRelWithoutAscendantSchema,
|
|
1896
|
-
CriteriaLineageRelWithoutDescendantSchema,
|
|
1897
|
-
CriteriaDetailedSchema,
|
|
1898
2049
|
CriteriaOverviewSchema,
|
|
1899
2050
|
CriteriaSimpleSchema,
|
|
1900
2051
|
CriteriaCreationSchema,
|
|
@@ -1971,6 +2122,7 @@ export {
|
|
|
1971
2122
|
TrackListOriginFromTrack,
|
|
1972
2123
|
TrackListOriginFromCriteriaPlaylist,
|
|
1973
2124
|
TrackListOriginFromArtist,
|
|
2125
|
+
TrackListOriginFromGenreCatalogue,
|
|
1974
2126
|
TrackListSidebarVisibilityProvider,
|
|
1975
2127
|
useTrackListSidebarVisibility,
|
|
1976
2128
|
useListTracks,
|
|
@@ -1985,4 +2137,4 @@ export {
|
|
|
1985
2137
|
getReparentCandidates,
|
|
1986
2138
|
editGenreSongPages
|
|
1987
2139
|
};
|
|
1988
|
-
//# sourceMappingURL=chunk-
|
|
2140
|
+
//# sourceMappingURL=chunk-3PITD62C.js.map
|