FIX: vite warnings
This commit is contained in:
parent
731c7a7a0b
commit
22365976c9
3 changed files with 14 additions and 52 deletions
41
js/app.js
41
js/app.js
|
|
@ -16,17 +16,18 @@ import { registerSW } from 'virtual:pwa-register';
|
||||||
import { initializeDiscordRPC } from './discord-rpc.js';
|
import { initializeDiscordRPC } from './discord-rpc.js';
|
||||||
import * as Neutralino from '@neutralinojs/lib';
|
import * as Neutralino from '@neutralinojs/lib';
|
||||||
import './smooth-scrolling.js';
|
import './smooth-scrolling.js';
|
||||||
|
import { showNotification, downloadPlaylistAsZip } from './downloads.js';
|
||||||
|
import './metadata.js'; // Ensure Side Effects
|
||||||
|
|
||||||
// Assign Neutralino to window for global access
|
// Assign Neutralino to window for global access
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.Neutralino = Neutralino;
|
window.Neutralino = Neutralino;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { initTracker } from './tracker.js';
|
||||||
|
|
||||||
// Lazy-loaded modules
|
// Lazy-loaded modules
|
||||||
let settingsModule = null;
|
let settingsModule = null;
|
||||||
let downloadsModule = null;
|
|
||||||
let trackerModule = null;
|
|
||||||
let metadataModule = null;
|
|
||||||
|
|
||||||
async function loadSettingsModule() {
|
async function loadSettingsModule() {
|
||||||
if (!settingsModule) {
|
if (!settingsModule) {
|
||||||
|
|
@ -35,26 +36,7 @@ async function loadSettingsModule() {
|
||||||
return settingsModule;
|
return settingsModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDownloadsModule() {
|
|
||||||
if (!downloadsModule) {
|
|
||||||
downloadsModule = await import('./downloads.js');
|
|
||||||
}
|
|
||||||
return downloadsModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadTrackerModule() {
|
|
||||||
if (!trackerModule) {
|
|
||||||
trackerModule = await import('./tracker.js');
|
|
||||||
}
|
|
||||||
return trackerModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadMetadataModule() {
|
|
||||||
if (!metadataModule) {
|
|
||||||
metadataModule = await import('./metadata.js');
|
|
||||||
}
|
|
||||||
return metadataModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeCasting(audioPlayer, castBtn) {
|
function initializeCasting(audioPlayer, castBtn) {
|
||||||
if (!castBtn) return;
|
if (!castBtn) return;
|
||||||
|
|
@ -381,8 +363,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
initializeUIInteractions(player, api, ui);
|
initializeUIInteractions(player, api, ui);
|
||||||
initializeKeyboardShortcuts(player, audioPlayer);
|
initializeKeyboardShortcuts(player, audioPlayer);
|
||||||
|
|
||||||
// Load tracker module
|
// Initialize tracker
|
||||||
const { initTracker } = await loadTrackerModule();
|
|
||||||
initTracker(player);
|
initTracker(player);
|
||||||
|
|
||||||
// Initialize desktop environment (Neutralino)
|
// Initialize desktop environment (Neutralino)
|
||||||
|
|
@ -390,7 +371,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
console.log('Initializing Neutralino desktop environment (Lite Mode)...');
|
console.log('Initializing Neutralino desktop environment (Lite Mode)...');
|
||||||
try {
|
try {
|
||||||
Neutralino.init();
|
Neutralino.init();
|
||||||
|
|
||||||
// Register events immediately
|
// Register events immediately
|
||||||
Neutralino.events.on('windowClose', () => {
|
Neutralino.events.on('windowClose', () => {
|
||||||
Neutralino.app.exit();
|
Neutralino.app.exit();
|
||||||
|
|
@ -584,7 +565,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to play album:', error);
|
console.error('Failed to play album:', error);
|
||||||
const { showNotification } = await loadDownloadsModule();
|
|
||||||
showNotification('Failed to play album');
|
showNotification('Failed to play album');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -608,12 +589,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
if (shuffleBtn) shuffleBtn.classList.remove('active');
|
if (shuffleBtn) shuffleBtn.classList.remove('active');
|
||||||
player.shuffleActive = false;
|
player.shuffleActive = false;
|
||||||
player.playTrackFromQueue();
|
player.playTrackFromQueue();
|
||||||
const { showNotification } = await loadDownloadsModule();
|
|
||||||
showNotification('Shuffling album');
|
showNotification('Shuffling album');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to shuffle album:', error);
|
console.error('Failed to shuffle album:', error);
|
||||||
const { showNotification } = await loadDownloadsModule();
|
|
||||||
showNotification('Failed to shuffle album');
|
showNotification('Failed to shuffle album');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -637,7 +618,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { mix, tracks } = await api.getMix(mixId);
|
const { mix, tracks } = await api.getMix(mixId);
|
||||||
const { downloadPlaylistAsZip } = await loadDownloadsModule();
|
|
||||||
await downloadPlaylistAsZip(mix, tracks, api, downloadQualitySettings.getQuality(), lyricsManager);
|
await downloadPlaylistAsZip(mix, tracks, api, downloadQualitySettings.getQuality(), lyricsManager);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Mix download failed:', error);
|
console.error('Mix download failed:', error);
|
||||||
|
|
@ -681,7 +662,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
tracks = data.tracks;
|
tracks = data.tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { downloadPlaylistAsZip } = await loadDownloadsModule();
|
|
||||||
await downloadPlaylistAsZip(playlist, tracks, api, downloadQualitySettings.getQuality(), lyricsManager);
|
await downloadPlaylistAsZip(playlist, tracks, api, downloadQualitySettings.getQuality(), lyricsManager);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Playlist download failed:', error);
|
console.error('Playlist download failed:', error);
|
||||||
|
|
|
||||||
|
|
@ -1250,7 +1250,6 @@ async function updateContextMenuLikeState(contextMenu, contextTrack) {
|
||||||
|
|
||||||
const likeItem = contextMenu.querySelector('li[data-action="toggle-like"]');
|
const likeItem = contextMenu.querySelector('li[data-action="toggle-like"]');
|
||||||
if (likeItem) {
|
if (likeItem) {
|
||||||
const { db } = await import('./db.js');
|
|
||||||
const isLiked = await db.isFavorite('track', contextTrack.id);
|
const isLiked = await db.isFavorite('track', contextTrack.id);
|
||||||
likeItem.textContent = isLiked ? 'Unlike' : 'Like';
|
likeItem.textContent = isLiked ? 'Unlike' : 'Like';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ import {
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
import { sidePanelManager } from './side-panel.js';
|
import { sidePanelManager } from './side-panel.js';
|
||||||
import { downloadQualitySettings } from './storage.js';
|
import { downloadQualitySettings } from './storage.js';
|
||||||
|
import { db } from './db.js';
|
||||||
|
import { syncManager } from './accounts/pocketbase.js';
|
||||||
|
import { showNotification, downloadTracks } from './downloads.js';
|
||||||
|
|
||||||
export function initializeUIInteractions(player, api, ui) {
|
export function initializeUIInteractions(player, api, ui) {
|
||||||
const sidebar = document.querySelector('.sidebar');
|
const sidebar = document.querySelector('.sidebar');
|
||||||
|
|
@ -53,9 +56,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
const folderId = folderCard.dataset.folderId;
|
const folderId = folderCard.dataset.folderId;
|
||||||
|
|
||||||
if (playlistId && folderId) {
|
if (playlistId && folderId) {
|
||||||
const { db } = await import('./db.js');
|
|
||||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
|
||||||
const { showNotification } = await import('./downloads.js');
|
|
||||||
const updatedFolder = await db.addPlaylistToFolder(folderId, playlistId);
|
const updatedFolder = await db.addPlaylistToFolder(folderId, playlistId);
|
||||||
syncManager.syncUserFolder(updatedFolder, 'update');
|
syncManager.syncUserFolder(updatedFolder, 'update');
|
||||||
const subtitle = folderCard.querySelector('.card-subtitle');
|
const subtitle = folderCard.querySelector('.card-subtitle');
|
||||||
|
|
@ -126,7 +126,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
const downloadBtn = container.querySelector('#download-queue-btn');
|
const downloadBtn = container.querySelector('#download-queue-btn');
|
||||||
if (downloadBtn) {
|
if (downloadBtn) {
|
||||||
downloadBtn.addEventListener('click', async () => {
|
downloadBtn.addEventListener('click', async () => {
|
||||||
const { downloadTracks } = await import('./downloads.js');
|
|
||||||
downloadTracks(currentQueue, api, downloadQualitySettings.getQuality());
|
downloadTracks(currentQueue, api, downloadQualitySettings.getQuality());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -134,10 +133,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
const likeBtn = container.querySelector('#like-queue-btn');
|
const likeBtn = container.querySelector('#like-queue-btn');
|
||||||
if (likeBtn) {
|
if (likeBtn) {
|
||||||
likeBtn.addEventListener('click', async () => {
|
likeBtn.addEventListener('click', async () => {
|
||||||
const { db } = await import('./db.js'); // Already imported
|
|
||||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
|
||||||
const { showNotification } = await import('./downloads.js');
|
|
||||||
|
|
||||||
let addedCount = 0;
|
let addedCount = 0;
|
||||||
for (const track of currentQueue) {
|
for (const track of currentQueue) {
|
||||||
const wasAdded = await db.toggleFavorite('track', track);
|
const wasAdded = await db.toggleFavorite('track', track);
|
||||||
|
|
@ -160,10 +155,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
const addToPlaylistBtn = container.querySelector('#add-queue-to-playlist-btn');
|
const addToPlaylistBtn = container.querySelector('#add-queue-to-playlist-btn');
|
||||||
if (addToPlaylistBtn) {
|
if (addToPlaylistBtn) {
|
||||||
addToPlaylistBtn.addEventListener('click', async () => {
|
addToPlaylistBtn.addEventListener('click', async () => {
|
||||||
const { db } = await import('./db.js'); // Already imported
|
|
||||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
|
||||||
const { showNotification } = await import('./downloads.js');
|
|
||||||
|
|
||||||
const playlists = await db.getPlaylists();
|
const playlists = await db.getPlaylists();
|
||||||
if (playlists.length === 0) {
|
if (playlists.length === 0) {
|
||||||
showNotification('No playlists yet. Create one first.');
|
showNotification('No playlists yet. Create one first.');
|
||||||
|
|
@ -291,7 +282,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
// Update like button state
|
// Update like button state
|
||||||
const likeBtn = item.querySelector('.queue-like-btn');
|
const likeBtn = item.querySelector('.queue-like-btn');
|
||||||
if (likeBtn && track) {
|
if (likeBtn && track) {
|
||||||
const { db } = await import('./db.js');
|
|
||||||
const isLiked = await db.isFavorite('track', track.id);
|
const isLiked = await db.isFavorite('track', track.id);
|
||||||
likeBtn.classList.toggle('active', isLiked);
|
likeBtn.classList.toggle('active', isLiked);
|
||||||
likeBtn.innerHTML = isLiked
|
likeBtn.innerHTML = isLiked
|
||||||
|
|
@ -313,10 +303,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const track = player.getCurrentQueue()[index];
|
const track = player.getCurrentQueue()[index];
|
||||||
if (track) {
|
if (track) {
|
||||||
const { db } = await import('./db.js'); // Already imported
|
|
||||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
|
||||||
const { showNotification } = await import('./downloads.js');
|
|
||||||
|
|
||||||
const added = await db.toggleFavorite('track', track);
|
const added = await db.toggleFavorite('track', track);
|
||||||
syncManager.syncLibraryItem('track', track, added);
|
syncManager.syncLibraryItem('track', track, added);
|
||||||
|
|
||||||
|
|
@ -343,7 +329,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
if (contextMenu) {
|
if (contextMenu) {
|
||||||
const track = player.getCurrentQueue()[index];
|
const track = player.getCurrentQueue()[index];
|
||||||
if (track) {
|
if (track) {
|
||||||
const { db } = await import('./db.js');
|
|
||||||
const isLiked = await db.isFavorite('track', track.id);
|
const isLiked = await db.isFavorite('track', track.id);
|
||||||
const likeItem = contextMenu.querySelector('li[data-action="toggle-like"]');
|
const likeItem = contextMenu.querySelector('li[data-action="toggle-like"]');
|
||||||
if (likeItem) {
|
if (likeItem) {
|
||||||
|
|
@ -440,9 +425,6 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
const playlistId = e.dataTransfer.getData('text/playlist-id');
|
const playlistId = e.dataTransfer.getData('text/playlist-id');
|
||||||
const folderId = window.location.pathname.split('/')[2];
|
const folderId = window.location.pathname.split('/')[2];
|
||||||
if (playlistId && folderId) {
|
if (playlistId && folderId) {
|
||||||
const { db } = await import('./db.js');
|
|
||||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
|
||||||
const { showNotification } = await import('./downloads.js');
|
|
||||||
try {
|
try {
|
||||||
const updatedFolder = await db.addPlaylistToFolder(folderId, playlistId);
|
const updatedFolder = await db.addPlaylistToFolder(folderId, playlistId);
|
||||||
syncManager.syncUserFolder(updatedFolder, 'update');
|
syncManager.syncUserFolder(updatedFolder, 'update');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue