import { Title } from "@solidjs/meta"; import { Show } from "solid-js"; import { Loading } from "solid-js"; import { Router } from "./router"; import { connectionSignal } from "./lib/connection"; import { startFavoritesSync } from "./lib/favorites"; import { startLibrarySync } from "./lib/harvest"; import { createLibraryQueryStore, LibraryQueryProvider } from "./lib/library/query"; import { player, startPlayerSync } from "./lib/player"; import { startMediaSessionForApp } from "./lib/player/mediasession"; import { startLyricsSync } from "./lib/lyrics"; import { startAccentSync, startThemeSync } from "./lib/theme"; import LoginDialog from "./components/LoginDialog"; import { CommandLine } from "./components/CommandLine"; import { PlayerBar } from "./components/PlayerBar"; import { TimeAuditModal } from "./components/TimeAuditModal"; import { LadderAuditModal } from "./components/LadderAuditModal"; import { ladderAuditModal } from "./lib/lyrics/audit"; import { auditModal } from "./lib/loadaudit"; import "./lib/perf"; // dev-only long-task watchdog (self-starting) import "./App.css"; // The app root. Until a server connection is configured, the whole app is // gated behind the login modal; once connected, the router takes over. There is // no app bar: the toolbar in the view is the top of the screen, and it carries // the harvest readout itself (components/HarvestProgress.tsx). At the other end of the // screen are the two things that belong to the session rather than to whichever view is // up — the command line and the transport, stacked in that order below the router // (components/CommandLine.tsx, components/PlayerBar.tsx). Host/library // switching gets its own UI later (connection.ts already supports swapping). export default function App() { // Set the theme first, before anything that reads the effective one: it puts `data-theme` // on the document (dark by default, light when asked or when `system` and the machine is // light), and the accent's derivation reads that theme to decide how light its ink is. startThemeSync(); // start the shared library harvest; idles until a connection exists and // re-runs when it changes (owned by this component's reactive root) startLibrarySync(); // ...and tie the shared player to that same lifecycle: a server switch // cannot leave the previous server's stream playing startPlayerSync(); // ...and to the operating system's copy of the transport, which is the same store // seen from the other end of the wire: lock-screen credits and sleeve, the headset's // buttons, the media key. It forwards and decides nothing, so the keyboard keeps // every answer it already had (lib/player/mediasession.ts). startMediaSessionForApp(); // ...and the same lifecycle for the hearts: one getStarred per connection, read // independently of the crawl so the rows already on screen can wear theirs startFavoritesSync(); // ...and for the accent, which is asked of the server rather than guessed at: the // record being heard lends its hue and its chroma, and the app keeps its own // lightness (lib/theme/accent.ts explains the split). What the accent follows is the // cover on the transport and nothing else — not the grid, not a hover — because the // colour is drawn on the bar and the reader reads it as a statement about what is // playing, so it is only ever allowed to answer that question. Which cover that is has // one answer (`library/cover.ts`): a track wearing its record's sleeve lends the hue of // the sleeve it is actually wearing, not of a picture its own file never had. startAccentSync({ connection: connectionSignal, track: () => player().current(), }); // ...and for the lyric, which is asked of LRCLIB rather than of the server: the bar names the // track, and one question per track goes out to a third-party host that identifies this app by // name and asks to be asked slowly (`lib/lyrics/lrclib.ts` holds both halves of that promise). // It follows the same thing the accent does — the record on the transport — because that is the // track the words have to be right about, and it is the only place the question is ever asked. startLyricsSync(() => player().current()); // The needle the library is filtered by, created here rather than at module scope so // that a fresh root — a reload, or a test's re-render — reads it off the disk again, // and shared from here because the two components that touch it are not in a // parent-child relation: the list narrows itself by it from inside the router, and the // command line types it from beside the transport. const libraryQuery = createLibraryQueryStore(); return ( }> {(props) => ( <> hackermusic loading…}> {props.children} {/* Outside the router, so both survive navigation: the command line and the transport belong to the session rather than to whichever view is up. One asks for the move, the other makes it, and they are stacked in that order at the bottom of the shell. */} {/* The load flamegraph, outside the router with the other two: `:timeaudit` is a question about the session — what went into the track the bar is showing — and it outlives whichever view is up, including the one you navigated to while a load is still being drawn. Nothing renders it unless the audit says so. */} {(audit) => } {/* The lyric ladder's account of one track, raised by `:lyricsaudit` and mounted by the app for the same reason the flamegraph is: it is a question about the session rather than about whichever view is up, and it has to survive navigating away to go and look at the library entry for the track it is complaining about. */} {(audit) => } )} ); }