@behindthemusictree/app-kit 33.1.0 → 33.3.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-PY3Y4E27.js → chunk-HHE6VK67.js} +251 -118
- package/dist/chunk-HHE6VK67.js.map +1 -0
- package/dist/genre-tree/index.cjs +309 -160
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +160 -4
- package/dist/genre-tree/index.js +33 -1
- package/dist/index.cjs +306 -157
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -1
- package/package.json +1 -1
- package/dist/chunk-PY3Y4E27.js.map +0 -1
|
@@ -393,6 +393,10 @@ var genreQueryKeys = {
|
|
|
393
393
|
overview: (id) => ["referenceGenres", "overview", id]
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
|
+
var genreSearchQueryKeys = {
|
|
397
|
+
search: (params) => ["genreSearch", params],
|
|
398
|
+
regionLexicon: () => ["regionGenreLexicon"]
|
|
399
|
+
};
|
|
396
400
|
var genreUpdateMutationKey = ["genres", "update"];
|
|
397
401
|
|
|
398
402
|
// src/genre-tree/api/genres/endpoints.ts
|
|
@@ -406,7 +410,9 @@ var makeGenreEndpoints = (prefix) => ({
|
|
|
406
410
|
});
|
|
407
411
|
var genreEndpoints = {
|
|
408
412
|
me: makeGenreEndpoints("me/"),
|
|
409
|
-
reference: makeGenreEndpoints("")
|
|
413
|
+
reference: makeGenreEndpoints(""),
|
|
414
|
+
search: () => "genres/search/",
|
|
415
|
+
regionLexicon: () => "regions/map/genres/"
|
|
410
416
|
};
|
|
411
417
|
|
|
412
418
|
// src/genre-tree/useGenre.ts
|
|
@@ -653,10 +659,6 @@ function useArtist(uuid, getBackendBaseUrl) {
|
|
|
653
659
|
return { status: "success", artist: data };
|
|
654
660
|
}
|
|
655
661
|
|
|
656
|
-
// src/genre-tree/useArtistSearch.ts
|
|
657
|
-
import { keepPreviousData } from "@tanstack/react-query";
|
|
658
|
-
import { useEffect, useState } from "react";
|
|
659
|
-
|
|
660
662
|
// src/genre-tree/schemas/artist-search.ts
|
|
661
663
|
import { z as z21 } from "zod";
|
|
662
664
|
var ArtistSearchResultSchema = z21.object({
|
|
@@ -672,37 +674,57 @@ var ArtistSearchResultSchema = z21.object({
|
|
|
672
674
|
});
|
|
673
675
|
var ArtistSearchResultsSchema = z21.array(ArtistSearchResultSchema);
|
|
674
676
|
|
|
675
|
-
// src/genre-tree/
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
var
|
|
679
|
-
|
|
677
|
+
// src/genre-tree/useRemoteSearch.ts
|
|
678
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
679
|
+
import { useEffect, useRef, useState } from "react";
|
|
680
|
+
var SEARCH_DEBOUNCE_MS = 250;
|
|
681
|
+
var SEARCH_QUERY_MIN_LENGTH = 2;
|
|
682
|
+
function useRemoteSearch(getBackendBaseUrl, { queryKey, endpoint, params, schema, context, text, enabled: extraEnabled = true, scope = "" }) {
|
|
680
683
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
681
684
|
const trimmed = text.trim();
|
|
682
685
|
const [query, setQuery] = useState("");
|
|
683
686
|
useEffect(() => {
|
|
684
|
-
const timer = setTimeout(() => setQuery(trimmed),
|
|
687
|
+
const timer = setTimeout(() => setQuery(trimmed), SEARCH_DEBOUNCE_MS);
|
|
685
688
|
return () => clearTimeout(timer);
|
|
686
689
|
}, [trimmed]);
|
|
687
|
-
const
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
690
|
+
const dataScope = useRef(null);
|
|
691
|
+
const enabled = query.length >= SEARCH_QUERY_MIN_LENGTH && extraEnabled;
|
|
692
|
+
const { data, isFetching, isError, isPlaceholderData } = useQueryWithParse({
|
|
693
|
+
queryKey: queryKey(query),
|
|
694
|
+
queryFn: ({ signal }) => fetch(endpoint, true, false, { signal }, params(query)),
|
|
695
|
+
schema,
|
|
696
|
+
context,
|
|
693
697
|
enabled,
|
|
694
|
-
placeholderData: keepPreviousData
|
|
698
|
+
placeholderData: (previous) => dataScope.current === scope ? keepPreviousData(previous) : void 0
|
|
695
699
|
});
|
|
700
|
+
useEffect(() => {
|
|
701
|
+
if (data !== void 0 && !isPlaceholderData) dataScope.current = scope;
|
|
702
|
+
}, [data, isPlaceholderData, scope]);
|
|
696
703
|
const settled = enabled && !isFetching && query === trimmed;
|
|
697
704
|
const failed = enabled && isError;
|
|
705
|
+
const long = trimmed.length >= SEARCH_QUERY_MIN_LENGTH;
|
|
698
706
|
return {
|
|
699
|
-
|
|
707
|
+
results: long ? data ?? [] : [],
|
|
700
708
|
isError: failed,
|
|
701
709
|
settled,
|
|
702
|
-
pending:
|
|
710
|
+
pending: long && !settled && !failed
|
|
703
711
|
};
|
|
704
712
|
}
|
|
705
713
|
|
|
714
|
+
// src/genre-tree/useArtistSearch.ts
|
|
715
|
+
var RESULT_LIMIT = 8;
|
|
716
|
+
function useArtistSearch(getBackendBaseUrl, text) {
|
|
717
|
+
const { results, isError, settled, pending } = useRemoteSearch(getBackendBaseUrl, {
|
|
718
|
+
queryKey: artistQueryKeys.search,
|
|
719
|
+
endpoint: artistEndpoints.search(),
|
|
720
|
+
params: (q) => ({ q, limit: RESULT_LIMIT }),
|
|
721
|
+
schema: ArtistSearchResultsSchema,
|
|
722
|
+
context: "useArtistSearch",
|
|
723
|
+
text
|
|
724
|
+
});
|
|
725
|
+
return { artists: results, isError, settled, pending };
|
|
726
|
+
}
|
|
727
|
+
|
|
706
728
|
// src/genre-tree/useSong.ts
|
|
707
729
|
import { z as z23 } from "zod";
|
|
708
730
|
|
|
@@ -799,10 +821,6 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
|
799
821
|
return { status: "success", entries: data };
|
|
800
822
|
}
|
|
801
823
|
|
|
802
|
-
// src/genre-tree/useSongSearch.ts
|
|
803
|
-
import { keepPreviousData as keepPreviousData2 } from "@tanstack/react-query";
|
|
804
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
805
|
-
|
|
806
824
|
// src/genre-tree/schemas/song-search.ts
|
|
807
825
|
import { z as z25 } from "zod";
|
|
808
826
|
var SongSearchResultSchema = z25.object({
|
|
@@ -823,39 +841,26 @@ function isSongSearchResultPlayable(result) {
|
|
|
823
841
|
}
|
|
824
842
|
|
|
825
843
|
// src/genre-tree/useSongSearch.ts
|
|
826
|
-
var
|
|
827
|
-
|
|
828
|
-
var RESULT_LIMIT2 = 8;
|
|
829
|
-
function useSongSearch(getBackendBaseUrl, text) {
|
|
844
|
+
var DEFAULT_RESULT_LIMIT = 8;
|
|
845
|
+
function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
830
846
|
const playback = usePlaybackContext();
|
|
831
|
-
const {
|
|
832
|
-
const
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}, [trimmed]);
|
|
838
|
-
const enabled = query.length >= MIN_QUERY_LENGTH2 && playback.ready;
|
|
839
|
-
const { data, isFetching, isError } = useQueryWithParse({
|
|
840
|
-
queryKey: [...libraryQueryKeys.reference.songs.search({ q: query, limit: RESULT_LIMIT2 }), ...playback.key ? [playback.key] : []],
|
|
841
|
-
queryFn: ({ signal }) => fetch(libraryEndpoints.reference.songs.search(), true, false, { signal }, { q: query, limit: RESULT_LIMIT2 }),
|
|
847
|
+
const { limit = DEFAULT_RESULT_LIMIT, genre, playable } = options;
|
|
848
|
+
const params = (q) => ({ q, limit, ...genre && { genre }, ...playable !== void 0 && { playable } });
|
|
849
|
+
const { results, isError, settled, pending } = useRemoteSearch(getBackendBaseUrl, {
|
|
850
|
+
queryKey: (q) => [...libraryQueryKeys.reference.songs.search(params(q)), ...playback.key ? [playback.key] : []],
|
|
851
|
+
endpoint: libraryEndpoints.reference.songs.search(),
|
|
852
|
+
params,
|
|
842
853
|
schema: SongSearchResultsSchema,
|
|
843
854
|
context: "useSongSearch",
|
|
844
|
-
|
|
845
|
-
|
|
855
|
+
text,
|
|
856
|
+
enabled: playback.ready,
|
|
857
|
+
scope: playback.key ?? ""
|
|
846
858
|
});
|
|
847
|
-
|
|
848
|
-
const failed = enabled && isError;
|
|
849
|
-
return {
|
|
850
|
-
songs: trimmed.length >= MIN_QUERY_LENGTH2 ? data ?? [] : [],
|
|
851
|
-
isError: failed,
|
|
852
|
-
settled,
|
|
853
|
-
pending: trimmed.length >= MIN_QUERY_LENGTH2 && !settled && !failed
|
|
854
|
-
};
|
|
859
|
+
return { songs: results, isError, settled, pending };
|
|
855
860
|
}
|
|
856
861
|
|
|
857
862
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
858
|
-
import { keepPreviousData as
|
|
863
|
+
import { keepPreviousData as keepPreviousData2 } from "@tanstack/react-query";
|
|
859
864
|
import { z as z27 } from "zod";
|
|
860
865
|
|
|
861
866
|
// src/genre-tree/schemas/artist-genre-count.ts
|
|
@@ -878,56 +883,168 @@ function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
|
878
883
|
queryFn: () => fetch(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
|
|
879
884
|
schema: z27.array(ArtistGenreCountSchema),
|
|
880
885
|
enabled: artistUuid !== null,
|
|
881
|
-
placeholderData:
|
|
886
|
+
placeholderData: keepPreviousData2,
|
|
882
887
|
retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
|
|
883
888
|
context: "useArtistGenreCounts"
|
|
884
889
|
});
|
|
885
890
|
}
|
|
886
891
|
|
|
887
|
-
// src/genre-tree/
|
|
888
|
-
|
|
892
|
+
// src/genre-tree/lib/search-text.ts
|
|
893
|
+
var foldSearchText = (text) => text.normalize("NFD").replace(/\p{M}+/gu, "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
894
|
+
var trigrams = (folded) => {
|
|
895
|
+
const padded = ` ${folded} `;
|
|
896
|
+
const grams = /* @__PURE__ */ new Set();
|
|
897
|
+
for (let i = 0; i + 3 <= padded.length; i++) grams.add(padded.slice(i, i + 3));
|
|
898
|
+
return grams;
|
|
899
|
+
};
|
|
900
|
+
var trigramSimilarity = (a, b) => {
|
|
901
|
+
const ta = trigrams(foldSearchText(a));
|
|
902
|
+
const tb = trigrams(foldSearchText(b));
|
|
903
|
+
let shared = 0;
|
|
904
|
+
for (const gram of ta) if (tb.has(gram)) shared++;
|
|
905
|
+
const union = ta.size + tb.size - shared;
|
|
906
|
+
return union === 0 ? 0 : shared / union;
|
|
907
|
+
};
|
|
908
|
+
var FUZZY_MIN_SIMILARITY = 0.3;
|
|
909
|
+
var TIER_EXACT = 0;
|
|
910
|
+
var TIER_PREFIX = 1;
|
|
911
|
+
var TIER_SUBSTRING = 2;
|
|
912
|
+
var TIER_FUZZY = 3;
|
|
913
|
+
function rankByName(items, query, getName, getViews) {
|
|
914
|
+
const folded = foldSearchText(query);
|
|
915
|
+
if (!folded) return [];
|
|
916
|
+
const scored = [];
|
|
917
|
+
for (const item of items) {
|
|
918
|
+
const name = getName(item);
|
|
919
|
+
const foldedName = foldSearchText(name);
|
|
920
|
+
let tier;
|
|
921
|
+
let similarity = 0;
|
|
922
|
+
if (foldedName === folded) tier = TIER_EXACT;
|
|
923
|
+
else if (foldedName.startsWith(folded)) tier = TIER_PREFIX;
|
|
924
|
+
else if (foldedName.includes(folded)) tier = TIER_SUBSTRING;
|
|
925
|
+
else {
|
|
926
|
+
similarity = trigramSimilarity(name, query);
|
|
927
|
+
if (similarity < FUZZY_MIN_SIMILARITY) continue;
|
|
928
|
+
tier = TIER_FUZZY;
|
|
929
|
+
}
|
|
930
|
+
scored.push({ item, tier, similarity, views: getViews?.(item) ?? 0, name: foldedName });
|
|
931
|
+
}
|
|
932
|
+
scored.sort(
|
|
933
|
+
(a, b) => a.tier - b.tier || b.similarity - a.similarity || b.views - a.views || a.name.localeCompare(b.name)
|
|
934
|
+
);
|
|
935
|
+
return scored.map((entry) => entry.item);
|
|
936
|
+
}
|
|
889
937
|
|
|
890
938
|
// src/genre-tree/lib/genre-search.ts
|
|
891
|
-
var searchGenrePlaylistsByName = (genrePlaylists, query) =>
|
|
892
|
-
const trimmedQuery = query.trim().toLowerCase();
|
|
893
|
-
if (!trimmedQuery) return [];
|
|
894
|
-
return genrePlaylists.filter(
|
|
895
|
-
(genrePlaylist) => genrePlaylist.name.toLowerCase().includes(trimmedQuery)
|
|
896
|
-
);
|
|
897
|
-
};
|
|
939
|
+
var searchGenrePlaylistsByName = (genrePlaylists, query) => rankByName(genrePlaylists, query, (genrePlaylist) => genrePlaylist.name, (genrePlaylist) => genrePlaylist.viewsCount ?? 0);
|
|
898
940
|
|
|
899
|
-
// src/genre-tree/
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
onClear
|
|
905
|
-
}) {
|
|
906
|
-
const [query, setQuery] = useState3(selectedName ?? "");
|
|
907
|
-
const [prevSelectedName, setPrevSelectedName] = useState3(selectedName);
|
|
941
|
+
// src/genre-tree/useSearchQueryState.ts
|
|
942
|
+
import { useState as useState2 } from "react";
|
|
943
|
+
function useSearchQueryState({ selectedName = null, onClear } = {}) {
|
|
944
|
+
const [query, setQuery] = useState2(selectedName ?? "");
|
|
945
|
+
const [prevSelectedName, setPrevSelectedName] = useState2(selectedName);
|
|
908
946
|
if (selectedName !== prevSelectedName) {
|
|
909
947
|
setPrevSelectedName(selectedName);
|
|
910
948
|
setQuery(selectedName ?? "");
|
|
911
949
|
}
|
|
912
|
-
const results = query !== "" && query !== selectedName ? searchGenrePlaylistsByName(genrePlaylists, query) : [];
|
|
913
950
|
return {
|
|
914
951
|
query,
|
|
915
952
|
setQuery,
|
|
916
|
-
|
|
953
|
+
isTyping: query !== "" && query !== selectedName,
|
|
917
954
|
canClear: query !== "" || selectedName !== null,
|
|
918
955
|
clear: () => {
|
|
919
956
|
setQuery("");
|
|
920
957
|
onClear?.();
|
|
921
958
|
},
|
|
959
|
+
notifyPick: (pickedName) => {
|
|
960
|
+
setQuery(pickedName === selectedName ? selectedName : "");
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// src/genre-tree/useGenreSearch.ts
|
|
966
|
+
function useGenreSearch({
|
|
967
|
+
genrePlaylists,
|
|
968
|
+
onSelect,
|
|
969
|
+
selectedName = null,
|
|
970
|
+
onClear
|
|
971
|
+
}) {
|
|
972
|
+
const { query, setQuery, isTyping, canClear, clear, notifyPick } = useSearchQueryState({ selectedName, onClear });
|
|
973
|
+
const results = isTyping ? searchGenrePlaylistsByName(genrePlaylists, query) : [];
|
|
974
|
+
return {
|
|
975
|
+
query,
|
|
976
|
+
setQuery,
|
|
977
|
+
results,
|
|
978
|
+
canClear,
|
|
979
|
+
clear,
|
|
922
980
|
select: (genrePlaylist) => {
|
|
923
|
-
|
|
981
|
+
notifyPick(genrePlaylist.name);
|
|
924
982
|
onSelect(genrePlaylist);
|
|
925
983
|
}
|
|
926
984
|
};
|
|
927
985
|
}
|
|
928
986
|
|
|
987
|
+
// src/genre-tree/schemas/genre-search.ts
|
|
988
|
+
import { z as z28 } from "zod";
|
|
989
|
+
var GenreSearchTreeNameSchema = z28.enum(["canonical", "regional"]);
|
|
990
|
+
var GenreSearchResultSchema = z28.object({
|
|
991
|
+
/** Criteria (genre) uuid. */
|
|
992
|
+
uuid: GenreUuidSchema,
|
|
993
|
+
name: z28.string(),
|
|
994
|
+
/** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
|
|
995
|
+
wikidataId: z28.string().nullable(),
|
|
996
|
+
treeName: z28.string(),
|
|
997
|
+
/** Null when the genre has no playlist in the tree, so it cannot be opened there. */
|
|
998
|
+
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
999
|
+
root: z28.object({ uuid: GenreUuidSchema, name: z28.string() }),
|
|
1000
|
+
isUmbrella: z28.boolean(),
|
|
1001
|
+
viewsCount: z28.number().int()
|
|
1002
|
+
});
|
|
1003
|
+
var GenreSearchResultsSchema = z28.array(GenreSearchResultSchema);
|
|
1004
|
+
var RegionGenreLexiconEntrySchema = z28.object({
|
|
1005
|
+
wikidataId: z28.string(),
|
|
1006
|
+
uuid: GenreUuidSchema,
|
|
1007
|
+
name: z28.string(),
|
|
1008
|
+
treeName: z28.string(),
|
|
1009
|
+
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
1010
|
+
isUmbrella: z28.boolean(),
|
|
1011
|
+
viewsCount: z28.number().int()
|
|
1012
|
+
});
|
|
1013
|
+
var RegionGenreLexiconSchema = z28.array(RegionGenreLexiconEntrySchema);
|
|
1014
|
+
|
|
1015
|
+
// src/genre-tree/useGenreRemoteSearch.ts
|
|
1016
|
+
var DEFAULT_RESULT_LIMIT2 = 8;
|
|
1017
|
+
function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAULT_RESULT_LIMIT2, enabled } = {}) {
|
|
1018
|
+
const params = (q) => ({ q, limit, ...treeName && { treeName } });
|
|
1019
|
+
const { results, isError, settled, pending } = useRemoteSearch(getBackendBaseUrl, {
|
|
1020
|
+
queryKey: (q) => genreSearchQueryKeys.search(params(q)),
|
|
1021
|
+
endpoint: genreEndpoints.search(),
|
|
1022
|
+
params,
|
|
1023
|
+
schema: GenreSearchResultsSchema,
|
|
1024
|
+
context: "useGenreRemoteSearch",
|
|
1025
|
+
text,
|
|
1026
|
+
enabled
|
|
1027
|
+
});
|
|
1028
|
+
return { genres: results, isError, settled, pending };
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// src/genre-tree/useRegionGenreLexicon.ts
|
|
1032
|
+
function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
1033
|
+
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
1034
|
+
const { data, isError, isPending } = useQueryWithParse({
|
|
1035
|
+
queryKey: genreSearchQueryKeys.regionLexicon(),
|
|
1036
|
+
queryFn: ({ signal }) => fetch(genreEndpoints.regionLexicon(), true, false, { signal }),
|
|
1037
|
+
schema: RegionGenreLexiconSchema,
|
|
1038
|
+
context: "useRegionGenreLexicon",
|
|
1039
|
+
enabled,
|
|
1040
|
+
staleTime: Infinity
|
|
1041
|
+
});
|
|
1042
|
+
const entries = data ?? [];
|
|
1043
|
+
return { entries, isError, isPending: enabled && isPending };
|
|
1044
|
+
}
|
|
1045
|
+
|
|
929
1046
|
// src/genre-tree/useGenreTreeViewState.ts
|
|
930
|
-
import { useCallback as useCallback2, useEffect as
|
|
1047
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
931
1048
|
|
|
932
1049
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
933
1050
|
import { useMemo } from "react";
|
|
@@ -990,9 +1107,9 @@ function useGenreTreeViewState({
|
|
|
990
1107
|
onSelectedNodeIdChange,
|
|
991
1108
|
criteriaOverviewSchema
|
|
992
1109
|
}) {
|
|
993
|
-
const [internalViewMode, setInternalViewMode] =
|
|
994
|
-
const [allowWheelRotation, setAllowWheelRotation] =
|
|
995
|
-
const [internalSelectedNodeId, setInternalSelectedNodeId] =
|
|
1110
|
+
const [internalViewMode, setInternalViewMode] = useState3("pop-core");
|
|
1111
|
+
const [allowWheelRotation, setAllowWheelRotation] = useState3(false);
|
|
1112
|
+
const [internalSelectedNodeId, setInternalSelectedNodeId] = useState3(null);
|
|
996
1113
|
const isSelectionControlled = controlledSelectedNodeId !== void 0;
|
|
997
1114
|
const requestedSelectedNodeId = isSelectionControlled ? controlledSelectedNodeId : internalSelectedNodeId;
|
|
998
1115
|
const setSelectedNodeId = useCallback2(
|
|
@@ -1011,7 +1128,7 @@ function useGenreTreeViewState({
|
|
|
1011
1128
|
[genrePlaylists, requestedSelectedNodeId]
|
|
1012
1129
|
);
|
|
1013
1130
|
const selectedNodeId = selectedGenrePlaylist?.uuid ?? requestedSelectedNodeId;
|
|
1014
|
-
|
|
1131
|
+
useEffect2(() => {
|
|
1015
1132
|
if (!isSelectionControlled || requestedSelectedNodeId == null || selectedGenrePlaylist == null || requestedSelectedNodeId === selectedGenrePlaylist.uuid) {
|
|
1016
1133
|
return;
|
|
1017
1134
|
}
|
|
@@ -1024,8 +1141,8 @@ function useGenreTreeViewState({
|
|
|
1024
1141
|
[setSelectedNodeId]
|
|
1025
1142
|
);
|
|
1026
1143
|
const prefetchGenreOverview = usePrefetchGenreOverview(scope, getBackendBaseUrl, criteriaOverviewSchema);
|
|
1027
|
-
const hoverPrefetchTimerRef =
|
|
1028
|
-
|
|
1144
|
+
const hoverPrefetchTimerRef = useRef2(null);
|
|
1145
|
+
useEffect2(
|
|
1029
1146
|
() => () => {
|
|
1030
1147
|
if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
|
|
1031
1148
|
},
|
|
@@ -1052,7 +1169,7 @@ function useGenreTreeViewState({
|
|
|
1052
1169
|
),
|
|
1053
1170
|
[genrePlaylists]
|
|
1054
1171
|
);
|
|
1055
|
-
|
|
1172
|
+
useEffect2(() => {
|
|
1056
1173
|
if (!isLoading && needsPopCore(internalViewMode) && !canShowPopCore) {
|
|
1057
1174
|
setInternalViewMode("wheel");
|
|
1058
1175
|
}
|
|
@@ -1088,13 +1205,13 @@ function useGenreTreeViewState({
|
|
|
1088
1205
|
}
|
|
1089
1206
|
|
|
1090
1207
|
// src/genre-tree/TrackListContext.tsx
|
|
1091
|
-
import { createContext as createContext2, useState as
|
|
1208
|
+
import { createContext as createContext2, useState as useState5, useContext as useContext2, useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo4, useRef as useRef3 } from "react";
|
|
1092
1209
|
|
|
1093
1210
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
1094
|
-
import { z as
|
|
1095
|
-
var makeTrackPlaylistRelSchema = (trackSchema) =>
|
|
1211
|
+
import { z as z29 } from "zod";
|
|
1212
|
+
var makeTrackPlaylistRelSchema = (trackSchema) => z29.object({
|
|
1096
1213
|
track: trackSchema,
|
|
1097
|
-
position:
|
|
1214
|
+
position: z29.number().min(0)
|
|
1098
1215
|
});
|
|
1099
1216
|
var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
|
|
1100
1217
|
|
|
@@ -1198,11 +1315,11 @@ var TrackListOriginFromArtist = class extends TrackListOrigin {
|
|
|
1198
1315
|
};
|
|
1199
1316
|
|
|
1200
1317
|
// src/genre-tree/TrackListSidebarVisibilityContext.tsx
|
|
1201
|
-
import { createContext, useContext, useState as
|
|
1318
|
+
import { createContext, useContext, useState as useState4, useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
1202
1319
|
import { jsx } from "react/jsx-runtime";
|
|
1203
1320
|
var TrackListSidebarVisibilityContext = createContext(void 0);
|
|
1204
1321
|
function TrackListSidebarVisibilityProvider({ children }) {
|
|
1205
|
-
const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] =
|
|
1322
|
+
const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = useState4(false);
|
|
1206
1323
|
const toggleTrackListSidebar = useCallback3(() => {
|
|
1207
1324
|
setIsTrackListSidebarVisible((prev) => !prev);
|
|
1208
1325
|
}, []);
|
|
@@ -1260,12 +1377,12 @@ function TrackListProvider({
|
|
|
1260
1377
|
getBackendBaseUrl,
|
|
1261
1378
|
schema
|
|
1262
1379
|
}) {
|
|
1263
|
-
const [trackList, setTrackList] =
|
|
1264
|
-
const [selectedTrack, setSelectedTrack] =
|
|
1265
|
-
const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] =
|
|
1380
|
+
const [trackList, setTrackList] = useState5(null);
|
|
1381
|
+
const [selectedTrack, setSelectedTrack] = useState5(null);
|
|
1382
|
+
const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = useState5(null);
|
|
1266
1383
|
const { loadTrackForPlayer, setOnTrackEnd, hasPlaybackFailure, playerTrackObject } = usePlayer();
|
|
1267
|
-
const [failureClock, setFailureClock] =
|
|
1268
|
-
|
|
1384
|
+
const [failureClock, setFailureClock] = useState5(0);
|
|
1385
|
+
useEffect3(() => {
|
|
1269
1386
|
const timer = setInterval(() => setFailureClock((tick) => tick + 1), 3e4);
|
|
1270
1387
|
return () => clearInterval(timer);
|
|
1271
1388
|
}, []);
|
|
@@ -1276,13 +1393,13 @@ function TrackListProvider({
|
|
|
1276
1393
|
const playback = usePlaybackContext();
|
|
1277
1394
|
const { fetch } = useFetchWrapper(getBackendBaseUrl);
|
|
1278
1395
|
const pageSchema = useMemo4(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
|
|
1279
|
-
const latestPlayRequestRef =
|
|
1280
|
-
const startingPlaybackRef =
|
|
1281
|
-
const loadedContextRef =
|
|
1282
|
-
const autoAdvanceScrollRequestIdRef =
|
|
1283
|
-
const delayedTrackLoadRef =
|
|
1284
|
-
const loadingOriginRef =
|
|
1285
|
-
const pendingAdvanceRef =
|
|
1396
|
+
const latestPlayRequestRef = useRef3(0);
|
|
1397
|
+
const startingPlaybackRef = useRef3(false);
|
|
1398
|
+
const loadedContextRef = useRef3(playback.key);
|
|
1399
|
+
const autoAdvanceScrollRequestIdRef = useRef3(0);
|
|
1400
|
+
const delayedTrackLoadRef = useRef3(null);
|
|
1401
|
+
const loadingOriginRef = useRef3(null);
|
|
1402
|
+
const pendingAdvanceRef = useRef3(null);
|
|
1286
1403
|
const clearDelayedTrackLoad = useCallback4(() => {
|
|
1287
1404
|
if (delayedTrackLoadRef.current !== null) {
|
|
1288
1405
|
clearTimeout(delayedTrackLoadRef.current);
|
|
@@ -1376,7 +1493,7 @@ function TrackListProvider({
|
|
|
1376
1493
|
selectedTrack
|
|
1377
1494
|
]
|
|
1378
1495
|
);
|
|
1379
|
-
|
|
1496
|
+
useEffect3(() => {
|
|
1380
1497
|
setOnTrackEnd(trackList && selectedTrack ? advanceAfterTrackEnd : null);
|
|
1381
1498
|
return () => setOnTrackEnd(null);
|
|
1382
1499
|
}, [advanceAfterTrackEnd, trackList, selectedTrack, setOnTrackEnd]);
|
|
@@ -1475,8 +1592,8 @@ function TrackListProvider({
|
|
|
1475
1592
|
},
|
|
1476
1593
|
[clearDelayedTrackLoad, fetchArtistTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
1477
1594
|
);
|
|
1478
|
-
const contextKeyRef =
|
|
1479
|
-
|
|
1595
|
+
const contextKeyRef = useRef3(playback.key);
|
|
1596
|
+
useEffect3(() => {
|
|
1480
1597
|
if (contextKeyRef.current === playback.key) return;
|
|
1481
1598
|
contextKeyRef.current = playback.key;
|
|
1482
1599
|
if (loadedContextRef.current === playback.key) return;
|
|
@@ -1577,7 +1694,7 @@ function TrackListProvider({
|
|
|
1577
1694
|
setSelectedTrack(previousTrack);
|
|
1578
1695
|
loadTrackForPlayer(previousTrack.uuid);
|
|
1579
1696
|
}, [clearDelayedTrackLoad, loadTrackForPlayer, previousTrack, requestAutoAdvanceScroll]);
|
|
1580
|
-
|
|
1697
|
+
useEffect3(() => {
|
|
1581
1698
|
const pending = pendingAdvanceRef.current;
|
|
1582
1699
|
if (!pending) return;
|
|
1583
1700
|
if (!trackList || trackList.origin !== pending.origin || selectedTrack?.uuid !== pending.trackId) {
|
|
@@ -1611,8 +1728,8 @@ function TrackListProvider({
|
|
|
1611
1728
|
hasPlaybackFailure,
|
|
1612
1729
|
selectedTrack
|
|
1613
1730
|
]);
|
|
1614
|
-
|
|
1615
|
-
|
|
1731
|
+
useEffect3(() => clearDelayedTrackLoad, [clearDelayedTrackLoad]);
|
|
1732
|
+
useEffect3(() => {
|
|
1616
1733
|
if (!trackList || trackList.nextPage === null || !selectedTrack) return;
|
|
1617
1734
|
const index = trackList.tracks.findIndex((track) => track.uuid === selectedTrack.uuid);
|
|
1618
1735
|
if (index !== -1 && trackList.tracks.length - index <= AUTO_LOAD_REMAINING_TRACKS) {
|
|
@@ -1681,24 +1798,24 @@ function ArtistNames({
|
|
|
1681
1798
|
}
|
|
1682
1799
|
|
|
1683
1800
|
// src/genre-tree/schemas/mb-artist.ts
|
|
1684
|
-
import { z as
|
|
1685
|
-
var MbArtistDetailedSchema =
|
|
1686
|
-
musicbrainzId:
|
|
1687
|
-
name:
|
|
1801
|
+
import { z as z30 } from "zod";
|
|
1802
|
+
var MbArtistDetailedSchema = z30.object({
|
|
1803
|
+
musicbrainzId: z30.string().uuid(),
|
|
1804
|
+
name: z30.string(),
|
|
1688
1805
|
musicbrainzLink: HttpUrlSchema
|
|
1689
1806
|
});
|
|
1690
1807
|
|
|
1691
1808
|
// src/genre-tree/schemas/mb-recording.ts
|
|
1692
|
-
import { z as
|
|
1693
|
-
var MbRecordingDetailedSchema =
|
|
1694
|
-
musicbrainzId:
|
|
1695
|
-
title:
|
|
1696
|
-
score:
|
|
1697
|
-
musicbrainzArtists:
|
|
1809
|
+
import { z as z31 } from "zod";
|
|
1810
|
+
var MbRecordingDetailedSchema = z31.object({
|
|
1811
|
+
musicbrainzId: z31.string().uuid(),
|
|
1812
|
+
title: z31.string(),
|
|
1813
|
+
score: z31.number(),
|
|
1814
|
+
musicbrainzArtists: z31.array(MbArtistDetailedSchema),
|
|
1698
1815
|
musicbrainzLink: HttpUrlSchema,
|
|
1699
|
-
durationInSec:
|
|
1700
|
-
durationStrInHourMinSec:
|
|
1701
|
-
releaseDate:
|
|
1816
|
+
durationInSec: z31.number().min(0).nullable().optional(),
|
|
1817
|
+
durationStrInHourMinSec: z31.string().nullable().optional(),
|
|
1818
|
+
releaseDate: z31.union([z31.string().datetime(), z31.string()]).transform((val) => {
|
|
1702
1819
|
try {
|
|
1703
1820
|
const date = new Date(val);
|
|
1704
1821
|
if (isNaN(date.getTime())) {
|
|
@@ -1789,6 +1906,7 @@ export {
|
|
|
1789
1906
|
CriteriaCreationSchema,
|
|
1790
1907
|
CriteriaUpdateSchema,
|
|
1791
1908
|
genreQueryKeys,
|
|
1909
|
+
genreSearchQueryKeys,
|
|
1792
1910
|
genreUpdateMutationKey,
|
|
1793
1911
|
genreEndpoints,
|
|
1794
1912
|
useListGenres,
|
|
@@ -1808,6 +1926,9 @@ export {
|
|
|
1808
1926
|
useArtist,
|
|
1809
1927
|
ArtistSearchResultSchema,
|
|
1810
1928
|
ArtistSearchResultsSchema,
|
|
1929
|
+
SEARCH_DEBOUNCE_MS,
|
|
1930
|
+
SEARCH_QUERY_MIN_LENGTH,
|
|
1931
|
+
useRemoteSearch,
|
|
1811
1932
|
useArtistSearch,
|
|
1812
1933
|
YOUTUBE_UNPLAYABLE_REASON_LABELS,
|
|
1813
1934
|
YoutubeAvailabilitySchema,
|
|
@@ -1826,8 +1947,20 @@ export {
|
|
|
1826
1947
|
useSongSearch,
|
|
1827
1948
|
ArtistGenreCountSchema,
|
|
1828
1949
|
useArtistGenreCounts,
|
|
1950
|
+
foldSearchText,
|
|
1951
|
+
trigramSimilarity,
|
|
1952
|
+
FUZZY_MIN_SIMILARITY,
|
|
1953
|
+
rankByName,
|
|
1829
1954
|
searchGenrePlaylistsByName,
|
|
1955
|
+
useSearchQueryState,
|
|
1830
1956
|
useGenreSearch,
|
|
1957
|
+
GenreSearchTreeNameSchema,
|
|
1958
|
+
GenreSearchResultSchema,
|
|
1959
|
+
GenreSearchResultsSchema,
|
|
1960
|
+
RegionGenreLexiconEntrySchema,
|
|
1961
|
+
RegionGenreLexiconSchema,
|
|
1962
|
+
useGenreRemoteSearch,
|
|
1963
|
+
useRegionGenreLexicon,
|
|
1831
1964
|
pruneGenrePlaylistsForArtist,
|
|
1832
1965
|
useVisibleGenrePlaylists,
|
|
1833
1966
|
getGenrePlaylistsGroupedByRoot,
|
|
@@ -1858,4 +1991,4 @@ export {
|
|
|
1858
1991
|
getReparentCandidates,
|
|
1859
1992
|
editGenreSongPages
|
|
1860
1993
|
};
|
|
1861
|
-
//# sourceMappingURL=chunk-
|
|
1994
|
+
//# sourceMappingURL=chunk-HHE6VK67.js.map
|