fix: Fixed browser referencing main and getting called twice when in dev mode

This commit is contained in:
Simeon Radivoev 2026-03-25 22:14:45 +02:00
parent a78e75335f
commit 7c10f4e4c2
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
4 changed files with 16 additions and 11 deletions

View file

@ -49,7 +49,10 @@ function spawnBrowser ()
try
{
return browser(events, process.env.FORCE_BROWSER === "true", { configPath: path.join(tmpdir(), 'gameflow') });
return browser(events, process.env.FORCE_BROWSER === "true", {
configPath: path.join(tmpdir(), 'gameflow'),
isSteamDeckGameMode: false
});
} catch (error)
{
console.error(error);

View file

@ -1,9 +1,10 @@
import { RunBunServer } from './server';
import { RunAPIServer } from './api/rpc';
import { cleanup as appCleanup, config, events } from './api/app';
import * as app from './api/app';
import init from './browser';
import { dirname } from 'pathe';
import { createInterface } from 'readline';
import { isSteamDeckGameMode } from './utils';
const api = RunAPIServer();
let bunServer: { stop: () => void; } | undefined;
@ -16,7 +17,7 @@ if (!process.env.PUBLIC_ACCESS)
async function cleanup ()
{
console.log("Cleaning Up");
await appCleanup();
await app.cleanup();
bunServer?.stop();
await api.apiServer.stop(true);
await api.cleanup();
@ -38,17 +39,18 @@ if (process.env.HEADLESS)
});
// Called by user
events.on('exitapp', () =>
app.events.on('exitapp', () =>
{
process.send?.({ type: 'exitapp' });
cleanup();
});
} else
{
await init(events, Bun.env.FORCE_BROWSER === "true", {
configPath: dirname(config.path),
windowPosition: config.get('windowPosition'),
windowSize: config.get('windowSize')
await init(app.events, Bun.env.FORCE_BROWSER === "true", {
configPath: dirname(app.config.path),
windowPosition: app.config.get('windowPosition'),
windowSize: app.config.get('windowSize'),
isSteamDeckGameMode: isSteamDeckGameMode()
});
await cleanup();
}

View file

@ -2,7 +2,6 @@ import { SERVER_URL } from "@shared/constants";
import os from 'node:os';
import path from 'node:path';
import { getBrowserPath } from "./get-browser";
import { isSteamDeckGameMode } from "../utils";
import { ensureDir } from 'fs-extra';
import { host } from "./host";
@ -11,6 +10,7 @@ export interface BrowserParams
configPath: string;
windowPosition?: { x: number, y: number; };
windowSize?: { width?: number, height?: number; };
isSteamDeckGameMode: boolean;
}
export async function BuildParams (data: BrowserParams)
@ -54,7 +54,7 @@ export async function BuildParams (data: BrowserParams)
args.push('--allow-insecure-localhost');
args.push('--auto-accept-camera-and-microphone-capture');
if (isSteamDeckGameMode())
if (data.isSteamDeckGameMode)
{
args.push('--kiosk');
} else if (data.windowSize)

View file

@ -464,7 +464,7 @@ const assets = new Set<string>([
]);
// Store basePath resolved from Vite config
const BASE_PATH = "/";
const BASE_PATH = "./";
/**