From 1956606e6bffc2072e80eaf0c2126806919e0528 Mon Sep 17 00:00:00 2001 From: RobertGemmaJr Date: Mon, 5 Aug 2024 11:04:10 -0400 Subject: [PATCH] wip: Handle type:module building --- src/Electron/main.js | 11 ++++++++--- src/Electron/preload.js | 5 +++++ src/config/env.js | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Electron/main.js b/src/Electron/main.js index 4092df7c1..faa70f498 100644 --- a/src/Electron/main.js +++ b/src/Electron/main.js @@ -16,8 +16,6 @@ import { getPort, sendToPort } from "./lib/serialport"; // TODO @brown-ccv #192: Handle data writing to desktop in a utility process // TODO @brown-ccv #192: Handle video data writing to desktop in a utility process -console.log("MAIN", import.meta.dirname, import.meta.filename); - /************ GLOBALS ***********/ const IS_DEV = import.meta.env.DEV && !app.isPackaged; @@ -303,7 +301,14 @@ function createWindow() { const mainWindow = new BrowserWindow({ icon: "./favicon.ico", // webPreferences: { preload: path.join(__dirname, "preload.js") }, - webPreferences: { preload: path.join(import.meta.dirname, "preload.js") }, + webPreferences: { + // preload: path.join(import.meta.dirname, "preload.js"), + preload: path.join(import.meta.dirname, "preload.mjs"), + // TEST + sandbox: false, + contextIsolation: true, + // enableRemoteModule: false, + }, width: 1500, height: 900, // TODO @brown-ccv: Settings for preventing the menu bar from ever showing up diff --git a/src/Electron/preload.js b/src/Electron/preload.js index c0e9c37e8..c3e532848 100644 --- a/src/Electron/preload.js +++ b/src/Electron/preload.js @@ -1,7 +1,12 @@ import { contextBridge, ipcRenderer } from "electron"; +import log from "electron-log"; +log.info("PRELOAD"); /** Load bridges between the main and renderer processes when the preload process is first loaded */ process.once("loaded", () => { + // TODO: The "loaded" state is never executed for some reason + console.log("PRELOAD LOADED"); + log.info("PRELOAD LOADED"); contextBridge.exposeInMainWorld("electronAPI", { setConfig: (config) => ipcRenderer.send("setConfig", config), setTrigger: (triggerCodes) => ipcRenderer.send("setTrigger", triggerCodes), diff --git a/src/config/env.js b/src/config/env.js index 45f31a0a0..2c8953c40 100644 --- a/src/config/env.js +++ b/src/config/env.js @@ -18,4 +18,6 @@ const config = { USE_EEG, USE_CAMERA, }; + +console.log("CONFIG", window.electronAPI, config); export default config;