@excalidraw/excalidraw 0.18.0-6fc8502 → 0.18.0-864353b

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.
Files changed (164) hide show
  1. package/dist/dev/{chunk-X3RYHLJU.js → chunk-7YMZV3TY.js} +14 -4
  2. package/dist/dev/chunk-7YMZV3TY.js.map +7 -0
  3. package/dist/dev/chunk-BBNNHA7I.js +7 -0
  4. package/dist/dev/chunk-BBNNHA7I.js.map +7 -0
  5. package/dist/dev/{chunk-KYBDXI6F.js → chunk-LL55DS44.js} +15037 -10099
  6. package/dist/dev/chunk-LL55DS44.js.map +7 -0
  7. package/dist/dev/data/{image-NKFINVKH.js → image-OFYK7EOY.js} +3 -3
  8. package/dist/dev/index.css +100 -22
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +3531 -6486
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-CKWC2GMK.js → en-KIY5SGI3.js} +2 -2
  13. package/dist/dev/subset-shared.chunk.js +1 -1
  14. package/dist/dev/subset-worker.chunk.js +1 -1
  15. package/dist/prod/chunk-F44EGBV2.js +33 -0
  16. package/dist/prod/{chunk-IUH5AXLB.js → chunk-OUULIERA.js} +4 -4
  17. package/dist/prod/chunk-UH6Q3EIV.js +7 -0
  18. package/dist/prod/data/image-CUOH64HE.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +18 -17
  21. package/dist/prod/locales/{en-SBO6ZHT2.js → en-GCLCIHXH.js} +1 -1
  22. package/dist/prod/subset-shared.chunk.js +1 -1
  23. package/dist/prod/subset-worker.chunk.js +1 -1
  24. package/dist/types/common/src/constants.d.ts +11 -1
  25. package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
  26. package/dist/types/common/src/font-metadata.d.ts +4 -2
  27. package/dist/types/common/src/index.d.ts +1 -0
  28. package/dist/types/common/src/utility-types.d.ts +5 -0
  29. package/dist/types/common/src/utils.d.ts +22 -4
  30. package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
  31. package/dist/types/element/src/ShapeCache.d.ts +1 -1
  32. package/dist/types/element/src/align.d.ts +3 -3
  33. package/dist/types/element/src/binding.d.ts +19 -12
  34. package/dist/types/element/src/bounds.d.ts +2 -2
  35. package/dist/types/element/src/collision.d.ts +1 -1
  36. package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +40 -35
  37. package/dist/types/element/src/dragElements.d.ts +3 -2
  38. package/dist/types/element/src/duplicate.d.ts +10 -13
  39. package/dist/types/element/src/elbowArrow.d.ts +1 -1
  40. package/dist/types/element/src/flowchart.d.ts +3 -2
  41. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  42. package/dist/types/element/src/frame.d.ts +5 -4
  43. package/dist/types/element/src/index.d.ts +45 -2
  44. package/dist/types/element/src/linearElementEditor.d.ts +20 -31
  45. package/dist/types/element/src/mutateElement.d.ts +10 -2
  46. package/dist/types/element/src/newElement.d.ts +4 -3
  47. package/dist/types/element/src/resizeElements.d.ts +4 -4
  48. package/dist/types/element/src/selection.d.ts +11 -5
  49. package/dist/types/element/src/shapes.d.ts +5 -1
  50. package/dist/types/element/src/sizeHelpers.d.ts +2 -2
  51. package/dist/types/element/src/store.d.ts +227 -0
  52. package/dist/types/element/src/textElement.d.ts +5 -3
  53. package/dist/types/element/src/transformHandles.d.ts +4 -4
  54. package/dist/types/element/src/typeChecks.d.ts +15 -1
  55. package/dist/types/element/src/types.d.ts +14 -1
  56. package/dist/types/element/src/zindex.d.ts +1 -1
  57. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +39 -45
  58. package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
  59. package/dist/types/excalidraw/actions/actionBoundText.d.ts +26 -30
  60. package/dist/types/excalidraw/actions/actionCanvas.d.ts +262 -288
  61. package/dist/types/excalidraw/actions/actionClipboard.d.ts +81 -92
  62. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -15
  63. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +38 -43
  64. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
  65. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  66. package/dist/types/excalidraw/actions/actionElementLink.d.ts +13 -15
  67. package/dist/types/excalidraw/actions/actionElementLock.d.ts +41 -46
  68. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -15
  69. package/dist/types/excalidraw/actions/actionExport.d.ts +210 -228
  70. package/dist/types/excalidraw/actions/actionFinalize.d.ts +72 -36
  71. package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
  72. package/dist/types/excalidraw/actions/actionFrame.d.ts +96 -104
  73. package/dist/types/excalidraw/actions/actionGroup.d.ts +32 -36
  74. package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
  75. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +505 -14
  76. package/dist/types/excalidraw/actions/actionLink.d.ts +13 -15
  77. package/dist/types/excalidraw/actions/actionMenu.d.ts +39 -45
  78. package/dist/types/excalidraw/actions/actionNavigate.d.ts +25 -29
  79. package/dist/types/excalidraw/actions/actionProperties.d.ts +192 -214
  80. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +15 -17
  81. package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -19
  82. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +15 -17
  83. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +15 -17
  84. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +15 -190
  85. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  86. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +15 -17
  87. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +15 -17
  88. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +15 -17
  89. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  90. package/dist/types/excalidraw/actions/types.d.ts +4 -3
  91. package/dist/types/excalidraw/appState.d.ts +38 -29
  92. package/dist/types/excalidraw/components/App.d.ts +24 -11
  93. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  94. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  95. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
  96. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  97. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
  98. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
  99. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
  100. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  101. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  102. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  103. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  104. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
  105. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  106. package/dist/types/excalidraw/components/Range.d.ts +3 -3
  107. package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  108. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  109. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  110. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  111. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +1 -1
  112. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  113. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  114. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  115. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  116. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  117. package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
  118. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
  119. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  120. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  121. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  122. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
  123. package/dist/types/excalidraw/components/icons.d.ts +3 -0
  124. package/dist/types/excalidraw/components/shapes.d.ts +1 -1
  125. package/dist/types/excalidraw/data/blob.d.ts +1 -1
  126. package/dist/types/excalidraw/data/transform.d.ts +1 -1
  127. package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
  128. package/dist/types/excalidraw/eraser/index.d.ts +14 -0
  129. package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
  130. package/dist/types/excalidraw/history.d.ts +14 -22
  131. package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  132. package/dist/types/excalidraw/index.d.ts +9 -9
  133. package/dist/types/excalidraw/lasso/index.d.ts +1 -0
  134. package/dist/types/excalidraw/lasso/utils.d.ts +1 -2
  135. package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
  136. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  137. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  138. package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
  139. package/dist/types/excalidraw/scene/types.d.ts +2 -0
  140. package/dist/types/excalidraw/snapping.d.ts +2 -2
  141. package/dist/types/excalidraw/types.d.ts +28 -6
  142. package/dist/types/excalidraw/visualdebug.d.ts +1 -1
  143. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
  144. package/dist/types/math/src/angle.d.ts +2 -0
  145. package/dist/types/math/src/curve.d.ts +2 -0
  146. package/dist/types/math/src/point.d.ts +1 -1
  147. package/dist/types/math/src/types.d.ts +1 -0
  148. package/dist/types/math/src/vector.d.ts +4 -0
  149. package/dist/types/utils/src/bbox.d.ts +1 -1
  150. package/dist/types/utils/src/index.d.ts +1 -1
  151. package/dist/types/utils/src/withinBounds.d.ts +1 -1
  152. package/history.ts +68 -94
  153. package/package.json +3 -3
  154. package/dist/dev/chunk-H7XJ5UVD.js +0 -7
  155. package/dist/dev/chunk-H7XJ5UVD.js.map +0 -7
  156. package/dist/dev/chunk-KYBDXI6F.js.map +0 -7
  157. package/dist/dev/chunk-X3RYHLJU.js.map +0 -7
  158. package/dist/prod/chunk-CAN5RS4P.js +0 -31
  159. package/dist/prod/chunk-KJYFYP64.js +0 -7
  160. package/dist/prod/data/image-5XD47O4X.js +0 -1
  161. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  162. package/dist/types/excalidraw/store.d.ts +0 -129
  163. /package/dist/dev/data/{image-NKFINVKH.js.map → image-OFYK7EOY.js.map} +0 -0
  164. /package/dist/dev/locales/{en-CKWC2GMK.js.map → en-KIY5SGI3.js.map} +0 -0
@@ -15,3 +15,5 @@ export declare function radiansToDegrees(degrees: Radians): Degrees;
15
15
  * @returns TRUE if the provided angle is a right angle
16
16
  */
17
17
  export declare function isRightAngleRads(rads: Radians): boolean;
18
+ export declare function radiansBetweenAngles(a: Radians, min: Radians, max: Radians): boolean;
19
+ export declare function radiansDifference(a: Radians, b: Radians): Radians;
@@ -8,6 +8,7 @@ import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
8
8
  * @returns
9
9
  */
10
10
  export declare function curve<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, c: Point, d: Point): Curve<Point>;
11
+ export declare const bezierEquation: <Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, t: number) => Point;
11
12
  /**
12
13
  * Computes the intersection between a cubic spline and a line segment.
13
14
  */
@@ -38,3 +39,4 @@ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoin
38
39
  * Determines if the parameter is a Curve
39
40
  */
40
41
  export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
42
+ export declare function curveTangent<Point extends GlobalPoint | LocalPoint>([p0, p1, p2, p3]: Curve<Point>, t: number): import("./types").Vector;
@@ -43,7 +43,7 @@ export declare function isPoint(p: unknown): p is LocalPoint | GlobalPoint;
43
43
  * @param b Point The second point to compare
44
44
  * @returns TRUE if the points are sufficiently close to each other
45
45
  */
46
- export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point): boolean;
46
+ export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, tolerance?: number): boolean;
47
47
  /**
48
48
  * Rotate a point by [angle] radians.
49
49
  *
@@ -103,3 +103,4 @@ export type Ellipse<Point extends GlobalPoint | LocalPoint> = {
103
103
  } & {
104
104
  _brand: "excalimath_ellipse";
105
105
  };
106
+ export type ElementsSegmentsMap = Map<string, LineSegment<GlobalPoint>[]>;
@@ -86,3 +86,7 @@ export declare function vectorMagnitude(v: Vector): number;
86
86
  * @returns The new normalized vector
87
87
  */
88
88
  export declare const vectorNormalize: (v: Vector) => Vector;
89
+ /**
90
+ * Calculate the right-hand normal of the vector.
91
+ */
92
+ export declare const vectorNormal: (v: Vector) => Vector;
@@ -1,5 +1,5 @@
1
1
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
2
- import type { Bounds } from "@excalidraw/element/bounds";
2
+ import type { Bounds } from "@excalidraw/element";
3
3
  export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P];
4
4
  export declare function getBBox<P extends LocalPoint | GlobalPoint>(line: LineSegment<P>): Bounds;
5
5
  export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
@@ -1,4 +1,4 @@
1
1
  export * from "./export";
2
2
  export * from "./withinBounds";
3
3
  export * from "./bbox";
4
- export { getCommonBounds } from "@excalidraw/element/bounds";
4
+ export { getCommonBounds } from "@excalidraw/element";
@@ -1,4 +1,4 @@
1
- import type { Bounds } from "@excalidraw/element/bounds";
1
+ import type { Bounds } from "@excalidraw/element";
2
2
  import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
3
  type Element = NonDeletedExcalidrawElement;
4
4
  type Elements = readonly NonDeletedExcalidrawElement[];
package/history.ts CHANGED
@@ -1,12 +1,17 @@
1
- import type { SceneElementsMap } from "@excalidraw/element/types";
1
+ import { Emitter } from "@excalidraw/common";
2
+
3
+ import {
4
+ CaptureUpdateAction,
5
+ StoreChange,
6
+ StoreDelta,
7
+ type Store,
8
+ } from "@excalidraw/element";
2
9
 
3
- import { Emitter } from "./emitter";
10
+ import type { SceneElementsMap } from "@excalidraw/element/types";
4
11
 
5
- import type { AppStateChange, ElementsChange } from "./change";
6
- import type { Snapshot } from "./store";
7
12
  import type { AppState } from "./types";
8
13
 
9
- type HistoryStack = HistoryEntry[];
14
+ class HistoryEntry extends StoreDelta {}
10
15
 
11
16
  export class HistoryChangedEvent {
12
17
  constructor(
@@ -20,8 +25,8 @@ export class History {
20
25
  [HistoryChangedEvent]
21
26
  >();
22
27
 
23
- private readonly undoStack: HistoryStack = [];
24
- private readonly redoStack: HistoryStack = [];
28
+ public readonly undoStack: HistoryEntry[] = [];
29
+ public readonly redoStack: HistoryEntry[] = [];
25
30
 
26
31
  public get isUndoStackEmpty() {
27
32
  return this.undoStack.length === 0;
@@ -31,60 +36,52 @@ export class History {
31
36
  return this.redoStack.length === 0;
32
37
  }
33
38
 
39
+ constructor(private readonly store: Store) {}
40
+
34
41
  public clear() {
35
42
  this.undoStack.length = 0;
36
43
  this.redoStack.length = 0;
37
44
  }
38
45
 
39
46
  /**
40
- * Record a local change which will go into the history
47
+ * Record a non-empty local durable increment, which will go into the undo stack..
48
+ * Do not re-record history entries, which were already pushed to undo / redo stack, as part of history action.
41
49
  */
42
- public record(
43
- elementsChange: ElementsChange,
44
- appStateChange: AppStateChange,
45
- ) {
46
- const entry = HistoryEntry.create(appStateChange, elementsChange);
50
+ public record(delta: StoreDelta) {
51
+ if (delta.isEmpty() || delta instanceof HistoryEntry) {
52
+ return;
53
+ }
47
54
 
48
- if (!entry.isEmpty()) {
49
- // we have the latest changes, no need to `applyLatest`, which is done within `History.push`
50
- this.undoStack.push(entry.inverse());
55
+ // construct history entry, so once it's emitted, it's not recorded again
56
+ const entry = HistoryEntry.inverse(delta);
51
57
 
52
- if (!entry.elementsChange.isEmpty()) {
53
- // don't reset redo stack on local appState changes,
54
- // as a simple click (unselect) could lead to losing all the redo entries
55
- // only reset on non empty elements changes!
56
- this.redoStack.length = 0;
57
- }
58
+ this.undoStack.push(entry);
58
59
 
59
- this.onHistoryChangedEmitter.trigger(
60
- new HistoryChangedEvent(this.isUndoStackEmpty, this.isRedoStackEmpty),
61
- );
60
+ if (!entry.elements.isEmpty()) {
61
+ // don't reset redo stack on local appState changes,
62
+ // as a simple click (unselect) could lead to losing all the redo entries
63
+ // only reset on non empty elements changes!
64
+ this.redoStack.length = 0;
62
65
  }
66
+
67
+ this.onHistoryChangedEmitter.trigger(
68
+ new HistoryChangedEvent(this.isUndoStackEmpty, this.isRedoStackEmpty),
69
+ );
63
70
  }
64
71
 
65
- public undo(
66
- elements: SceneElementsMap,
67
- appState: AppState,
68
- snapshot: Readonly<Snapshot>,
69
- ) {
72
+ public undo(elements: SceneElementsMap, appState: AppState) {
70
73
  return this.perform(
71
74
  elements,
72
75
  appState,
73
- snapshot,
74
76
  () => History.pop(this.undoStack),
75
77
  (entry: HistoryEntry) => History.push(this.redoStack, entry, elements),
76
78
  );
77
79
  }
78
80
 
79
- public redo(
80
- elements: SceneElementsMap,
81
- appState: AppState,
82
- snapshot: Readonly<Snapshot>,
83
- ) {
81
+ public redo(elements: SceneElementsMap, appState: AppState) {
84
82
  return this.perform(
85
83
  elements,
86
84
  appState,
87
- snapshot,
88
85
  () => History.pop(this.redoStack),
89
86
  (entry: HistoryEntry) => History.push(this.undoStack, entry, elements),
90
87
  );
@@ -93,7 +90,6 @@ export class History {
93
90
  private perform(
94
91
  elements: SceneElementsMap,
95
92
  appState: AppState,
96
- snapshot: Readonly<Snapshot>,
97
93
  pop: () => HistoryEntry | null,
98
94
  push: (entry: HistoryEntry) => void,
99
95
  ): [SceneElementsMap, AppState] | void {
@@ -104,6 +100,10 @@ export class History {
104
100
  return;
105
101
  }
106
102
 
103
+ const action = CaptureUpdateAction.IMMEDIATELY;
104
+
105
+ let prevSnapshot = this.store.snapshot;
106
+
107
107
  let nextElements = elements;
108
108
  let nextAppState = appState;
109
109
  let containsVisibleChange = false;
@@ -112,9 +112,29 @@ export class History {
112
112
  while (historyEntry) {
113
113
  try {
114
114
  [nextElements, nextAppState, containsVisibleChange] =
115
- historyEntry.applyTo(nextElements, nextAppState, snapshot);
115
+ StoreDelta.applyTo(
116
+ historyEntry,
117
+ nextElements,
118
+ nextAppState,
119
+ prevSnapshot,
120
+ );
121
+
122
+ const nextSnapshot = prevSnapshot.maybeClone(
123
+ action,
124
+ nextElements,
125
+ nextAppState,
126
+ );
127
+
128
+ // schedule immediate capture, so that it's emitted for the sync purposes
129
+ this.store.scheduleMicroAction({
130
+ action,
131
+ change: StoreChange.create(prevSnapshot, nextSnapshot),
132
+ delta: historyEntry,
133
+ });
134
+
135
+ prevSnapshot = nextSnapshot;
116
136
  } finally {
117
- // make sure to always push / pop, even if the increment is corrupted
137
+ // make sure to always push, even if the delta is corrupted
118
138
  push(historyEntry);
119
139
  }
120
140
 
@@ -135,7 +155,7 @@ export class History {
135
155
  }
136
156
  }
137
157
 
138
- private static pop(stack: HistoryStack): HistoryEntry | null {
158
+ private static pop(stack: HistoryEntry[]): HistoryEntry | null {
139
159
  if (!stack.length) {
140
160
  return null;
141
161
  }
@@ -150,63 +170,17 @@ export class History {
150
170
  }
151
171
 
152
172
  private static push(
153
- stack: HistoryStack,
173
+ stack: HistoryEntry[],
154
174
  entry: HistoryEntry,
155
175
  prevElements: SceneElementsMap,
156
176
  ) {
157
- const updatedEntry = entry.inverse().applyLatestChanges(prevElements);
158
- return stack.push(updatedEntry);
159
- }
160
- }
161
-
162
- export class HistoryEntry {
163
- private constructor(
164
- public readonly appStateChange: AppStateChange,
165
- public readonly elementsChange: ElementsChange,
166
- ) {}
167
-
168
- public static create(
169
- appStateChange: AppStateChange,
170
- elementsChange: ElementsChange,
171
- ) {
172
- return new HistoryEntry(appStateChange, elementsChange);
173
- }
174
-
175
- public inverse(): HistoryEntry {
176
- return new HistoryEntry(
177
- this.appStateChange.inverse(),
178
- this.elementsChange.inverse(),
177
+ const inversedEntry = HistoryEntry.inverse(entry);
178
+ const updatedEntry = HistoryEntry.applyLatestChanges(
179
+ inversedEntry,
180
+ prevElements,
181
+ "inserted",
179
182
  );
180
- }
181
-
182
- public applyTo(
183
- elements: SceneElementsMap,
184
- appState: AppState,
185
- snapshot: Readonly<Snapshot>,
186
- ): [SceneElementsMap, AppState, boolean] {
187
- const [nextElements, elementsContainVisibleChange] =
188
- this.elementsChange.applyTo(elements, snapshot.elements);
189
183
 
190
- const [nextAppState, appStateContainsVisibleChange] =
191
- this.appStateChange.applyTo(appState, nextElements);
192
-
193
- const appliedVisibleChanges =
194
- elementsContainVisibleChange || appStateContainsVisibleChange;
195
-
196
- return [nextElements, nextAppState, appliedVisibleChanges];
197
- }
198
-
199
- /**
200
- * Apply latest (remote) changes to the history entry, creates new instance of `HistoryEntry`.
201
- */
202
- public applyLatestChanges(elements: SceneElementsMap): HistoryEntry {
203
- const updatedElementsChange =
204
- this.elementsChange.applyLatestChanges(elements);
205
-
206
- return HistoryEntry.create(this.appStateChange, updatedElementsChange);
207
- }
208
-
209
- public isEmpty(): boolean {
210
- return this.appStateChange.isEmpty() && this.elementsChange.isEmpty();
184
+ return stack.push(updatedEntry);
211
185
  }
212
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/excalidraw",
3
- "version": "0.18.0-6fc8502",
3
+ "version": "0.18.0-864353b",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -129,7 +129,7 @@
129
129
  "bugs": "https://github.com/excalidraw/excalidraw/issues",
130
130
  "homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw",
131
131
  "scripts": {
132
- "gen:types": "rm -rf types && tsc",
133
- "build:esm": "rm -rf dist && node ../../scripts/buildPackage.js && yarn gen:types"
132
+ "gen:types": "rimraf types && tsc",
133
+ "build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types"
134
134
  }
135
135
  }
@@ -1,7 +0,0 @@
1
- // <define:import.meta.env>
2
- var define_import_meta_env_default = { VITE_APP_BACKEND_V2_GET_URL: "https://json-dev.excalidraw.com/api/v2/", VITE_APP_BACKEND_V2_POST_URL: "https://json-dev.excalidraw.com/api/v2/post/", VITE_APP_LIBRARY_URL: "https://libraries.excalidraw.com", VITE_APP_LIBRARY_BACKEND: "https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries", VITE_APP_WS_SERVER_URL: "http://localhost:3002", VITE_APP_PLUS_LP: "https://plus.excalidraw.com", VITE_APP_PLUS_APP: "http://localhost:3000", VITE_APP_AI_BACKEND: "http://localhost:3015", VITE_APP_FIREBASE_CONFIG: '{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}', VITE_APP_DEV_DISABLE_LIVE_RELOAD: "", VITE_APP_ENABLE_TRACKING: "true", FAST_REFRESH: "false", VITE_APP_PORT: "3000", VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX: "", VITE_APP_COLLAPSE_OVERLAY: "true", VITE_APP_ENABLE_ESLINT: "true", VITE_APP_ENABLE_PWA: "false", VITE_APP_PLUS_EXPORT_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\nHQIDAQAB", VITE_APP_DISABLE_PREVENT_UNLOAD: "", PKG_NAME: "@excalidraw/excalidraw", PKG_VERSION: "0.18.0-6fc8502", DEV: true };
3
-
4
- export {
5
- define_import_meta_env_default
6
- };
7
- //# sourceMappingURL=chunk-H7XJ5UVD.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["<define:import.meta.env>"],
4
- "sourcesContent": [""],
5
- "mappings": ";AAAA,uCAAC,6BAA8B,2CAA0C,8BAA+B,gDAA+C,sBAAuB,oCAAmC,0BAA2B,gFAA+E,wBAAyB,yBAAwB,kBAAmB,+BAA8B,mBAAoB,yBAAwB,qBAAsB,yBAAwB,0BAA2B,mRAA0S,kCAAmC,IAAG,0BAA2B,QAAO,cAAe,SAAQ,eAAgB,QAAO,mDAAoD,IAAG,2BAA4B,QAAO,wBAAyB,QAAO,qBAAsB,SAAQ,iCAAkC,wZAAuZ,iCAAkC,IAAG,UAAW,0BAAyB,aAAc,kBAAiB,KAAM,KAAI;",
6
- "names": []
7
- }