/* tslint:disable */ /* eslint-disable */ export type Actor = string; export type ObjID = string; export type Change = Uint8Array; export type SyncMessage = Uint8Array; export type Prop = string | number; export type Hash = string; export type Heads = Hash[]; export type ScalarValue = string | number | boolean | null | Date | Uint8Array; export type Value = ScalarValue | object; export type MaterializeValue = | { [key: string]: MaterializeValue } | Array | Value; export type MapObjType = { [key: string]: ObjType | Value }; export type ObjInfo = { id: ObjID; type: ObjTypeName; path?: Prop[] }; export type Span = | { type: "text"; value: string; marks?: MarkSet } | { type: "block"; value: { [key: string]: MaterializeValue } }; export type ListObjType = Array; export type ObjType = string | ListObjType | MapObjType; export type FullValue = | ["str", string] | ["int", number] | ["uint", number] | ["f64", number] | ["boolean", boolean] | ["timestamp", Date] | ["counter", number] | ["bytes", Uint8Array] | ["null", null] | ["map", ObjID] | ["list", ObjID] | ["text", ObjID] | ["table", ObjID]; export type Cursor = string; export type CursorPosition = number | "start" | "end"; export type MoveCursor = "before" | "after"; export type FullValueWithId = | ["str", string, ObjID] | ["int", number, ObjID] | ["uint", number, ObjID] | ["f64", number, ObjID] | ["boolean", boolean, ObjID] | ["timestamp", Date, ObjID] | ["counter", number, ObjID] | ["bytes", Uint8Array, ObjID] | ["null", null, ObjID] | ["map", ObjID] | ["list", ObjID] | ["text", ObjID] | ["table", ObjID]; export enum ObjTypeName { list = "list", map = "map", table = "table", text = "text", } export type Datatype = | "boolean" | "str" | "int" | "uint" | "f64" | "null" | "timestamp" | "counter" | "bytes" | "map" | "text" | "list"; export type SyncHave = { lastSync: Heads; bloom: Uint8Array; }; export type DecodedSyncMessage = { heads: Heads; need: Heads; have: SyncHave[]; changes: Change[]; }; export type DecodedChange = { actor: Actor; seq: number; startOp: number; time: number; message: string | null; deps: Heads; hash: Hash; ops: Op[]; }; export type ChangeMetadata = { actor: Actor; seq: number; startOp: number; maxOp: number; time: number; message: string | null; deps: Heads; hash: Hash; }; type PartialBy = Omit & Partial>; export type ChangeToEncode = PartialBy; export type Op = { action: string; obj: ObjID; key: string; value?: string | number | boolean; datatype?: string; pred: string[]; }; export type PatchValue = | string | number | boolean | null | Date | Uint8Array | {} | []; export type Patch = | PutPatch | DelPatch | SpliceTextPatch | IncPatch | InsertPatch | MarkPatch | UnmarkPatch | ConflictPatch; export type PutPatch = { action: "put"; path: Prop[]; value: PatchValue; conflict?: boolean; }; export interface MarkSet { [name: string]: ScalarValue; } export type MarkPatch = { action: "mark"; path: Prop[]; marks: Mark[]; }; export type MarkRange = { expand?: "before" | "after" | "both" | "none"; start: number; end: number; }; export type UnmarkPatch = { action: "unmark"; path: Prop[]; name: string; start: number; end: number; }; export type IncPatch = { action: "inc"; path: Prop[]; value: number; }; export type DelPatch = { action: "del"; path: Prop[]; length?: number; }; export type SpliceTextPatch = { action: "splice"; path: Prop[]; value: string; marks?: MarkSet; }; export type InsertPatch = { action: "insert"; path: Prop[]; values: PatchValue[]; marks?: MarkSet; conflicts?: boolean[]; }; export type ConflictPatch = { action: "conflict"; path: Prop[]; }; export type Mark = { name: string; value: ScalarValue; start: number; end: number; }; // Some definitions can't be typed using the wasm_bindgen annotations // (specifically optional function parameters) so we do that work here // and merge this definition with the `class Automerge` definition // which follows interface Automerge { fork(actor?: string, heads?: Heads): Automerge; put(obj: ObjID, prop: Prop, value: Value, datatype?: Datatype): void; get(obj: ObjID, prop: Prop, heads?: Heads): Value | undefined; getWithType(obj: ObjID, prop: Prop, heads?: Heads): FullValue | null; getAll(obj: ObjID, arg: Prop, heads?: Heads): FullValueWithId[]; keys(obj: ObjID, heads?: Heads): string[]; text(obj: ObjID, heads?: Heads): string; spans(obj: ObjID, heads?: Heads): Span[]; marks(obj: ObjID, heads?: Heads): Mark[]; marksAt(obj: ObjID, index: number, heads?: Heads): MarkSet; length(obj: ObjID, heads?: Heads): number; objInfo(obj: ObjID, heads?: Heads): ObjInfo; materialize(obj?: ObjID, heads?: Heads, metadata?: unknown): MaterializeValue; push(obj: ObjID, value: Value, datatype?: Datatype): void; insert(obj: ObjID, index: number, value: Value, datatype?: Datatype): void; splice( obj: ObjID, start: number, delete_count: number, text?: string | Array, ): void; mark( obj: ObjID, range: MarkRange, name: string, value: Value, datatype?: Datatype, ): void; getCursor( obj: ObjID, position: CursorPosition, heads?: Heads, move?: MoveCursor, ): Cursor; applyPatches(obj: Doc, meta?: unknown): Doc; applyAndReturnPatches( obj: Doc, meta?: unknown, ): { value: Doc; patches: Patch[] }; getBlock(obj: ObjID, index: number, heads?: Heads): { [key: string]: MaterializeValue } | null; getMissingDeps(heads?: Heads): Heads; getCursorPosition(obj: ObjID, cursor: Cursor, heads?: Heads): number; diffPath(path: Prop[] | string, before: Heads, after: Heads, options?: DiffOptions): Patch[]; } export type LoadOptions = { actor?: Actor; unchecked?: boolean; allowMissingDeps?: boolean; convertImmutableStringsToText?: boolean; }; // if recursive is false do not diff child objects export type DiffOptions = { recursive?: boolean; }; export type InitOptions = { actor?: Actor; }; export function create(options?: InitOptions): Automerge; export function load(data: Uint8Array, options?: LoadOptions): Automerge; export interface JsSyncState { sharedHeads: Heads; lastSentHeads: Heads; theirHeads: Heads | undefined; theirHeed: Heads | undefined; theirHave: SyncHave[] | undefined; sentHashes: Heads; } export interface DecodedBundle { changes: DecodedChange[]; deps: Heads; } export interface API { create(options?: InitOptions): Automerge; load(data: Uint8Array, options?: LoadOptions): Automerge; encodeChange(change: ChangeToEncode): Change; decodeChange(change: Change): DecodedChange; initSyncState(): SyncState; encodeSyncMessage(message: DecodedSyncMessage): SyncMessage; decodeSyncMessage(msg: SyncMessage): DecodedSyncMessage; encodeSyncState(state: SyncState): Uint8Array; decodeSyncState(data: Uint8Array): SyncState; exportSyncState(state: SyncState): JsSyncState; importSyncState(state: JsSyncState): SyncState; readBundle(data: Uint8Array): DecodedBundle; wasmReleaseInfo(): WasmReleaseInfo; } export interface Stats { numChanges: number; numOps: number; numActors: number; } export interface WasmReleaseInfo { gitHead: string; cargoPackageName: string; cargoPackageVersion: string; rustcVersion: string; } export type UpdateSpansConfig = { defaultExpand?: "before" | "after" | "both" | "none"; perMarkExpand?: {[key: string]: "before" | "after" | "both" | "none" } } export class Automerge { private constructor(); free(): void; [Symbol.dispose](): void; applyChanges(changes: Change[]): void; clone(actor?: string | null): Automerge; commit(message?: string | null, time?: number | null): Hash | null; delete(obj: ObjID, prop: Prop): void; diff(before: Heads, after: Heads): Patch[]; diffIncremental(): Patch[]; dump(): void; emptyChange(message?: string | null, time?: number | null): Hash; enableFreeze(enable: boolean): boolean; generateSyncMessage(state: SyncState): SyncMessage | null; getActorId(): Actor; getChangeByHash(hash: Hash): Change | null; getChangeMetaByHash(hash: Hash): ChangeMetadata | null; getChanges(have_deps: Heads): Change[]; getChangesAdded(other: Automerge): Change[]; getChangesMeta(have_deps: Heads): ChangeMetadata[]; getDecodedChangeByHash(hash: Hash): DecodedChange | null; getHeads(): Heads; getLastLocalChange(): Change | null; hasOurChanges(state: SyncState): boolean; increment(obj: ObjID, prop: Prop, value: number): void; /** * Initialize the root object of an empty document from a JS object. * This is much faster than setting keys one at a time for large initial states. */ initRootFromHydrate(value: any): void; insertObject(obj: ObjID, index: number, value: ObjType): ObjID; /** * Insert a nested JavaScript value into a list using batch insertion. * This is much faster than insertObject for large nested objects. * The value is inserted at the given index, shifting subsequent elements. */ insertObjectFromHydrate(obj: ObjID, index: number, value: any): ObjID; integrate(): void; isolate(heads: Heads): void; joinBlock(obj: ObjID, index: number): void; loadIncremental(data: Uint8Array): number; merge(other: Automerge): Heads; static new(actor?: string | null): Automerge; pendingOps(): number; pushObject(obj: ObjID, value: ObjType): ObjID; putObject(obj: ObjID, prop: Prop, value: ObjType): ObjID; /** * Put a nested JavaScript value as a new object tree using batch insertion. * This is much faster than putObject for large nested objects. * For map keys this overwrites any existing value. For list indices this * overwrites the element at that index. */ putObjectFromHydrate(obj: ObjID, prop: Prop, value: any): ObjID; receiveSyncMessage(state: SyncState, message: SyncMessage): void; registerDatatype(datatype: string, construct: Function, deconstruct: (arg: any) => any | undefined): void; resetDiffCursor(): void; rollback(): number; save(): Uint8Array; saveAndVerify(): Uint8Array; saveBundle(hashes: any): Uint8Array; saveIncremental(): Uint8Array; saveNoCompress(): Uint8Array; saveSince(heads: Heads): Uint8Array; /** * Splice values into a list using batch insertion. * This is much faster than individual insert calls for multiple values. */ spliceFromHydrate(obj: ObjID, index: number, del: number, values: any): void; splitBlock(obj: ObjID, index: number, block: {[key: string]: MaterializeValue}): void; stats(): Stats; toJS(meta: any): MaterializeValue; topoHistoryTraversal(): Hash[]; unmark(obj: ObjID, range: MarkRange, name: string): void; updateBlock(obj: ObjID, index: number, block: {[key: string]: MaterializeValue}): void; updateDiffCursor(): void; updateSpans(obj: ObjID, args: Span[], config: UpdateSpansConfig | undefined | null): void; updateText(obj: ObjID, new_text: string): void; } export class SyncState { private constructor(); free(): void; [Symbol.dispose](): void; clone(): SyncState; lastSentHeads: Heads; set sentHashes(value: Heads); readonly sharedHeads: Heads; } export function decodeChange(change: Uint8Array): DecodedChange; export function decodeSyncMessage(msg: Uint8Array): DecodedSyncMessage; export function decodeSyncState(data: Uint8Array): SyncState; export function encodeChange(change: any): Uint8Array; export function encodeSyncMessage(message: any): SyncMessage; export function encodeSyncState(state: SyncState): Uint8Array; export function exportSyncState(state: SyncState): JsSyncState; export function importSyncState(state: any): SyncState; export function initSyncState(): SyncState; export function readBundle(bundle: Uint8Array): any; export function wasmReleaseInfo(): WasmReleaseInfo;