Files
OSIT-AE-App-Native-Electron/dist/main/index.js
Scott Idem 280de213c1 Fix: Standardize Electron bridge and implement robust caching
- Refactored all IPC methods and parameters to snake_case for consistency with SvelteKit.
- Implemented exhaustive background caching engine with download locking.
- Reverted to legacy-proven flat hash storage pattern (hash.file).
- Added axios for reliable stream-based binary downloads.
- Updated preload and main handlers to support recursive room data fetching.
2026-01-23 16:30:23 -05:00

104 lines
4.0 KiB
JavaScript

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const path = __importStar(require("path"));
const config_loader_1 = require("./config_loader");
const api_client_1 = require("./api_client");
const shell_handlers_1 = require("./shell_handlers");
const file_handlers_1 = require("./file_handlers");
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);
}
mainWindow = new electron_1.BrowserWindow({
width: 1400,
height: 900,
title: 'OSIT Aether Launcher (Native)',
webPreferences: {
preload: path.join(__dirname, '../preload/index.js'),
contextIsolation: true,
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;
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';
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;
});
}
// 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') {
electron_1.app.quit();
}
});
electron_1.app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
// 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;
});
//# sourceMappingURL=index.js.map