// Round five: the catalog record page's own sheet (play, save, add all to a // playlist, the artist), a raw file's sheet (play from here, save this // file, browse), room users → the peer sheet, and Search's "did you mean" // from the library's own names. Mocks, walks, doc. const fs = require('fs'); const root = 'F:/Coding/SoulStream/'; const scratch = 'C:/Users/Kyle/AppData/Local/Temp/claude/F--Coding-SoulStream/5488514a-11e8-482a-b0a0-20cb511ee110/scratchpad/'; const ins = (name) => fs.readFileSync(scratch + name, 'utf8'); let p, s; const load = (file) => { p = file; s = fs.readFileSync(root + p, 'utf8'); }; const save = () => fs.writeFileSync(root + p, s); const once = (a) => { const i = s.indexOf(a); if (i < 0) throw new Error('missing in ' + p + ': ' + a.slice(0, 90)); if (s.indexOf(a, i + 1) >= 0) throw new Error('ambiguous in ' + p + ': ' + a.slice(0, 90)); return i; }; const rep = (a, b) => { once(a); s = s.replace(a, () => b); }; const NL = String.fromCharCode(10); const afterLine = (anchor, text) => { const i = once(anchor); const nl = s.indexOf(NL, i); s = s.slice(0, nl + 1) + text + s.slice(nl + 1); }; const beforeLine = (anchor, text) => { const i = once(anchor); const ls = s.lastIndexOf(NL, i) + 1; s = s.slice(0, ls) + text + s.slice(ls); }; // ── HalfSheet ── load('src/mobile/HalfSheet.svelte'); rep(` import { streamSong, saveSong } from "./resolve.svelte.js";`, ` import { streamSong, saveSong, streamCatalogAlbum, saveCatalogAlbum } from "./resolve.svelte.js"; import { catalog, yearOf } from "./catalog.svelte.js";`); rep(` import { fmtOf, albumFmt, fmtBytes, basename, dirname, longDur, mmss } from "./util.js";`, ` import { fmtOf, albumFmt, fmtBytes, basename, dirname, longDur, mmss, titleFromName } from "./util.js";`); rep(` if (t.n === "playlist") return "playlist-more"; return "home-more";`, ` if (t.n === "playlist") return "playlist-more"; if (t.n === "catalogAlbum") return "catalogAlbum-more"; return "home-more";`); rep(` const trackArg = $derived(kind === "track" ? shown?.arg : null);`, ` const trackArg = $derived(kind === "track" ? shown?.arg : null); /* the catalog record page's sheet reads the page the store holds */ const catPage = $derived(kind === "catalogAlbum-more" ? (catalog.albums[top().c.id]?.page ?? null) : null);`); rep(`oncontextmenu={(e) => { e.preventDefault(); (buddy ? removeBuddy : addBuddy)(u.username).catch(() => {}); }}>`, `oncontextmenu={(e) => { e.preventDefault(); openHalf("peer", { username: u.username }); }}>`); beforeLine(` {:else if kind === "librarysort"}`, ins('ins-halfsheet-cat-file.txt')); save(); // ── Search: a raw file's sheet; did you mean ── load('src/mobile/screens/Search.svelte'); rep(` ?{/if}{/if}`); save(); // ── Browse: a file's sheet ── load('src/mobile/screens/Browse.svelte'); rep(`