style: auto-fix linting issues

This commit is contained in:
JulienMaille 2026-02-10 17:00:00 +00:00 committed by github-actions[bot]
parent 11d7d0ecd3
commit 75ae9c23fa
7 changed files with 959 additions and 151 deletions

View file

@ -259,15 +259,12 @@ document.addEventListener('DOMContentLoaded', async () => {
// Initialize Discord RPC // Initialize Discord RPC
console.log('[App] Starting Discord RPC...'); console.log('[App] Starting Discord RPC...');
initializeDiscordRPC(player); initializeDiscordRPC(player);
} catch (e) { } catch (e) {
console.error('[App] Neutralino init failed:', e); console.error('[App] Neutralino init failed:', e);
} }
} }
}; };
const api = new LosslessAPI(apiSettings); const api = new LosslessAPI(apiSettings);
const audioPlayer = document.getElementById('audio-player'); const audioPlayer = document.getElementById('audio-player');
@ -416,8 +413,6 @@ document.addEventListener('DOMContentLoaded', async () => {
// Initialize tracker // Initialize tracker
initTracker(player); initTracker(player);
initNeutralino(); initNeutralino();
const castBtn = document.getElementById('cast-btn'); const castBtn = document.getElementById('cast-btn');

View file

@ -52,8 +52,8 @@ export function initializeDiscordRPC(player) {
smallImageKey: 'pause', smallImageKey: 'pause',
smallImageText: 'Paused', smallImageText: 'Paused',
}; };
Neutralino.events.broadcast('discord:update', idlingData).catch(() => { }); Neutralino.events.broadcast('discord:update', idlingData).catch(() => {});
Neutralino.extensions.dispatch(EXTENSION_ID, 'discord:update', idlingData).catch(() => { }); Neutralino.extensions.dispatch(EXTENSION_ID, 'discord:update', idlingData).catch(() => {});
} }
}, 5000); }, 5000);
@ -84,6 +84,6 @@ export function initializeDiscordRPC(player) {
smallImageKey: 'pause', smallImageKey: 'pause',
smallImageText: 'Paused', smallImageText: 'Paused',
}) })
.catch(() => { }); .catch(() => {});
} }
} }

View file

@ -66,7 +66,7 @@ const _window = {
}, },
setTitle: async (title) => { setTitle: async (title) => {
window.parent.postMessage({ type: 'NL_WINDOW_SET_TITLE', title }, '*'); window.parent.postMessage({ type: 'NL_WINDOW_SET_TITLE', title }, '*');
} },
}; };
// Expose generically for other modules // Expose generically for other modules
@ -76,5 +76,5 @@ export default {
events, events,
extensions, extensions,
app, app,
window: _window window: _window,
}; };

View file

@ -44,10 +44,5 @@
"commandWindows": "powershell.exe -ExecutionPolicy Bypass -File \"${NL_PATH}/extensions/js.neutralino.discordrpc/bridge.ps1\"" "commandWindows": "powershell.exe -ExecutionPolicy Bypass -File \"${NL_PATH}/extensions/js.neutralino.discordrpc/bridge.ps1\""
} }
], ],
"nativeAllowList": [ "nativeAllowList": ["app.exit", "window.*", "extensions.*", "events.*"]
"app.exit",
"window.*",
"extensions.*",
"events.*"
]
} }

File diff suppressed because one or more lines are too long

View file

@ -1,147 +1,151 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<head> <meta charset="UTF-8" />
<meta charset="UTF-8"> <title>Monochrome Shell</title>
<title>Monochrome Shell</title> <style>
<style> body,
body, html {
html { margin: 0;
margin: 0; padding: 0;
padding: 0; width: 100%;
width: 100%; height: 100%;
height: 100%; overflow: hidden;
overflow: hidden; background-color: #000;
background-color: #000; /* Seamless blend */
/* Seamless blend */
}
iframe {
width: 100%;
height: 100%;
border: none;
display: block;
}
</style>
</head>
<body>
<script src="/__neutralino_globals.js"></script>
<script src="/neutralino.js"></script>
<!-- Load the app from the local Neutralino server -->
<iframe id="app-frame" allow="autoplay; fullscreen; microphone; clipboard-read; clipboard-write"></iframe>
<script>
// initialize Neutralino in the Shell (Local Context)
try {
Neutralino.init();
console.log('[Shell] Neutralino initialized.');
} catch (e) {
console.error('[Shell] Failed to init Neutralino:', e);
}
// Point iframe to local server using the port from Neutralino
// NL_PORT is available globally after init (or we can parse it/wait for it)
// Neutralino.init() usually populates window.NL_PORT or we read it from sessionStorage
const initFrame = async () => {
// Wait a tick for globals
await new Promise(r => setTimeout(r, 100));
let port = window.NL_PORT || sessionStorage.getItem('NL_PORT');
// Fallback if missing (shouldn't happen after init)
if (!port) {
// Try reading from window.location if passed (it isn't in shell mode usually)
// But Neutralino fills globals.
// If not, default to 5050
port = '5050';
} }
iframe {
width: 100%;
height: 100%;
border: none;
display: block;
}
</style>
</head>
<body>
<script src="/__neutralino_globals.js"></script>
<script src="/neutralino.js"></script>
<!-- Load the app from the local Neutralino server -->
<iframe id="app-frame" allow="autoplay; fullscreen; microphone; clipboard-read; clipboard-write"></iframe>
<script>
// initialize Neutralino in the Shell (Local Context)
try {
Neutralino.init();
console.log('[Shell] Neutralino initialized.');
} catch (e) {
console.error('[Shell] Failed to init Neutralino:', e);
}
// Point iframe to local server using the port from Neutralino
// NL_PORT is available globally after init (or we can parse it/wait for it)
// Neutralino.init() usually populates window.NL_PORT or we read it from sessionStorage
const initFrame = async () => {
// Wait a tick for globals
await new Promise((r) => setTimeout(r, 100));
let port = window.NL_PORT || sessionStorage.getItem('NL_PORT');
// Fallback if missing (shouldn't happen after init)
if (!port) {
// Try reading from window.location if passed (it isn't in shell mode usually)
// But Neutralino fills globals.
// If not, default to 5050
port = '5050';
}
const iframe = document.getElementById('app-frame');
// Load the local index.html
iframe.src = `http://localhost:${port}/?mode=neutralino`;
console.log(`[Shell] Loading local app from http://localhost:${port}/?mode=neutralino`);
};
initFrame();
const iframe = document.getElementById('app-frame'); const iframe = document.getElementById('app-frame');
// Load the local index.html
iframe.src = `http://localhost:${port}/?mode=neutralino`;
console.log(`[Shell] Loading local app from http://localhost:${port}/?mode=neutralino`);
};
initFrame(); // Forward generic Neutralino events to the Iframe
const forwardEvent = (eventName, detail) => {
if (iframe && iframe.contentWindow) {
iframe.contentWindow.postMessage(
{
type: 'NL_EVENT',
eventName: eventName,
detail: detail,
},
'*'
);
}
};
const iframe = document.getElementById('app-frame'); // Listen for specific events to forward
// Add more here if the app needs them (e.g., tray events)
Neutralino.events.on('windowClose', () => forwardEvent('windowClose'));
Neutralino.events.on('windowFocus', () => forwardEvent('windowFocus'));
Neutralino.events.on('windowBlur', () => forwardEvent('windowBlur'));
// Forward generic Neutralino events to the Iframe // Handle commands from the Iframe (via Bridge)
const forwardEvent = (eventName, detail) => { window.addEventListener('message', async (event) => {
if (iframe && iframe.contentWindow) { const { type, eventName, data, extensionId } = event.data;
iframe.contentWindow.postMessage({
type: 'NL_EVENT',
eventName: eventName,
detail: detail
}, '*');
}
};
// Listen for specific events to forward // Security: In a real scenario, check event.origin if possible.
// Add more here if the app needs them (e.g., tray events) // But since this loads valid HTTPS content, it's generally safe for this context.
Neutralino.events.on('windowClose', () => forwardEvent('windowClose'));
Neutralino.events.on('windowFocus', () => forwardEvent('windowFocus'));
Neutralino.events.on('windowBlur', () => forwardEvent('windowBlur'));
// Handle commands from the Iframe (via Bridge) switch (type) {
window.addEventListener('message', async (event) => { case 'NL_INIT':
const { type, eventName, data, extensionId } = event.data; console.log('[Shell] Bridge connected.');
break;
// Security: In a real scenario, check event.origin if possible. case 'NL_BROADCAST':
// But since this loads valid HTTPS content, it's generally safe for this context. // e.g. Discord RPC updates
try {
console.log('[Shell] Broadcasting:', eventName, data);
await Neutralino.events.broadcast(eventName, data);
} catch (e) {
console.error('[Shell] Broadcast failed:', e);
}
break;
switch (type) { case 'NL_EXTENSION':
case 'NL_INIT': // e.g. specific extension dispatch
console.log('[Shell] Bridge connected.'); try {
break; console.log('[Shell] Dispatching to extension:', extensionId, eventName);
await Neutralino.extensions.dispatch(extensionId, eventName, data);
} catch (e) {
console.error('[Shell] Extension dispatch failed:', e);
}
break;
case 'NL_BROADCAST': case 'NL_APP_EXIT':
// e.g. Discord RPC updates Neutralino.app.exit();
try { break;
console.log('[Shell] Broadcasting:', eventName, data);
await Neutralino.events.broadcast(eventName, data);
} catch (e) {
console.error('[Shell] Broadcast failed:', e);
}
break;
case 'NL_EXTENSION': case 'NL_WINDOW_MIN':
// e.g. specific extension dispatch Neutralino.window.minimize();
try { break;
console.log('[Shell] Dispatching to extension:', extensionId, eventName);
await Neutralino.extensions.dispatch(extensionId, eventName, data);
} catch (e) {
console.error('[Shell] Extension dispatch failed:', e);
}
break;
case 'NL_APP_EXIT': case 'NL_WINDOW_MAX':
Neutralino.app.exit(); try {
break; const isMax = await Neutralino.window.isMaximized();
if (isMax) Neutralino.window.unmaximize();
case 'NL_WINDOW_MIN': else Neutralino.window.maximize();
Neutralino.window.minimize(); } catch (e) {
break; console.error('[Shell] Window toggle failed:', e);
}
case 'NL_WINDOW_MAX': break;
try {
const isMax = await Neutralino.window.isMaximized();
if (isMax) Neutralino.window.unmaximize();
else Neutralino.window.maximize();
} catch (e) { console.error('[Shell] Window toggle failed:', e); }
break;
case 'NL_WINDOW_SET_TITLE':
try {
await Neutralino.window.setTitle(event.data.title);
} catch (e) { console.error('[Shell] Set title failed:', e); }
break;
}
});
</script>
</body>
case 'NL_WINDOW_SET_TITLE':
try {
await Neutralino.window.setTitle(event.data.title);
} catch (e) {
console.error('[Shell] Set title failed:', e);
}
break;
}
});
</script>
</body>
</html> </html>