Enhance: Implement dynamic launcher URL and restore package.json

- Added logic to construct launcher URL based on hydrated device context.
- Implemented dev/production host fallback for demo.localhost.
- Restored missing package.json with proper start and build scripts.
- Finalized IPC handlers for seed and device configuration.
This commit is contained in:
Scott Idem
2026-01-23 14:08:31 -05:00
parent 0497f5767b
commit 30db989b2c
5 changed files with 1140 additions and 31 deletions

31
dist/main/index.js vendored
View File

@@ -56,14 +56,21 @@ async function createWindow() {
nodeIntegration: false,
},
});
// Prioritize demo.localhost for local development
const devUrl = 'http://demo.localhost:5173';
// Fallback URL if local is offline
const fallbackUrl = 'https://dev-demo.oneskyit.com/';
console.log(`Loading UI from: ${devUrl}`);
mainWindow.loadURL(devUrl).catch(() => {
console.warn(`Failed to load ${devUrl}. Falling back to ${fallbackUrl}`);
mainWindow?.loadURL(fallbackUrl);
// Determine target URL based on hydrated config
let targetUrl = 'http://demo.localhost:5173'; // Default Dev Fallback
if (cachedFullConfig && cachedFullConfig.native_device) {
const device = cachedFullConfig.native_device;
const eventId = device.event_id_random || device.event_id;
const locationId = device.event_location_id_random || device.event_location_id || '';
const host = device.app_base_url || 'demo.localhost:5173';
// In development, we likely want to stick to localhost even if app_base_url is set
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;
@@ -85,13 +92,7 @@ electron_1.ipcMain.handle('get-seed-config', async () => {
return cachedSeed || await (0, config_loader_1.loadSeedConfig)();
});
electron_1.ipcMain.handle('get-device-config', async () => {
if (cachedFullConfig)
return cachedFullConfig;
if (cachedSeed) {
cachedFullConfig = await (0, api_client_1.fetchFullConfig)(cachedSeed);
return cachedFullConfig;
}
return null;
return cachedFullConfig;
});
electron_1.ipcMain.handle('get-jwt', async () => {
return null;