const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInMainWorld('api', { dialog: { selectDirectory: () => ipcRenderer.invoke('dialog:selectDirectory'), selectFile: (options) => ipcRenderer.invoke('dialog:selectFile', options), selectIcon: () => ipcRenderer.invoke('dialog:selectIcon'), saveFile: (options) => ipcRenderer.invoke('dialog:saveFile', options) }, dir: { readTree: (dirPath) => ipcRenderer.invoke('dir:readTree', dirPath) }, project: { create: (name, dir) => ipcRenderer.invoke('project:create', name, dir), load: (projectPath) => ipcRenderer.invoke('project:load', projectPath), save: (projectPath, data) => ipcRenderer.invoke('project:save', projectPath, data), importFiles: (projectPath, files) => ipcRenderer.invoke('project:importFiles', projectPath, files), removeFile: (projectPath, relativePath) => ipcRenderer.invoke('project:removeFile', projectPath, relativePath), setIcon: (projectPath, iconPath) => ipcRenderer.invoke('project:setIcon', projectPath, iconPath) }, pack: { start: (projectPath, outputPath) => ipcRenderer.invoke('pack:start', projectPath, outputPath), cancel: () => ipcRenderer.invoke('pack:cancel'), onProgress: (callback) => { const handler = (_event, progress) => callback(progress) ipcRenderer.on('pack:progress', handler) return () => ipcRenderer.removeListener('pack:progress', handler) } } })