@excalidraw/element 0.18.0-dda3affcb → 0.18.0-de715913e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,9 @@ export declare class Scene {
27
27
  getElementsMapIncludingDeleted(): Map<string, Ordered<ExcalidrawElement>> & import("@excalidraw/common/utility-types").MakeBrand<"SceneElementsMap">;
28
28
  getNonDeletedElements(): readonly Ordered<NonDeletedExcalidrawElement>[];
29
29
  getFramesIncludingDeleted(): readonly ExcalidrawFrameLikeElement[];
30
- constructor(elements?: ElementsMapOrArray | null);
30
+ constructor(elements?: ElementsMapOrArray | null, options?: {
31
+ skipValidation?: true;
32
+ });
31
33
  getSelectedElements(opts: {
32
34
  selectedElementIds: AppState["selectedElementIds"];
33
35
  /**
@@ -55,7 +57,9 @@ export declare class Scene {
55
57
  * @returns whether a change was made
56
58
  */
57
59
  mapElements(iteratee: (element: ExcalidrawElement) => ExcalidrawElement): boolean;
58
- replaceAllElements(nextElements: ElementsMapOrArray): void;
60
+ replaceAllElements(nextElements: ElementsMapOrArray, options?: {
61
+ skipValidation?: true;
62
+ }): void;
59
63
  triggerUpdate(): void;
60
64
  onUpdate(cb: SceneStateCallback): SceneStateCallbackRemover;
61
65
  destroy(): void;
@@ -32,13 +32,13 @@ export declare class Delta<T> {
32
32
  /**
33
33
  * Merges two deltas into a new one.
34
34
  */
35
- static merge<T>(delta1: Delta<T>, delta2: Delta<T>): Delta<T>;
35
+ static merge<T>(delta1: Delta<T>, delta2: Delta<T>, delta3?: Delta<T>): Delta<T>;
36
36
  /**
37
37
  * Merges deleted and inserted object partials.
38
38
  */
39
39
  static mergeObjects<T extends {
40
40
  [key: string]: unknown;
41
- }>(prev: T, added: T, removed: T): T;
41
+ }>(prev: T, added: T, removed?: T): T;
42
42
  /**
43
43
  * Merges deleted and inserted array partials.
44
44
  */
@@ -105,7 +105,7 @@ export interface DeltaContainer<T> {
105
105
  *
106
106
  * @returns a tuple of the next object `T` with applied `Delta`s, and `boolean`, indicating whether the applied deltas resulted in a visible change.
107
107
  */
108
- applyTo(previous: T, ...options: unknown[]): [T, boolean];
108
+ applyTo(previous: T, ...options: unknown[]): [T, boolean, ...unknown[]];
109
109
  /**
110
110
  * Squashes the current delta with the given one.
111
111
  */
@@ -118,6 +118,7 @@ export interface DeltaContainer<T> {
118
118
  export declare class AppStateDelta implements DeltaContainer<AppState> {
119
119
  delta: Delta<ObservedAppState>;
120
120
  private constructor();
121
+ static create(delta: Delta<ObservedAppState>): AppStateDelta;
121
122
  static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
122
123
  static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
123
124
  static empty(): AppStateDelta;
@@ -144,7 +145,7 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
144
145
  }
145
146
  type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
146
147
  export type ApplyToOptions = {
147
- excludedProperties: Set<keyof ElementPartial>;
148
+ excludedProperties?: Set<keyof ElementPartial>;
148
149
  };
149
150
  /**
150
151
  * Elements change is a low level primitive to capture a change between two sets of elements.
@@ -212,6 +213,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
212
213
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
213
214
  */
214
215
  private static rebindAffected;
216
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
215
217
  private static redrawTextBoundingBoxes;
216
218
  private static redrawBoundArrows;
217
219
  private static reorderElements;
@@ -169,7 +169,11 @@ export declare class StoreDelta {
169
169
  /**
170
170
  * Parse and load the delta from the remote payload.
171
171
  */
172
- static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
172
+ static load({ id, elements: { added, removed, updated }, appState: { delta: appStateDelta }, }: DTO<StoreDelta>): StoreDelta;
173
+ /**
174
+ * Squash the passed delta into the current instance.
175
+ */
176
+ squash(delta: StoreDelta): this;
173
177
  /**
174
178
  * Inverse store delta, creates new instance of `StoreDelta`.
175
179
  */
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { type EXPORT_IMAGE_TYPES, Emitter } from "@excalidraw/common";
3
- import { LinearElementEditor, FlowChartCreator, Scene, Store, type ElementUpdate } from "@excalidraw/element";
4
- import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered } from "@excalidraw/element/types";
3
+ import { LinearElementEditor, FlowChartCreator, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
4
+ import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "@excalidraw/element/types";
5
5
  import type { Mutable } from "@excalidraw/common/utility-types";
6
6
  import { ActionManager } from "../actions/manager";
7
7
  import { AnimationFrameHandler } from "../animation-frame-handler";
@@ -265,7 +265,7 @@ declare class App extends React.Component<AppProps, AppState> {
265
265
  private toggleOverscrollBehavior;
266
266
  render(): import("react/jsx-runtime").JSX.Element;
267
267
  focusContainer: AppClassProperties["focusContainer"];
268
- getSceneElementsIncludingDeleted: () => readonly import("@excalidraw/element/types").OrderedExcalidrawElement[];
268
+ getSceneElementsIncludingDeleted: () => readonly OrderedExcalidrawElement[];
269
269
  getSceneElementsMapIncludingDeleted: () => Map<string, Ordered<ExcalidrawElement>> & import("@excalidraw/common/utility-types").MakeBrand<"SceneElementsMap">;
270
270
  getSceneElements: () => readonly Ordered<NonDeletedExcalidrawElement>[];
271
271
  onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
@@ -397,6 +397,7 @@ declare class App extends React.Component<AppProps, AppState> {
397
397
  */
398
398
  captureUpdate?: SceneData["captureUpdate"];
399
399
  }) => void;
400
+ applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
400
401
  mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
401
402
  private triggerRender;
402
403
  /**
@@ -618,6 +618,7 @@ export type PointerDownState = Readonly<{
618
618
  export type UnsubscribeCallback = () => void;
619
619
  export interface ExcalidrawImperativeAPI {
620
620
  updateScene: InstanceType<typeof App>["updateScene"];
621
+ applyDeltas: InstanceType<typeof App>["applyDeltas"];
621
622
  mutateElement: InstanceType<typeof App>["mutateElement"];
622
623
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
623
624
  resetScene: InstanceType<typeof App>["resetScene"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/element",
3
- "version": "0.18.0-dda3affcb",
3
+ "version": "0.18.0-de715913e",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -57,7 +57,7 @@
57
57
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
58
58
  },
59
59
  "dependencies": {
60
- "@excalidraw/common": "0.18.0-dda3affcb",
61
- "@excalidraw/math": "0.18.0-dda3affcb"
60
+ "@excalidraw/common": "0.18.0-de715913e",
61
+ "@excalidraw/math": "0.18.0-de715913e"
62
62
  }
63
63
  }