From a810049743ec4096a2f8d6cef31d81d9ebc91194 Mon Sep 17 00:00:00 2001 From: Achyuta <107514366+achyutagupta@users.noreply.github.com> Date: Thu, 11 Jan 2024 14:22:26 +0530 Subject: [PATCH] Added preload scripts --- imagelab_react/public/electron.js | 1 + imagelab_react/public/preload.js | 2 ++ imagelab_react/src/browse-blocks-functions.js | 3 +-- imagelab_react/src/utils/main.js | 3 +-- 4 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 imagelab_react/public/preload.js diff --git a/imagelab_react/public/electron.js b/imagelab_react/public/electron.js index 1031e67..785c999 100644 --- a/imagelab_react/public/electron.js +++ b/imagelab_react/public/electron.js @@ -13,6 +13,7 @@ function createWindow() { webPreferences: { nodeIntegration: true, contextIsolation: false, + preload: path.join(__dirname, 'preload.js'), }, }); diff --git a/imagelab_react/public/preload.js b/imagelab_react/public/preload.js new file mode 100644 index 0000000..983dd63 --- /dev/null +++ b/imagelab_react/public/preload.js @@ -0,0 +1,2 @@ +const electron = require('electron'); +window.ipcRenderer = electron.ipcRenderer; diff --git a/imagelab_react/src/browse-blocks-functions.js b/imagelab_react/src/browse-blocks-functions.js index a66a855..6feb2df 100644 --- a/imagelab_react/src/browse-blocks-functions.js +++ b/imagelab_react/src/browse-blocks-functions.js @@ -1,6 +1,5 @@ import Blockly from "blockly"; -const electron = window.require('electron'); -const ipcRenderer = electron.ipcRenderer; +const ipcRenderer = window.ipcRenderer; /*This function is responible for opening file selector window to choose the picture you will do operqations on it works with (read image) block */ diff --git a/imagelab_react/src/utils/main.js b/imagelab_react/src/utils/main.js index 20aa6da..df346c0 100644 --- a/imagelab_react/src/utils/main.js +++ b/imagelab_react/src/utils/main.js @@ -1,6 +1,5 @@ import Blockly from "blockly"; -const electron = window.require('electron'); -const ipcRenderer = electron.ipcRenderer; +const ipcRenderer = window.ipcRenderer; function processBlock(block, pipeline) { const blockParams = block.inputList.reduce((params, input) => {