Main plugins allow you to customize, extend, or enhance the main process of the Deskofy application. These plugins have full access to the Electron API, enabling you to add new capabilities or modify existing behavior. Each main plugin must follow a specific structure:
import { App } from 'electron';
const plugin = {
init: (deskofyApp: App) => {
// Your main process logic here
},
};
export default plugin;
When the file follows this structure, Deskofy will automatically identify and inject the plugin into the main process. There is no limit to the number of plugins you can create.
Main plugins operate on the backend side of the Deskofy application and run within the main process. They do not have direct access to the web view.
To interact with the frontend or web view, you must create renderer plugins, which are specifically designed for the renderer proces
Here is a sample main plugin example. In this example, a new window is created whenever the main window is initialized:
import { BrowserWindow, App } from 'electron';
const plugin = {
init: (deskofyApp: App) => {
deskofyApp.whenReady().then(() => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
show: true,
});
mainWindow.loadURL('data:text/html;charset=utf-8,' +
encodeURIComponent('<h1>Hello from Main Plugin!</h1><p>This window was created by your plugin.</p>')
);
mainWindow.webContents.openDevTools();
console.log('Window created and visible.');
});
deskofyApp.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
deskofyApp.quit();
}
});
},
};
export default plugin;
This approach allows developers to extend the core Deskofy functionality safely and efficiently.