Fix: Finalize Phase 3 OS interactions and telemetry bridge

- Implemented get_device_info for OS/Network telemetry.
- Added run_cmd_sync using execSync for blocking-style commands.
- Implemented kill_processes (plural) to support multiple process termination.
- Standardized open_local_file_v2 and all bridge methods to snake_case.
- Synchronized preload and main handlers with SvelteKit relay expectations.
This commit is contained in:
Scott Idem
2026-01-23 17:23:14 -05:00
parent f6875acc72
commit e942b234c4
11 changed files with 170 additions and 112 deletions

48
dist/main/index.js vendored
View File

@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const path = __importStar(require("path"));
const os = __importStar(require("os"));
const config_loader_1 = require("./config_loader");
const api_client_1 = require("./api_client");
const shell_handlers_1 = require("./shell_handlers");
@@ -43,7 +44,6 @@ let mainWindow = null;
let cachedSeed = null;
let cachedFullConfig = null;
async function createWindow() {
// 1. Initial Load of Configs
cachedSeed = await (0, config_loader_1.loadSeedConfig)();
if (cachedSeed) {
cachedFullConfig = await (0, api_client_1.fetchFullConfig)(cachedSeed);
@@ -58,7 +58,6 @@ async function createWindow() {
nodeIntegration: false,
},
});
// Determine target URL based on hydrated config
let targetUrl = 'http://demo.localhost:5173';
if (cachedFullConfig && cachedFullConfig.native_device) {
const device = cachedFullConfig.native_device;
@@ -68,37 +67,44 @@ async function createWindow() {
const useHost = (host.includes('localhost')) ? host : 'demo.localhost:5173';
targetUrl = `http://${useHost}/events/${eventId}/launcher/${locationId}`;
}
console.log(`Launcher: Navigating to ${targetUrl}`);
mainWindow.loadURL(targetUrl).catch(() => {
console.warn(`Failed to load ${targetUrl}. Falling back to dev-demo...`);
mainWindow?.loadURL('https://dev-demo.oneskyit.com/');
});
mainWindow.on('closed', () => {
mainWindow = null;
});
mainWindow.on('closed', () => { mainWindow = null; });
}
// Register OS-level handlers
(0, shell_handlers_1.registerShellHandlers)();
(0, file_handlers_1.registerFileHandlers)();
electron_1.app.on('ready', createWindow);
electron_1.app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
if (process.platform !== 'darwin')
electron_1.app.quit();
}
});
electron_1.app.on('activate', () => {
if (mainWindow === null) {
if (mainWindow === null)
createWindow();
});
electron_1.ipcMain.handle('get-seed-config', async () => cachedSeed || await (0, config_loader_1.loadSeedConfig)());
electron_1.ipcMain.handle('get-device-config', async () => cachedFullConfig);
electron_1.ipcMain.handle('get-jwt', async () => null);
electron_1.ipcMain.handle('get-device-info', async () => {
const interfaces = os.networkInterfaces();
const addresses = [];
for (const name of Object.keys(interfaces)) {
for (const net of interfaces[name]) {
if (net.family === 'IPv4' && !net.internal) {
addresses.push(net.address);
}
}
}
});
// IPC Handlers
electron_1.ipcMain.handle('get-seed-config', async () => {
return cachedSeed || await (0, config_loader_1.loadSeedConfig)();
});
electron_1.ipcMain.handle('get-device-config', async () => {
return cachedFullConfig;
});
electron_1.ipcMain.handle('get-jwt', async () => {
return null;
return {
platform: os.platform(),
release: os.release(),
arch: os.arch(),
hostname: os.hostname(),
cpus: os.cpus().length,
total_mem: os.totalmem(),
free_mem: os.freemem(),
ip_addresses: addresses
};
});
//# sourceMappingURL=index.js.map