insomnia/packages/insomnia-app/app/preload.js
Jack Kavanagh 8585eea9e6
electron v15 pre-upgrade refactoring (#4524)
* now with 100% fat free cancellation

Co-authored-by: James Gatz <jamesgatzos@gmail.com>

* unblock electron 15

* fix cookielist and temp fix curl types

* fix types

* fix inso

* default to verbose inso test

* implement readdata function

* fix test

* revert test changes

* isomorphic cancel

* reduce typing issues

* curl types

* turns out the tests were wrong

* handle errors

* remove unused inso mock

* remove request delay

* fix lint and add logs

* Revert "remove request delay"

This reverts commit f07d8c90a7a7279ca10f8a8de1ea0c82caa06390.

* simplify and add cancel fallback

* skip cancel test

* playwright is fast and insomnia is slow

* trailing spaces are serious yo

* cancel is flake town

* hmm

* unblock nunjucks and storeTimeline

* fix nunjucks tests

* preload writeFile

* oops forgot to remove the reload

* debugging CI takes all day, log stuff and pray

* also warn if nunjucks is being lame

* Stop using environment variables

* revert debugging logs

Co-authored-by: James Gatz <jamesgatzos@gmail.com>
Co-authored-by: David Marby <david@dmarby.se>
2022-03-03 13:42:04 +00:00

36 lines
1.4 KiB
JavaScript

const { contextBridge, ipcRenderer } = require('electron');
const main = {
restart: () => ipcRenderer.send('restart'),
authorizeUserInWindow: options => ipcRenderer.invoke('authorizeUserInWindow', options),
setMenuBarVisibility: options => ipcRenderer.send('setMenuBarVisibility', options),
installPlugin: options => ipcRenderer.invoke('installPlugin', options),
curlRequest: options => ipcRenderer.invoke('curlRequest', options),
cancelCurlRequest: options => ipcRenderer.send('cancelCurlRequest', options),
writeFile: options => ipcRenderer.invoke('writeFile', options),
};
const dialog = {
showOpenDialog: options => ipcRenderer.invoke('showOpenDialog', options),
showSaveDialog: options => ipcRenderer.invoke('showSaveDialog', options),
};
const app = {
getPath: options => ipcRenderer.sendSync('getPath', options),
getAppPath: options => ipcRenderer.sendSync('getAppPath', options),
};
const shell = {
showItemInFolder: options => ipcRenderer.send('showItemInFolder', options),
};
// if (process.contextIsolated) { TODO: use if rather than try after upgrading to electron 13
try {
contextBridge.exposeInMainWorld('main', main);
contextBridge.exposeInMainWorld('dialog', dialog);
contextBridge.exposeInMainWorld('app', app);
contextBridge.exposeInMainWorld('shell', shell);
} catch {
window.main = main;
window.dialog = dialog;
window.app = app;
window.shell = shell;
}