Where does “Export notes” go?
- Page → bridge
A small API
The page can only call what the preload script exposes.
- Between processes
A named message
The bridge sends a channel name the main process listens on.
- Main process
The real work
The handler formats the data and writes the file.
Ask about the export
Use our Notes example (six files) or any Electron app you may examine. Packaged apps keep their code in resources/app.asar; REP reads inside it, so there is nothing to unpack by hand.
›Use REP to analyze the app in ./notes-example. Trace the Export notes button: the API the page calls, the IPC channel, the handler, and the file it writes. Cite files and lines.
Trace it
The page calls a small API
document.querySelector('#export').addEventListener('click', async () => {
const file = await window.notesApi.saveCsv();
status.textContent = `Saved to ${file}`;
});The preload script turns it into a message
contextBridge.exposeInMainWorld('notesApi', {
list: () => ipcRenderer.invoke('notes:list'),
saveCsv: () => ipcRenderer.invoke('notes:save-csv'),
});The main process answers it
ipcMain.handle('notes:save-csv', () => {
const file = path.join(app.getPath('documents'), 'notes-export.csv');
fs.writeFileSync(file, toCsv(notes, ['id', 'title', 'created']));
return file;
});The channel name is the join: one invoke in the bridge, one handle in the main process. REP lists every exposed API, every channel and every handler, and pairs them, so the agent follows the feature instead of searching for words.
From the terminal
The same analysis runs without an agent and prints JSON you can keep:
rep analyze-javascript-application ./notes-example --jsonRead the writer
function toCsv(rows, columns) {
const head = columns.join(',');
const body = rows.map((r) => columns.map((c) => cell(r[c])).join(','));
return [head, ...body].join('\n') + '\n';
}So the file starts with id,title,created, then one line per note; a title with a comma or a quote gets wrapped in quotes by cell.