From 305f5e2231ae2907fee1115db121ab5c1a225226 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 01:18:29 +0000 Subject: [PATCH] chore: remove dead code + stop shipping dev sample WAVs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lean-down (#22): delete the two never-imported hooks useStarredTracks and usePlaylist, three unused CSS rules (.backbtn, .searchbar__clear, .view__head--row), and the unused --dock-h custom property. (storageEstimate is kept — it's now used by the import quota check.) PWA hygiene (#20): the public/samples/*.wav tones are dev-only seed fixtures but shipped in the build because they live in public/. Add a build-only Vite plugin that strips dist/samples from the production output (~2.7MB). The other #20 checklist items are intentionally skipped: a GitHub Pages deploy workflow is moot (the deploy is Firebase), and iOS splash screens are cosmetic (the dark background_color already covers the launch). Verified: production build succeeds with dist/samples absent and the deleted CSS gone from the bundle; dev still renders the library, search, and rows with no errors. Fixes #22. Fixes #20. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01FkDKh1Uo1a4D7n5wCKdcKF --- src/index.css | 11 ----------- src/state/useLibrary.js | 8 -------- vite.config.js | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/index.css b/src/index.css index 6b061c5..f52171a 100644 --- a/src/index.css +++ b/src/index.css @@ -13,7 +13,6 @@ --accent-soft: #2a2114; --font: 'Bricolage Grotesque Variable', -apple-system, system-ui, sans-serif; - --dock-h: 150px; /* reserved space so content never hides under the dock */ color-scheme: dark; } @@ -77,7 +76,6 @@ body { } .view__head { margin-bottom: 18px; } -.view__head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; } .view__titlerow { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; } .importbtn { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; margin-top: 6px; } @@ -178,10 +176,6 @@ body { color: var(--text); font-size: 16px; /* 16px = no iOS zoom-on-focus */ padding: 13px 0; outline: none; } -.searchbar__clear { - border: none; background: none; color: var(--text-faint); - font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; -} .searchbar__icon { border: none; background: none; color: var(--text-dim); display: grid; place-items: center; cursor: pointer; @@ -282,11 +276,6 @@ body { .plcard__name { font-size: 16px; font-weight: 600; } .plrow { display: flex; align-items: center; } .plrow .row { flex: 1; } -.backbtn { - background: none; border: none; color: var(--accent); - font-family: var(--font); font-size: 15px; font-weight: 600; - padding: 0 0 12px; cursor: pointer; -} /* ── bottom sheet ────────────────────────────────────────────── */ .sheet-overlay { diff --git a/src/state/useLibrary.js b/src/state/useLibrary.js index 6d54d5b..29f9cb8 100644 --- a/src/state/useLibrary.js +++ b/src/state/useLibrary.js @@ -12,18 +12,10 @@ export function useTracks() { return useLiveQuery(() => db.tracks.orderBy('dateAdded').reverse().toArray()) } -export function useStarredTracks() { - return useLiveQuery(() => db.tracks.where('starred').equals(1).toArray()) -} - export function usePlaylists() { return useLiveQuery(() => db.playlists.orderBy('createdAt').reverse().toArray()) } -export function usePlaylist(id) { - return useLiveQuery(() => (id == null ? undefined : db.playlists.get(id)), [id]) -} - export function useLyrics(trackId) { return useLiveQuery(() => (trackId == null ? undefined : db.lyrics.get(trackId)), [trackId]) } diff --git a/vite.config.js b/vite.config.js index 0006b4b..d71abb9 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,20 @@ +import { rm } from 'node:fs/promises' import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import { VitePWA } from 'vite-plugin-pwa' +// The public/samples/*.wav tones are dev-only seed fixtures (see src/lib/seed.js, +// gated behind import.meta.env.DEV). Because they live in public/ they'd be +// copied verbatim into the build; strip them from the production output so +// ~2.7MB of audio no user ever plays doesn't ship. +const stripDevSamplesPlugin = () => ({ + name: 'melody-strip-dev-samples', + apply: 'build', + closeBundle: async () => { + await rm('dist/samples', { recursive: true, force: true }) + }, +}) + // Content-Security-Policy (defense-in-depth). Injected into index.html for // PRODUCTION BUILDS ONLY — dev/HMR needs inline scripts + eval, which this would // block. Sources: app assets are same-origin ('self'); thumbnails come from @@ -49,6 +62,7 @@ export default defineConfig(({ command }) => ({ plugins: [ // CSP only in the built HTML — injecting it in dev would break Vite HMR. command === 'build' && cspPlugin(), + stripDevSamplesPlugin(), // apply:'build' gates it to production react(), VitePWA({ // 'autoUpdate' = the new service worker activates and reloads the page as