mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 20:12:54 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { createBuildStartupBootstrapRuntimeFactoryDepsHandler } from './startup-bootstrap-deps-builder';
|
||||
import { createBuildAppLifecycleRuntimeRunnerMainDepsHandler } from './startup-lifecycle-main-deps';
|
||||
import { createBuildStartupBootstrapMainDepsHandler } from './startup-bootstrap-main-deps';
|
||||
|
||||
type AppLifecycleRuntimeRunnerMainDeps = Parameters<
|
||||
typeof createBuildAppLifecycleRuntimeRunnerMainDepsHandler
|
||||
>[0];
|
||||
type StartupBootstrapMainDeps = Parameters<typeof createBuildStartupBootstrapMainDepsHandler>[0];
|
||||
type StartupBootstrapRuntimeFactoryDeps = Parameters<
|
||||
typeof createBuildStartupBootstrapRuntimeFactoryDepsHandler
|
||||
>[0];
|
||||
|
||||
export function createStartupRuntimeHandlers<
|
||||
TCliArgs,
|
||||
TStartupState,
|
||||
TStartupBootstrapRuntimeDeps = unknown,
|
||||
>(deps: {
|
||||
appLifecycleRuntimeRunnerMainDeps: AppLifecycleRuntimeRunnerMainDeps;
|
||||
createAppLifecycleRuntimeRunner: (
|
||||
params: AppLifecycleRuntimeRunnerMainDeps,
|
||||
) => (args: TCliArgs) => void;
|
||||
buildStartupBootstrapMainDeps: (
|
||||
startAppLifecycle: (args: TCliArgs) => void,
|
||||
) => StartupBootstrapMainDeps;
|
||||
createStartupBootstrapRuntimeDeps: (
|
||||
deps: StartupBootstrapRuntimeFactoryDeps,
|
||||
) => TStartupBootstrapRuntimeDeps;
|
||||
runStartupBootstrapRuntime: (deps: TStartupBootstrapRuntimeDeps) => TStartupState;
|
||||
applyStartupState: (startupState: TStartupState) => void;
|
||||
}) {
|
||||
const appLifecycleRuntimeRunnerMainDeps =
|
||||
createBuildAppLifecycleRuntimeRunnerMainDepsHandler(deps.appLifecycleRuntimeRunnerMainDeps)();
|
||||
const appLifecycleRuntimeRunner = deps.createAppLifecycleRuntimeRunner(
|
||||
appLifecycleRuntimeRunnerMainDeps,
|
||||
);
|
||||
|
||||
const startupBootstrapMainDeps = createBuildStartupBootstrapMainDepsHandler(
|
||||
deps.buildStartupBootstrapMainDeps(appLifecycleRuntimeRunner),
|
||||
)();
|
||||
const startupBootstrapRuntimeFactoryDeps =
|
||||
createBuildStartupBootstrapRuntimeFactoryDepsHandler(startupBootstrapMainDeps)();
|
||||
|
||||
const runAndApplyStartupState = (): TStartupState => {
|
||||
const startupState = deps.runStartupBootstrapRuntime(
|
||||
deps.createStartupBootstrapRuntimeDeps(startupBootstrapRuntimeFactoryDeps),
|
||||
);
|
||||
deps.applyStartupState(startupState);
|
||||
return startupState;
|
||||
};
|
||||
|
||||
return {
|
||||
appLifecycleRuntimeRunner,
|
||||
runAndApplyStartupState,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user