-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
47 lines (45 loc) · 1.79 KB
/
Copy pathpreload.js
File metadata and controls
47 lines (45 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { contextBridge, ipcRenderer, globalShortcut } = require("electron");
const { exec } = require("child_process");
const fs = require("fs");
const net = require("net");
const path = require("path");
const { spawn } = require("child_process");
const { rejects } = require("assert");
// Cargar solo módulos válidos
contextBridge.exposeInMainWorld("electron", {
startShell: (shellid, tabidx, terminalidx) =>
ipcRenderer.send("start-shell", { shellid, tabidx, terminalidx }),
editShell: (shellid, terminalidx, tabidx) =>
ipcRenderer.send("edit-shell", { shellid, terminalidx, tabidx }),
runCmd: (command, shellid) =>
ipcRenderer.send("run-cmd", { command, shellid }),
stopShell: (shellid) => ipcRenderer.send("stop-shell", { shellid }),
stopAllShells: () => ipcRenderer.send("close-all"),
createNewWindow: () => ipcRenderer.send("create-new-window"),
spawn: (command, scriptPath, shellid, tabidx, terminalidx) =>
ipcRenderer.send("spawn", {
command,
scriptPath,
shellid,
tabidx,
terminalidx,
}),
onCmdOutput: (callback) =>
ipcRenderer.on("shell-output", (event, message) => callback(message)),
openDevTools: () => ipcRenderer.send("devtools"),
loadModules: () => ipcRenderer.send("loadModules"),
onModulesLoaded: (callback) =>
ipcRenderer.on("modulesLoaded", (event, modules) => callback(modules)),
loadFiles: (folderPath, validExtensions) => {
ipcRenderer.send("loadFiles", {
folderName: folderPath,
validExtensions: [validExtensions],
});
},
onFilesLoaded: (callback) => {
ipcRenderer.on("filesLoaded", (event, validFiles) => callback(validFiles));
},
send: (channel, data) => ipcRenderer.send(channel, data),
on: (channel, callback) =>
ipcRenderer.on(channel, (event, ...args) => callback(...args)),
});