mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
feat: Implement application bootstrap and window management
- Added bootstrap functionality to initialize the Electron application. - Created a new paths module to manage application paths and URLs. - Introduced a shutdown service to handle graceful application shutdowns. - Refactored error logging to use a dedicated logger module. - Implemented process killing logic for NodeCG processes across platforms. - Established navigation policies for internal and external URL handling in windows. - Developed window service for creating and managing application windows. - Added tests for application paths, application controller, navigation policies, process killer, and shutdown service.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import path from "node:path";
|
||||
|
||||
import { AppRuntimeConfig } from "../config/runtime-config";
|
||||
|
||||
export type ApplicationPaths = {
|
||||
rootPath: string;
|
||||
sourceNodecgRuntimePath: string;
|
||||
userDataPath: string;
|
||||
nodecgBaseUrl: string;
|
||||
mainDashboardUrl: string;
|
||||
loadingDashboardUrl: string;
|
||||
};
|
||||
|
||||
export function getRootPath(isDev: boolean, compiledMainDir: string, resourcesPath: string): string {
|
||||
return isDev ? path.resolve(compiledMainDir, "../..") : resourcesPath;
|
||||
}
|
||||
|
||||
export function getUserDataPath(appDataPath: string, userDataDirectoryName: string): string {
|
||||
return path.join(appDataPath, userDataDirectoryName);
|
||||
}
|
||||
|
||||
export function getSourceNodecgRuntimePath(rootPath: string): string {
|
||||
return path.resolve(rootPath, "lib", "nodecg");
|
||||
}
|
||||
|
||||
export function getNodecgBaseUrl(nodecgPort: string): string {
|
||||
return `http://127.0.0.1:${nodecgPort}`;
|
||||
}
|
||||
|
||||
export function getDashboardUrl(nodecgPort: string, bundleName: string, dashboardRoute: string): string {
|
||||
return `http://localhost:${nodecgPort}/bundles/${bundleName}/${dashboardRoute}`;
|
||||
}
|
||||
|
||||
export function getApplicationPaths({
|
||||
appConfig,
|
||||
appDataPath,
|
||||
compiledMainDir,
|
||||
isDev,
|
||||
resourcesPath,
|
||||
}: {
|
||||
appConfig: Pick<
|
||||
AppRuntimeConfig,
|
||||
"bundleName" | "loadingDashboardRoute" | "mainDashboardRoute" | "nodecgPort" | "userDataDirectoryName"
|
||||
>;
|
||||
appDataPath: string;
|
||||
compiledMainDir: string;
|
||||
isDev: boolean;
|
||||
resourcesPath: string;
|
||||
}): ApplicationPaths {
|
||||
const rootPath = getRootPath(isDev, compiledMainDir, resourcesPath);
|
||||
|
||||
return {
|
||||
rootPath,
|
||||
sourceNodecgRuntimePath: getSourceNodecgRuntimePath(rootPath),
|
||||
userDataPath: getUserDataPath(appDataPath, appConfig.userDataDirectoryName),
|
||||
nodecgBaseUrl: getNodecgBaseUrl(appConfig.nodecgPort),
|
||||
mainDashboardUrl: getDashboardUrl(appConfig.nodecgPort, appConfig.bundleName, appConfig.mainDashboardRoute),
|
||||
loadingDashboardUrl: getDashboardUrl(appConfig.nodecgPort, appConfig.bundleName, appConfig.loadingDashboardRoute),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user