@sanity/desk-tool
Version:
Tool for managing all sorts of content in a structured manner
71 lines • 2.76 kB
TypeScript
import type { SanityClient } from '@sanity/client';
import { Annotation } from '@sanity/field/diff';
import { Observable } from 'rxjs';
import { Diff, ObjectDiff } from '@sanity/diff';
import { Timeline } from './Timeline';
import { RemoteSnapshotVersionEvent, Chunk } from './types';
export declare type Options = {
timeline: Timeline;
client: SanityClient;
documentId: string;
documentType: string;
handler: (err: Error | null, controller: Controller) => void;
};
/**
* The controller is responsible for fetching information
* about a document and maintaining a Timeline.
*/
export declare class Controller {
timeline: Timeline;
client: SanityClient;
handler: Options['handler'];
version: number;
/**
* The selection state represents the different states of the current selection:
* - inactive: No selection is active.
* - rev: A selection is active for a single revision.
* - range: A selection is active for a range and we have all the data needed to render it.
* - loading: A selection is active, but we don't have the entries yet.
* - invalid: The selection picked is invalid.
*/
selectionState: 'inactive' | 'rev' | 'range' | 'loading' | 'invalid';
constructor(options: Options);
private _aligner;
private _fetchMore;
private _fetchAtLeast;
private _isRunning;
private _didErr;
private _since;
private _sinceTime;
private _rev;
private _revTime;
clearRange(): void;
setRange(since: string | null, rev: string | null): void;
setLoadMore(state: boolean): void;
get sinceTime(): Chunk | null;
get revTime(): Chunk | null;
get realRevChunk(): Chunk;
/** Returns true when there's an older revision we want to render. */
onOlderRevision(): boolean;
/** Returns true when the changes panel should be active. */
changesPanelActive(): boolean;
findRangeForNewRev(rev: Chunk): [string | null, string | null];
findRangeForNewSince(since: Chunk): [string, string | null];
setRevTime(rev: string | null): void;
setSinceTime(since: string | null): void;
sinceAttributes(): Record<string, unknown> | null;
displayed(): Record<string, unknown> | null;
private _reconstruction?;
setReconstruction(since: Chunk | null, rev: Chunk): void;
currentDiff(): Diff<Annotation> | null;
currentObjectDiff(): ObjectDiff<Annotation> | null;
handleRemoteMutation(ev: RemoteSnapshotVersionEvent): void;
start(): void;
private tick;
private fetchMoreTransactions;
private markChange;
}
export declare function createObservableController(options: Omit<Options, 'handler'>): Observable<{
historyController: Controller;
}>;
//# sourceMappingURL=Controller.d.ts.map