computer-auditor / electron /preload.ts
algorembrant's picture
Upload 28 files
b4143a2 verified
import { contextBridge, ipcRenderer } from 'electron'
export interface AuditorAPI {
drives: () => Promise<unknown>
listDir: (dirPath: string, opts?: { maxEntries?: number }) => Promise<unknown>
folderSize: (dirPath: string) => Promise<unknown>
largeFiles: (rootPath: string, minBytes: number, maxResults: number) => Promise<unknown>
processes: () => Promise<unknown>
services: () => Promise<unknown>
installed: () => Promise<unknown>
system: () => Promise<unknown>
network: () => Promise<unknown>
env: (keys?: string[]) => Promise<unknown>
startup: () => Promise<unknown>
temp: () => Promise<unknown>
tasks: () => Promise<unknown>
features: () => Promise<string>
openExplorer: (p: string) => Promise<void>
killProcess: (pid: number) => Promise<void>
openExternal: (url: string) => Promise<void>
clipboardWriteText: (text: string) => Promise<void>
notesGetAll: () => Promise<Record<string, string>>
notesSet: (key: string, value: string) => Promise<Record<string, string>>
notesDelete: (key: string) => Promise<Record<string, string>>
}
const api: AuditorAPI = {
drives: () => ipcRenderer.invoke('audit:drives'),
listDir: (dirPath, opts) => ipcRenderer.invoke('audit:listDir', dirPath, opts),
folderSize: (dirPath) => ipcRenderer.invoke('audit:folderSize', dirPath),
largeFiles: (rootPath, minBytes, maxResults) =>
ipcRenderer.invoke('audit:largeFiles', rootPath, minBytes, maxResults),
processes: () => ipcRenderer.invoke('audit:processes'),
services: () => ipcRenderer.invoke('audit:services'),
installed: () => ipcRenderer.invoke('audit:installed'),
system: () => ipcRenderer.invoke('audit:system'),
network: () => ipcRenderer.invoke('audit:network'),
env: (keys) => ipcRenderer.invoke('audit:env', keys),
startup: () => ipcRenderer.invoke('audit:startup'),
temp: () => ipcRenderer.invoke('audit:temp'),
tasks: () => ipcRenderer.invoke('audit:tasks'),
features: () => ipcRenderer.invoke('audit:features'),
openExplorer: (p) => ipcRenderer.invoke('audit:openExplorer', p),
killProcess: (pid) => ipcRenderer.invoke('audit:killProcess', pid),
openExternal: (url) => ipcRenderer.invoke('audit:openExternal', url),
clipboardWriteText: (text) => ipcRenderer.invoke('clipboard:writeText', text),
notesGetAll: () => ipcRenderer.invoke('notes:getAll'),
notesSet: (key, value) => ipcRenderer.invoke('notes:set', key, value),
notesDelete: (key) => ipcRenderer.invoke('notes:delete', key),
}
contextBridge.exposeInMainWorld('auditor', api)