diff --git a/src/main/main.ts b/src/main/main.ts index 5b0384a..d2093a8 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -25,6 +25,8 @@ const createWindow = () => { height: 720, webPreferences: { preload: path.join(__dirname, "preload.js"), + nodeIntegration: true, + contextIsolation: false, }, icon: "./resources/icon.png", }); diff --git a/src/preload.ts b/src/preload.ts index 56b24dd..258c009 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -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, @@ -91,4 +96,4 @@ contextBridge.exposeInMainWorld("electronAPI", { terminalExitCallbacks.set(id, callback); return () => terminalExitCallbacks.delete(id); }, -}); +}; diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 6470c2c..ba3687e 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -55,8 +55,8 @@ declare global { id: string, callback: (exitCode: number) => void, ) => () => void; - removeAllTerminalListeners: () => void; }; + fs: typeof import("fs"); } }