/** What the operations are built from: the type of an operation, how one finds what it writes to on the draft, and the edits it writes. */ import { Draft } from "immer"; import { Edition } from "../model/Edition.js"; import { AnySymbol } from "../model/Symbol.js"; import { Edit } from "../model/Edit.js"; import { Version } from "../model/Version.js"; import { RollCopy } from "../model/RollCopy.js"; import { Belief, ReferenceAssumption } from "../model/Assumption.js"; import { FeatureOrPatch } from "../model/Feature.js"; import { WithId } from "../shared/utils.js"; /** * A change to an edition, written onto an immer draft of it. One * operation is one undo step, so an operation that has to read the * edition reads it as the draft stands when the operation is applied * (`reading`) and does all its writing in the one function it builds * from that. Where operations run one after another on one draft, each * reads what the ones before it wrote. * @category Operations */ export type EditionOp = (draft: Draft) => void; export declare const noChange: EditionOp; export declare const onCopy: (copyId: string, op: (copy: Draft, draft: Draft) => void) => EditionOp; export declare const onVersion: (versionId: string, op: (version: Draft, draft: Draft) => void) => EditionOp; export declare const onFeature: (copyId: string, featureId: string, op: (feature: Draft) => void) => EditionOp; /** * The operation built from the state it is applied to: the draft as it * stands, an operation run before on the same draft included. A path * or an index read off an earlier state would name what stood there * before. What is worked out from a state is kept with it, so a draft * nothing has changed yet is read from what is known already. */ export declare const reading: (build: (edition: Edition) => EditionOp) => EditionOp; /** * The state a draft stands at, as plain data. Reading a draft proxies * everything it touches, so what is only read is read from this, and * what is looked up in an edition is looked up in this (`takenOf`). * @category Lookups */ export declare const stateOf: (draft: Draft) => T; /** The ids of the items the rewriting left out. */ export declare const droppedIds: (before: readonly WithId[], after: readonly WithId[]) => string[]; export type Ids = ReadonlySet; export declare const insertion: (symbol: AnySymbol) => Edit; export declare const deletion: (symbolId: string) => Edit; export declare const insertedIn: (versions: readonly Version[]) => AnySymbol[]; /** The edits with the change applied, less those it emptied; the very same array where it changed none. */ export declare const edited: (edits: Edit[], change: (edit: Edit) => Edit) => Edit[]; /** Takes the symbols out of the version's own insertions, and the edits that had nothing else. */ export declare const dropInsertions: (version: Draft, symbolIds: Ids) => void; /** A reference under the belief given, where one is given. */ export declare const referenceHeld: (id: string, belief?: Belief) => ReferenceAssumption; /** The references less those that match, or nothing where none is left. */ export declare const withoutReferences: (references: readonly R[], matches: (reference: Readonly) => boolean) => R[] | undefined;