UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
40 lines (39 loc) 1.58 kB
import { SerializedNode } from '@infinite-canvas-tutorial/ecs'; import { AppState } from '../context'; type OrderedExcalidrawElement = SerializedNode; type ObservedAppState = AppState; export declare class Snapshot { readonly elements: Map<string, SerializedNode>; readonly appState: AppState; readonly meta: { didElementsChange: boolean; didAppStateChange: boolean; isEmpty?: boolean; }; private constructor(); static empty(): Snapshot; /** * Efficiently clone the existing snapshot, only if we detected changes. * * @returns same instance if there are no changes detected, new instance otherwise. */ maybeClone(elements: Map<string, OrderedExcalidrawElement> | undefined, appState: AppState | ObservedAppState | undefined): Snapshot; private maybeCreateAppStateSnapshot; private detectChangedAppState; private maybeCreateElementsSnapshot; /** * Detect if there any changed elements. * * NOTE: we shouldn't just use `sceneVersionNonce` instead, as we need to call this before the scene updates. */ private detectChangedElements; /** * Perform structural clone, cloning only elements that changed. */ private createElementsSnapshot; } /** * @see https://github.com/excalidraw/excalidraw/blob/ab89d4c16f53bd1e06cb980c600f0952b7a3d7d3/packages/excalidraw/element/mutateElement.ts#L152 */ export declare const newElementWith: <TElement extends SerializedNode>(element: TElement, updates: Partial<TElement>, force?: boolean) => TElement; export {};