@behindthemusictree/app-kit 34.0.0 → 35.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-3PITD62C.js → chunk-ULSVAC23.js} +112 -51
- package/dist/chunk-ULSVAC23.js.map +1 -0
- package/dist/genre-tree/index.cjs +165 -102
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +219 -210
- package/dist/genre-tree/index.js +5 -1
- package/dist/index.cjs +162 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
- package/dist/chunk-3PITD62C.js.map +0 -1
|
@@ -87,6 +87,7 @@ __export(genre_tree_exports, {
|
|
|
87
87
|
artistEndpoints: () => artistEndpoints,
|
|
88
88
|
artistQueryKeys: () => artistQueryKeys,
|
|
89
89
|
capitalizeFirstLetter: () => capitalizeFirstLetter,
|
|
90
|
+
createNameIndex: () => createNameIndex,
|
|
90
91
|
defaultGenreMusicSelection: () => defaultGenreMusicSelection,
|
|
91
92
|
editGenreSongPages: () => editGenreSongPages,
|
|
92
93
|
foldSearchText: () => foldSearchText,
|
|
@@ -113,6 +114,7 @@ __export(genre_tree_exports, {
|
|
|
113
114
|
musicBrainzRecordingUrl: () => musicBrainzRecordingUrl,
|
|
114
115
|
pruneGenrePlaylistsForArtist: () => pruneGenrePlaylistsForArtist,
|
|
115
116
|
rankByName: () => rankByName,
|
|
117
|
+
rankNameIndex: () => rankNameIndex,
|
|
116
118
|
searchGenrePlaylistsByName: () => searchGenrePlaylistsByName,
|
|
117
119
|
songUnplayableReason: () => songUnplayableReason,
|
|
118
120
|
trigramSimilarity: () => trigramSimilarity,
|
|
@@ -269,12 +271,12 @@ var CriteriaDetailedSchema = import_zod11.z.object({
|
|
|
269
271
|
wikidataId: import_zod11.z.string().nullable().optional(),
|
|
270
272
|
parent: CriteriaMinimumSchema.nullable(),
|
|
271
273
|
ascendants: import_zod11.z.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
272
|
-
descendants: import_zod11.z.array(CriteriaLineageRelWithoutAscendantSchema),
|
|
274
|
+
descendants: import_zod11.z.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
|
|
273
275
|
root: CriteriaMinimumSchema,
|
|
274
276
|
children: import_zod11.z.array(CriteriaMinimumSchema),
|
|
275
277
|
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
276
|
-
criteriaPlaylist: import_zod11.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]),
|
|
277
|
-
tracks: import_zod11.z.array(TrackMinimumSchema),
|
|
278
|
+
criteriaPlaylist: import_zod11.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
|
|
279
|
+
tracks: import_zod11.z.array(TrackMinimumSchema).optional(),
|
|
278
280
|
essentialSongs: import_zod11.z.array(TrackMinimumSchema),
|
|
279
281
|
tracksCount: import_zod11.z.number(),
|
|
280
282
|
updatedOn: import_zod11.z.string().datetime().nullable()
|
|
@@ -330,7 +332,7 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
|
|
|
330
332
|
// src/genre-tree/schemas/reference-genre.ts
|
|
331
333
|
var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
|
|
332
334
|
catalogue: GenreCatalogueCountsSchema,
|
|
333
|
-
criteriaPlaylist: GenrePlaylistSummarySchema
|
|
335
|
+
criteriaPlaylist: GenrePlaylistSummarySchema.nullable()
|
|
334
336
|
});
|
|
335
337
|
var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
|
|
336
338
|
...GenreCountsSchema.shape,
|
|
@@ -1715,6 +1717,9 @@ function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
|
1715
1717
|
});
|
|
1716
1718
|
}
|
|
1717
1719
|
|
|
1720
|
+
// src/genre-tree/useGenreSearch.ts
|
|
1721
|
+
var import_react9 = require("react");
|
|
1722
|
+
|
|
1718
1723
|
// src/genre-tree/lib/search-text.ts
|
|
1719
1724
|
var foldSearchText = (text) => text.normalize("NFD").replace(/\p{M}+/gu, "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
1720
1725
|
var trigrams = (folded) => {
|
|
@@ -1760,9 +1765,54 @@ function rankByName(items, query, getName, getViews) {
|
|
|
1760
1765
|
);
|
|
1761
1766
|
return scored.map((entry) => entry.item);
|
|
1762
1767
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1768
|
+
function createNameIndex(items, getName, getViews) {
|
|
1769
|
+
return items.map((item) => {
|
|
1770
|
+
const name = foldSearchText(getName(item));
|
|
1771
|
+
return { item, name, grams: trigrams(name), views: getViews?.(item) ?? 0 };
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
function rankNameIndex(index, query, limit = Infinity) {
|
|
1775
|
+
if (limit !== Infinity && (!Number.isInteger(limit) || limit < 0)) {
|
|
1776
|
+
throw new RangeError("Search limit must be a nonnegative integer or Infinity");
|
|
1777
|
+
}
|
|
1778
|
+
const folded = foldSearchText(query);
|
|
1779
|
+
if (!folded || limit === 0) return [];
|
|
1780
|
+
const queryGrams = trigrams(folded);
|
|
1781
|
+
const scored = [];
|
|
1782
|
+
const compare = (a, b) => a.tier - b.tier || b.similarity - a.similarity || b.views - a.views || a.name.localeCompare(b.name);
|
|
1783
|
+
for (const entry of index) {
|
|
1784
|
+
let tier;
|
|
1785
|
+
let similarity = 0;
|
|
1786
|
+
if (entry.name === folded) tier = TIER_EXACT;
|
|
1787
|
+
else if (entry.name.startsWith(folded)) tier = TIER_PREFIX;
|
|
1788
|
+
else if (entry.name.includes(folded)) tier = TIER_SUBSTRING;
|
|
1789
|
+
else {
|
|
1790
|
+
let shared = 0;
|
|
1791
|
+
for (const gram of queryGrams) if (entry.grams.has(gram)) shared++;
|
|
1792
|
+
const union = entry.grams.size + queryGrams.size - shared;
|
|
1793
|
+
similarity = union === 0 ? 0 : shared / union;
|
|
1794
|
+
if (similarity < FUZZY_MIN_SIMILARITY) continue;
|
|
1795
|
+
tier = TIER_FUZZY;
|
|
1796
|
+
}
|
|
1797
|
+
const candidate = { ...entry, tier, similarity };
|
|
1798
|
+
if (limit === Infinity) scored.push(candidate);
|
|
1799
|
+
else {
|
|
1800
|
+
let low = 0;
|
|
1801
|
+
let high = scored.length;
|
|
1802
|
+
while (low < high) {
|
|
1803
|
+
const mid = low + high >>> 1;
|
|
1804
|
+
if (compare(candidate, scored[mid]) < 0) high = mid;
|
|
1805
|
+
else low = mid + 1;
|
|
1806
|
+
}
|
|
1807
|
+
if (low < limit) {
|
|
1808
|
+
scored.splice(low, 0, candidate);
|
|
1809
|
+
if (scored.length > limit) scored.pop();
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
if (limit === Infinity) scored.sort(compare);
|
|
1814
|
+
return scored.map((entry) => entry.item);
|
|
1815
|
+
}
|
|
1766
1816
|
|
|
1767
1817
|
// src/genre-tree/useSearchQueryState.ts
|
|
1768
1818
|
var import_react8 = require("react");
|
|
@@ -1796,7 +1846,15 @@ function useGenreSearch({
|
|
|
1796
1846
|
onClear
|
|
1797
1847
|
}) {
|
|
1798
1848
|
const { query, setQuery, isTyping, canClear, clear, notifyPick } = useSearchQueryState({ selectedName, onClear });
|
|
1799
|
-
const
|
|
1849
|
+
const index = (0, import_react9.useMemo)(
|
|
1850
|
+
() => createNameIndex(genrePlaylists, (playlist) => playlist.name, (playlist) => playlist.viewsCount ?? 0),
|
|
1851
|
+
[genrePlaylists]
|
|
1852
|
+
);
|
|
1853
|
+
const deferredQuery = (0, import_react9.useDeferredValue)(query);
|
|
1854
|
+
const results = (0, import_react9.useMemo)(
|
|
1855
|
+
() => isTyping ? rankNameIndex(index, deferredQuery) : [],
|
|
1856
|
+
[index, deferredQuery, isTyping]
|
|
1857
|
+
);
|
|
1800
1858
|
return {
|
|
1801
1859
|
query,
|
|
1802
1860
|
setQuery,
|
|
@@ -1855,6 +1913,7 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
|
|
|
1855
1913
|
}
|
|
1856
1914
|
|
|
1857
1915
|
// src/genre-tree/useRegionGenreLexicon.ts
|
|
1916
|
+
var EMPTY_ENTRIES = [];
|
|
1858
1917
|
function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
1859
1918
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1860
1919
|
const { data, isError, isPending } = useQueryWithParse({
|
|
@@ -1865,15 +1924,15 @@ function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
|
1865
1924
|
enabled,
|
|
1866
1925
|
staleTime: Infinity
|
|
1867
1926
|
});
|
|
1868
|
-
const entries = data ??
|
|
1927
|
+
const entries = data ?? EMPTY_ENTRIES;
|
|
1869
1928
|
return { entries, isError, isPending: enabled && isPending };
|
|
1870
1929
|
}
|
|
1871
1930
|
|
|
1872
1931
|
// src/genre-tree/useGenreTreeViewState.ts
|
|
1873
|
-
var
|
|
1932
|
+
var import_react11 = require("react");
|
|
1874
1933
|
|
|
1875
1934
|
// src/genre-tree/useVisibleGenrePlaylists.ts
|
|
1876
|
-
var
|
|
1935
|
+
var import_react10 = require("react");
|
|
1877
1936
|
|
|
1878
1937
|
// src/genre-tree/lib/prune-genre-playlists-for-artist.ts
|
|
1879
1938
|
var POP_ROOT_NAME = "Mainstream Pop";
|
|
@@ -1915,7 +1974,7 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
|
|
|
1915
1974
|
const counts = useArtistGenreCounts(artistUuid, getBackendBaseUrl);
|
|
1916
1975
|
const artistCounts = artistUuid !== null ? counts.data : void 0;
|
|
1917
1976
|
const isCountsLoading = artistUuid !== null && (counts.isPending || counts.isPlaceholderData);
|
|
1918
|
-
const genrePlaylists = (0,
|
|
1977
|
+
const genrePlaylists = (0, import_react10.useMemo)(() => {
|
|
1919
1978
|
if (!tree) return [];
|
|
1920
1979
|
return artistCounts ? pruneGenrePlaylistsForArtist(tree, artistCounts) : tree;
|
|
1921
1980
|
}, [tree, artistCounts]);
|
|
@@ -1939,52 +1998,49 @@ function useGenreTreeViewState({
|
|
|
1939
1998
|
getBackendBaseUrl,
|
|
1940
1999
|
viewMode: controlledViewMode,
|
|
1941
2000
|
artistUuid,
|
|
1942
|
-
|
|
1943
|
-
|
|
2001
|
+
selectedGenreUuid: controlledSelectedGenreUuid,
|
|
2002
|
+
onSelectedGenreUuidChange,
|
|
1944
2003
|
criteriaOverviewSchema
|
|
1945
2004
|
}) {
|
|
1946
|
-
const [internalViewMode, setInternalViewMode] = (0,
|
|
1947
|
-
const [allowWheelRotation, setAllowWheelRotation] = (0,
|
|
1948
|
-
const [
|
|
1949
|
-
const isSelectionControlled =
|
|
1950
|
-
const
|
|
1951
|
-
const
|
|
2005
|
+
const [internalViewMode, setInternalViewMode] = (0, import_react11.useState)("pop-core");
|
|
2006
|
+
const [allowWheelRotation, setAllowWheelRotation] = (0, import_react11.useState)(false);
|
|
2007
|
+
const [internalSelectedGenreUuid, setInternalSelectedGenreUuid] = (0, import_react11.useState)(null);
|
|
2008
|
+
const isSelectionControlled = controlledSelectedGenreUuid !== void 0;
|
|
2009
|
+
const selectedGenreUuid = isSelectionControlled ? controlledSelectedGenreUuid : internalSelectedGenreUuid;
|
|
2010
|
+
const selectGenre = (0, import_react11.useCallback)(
|
|
1952
2011
|
(nodeId) => {
|
|
1953
|
-
if (!isSelectionControlled)
|
|
1954
|
-
|
|
2012
|
+
if (!isSelectionControlled) setInternalSelectedGenreUuid(nodeId);
|
|
2013
|
+
onSelectedGenreUuidChange?.(nodeId);
|
|
1955
2014
|
},
|
|
1956
|
-
[isSelectionControlled,
|
|
2015
|
+
[isSelectionControlled, onSelectedGenreUuidChange]
|
|
1957
2016
|
);
|
|
1958
2017
|
const { isLoading, isFetching, genrePlaylists } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
|
|
1959
|
-
const genrePlaylistByNodeId = (0,
|
|
1960
|
-
const selectedGenrePlaylist = (0,
|
|
1961
|
-
() => genrePlaylists.find((gp) => gp.uuid ===
|
|
1962
|
-
|
|
1963
|
-
genrePlaylists.find((gp) => gp.criteria?.uuid === requestedSelectedNodeId),
|
|
1964
|
-
[genrePlaylists, requestedSelectedNodeId]
|
|
2018
|
+
const genrePlaylistByNodeId = (0, import_react11.useMemo)(() => new Map(genrePlaylists.map((gp) => [gp.uuid, gp])), [genrePlaylists]);
|
|
2019
|
+
const selectedGenrePlaylist = (0, import_react11.useMemo)(
|
|
2020
|
+
() => genrePlaylists.find((gp) => gp.criteria?.uuid === selectedGenreUuid),
|
|
2021
|
+
[genrePlaylists, selectedGenreUuid]
|
|
1965
2022
|
);
|
|
1966
|
-
const selectedNodeId = selectedGenrePlaylist?.uuid ??
|
|
1967
|
-
(0,
|
|
1968
|
-
if (!
|
|
1969
|
-
|
|
2023
|
+
const selectedNodeId = selectedGenrePlaylist?.uuid ?? null;
|
|
2024
|
+
const selectNode = (0, import_react11.useCallback)((node) => {
|
|
2025
|
+
if (!node) selectGenre(null);
|
|
2026
|
+
else {
|
|
2027
|
+
const genreUuid = genrePlaylistByNodeId.get(node.id)?.criteria?.uuid;
|
|
2028
|
+
if (genreUuid) selectGenre(genreUuid);
|
|
1970
2029
|
}
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
const
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
(genrePlaylist) => setSelectedNodeId(genrePlaylist.uuid),
|
|
1977
|
-
[setSelectedNodeId]
|
|
1978
|
-
);
|
|
2030
|
+
}, [selectGenre, genrePlaylistByNodeId]);
|
|
2031
|
+
const clearSelection = (0, import_react11.useCallback)(() => selectGenre(null), [selectGenre]);
|
|
2032
|
+
const selectGenrePlaylist = (0, import_react11.useCallback)((playlist) => {
|
|
2033
|
+
if (playlist.criteria) selectGenre(playlist.criteria.uuid);
|
|
2034
|
+
}, [selectGenre]);
|
|
1979
2035
|
const prefetchGenreOverview = usePrefetchGenreOverview(scope, getBackendBaseUrl, criteriaOverviewSchema);
|
|
1980
|
-
const hoverPrefetchTimerRef = (0,
|
|
1981
|
-
(0,
|
|
2036
|
+
const hoverPrefetchTimerRef = (0, import_react11.useRef)(null);
|
|
2037
|
+
(0, import_react11.useEffect)(
|
|
1982
2038
|
() => () => {
|
|
1983
2039
|
if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
|
|
1984
2040
|
},
|
|
1985
2041
|
[]
|
|
1986
2042
|
);
|
|
1987
|
-
const onNodeHover = (0,
|
|
2043
|
+
const onNodeHover = (0, import_react11.useCallback)(
|
|
1988
2044
|
(node) => {
|
|
1989
2045
|
if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
|
|
1990
2046
|
const genreUuid = genrePlaylistByNodeId.get(node.id)?.criteria?.uuid;
|
|
@@ -1995,8 +2051,8 @@ function useGenreTreeViewState({
|
|
|
1995
2051
|
},
|
|
1996
2052
|
[genrePlaylistByNodeId, prefetchGenreOverview]
|
|
1997
2053
|
);
|
|
1998
|
-
const groupedGenrePlaylistsByRoot = (0,
|
|
1999
|
-
const canShowPopCore = (0,
|
|
2054
|
+
const groupedGenrePlaylistsByRoot = (0, import_react11.useMemo)(() => getGenrePlaylistsGroupedByRoot(genrePlaylists), [genrePlaylists]);
|
|
2055
|
+
const canShowPopCore = (0, import_react11.useMemo)(
|
|
2000
2056
|
() => hasMainstreamPopRoot(
|
|
2001
2057
|
genrePlaylists.map((genrePlaylist) => ({
|
|
2002
2058
|
parentId: genrePlaylist.parent?.uuid ?? null,
|
|
@@ -2005,14 +2061,14 @@ function useGenreTreeViewState({
|
|
|
2005
2061
|
),
|
|
2006
2062
|
[genrePlaylists]
|
|
2007
2063
|
);
|
|
2008
|
-
(0,
|
|
2064
|
+
(0, import_react11.useEffect)(() => {
|
|
2009
2065
|
if (!isLoading && needsPopCore(internalViewMode) && !canShowPopCore) {
|
|
2010
2066
|
setInternalViewMode("wheel");
|
|
2011
2067
|
}
|
|
2012
2068
|
}, [isLoading, canShowPopCore, internalViewMode]);
|
|
2013
2069
|
const selectedViewMode = controlledViewMode ?? internalViewMode;
|
|
2014
2070
|
const viewMode = needsPopCore(selectedViewMode) && !canShowPopCore ? "wheel" : selectedViewMode;
|
|
2015
|
-
const visibleGenrePlaylists = (0,
|
|
2071
|
+
const visibleGenrePlaylists = (0, import_react11.useMemo)(() => {
|
|
2016
2072
|
if (viewMode === "stacked") return genrePlaylists;
|
|
2017
2073
|
const unacceptedRootUuids = new Set(genrePlaylists.filter((gp) => gp.isUnacceptedRoot).map((gp) => gp.uuid));
|
|
2018
2074
|
const accepted = genrePlaylists.filter((gp) => !gp.isUnacceptedRoot && !unacceptedRootUuids.has(gp.root.uuid));
|
|
@@ -2025,6 +2081,8 @@ function useGenreTreeViewState({
|
|
|
2025
2081
|
genrePlaylistByNodeId,
|
|
2026
2082
|
visibleGenrePlaylists,
|
|
2027
2083
|
groupedGenrePlaylistsByRoot,
|
|
2084
|
+
selectedGenreUuid,
|
|
2085
|
+
selectGenre,
|
|
2028
2086
|
selectedNodeId,
|
|
2029
2087
|
selectedGenrePlaylist,
|
|
2030
2088
|
selectNode,
|
|
@@ -2041,7 +2099,7 @@ function useGenreTreeViewState({
|
|
|
2041
2099
|
}
|
|
2042
2100
|
|
|
2043
2101
|
// src/genre-tree/TrackListContext.tsx
|
|
2044
|
-
var
|
|
2102
|
+
var import_react14 = require("react");
|
|
2045
2103
|
|
|
2046
2104
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
2047
2105
|
var import_zod35 = require("zod");
|
|
@@ -2173,16 +2231,16 @@ var TrackListOriginFromGenreCatalogue = class extends TrackListOrigin {
|
|
|
2173
2231
|
};
|
|
2174
2232
|
|
|
2175
2233
|
// src/player/PlayerContext.tsx
|
|
2176
|
-
var
|
|
2234
|
+
var import_react12 = require("react");
|
|
2177
2235
|
|
|
2178
2236
|
// src/player/PlaybackFailures.ts
|
|
2179
2237
|
var TTL_MS = 10 * 6e4;
|
|
2180
2238
|
|
|
2181
2239
|
// src/player/PlayerContext.tsx
|
|
2182
2240
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2183
|
-
var PlayerContext = (0,
|
|
2241
|
+
var PlayerContext = (0, import_react12.createContext)(void 0);
|
|
2184
2242
|
function usePlayer() {
|
|
2185
|
-
const context = (0,
|
|
2243
|
+
const context = (0, import_react12.useContext)(PlayerContext);
|
|
2186
2244
|
if (context === void 0) {
|
|
2187
2245
|
throw new Error("usePlayer must be used within a PlayerProvider");
|
|
2188
2246
|
}
|
|
@@ -2190,21 +2248,21 @@ function usePlayer() {
|
|
|
2190
2248
|
}
|
|
2191
2249
|
|
|
2192
2250
|
// src/genre-tree/TrackListSidebarVisibilityContext.tsx
|
|
2193
|
-
var
|
|
2251
|
+
var import_react13 = require("react");
|
|
2194
2252
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2195
|
-
var TrackListSidebarVisibilityContext = (0,
|
|
2253
|
+
var TrackListSidebarVisibilityContext = (0, import_react13.createContext)(void 0);
|
|
2196
2254
|
function TrackListSidebarVisibilityProvider({ children }) {
|
|
2197
|
-
const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0,
|
|
2198
|
-
const toggleTrackListSidebar = (0,
|
|
2255
|
+
const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0, import_react13.useState)(false);
|
|
2256
|
+
const toggleTrackListSidebar = (0, import_react13.useCallback)(() => {
|
|
2199
2257
|
setIsTrackListSidebarVisible((prev) => !prev);
|
|
2200
2258
|
}, []);
|
|
2201
|
-
const showTrackListSidebar = (0,
|
|
2259
|
+
const showTrackListSidebar = (0, import_react13.useCallback)(() => {
|
|
2202
2260
|
setIsTrackListSidebarVisible(true);
|
|
2203
2261
|
}, []);
|
|
2204
|
-
const hideTrackListSidebar = (0,
|
|
2262
|
+
const hideTrackListSidebar = (0, import_react13.useCallback)(() => {
|
|
2205
2263
|
setIsTrackListSidebarVisible(false);
|
|
2206
2264
|
}, []);
|
|
2207
|
-
const value = (0,
|
|
2265
|
+
const value = (0, import_react13.useMemo)(
|
|
2208
2266
|
() => ({
|
|
2209
2267
|
isTrackListSidebarVisible,
|
|
2210
2268
|
toggleTrackListSidebar,
|
|
@@ -2216,7 +2274,7 @@ function TrackListSidebarVisibilityProvider({ children }) {
|
|
|
2216
2274
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TrackListSidebarVisibilityContext.Provider, { value, children });
|
|
2217
2275
|
}
|
|
2218
2276
|
function useTrackListSidebarVisibility() {
|
|
2219
|
-
const context = (0,
|
|
2277
|
+
const context = (0, import_react13.useContext)(TrackListSidebarVisibilityContext);
|
|
2220
2278
|
if (context === void 0) {
|
|
2221
2279
|
throw new Error("useTrackListSidebarVisibility must be used within a TrackListSidebarVisibilityProvider");
|
|
2222
2280
|
}
|
|
@@ -2246,45 +2304,45 @@ function useListTracks(scope, getBackendBaseUrl, schema, listEndpoint, listQuery
|
|
|
2246
2304
|
enabled: playback.ready && scope != null && (scope === "reference" || sessionRestored && !!session?.accessToken)
|
|
2247
2305
|
});
|
|
2248
2306
|
}
|
|
2249
|
-
var TrackListContext = (0,
|
|
2307
|
+
var TrackListContext = (0, import_react14.createContext)(void 0);
|
|
2250
2308
|
function TrackListProvider({
|
|
2251
2309
|
children,
|
|
2252
2310
|
getBackendBaseUrl,
|
|
2253
2311
|
schema
|
|
2254
2312
|
}) {
|
|
2255
|
-
const [trackList, setTrackList] = (0,
|
|
2256
|
-
const [selectedTrack, setSelectedTrack] = (0,
|
|
2257
|
-
const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0,
|
|
2313
|
+
const [trackList, setTrackList] = (0, import_react14.useState)(null);
|
|
2314
|
+
const [selectedTrack, setSelectedTrack] = (0, import_react14.useState)(null);
|
|
2315
|
+
const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0, import_react14.useState)(null);
|
|
2258
2316
|
const { loadTrackForPlayer, setOnTrackEnd, hasPlaybackFailure, playerTrackObject } = usePlayer();
|
|
2259
|
-
const [failureClock, setFailureClock] = (0,
|
|
2260
|
-
(0,
|
|
2317
|
+
const [failureClock, setFailureClock] = (0, import_react14.useState)(0);
|
|
2318
|
+
(0, import_react14.useEffect)(() => {
|
|
2261
2319
|
const timer = setInterval(() => setFailureClock((tick) => tick + 1), 3e4);
|
|
2262
2320
|
return () => clearInterval(timer);
|
|
2263
2321
|
}, []);
|
|
2264
|
-
const runtimeUnplayableTrackIds = (0,
|
|
2322
|
+
const runtimeUnplayableTrackIds = (0, import_react14.useMemo)(() => new Set(
|
|
2265
2323
|
(trackList?.tracks ?? []).filter((track) => isSong(track) && track.youtubeVideo && hasPlaybackFailure(track.youtubeVideo.id)).map((track) => track.uuid)
|
|
2266
2324
|
), [trackList, hasPlaybackFailure, playerTrackObject, failureClock]);
|
|
2267
2325
|
const { showTrackListSidebar } = useTrackListSidebarVisibility();
|
|
2268
2326
|
const playback = usePlaybackContext();
|
|
2269
2327
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2270
|
-
const pageSchema = (0,
|
|
2271
|
-
const latestPlayRequestRef = (0,
|
|
2272
|
-
const startingPlaybackRef = (0,
|
|
2273
|
-
const loadedContextRef = (0,
|
|
2274
|
-
const autoAdvanceScrollRequestIdRef = (0,
|
|
2275
|
-
const delayedTrackLoadRef = (0,
|
|
2276
|
-
const loadingOriginRef = (0,
|
|
2277
|
-
const pendingAdvanceRef = (0,
|
|
2278
|
-
const clearDelayedTrackLoad = (0,
|
|
2328
|
+
const pageSchema = (0, import_react14.useMemo)(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
|
|
2329
|
+
const latestPlayRequestRef = (0, import_react14.useRef)(0);
|
|
2330
|
+
const startingPlaybackRef = (0, import_react14.useRef)(false);
|
|
2331
|
+
const loadedContextRef = (0, import_react14.useRef)(playback.key);
|
|
2332
|
+
const autoAdvanceScrollRequestIdRef = (0, import_react14.useRef)(0);
|
|
2333
|
+
const delayedTrackLoadRef = (0, import_react14.useRef)(null);
|
|
2334
|
+
const loadingOriginRef = (0, import_react14.useRef)(null);
|
|
2335
|
+
const pendingAdvanceRef = (0, import_react14.useRef)(null);
|
|
2336
|
+
const clearDelayedTrackLoad = (0, import_react14.useCallback)(() => {
|
|
2279
2337
|
if (delayedTrackLoadRef.current !== null) {
|
|
2280
2338
|
clearTimeout(delayedTrackLoadRef.current);
|
|
2281
2339
|
delayedTrackLoadRef.current = null;
|
|
2282
2340
|
}
|
|
2283
2341
|
}, []);
|
|
2284
|
-
const requestAutoAdvanceScroll = (0,
|
|
2342
|
+
const requestAutoAdvanceScroll = (0, import_react14.useCallback)((trackUuid) => {
|
|
2285
2343
|
setAutoAdvanceScrollRequest({ id: ++autoAdvanceScrollRequestIdRef.current, trackUuid });
|
|
2286
2344
|
}, []);
|
|
2287
|
-
const loadTrackAfterSkipDelay = (0,
|
|
2345
|
+
const loadTrackAfterSkipDelay = (0, import_react14.useCallback)(
|
|
2288
2346
|
(trackUuid) => {
|
|
2289
2347
|
clearDelayedTrackLoad();
|
|
2290
2348
|
delayedTrackLoadRef.current = setTimeout(() => {
|
|
@@ -2294,7 +2352,7 @@ function TrackListProvider({
|
|
|
2294
2352
|
},
|
|
2295
2353
|
[clearDelayedTrackLoad, loadTrackForPlayer]
|
|
2296
2354
|
);
|
|
2297
|
-
const fetchTracksPage = (0,
|
|
2355
|
+
const fetchTracksPage = (0, import_react14.useCallback)(
|
|
2298
2356
|
async (uuid, scope, page, from, selection, artistUuid) => {
|
|
2299
2357
|
const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
|
|
2300
2358
|
if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
|
|
@@ -2309,8 +2367,8 @@ function TrackListProvider({
|
|
|
2309
2367
|
},
|
|
2310
2368
|
[fetch2, pageSchema]
|
|
2311
2369
|
);
|
|
2312
|
-
const cataloguePageSchema = (0,
|
|
2313
|
-
const fetchCatalogueTracksPage = (0,
|
|
2370
|
+
const cataloguePageSchema = (0, import_react14.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
|
|
2371
|
+
const fetchCatalogueTracksPage = (0, import_react14.useCallback)(
|
|
2314
2372
|
async (origin, page) => {
|
|
2315
2373
|
const params = {
|
|
2316
2374
|
...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
|
|
@@ -2338,7 +2396,7 @@ function TrackListProvider({
|
|
|
2338
2396
|
},
|
|
2339
2397
|
[fetch2, cataloguePageSchema]
|
|
2340
2398
|
);
|
|
2341
|
-
const advanceAfterTrackEnd = (0,
|
|
2399
|
+
const advanceAfterTrackEnd = (0, import_react14.useCallback)(
|
|
2342
2400
|
(event) => {
|
|
2343
2401
|
const completedTrackId = event?.trackId ?? selectedTrack?.uuid;
|
|
2344
2402
|
if (!completedTrackId || !trackList) return;
|
|
@@ -2370,11 +2428,11 @@ function TrackListProvider({
|
|
|
2370
2428
|
selectedTrack
|
|
2371
2429
|
]
|
|
2372
2430
|
);
|
|
2373
|
-
(0,
|
|
2431
|
+
(0, import_react14.useEffect)(() => {
|
|
2374
2432
|
setOnTrackEnd(trackList && selectedTrack ? advanceAfterTrackEnd : null);
|
|
2375
2433
|
return () => setOnTrackEnd(null);
|
|
2376
2434
|
}, [advanceAfterTrackEnd, trackList, selectedTrack, setOnTrackEnd]);
|
|
2377
|
-
const toTrackAtPosition = (0,
|
|
2435
|
+
const toTrackAtPosition = (0, import_react14.useCallback)(
|
|
2378
2436
|
(position) => {
|
|
2379
2437
|
if (trackList && position >= 0 && position < trackList.tracks.length) {
|
|
2380
2438
|
clearDelayedTrackLoad();
|
|
@@ -2384,7 +2442,7 @@ function TrackListProvider({
|
|
|
2384
2442
|
},
|
|
2385
2443
|
[clearDelayedTrackLoad, trackList]
|
|
2386
2444
|
);
|
|
2387
|
-
const playNewTrackListFromTrackUuid = (0,
|
|
2445
|
+
const playNewTrackListFromTrackUuid = (0, import_react14.useCallback)(
|
|
2388
2446
|
(track, scope) => {
|
|
2389
2447
|
latestPlayRequestRef.current++;
|
|
2390
2448
|
startingPlaybackRef.current = false;
|
|
@@ -2400,7 +2458,7 @@ function TrackListProvider({
|
|
|
2400
2458
|
},
|
|
2401
2459
|
[clearDelayedTrackLoad, showTrackListSidebar, loadTrackForPlayer]
|
|
2402
2460
|
);
|
|
2403
|
-
const playNewTrackListFromGenrePlaylist = (0,
|
|
2461
|
+
const playNewTrackListFromGenrePlaylist = (0, import_react14.useCallback)(
|
|
2404
2462
|
async (genrePlaylist, scope, options) => {
|
|
2405
2463
|
clearDelayedTrackLoad();
|
|
2406
2464
|
const request = ++latestPlayRequestRef.current;
|
|
@@ -2434,7 +2492,7 @@ function TrackListProvider({
|
|
|
2434
2492
|
},
|
|
2435
2493
|
[clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
2436
2494
|
);
|
|
2437
|
-
const playCatalogue = (0,
|
|
2495
|
+
const playCatalogue = (0, import_react14.useCallback)(
|
|
2438
2496
|
async (origin) => {
|
|
2439
2497
|
clearDelayedTrackLoad();
|
|
2440
2498
|
const request = ++latestPlayRequestRef.current;
|
|
@@ -2467,7 +2525,7 @@ function TrackListProvider({
|
|
|
2467
2525
|
},
|
|
2468
2526
|
[clearDelayedTrackLoad, fetchCatalogueTracksPage, showTrackListSidebar, loadTrackForPlayer]
|
|
2469
2527
|
);
|
|
2470
|
-
const playNewTrackListFromArtist = (0,
|
|
2528
|
+
const playNewTrackListFromArtist = (0, import_react14.useCallback)(
|
|
2471
2529
|
async (artist, scope, options) => {
|
|
2472
2530
|
if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
|
|
2473
2531
|
if (options.selection && !options.genreUuid) throw new Error("A genre selection requires a genre");
|
|
@@ -2475,15 +2533,15 @@ function TrackListProvider({
|
|
|
2475
2533
|
},
|
|
2476
2534
|
[playCatalogue]
|
|
2477
2535
|
);
|
|
2478
|
-
const playNewTrackListFromGenreCatalogue = (0,
|
|
2536
|
+
const playNewTrackListFromGenreCatalogue = (0, import_react14.useCallback)(
|
|
2479
2537
|
async (genre, scope, options) => {
|
|
2480
2538
|
if (scope !== "reference") throw new Error("Genre catalogues only support the reference scope");
|
|
2481
2539
|
return playCatalogue(new TrackListOriginFromGenreCatalogue(genre, scope, options?.startSongUuid, options?.selection));
|
|
2482
2540
|
},
|
|
2483
2541
|
[playCatalogue]
|
|
2484
2542
|
);
|
|
2485
|
-
const contextKeyRef = (0,
|
|
2486
|
-
(0,
|
|
2543
|
+
const contextKeyRef = (0, import_react14.useRef)(playback.key);
|
|
2544
|
+
(0, import_react14.useEffect)(() => {
|
|
2487
2545
|
if (contextKeyRef.current === playback.key) return;
|
|
2488
2546
|
contextKeyRef.current = playback.key;
|
|
2489
2547
|
if (loadedContextRef.current === playback.key) return;
|
|
@@ -2535,7 +2593,7 @@ function TrackListProvider({
|
|
|
2535
2593
|
});
|
|
2536
2594
|
}
|
|
2537
2595
|
}, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch2]);
|
|
2538
|
-
const updateTrack = (0,
|
|
2596
|
+
const updateTrack = (0, import_react14.useCallback)((track) => {
|
|
2539
2597
|
setTrackList((prev) => {
|
|
2540
2598
|
if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
|
|
2541
2599
|
const tracks = prev.tracks.map((listed) => listed.uuid === track.uuid ? track : listed);
|
|
@@ -2543,7 +2601,7 @@ function TrackListProvider({
|
|
|
2543
2601
|
});
|
|
2544
2602
|
setSelectedTrack((prev) => prev?.uuid === track.uuid ? track : prev);
|
|
2545
2603
|
}, []);
|
|
2546
|
-
const loadMore = (0,
|
|
2604
|
+
const loadMore = (0, import_react14.useCallback)(async () => {
|
|
2547
2605
|
if (!trackList || trackList.nextPage === null) return;
|
|
2548
2606
|
const origin = trackList.origin;
|
|
2549
2607
|
if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
|
|
@@ -2567,7 +2625,7 @@ function TrackListProvider({
|
|
|
2567
2625
|
const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
|
|
2568
2626
|
const hasNextTrack = nextTrack !== null || selectedTrackIndex >= 0 && trackList?.nextPage != null;
|
|
2569
2627
|
const hasPreviousTrack = previousTrack !== null;
|
|
2570
|
-
const playNextTrack = (0,
|
|
2628
|
+
const playNextTrack = (0, import_react14.useCallback)(() => {
|
|
2571
2629
|
if (!trackList || !selectedTrack || selectedTrackIndex < 0) return;
|
|
2572
2630
|
clearDelayedTrackLoad();
|
|
2573
2631
|
if (nextTrack) {
|
|
@@ -2584,7 +2642,7 @@ function TrackListProvider({
|
|
|
2584
2642
|
console.error("Failed to load more tracks:", error);
|
|
2585
2643
|
});
|
|
2586
2644
|
}, [clearDelayedTrackLoad, trackList, loadMore, loadTrackForPlayer, nextTrack, selectedTrack, selectedTrackIndex]);
|
|
2587
|
-
const playPreviousTrack = (0,
|
|
2645
|
+
const playPreviousTrack = (0, import_react14.useCallback)(() => {
|
|
2588
2646
|
if (!previousTrack) return;
|
|
2589
2647
|
clearDelayedTrackLoad();
|
|
2590
2648
|
pendingAdvanceRef.current = null;
|
|
@@ -2592,7 +2650,7 @@ function TrackListProvider({
|
|
|
2592
2650
|
setSelectedTrack(previousTrack);
|
|
2593
2651
|
loadTrackForPlayer(previousTrack.uuid);
|
|
2594
2652
|
}, [clearDelayedTrackLoad, loadTrackForPlayer, previousTrack, requestAutoAdvanceScroll]);
|
|
2595
|
-
(0,
|
|
2653
|
+
(0, import_react14.useEffect)(() => {
|
|
2596
2654
|
const pending = pendingAdvanceRef.current;
|
|
2597
2655
|
if (!pending) return;
|
|
2598
2656
|
if (!trackList || trackList.origin !== pending.origin || selectedTrack?.uuid !== pending.trackId) {
|
|
@@ -2626,15 +2684,15 @@ function TrackListProvider({
|
|
|
2626
2684
|
hasPlaybackFailure,
|
|
2627
2685
|
selectedTrack
|
|
2628
2686
|
]);
|
|
2629
|
-
(0,
|
|
2630
|
-
(0,
|
|
2687
|
+
(0, import_react14.useEffect)(() => clearDelayedTrackLoad, [clearDelayedTrackLoad]);
|
|
2688
|
+
(0, import_react14.useEffect)(() => {
|
|
2631
2689
|
if (!trackList || trackList.nextPage === null || !selectedTrack) return;
|
|
2632
2690
|
const index = trackList.tracks.findIndex((track) => track.uuid === selectedTrack.uuid);
|
|
2633
2691
|
if (index !== -1 && trackList.tracks.length - index <= AUTO_LOAD_REMAINING_TRACKS) {
|
|
2634
2692
|
loadMore().catch((error) => console.error("Failed to load more tracks:", error));
|
|
2635
2693
|
}
|
|
2636
2694
|
}, [trackList, selectedTrack, loadMore]);
|
|
2637
|
-
const value = (0,
|
|
2695
|
+
const value = (0, import_react14.useMemo)(
|
|
2638
2696
|
() => ({
|
|
2639
2697
|
trackList,
|
|
2640
2698
|
selectedTrack,
|
|
@@ -2676,7 +2734,7 @@ function TrackListProvider({
|
|
|
2676
2734
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TrackListContext.Provider, { value, children });
|
|
2677
2735
|
}
|
|
2678
2736
|
function useTrackList() {
|
|
2679
|
-
const context = (0,
|
|
2737
|
+
const context = (0, import_react14.useContext)(TrackListContext);
|
|
2680
2738
|
if (!context) {
|
|
2681
2739
|
throw new Error("useTrackList must be used within a TrackListProvider");
|
|
2682
2740
|
}
|
|
@@ -2684,14 +2742,14 @@ function useTrackList() {
|
|
|
2684
2742
|
}
|
|
2685
2743
|
|
|
2686
2744
|
// src/genre-tree/ArtistNames.tsx
|
|
2687
|
-
var
|
|
2745
|
+
var import_react15 = require("react");
|
|
2688
2746
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2689
2747
|
function ArtistNames({
|
|
2690
2748
|
artists,
|
|
2691
2749
|
renderArtistLink
|
|
2692
2750
|
}) {
|
|
2693
2751
|
if (!renderArtistLink) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist) => artist.name).join(", ") });
|
|
2694
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react15.Fragment, { children: [
|
|
2695
2753
|
index > 0 && ", ",
|
|
2696
2754
|
renderArtistLink(artist)
|
|
2697
2755
|
] }, artist.uuid)) });
|
|
@@ -2745,6 +2803,9 @@ var capitalizeFirstLetter = (string) => {
|
|
|
2745
2803
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
2746
2804
|
};
|
|
2747
2805
|
|
|
2806
|
+
// src/genre-tree/lib/genre-search.ts
|
|
2807
|
+
var searchGenrePlaylistsByName = (genrePlaylists, query) => rankByName(genrePlaylists, query, (genrePlaylist) => genrePlaylist.name, (genrePlaylist) => genrePlaylist.viewsCount ?? 0);
|
|
2808
|
+
|
|
2748
2809
|
// src/genre-tree/lib/reparent-candidates.ts
|
|
2749
2810
|
var hasCriteria = (genrePlaylist) => genrePlaylist.criteria !== null;
|
|
2750
2811
|
var getReparentCandidates = (genrePlaylists, genrePlaylistUuid) => {
|
|
@@ -2848,6 +2909,7 @@ function editGenreSongPages(data, edit) {
|
|
|
2848
2909
|
artistEndpoints,
|
|
2849
2910
|
artistQueryKeys,
|
|
2850
2911
|
capitalizeFirstLetter,
|
|
2912
|
+
createNameIndex,
|
|
2851
2913
|
defaultGenreMusicSelection,
|
|
2852
2914
|
editGenreSongPages,
|
|
2853
2915
|
foldSearchText,
|
|
@@ -2874,6 +2936,7 @@ function editGenreSongPages(data, edit) {
|
|
|
2874
2936
|
musicBrainzRecordingUrl,
|
|
2875
2937
|
pruneGenrePlaylistsForArtist,
|
|
2876
2938
|
rankByName,
|
|
2939
|
+
rankNameIndex,
|
|
2877
2940
|
searchGenrePlaylistsByName,
|
|
2878
2941
|
songUnplayableReason,
|
|
2879
2942
|
trigramSimilarity,
|