import type { BatchEditOperationContext, CreateOperationContext, EditOperationContext, RefreshOperationContext, RemoveOperationContext } from '../alt-editor-lite-options.js'; import type { EditorOperation, EditorOperationMode, EditorOperationTarget } from '../editor-operation.js'; /** Request identity shared by dialog, inline, and refresh operations. */ export interface OwnedOperationRequest { readonly abortController: AbortController; readonly mode: EditorOperationMode; readonly operation: TOperation; readonly sequence: number; readonly target?: Readonly; readonly targets?: readonly Readonly[]; } /** Owns one asynchronous editor operation at a time. */ export declare class OperationOwner { #private; /** Begins a request and invalidates any earlier request. */ begin(operation: 'create', mode: 'dialog'): OwnedOperationRequest<'create'>; begin(operation: 'edit', mode: 'dialog' | 'inline', target: Readonly): OwnedOperationRequest<'edit'>; begin(operation: 'batchEdit', mode: 'dialog', targets: readonly Readonly[]): OwnedOperationRequest<'batchEdit'>; begin(operation: 'remove', mode: 'dialog'): OwnedOperationRequest<'remove'>; begin(operation: 'refresh', mode: 'api'): OwnedOperationRequest<'refresh'>; /** Returns whether a request still owns every asynchronous continuation. */ owns(request: OwnedOperationRequest): boolean; /** Creates the public callback context for an owned request. */ context(request: OwnedOperationRequest<'create'>): CreateOperationContext; context(request: OwnedOperationRequest<'edit'>): EditOperationContext; context(request: OwnedOperationRequest<'edit'>, operation: 'refresh'): RefreshOperationContext; context(request: OwnedOperationRequest<'batchEdit'>): BatchEditOperationContext; context(request: OwnedOperationRequest<'remove'>): RemoveOperationContext; context(request: OwnedOperationRequest<'refresh'>): RefreshOperationContext; /** Stops waiting when the owning request is cancelled or destroyed. */ wait(request: OwnedOperationRequest, value: T | PromiseLike): Promise; /** Completes a request only when it still owns the operation. */ complete(request: OwnedOperationRequest): void; /** Aborts the current request, optionally limited to one presentation mode. */ abort(mode?: EditorOperationMode): void; /** Invalidates late continuations without changing the destroyed state. */ invalidate(): void; /** Permanently aborts and rejects ownership for every request. */ destroy(): void; }