Skip to content

Commit 41513d7

Browse files
committed
chore: add getPhNodePath and getSrcNodePath electron api
1 parent 613dec9 commit 41513d7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src-electron/main-app-ipc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { app, ipcMain } = require('electron');
22
const { spawn } = require('child_process');
33
const readline = require('readline');
4+
const path = require('path');
5+
const fs = require('fs');
46
const { productName } = require('./package.json');
57

68
let processInstanceId = 0;
@@ -134,6 +136,24 @@ function registerAppIpcHandlers() {
134136
ipcMain.handle('get-all-items', () => {
135137
return Object.fromEntries(sharedStorageMap);
136138
});
139+
140+
// Get path to phnode binary
141+
ipcMain.handle('get-phnode-path', () => {
142+
const phNodePath = path.resolve(__dirname, 'bin', 'phnode');
143+
if (!fs.existsSync(phNodePath)) {
144+
throw new Error(`phnode binary does not exist: ${phNodePath}`);
145+
}
146+
return phNodePath;
147+
});
148+
149+
// Get path to src-node (for development)
150+
ipcMain.handle('get-src-node-path', () => {
151+
const srcNodePath = path.resolve(__dirname, '..', '..', 'phoenix', 'src-node');
152+
if (!fs.existsSync(srcNodePath)) {
153+
throw new Error(`src-node path does not exist: ${srcNodePath}`);
154+
}
155+
return srcNodePath;
156+
});
137157
}
138158

139159
module.exports = {

src-electron/preload.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
6969

7070
// In-memory storage for multi-window sync (mirrors Tauri's put_item/get_all_items)
7171
putItem: (key, value) => ipcRenderer.invoke('put-item', key, value),
72-
getAllItems: () => ipcRenderer.invoke('get-all-items')
72+
getAllItems: () => ipcRenderer.invoke('get-all-items'),
73+
74+
// Path to phnode binary (src-electron/bin/phnode)
75+
getPhNodePath: () => ipcRenderer.invoke('get-phnode-path'),
76+
77+
// Path to src-node for development (../phoenix/src-node)
78+
// Throws if path does not exist
79+
getSrcNodePath: () => ipcRenderer.invoke('get-src-node-path')
7380
});

0 commit comments

Comments
 (0)