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

View File

@@ -26,16 +26,26 @@ async function createWindow() {
},
});
// 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}`);
// Determine target URL based on hydrated config
let targetUrl = 'http://demo.localhost:5173'; // Default Dev Fallback
mainWindow.loadURL(devUrl).catch(() => {
console.warn(`Failed to load ${devUrl}. Falling back to ${fallbackUrl}`);
mainWindow?.loadURL(fallbackUrl);
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', () => {
@@ -63,12 +73,7 @@ ipcMain.handle('get-seed-config', async () => {
});
ipcMain.handle('get-device-config', async () => {
if (cachedFullConfig) return cachedFullConfig;
if (cachedSeed) {
cachedFullConfig = await fetchFullConfig(cachedSeed);
return cachedFullConfig;
}
return null;
return cachedFullConfig;
});
ipcMain.handle('get-jwt', async () => {