UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
43 lines (42 loc) 1.97 kB
/** * Borrow from https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/change.ts#L399 */ import { SerializedNode } from '@infinite-canvas-tutorial/ecs'; import { Change } from './Change'; import { Delta } from './Delta'; export type SceneElementsMap = Map<SerializedNode['id'], SerializedNode>; export type ElementPartial = Partial<SerializedNode>; export declare class ElementsChange implements Change<SceneElementsMap> { private readonly added; private readonly removed; private readonly updated; static empty(): ElementsChange; private static stripIrrelevantProps; /** * Calculates the `Delta`s between the previous and next set of elements. * * @param prevElements - Map representing the previous state of elements. * @param nextElements - Map representing the next state of elements. * * @returns `ElementsChange` instance representing the `Delta` changes between the two sets of elements. */ static calculate<T extends SerializedNode>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsChange; private static satisfiesAddition; private static satisfiesRemoval; private static satisfiesUpdate; static create(added: Map<string, Delta<ElementPartial>>, removed: Map<string, Delta<ElementPartial>>, updated: Map<string, Delta<ElementPartial>>, options?: { shouldRedistribute: boolean; }): ElementsChange; private constructor(); inverse(): ElementsChange; /** * Update delta/s based on the existing elements. * * @param elements current elements * @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated * @returns new instance with modified delta/s */ applyLatestChanges(elements: SceneElementsMap): ElementsChange; applyTo(elements: SceneElementsMap, snapshot: Map<string, SerializedNode>): [SceneElementsMap, boolean]; isEmpty(): boolean; }