mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-27 06:12:05 -07:00
refactor: compose startup and setup window wiring
This commit is contained in:
49
src/main/runtime/composers/headless-startup-composer.ts
Normal file
49
src/main/runtime/composers/headless-startup-composer.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { createStartupRuntimeHandlers } from '../startup-runtime-handlers';
|
||||
import type { ComposerInputs, ComposerOutputs } from './contracts';
|
||||
|
||||
type StartupRuntimeHandlersDeps<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps> = Parameters<
|
||||
typeof createStartupRuntimeHandlers<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps>
|
||||
>[0];
|
||||
type StartupRuntimeHandlers<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps> = ReturnType<
|
||||
typeof createStartupRuntimeHandlers<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps>
|
||||
>;
|
||||
|
||||
export type HeadlessStartupComposerOptions<
|
||||
TCliArgs,
|
||||
TStartupState,
|
||||
TStartupBootstrapRuntimeDeps,
|
||||
> = ComposerInputs<{
|
||||
startupRuntimeHandlersDeps: StartupRuntimeHandlersDeps<
|
||||
TCliArgs,
|
||||
TStartupState,
|
||||
TStartupBootstrapRuntimeDeps
|
||||
>;
|
||||
}>;
|
||||
|
||||
export type HeadlessStartupComposerResult<
|
||||
TCliArgs,
|
||||
TStartupState,
|
||||
TStartupBootstrapRuntimeDeps,
|
||||
> = ComposerOutputs<
|
||||
Pick<
|
||||
StartupRuntimeHandlers<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps>,
|
||||
'appLifecycleRuntimeRunner' | 'runAndApplyStartupState'
|
||||
>
|
||||
>;
|
||||
|
||||
export function composeHeadlessStartupHandlers<
|
||||
TCliArgs,
|
||||
TStartupState,
|
||||
TStartupBootstrapRuntimeDeps,
|
||||
>(
|
||||
options: HeadlessStartupComposerOptions<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps>,
|
||||
): HeadlessStartupComposerResult<TCliArgs, TStartupState, TStartupBootstrapRuntimeDeps> {
|
||||
const { appLifecycleRuntimeRunner, runAndApplyStartupState } = createStartupRuntimeHandlers(
|
||||
options.startupRuntimeHandlersDeps,
|
||||
);
|
||||
|
||||
return {
|
||||
appLifecycleRuntimeRunner,
|
||||
runAndApplyStartupState,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user