fix: Fixed browser referencing main and getting called twice when in dev mode
This commit is contained in:
parent
a78e75335f
commit
7c10f4e4c2
4 changed files with 16 additions and 11 deletions
|
|
@ -49,7 +49,10 @@ function spawnBrowser ()
|
||||||
try
|
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)
|
} catch (error)
|
||||||
{
|
{
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { RunBunServer } from './server';
|
import { RunBunServer } from './server';
|
||||||
import { RunAPIServer } from './api/rpc';
|
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 init from './browser';
|
||||||
import { dirname } from 'pathe';
|
import { dirname } from 'pathe';
|
||||||
import { createInterface } from 'readline';
|
import { createInterface } from 'readline';
|
||||||
|
import { isSteamDeckGameMode } from './utils';
|
||||||
|
|
||||||
const api = RunAPIServer();
|
const api = RunAPIServer();
|
||||||
let bunServer: { stop: () => void; } | undefined;
|
let bunServer: { stop: () => void; } | undefined;
|
||||||
|
|
@ -16,7 +17,7 @@ if (!process.env.PUBLIC_ACCESS)
|
||||||
async function cleanup ()
|
async function cleanup ()
|
||||||
{
|
{
|
||||||
console.log("Cleaning Up");
|
console.log("Cleaning Up");
|
||||||
await appCleanup();
|
await app.cleanup();
|
||||||
bunServer?.stop();
|
bunServer?.stop();
|
||||||
await api.apiServer.stop(true);
|
await api.apiServer.stop(true);
|
||||||
await api.cleanup();
|
await api.cleanup();
|
||||||
|
|
@ -38,17 +39,18 @@ if (process.env.HEADLESS)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Called by user
|
// Called by user
|
||||||
events.on('exitapp', () =>
|
app.events.on('exitapp', () =>
|
||||||
{
|
{
|
||||||
process.send?.({ type: 'exitapp' });
|
process.send?.({ type: 'exitapp' });
|
||||||
cleanup();
|
cleanup();
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
await init(events, Bun.env.FORCE_BROWSER === "true", {
|
await init(app.events, Bun.env.FORCE_BROWSER === "true", {
|
||||||
configPath: dirname(config.path),
|
configPath: dirname(app.config.path),
|
||||||
windowPosition: config.get('windowPosition'),
|
windowPosition: app.config.get('windowPosition'),
|
||||||
windowSize: config.get('windowSize')
|
windowSize: app.config.get('windowSize'),
|
||||||
|
isSteamDeckGameMode: isSteamDeckGameMode()
|
||||||
});
|
});
|
||||||
await cleanup();
|
await cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import { SERVER_URL } from "@shared/constants";
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { getBrowserPath } from "./get-browser";
|
import { getBrowserPath } from "./get-browser";
|
||||||
import { isSteamDeckGameMode } from "../utils";
|
|
||||||
import { ensureDir } from 'fs-extra';
|
import { ensureDir } from 'fs-extra';
|
||||||
import { host } from "./host";
|
import { host } from "./host";
|
||||||
|
|
||||||
|
|
@ -11,6 +10,7 @@ export interface BrowserParams
|
||||||
configPath: string;
|
configPath: string;
|
||||||
windowPosition?: { x: number, y: number; };
|
windowPosition?: { x: number, y: number; };
|
||||||
windowSize?: { width?: number, height?: number; };
|
windowSize?: { width?: number, height?: number; };
|
||||||
|
isSteamDeckGameMode: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function BuildParams (data: BrowserParams)
|
export async function BuildParams (data: BrowserParams)
|
||||||
|
|
@ -54,7 +54,7 @@ export async function BuildParams (data: BrowserParams)
|
||||||
args.push('--allow-insecure-localhost');
|
args.push('--allow-insecure-localhost');
|
||||||
args.push('--auto-accept-camera-and-microphone-capture');
|
args.push('--auto-accept-camera-and-microphone-capture');
|
||||||
|
|
||||||
if (isSteamDeckGameMode())
|
if (data.isSteamDeckGameMode)
|
||||||
{
|
{
|
||||||
args.push('--kiosk');
|
args.push('--kiosk');
|
||||||
} else if (data.windowSize)
|
} else if (data.windowSize)
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ const assets = new Set<string>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Store basePath resolved from Vite config
|
// Store basePath resolved from Vite config
|
||||||
const BASE_PATH = "/";
|
const BASE_PATH = "./";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue