@zsviczian/excalidraw 0.18.0-13 → 0.18.0-15

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 (116) hide show
  1. package/dist/excalidraw.development.js +153 -153
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/styles.development.css +38 -2
  4. package/dist/styles.production.css +2 -2
  5. package/package.json +1 -1
  6. package/types/common/src/constants.d.ts +1 -0
  7. package/types/{excalidraw → common/src}/emitter.d.ts +1 -1
  8. package/types/common/src/font-metadata.d.ts +4 -2
  9. package/types/common/src/index.d.ts +1 -0
  10. package/types/common/src/utility-types.d.ts +5 -0
  11. package/types/common/src/utils.d.ts +16 -4
  12. package/types/element/src/Scene.d.ts +4 -4
  13. package/types/element/src/ShapeCache.d.ts +1 -1
  14. package/types/element/src/align.d.ts +1 -1
  15. package/types/element/src/binding.d.ts +1 -1
  16. package/types/element/src/bounds.d.ts +1 -1
  17. package/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +40 -35
  18. package/types/element/src/dragElements.d.ts +1 -1
  19. package/types/element/src/flowchart.d.ts +1 -1
  20. package/types/element/src/frame.d.ts +3 -2
  21. package/types/element/src/index.d.ts +45 -2
  22. package/types/element/src/linearElementEditor.d.ts +4 -8
  23. package/types/element/src/newElement.d.ts +1 -1
  24. package/types/element/src/resizeElements.d.ts +1 -1
  25. package/types/element/src/selection.d.ts +1 -6
  26. package/types/element/src/store.d.ts +227 -0
  27. package/types/element/src/textElement.d.ts +1 -1
  28. package/types/element/src/transformHandles.d.ts +4 -4
  29. package/types/element/src/typeChecks.d.ts +2 -1
  30. package/types/element/src/types.d.ts +6 -1
  31. package/types/element/src/zindex.d.ts +3 -3
  32. package/types/excalidraw/actions/actionAddToLibrary.d.ts +24 -42
  33. package/types/excalidraw/actions/actionAlign.d.ts +8 -8
  34. package/types/excalidraw/actions/actionBoundText.d.ts +16 -28
  35. package/types/excalidraw/actions/actionCanvas.d.ts +238 -328
  36. package/types/excalidraw/actions/actionClipboard.d.ts +50 -86
  37. package/types/excalidraw/actions/actionCropEditor.d.ts +8 -14
  38. package/types/excalidraw/actions/actionDeleteSelected.d.ts +22 -40
  39. package/types/excalidraw/actions/actionDistribute.d.ts +4 -4
  40. package/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  41. package/types/excalidraw/actions/actionElementLink.d.ts +8 -14
  42. package/types/excalidraw/actions/actionElementLock.d.ts +18 -30
  43. package/types/excalidraw/actions/actionEmbeddable.d.ts +8 -14
  44. package/types/excalidraw/actions/actionExport.d.ts +173 -227
  45. package/types/excalidraw/actions/actionFinalize.d.ts +14 -26
  46. package/types/excalidraw/actions/actionFlip.d.ts +4 -4
  47. package/types/excalidraw/actions/actionFrame.d.ts +81 -105
  48. package/types/excalidraw/actions/actionGroup.d.ts +22 -34
  49. package/types/excalidraw/actions/actionHistory.d.ts +1 -2
  50. package/types/excalidraw/actions/actionLinearEditor.d.ts +7 -13
  51. package/types/excalidraw/actions/actionLink.d.ts +9 -15
  52. package/types/excalidraw/actions/actionMenu.d.ts +26 -44
  53. package/types/excalidraw/actions/actionNavigate.d.ts +16 -28
  54. package/types/excalidraw/actions/actionProperties.d.ts +106 -196
  55. package/types/excalidraw/actions/actionSelectAll.d.ts +10 -16
  56. package/types/excalidraw/actions/actionStyles.d.ts +12 -18
  57. package/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -16
  58. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -16
  59. package/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -225
  60. package/types/excalidraw/actions/actionToggleStats.d.ts +10 -16
  61. package/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -16
  62. package/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -16
  63. package/types/excalidraw/actions/actionZindex.d.ts +10 -10
  64. package/types/excalidraw/actions/types.d.ts +1 -1
  65. package/types/excalidraw/appState.d.ts +23 -23
  66. package/types/excalidraw/clipboard.d.ts +4 -4
  67. package/types/excalidraw/components/App.d.ts +8 -8
  68. package/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  69. package/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
  70. package/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  71. package/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
  72. package/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
  73. package/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
  74. package/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  75. package/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  76. package/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  77. package/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -28
  78. package/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
  79. package/types/excalidraw/components/Range.d.ts +3 -3
  80. package/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  81. package/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  82. package/types/excalidraw/components/Stats/CanvasGridSize.d.ts +1 -1
  83. package/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  84. package/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  85. package/types/excalidraw/components/Stats/DragInput.d.ts +1 -1
  86. package/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  87. package/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  88. package/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  89. package/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  90. package/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  91. package/types/excalidraw/components/Stats/Position.d.ts +1 -1
  92. package/types/excalidraw/components/Stats/utils.d.ts +1 -1
  93. package/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
  94. package/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
  95. package/types/excalidraw/components/hyperlink/helpers.d.ts +1 -1
  96. package/types/excalidraw/components/icons.d.ts +1 -0
  97. package/types/excalidraw/components/shapes.d.ts +1 -1
  98. package/types/excalidraw/data/blob.d.ts +1 -1
  99. package/types/excalidraw/data/library.d.ts +1 -1
  100. package/types/excalidraw/data/transform.d.ts +1 -1
  101. package/types/excalidraw/fonts/Fonts.d.ts +1 -1
  102. package/types/excalidraw/history.d.ts +14 -22
  103. package/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  104. package/types/excalidraw/index.d.ts +9 -9
  105. package/types/excalidraw/renderer/helpers.d.ts +6 -1
  106. package/types/excalidraw/scene/Renderer.d.ts +1 -1
  107. package/types/excalidraw/scene/index.d.ts +2 -2
  108. package/types/excalidraw/snapping.d.ts +2 -2
  109. package/types/excalidraw/types.d.ts +13 -6
  110. package/types/excalidraw/visualdebug.d.ts +1 -1
  111. package/types/math/src/curve.d.ts +2 -0
  112. package/types/math/src/vector.d.ts +4 -0
  113. package/types/utils/src/bbox.d.ts +1 -1
  114. package/types/utils/src/index.d.ts +1 -1
  115. package/types/utils/src/withinBounds.d.ts +1 -1
  116. package/types/excalidraw/store.d.ts +0 -129
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
1
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMapOrArray } from "./types";
2
2
  /**
3
3
  * @deprecated unsafe, use hashElementsVersion instead
4
4
  */
@@ -6,7 +6,7 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
6
6
  /**
7
7
  * Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
8
8
  */
9
- export declare const hashElementsVersion: (elements: readonly ExcalidrawElement[]) => number;
9
+ export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
10
10
  export declare const hashString: (s: string) => number;
11
11
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
12
12
  export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
@@ -14,3 +14,46 @@ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element:
14
14
  export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
15
15
  export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
16
16
  export declare const clearElementsForLocalStorage: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
17
+ export * from "./align";
18
+ export * from "./binding";
19
+ export * from "./bounds";
20
+ export * from "./collision";
21
+ export * from "./comparisons";
22
+ export * from "./containerCache";
23
+ export * from "./cropElement";
24
+ export * from "./delta";
25
+ export * from "./distance";
26
+ export * from "./distribute";
27
+ export * from "./dragElements";
28
+ export * from "./duplicate";
29
+ export * from "./elbowArrow";
30
+ export * from "./elementLink";
31
+ export * from "./embeddable";
32
+ export * from "./flowchart";
33
+ export * from "./fractionalIndex";
34
+ export * from "./frame";
35
+ export * from "./groups";
36
+ export * from "./heading";
37
+ export * from "./image";
38
+ export * from "./linearElementEditor";
39
+ export * from "./mutateElement";
40
+ export * from "./newElement";
41
+ export * from "./renderElement";
42
+ export * from "./resizeElements";
43
+ export * from "./resizeTest";
44
+ export * from "./Scene";
45
+ export * from "./selection";
46
+ export * from "./Shape";
47
+ export * from "./ShapeCache";
48
+ export * from "./shapes";
49
+ export * from "./showSelectedShapeActions";
50
+ export * from "./sizeHelpers";
51
+ export * from "./sortElements";
52
+ export * from "./store";
53
+ export * from "./textElement";
54
+ export * from "./textMeasurements";
55
+ export * from "./textWrapping";
56
+ export * from "./transformHandles";
57
+ export * from "./typeChecks";
58
+ export * from "./utils";
59
+ export * from "./zindex";
@@ -1,9 +1,9 @@
1
1
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
2
- import type { Store } from "@excalidraw/excalidraw/store";
2
+ import type { Store } from "@excalidraw/element";
3
3
  import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
4
- import type Scene from "./Scene";
4
+ import type { Scene } from "./Scene";
5
5
  import type { Bounds } from "./bounds";
6
- import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement } from "./types";
6
+ import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
7
7
  declare const editorMidPointsCache: {
8
8
  version: number | null;
9
9
  points: (GlobalPoint | null)[];
@@ -102,11 +102,7 @@ export declare class LinearElementEditor {
102
102
  static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, targetPoints: {
103
103
  point: LocalPoint;
104
104
  }[]): void;
105
- static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, targetPoints: {
106
- index: number;
107
- point: LocalPoint;
108
- isDragging?: boolean;
109
- }[], otherUpdates?: {
105
+ static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
110
106
  startBinding?: PointBinding | null;
111
107
  endBinding?: PointBinding | null;
112
108
  }): void;
@@ -52,7 +52,7 @@ export declare const newArrowElement: <T extends boolean>(opts: {
52
52
  points?: readonly import("@excalidraw/math").LocalPoint[] | undefined;
53
53
  elbowed?: T | undefined;
54
54
  fixedSegments?: readonly import("./types").FixedSegment[] | null | undefined;
55
- } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "angle" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "angle" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
55
+ } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
56
56
  export declare const newImageElement: (opts: {
57
57
  type: ExcalidrawImageElement["type"];
58
58
  status?: ExcalidrawImageElement["status"];
@@ -1,6 +1,6 @@
1
1
  import { type LocalPoint } from "@excalidraw/math";
2
2
  import type { PointerDownState } from "@excalidraw/excalidraw/types";
3
- import type Scene from "./Scene";
3
+ import type { Scene } from "./Scene";
4
4
  import type { BoundingBox } from "./bounds";
5
5
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
6
6
  import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap } from "./types";
@@ -14,11 +14,6 @@ export declare const isSomeElementSelected: {
14
14
  (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
15
15
  clearCache(): void;
16
16
  };
17
- /**
18
- * Returns common attribute (picked by `getAttribute` callback) of selected
19
- * elements. If elements don't share the same value, returns `null`.
20
- */
21
- export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
22
17
  export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
23
18
  includeBoundTextElement?: boolean;
24
19
  includeElementsInFrames?: boolean;
@@ -32,12 +27,12 @@ export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppSta
32
27
  [id: string]: true;
33
28
  }>;
34
29
  export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
35
- editingGroupId: string | null;
36
30
  selectedElementIds: Readonly<{
37
31
  [id: string]: true;
38
32
  }>;
39
33
  selectedGroupIds: {
40
34
  [groupId: string]: boolean;
41
35
  };
36
+ editingGroupId: string | null;
42
37
  selectedLinearElement: LinearElementEditor | null;
43
38
  };
@@ -0,0 +1,227 @@
1
+ import { Emitter } from "@excalidraw/common";
2
+ import type App from "@excalidraw/excalidraw/components/App";
3
+ import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
4
+ import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
5
+ import { ElementsDelta, AppStateDelta } from "./delta";
6
+ import type { OrderedExcalidrawElement, SceneElementsMap } from "./types";
7
+ export declare const CaptureUpdateAction: {
8
+ /**
9
+ * Immediately undoable.
10
+ *
11
+ * Use for updates which should be captured.
12
+ * Should be used for most of the local updates, except ephemerals such as dragging or resizing.
13
+ *
14
+ * These updates will _immediately_ make it to the local undo / redo stacks.
15
+ */
16
+ readonly IMMEDIATELY: "IMMEDIATELY";
17
+ /**
18
+ * Never undoable.
19
+ *
20
+ * Use for updates which should never be recorded, such as remote updates
21
+ * or scene initialization.
22
+ *
23
+ * These updates will _never_ make it to the local undo / redo stacks.
24
+ */
25
+ readonly NEVER: "NEVER";
26
+ /**
27
+ * Eventually undoable.
28
+ *
29
+ * Use for updates which should not be captured immediately - likely
30
+ * exceptions which are part of some async multi-step process. Otherwise, all
31
+ * such updates would end up being captured with the next
32
+ * `CaptureUpdateAction.IMMEDIATELY` - triggered either by the next `updateScene`
33
+ * or internally by the editor.
34
+ *
35
+ * These updates will _eventually_ make it to the local undo / redo stacks.
36
+ */
37
+ readonly EVENTUALLY: "EVENTUALLY";
38
+ };
39
+ export type CaptureUpdateActionType = ValueOf<typeof CaptureUpdateAction>;
40
+ /**
41
+ * Store which captures the observed changes and emits them as `StoreIncrement` events.
42
+ */
43
+ export declare class Store {
44
+ private readonly app;
45
+ readonly onDurableIncrementEmitter: Emitter<[DurableIncrement]>;
46
+ readonly onStoreIncrementEmitter: Emitter<[DurableIncrement | EphemeralIncrement]>;
47
+ private scheduledMacroActions;
48
+ private scheduledMicroActions;
49
+ private _snapshot;
50
+ get snapshot(): StoreSnapshot;
51
+ set snapshot(snapshot: StoreSnapshot);
52
+ constructor(app: App);
53
+ scheduleAction(action: CaptureUpdateActionType): void;
54
+ /**
55
+ * Use to schedule a delta calculation, which will consquentially be emitted as `DurableStoreIncrement` and pushed in the undo stack.
56
+ */
57
+ scheduleCapture(): void;
58
+ /**
59
+ * Schedule special "micro" actions, to-be executed before the next commit, before it executes a scheduled "macro" action.
60
+ */
61
+ scheduleMicroAction(params: {
62
+ action: CaptureUpdateActionType;
63
+ elements: SceneElementsMap | undefined;
64
+ appState: AppState | ObservedAppState | undefined;
65
+ } | {
66
+ action: typeof CaptureUpdateAction.IMMEDIATELY;
67
+ change: StoreChange;
68
+ delta: StoreDelta;
69
+ } | {
70
+ action: typeof CaptureUpdateAction.NEVER | typeof CaptureUpdateAction.EVENTUALLY;
71
+ change: StoreChange;
72
+ }): void;
73
+ /**
74
+ * Performs the incoming `CaptureUpdateAction` and emits the corresponding `StoreIncrement`.
75
+ * Emits `DurableStoreIncrement` when action is "capture", emits `EphemeralStoreIncrement` otherwise.
76
+ *
77
+ * @emits StoreIncrement
78
+ */
79
+ commit(elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): void;
80
+ /**
81
+ * Clears the store instance.
82
+ */
83
+ clear(): void;
84
+ /**
85
+ * Performs delta & change calculation and emits a durable increment.
86
+ *
87
+ * @emits StoreIncrement.
88
+ */
89
+ private emitDurableIncrement;
90
+ /**
91
+ * Performs change calculation and emits an ephemeral increment.
92
+ *
93
+ * @emits EphemeralStoreIncrement
94
+ */
95
+ private emitEphemeralIncrement;
96
+ private applyChangeToSnapshot;
97
+ /**
98
+ * Clones the snapshot if there are changes detected.
99
+ */
100
+ private maybeCloneSnapshot;
101
+ private flushMicroActions;
102
+ private processAction;
103
+ /**
104
+ * Returns the scheduled macro action.
105
+ */
106
+ private getScheduledMacroAction;
107
+ /**
108
+ * Ensures that the scheduled actions invariant is satisfied.
109
+ */
110
+ private satisfiesScheduledActionsInvariant;
111
+ }
112
+ /**
113
+ * Repsents a change to the store containing changed elements and appState.
114
+ */
115
+ export declare class StoreChange {
116
+ readonly elements: Record<string, OrderedExcalidrawElement>;
117
+ readonly appState: Partial<ObservedAppState>;
118
+ private constructor();
119
+ static create(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreChange;
120
+ }
121
+ /**
122
+ * Encpasulates any change to the store (durable or ephemeral).
123
+ */
124
+ export declare abstract class StoreIncrement {
125
+ readonly type: "durable" | "ephemeral";
126
+ readonly change: StoreChange;
127
+ protected constructor(type: "durable" | "ephemeral", change: StoreChange);
128
+ static isDurable(increment: StoreIncrement): increment is DurableIncrement;
129
+ static isEphemeral(increment: StoreIncrement): increment is EphemeralIncrement;
130
+ }
131
+ /**
132
+ * Represents a durable change to the store.
133
+ */
134
+ export declare class DurableIncrement extends StoreIncrement {
135
+ readonly change: StoreChange;
136
+ readonly delta: StoreDelta;
137
+ constructor(change: StoreChange, delta: StoreDelta);
138
+ }
139
+ /**
140
+ * Represents an ephemeral change to the store.
141
+ */
142
+ export declare class EphemeralIncrement extends StoreIncrement {
143
+ readonly change: StoreChange;
144
+ constructor(change: StoreChange);
145
+ }
146
+ /**
147
+ * Represents a captured delta by the Store.
148
+ */
149
+ export declare class StoreDelta {
150
+ readonly id: string;
151
+ readonly elements: ElementsDelta;
152
+ readonly appState: AppStateDelta;
153
+ protected constructor(id: string, elements: ElementsDelta, appState: AppStateDelta);
154
+ /**
155
+ * Create a new instance of `StoreDelta`.
156
+ */
157
+ static create(elements: ElementsDelta, appState: AppStateDelta, opts?: {
158
+ id: string;
159
+ }): StoreDelta;
160
+ /**
161
+ * Restore a store delta instance from a DTO.
162
+ */
163
+ static restore(storeDeltaDTO: DTO<StoreDelta>): StoreDelta;
164
+ /**
165
+ * Parse and load the delta from the remote payload.
166
+ */
167
+ static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
168
+ /**
169
+ * Inverse store delta, creates new instance of `StoreDelta`.
170
+ */
171
+ static inverse(delta: StoreDelta): StoreDelta;
172
+ /**
173
+ * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
174
+ */
175
+ static applyLatestChanges(delta: StoreDelta, elements: SceneElementsMap, modifierOptions: "deleted" | "inserted"): StoreDelta;
176
+ /**
177
+ * Apply the delta to the passed elements and appState, does not modify the snapshot.
178
+ */
179
+ static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState, prevSnapshot?: StoreSnapshot): [SceneElementsMap, AppState, boolean];
180
+ isEmpty(): boolean;
181
+ }
182
+ /**
183
+ * Represents a snapshot of the captured or updated changes in the store,
184
+ * used for producing deltas and emitting `DurableStoreIncrement`s.
185
+ */
186
+ export declare class StoreSnapshot {
187
+ readonly elements: SceneElementsMap;
188
+ readonly appState: ObservedAppState;
189
+ readonly metadata: {
190
+ didElementsChange: boolean;
191
+ didAppStateChange: boolean;
192
+ isEmpty?: boolean;
193
+ };
194
+ private _lastChangedElementsHash;
195
+ private _lastChangedAppStateHash;
196
+ private constructor();
197
+ static create(elements: SceneElementsMap, appState: AppState | ObservedAppState, metadata?: {
198
+ didElementsChange: boolean;
199
+ didAppStateChange: boolean;
200
+ }): StoreSnapshot;
201
+ static empty(): StoreSnapshot;
202
+ getChangedElements(prevSnapshot: StoreSnapshot): Record<string, OrderedExcalidrawElement>;
203
+ getChangedAppState(prevSnapshot: StoreSnapshot): Partial<ObservedAppState>;
204
+ isEmpty(): boolean | undefined;
205
+ /**
206
+ * Apply the change and return a new snapshot instance.
207
+ */
208
+ applyChange(change: StoreChange): StoreSnapshot;
209
+ /**
210
+ * Efficiently clone the existing snapshot, only if we detected changes.
211
+ *
212
+ * @returns same instance if there are no changes detected, new instance otherwise.
213
+ */
214
+ maybeClone(action: CaptureUpdateActionType, elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): StoreSnapshot;
215
+ private maybeCreateAppStateSnapshot;
216
+ private maybeCreateElementsSnapshot;
217
+ private detectChangedAppState;
218
+ /**
219
+ * Detect if there any changed elements.
220
+ */
221
+ private detectChangedElements;
222
+ /**
223
+ * Perform structural clone, deep cloning only elements that changed.
224
+ */
225
+ private createElementsSnapshot;
226
+ }
227
+ export declare const getObservedAppState: (appState: AppState) => ObservedAppState;
@@ -1,7 +1,7 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
2
  import type { ExtractSetType } from "@excalidraw/common/utility-types";
3
3
  import type { Radians } from "@excalidraw/math";
4
- import type Scene from "./Scene";
4
+ import type { Scene } from "./Scene";
5
5
  import type { MaybeTransformHandleType } from "./transformHandles";
6
6
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
7
7
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
@@ -31,10 +31,10 @@ export declare const OMIT_SIDES_FOR_FRAME: {
31
31
  export declare const canResizeFromSides: (device: Device) => boolean;
32
32
  export declare const getOmitSidesForDevice: (device: Device) => {};
33
33
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: Radians, zoom: Zoom, pointerType: PointerType, omitSides?: {
34
+ e?: boolean | undefined;
34
35
  s?: boolean | undefined;
35
- n?: boolean | undefined;
36
36
  w?: boolean | undefined;
37
- e?: boolean | undefined;
37
+ n?: boolean | undefined;
38
38
  nw?: boolean | undefined;
39
39
  ne?: boolean | undefined;
40
40
  sw?: boolean | undefined;
@@ -42,10 +42,10 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
42
42
  rotation?: boolean | undefined;
43
43
  }, margin?: number, spacing?: number) => TransformHandles;
44
44
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, elementsMap: ElementsMap, pointerType?: PointerType, omitSides?: {
45
+ e?: boolean | undefined;
45
46
  s?: boolean | undefined;
46
- n?: boolean | undefined;
47
47
  w?: boolean | undefined;
48
- e?: boolean | undefined;
48
+ n?: boolean | undefined;
49
49
  nw?: boolean | undefined;
50
50
  ne?: boolean | undefined;
51
51
  sw?: boolean | undefined;
@@ -1,7 +1,7 @@
1
1
  import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkNonNullable } from "@excalidraw/common/utility-types";
3
3
  import type { Bounds } from "./bounds";
4
- import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, PointBinding, FixedPointBinding, ExcalidrawFlowchartNodeElement } from "./types";
4
+ import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, PointBinding, FixedPointBinding, ExcalidrawFlowchartNodeElement, ExcalidrawLinearElementSubType } from "./types";
5
5
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
6
6
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
7
7
  export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
@@ -40,3 +40,4 @@ export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElem
40
40
  } | null;
41
41
  export declare const isFixedPointBinding: (binding: PointBinding | FixedPointBinding) => binding is FixedPointBinding;
42
42
  export declare const isBounds: (box: unknown) => box is Bounds;
43
+ export declare const getLinearElementSubType: (element: ExcalidrawLinearElement) => ExcalidrawLinearElementSubType;
@@ -208,6 +208,10 @@ export type PointBinding = {
208
208
  export type FixedPointBinding = Merge<PointBinding, {
209
209
  fixedPoint: FixedPoint;
210
210
  }>;
211
+ export type PointsPositionUpdates = Map<number, {
212
+ point: LocalPoint;
213
+ isDragging?: boolean;
214
+ }>;
211
215
  export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline" | "crowfoot_one" | "crowfoot_many" | "crowfoot_one_or_many";
212
216
  export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
213
217
  type: "line" | "arrow";
@@ -282,7 +286,8 @@ export type SceneElementsMap = Map<ExcalidrawElement["id"], Ordered<ExcalidrawEl
282
286
  */
283
287
  export type NonDeletedSceneElementsMap = Map<ExcalidrawElement["id"], Ordered<NonDeletedExcalidrawElement>> & MakeBrand<"NonDeletedSceneElementsMap">;
284
288
  export type ElementsMapOrArray = readonly ExcalidrawElement[] | Readonly<ElementsMap>;
289
+ export type ExcalidrawLinearElementSubType = "line" | "sharpArrow" | "curvedArrow" | "elbowArrow";
285
290
  export type ConvertibleGenericTypes = "rectangle" | "diamond" | "ellipse";
286
- export type ConvertibleLinearTypes = "line" | "sharpArrow" | "curvedArrow" | "elbowArrow";
291
+ export type ConvertibleLinearTypes = ExcalidrawLinearElementSubType;
287
292
  export type ConvertibleTypes = ConvertibleGenericTypes | ConvertibleLinearTypes;
288
293
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
- import type Scene from "./Scene";
2
+ import type { Scene } from "./Scene";
3
3
  import type { ExcalidrawElement } from "./types";
4
4
  export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState, scene: Scene) => readonly ExcalidrawElement[];
5
5
  export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState, scene: Scene) => readonly ExcalidrawElement[];
6
- export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[] | readonly ExcalidrawElement[];
7
- export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[] | readonly ExcalidrawElement[];
6
+ export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
7
+ export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
@@ -27,7 +27,7 @@ export declare const actionAddToLibrary: {
27
27
  selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
28
28
  isBindingEnabled: boolean;
29
29
  startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
30
- suggestedBindings: import("@excalidraw/element/binding").SuggestedBinding[];
30
+ suggestedBindings: import("@excalidraw/element").SuggestedBinding[];
31
31
  frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
32
32
  frameRendering: {
33
33
  enabled: boolean;
@@ -38,7 +38,7 @@ export declare const actionAddToLibrary: {
38
38
  editingFrame: string | null;
39
39
  elementsToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawElement>[] | null;
40
40
  editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
41
- editingLinearElement: import("@excalidraw/element/linearElementEditor").LinearElementEditor | null;
41
+ editingLinearElement: import("@excalidraw/element").LinearElementEditor | null;
42
42
  activeTool: {
43
43
  lastActiveTool: import("../types").ActiveTool | null;
44
44
  locked: boolean;
@@ -154,7 +154,7 @@ export declare const actionAddToLibrary: {
154
154
  data: import("../charts").Spreadsheet;
155
155
  };
156
156
  pendingImageElementId: string | null;
157
- showHyperlinkPopup: false | "editor" | "info";
157
+ showHyperlinkPopup: false | "info" | "editor";
158
158
  linkOpacity: number;
159
159
  trayModeEnabled: boolean;
160
160
  colorPalette?: {
@@ -191,7 +191,7 @@ export declare const actionAddToLibrary: {
191
191
  nameColor: string;
192
192
  };
193
193
  invertBindingBehaviour: boolean;
194
- selectedLinearElement: import("@excalidraw/element/linearElementEditor").LinearElementEditor | null;
194
+ selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
195
195
  snapLines: readonly import("../snapping").SnapLine[];
196
196
  originSnapOffset: {
197
197
  x: number;
@@ -202,16 +202,10 @@ export declare const actionAddToLibrary: {
202
202
  followedBy: Set<import("../types").SocketId>;
203
203
  isCropping: boolean;
204
204
  croppingElementId: string | null;
205
- searchMatches: readonly {
206
- id: string;
207
- focus: boolean;
208
- matchedLines: {
209
- offsetX: number;
210
- offsetY: number;
211
- width: number;
212
- height: number;
213
- }[];
214
- }[];
205
+ searchMatches: Readonly<{
206
+ focusedId: string | null;
207
+ matches: readonly import("../types").SearchMatch[];
208
+ }> | null;
215
209
  };
216
210
  } | {
217
211
  captureUpdate: "EVENTUALLY";
@@ -234,7 +228,7 @@ export declare const actionAddToLibrary: {
234
228
  selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
235
229
  isBindingEnabled: boolean;
236
230
  startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
237
- suggestedBindings: import("@excalidraw/element/binding").SuggestedBinding[];
231
+ suggestedBindings: import("@excalidraw/element").SuggestedBinding[];
238
232
  frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
239
233
  frameRendering: {
240
234
  enabled: boolean;
@@ -245,7 +239,7 @@ export declare const actionAddToLibrary: {
245
239
  editingFrame: string | null;
246
240
  elementsToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawElement>[] | null;
247
241
  editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
248
- editingLinearElement: import("@excalidraw/element/linearElementEditor").LinearElementEditor | null;
242
+ editingLinearElement: import("@excalidraw/element").LinearElementEditor | null;
249
243
  activeTool: {
250
244
  lastActiveTool: import("../types").ActiveTool | null;
251
245
  locked: boolean;
@@ -366,7 +360,7 @@ export declare const actionAddToLibrary: {
366
360
  data: import("../charts").Spreadsheet;
367
361
  };
368
362
  pendingImageElementId: string | null;
369
- showHyperlinkPopup: false | "editor" | "info";
363
+ showHyperlinkPopup: false | "info" | "editor";
370
364
  linkOpacity: number;
371
365
  trayModeEnabled: boolean;
372
366
  colorPalette?: {
@@ -403,7 +397,7 @@ export declare const actionAddToLibrary: {
403
397
  nameColor: string;
404
398
  };
405
399
  invertBindingBehaviour: boolean;
406
- selectedLinearElement: import("@excalidraw/element/linearElementEditor").LinearElementEditor | null;
400
+ selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
407
401
  snapLines: readonly import("../snapping").SnapLine[];
408
402
  originSnapOffset: {
409
403
  x: number;
@@ -414,16 +408,10 @@ export declare const actionAddToLibrary: {
414
408
  followedBy: Set<import("../types").SocketId>;
415
409
  isCropping: boolean;
416
410
  croppingElementId: string | null;
417
- searchMatches: readonly {
418
- id: string;
419
- focus: boolean;
420
- matchedLines: {
421
- offsetX: number;
422
- offsetY: number;
423
- width: number;
424
- height: number;
425
- }[];
426
- }[];
411
+ searchMatches: Readonly<{
412
+ focusedId: string | null;
413
+ matches: readonly import("../types").SearchMatch[];
414
+ }> | null;
427
415
  };
428
416
  }> | {
429
417
  captureUpdate: "EVENTUALLY";
@@ -446,7 +434,7 @@ export declare const actionAddToLibrary: {
446
434
  selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
447
435
  isBindingEnabled: boolean;
448
436
  startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
449
- suggestedBindings: import("@excalidraw/element/binding").SuggestedBinding[];
437
+ suggestedBindings: import("@excalidraw/element").SuggestedBinding[];
450
438
  frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
451
439
  frameRendering: {
452
440
  enabled: boolean;
@@ -457,7 +445,7 @@ export declare const actionAddToLibrary: {
457
445
  editingFrame: string | null;
458
446
  elementsToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawElement>[] | null;
459
447
  editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
460
- editingLinearElement: import("@excalidraw/element/linearElementEditor").LinearElementEditor | null;
448
+ editingLinearElement: import("@excalidraw/element").LinearElementEditor | null;
461
449
  activeTool: {
462
450
  lastActiveTool: import("../types").ActiveTool | null;
463
451
  locked: boolean;
@@ -578,7 +566,7 @@ export declare const actionAddToLibrary: {
578
566
  data: import("../charts").Spreadsheet;
579
567
  };
580
568
  pendingImageElementId: string | null;
581
- showHyperlinkPopup: false | "editor" | "info";
569
+ showHyperlinkPopup: false | "info" | "editor";
582
570
  linkOpacity: number;
583
571
  trayModeEnabled: boolean;
584
572
  colorPalette?: {
@@ -615,7 +603,7 @@ export declare const actionAddToLibrary: {
615
603
  nameColor: string;
616
604
  };
617
605
  invertBindingBehaviour: boolean;
618
- selectedLinearElement: import("@excalidraw/element/linearElementEditor").LinearElementEditor | null;
606
+ selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
619
607
  snapLines: readonly import("../snapping").SnapLine[];
620
608
  originSnapOffset: {
621
609
  x: number;
@@ -626,16 +614,10 @@ export declare const actionAddToLibrary: {
626
614
  followedBy: Set<import("../types").SocketId>;
627
615
  isCropping: boolean;
628
616
  croppingElementId: string | null;
629
- searchMatches: readonly {
630
- id: string;
631
- focus: boolean;
632
- matchedLines: {
633
- offsetX: number;
634
- offsetY: number;
635
- width: number;
636
- height: number;
637
- }[];
638
- }[];
617
+ searchMatches: Readonly<{
618
+ focusedId: string | null;
619
+ matches: readonly import("../types").SearchMatch[];
620
+ }> | null;
639
621
  };
640
622
  };
641
623
  label: string;