Skip to content

Instantly share code, notes, and snippets.

@nornagon
Created February 5, 2021 01:01
Show Gist options
  • Save nornagon/1d1190d6c6d971fe7b938d0d12be8071 to your computer and use it in GitHub Desktop.
Save nornagon/1d1190d6c6d971fe7b938d0d12be8071 to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
<!-- Empty -->
const {app, BrowserWindow, BrowserView} = require('electron')
const APPLY_BROWSER_VIEW_FIX = false;
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600
})
const mainView = new BrowserView({
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
},
});
mainWindow.setBrowserView(mainView);
mainView.setBounds({
x: 0,
y: 0,
width: 800,
height: 600,
});
mainView.webContents.loadFile('index.html')
if(APPLY_BROWSER_VIEW_FIX) {
app.on("before-quit", () => {
mainWindow.setBrowserView(null);
});
}
}
app.whenReady().then(createWindow)
// const { contextBridge } = require("electron");
// class DUJK {
// constructor(f) {
// this.f = f;
// }
// }
// let g_fn = null
// contextBridge.exposeInMainWorld("test", {
// // Listen for messages
// on: (fn) => g_fn = new DUJK(fn),
// });
for (let i = 0; i < 10; i++) {
setInterval(() => {
(() => {})(function() {})
}, 1)
}
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment