Fix: Standardize Electron bridge and implement robust caching

- Refactored all IPC methods and parameters to snake_case for consistency with SvelteKit.
- Implemented exhaustive background caching engine with download locking.
- Reverted to legacy-proven flat hash storage pattern (hash.file).
- Added axios for reliable stream-based binary downloads.
- Updated preload and main handlers to support recursive room data fetching.
This commit is contained in:
Scott Idem
2026-01-23 16:30:23 -05:00
parent 30db989b2c
commit 280de213c1
21 changed files with 665 additions and 24 deletions

View File

@@ -0,0 +1,38 @@
import { ipcMain, shell } from 'electron';
import { exec } from 'child_process';
import * as path from 'path';
import * as fs from 'fs';
export function registerShellHandlers() {
// Open a local directory in the OS File Manager
ipcMain.handle('native:open-folder', async (event, folderPath: string) => {
console.log(`Native: Opening folder ${folderPath}`);
const error = await shell.openPath(folderPath);
return { success: !error, error };
});
// Run a generic shell command (Whitelisted logic can be added here)
ipcMain.handle('native:run-cmd', async (event, command: string) => {
console.log(`Native: Running command: ${command}`);
return new Promise((resolve) => {
exec(command, (error, stdout, stderr) => {
resolve({
success: !error,
stdout,
stderr,
error: error ? error.message : null
});
});
});
});
// Specific handler for launching a presentation file
ipcMain.handle('native:launch-file', async (event, filePath: string) => {
console.log(`Native: Launching file: ${filePath}`);
if (!fs.existsSync(filePath)) {
return { success: false, error: 'File not found' };
}
const error = await shell.openPath(filePath);
return { success: !error, error };
});
}