fix(renderer): migrate File.path reads to webUtils.getPathForFile for Electron 41

This commit is contained in:
2026-08-23 19:31:33 +05:30
parent 5fcc282fe0
commit c6ec1cef64
8 changed files with 185 additions and 22 deletions
+16 -1
View File
@@ -12,7 +12,7 @@
* @version 4.4.1
*/
const { contextBridge, ipcRenderer } = require('electron');
const { contextBridge, ipcRenderer, webUtils } = require('electron');
// Define allowed IPC channels for security
const ALLOWED_SEND_CHANNELS = [
@@ -431,6 +431,21 @@ contextBridge.exposeInMainWorld('electronAPI', {
updateSettings: (settings) => ipcRenderer.send('update-page-settings', settings),
},
/**
* Resolve a File object chosen via `<input type="file">` to its absolute
* path. `File.path` was removed in Electron 32; `webUtils.getPathForFile`
* is its replacement. Falls back to `file.path` on older Electron where
* webUtils is unavailable.
* @param {File} file - File object from a file input's files list
* @returns {string | undefined} Absolute filesystem path when resolvable
*/
getFilePath: (file) => {
if (webUtils && typeof webUtils.getPathForFile === 'function') {
return webUtils.getPathForFile(file);
}
return file && file.path;
},
// PDF Operations
pdf: {
processOperation: (data) => ipcRenderer.send('process-pdf-operation', data),