@myoc/excalidraw 0.18.17 → 0.18.18

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 (110) hide show
  1. package/dist/dev/{chunk-FQEIAL75.js → chunk-MAGRVBVM.js} +8745 -10813
  2. package/dist/dev/chunk-MAGRVBVM.js.map +7 -0
  3. package/dist/dev/{chunk-KJKC5BJI.js → chunk-QO4EFL6B.js} +6 -2
  4. package/dist/dev/chunk-QO4EFL6B.js.map +7 -0
  5. package/dist/dev/chunk-WUH7JFG4.js +7 -0
  6. package/dist/dev/chunk-WUH7JFG4.js.map +7 -0
  7. package/dist/dev/data/{image-WMF622SS.js → image-BBHDGXQ3.js} +3 -3
  8. package/dist/dev/index.css +32 -2
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +4749 -2336
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-UQFCZXHO.js → en-2WXBKZE2.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-4Z2WWUCC.js +7 -0
  16. package/dist/prod/{chunk-EJLAYNAE.js → chunk-KZXLT4YB.js} +4 -4
  17. package/dist/prod/chunk-YBT3HBS6.js +33 -0
  18. package/dist/prod/data/image-JFILZTP3.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +18 -18
  21. package/dist/prod/locales/{en-7EHYHCIL.js → en-XFR6MADM.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 +16 -1
  25. package/dist/types/common/src/points.d.ts +1 -1
  26. package/dist/types/common/src/utils.d.ts +1 -3
  27. package/dist/types/element/src/binding.d.ts +6 -7
  28. package/dist/types/element/src/bounds.d.ts +10 -4
  29. package/dist/types/element/src/collision.d.ts +18 -12
  30. package/dist/types/element/src/cropElement.d.ts +1 -1
  31. package/dist/types/element/src/delta.d.ts +26 -6
  32. package/dist/types/element/src/distance.d.ts +2 -2
  33. package/dist/types/element/src/elbowArrow.d.ts +1 -1
  34. package/dist/types/element/src/fractionalIndex.d.ts +8 -2
  35. package/dist/types/element/src/heading.d.ts +2 -2
  36. package/dist/types/element/src/index.d.ts +1 -3
  37. package/dist/types/element/src/linearElementEditor.d.ts +11 -18
  38. package/dist/types/element/src/mutateElement.d.ts +1 -1
  39. package/dist/types/element/src/newElement.d.ts +2 -1
  40. package/dist/types/element/src/resizeElements.d.ts +1 -0
  41. package/dist/types/element/src/resizeTest.d.ts +2 -2
  42. package/dist/types/element/src/{ShapeCache.d.ts → shape.d.ts} +20 -3
  43. package/dist/types/element/src/shapes.d.ts +9 -9
  44. package/dist/types/element/src/sizeHelpers.d.ts +2 -1
  45. package/dist/types/element/src/store.d.ts +11 -7
  46. package/dist/types/element/src/typeChecks.d.ts +15 -1
  47. package/dist/types/element/src/types.d.ts +8 -3
  48. package/dist/types/element/src/utils.d.ts +5 -1
  49. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -6
  50. package/dist/types/excalidraw/actions/actionBoundText.d.ts +10 -4
  51. package/dist/types/excalidraw/actions/actionCanvas.d.ts +60 -24
  52. package/dist/types/excalidraw/actions/actionClipboard.d.ts +31 -12
  53. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -2
  54. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +16 -6
  55. package/dist/types/excalidraw/actions/actionElementLink.d.ts +5 -2
  56. package/dist/types/excalidraw/actions/actionElementLock.d.ts +25 -20
  57. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +5 -2
  58. package/dist/types/excalidraw/actions/actionExport.d.ts +45 -18
  59. package/dist/types/excalidraw/actions/actionFinalize.d.ts +58 -12
  60. package/dist/types/excalidraw/actions/actionFrame.d.ts +20 -8
  61. package/dist/types/excalidraw/actions/actionGroup.d.ts +10 -4
  62. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +498 -2
  63. package/dist/types/excalidraw/actions/actionLink.d.ts +5 -2
  64. package/dist/types/excalidraw/actions/actionMenu.d.ts +15 -6
  65. package/dist/types/excalidraw/actions/actionNavigate.d.ts +10 -4
  66. package/dist/types/excalidraw/actions/actionProperties.d.ts +84 -31
  67. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +5 -2
  68. package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -2
  69. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -2
  70. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -2
  71. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -2
  72. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -2
  73. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -2
  74. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -2
  75. package/dist/types/excalidraw/actions/types.d.ts +2 -1
  76. package/dist/types/excalidraw/appState.d.ts +10 -1
  77. package/dist/types/excalidraw/components/App.d.ts +7 -14
  78. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  79. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  80. package/dist/types/excalidraw/components/icons.d.ts +2 -0
  81. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  82. package/dist/types/excalidraw/history.d.ts +21 -5
  83. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  84. package/dist/types/excalidraw/renderer/helpers.d.ts +4 -4
  85. package/dist/types/excalidraw/scene/Renderer.d.ts +0 -1
  86. package/dist/types/excalidraw/types.d.ts +10 -4
  87. package/dist/types/math/src/angle.d.ts +3 -1
  88. package/dist/types/math/src/constants.d.ts +3 -0
  89. package/dist/types/math/src/curve.d.ts +33 -1
  90. package/dist/types/math/src/ellipse.d.ts +3 -3
  91. package/dist/types/math/src/index.d.ts +1 -0
  92. package/dist/types/math/src/point.d.ts +3 -3
  93. package/dist/types/math/src/polygon.d.ts +2 -2
  94. package/dist/types/math/src/segment.d.ts +5 -5
  95. package/dist/types/math/src/utils.d.ts +2 -0
  96. package/dist/types/math/src/vector.d.ts +4 -2
  97. package/dist/types/utils/src/shape.d.ts +12 -12
  98. package/history.ts +108 -45
  99. package/package.json +1 -1
  100. package/dist/dev/chunk-FQEIAL75.js.map +0 -7
  101. package/dist/dev/chunk-KJKC5BJI.js.map +0 -7
  102. package/dist/dev/chunk-XL2I4W52.js +0 -7
  103. package/dist/dev/chunk-XL2I4W52.js.map +0 -7
  104. package/dist/prod/chunk-5JAQX5EH.js +0 -7
  105. package/dist/prod/chunk-LSNMPGNI.js +0 -33
  106. package/dist/prod/data/image-Z433FUMH.js +0 -1
  107. package/dist/types/element/src/Shape.d.ts +0 -17
  108. package/dist/types/utils/src/collision.d.ts +0 -8
  109. /package/dist/dev/data/{image-WMF622SS.js.map → image-BBHDGXQ3.js.map} +0 -0
  110. /package/dist/dev/locales/{en-UQFCZXHO.js.map → en-2WXBKZE2.js.map} +0 -0
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-EJLAYNAE.js";import"../chunk-SRAX5OIU.js";export{f as alerts,e as buttons,l as canvasError,s as clearCanvasDialog,C as colorPicker,A as colors,I as commandPalette,v as confirmDialog,J as default,i as element,b as elementLink,x as encrypted,p as errorDialog,m as errorSplash,g as errors,q as exportDialog,G as fontList,j as headings,r as helpDialog,k as hints,w as imageExportDialog,a as labels,c as library,E as mermaid,D as overwriteConfirm,t as publishDialog,u as publishSuccessDialog,F as quickSearch,o as roomDialog,d as search,n as shareDialog,y as stats,z as toast,h as toolBar,H as userList,B as welcomeScreen};
1
+ import{A,B,C,D,E,F,G,H,I,J,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-KZXLT4YB.js";import"../chunk-SRAX5OIU.js";export{f as alerts,e as buttons,l as canvasError,s as clearCanvasDialog,C as colorPicker,A as colors,I as commandPalette,v as confirmDialog,J as default,i as element,b as elementLink,x as encrypted,p as errorDialog,m as errorSplash,g as errors,q as exportDialog,G as fontList,j as headings,r as helpDialog,k as hints,w as imageExportDialog,a as labels,c as library,E as mermaid,D as overwriteConfirm,t as publishDialog,u as publishSuccessDialog,F as quickSearch,o as roomDialog,d as search,n as shareDialog,y as stats,z as toast,h as toolBar,H as userList,B as welcomeScreen};
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-LS7FJGPW.js";import"./chunk-5JAQX5EH.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
1
+ import{a,b,c,d}from"./chunk-LS7FJGPW.js";import"./chunk-4Z2WWUCC.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
@@ -1 +1 @@
1
- import{a as r,c as t}from"./chunk-LS7FJGPW.js";import"./chunk-5JAQX5EH.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
1
+ import{a as r,c as t}from"./chunk-LS7FJGPW.js";import"./chunk-4Z2WWUCC.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
@@ -111,10 +111,19 @@ export declare const FONT_FAMILY: {
111
111
  "Liberation Sans": number;
112
112
  Assistant: number;
113
113
  };
114
+ export declare const SANS_SERIF_GENERIC_FONT = "sans-serif";
115
+ export declare const MONOSPACE_GENERIC_FONT = "monospace";
116
+ export declare const FONT_FAMILY_GENERIC_FALLBACKS: {
117
+ "sans-serif": number;
118
+ monospace: number;
119
+ };
114
120
  export declare const FONT_FAMILY_FALLBACKS: {
115
- Xiaolai: number;
116
121
  "Segoe UI Emoji": number;
122
+ "sans-serif": number;
123
+ monospace: number;
124
+ Xiaolai: number;
117
125
  };
126
+ export declare function getGenericFontFamilyFallback(fontFamily: number): keyof typeof FONT_FAMILY_GENERIC_FALLBACKS;
118
127
  export declare const getFontFamilyFallbacks: (fontFamily: number) => Array<keyof typeof FONT_FAMILY_FALLBACKS>;
119
128
  export declare const THEME: {
120
129
  readonly LIGHT: "light";
@@ -326,3 +335,9 @@ export declare enum UserIdleState {
326
335
  AWAY = "away",
327
336
  IDLE = "idle"
328
337
  }
338
+ /**
339
+ * distance at which we merge points instead of adding a new merge-point
340
+ * when converting a line to a polygon (merge currently means overlaping
341
+ * the start and end points)
342
+ */
343
+ export declare const LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
@@ -5,5 +5,5 @@ export declare const getSizeFromPoints: (points: readonly (GlobalPoint | LocalPo
5
5
  height: number;
6
6
  };
7
7
  /** @arg dimension, 0 for rescaling only x, 1 for y */
8
- export declare const rescalePoints: <Point extends GlobalPoint | LocalPoint>(dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
8
+ export declare const rescalePoints: <Point extends LocalPoint | GlobalPoint>(dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
9
9
  export declare const getGridPoint: (x: number, y: number, gridSize: NullableGridSize) => [number, number];
@@ -1,5 +1,4 @@
1
- import { type GlobalPoint } from "@excalidraw/math";
2
- import type { ExcalidrawBindableElement, FontFamilyValues, FontString, ExcalidrawElement } from "@excalidraw/element/types";
1
+ import type { ExcalidrawBindableElement, FontFamilyValues, FontString } from "@excalidraw/element/types";
3
2
  import type { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "@excalidraw/excalidraw/types";
4
3
  import type { MaybePromise } from "./utility-types";
5
4
  import type { EVENT } from "./constants";
@@ -261,7 +260,6 @@ export declare const safelyParseJSON: (json: string) => Record<string, any> | nu
261
260
  */
262
261
  export declare const escapeDoubleQuotes: (str: string) => string;
263
262
  export declare const castArray: <T>(value: T | T[]) => T[];
264
- export declare const elementCenterPoint: (element: ExcalidrawElement, xOffset?: number, yOffset?: number) => GlobalPoint;
265
263
  /** hack for Array.isArray type guard not working with readonly value[] */
266
264
  export declare const isReadonlyArray: (value?: any) => value is readonly any[];
267
265
  export declare const sizeOf: (value: readonly unknown[] | Readonly<Map<string, unknown>> | Readonly<Record<string, unknown>> | ReadonlySet<unknown>) => number;
@@ -16,7 +16,6 @@ export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEv
16
16
  export declare const isBindingEnabled: (appState: AppState) => boolean;
17
17
  export declare const FIXED_BINDING_DISTANCE = 5;
18
18
  export declare const BINDING_HIGHLIGHT_THICKNESS = 10;
19
- export declare const BINDING_HIGHLIGHT_OFFSET = 4;
20
19
  export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", scene: Scene) => void;
21
20
  export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], isBindingEnabled: boolean, draggingPoints: readonly number[] | null, scene: Scene, zoom?: AppState["zoom"]) => void;
22
21
  export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => SuggestedBinding[];
@@ -46,11 +45,11 @@ export declare const updateBindings: (latestElement: ExcalidrawElement, scene: S
46
45
  };
47
46
  zoom?: AppState["zoom"];
48
47
  }) => void;
49
- export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, zoom?: AppState["zoom"]) => Heading;
50
- export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => GlobalPoint;
51
- export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: GlobalPoint) => GlobalPoint;
52
- export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPoint, tolerance?: number) => GlobalPoint;
53
- export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => {
48
+ export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, elementsMap: ElementsMap, zoom?: AppState["zoom"]) => Heading;
49
+ export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => GlobalPoint;
50
+ export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
51
+ export declare const snapToMid: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number) => GlobalPoint;
52
+ export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
54
53
  fixedPoint: FixedPoint;
55
54
  };
56
55
  export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
@@ -101,7 +100,7 @@ export declare class BindableElement {
101
100
  */
102
101
  static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
103
102
  }
104
- export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement) => GlobalPoint;
103
+ export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement, elementsMap: ElementsMap) => GlobalPoint;
105
104
  export declare const getGlobalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => [GlobalPoint, GlobalPoint];
106
105
  export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => LocalPoint[];
107
106
  export declare const normalizeFixedPoint: <T extends FixedPoint | null>(fixedPoint: T) => T extends null ? null : FixedPoint;
@@ -1,4 +1,4 @@
1
- import type { Degrees, GlobalPoint, LineSegment } from "@excalidraw/math";
1
+ import type { Degrees, GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
2
2
  import type { AppState } from "@excalidraw/excalidraw/types";
3
3
  import type { Drawable, Op } from "roughjs/bin/core";
4
4
  import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, NonDeleted } from "./types";
@@ -26,7 +26,8 @@ export type SceneBounds = readonly [
26
26
  ];
27
27
  export declare class ElementBounds {
28
28
  private static boundsCache;
29
- static getBounds(element: ExcalidrawElement, elementsMap: ElementsMap): Bounds;
29
+ private static nonRotatedBoundsCache;
30
+ static getBounds(element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean): Bounds;
30
31
  private static calculateBounds;
31
32
  }
32
33
  export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
@@ -50,7 +51,7 @@ export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
50
51
  /** @returns number in degrees */
51
52
  export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
52
53
  export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
53
- export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap) => Bounds;
54
+ export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
54
55
  export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
55
56
  export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
56
57
  x: number;
@@ -78,4 +79,9 @@ export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | read
78
79
  */
79
80
  export declare const getVisibleSceneBounds: ({ scrollX, scrollY, width, height, zoom, }: AppState) => SceneBounds;
80
81
  export declare const getCenterForBounds: (bounds: Bounds) => GlobalPoint;
81
- export declare const doBoundsIntersect: (bounds1: Bounds | null, bounds2: Bounds | null) => boolean;
82
+ /**
83
+ * Get the axis-aligned bounding box for a given element
84
+ */
85
+ export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
86
+ export declare const pointInsideBounds: <P extends LocalPoint | GlobalPoint>(p: P, bounds: Bounds) => boolean;
87
+ export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
@@ -1,20 +1,18 @@
1
- import { type GeometricShape } from "@excalidraw/utils/shape";
2
- import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
1
+ import type { GlobalPoint, LineSegment } from "@excalidraw/math";
3
2
  import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
4
3
  import type { ElementsMap, ExcalidrawElement } from "./types";
5
4
  export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
6
- export type HitTestArgs<Point extends GlobalPoint | LocalPoint> = {
7
- x: number;
8
- y: number;
5
+ export type HitTestArgs = {
6
+ point: GlobalPoint;
9
7
  element: ExcalidrawElement;
10
- shape: GeometricShape<Point>;
11
- threshold?: number;
8
+ threshold: number;
9
+ elementsMap: ElementsMap;
12
10
  frameNameBound?: FrameNameBounds | null;
13
11
  };
14
- export declare const hitElementItself: <Point extends GlobalPoint | LocalPoint>({ x, y, element, shape, threshold, frameNameBound, }: HitTestArgs<Point>) => boolean;
15
- export declare const hitElementBoundingBox: (x: number, y: number, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
16
- export declare const hitElementBoundingBoxOnly: <Point extends GlobalPoint | LocalPoint>(hitArgs: HitTestArgs<Point>, elementsMap: ElementsMap) => boolean;
17
- export declare const hitElementBoundText: <Point extends GlobalPoint | LocalPoint>(x: number, y: number, textShape: GeometricShape<Point> | null) => boolean;
12
+ export declare const hitElementItself: ({ point, element, threshold, elementsMap, frameNameBound, }: HitTestArgs) => boolean;
13
+ export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
14
+ export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
15
+ export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
18
16
  /**
19
17
  * Intersect a line with an element for binding test
20
18
  *
@@ -23,4 +21,12 @@ export declare const hitElementBoundText: <Point extends GlobalPoint | LocalPoin
23
21
  * @param offset
24
22
  * @returns
25
23
  */
26
- export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, line: LineSegment<GlobalPoint>, offset?: number) => GlobalPoint[];
24
+ export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, elementsMap: ElementsMap, line: LineSegment<GlobalPoint>, offset?: number, onlyFirst?: boolean) => GlobalPoint[];
25
+ /**
26
+ * Check if the given point is considered inside the element's border
27
+ *
28
+ * @param point
29
+ * @param element
30
+ * @returns
31
+ */
32
+ export declare const isPointInElement: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { TransformHandleType } from "./transformHandles";
2
2
  import type { ElementsMap, ExcalidrawImageElement, ImageCrop } from "./types";
3
3
  export declare const MINIMAL_CROP_SIZE = 10;
4
- export declare const cropElement: (element: ExcalidrawImageElement, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
4
+ export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
5
5
  x: number;
6
6
  y: number;
7
7
  width: number;
@@ -1,7 +1,7 @@
1
1
  import type { ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "@excalidraw/element/types";
2
2
  import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
4
- import type { ElementUpdate } from "./mutateElement";
4
+ import { StoreSnapshot } from "./store";
5
5
  /**
6
6
  * Represents the difference between two objects of the same type.
7
7
  *
@@ -15,7 +15,7 @@ export declare class Delta<T> {
15
15
  readonly deleted: Partial<T>;
16
16
  readonly inserted: Partial<T>;
17
17
  private constructor();
18
- static create<T>(deleted: Partial<T>, inserted: Partial<T>, modifier?: (delta: Partial<T>) => Partial<T>, modifierOptions?: "deleted" | "inserted"): Delta<T>;
18
+ static create<T>(deleted: Partial<T>, inserted: Partial<T>, modifier?: (delta: Partial<T>, partialType: "deleted" | "inserted") => Partial<T>, modifierOptions?: "deleted" | "inserted" | "both"): Delta<T>;
19
19
  /**
20
20
  * Calculates the delta between two objects.
21
21
  *
@@ -55,6 +55,14 @@ export declare class Delta<T> {
55
55
  * Compares if object2 contains any different value compared to the object1.
56
56
  */
57
57
  static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
58
+ /**
59
+ * Compares if shared properties of object1 and object2 contain any different value (aka inner join).
60
+ */
61
+ static isInnerDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
62
+ /**
63
+ * Compares if any properties of object1 and object2 contain any different value (aka full join).
64
+ */
65
+ static isDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
58
66
  /**
59
67
  * Returns sorted object1 keys that have distinct values.
60
68
  */
@@ -63,6 +71,14 @@ export declare class Delta<T> {
63
71
  * Returns sorted object2 keys that have distinct values.
64
72
  */
65
73
  static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
74
+ /**
75
+ * Returns sorted keys of shared object1 and object2 properties that have distinct values (aka inner join).
76
+ */
77
+ static getInnerDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
78
+ /**
79
+ * Returns sorted keys that have distinct values between object1 and object2 (aka full join).
80
+ */
81
+ static getDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
66
82
  /**
67
83
  * Iterator comparing values of object properties based on the passed joining strategy.
68
84
  *
@@ -118,7 +134,10 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
118
134
  private static postProcess;
119
135
  private static orderAppStateKeys;
120
136
  }
121
- type ElementPartial<T extends ExcalidrawElement = ExcalidrawElement> = Omit<ElementUpdate<Ordered<T>>, "seed">;
137
+ type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
138
+ export type ApplyToOptions = {
139
+ excludedProperties: Set<keyof ElementPartial>;
140
+ };
122
141
  /**
123
142
  * Elements change is a low level primitive to capture a change between two sets of elements.
124
143
  * It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
@@ -135,6 +154,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
135
154
  private static satisfiesAddition;
136
155
  private static satisfiesRemoval;
137
156
  private static satisfiesUpdate;
157
+ private static satisfiesCommmonInvariants;
138
158
  private static validate;
139
159
  /**
140
160
  * Calculates the `Delta`s between the previous and next set of elements.
@@ -151,12 +171,12 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
151
171
  /**
152
172
  * Update delta/s based on the existing elements.
153
173
  *
154
- * @param elements current elements
174
+ * @param nextElements current elements
155
175
  * @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
156
176
  * @returns new instance with modified delta/s
157
177
  */
158
- applyLatestChanges(elements: SceneElementsMap, modifierOptions: "deleted" | "inserted"): ElementsDelta;
159
- applyTo(elements: SceneElementsMap, elementsSnapshot: Map<string, OrderedExcalidrawElement>): [SceneElementsMap, boolean];
178
+ applyLatestChanges(prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): ElementsDelta;
179
+ applyTo(elements: SceneElementsMap, snapshot?: StoreSnapshot["elements"], options?: ApplyToOptions): [SceneElementsMap, boolean];
160
180
  private static createApplier;
161
181
  private static createGetter;
162
182
  private static applyDelta;
@@ -1,3 +1,3 @@
1
1
  import type { GlobalPoint } from "@excalidraw/math";
2
- import type { ExcalidrawBindableElement } from "./types";
3
- export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, p: GlobalPoint) => number;
2
+ import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export declare const distanceToElement: (element: ExcalidrawElement, elementsMap: ElementsMap, p: GlobalPoint) => number;
@@ -14,4 +14,4 @@ export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArr
14
14
  }, options?: {
15
15
  isDragging?: boolean;
16
16
  }) => ElementUpdate<ExcalidrawElbowArrowElement>;
17
- export declare const validateElbowPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], tolerance?: number) => boolean;
17
+ export declare const validateElbowPoints: <P extends LocalPoint | GlobalPoint>(points: readonly P[], tolerance?: number) => boolean;
@@ -1,4 +1,4 @@
1
- import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement } from "./types";
1
+ import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  export declare class InvalidFractionalIndexError extends Error {
3
3
  code: "ELEMENT_HAS_INVALID_INDEX";
4
4
  }
@@ -44,8 +44,14 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
44
44
  */
45
45
  export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: ElementsMap) => OrderedExcalidrawElement[];
46
46
  /**
47
- * Synchronizes all invalid fractional indices with the array order by mutating passed elements.
47
+ * Synchronizes all invalid fractional indices within the array order by mutating elements in the passed array.
48
48
  *
49
49
  * WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
50
50
  */
51
51
  export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
52
+ /**
53
+ * Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
54
+ *
55
+ * WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
56
+ */
57
+ export declare const syncInvalidIndicesImmutable: (elements: readonly ExcalidrawElement[]) => SceneElementsMap | undefined;
@@ -6,8 +6,8 @@ export declare const HEADING_LEFT: Heading;
6
6
  export declare const HEADING_UP: Heading;
7
7
  export type Heading = [1, 0] | [0, 1] | [-1, 0] | [0, -1];
8
8
  export declare const vectorToHeading: (vec: Vector) => Heading;
9
- export declare const headingForPoint: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => Heading;
10
- export declare const headingForPointIsHorizontal: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => boolean;
9
+ export declare const headingForPoint: <P extends LocalPoint | GlobalPoint>(p: P, o: P) => Heading;
10
+ export declare const headingForPointIsHorizontal: <P extends LocalPoint | GlobalPoint>(p: P, o: P) => boolean;
11
11
  export declare const compareHeading: (a: Heading, b: Heading) => boolean;
12
12
  export declare const headingIsHorizontal: (a: Heading) => boolean;
13
13
  export declare const headingIsVertical: (a: Heading) => boolean;
@@ -43,9 +43,7 @@ export * from "./resizeElements";
43
43
  export * from "./resizeTest";
44
44
  export * from "./Scene";
45
45
  export * from "./selection";
46
- export * from "./Shape";
47
- export * from "./ShapeCache";
48
- export * from "./shapes";
46
+ export * from "./shape";
49
47
  export * from "./showSelectedShapeActions";
50
48
  export * from "./sizeHelpers";
51
49
  export * from "./sortElements";
@@ -1,15 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
3
- import type { Store } from "@excalidraw/element";
3
+ import { type Store } from "@excalidraw/element";
4
4
  import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
5
5
  import type { Scene } from "./Scene";
6
6
  import type { Bounds } from "./bounds";
7
7
  import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
8
- declare const editorMidPointsCache: {
9
- version: number | null;
10
- points: (GlobalPoint | null)[];
11
- zoom: number | null;
12
- };
13
8
  export declare class LinearElementEditor {
14
9
  readonly elementId: ExcalidrawElement["id"] & {
15
10
  _brand: "excalidrawLinearElementId";
@@ -43,6 +38,7 @@ export declare class LinearElementEditor {
43
38
  readonly hoverPointIndex: number;
44
39
  readonly segmentMidPointHoveredCoords: GlobalPoint | null;
45
40
  readonly elbowed: boolean;
41
+ readonly customLineAngle: number | null;
46
42
  constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap);
47
43
  static POINT_HANDLE_SIZE: number;
48
44
  /**
@@ -59,14 +55,13 @@ export declare class LinearElementEditor {
59
55
  y: number;
60
56
  }[]) => void, linearElementEditor: LinearElementEditor, scene: Scene): LinearElementEditor | null;
61
57
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
62
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
63
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
58
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
64
59
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
65
60
  x: number;
66
61
  y: number;
67
62
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
68
63
  static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
69
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
64
+ static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number): GlobalPoint;
70
65
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
71
66
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
72
67
  x: number;
@@ -89,20 +84,19 @@ export declare class LinearElementEditor {
89
84
  static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
90
85
  /**
91
86
  * Normalizes line points so that the start point is at [0,0]. This is
92
- * expected in various parts of the codebase. Also returns new x/y to account
93
- * for the potential normalization.
87
+ * expected in various parts of the codebase.
88
+ *
89
+ * Also returns normalized x and y coords to account for the normalization
90
+ * of the points.
94
91
  */
95
- static getNormalizedPoints(element: ExcalidrawLinearElement): {
92
+ static getNormalizeElementPointsAndCoords(element: ExcalidrawLinearElement): {
96
93
  points: LocalPoint[];
97
94
  x: number;
98
95
  y: number;
99
96
  };
100
- static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap): void;
101
97
  static duplicateSelectedPoints(appState: AppState, scene: Scene): AppState;
102
- static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointIndices: readonly number[]): void;
103
- static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, targetPoints: {
104
- point: LocalPoint;
105
- }[]): void;
98
+ static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
99
+ static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
106
100
  static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
107
101
  startBinding?: PointBinding | null;
108
102
  endBinding?: PointBinding | null;
@@ -123,4 +117,3 @@ export declare class LinearElementEditor {
123
117
  static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
124
118
  static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
125
119
  }
126
- export {};
@@ -1,6 +1,6 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
- export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
3
+ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
4
4
  /**
5
5
  * This function tracks updates of text elements for the purposes for collaboration.
6
6
  * The version is used to compare updates when more than one user is working in
@@ -1,5 +1,5 @@
1
1
  import type { MarkOptional } from "@excalidraw/common/utility-types";
2
- import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement } from "./types";
2
+ import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement } from "./types";
3
3
  export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
4
4
  export declare const newElement: (opts: {
5
5
  type: ExcalidrawGenericElement["type"];
@@ -43,6 +43,7 @@ export declare const newFreeDrawElement: (opts: {
43
43
  export declare const newLinearElement: (opts: {
44
44
  type: ExcalidrawLinearElement["type"];
45
45
  points?: ExcalidrawLinearElement["points"];
46
+ polygon?: ExcalidrawLineElement["polygon"];
46
47
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
47
48
  export declare const newArrowElement: <T extends boolean>(opts: {
48
49
  type: ExcalidrawArrowElement["type"];
@@ -13,6 +13,7 @@ export declare const rescalePointsInElement: (element: NonDeletedExcalidrawEleme
13
13
  export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTextElement>, elementsMap: ElementsMap, nextWidth: number) => {
14
14
  size: number;
15
15
  } | null;
16
+ export declare const resizeSingleTextElement: (origElement: NonDeleted<ExcalidrawTextElement>, element: NonDeleted<ExcalidrawTextElement>, scene: Scene, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, nextWidth: number, nextHeight: number) => void;
16
17
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
17
18
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
18
19
  export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
@@ -3,12 +3,12 @@ import type { AppState, Device, Zoom } from "@excalidraw/excalidraw/types";
3
3
  import type { Bounds } from "./bounds";
4
4
  import type { MaybeTransformHandleType } from "./transformHandles";
5
5
  import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
6
- export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
6
+ export declare const resizeTest: <Point extends LocalPoint | GlobalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
7
7
  export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
8
8
  element: NonDeletedExcalidrawElement;
9
9
  transformHandleType: MaybeTransformHandleType;
10
10
  } | null;
11
- export declare const getTransformHandleTypeFromCoords: <Point extends GlobalPoint | LocalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
11
+ export declare const getTransformHandleTypeFromCoords: <Point extends LocalPoint | GlobalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
12
12
  export declare const getCursorForResizingElement: (resizingElement: {
13
13
  element?: ExcalidrawElement;
14
14
  transformHandleType: MaybeTransformHandleType;
@@ -1,7 +1,10 @@
1
+ import { type GeometricShape } from "@excalidraw/utils/shape";
2
+ import { type LocalPoint } from "@excalidraw/math";
3
+ import type { GlobalPoint } from "@excalidraw/math";
1
4
  import type { AppState, EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
2
5
  import type { ElementShape, ElementShapes } from "@excalidraw/excalidraw/scene/types";
3
- import type { ExcalidrawElement } from "./types";
4
- import type { Drawable } from "roughjs/bin/core";
6
+ import type { ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawFreeDrawElement, ElementsMap, ExcalidrawLineElement } from "./types";
7
+ import type { Drawable, Options } from "roughjs/bin/core";
5
8
  export declare class ShapeCache {
6
9
  private static rg;
7
10
  private static cache;
@@ -17,9 +20,23 @@ export declare class ShapeCache {
17
20
  * Generates & caches shape for element if not already cached, otherwise
18
21
  * returns cached shape.
19
22
  */
20
- static generateElementShape: <T extends import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawArrowElement | import("./types").ExcalidrawFreeDrawElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawEmbeddableElement>(element: T, renderConfig: {
23
+ static generateElementShape: <T extends import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawTextElement | ExcalidrawLinearElement | import("./types").ExcalidrawArrowElement | ExcalidrawFreeDrawElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawEmbeddableElement>(element: T, renderConfig: {
21
24
  isExporting: boolean;
22
25
  canvasBackgroundColor: AppState["viewBackgroundColor"];
23
26
  embedsValidationStatus: EmbedsValidationStatus;
24
27
  } | null) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
25
28
  }
29
+ export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
30
+ export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement) => {
31
+ op: string;
32
+ data: number[];
33
+ }[];
34
+ /**
35
+ * get the pure geometric shape of an excalidraw elementw
36
+ * which is then used for hit detection
37
+ */
38
+ export declare const getElementShape: <Point extends LocalPoint | GlobalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point>;
39
+ export declare const toggleLinePolygonState: (element: ExcalidrawLineElement, nextPolygonState: boolean) => {
40
+ polygon: ExcalidrawLineElement["polygon"];
41
+ points: ExcalidrawLineElement["points"];
42
+ } | null;
@@ -2,7 +2,7 @@ import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
2
2
  import { type GeometricShape } from "@excalidraw/utils/shape";
3
3
  import type { Zoom } from "@excalidraw/excalidraw/types";
4
4
  import { type Bounds } from "./bounds";
5
- import type { ExcalidrawElement, ElementsMap, NonDeleted, ExcalidrawLinearElement } from "./types";
5
+ import type { ExcalidrawElement, ElementsMap, NonDeleted, ExcalidrawLinearElement, NonDeletedSceneElementsMap } from "./types";
6
6
  export type ToolCategory = "manipulation" | "elements";
7
7
  export declare const SHAPES: readonly [{
8
8
  readonly icon: import("react/jsx-runtime").JSX.Element;
@@ -80,17 +80,17 @@ export declare const findShapeByKey: (key: string) => "text" | "line" | "arrow"
80
80
  * get the pure geometric shape of an excalidraw elementw
81
81
  * which is then used for hit detection
82
82
  */
83
- export declare const getElementShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point>;
84
- export declare const getBoundTextShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point> | null;
85
- export declare const getControlPointsForBezierCurve: <P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P) => P[] | null;
86
- export declare const getBezierXY: <P extends GlobalPoint | LocalPoint>(p0: P, p1: P, p2: P, p3: P, t: number) => P;
87
- export declare const getBezierCurveLength: <P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P) => number;
88
- export declare const mapIntervalToBezierT: <P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P, interval: number) => number;
83
+ export declare const getElementShape: <Point extends LocalPoint | GlobalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point>;
84
+ export declare const getBoundTextShape: <Point extends LocalPoint | GlobalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point> | null;
85
+ export declare const getControlPointsForBezierCurve: <P extends LocalPoint | GlobalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P) => P[] | null;
86
+ export declare const getBezierXY: <P extends LocalPoint | GlobalPoint>(p0: P, p1: P, p2: P, p3: P, t: number) => P;
87
+ export declare const getBezierCurveLength: <P extends LocalPoint | GlobalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P) => number;
88
+ export declare const mapIntervalToBezierT: <P extends LocalPoint | GlobalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P, interval: number) => number;
89
89
  /**
90
90
  * Get the axis-aligned bounding box for a given element
91
91
  */
92
- export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, offset?: [number, number, number, number]) => Bounds;
93
- export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
92
+ export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: NonDeletedSceneElementsMap, offset?: [number, number, number, number]) => Bounds;
93
+ export declare const pointInsideBounds: <P extends LocalPoint | GlobalPoint>(p: P, bounds: Bounds) => boolean;
94
94
  export declare const aabbsOverlapping: (a: Bounds, b: Bounds) => boolean;
95
95
  export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
96
96
  export declare const isPathALoop: (points: ExcalidrawLinearElement["points"], zoomValue?: Zoom["value"]) => boolean;
@@ -1,5 +1,6 @@
1
1
  import type { AppState, Offsets, Zoom } from "@excalidraw/excalidraw/types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export declare const INVISIBLY_SMALL_ELEMENT_SIZE = 0.1;
3
4
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
5
  export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
6
  zoom: Zoom;
@@ -22,7 +23,7 @@ export declare const getPerfectElementSize: (elementType: AppState["activeTool"]
22
23
  width: number;
23
24
  height: number;
24
25
  };
25
- export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number) => {
26
+ export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number, customAngle?: number) => {
26
27
  width: number;
27
28
  height: number;
28
29
  };