import type { IStateManager } from './interfaces.js'; import type { Logger } from './logger.js'; import type { BuildStatus, Target } from './types.js'; import { type ProcessInfo } from './utils/process-manager.js'; export type { ProcessInfo } from './utils/process-manager.js'; export interface PostBuildResult { name: string; status: 'pending' | 'running' | 'success' | 'failure'; summary?: string; lines?: string[]; startedAt?: string; completedAt?: string; durationMs?: number; exitCode?: number; formatterError?: string; trigger?: 'success' | 'failure'; } export interface AppInfo { bundleId?: string; outputPath?: string; iconPath?: string; } export interface BuildStatistics { successfulBuilds: Array<{ duration: number; timestamp: string; }>; averageDuration: number; minDuration?: number; maxDuration?: number; } export interface PoltergeistState { version: string; projectPath: string; projectName: string; target: string; targetType: string; configPath: string; process: ProcessInfo; lastBuild?: BuildStatus; appInfo?: AppInfo; buildStats?: BuildStatistics; lastBuildError?: { exitCode: number; errorOutput: string[]; lastOutput: string[]; command: string; timestamp: string; }; postBuildResults?: Record; } export declare class StateManager implements IStateManager { private logger; private projectRoot; private processManager; private states; private stateDir; constructor(projectRoot: string, logger: Logger); /** * Get full path to state file */ private getStateFilePath; /** * Initialize state for a target */ initializeState(target: Target): Promise; /** * Update build status in state */ updateBuildStatus(targetName: string, buildStatus: BuildStatus): Promise; /** * Update app info (e.g., after successful build) */ updateAppInfo(targetName: string, appInfo: Partial): Promise; /** * Update build error context for better diagnostics */ updateBuildError(targetName: string, errorContext: { exitCode: number; errorOutput: string[]; lastOutput: string[]; command: string; timestamp: string; }): Promise; updatePostBuildResult(targetName: string, hookName: string, updates: Partial): Promise; /** * Forcefully clear locks and mark processes inactive for a target. * Used by manual --force builds to take over from stuck processes. */ forceUnlock(targetName: string): Promise; /** * Writes state to file using write-file-atomic for robust cross-platform atomic writes. * This prevents corruption during concurrent writes and handles Windows race conditions. */ private writeState; /** * Ensures state directory exists with Windows-specific retry logic */ private ensureStateDirectory; /** * Read state from file */ readState(targetName: string): Promise; /** * Checks if target is locked by another active Poltergeist process. * Uses multi-layer validation: * 1. Process ownership (same PID = not locked) * 2. Process active flag * 3. Heartbeat freshness (5 minute timeout for stale detection) * * This prevents duplicate builds across multiple Poltergeist instances. */ isLocked(targetName: string): Promise; /** * Start heartbeat updates */ startHeartbeat(): void; /** * Stop heartbeat updates */ stopHeartbeat(): void; /** * Update heartbeat for all active states (called by ProcessManager) */ protected updateHeartbeat(): Promise; /** * Update state with partial updates */ updateState(targetName: string, updates: Partial): Promise; /** * Discover all states in the state directory */ discoverStates(): Promise>>; /** * Clean up state files on exit */ cleanup(): Promise; /** * Remove state file */ removeState(targetName: string): Promise; /** * List all state files in the state directory */ static listAllStates(): Promise; } //# sourceMappingURL=state.d.ts.map