You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
1.1 KiB

import { contextBridge, ipcRenderer } from 'electron';
require('./rt/electron-rt');
//////////////////////////////
// User Defined Preload scripts below
console.log('User Preload!');
/**
* Expose secure IPC APIs to the renderer process.
*
* This creates a bridge between the sandboxed renderer and the main process,
* allowing secure file operations while maintaining Electron's security model.
*/
contextBridge.exposeInMainWorld('electronAPI', {
/**
* Export data to the user's Downloads folder.
*
* @param fileName - The name of the file to save (e.g., 'backup-2025-07-06.json')
* @param data - The content to write to the file (string)
* @returns Promise<{success: boolean, path?: string, error?: string}>
*
* @example
* ```typescript
* const result = await window.electronAPI.exportData('my-backup.json', JSON.stringify(data));
* if (result.success) {
* console.log('File saved to:', result.path);
* } else {
* console.error('Export failed:', result.error);
* }
* ```
*/
exportData: (fileName: string, data: string) =>
ipcRenderer.invoke('export-data-to-downloads', fileName, data)
});