mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
e3d3936156
- 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.
33 lines
728 B
TypeScript
33 lines
728 B
TypeScript
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;
|
|
},
|
|
};
|
|
}
|