import type { EditorOperation, EditorOperationMode } from '../core/editor-operation.js'; import type { MaybePromise } from '../fields/field-value.js'; /** Immutable cancellation context supplied while a Host reads a record. */ export interface HostReadContext { /** Signal aborted when the owning editor work is cancelled or replaced. */ readonly signal: AbortSignal; } /** Immutable context supplied while a host applies a canonical result. */ export interface HostApplyContext { /** Signal aborted when the owning operation is cancelled or destroyed. */ readonly signal: AbortSignal; /** Operation whose canonical result is being applied. */ readonly operation: Extract; /** Presentation surface that initiated the operation. */ readonly mode: EditorOperationMode; } /** One canonical row replacement supplied to a batch-capable Host. */ export interface HostBatchUpdate { readonly target: TTarget; readonly row: TRow; } /** Optional Host support for applying multiple canonical replacement rows. */ export interface HostBatchUpdateCapability { applyUpdates(updates: readonly Readonly>[], context: Readonly): Promise; } /** Minimal record operations required by the host-independent editor runtime. */ export interface EditorHost { /** Event destination used for editor lifecycle notifications. */ readonly eventTarget: EventTarget; /** Stable object identity used to enforce exclusive editor ownership. */ readonly ownershipKey: object; /** Reads the current record represented by an opaque host target. */ read(target: TTarget, context?: Readonly): MaybePromise>; /** Applies a created record and resolves after presentation is stable. */ applyCreate(row: TRow, context: Readonly): Promise; /** Applies a replacement record and resolves after presentation is stable. */ applyUpdate(target: TTarget, row: TRow, context: Readonly): Promise; /** Applies record removal and resolves after presentation is stable. */ applyRemove(targets: readonly TTarget[], context: Readonly): Promise; /** Releases resources owned by this host wrapper. */ destroy(): void; } /** Optional host support for resolving consumer selection. */ export interface HostSelectionCapability { getSelectedTargets(unavailableMessage?: string): readonly TTarget[]; } /** Optional host support for a stable consumer-visible refresh. */ export interface HostRefreshCapability { refresh(signal: AbortSignal, action?: () => Promise): Promise; } /** Optional host support for editor state and presentation notifications. */ export interface HostPresentationCapability { notifyEditorStateChange(): void; completeEditorPresentation(): void; } /** One record exposed by an optional host collection capability. */ export interface HostRecordEntry { readonly target: TTarget; readonly row: Readonly; } /** Optional host support for enumerating records used by local validation. */ export interface HostRowCollectionCapability { entries(): Iterable>>; } /** Detects selection support without adding optional methods to EditorHost. */ export declare function hasHostSelectionCapability(host: object): host is HostSelectionCapability; /** Detects support for applying multiple canonical replacement rows. */ export declare function hasHostBatchUpdateCapability(host: object): host is HostBatchUpdateCapability; /** Detects refresh support without adding optional methods to EditorHost. */ export declare function hasHostRefreshCapability(host: object): host is HostRefreshCapability; /** Detects presentation notifications supplied by a concrete Host. */ export declare function hasHostPresentationCapability(host: object): host is HostPresentationCapability; /** Detects record collection support used by local uniqueness validation. */ export declare function hasHostRowCollectionCapability(host: object): host is HostRowCollectionCapability;