diff --git a/src/ElectronNET.Host/api/browserWindows.js b/src/ElectronNET.Host/api/browserWindows.js index 551b10f..c24153b 100644 --- a/src/ElectronNET.Host/api/browserWindows.js +++ b/src/ElectronNET.Host/api/browserWindows.js @@ -444,10 +444,27 @@ module.exports = (socket, app) => { electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle); }); socket.on('browserWindowSetRepresentedFilename', (id, filename) => { - getWindowById(id).setRepresentedFilename(filename); + const win = getWindowById(id); + try { + if (win && typeof win.setRepresentedFilename === 'function') { + win.setRepresentedFilename(filename); + } + } + catch (e) { + console.warn('setRepresentedFilename failed (likely unsupported platform):', e); + } }); socket.on('browserWindowGetRepresentedFilename', (id) => { - const pathname = getWindowById(id).getRepresentedFilename(); + const win = getWindowById(id); + let pathname = ''; + try { + if (win && typeof win.getRepresentedFilename === 'function') { + pathname = win.getRepresentedFilename() || ''; + } + } + catch (e) { + console.warn('getRepresentedFilename failed (likely unsupported platform):', e); + } electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname); }); socket.on('browserWindowSetDocumentEdited', (id, edited) => { diff --git a/src/ElectronNET.Host/api/browserWindows.ts b/src/ElectronNET.Host/api/browserWindows.ts index b231742..3f4453b 100644 --- a/src/ElectronNET.Host/api/browserWindows.ts +++ b/src/ElectronNET.Host/api/browserWindows.ts @@ -566,12 +566,26 @@ export = (socket: Socket, app: Electron.App) => { }); socket.on('browserWindowSetRepresentedFilename', (id, filename) => { - getWindowById(id).setRepresentedFilename(filename); + const win = getWindowById(id); + try { + if (win && typeof win.setRepresentedFilename === 'function') { + win.setRepresentedFilename(filename); + } + } catch (e) { + console.warn('setRepresentedFilename failed (likely unsupported platform):', e); + } }); socket.on('browserWindowGetRepresentedFilename', (id) => { - const pathname = getWindowById(id).getRepresentedFilename(); - + const win = getWindowById(id); + let pathname = ''; + try { + if (win && typeof win.getRepresentedFilename === 'function') { + pathname = win.getRepresentedFilename() || ''; + } + } catch (e) { + console.warn('getRepresentedFilename failed (likely unsupported platform):', e); + } electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname); });