refactor: add full documentation and fix theme loading robustness

- Add JSDoc comments across frontend and backend modules
- Improve code readability and maintainability with consistent documentation style
- Document Electron IPC handlers, UI utilities, and theme system
- Add missing function/class documentation in theme loader and app services
- Minor structural improvements and cleanup across Electron main process modules
- Minor fixes on variable names
This commit is contained in:
MasterAcnolo
2026-05-31 20:38:42 +02:00
parent 6afc5e06d6
commit 0218664c5a
34 changed files with 1777 additions and 340 deletions

View File

@@ -1,27 +1,124 @@
const { contextBridge, ipcRenderer } = require("electron");
/**
* Exposes the main application API to the renderer process.
*
* This API acts as a secure bridge between the renderer and the
* Electron main process using IPC (Inter-Process Communication).
* All calls are explicitly whitelisted.
*/
contextBridge.exposeInMainWorld("electronAPI", {
/**
* Returns the default system download directory.
*/
getDefaultDownloadPath: () => ipcRenderer.invoke("get-default-download-path"),
/**
* Opens a native dialog allowing the user to select a download folder.
*/
selectDownloadFolder: () => ipcRenderer.invoke("select-download-folder"),
/**
* Sends download progress value to the main process (used for taskbar / UI sync).
*
* @param {number} percent - Download progress percentage (0100)
*/
setProgress: (percent) => ipcRenderer.send("set-progress", percent),
/**
* Retrieves application feature flags (runtime configuration).
*/
getFeatures: () => ipcRenderer.invoke("features"),
setFeature: (key, value) => ipcRenderer.invoke("set-feature", { key, value }),
/**
* Updates a feature flag dynamically at runtime.
*
* @param {string} key - Feature name
* @param {any} value - Feature value
*/
setFeature: (key, value) =>
ipcRenderer.invoke("set-feature", { key, value }),
/**
* Returns the current application version.
*/
getVersion: () => ipcRenderer.invoke("version"),
getValidatedDownloadPath: (path) => ipcRenderer.invoke("validate-download-path", path),
/**
* Validates a download path before using it for file operations.
*
* @param {string} path - Path to validate
*/
getValidatedDownloadPath: (path) =>
ipcRenderer.invoke("validate-download-path", path),
/**
* Retrieves available themes from the filesystem or config layer.
*/
getThemes: () => ipcRenderer.invoke("get-themes"),
reloadThemes: () => ipcRenderer.invoke("reload-themes")
/**
* Forces a reload of theme files (useful after modification/import).
*/
reloadThemes: () => ipcRenderer.invoke("reload-themes"),
});
// Contrôles de fenêtre et outils custom pour la topbar
/**
* Exposes window control and developer utilities for the custom topbar UI.
*
* These methods forward commands to the Electron main process via IPC.
*/
contextBridge.exposeInMainWorld("topbarAPI", {
/**
* Minimizes the application window.
*/
minimize: () => ipcRenderer.send("window-minimize"),
/**
* Toggles maximize/restore state of the application window.
*/
maximize: () => ipcRenderer.send("window-maximize"),
/**
* Closes the application window.
*/
close: () => ipcRenderer.send("window-close"),
/**
* Opens Chromium DevTools for debugging.
*/
openDevTools: () => ipcRenderer.send("open-devtools"),
/**
* Opens application logs directory or log viewer.
*/
openLogs: () => ipcRenderer.send("open-logs"),
/**
* Opens the official website or project homepage.
*/
openWebsite: () => ipcRenderer.send("open-website"),
/**
* Opens the theme directory or theme editor interface.
*/
openTheme: () => ipcRenderer.send("open-theme"),
/**
* Opens project wiki/documentation.
*/
openWiki: () => ipcRenderer.send("open-wiki"),
/**
* Opens the workshop or external content library.
*/
openWorkshop: () => ipcRenderer.send("open-workshop"),
openConfig: () => ipcRenderer.send("open-config")
});
/**
* Opens configuration/settings panel.
*/
openConfig: () => ipcRenderer.send("open-config"),
});