/** * Borrow from https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/change.ts#L399 */ import { ComponentType, Entity } from '@lastolivegames/becsy'; import { Change } from './Change'; import { Delta } from './Delta'; import type { SerializedNode } from '../types/serialized-node'; import { API } from '../API'; export type SceneElementsMap = Map; export type ElementPartial = Partial; export type ElementUpdate = Omit, 'id' | 'version' | 'versionNonce' | 'updated'>; export type Mutable = { -readonly [P in keyof T]: T[P]; }; export declare const getUpdatedTimestamp: () => number; export declare function safeAddComponent(entity: Entity, componentCtor: ComponentType, component?: Partial): void; export declare function safeRemoveComponent(entity: Entity, componentCtor: ComponentType): void; export declare class ElementsChange implements Change { private readonly added; private readonly removed; private readonly updated; private readonly api; 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(prevElements: Map, nextElements: Map, api: API): ElementsChange; private static satisfiesAddition; private static satisfiesRemoval; private static satisfiesUpdate; private static createGetter; private static createApplier; /** * Check for visible changes regardless of whether they were removed, added or updated. */ private static checkForVisibleDifference; private static applyDelta; static create(added: Map>, removed: Map>, updated: Map>, api: API, 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): [SceneElementsMap, boolean]; isEmpty(): boolean; } export declare const mutateElement: >(entity: Entity, element: TElement, updates: ElementUpdate, skipOverrideKeys: string[], api: API) => TElement;