@behindthemusictree/app-kit 41.0.0 → 42.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.
@@ -24,8 +24,10 @@ import {
24
24
  import {
25
25
  GenrePlaylistUuidSchema,
26
26
  GenreUuidSchema,
27
- toGenreUuid
28
- } from "./chunk-X2QEQR6H.js";
27
+ toArtistUuid,
28
+ toGenreUuid,
29
+ toSongUuid
30
+ } from "./chunk-RGHDVBEY.js";
29
31
 
30
32
  // src/genre-tree/useGenre.ts
31
33
  import { z as z20 } from "zod";
@@ -657,9 +659,6 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
657
659
  });
658
660
  }
659
661
 
660
- // src/genre-tree/useArtist.ts
661
- import { z as z22 } from "zod";
662
-
663
662
  // src/genre-tree/schemas/artist-detailed.ts
664
663
  import { z as z21 } from "zod";
665
664
  var ArtistMembershipSchema = z21.object({
@@ -681,6 +680,15 @@ var ARTIST_LINK_KINDS = [
681
680
  "social"
682
681
  ];
683
682
  var ArtistImageSchema = CommonsImageSchema;
683
+ var ArtistOriginSchema = z21.object({
684
+ name: z21.string(),
685
+ kind: z21.string(),
686
+ source: z21.enum(["begin_area", "area"]),
687
+ wikidataId: z21.string().nullable(),
688
+ longitude: z21.number().nullable(),
689
+ latitude: z21.number().nullable(),
690
+ regionId: z21.string().nullable()
691
+ });
684
692
  var ArtistDetailedSchema = z21.object({
685
693
  uuid: z21.string().uuid(),
686
694
  name: z21.string(),
@@ -704,7 +712,8 @@ var ArtistDetailedSchema = z21.object({
704
712
  ),
705
713
  tracksCount: z21.number().int(),
706
714
  playableTracksCount: z21.number().int(),
707
- image: ArtistImageSchema.nullable()
715
+ image: ArtistImageSchema.nullable(),
716
+ origin: ArtistOriginSchema.nullable()
708
717
  });
709
718
 
710
719
  // src/genre-tree/api/artists/queryKeys.ts
@@ -725,10 +734,11 @@ var artistEndpoints = {
725
734
  // src/genre-tree/useArtist.ts
726
735
  function useArtist(uuid, getBackendBaseUrl) {
727
736
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
728
- const isUuid = uuid !== null && z22.string().uuid().safeParse(uuid).success;
737
+ const id = toArtistUuid(uuid);
738
+ const isUuid = id !== null;
729
739
  const { data, isPending, error } = useQueryWithParse({
730
- queryKey: artistQueryKeys.detail(uuid),
731
- queryFn: () => fetch(artistEndpoints.detail(uuid), true, false),
740
+ queryKey: artistQueryKeys.detail(id),
741
+ queryFn: () => fetch(artistEndpoints.detail(id), true, false),
732
742
  schema: ArtistDetailedSchema,
733
743
  enabled: isUuid,
734
744
  retry: resourceRetry,
@@ -739,19 +749,19 @@ function useArtist(uuid, getBackendBaseUrl) {
739
749
  }
740
750
 
741
751
  // src/genre-tree/schemas/artist-search.ts
742
- import { z as z23 } from "zod";
743
- var ArtistSearchResultSchema = z23.object({
744
- uuid: z23.string().uuid(),
745
- name: z23.string(),
746
- disambiguation: z23.string().nullable(),
747
- type: z23.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
748
- country: z23.string().nullable(),
749
- beginYear: z23.number().int().nullable(),
750
- endYear: z23.number().int().nullable(),
751
- matchedAlias: z23.string().nullable(),
752
- recordingCount: z23.number().int()
752
+ import { z as z22 } from "zod";
753
+ var ArtistSearchResultSchema = z22.object({
754
+ uuid: z22.string().uuid(),
755
+ name: z22.string(),
756
+ disambiguation: z22.string().nullable(),
757
+ type: z22.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
758
+ country: z22.string().nullable(),
759
+ beginYear: z22.number().int().nullable(),
760
+ endYear: z22.number().int().nullable(),
761
+ matchedAlias: z22.string().nullable(),
762
+ recordingCount: z22.number().int()
753
763
  });
754
- var ArtistSearchResultsSchema = z23.array(ArtistSearchResultSchema);
764
+ var ArtistSearchResultsSchema = z22.array(ArtistSearchResultSchema);
755
765
 
756
766
  // src/genre-tree/useRemoteSearch.ts
757
767
  import { keepPreviousData } from "@tanstack/react-query";
@@ -805,11 +815,8 @@ function useArtistSearch(getBackendBaseUrl, text) {
805
815
  return { artists: results, isError, settled, pending };
806
816
  }
807
817
 
808
- // src/genre-tree/useSong.ts
809
- import { z as z25 } from "zod";
810
-
811
818
  // src/genre-tree/schemas/song/detailed.ts
812
- import { z as z24 } from "zod";
819
+ import { z as z23 } from "zod";
813
820
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
814
821
  not_found: "Video unavailable",
815
822
  not_embeddable: "Embedding disabled",
@@ -818,23 +825,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
818
825
  region_whitelisted: "Region restricted"
819
826
  };
820
827
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
821
- var YoutubeAvailabilitySchema = z24.object({
822
- status: z24.enum(["eligible", "blocked", "unknown"]),
823
- reason: z24.string().nullable(),
824
- country: z24.string().nullable()
828
+ var YoutubeAvailabilitySchema = z23.object({
829
+ status: z23.enum(["eligible", "blocked", "unknown"]),
830
+ reason: z23.string().nullable(),
831
+ country: z23.string().nullable()
825
832
  });
826
833
  var SongDetailedSchema = TrackBaseSchema.extend({
827
- youtubeVideo: z24.object({
828
- id: z24.string(),
834
+ youtubeVideo: z23.object({
835
+ id: z23.string(),
829
836
  availability: YoutubeAvailabilitySchema.optional(),
830
837
  // null = playable
831
- unplayableReason: z24.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
832
- viewCount: z24.number().int().nullable().optional()
838
+ unplayableReason: z23.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
839
+ viewCount: z23.number().int().nullable().optional()
833
840
  }).nullable(),
834
841
  // null for hand-made/admin songs
835
- musicbrainzRecordingId: z24.string().uuid().nullable(),
836
- firstReleaseYear: z24.number().int().nullable().optional(),
837
- essentialGenres: z24.array(CriteriaMinimumSchema).optional()
842
+ musicbrainzRecordingId: z23.string().uuid().nullable(),
843
+ firstReleaseYear: z23.number().int().nullable().optional(),
844
+ essentialGenres: z23.array(CriteriaMinimumSchema).optional()
838
845
  });
839
846
  var NO_VIDEO_LABEL = "No video available";
840
847
  function isSong(track) {
@@ -852,11 +859,12 @@ function musicBrainzRecordingUrl(song) {
852
859
 
853
860
  // src/genre-tree/useSong.ts
854
861
  function useSong(uuid, getBackendBaseUrl) {
855
- const isUuid = uuid !== null && z25.string().uuid().safeParse(uuid).success;
862
+ const id = toSongUuid(uuid);
863
+ const isUuid = id !== null;
856
864
  const { data, isPending, error } = usePlaybackQuery({
857
865
  getBackendBaseUrl,
858
- queryKey: libraryQueryKeys.reference.songs.detail(uuid),
859
- queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.detail(uuid), true, false, { signal }),
866
+ queryKey: libraryQueryKeys.reference.songs.detail(id),
867
+ queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.detail(id), true, false, { signal }),
860
868
  schema: SongDetailedSchema,
861
869
  enabled: isUuid,
862
870
  retry: resourceRetry,
@@ -867,24 +875,25 @@ function useSong(uuid, getBackendBaseUrl) {
867
875
  }
868
876
 
869
877
  // src/genre-tree/schemas/song-history.ts
870
- import { z as z26 } from "zod";
871
- var SongHistoryEntrySchema = z26.object({
872
- uuid: z26.string().uuid(),
873
- action: z26.string(),
874
- actorPseudo: z26.string().nullable(),
875
- oldValue: z26.string().nullable(),
876
- newValue: z26.string().nullable(),
877
- createdOn: z26.string()
878
+ import { z as z24 } from "zod";
879
+ var SongHistoryEntrySchema = z24.object({
880
+ uuid: z24.string().uuid(),
881
+ action: z24.string(),
882
+ actorPseudo: z24.string().nullable(),
883
+ oldValue: z24.string().nullable(),
884
+ newValue: z24.string().nullable(),
885
+ createdOn: z24.string()
878
886
  });
879
- var SongHistorySchema = z26.array(SongHistoryEntrySchema);
887
+ var SongHistorySchema = z24.array(SongHistoryEntrySchema);
880
888
 
881
889
  // src/genre-tree/useSongHistory.ts
882
890
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
883
- const active = enabled && uuid !== null;
891
+ const id = toSongUuid(uuid);
892
+ const active = enabled && id !== null;
884
893
  const { data, isPending, error } = usePlaybackQuery({
885
894
  getBackendBaseUrl,
886
- queryKey: libraryQueryKeys.reference.songs.history(uuid),
887
- queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.history(uuid), true, false, { signal }),
895
+ queryKey: libraryQueryKeys.reference.songs.history(id),
896
+ queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.history(id), true, false, { signal }),
888
897
  schema: SongHistorySchema,
889
898
  enabled: active,
890
899
  context: "useSongHistory"
@@ -896,20 +905,20 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
896
905
  }
897
906
 
898
907
  // src/genre-tree/schemas/song-search.ts
899
- import { z as z27 } from "zod";
900
- var SongSearchResultSchema = z27.object({
901
- uuid: z27.string().uuid(),
902
- title: z27.string(),
903
- artists: z27.array(ArtistMinimumSchema),
908
+ import { z as z25 } from "zod";
909
+ var SongSearchResultSchema = z25.object({
910
+ uuid: z25.string().uuid(),
911
+ title: z25.string(),
912
+ artists: z25.array(ArtistMinimumSchema),
904
913
  // null for songs not yet linked to a genre.
905
914
  genre: CriteriaMinimumSchema.nullable(),
906
- youtubeVideo: z27.object({
907
- id: z27.string(),
908
- unplayableReason: z27.string().nullable()
915
+ youtubeVideo: z25.object({
916
+ id: z25.string(),
917
+ unplayableReason: z25.string().nullable()
909
918
  }).nullable(),
910
- firstReleaseYear: z27.number().int().nullable()
919
+ firstReleaseYear: z25.number().int().nullable()
911
920
  });
912
- var SongSearchResultsSchema = z27.array(SongSearchResultSchema);
921
+ var SongSearchResultsSchema = z25.array(SongSearchResultSchema);
913
922
  function isSongSearchResultPlayable(result) {
914
923
  return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
915
924
  }
@@ -937,18 +946,18 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
937
946
 
938
947
  // src/genre-tree/useArtistGenreCounts.ts
939
948
  import { keepPreviousData as keepPreviousData2 } from "@tanstack/react-query";
940
- import { z as z29 } from "zod";
949
+ import { z as z27 } from "zod";
941
950
 
942
951
  // src/genre-tree/schemas/artist-genre-count.ts
943
- import { z as z28 } from "zod";
944
- var ArtistGenreCountSchema = z28.object({
952
+ import { z as z26 } from "zod";
953
+ var ArtistGenreCountSchema = z26.object({
945
954
  ...GenreCountsSchema.shape,
946
955
  catalogue: GenreCatalogueCountsSchema,
947
956
  genrePlaylist: GenrePlaylistUuidSchema,
948
957
  /** Legacy catalogue count for the default selection. */
949
- songsCount: z28.number().int().nonnegative(),
958
+ songsCount: z26.number().int().nonnegative(),
950
959
  /** Legacy playlist count for the default selection. */
951
- tracksCount: z28.number().int().nonnegative()
960
+ tracksCount: z26.number().int().nonnegative()
952
961
  }).superRefine((row, ctx) => {
953
962
  const counts = GenreCatalogueCountsSchema.safeParse(row);
954
963
  if (!counts.success) {
@@ -961,11 +970,12 @@ var ArtistGenreCountSchema = z28.object({
961
970
  // src/genre-tree/useArtistGenreCounts.ts
962
971
  function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
963
972
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
973
+ const id = toArtistUuid(artistUuid);
964
974
  return useQueryWithParse({
965
- queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid), "genreMusicV1"],
966
- queryFn: () => fetch(artistEndpoints.genreCounts(artistUuid), true, false),
967
- schema: z29.array(ArtistGenreCountSchema),
968
- enabled: artistUuid !== null,
975
+ queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), id), "genreMusicV1"],
976
+ queryFn: () => fetch(artistEndpoints.genreCounts(id), true, false),
977
+ schema: z27.array(ArtistGenreCountSchema),
978
+ enabled: id !== null,
969
979
  placeholderData: keepPreviousData2,
970
980
  retry: resourceRetry,
971
981
  context: "useArtistGenreCounts"
@@ -1124,32 +1134,32 @@ function useGenreSearch({
1124
1134
  }
1125
1135
 
1126
1136
  // src/genre-tree/schemas/genre-search.ts
1127
- import { z as z30 } from "zod";
1128
- var GenreSearchTreeNameSchema = z30.enum(["canonical", "regional"]);
1129
- var GenreSearchResultSchema = z30.object({
1137
+ import { z as z28 } from "zod";
1138
+ var GenreSearchTreeNameSchema = z28.enum(["canonical", "regional"]);
1139
+ var GenreSearchResultSchema = z28.object({
1130
1140
  /** Criteria (genre) uuid. */
1131
1141
  uuid: GenreUuidSchema,
1132
- name: z30.string(),
1142
+ name: z28.string(),
1133
1143
  /** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
1134
- wikidataId: z30.string().nullable(),
1135
- treeName: z30.string(),
1144
+ wikidataId: z28.string().nullable(),
1145
+ treeName: z28.string(),
1136
1146
  /** Null when the genre has no playlist in the tree, so it cannot be opened there. */
1137
1147
  genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1138
- root: z30.object({ uuid: GenreUuidSchema, name: z30.string() }),
1139
- isUmbrella: z30.boolean(),
1140
- viewsCount: z30.number().int()
1148
+ root: z28.object({ uuid: GenreUuidSchema, name: z28.string() }),
1149
+ isUmbrella: z28.boolean(),
1150
+ viewsCount: z28.number().int()
1141
1151
  });
1142
- var GenreSearchResultsSchema = z30.array(GenreSearchResultSchema);
1143
- var RegionGenreLexiconEntrySchema = z30.object({
1144
- wikidataId: z30.string(),
1152
+ var GenreSearchResultsSchema = z28.array(GenreSearchResultSchema);
1153
+ var RegionGenreLexiconEntrySchema = z28.object({
1154
+ wikidataId: z28.string(),
1145
1155
  uuid: GenreUuidSchema,
1146
- name: z30.string(),
1147
- treeName: z30.string(),
1156
+ name: z28.string(),
1157
+ treeName: z28.string(),
1148
1158
  genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1149
- isUmbrella: z30.boolean(),
1150
- viewsCount: z30.number().int()
1159
+ isUmbrella: z28.boolean(),
1160
+ viewsCount: z28.number().int()
1151
1161
  });
1152
- var RegionGenreLexiconSchema = z30.array(RegionGenreLexiconEntrySchema);
1162
+ var RegionGenreLexiconSchema = z28.array(RegionGenreLexiconEntrySchema);
1153
1163
 
1154
1164
  // src/genre-tree/useGenreRemoteSearch.ts
1155
1165
  var DEFAULT_RESULT_LIMIT2 = 8;
@@ -1229,9 +1239,10 @@ var projectGenrePlaylistsForArtist = (playlists, counts) => {
1229
1239
  // src/genre-tree/useVisibleGenrePlaylists.ts
1230
1240
  function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null }) {
1231
1241
  const { data: tree, isPending: isTreePending, isFetching: isTreeFetching, isError: isTreeError, refetch } = useListFullGenrePlaylists(scope, getBackendBaseUrl);
1232
- const counts = useArtistGenreCounts(artistUuid, getBackendBaseUrl);
1233
- const artistCounts = artistUuid !== null ? counts.data : void 0;
1234
- const isCountsLoading = artistUuid !== null && (counts.isPending || counts.isPlaceholderData);
1242
+ const validArtistUuid = toArtistUuid(artistUuid);
1243
+ const counts = useArtistGenreCounts(validArtistUuid, getBackendBaseUrl);
1244
+ const artistCounts = validArtistUuid !== null ? counts.data : void 0;
1245
+ const isCountsLoading = validArtistUuid !== null && (counts.isPending || counts.isPlaceholderData);
1235
1246
  const projection = useMemo2(() => {
1236
1247
  if (!tree) return { genrePlaylists: [], focusUuids: void 0 };
1237
1248
  return artistCounts ? projectGenrePlaylistsForArtist(tree, artistCounts) : { genrePlaylists: tree, focusUuids: void 0 };
@@ -1371,10 +1382,10 @@ function useGenreTreeViewState({
1371
1382
  import { createContext as createContext2, useState as useState5, useContext as useContext2, useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef3 } from "react";
1372
1383
 
1373
1384
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
1374
- import { z as z31 } from "zod";
1375
- var makeTrackPlaylistRelSchema = (trackSchema) => z31.object({
1385
+ import { z as z29 } from "zod";
1386
+ var makeTrackPlaylistRelSchema = (trackSchema) => z29.object({
1376
1387
  track: trackSchema,
1377
- position: z31.number().min(0)
1388
+ position: z29.number().min(0)
1378
1389
  });
1379
1390
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
1380
1391
 
@@ -2013,24 +2024,24 @@ function ArtistNames({
2013
2024
  }
2014
2025
 
2015
2026
  // src/genre-tree/schemas/mb-artist.ts
2016
- import { z as z32 } from "zod";
2017
- var MbArtistDetailedSchema = z32.object({
2018
- musicbrainzId: z32.string().uuid(),
2019
- name: z32.string(),
2027
+ import { z as z30 } from "zod";
2028
+ var MbArtistDetailedSchema = z30.object({
2029
+ musicbrainzId: z30.string().uuid(),
2030
+ name: z30.string(),
2020
2031
  musicbrainzLink: HttpUrlSchema
2021
2032
  });
2022
2033
 
2023
2034
  // src/genre-tree/schemas/mb-recording.ts
2024
- import { z as z33 } from "zod";
2025
- var MbRecordingDetailedSchema = z33.object({
2026
- musicbrainzId: z33.string().uuid(),
2027
- title: z33.string(),
2028
- score: z33.number(),
2029
- musicbrainzArtists: z33.array(MbArtistDetailedSchema),
2035
+ import { z as z31 } from "zod";
2036
+ var MbRecordingDetailedSchema = z31.object({
2037
+ musicbrainzId: z31.string().uuid(),
2038
+ title: z31.string(),
2039
+ score: z31.number(),
2040
+ musicbrainzArtists: z31.array(MbArtistDetailedSchema),
2030
2041
  musicbrainzLink: HttpUrlSchema,
2031
- durationInSec: z33.number().min(0).nullable().optional(),
2032
- durationStrInHourMinSec: z33.string().nullable().optional(),
2033
- releaseDate: z33.union([z33.string().datetime(), z33.string()]).transform((val) => {
2042
+ durationInSec: z31.number().min(0).nullable().optional(),
2043
+ durationStrInHourMinSec: z31.string().nullable().optional(),
2044
+ releaseDate: z31.union([z31.string().datetime(), z31.string()]).transform((val) => {
2034
2045
  try {
2035
2046
  const date = new Date(val);
2036
2047
  if (isNaN(date.getTime())) {
@@ -2152,6 +2163,7 @@ export {
2152
2163
  useDeleteGenre,
2153
2164
  ARTIST_LINK_KINDS,
2154
2165
  ArtistImageSchema,
2166
+ ArtistOriginSchema,
2155
2167
  ArtistDetailedSchema,
2156
2168
  artistQueryKeys,
2157
2169
  artistEndpoints,
@@ -2227,4 +2239,4 @@ export {
2227
2239
  getReparentCandidates,
2228
2240
  editGenreSongPages
2229
2241
  };
2230
- //# sourceMappingURL=chunk-4E3YMYDH.js.map
2242
+ //# sourceMappingURL=chunk-QNBZQZEL.js.map