diff --git a/README.md b/README.md index ca78040..ee99ee6 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Wrapper de Electron para empaquetar una instalación de NodeCG que incluya el bu ## Qué hace - Arranca `lib/nodecg/index.js` como proceso hijo desde Electron. -- Muestra la pantalla de carga propia del bundle (`dashboard/loading.html`) mientras NodeCG inicia. +- Muestra la ruta de dashboard de carga del bundle (`/bundles//dashboard/loading.html`) servida por NodeCG mientras inicia (no usa un archivo local del wrapper). - Carga el dashboard del bundle en `http://localhost:/bundles//`. - Empaqueta NodeCG + assets dentro de la app final con `electron-builder`. diff --git a/src/main/main.ts b/src/main/main.ts index d37680f..80ebb46 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -16,9 +16,8 @@ const NODE_BINARY = process.env.NODECG_NODE_BINARY ?? "node"; const isDev = !app.isPackaged; const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath; const nodecgPath = path.resolve(rootPath, "lib", "nodecg"); -const loadingPath = path.join(rootPath, "lib", "nodecg", "bundles", DEFAULT_BUNDLE_NAME, DEFAULT_LOADING_ROUTE); - const dashboardUrl = `http://localhost:${DEFAULT_NODECG_PORT}/bundles/${DEFAULT_BUNDLE_NAME}/${DEFAULT_DASHBOARD_ROUTE}`; +const loadingUrl = `http://localhost:${DEFAULT_NODECG_PORT}/bundles/${DEFAULT_BUNDLE_NAME}/${DEFAULT_LOADING_ROUTE}`; const baseUrl = `http://127.0.0.1:${DEFAULT_NODECG_PORT}`; let mainWindow: BrowserWindow | null = null; @@ -127,15 +126,6 @@ function validateNodeCGInstall(): void { ); } - if (!fs.existsSync(loadingPath)) { - throw new Error( - [ - "No se encontró el loading del dashboard dentro del bundle.", - `Ruta esperada: ${loadingPath}`, - "Ajusta SCOREKO_LOADING_ROUTE o verifica que exista dashboard/loading.html en el bundle.", - ].join("\n"), - ); - } } function enrichNodeCGFailureMessage(baseMessage: string): string { @@ -245,7 +235,6 @@ async function launch(): Promise { mainWindow = createMainWindow(); loadingWindow = createLoadingWindow(); - await loadingWindow.loadFile(loadingPath); loadingWindow.show(); lastNodeCGOutput = ""; @@ -254,6 +243,12 @@ async function launch(): Promise { await sleep(Math.max(0, LOAD_DELAY_MS)); await waitForNodeCGReady(Date.now()); + try { + await loadingWindow.loadURL(loadingUrl); + } catch (error) { + log("No se pudo cargar la ruta de loading del bundle", loadingUrl, error); + } + if (!mainWindow) { return; }