-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
55 lines (47 loc) · 3.59 KB
/
Copy pathpreload.js
File metadata and controls
55 lines (47 loc) · 3.59 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
48
49
50
51
52
53
54
55
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("electronAPI", {
// Menu event listeners
onMenuOpen : (callback) => ipcRenderer.on("menu-open", callback),
onMenuSave : (callback) => ipcRenderer.on("menu-save", callback),
onMenuRevert : (callback) => ipcRenderer.on("menu-revert", callback),
onMenuRevertDefaults: (callback) => ipcRenderer.on("menu-revert-defaults", callback),
onMenuAddFile : (callback) => ipcRenderer.on("menu-add-file", callback),
onMenuDeleteFile : (callback) => ipcRenderer.on("menu-delete-file", callback),
onMenuToggleDeleted : (callback) => ipcRenderer.on("menu-toggle-deleted", (event, checked) => callback(checked)),
onMenuDoctor : (callback) => ipcRenderer.on("menu-doctor", callback),
onOpenProjectPath : (callback) => ipcRenderer.on("open-project-path", (event, projectPath) => callback(projectPath)),
// Dialog handlers
openDirectoryDialog: () => ipcRenderer.invoke("open-directory-dialog"),
// Project operations
validateProject : (projectPath) => ipcRenderer.invoke("validate-project", projectPath),
scanPatternFiles: (projectPath) => ipcRenderer.invoke("scan-pattern-files", projectPath),
readFile : (filePath) => ipcRenderer.invoke("read-file", filePath),
// Preview operations
createTempDirectory : () => ipcRenderer.invoke("create-temp-directory"),
writeTempFile : (tempDir, subdir, filename, content) => ipcRenderer.invoke("write-temp-file", tempDir, subdir, filename, content),
runMulleMatch : (projectPath, tempDir, envVars) => ipcRenderer.invoke("run-mulle-match", projectPath, tempDir, envVars),
evaluateEnvVars : (projectPath) => ipcRenderer.invoke("evaluate-env-vars", projectPath),
cleanupTempDirectory: (tempDir) => ipcRenderer.invoke("cleanup-temp-directory", tempDir),
// Environment operations
getMulleEnv: (projectPath, keyName) => ipcRenderer.invoke("get-mulle-env", projectPath, keyName),
setMulleEnv: (projectPath, keyName, value) => ipcRenderer.invoke("set-mulle-env", projectPath, keyName, value),
// File operations for saving
writePatternFile : (filePath, content) => ipcRenderer.invoke("write-pattern-file", filePath, content),
readPatternFile : (filePath) => ipcRenderer.invoke("read-pattern-file", filePath),
createSymlink : (target, linkPath) => ipcRenderer.invoke("create-symlink", target, linkPath),
removeFile : (filePath) => ipcRenderer.invoke("remove-file", filePath),
listDirectory : (dirPath) => ipcRenderer.invoke("list-directory", dirPath),
removeDirectory : (dirPath) => ipcRenderer.invoke("remove-directory", dirPath),
fileExists : (filePath) => ipcRenderer.invoke("file-exists", filePath),
createCraftDirectory: (projectPath) => ipcRenderer.invoke("create-craft-directory", projectPath),
updateMenuState : (state) => ipcRenderer.invoke("update-menu-state", state),
runDoctor : (projectPath) => ipcRenderer.invoke("run-doctor", projectPath),
// Recent projects
getRecentProjects : () => ipcRenderer.invoke("get-recent-projects"),
addRecentProject : (projectPath) => ipcRenderer.invoke("add-recent-project", projectPath),
onOpenRecentProject: (callback) => ipcRenderer.on("open-recent-project", (event, projectPath) => callback(projectPath)),
// Preferences
getPreferences : () => ipcRenderer.invoke("get-preferences"),
setPreferences : (prefs) => ipcRenderer.invoke("set-preferences", prefs),
onMenuPreferences: (callback) => ipcRenderer.on("menu-preferences", callback),
});