/** * Host-side cancellation for browser `insert`, `mutations.apply`, and `extract`. * * `signal` and `timeoutMs` stay on the caller side. They are not serialized * into the worker. An already-aborted signal or a `timeoutMs` of 0 finishes * as {@link OperationCancellationError} `CANCELLED` before dispatch and does * not change the document. Aborting after the worker has started the command * does not roll it back: the call rejects as `INDETERMINATE` so the caller * stops waiting, and must read the document before deciding whether to retry. * Replacing the document or closing the editor also settles as `INDETERMINATE`. */ export interface OperationCancellation { /** Abort before dispatch, or ask the host to cancel a command that has not started. */ signal?: AbortSignal; /** * Milliseconds from the call. `0` is already expired and does not dispatch. * A positive deadline uses the same outcome rules as `signal`. */ timeoutMs?: number; } export type OperationCancellationCode = 'CANCELLED' | 'INDETERMINATE'; /** * Machine-readable outcome for a cancellation that did not return the * operation's normal receipt. * * `CANCELLED` means the command did not start and the document is unchanged. * Retrying that same call is safe. `INDETERMINATE` means the call cannot * prove whether a mutation committed. Read the current document before * retrying. A resolved receipt means the work committed; do not retry it. */ export declare class OperationCancellationError extends Error { readonly code: OperationCancellationCode; readonly details?: { cause?: string; }; constructor(code: OperationCancellationCode, message: string, details?: { cause?: string; }); } export declare function cancelledBeforeDispatch(): OperationCancellationError; export declare function indeterminateOperation(cause: 'replaced' | 'disposed' | 'in-flight'): OperationCancellationError; /** * Reject a call that is already cancelled or whose deadline has already * expired. Returns without effect when the caller did not ask for control. */ export declare function assertOperationCanStart(options?: OperationCancellation): void; /** * Separate host-only cancellation fields from a value that will be * structured-cloned into the worker. `AbortSignal` cannot cross that boundary. */ export declare function splitOperationCancellation(value: unknown): { cancellation?: OperationCancellation; rest: unknown; };