@excalidraw/excalidraw 0.18.0-6d870b1c8 → 0.18.0-7876ee524

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.
@@ -163,6 +164,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
163
164
  private static satisfiesRemoval;
164
165
  private static satisfiesUpdate;
165
166
  private static satisfiesCommmonInvariants;
167
+ private static satisfiesUniqueInvariants;
166
168
  private static validate;
167
169
  /**
168
170
  * Calculates the `Delta`s between the previous and next set of elements.
@@ -212,6 +214,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
212
214
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
213
215
  */
214
216
  private static rebindAffected;
217
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
215
218
  private static redrawTextBoundingBoxes;
216
219
  private static redrawBoundArrows;
217
220
  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
  /**
@@ -9,18 +9,18 @@ export type RestoredDataState = {
9
9
  files: BinaryFiles;
10
10
  };
11
11
  export declare const restoreElement: (element: Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, opts?: {
12
- deleteEmptyTextElements?: boolean;
12
+ deleteInvisibleElements?: boolean;
13
13
  }) => ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | ExcalidrawArrowElement | null;
14
14
  export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, opts?: {
15
15
  refreshDimensions?: boolean;
16
16
  repairBindings?: boolean;
17
- deleteEmptyTextElements?: boolean;
17
+ deleteInvisibleElements?: boolean;
18
18
  } | undefined) => OrderedExcalidrawElement[];
19
19
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
20
20
  export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined, elementsConfig?: {
21
21
  refreshDimensions?: boolean;
22
22
  repairBindings?: boolean;
23
- deleteEmptyTextElements?: boolean;
23
+ deleteInvisibleElements?: boolean;
24
24
  }) => RestoredDataState;
25
25
  export declare const restoreLibraryItems: (libraryItems: ImportedDataState["libraryItems"], defaultStatus: LibraryItem["status"]) => LibraryItem[];
26
26
  export {};
@@ -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/history.ts CHANGED
@@ -175,7 +175,7 @@ export class History {
175
175
  let nextAppState = appState;
176
176
  let containsVisibleChange = false;
177
177
 
178
- // iterate through the history entries in case ;they result in no visible changes
178
+ // iterate through the history entries in case they result in no visible changes
179
179
  while (historyDelta) {
180
180
  try {
181
181
  [nextElements, nextAppState, containsVisibleChange] =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/excalidraw",
3
- "version": "0.18.0-6d870b1c8",
3
+ "version": "0.18.0-7876ee524",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -79,9 +79,9 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@braintree/sanitize-url": "6.0.2",
82
- "@excalidraw/common": "0.18.0-6d870b1c8",
83
- "@excalidraw/element": "0.18.0-6d870b1c8",
84
- "@excalidraw/math": "0.18.0-6d870b1c8",
82
+ "@excalidraw/common": "0.18.0-7876ee524",
83
+ "@excalidraw/element": "0.18.0-7876ee524",
84
+ "@excalidraw/math": "0.18.0-7876ee524",
85
85
  "@excalidraw/laser-pointer": "1.3.1",
86
86
  "@excalidraw/mermaid-to-excalidraw": "1.1.2",
87
87
  "@excalidraw/random-username": "1.1.0",