UNPKG

histoire

Version:

A fast story book powered by Vite

28 lines (27 loc) • 1.46 kB
import { createRestartCoordinator } from '@histoire/dev-proxy/lifecycle'; import { hasUnconfirmedCleanup, withCleanupDeadline } from './cleanup.js'; import { watchProjectConfiguration } from './config-watchers.js'; import { startProjectRuntime } from './start.js'; /** SDK/MCP compatibility adapter; restart scheduling belongs to dev-proxy package. */ export function createProjectRuntimeController(options = {}, dependencies = {}) { return createRestartCoordinator({ acquire: (signal, active) => (dependencies.start ?? startProjectRuntime)(options, signal, active), watch: (runtime, restart) => (dependencies.watch ?? watchProjectConfiguration)(runtime, options, restart, runtime.configurationRevision), onGeneration: options.onGeneration, onBeforeRelease: options.onBeforeRelease, onError: options.onError, isUnsafeCleanup: hasUnconfirmedCleanup, withDeadline: withCleanupDeadline, }); } /** One CLI child runs once; config watching and replacement belong to its parent. */ export function createSingleRunProjectRuntimeController(options = {}) { return createRestartCoordinator({ acquire: (signal, active) => startProjectRuntime(options, signal, active), onGeneration: options.onGeneration, onBeforeRelease: options.onBeforeRelease, onError: options.onError, isUnsafeCleanup: hasUnconfirmedCleanup, withDeadline: withCleanupDeadline, }); }