diff --git a/ivette/src/dome/main/dome.ts b/ivette/src/dome/main/dome.ts index 948d7d76ef9378bdfc52f5fddca2431223a62b25..337d9bb2f18361ab6cfc7ff01524a9a5a57b7318 100644 --- a/ivette/src/dome/main/dome.ts +++ b/ivette/src/dome/main/dome.ts @@ -414,6 +414,7 @@ function createBrowserWindow( nodeIntegration: true, sandbox: false, additionalArguments: [...browserArguments], + preload: path.join(__dirname, '../preload/index.js'), }, ...config, }; @@ -538,6 +539,7 @@ function createBrowserWindow( }); } + return theWindow; } @@ -554,11 +556,6 @@ interface Cmd { wdir: string; argv: string[] } // [LC]: this is buggy, process.argv has no command line arguments function stripElectronArgv(cmd: Cmd): Cmd { - console.log("DEVEL", DEVEL); - console.log("Is Dev", is.dev); - console.log("LOCAL", LOCAL); - console.log("Vite Mode", import.meta.env.MODE); - const devel = import.meta.env.MODE === "development"; const wdir = devel ? cmd.argv[2] : cmd.wdir; const argv = cmd.argv @@ -578,10 +575,7 @@ function createPrimaryWindow(): void { // }); const cwd = process.cwd(); const wdir = cwd === '/' ? app.getPath('home') : cwd; - console.log("Process argv: ", process.argv); - console.log("Before", { wdir, argv: process.argv }); const cmd = stripElectronArgv({ wdir, argv: process.argv }); - console.log("After", cmd); // Reset Settings if the associated argument is provided const settingsIdx = cmd.argv.indexOf(CLI_OPTION_SETTINGS.name); diff --git a/ivette/src/dome/misc/system.ts b/ivette/src/dome/misc/system.ts index f998ca469579c448d0ac263d59e7884be56ffee5..b1287d0fa7f597b84923474c88372fc6a5269eff 100644 --- a/ivette/src/dome/misc/system.ts +++ b/ivette/src/dome/misc/system.ts @@ -564,7 +564,6 @@ export function spawn( options?: ProcessOptions, ): Promise<Exec.ChildProcess> { return new Promise((result, reject) => { - const cwd = options ? options.cwd : undefined; const opt = options ? options.env : undefined; const env = // Forces 'PWD' env. variable for executing a non-shell process diff --git a/ivette/src/frama-c/server.ts b/ivette/src/frama-c/server.ts index 1364e16daacb2464428f88ad7ead814b97c7297e..06a0706c052b90a50bc6993be72134fb322375c1 100644 --- a/ivette/src/frama-c/server.ts +++ b/ivette/src/frama-c/server.ts @@ -491,7 +491,7 @@ async function _launch(): Promise<void> { cwd: working, stdout: { path: logout, pipe: true }, stderr: { path: logerr, pipe: true }, - env, + env: { ...env, ... window.electron.process.env }, }; // Launch Process System.atExit(() => { diff --git a/ivette/src/preload/index.d.ts b/ivette/src/preload/index.d.ts index 909e10c3bf6136aa746c9e011ca07016453e13b7..bc2ee9237f14d7fbdc280b8ad7f54c346f69a245 100644 --- a/ivette/src/preload/index.d.ts +++ b/ivette/src/preload/index.d.ts @@ -2,9 +2,6 @@ import { ElectronAPI } from '@electron-toolkit/preload'; declare global { interface Window { - electron: ElectronAPI - api: { - readDir(path: string): Promise<string[]> - } + electron: ElectronAPI; } } diff --git a/ivette/src/preload/index.ts b/ivette/src/preload/index.ts index d9df9b5fbea19cdd09406074747313a8422878bd..680cfe2b09c25c17c7eb50f1c192c0bdc8c9efb0 100644 --- a/ivette/src/preload/index.ts +++ b/ivette/src/preload/index.ts @@ -1,13 +1,5 @@ -import { contextBridge } from 'electron'; import { electronAPI } from '@electron-toolkit/preload'; -import fs from 'fs/promises'; - -// Custom APIs for renderer -const api = { - readDir: async (path: string) => { - return await fs.readdir(path); - }, -}; +import { contextBridge } from 'electron'; // Use `contextBridge` APIs to expose Electron APIs to // renderer only if context isolation is enabled, otherwise @@ -15,7 +7,6 @@ const api = { if (process.contextIsolated) { try { contextBridge.exposeInMainWorld('electron', electronAPI); - contextBridge.exposeInMainWorld('api', api); } catch (error) { // eslint-disable-next-line no-console console.error(error); @@ -23,6 +14,4 @@ if (process.contextIsolated) { } else { // @ts-expect-error (define in dts) window.electron = electronAPI; - // @ts-expect-error (define in dts) - window.api = api; }