import { ContainerID, LoroDoc } from "loro-crdt"; import { ContainerSchemaType, LoroListSchema, LoroMapSchema, LoroMovableListSchema, LoroTreeSchema, RootSchemaType, SchemaType, type InferContainerOptions } from "../schema/index.js"; import { type Change } from "./mirror.js"; import { type ObjectLike, type ArrayLike } from "./utils.js"; /** * Finds the longest increasing subsequence of a sequence of numbers * @param sequence The sequence of numbers * @returns The longest increasing subsequence */ export declare function longestIncreasingSubsequence(sequence: number[]): number[]; type IdSelector = (item: T) => string | undefined; /** * Diffs a container between two states * * @param doc The LoroDoc instance * @param oldState The old state * @param newState The new state * @param containerId The container ID can be "" for root level changes * @param schema The schema for the container (can be undefined) * @returns The list of changes */ export declare function diffContainer(doc: LoroDoc, oldState: unknown, newState: unknown, containerId: ContainerID | "", schema: SchemaType | undefined, inferOptions?: InferContainerOptions): Change[]; /** * Diffs a [LoroText] between two states * * @param oldState The old state * @param newState The new state * @param containerId The container ID * @returns The list of changes */ export declare function diffText(oldState: string, newState: string, containerId: ContainerID | ""): Change[]; /** * Diffs a LoroTree between two states * * Produces structural tree operations (create/move/delete) and per-node data updates. */ export declare function diffTree(doc: LoroDoc, oldState: ArrayLike, newState: ArrayLike, containerId: ContainerID, schema: LoroTreeSchema> | undefined, inferOptions?: InferContainerOptions): Change[]; /** * Finds the difference between two lists based on an idSelector function * * Time Complexity: * * - O(1) if not changed * - O(n + klogk) for insertions/deletions/replacements, where k is the number of deletions * - O(n) for one move op * - Worst case O(n^2) for move op * * @param doc The LoroDoc instance * @param oldState The old state * @param newState The new state * @param containerId The container ID * @param schema The schema for the container * @param idSelector The idSelector function * @returns The list of changes */ export declare function diffMovableList(doc: LoroDoc, oldState: S, newState: S, containerId: ContainerID, schema: LoroListSchema | LoroMovableListSchema | undefined, idSelector: IdSelector, inferOptions?: InferContainerOptions): Change[]; /** * Finds the difference between two lists based on an idSelector function * * @param doc The LoroDoc instance * @param oldState The old state * @param newState The new state * @param containerId The container ID * @param schema The schema for the container * @param idSelector The idSelector function * @returns The list of changes */ export declare function diffListWithIdSelector(doc: LoroDoc, oldState: S, newState: S, containerId: ContainerID, schema: LoroListSchema | undefined, idSelector: IdSelector, inferOptions?: InferContainerOptions): Change[]; /** * Diffs a [LoroList] between two states * * This function handles list diffing without an ID selector. * This can result in less precise updates, and can cause clone/fork of items. * * If an ID selector is possible, use [diffMovableList] instead. * * @param doc The LoroDoc instance * @param oldState The old state * @param newState The new state * @param containerId The container ID of the list * @param schema The schema for the container * @returns The list of changes */ export declare function diffList(doc: LoroDoc, oldState: S, newState: S, containerId: ContainerID, schema: LoroListSchema | undefined, inferOptions?: InferContainerOptions): Change[]; /** * Diffs a [LoroMovableList] between two states without requiring an idSelector. * * This is an index-based fallback intended for inference-driven movable lists * (e.g. when `inferOptions.defaultMovableList` is enabled). */ export declare function diffMovableListByIndex(doc: LoroDoc, oldState: ArrayLike, newState: ArrayLike, containerId: ContainerID, schema: LoroMovableListSchema | undefined, inferOptions?: InferContainerOptions): Change[]; /** * Diffs a [LoroMap] between two states * * @param doc The LoroDoc instance * @param oldState The old state * @param newState The new state * @param containerId The container ID of the map * @param schema The schema for the container * @returns The list of changes */ export declare function diffMap(doc: LoroDoc, oldState: S, newState: S, containerId: ContainerID | "", schema: LoroMapSchema> | RootSchemaType> | undefined, inferOptions?: InferContainerOptions): Change[]; export {}; //# sourceMappingURL=diff.d.ts.map