Two lockstep-versioned packages for BehindTheMusicTree React apps, consumed by
grow-the-music-tree-frontend and hear-the-music-tree-frontend:
@behindthemusictree/app-kit— headless: transport, auth, popup state, player, and genre-tree data and state hooks. No styling.@behindthemusictree/app-kit-ui— the styled BTMT components built on the hooks above, themed through CSS variables. See its README for the theme tokens.
Use app-kit alone to build a different design; add app-kit-ui for the BTMT one.
Published to npm, with a subpath per module (also re-exported from the root):
import { useFetchWrapper } from "@behindthemusictree/app-kit/transport";
import { SessionProvider, useAuthCallback } from "@behindthemusictree/app-kit/auth";
import { PopupProvider, usePopup } from "@behindthemusictree/app-kit/popup";
import { PlayerProvider, type PlayerTrack } from "@behindthemusictree/app-kit/player";
import { useGenreTreeViewState, useGenreSearch } from "@behindthemusictree/app-kit/genre-tree";transport— fetch wrapper, query client, app-error types, subdomain base-URL builderauth— session context, code-exchange core, logout,useAuthCallbackpopup— popup context and state,useConnectivityErrorPopup,useTrackUploadplayer— genericPlayerTrack-based playback context (consumer suppliesloadTrack)genre-tree— scope-parameterized ("me" | "reference") schemas, data hooks, track-list providers, and theuseGenreTreeViewState/useGenreSearchhooks
Pieces are decoupled from any single app: PlayerProvider takes an injected loadTrack,
useAuthCallback takes injected pathnames and handlers, and track lists take an optional
renderArtistLink.
reference reads (genres, genre playlists and tree, artists, songs, searches, region lexicon, song
history) are parsed with the Zod roots generated in @behindthemusictree/grow-api, a peer
dependency (>=0.1.0-next.9 <0.2.0). app-kit only adds what the generated roots cannot express:
count invariants, http(s)-only links and images, and re-parsing into the branded shapes shared with
the me scope. A contract test
(schemas/reference.contract.test.ts) parses captured responses from src/genre-tree/__fixtures__/grow/.
Reference genre detail and tree hooks require separate catalogue and playlist counts:
genreOnlyTracksCount and genreAndSubgenresTracksCount. Global genres expose inclusive
global, regional, and all counts; regional genres expose all. Inclusive counts already
contain the genre itself, and all is a deduplicated union. Personal playlists retain their
existing count contract.
GenreMusicSelection selects genreOnly or genreAndSubgenres with a subgenre scope. Use
genreMusicCount for the corresponding count and genreMusicQueryParams for API parameters.
Reference playback defaults to global subgenres for global genres and all subgenres for
regional genres. Playlist playback intersects actual members, including when filtered by artist;
the detail panel's song list describes the catalogue. Catalogue row playback uses
playNewTrackListFromGenreCatalogue (or the artist catalogue when filtered), so a playable
catalogue song need not belong to the genre playlist. Country availability can further restrict
the playback queue without changing global counts.
pnpm install
pnpm dev # builds the package in watch mode + runs apps/playgroundapps/playground is a small Vite app for exercising exported components against the staging
backend; it is not published. Its Playwright suite intercepts API and image requests with local
fixtures and runs at desktop and mobile widths. See verification commands.
Branch from main and open PRs against main. Squash merges use the PR title.
Release Please uses conventional PR titles to update both package versions in a single release PR. After it merges, CI tags the version and publishes both packages to npm through Trusted Publishing. See CONTRIBUTING.md.
GenreTreeView and useGenreTreeViewState accept selectedGenreUuid and
onSelectedGenreUuidChange. selectedGenreUuid is a raw string | null, so a URL
value can be passed as is: one that names no genre shows "Genre not found" in the
panel. onSelectedGenreUuidChange reports branded GenreUuid values. Renderer node IDs and playlist UUIDs remain internal
visualization/playback identities; they are never selection aliases.
A selected genre loads its own detail endpoint even when it has no node or
playlist. Family and ancestor navigation reports genre UUIDs. Genre share targets
use { kind: "genre", genreUuid, name, scope } (plus optional artist context).
Hosts should write ?genre=<genre UUID> consistently across views and handle old
playlist links as unavailable entities, without reinterpreting them.
Hosts injecting SearchGroups receive onSelectGenre(uuid) to open remote results
in the current view. A geographic region is optional context, independent of the
selected genre. Selection actions should reopen collapsed panels even when the
UUID is unchanged.