import type { BaseLayoutedDiagram } from "@hylimo/diagram-common"; import type { IncrementalUpdate, TransactionalAction } from "@hylimo/diagram-protocol"; import type { TextDocumentContentChangeEvent } from "vscode-languageserver-textdocument"; import type { Diagram } from "../diagram/diagram.js"; import type { SharedDiagramUtils } from "../sharedDiagramUtils.js"; /** * Handles TransactionActions modifying the textdocument */ export declare class TransactionManager { private readonly diagram; private readonly utils; /** * Current transactionId */ private currentTransactionId?; /** * Current edit handling actions of the same transaction */ private edit?; /** * Last action which caused a text update */ private lastAppliedAction?; /** * Last action which was handled or skipped */ private lastKnownAction?; /** * If true, the diagram has been updated since the last text update, * meaning a new text update is possible */ private hasUpdatedDiagram; /** * Returns true if the manager is currently handling a transaction */ get isActive(): boolean; /** * Creates a new TransactionManager which handles edits to the specified textDocument * * @param diagram the associated Diagram * @param utils the shared diagram utils */ constructor(diagram: Diagram, utils: SharedDiagramUtils); /** * Handles an action. Does currently not support concurrent/interleaved transactions * Every action causes an incremental update. * Also, a relayout is scheduled if possible. * * @param action the action to handle * @returns the incremental updates */ handleAction(action: TransactionalAction): Promise; /** * Updates the text document if possible, meaning if the last known action has not been applied yet. */ private updateTextDocumentIfPossible; /** * Resets currentTransactionId, edit, lastKnownAction and lastAppliedAction. * Usually called after an action commits. */ private resetActionState; /** * Handles an transactional action internally. * Either delays the action, or applies it. * If it is applied, either an incremental update is calculated or a text document modification is created. * * @param action the action to handle * @returns the computed result of the action */ private createHandleActionResult; /** * Updates a LayoutedDiagram based on the lastKnownAction. * Also triggers any outstanding actions. * * @param layoutedDiagram the layouted diagram */ updateLayoutedDiagram(layoutedDiagram: BaseLayoutedDiagram): void; /** * Update the current entries based on the changes. * Updates indices. * * @param changes the changes to the text document */ updateGeneratorEntries(changes: TextDocumentContentChangeEvent[]): void; } //# sourceMappingURL=transactionManager.d.ts.map