import { actions, query, Synnax as Client } from '@synnaxlabs/client'; import { record } from '@synnaxlabs/x'; /** One or more actions aimed at the document with the given key. */ export interface DispatchInput { key: Key; actions: Action | Action[]; } /** Params for {@link createDispatch}. */ export interface CreateDispatchParams { /** Selects the domain's dispatch surface off the client. */ domain: (client: Client) => actions.Domain; /** * Rewrites an action batch against the current document before replay and * send. Lives here rather than in the domain client when the rewrite needs * visualization-layer context (e.g. diagram geometry). */ preprocess?: actions.Preprocess; } /** Return value for the `useDispatch` hook. */ export interface UseDispatchReturn { /** Applies actions and reports a failure as an error status. */ dispatch: (input: DispatchInput) => void; /** Applies actions and resolves to whether they committed. */ dispatchAsync: (input: DispatchInput) => Promise; /** Groups actions so undo takes them back as one step. */ beginTransaction: (input: { key: Key; kind?: string; }) => actions.Transaction; } /** Return value for the `useUndo` hook. */ export interface UseUndoReturn { undo: () => void; canUndo: boolean; } /** Return value for the `useRedo` hook. */ export interface UseRedoReturn { redo: () => void; canRedo: boolean; } /** The hooks {@link createDispatch} builds for one domain. */ export interface CreateDispatchReturn { useDispatch: () => UseDispatchReturn; useUndo: (params: { key: Key; }) => UseUndoReturn; useRedo: (params: record.Keyed) => UseRedoReturn; useSingleDispatch: (params: record.Keyed) => (action: Action | Action[]) => void; } /** * Builds the dispatch, undo, and redo hooks for one editable document domain. Call it * once per domain, at module scope. */ export declare const createDispatch: ({ domain, preprocess, }: CreateDispatchParams) => CreateDispatchReturn; //# sourceMappingURL=dispatch.d.ts.map