Compare commits

...

1 Commits

Author SHA1 Message Date
Quinten Kock 990ae9a7da Enable nodeIntegration and put "fs" in window 2025-11-24 22:07:44 +01:00
3 changed files with 10 additions and 3 deletions

View File

@ -25,6 +25,8 @@ const createWindow = () => {
height: 720,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: true,
contextIsolation: false,
},
icon: "./resources/icon.png",
});

View File

@ -3,6 +3,11 @@
import { contextBridge, ipcRenderer } from "electron";
import type { FolderTree } from "./types/global";
import fs from "fs";
import * as pty from "node-pty";
window.fs = fs;
window.pty = pty;
// Centralized routing for terminal events: keep a single ipcRenderer listener
// and forward events to subscribed callbacks. Each `onTerminal*` returns an
@ -23,7 +28,7 @@ ipcRenderer.on("terminal:exit", (_ev, id: string, exitCode: number) => {
else console.warn(`No exit callback for terminal ${id}`);
});
contextBridge.exposeInMainWorld("electronAPI", {
window.electronAPI = {
openFolder: () =>
ipcRenderer.invoke("dialog:openFolder") as Promise<FolderTree | null>,
@ -91,4 +96,4 @@ contextBridge.exposeInMainWorld("electronAPI", {
terminalExitCallbacks.set(id, callback);
return () => terminalExitCallbacks.delete(id);
},
});
};

View File

@ -55,8 +55,8 @@ declare global {
id: string,
callback: (exitCode: number) => void,
) => () => void;
removeAllTerminalListeners: () => void;
};
fs: typeof import("fs");
}
}