import type { CircuitTreeResponseDto, ProjectHistoryStateDto, } from "../types"; export interface CircuitEditorSnapshot { tree: CircuitTreeResponseDto; history: ProjectHistoryStateDto; } export async function loadCircuitEditorSnapshot( readTree: () => Promise, readHistory: () => Promise, maxAttempts = 3 ): Promise { for (let attempt = 0; attempt < maxAttempts; attempt += 1) { const tree = await readTree(); const history = await readHistory(); if (tree.currentRevision === history.currentRevision) { return { tree, history }; } } throw new Error( "Der Projektstand hat sich während des Ladens geändert. Bitte erneut versuchen." ); }