fix: treat loading as nodecg dashboard route (#9)

This commit is contained in:
Pandipipas
2026-02-10 18:16:59 +01:00
committed by GitHub
parent 28b9312d4f
commit 9286a701d4
2 changed files with 8 additions and 13 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ Wrapper de Electron para empaquetar una instalación de NodeCG que incluya el bu
## Qué hace ## Qué hace
- Arranca `lib/nodecg/index.js` como proceso hijo desde Electron. - 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/<bundle>/dashboard/loading.html`) servida por NodeCG mientras inicia (no usa un archivo local del wrapper).
- Carga el dashboard del bundle en `http://localhost:<puerto>/bundles/<bundle>/<ruta-dashboard>`. - Carga el dashboard del bundle en `http://localhost:<puerto>/bundles/<bundle>/<ruta-dashboard>`.
- Empaqueta NodeCG + assets dentro de la app final con `electron-builder`. - Empaqueta NodeCG + assets dentro de la app final con `electron-builder`.
+7 -12
View File
@@ -16,9 +16,8 @@ const NODE_BINARY = process.env.NODECG_NODE_BINARY ?? "node";
const isDev = !app.isPackaged; const isDev = !app.isPackaged;
const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath; const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath;
const nodecgPath = path.resolve(rootPath, "lib", "nodecg"); 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 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}`; const baseUrl = `http://127.0.0.1:${DEFAULT_NODECG_PORT}`;
let mainWindow: BrowserWindow | null = null; 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 { function enrichNodeCGFailureMessage(baseMessage: string): string {
@@ -245,7 +235,6 @@ async function launch(): Promise<void> {
mainWindow = createMainWindow(); mainWindow = createMainWindow();
loadingWindow = createLoadingWindow(); loadingWindow = createLoadingWindow();
await loadingWindow.loadFile(loadingPath);
loadingWindow.show(); loadingWindow.show();
lastNodeCGOutput = ""; lastNodeCGOutput = "";
@@ -254,6 +243,12 @@ async function launch(): Promise<void> {
await sleep(Math.max(0, LOAD_DELAY_MS)); await sleep(Math.max(0, LOAD_DELAY_MS));
await waitForNodeCGReady(Date.now()); 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) { if (!mainWindow) {
return; return;
} }