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,32 @@
|
||||
export type AppShutdownState = "running" | "stopping" | "stopped";
|
||||
|
||||
export type ShutdownService = {
|
||||
getState: () => AppShutdownState;
|
||||
stop: () => Promise<void>;
|
||||
};
|
||||
|
||||
export function createShutdownService(stopRuntime: () => Promise<void>): ShutdownService {
|
||||
let state: AppShutdownState = "running";
|
||||
let stopPromise: Promise<void> | null = null;
|
||||
|
||||
return {
|
||||
getState: () => state,
|
||||
stop: () => {
|
||||
if (state === "stopped") {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (stopPromise) {
|
||||
return stopPromise;
|
||||
}
|
||||
|
||||
state = "stopping";
|
||||
stopPromise = stopRuntime().finally(() => {
|
||||
state = "stopped";
|
||||
stopPromise = null;
|
||||
});
|
||||
|
||||
return stopPromise;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user