merge(pre-release): sync latest integration branch into plex feature
cx
This commit is contained in:
commit
fb3204f2e4
49 files changed
+4570
-1240
No files matched your search
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Console log capture store
|
||||
*
|
||||
* Wraps console.log/warn/error/info to capture browser-side logs
|
||||
* for the Developer Mode "View Logs" modal. Original console methods
|
||||
* are still called — no breakage.
|
||||
*/
|
||||
|
||||
interface ConsoleEntry {
|
||||
level: 'log' | 'warn' | 'error' | 'info';
|
||||
timestamp: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
const MAX_ENTRIES = 2000;
|
||||
let entries: ConsoleEntry[] = [];
|
||||
let initialized = false;
|
||||
|
||||
// Keep references to the real console methods
|
||||
const originalConsole = {
|
||||
log: console.log.bind(console),
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console),
|
||||
info: console.info.bind(console),
|
||||
};
|
||||
|
||||
function formatArgs(args: unknown[]): string {
|
||||
return args.map(arg => {
|
||||
if (typeof arg === 'string') return arg;
|
||||
try {
|
||||
return JSON.stringify(arg);
|
||||
} catch {
|
||||
return String(arg);
|
||||
}
|
||||
}).join(' ');
|
||||
}
|
||||
|
||||
function capture(level: ConsoleEntry['level'], args: unknown[]) {
|
||||
const entry: ConsoleEntry = {
|
||||
level,
|
||||
timestamp: new Date().toISOString(),
|
||||
message: formatArgs(args),
|
||||
};
|
||||
|
||||
entries.push(entry);
|
||||
if (entries.length > MAX_ENTRIES) {
|
||||
entries = entries.slice(-MAX_ENTRIES);
|
||||
}
|
||||
}
|
||||
|
||||
export function initConsoleCapture() {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
|
||||
console.log = (...args: unknown[]) => {
|
||||
capture('log', args);
|
||||
originalConsole.log(...args);
|
||||
};
|
||||
console.warn = (...args: unknown[]) => {
|
||||
capture('warn', args);
|
||||
originalConsole.warn(...args);
|
||||
};
|
||||
console.error = (...args: unknown[]) => {
|
||||
capture('error', args);
|
||||
originalConsole.error(...args);
|
||||
};
|
||||
console.info = (...args: unknown[]) => {
|
||||
capture('info', args);
|
||||
originalConsole.info(...args);
|
||||
};
|
||||
}
|
||||
|
||||
export function getConsoleLogs(): ConsoleEntry[] {
|
||||
return [...entries];
|
||||
}
|
||||
|
||||
export function getConsoleLogsAsText(): string {
|
||||
return entries
|
||||
.map(e => `[${e.timestamp}] [${e.level.toUpperCase()}] ${e.message}`)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
export function clearConsoleLogs() {
|
||||
entries = [];
|
||||
}
|
||||
@@ -13,6 +13,7 @@ export interface AlbumCardData {
|
||||
artwork: string;
|
||||
title: string;
|
||||
artist: string;
|
||||
artistId?: number;
|
||||
genre: string;
|
||||
quality?: string;
|
||||
releaseDate?: string;
|
||||
|
||||
@@ -30,6 +30,9 @@ let activeView: ViewType = 'home';
|
||||
let viewHistory: ViewType[] = ['home'];
|
||||
let forwardHistory: ViewType[] = [];
|
||||
|
||||
// Scroll position memory — keyed by ViewType
|
||||
const scrollPositions = new Map<ViewType, number>();
|
||||
|
||||
// Selected playlist ID (album/artist are full data objects in +page.svelte)
|
||||
let selectedPlaylistId: number | null = null;
|
||||
|
||||
@@ -222,6 +225,22 @@ export function navigateToFavorites(tab?: FavoritesTab): void {
|
||||
navigateTo(favoritesViewForTab(targetTab));
|
||||
}
|
||||
|
||||
// ============ Scroll Position ============
|
||||
|
||||
/**
|
||||
* Save scroll position for a view (call before navigating away)
|
||||
*/
|
||||
export function saveScrollPosition(view: ViewType, scrollTop: number): void {
|
||||
scrollPositions.set(view, scrollTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get saved scroll position for a view (0 if none saved)
|
||||
*/
|
||||
export function getSavedScrollPosition(view: ViewType): number {
|
||||
return scrollPositions.get(view) ?? 0;
|
||||
}
|
||||
|
||||
// ============ Getters ============
|
||||
|
||||
export function getActiveView(): ViewType {
|
||||
|
||||
Reference in new issue
Block a user