@excalidraw/excalidraw 0.18.0-rc.4 → 0.18.0-rc.5

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 (46) hide show
  1. package/README.md +1 -0
  2. package/dist/dev/{chunk-3O3BNMYV.js → chunk-UGZAZPWM.js} +1143 -848
  3. package/dist/dev/chunk-UGZAZPWM.js.map +7 -0
  4. package/dist/dev/data/{image-EN763OZS.js → image-NQXTDRIN.js} +2 -2
  5. package/dist/dev/index.js +6 -8
  6. package/dist/dev/index.js.map +2 -2
  7. package/dist/prod/chunk-44FFCT2W.js +34 -0
  8. package/dist/prod/data/{image-XQM6YLGO.js → image-WYICPQ4X.js} +1 -1
  9. package/dist/prod/index.js +2 -2
  10. package/dist/types/excalidraw/actions/actionCanvas.d.ts +5 -5
  11. package/dist/types/excalidraw/actions/actionExport.d.ts +7 -7
  12. package/dist/types/excalidraw/actions/actionFrame.d.ts +1 -1
  13. package/dist/types/excalidraw/actions/actionZindex.d.ts +2 -2
  14. package/dist/types/excalidraw/appState.d.ts +8 -8
  15. package/dist/types/excalidraw/clipboard.d.ts +4 -4
  16. package/dist/types/excalidraw/constants.d.ts +1 -0
  17. package/dist/types/excalidraw/data/blob.d.ts +1 -1
  18. package/dist/types/excalidraw/element/binding.d.ts +1 -2
  19. package/dist/types/excalidraw/element/collision.d.ts +10 -1
  20. package/dist/types/excalidraw/element/distance.d.ts +3 -0
  21. package/dist/types/excalidraw/element/newElement.d.ts +1 -1
  22. package/dist/types/excalidraw/element/transformHandles.d.ts +2 -2
  23. package/dist/types/excalidraw/element/utils.d.ts +21 -0
  24. package/dist/types/excalidraw/shapes.d.ts +1 -1
  25. package/dist/types/excalidraw/utils.d.ts +3 -3
  26. package/dist/types/excalidraw/visualdebug.d.ts +7 -8
  27. package/dist/types/excalidraw/zindex.d.ts +2 -2
  28. package/dist/types/math/curve.d.ts +22 -14
  29. package/dist/types/math/ellipse.d.ts +44 -0
  30. package/dist/types/math/index.d.ts +1 -1
  31. package/dist/types/math/line.d.ts +2 -30
  32. package/dist/types/math/point.d.ts +1 -29
  33. package/dist/types/math/rectangle.d.ts +3 -0
  34. package/dist/types/math/segment.d.ts +8 -1
  35. package/dist/types/math/types.d.ts +15 -6
  36. package/dist/types/math/vector.d.ts +0 -4
  37. package/package.json +1 -1
  38. package/dist/dev/chunk-3O3BNMYV.js.map +0 -7
  39. package/dist/prod/chunk-ELWWJGPE.js +0 -34
  40. package/dist/types/math/arc.d.ts +0 -6
  41. package/dist/types/math/ga/ga.d.ts +0 -63
  42. package/dist/types/math/ga/gadirections.d.ts +0 -8
  43. package/dist/types/math/ga/galines.d.ts +0 -22
  44. package/dist/types/math/ga/gapoints.d.ts +0 -7
  45. package/dist/types/math/ga/gatransforms.d.ts +0 -10
  46. /package/dist/dev/data/{image-EN763OZS.js.map → image-NQXTDRIN.js.map} +0 -0
@@ -52,6 +52,11 @@ export declare const actionClearCanvas: {
52
52
  lastActiveTool: import("../types").ActiveTool | null;
53
53
  locked: boolean;
54
54
  } & import("../types").ActiveTool;
55
+ viewModeEnabled: boolean;
56
+ zenModeEnabled: boolean;
57
+ objectsSnapModeEnabled: boolean;
58
+ name: string | null;
59
+ currentItemArrowType: "round" | "sharp" | "elbow";
55
60
  contextMenu: {
56
61
  items: import("../components/ContextMenu").ContextMenuItems;
57
62
  top: number;
@@ -98,13 +103,11 @@ export declare const actionClearCanvas: {
98
103
  currentItemEndArrowhead: import("../element/types").Arrowhead | null;
99
104
  currentHoveredFontFamily: number | null;
100
105
  currentItemRoundness: import("../element/types").StrokeRoundness;
101
- currentItemArrowType: "round" | "sharp" | "elbow";
102
106
  viewBackgroundColor: string;
103
107
  scrollX: number;
104
108
  scrollY: number;
105
109
  cursorButton: "up" | "down";
106
110
  scrolledOutside: boolean;
107
- name: string | null;
108
111
  isResizing: boolean;
109
112
  isRotating: boolean;
110
113
  zoom: Readonly<{
@@ -145,8 +148,6 @@ export declare const actionClearCanvas: {
145
148
  closable?: boolean | undefined;
146
149
  duration?: number | undefined;
147
150
  } | null;
148
- zenModeEnabled: boolean;
149
- viewModeEnabled: boolean;
150
151
  selectedGroupIds: {
151
152
  [groupId: string]: boolean;
152
153
  };
@@ -181,7 +182,6 @@ export declare const actionClearCanvas: {
181
182
  x: number;
182
183
  y: number;
183
184
  } | null;
184
- objectsSnapModeEnabled: boolean;
185
185
  userToFollow: import("../types").UserToFollow | null;
186
186
  followedBy: Set<import("../types").SocketId>;
187
187
  isCropping: boolean;
@@ -1125,6 +1125,13 @@ export declare const actionLoadScene: {
1125
1125
  perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: any, app: import("../types").AppClassProperties) => Promise<false | {
1126
1126
  elements: import("../element/types").OrderedExcalidrawElement[];
1127
1127
  appState: {
1128
+ viewModeEnabled: boolean;
1129
+ zenModeEnabled: boolean;
1130
+ gridModeEnabled: boolean;
1131
+ objectsSnapModeEnabled: boolean;
1132
+ theme: Theme;
1133
+ name: string | null;
1134
+ currentItemArrowType: "round" | "sharp" | "elbow";
1128
1135
  contextMenu: {
1129
1136
  items: import("../components/ContextMenu").ContextMenuItems;
1130
1137
  top: number;
@@ -1179,13 +1186,11 @@ export declare const actionLoadScene: {
1179
1186
  currentItemEndArrowhead: import("../element/types").Arrowhead | null;
1180
1187
  currentHoveredFontFamily: number | null;
1181
1188
  currentItemRoundness: import("../element/types").StrokeRoundness;
1182
- currentItemArrowType: "round" | "sharp" | "elbow";
1183
1189
  viewBackgroundColor: string;
1184
1190
  scrollX: number;
1185
1191
  scrollY: number;
1186
1192
  cursorButton: "up" | "down";
1187
1193
  scrolledOutside: boolean;
1188
- name: string | null;
1189
1194
  isResizing: boolean;
1190
1195
  isRotating: boolean;
1191
1196
  zoom: Readonly<{
@@ -1226,12 +1231,8 @@ export declare const actionLoadScene: {
1226
1231
  closable?: boolean | undefined;
1227
1232
  duration?: number | undefined;
1228
1233
  } | null;
1229
- zenModeEnabled: boolean;
1230
- theme: Theme;
1231
1234
  gridSize: number;
1232
1235
  gridStep: number;
1233
- gridModeEnabled: boolean;
1234
- viewModeEnabled: boolean;
1235
1236
  selectedGroupIds: {
1236
1237
  [groupId: string]: boolean;
1237
1238
  };
@@ -1277,7 +1278,6 @@ export declare const actionLoadScene: {
1277
1278
  x: number;
1278
1279
  y: number;
1279
1280
  } | null;
1280
- objectsSnapModeEnabled: boolean;
1281
1281
  userToFollow: import("../types").UserToFollow | null;
1282
1282
  followedBy: Set<import("../types").SocketId>;
1283
1283
  isCropping: boolean;
@@ -1082,7 +1082,7 @@ export declare const actionWrapSelectionInFrame: {
1082
1082
  }> & Readonly<{
1083
1083
  type: "image";
1084
1084
  fileId: import("../element/types").FileId | null;
1085
- status: "pending" | "saved" | "error";
1085
+ status: "error" | "pending" | "saved";
1086
1086
  scale: [number, number];
1087
1087
  crop: import("../element/types").ImageCrop | null;
1088
1088
  }> & {
@@ -46,7 +46,7 @@ export declare const actionSendToBack: {
46
46
  category: "element";
47
47
  };
48
48
  perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
49
- elements: import("../element/types").ExcalidrawElement[] | readonly import("../element/types").ExcalidrawElement[];
49
+ elements: readonly import("../element/types").ExcalidrawElement[] | import("../element/types").ExcalidrawElement[];
50
50
  appState: Readonly<import("../types").AppState>;
51
51
  storeAction: "capture";
52
52
  };
@@ -64,7 +64,7 @@ export declare const actionBringToFront: {
64
64
  category: "element";
65
65
  };
66
66
  perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
67
- elements: import("../element/types").ExcalidrawElement[] | readonly import("../element/types").ExcalidrawElement[];
67
+ elements: readonly import("../element/types").ExcalidrawElement[] | import("../element/types").ExcalidrawElement[];
68
68
  appState: Readonly<import("../types").AppState>;
69
69
  storeAction: "capture";
70
70
  };
@@ -1,6 +1,12 @@
1
1
  import type { AppState, NormalizedZoomValue } from "./types";
2
2
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
3
3
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
+ zenModeEnabled?: boolean | undefined;
5
+ gridModeEnabled?: boolean | undefined;
6
+ objectsSnapModeEnabled?: boolean | undefined;
7
+ theme?: import("./element/types").Theme | undefined;
8
+ name?: string | null | undefined;
9
+ currentItemArrowType?: "round" | "sharp" | "elbow" | undefined;
4
10
  showWelcomeScreen?: boolean | undefined;
5
11
  activeTool?: ({
6
12
  lastActiveTool: import("./types").ActiveTool | null;
@@ -25,13 +31,11 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
25
31
  currentItemStartArrowhead?: import("./element/types").Arrowhead | null | undefined;
26
32
  currentItemEndArrowhead?: import("./element/types").Arrowhead | null | undefined;
27
33
  currentItemRoundness?: import("./element/types").StrokeRoundness | undefined;
28
- currentItemArrowType?: "round" | "sharp" | "elbow" | undefined;
29
34
  viewBackgroundColor?: string | undefined;
30
35
  scrollX?: number | undefined;
31
36
  scrollY?: number | undefined;
32
37
  cursorButton?: "up" | "down" | undefined;
33
38
  scrolledOutside?: boolean | undefined;
34
- name?: string | null | undefined;
35
39
  zoom?: Readonly<{
36
40
  value: NormalizedZoomValue;
37
41
  }> | undefined;
@@ -49,11 +53,8 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
49
53
  [id: string]: true;
50
54
  } | undefined;
51
55
  shouldCacheIgnoreZoom?: boolean | undefined;
52
- zenModeEnabled?: boolean | undefined;
53
- theme?: import("./element/types").Theme | undefined;
54
56
  gridSize?: number | undefined;
55
57
  gridStep?: number | undefined;
56
- gridModeEnabled?: boolean | undefined;
57
58
  selectedGroupIds?: {
58
59
  [groupId: string]: boolean;
59
60
  } | undefined;
@@ -64,19 +65,18 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
64
65
  } | undefined;
65
66
  currentChartType?: import("./element/types").ChartType | undefined;
66
67
  selectedLinearElement?: import("./element/linearElementEditor").LinearElementEditor | null | undefined;
67
- objectsSnapModeEnabled?: boolean | undefined;
68
68
  };
69
69
  export declare const cleanAppStateForExport: (appState: Partial<AppState>) => {
70
+ gridModeEnabled?: boolean | undefined;
70
71
  viewBackgroundColor?: string | undefined;
71
72
  gridSize?: number | undefined;
72
73
  gridStep?: number | undefined;
73
- gridModeEnabled?: boolean | undefined;
74
74
  };
75
75
  export declare const clearAppStateForDatabase: (appState: Partial<AppState>) => {
76
+ gridModeEnabled?: boolean | undefined;
76
77
  viewBackgroundColor?: string | undefined;
77
78
  gridSize?: number | undefined;
78
79
  gridStep?: number | undefined;
79
- gridModeEnabled?: boolean | undefined;
80
80
  };
81
81
  export declare const isEraserActive: ({ activeTool, }: {
82
82
  activeTool: AppState["activeTool"];
@@ -21,8 +21,6 @@ export declare const probablySupportsClipboardWriteText: boolean;
21
21
  export declare const probablySupportsClipboardBlob: boolean;
22
22
  export declare const createPasteEvent: ({ types, files, }: {
23
23
  types?: {
24
- "text/plain"?: string | File | undefined;
25
- "text/html"?: string | File | undefined;
26
24
  "image/svg+xml"?: string | File | undefined;
27
25
  "image/png"?: string | File | undefined;
28
26
  "image/jpeg"?: string | File | undefined;
@@ -32,6 +30,8 @@ export declare const createPasteEvent: ({ types, files, }: {
32
30
  "image/x-icon"?: string | File | undefined;
33
31
  "image/avif"?: string | File | undefined;
34
32
  "image/jfif"?: string | File | undefined;
33
+ "text/plain"?: string | File | undefined;
34
+ "text/html"?: string | File | undefined;
35
35
  } | undefined;
36
36
  files?: File[] | undefined;
37
37
  }) => ClipboardEvent;
@@ -45,8 +45,6 @@ export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawEl
45
45
  * Will prompt user for permission if not granted.
46
46
  */
47
47
  export declare const readSystemClipboard: () => Promise<{
48
- "text/plain"?: string | File | undefined;
49
- "text/html"?: string | File | undefined;
50
48
  "image/svg+xml"?: string | File | undefined;
51
49
  "image/png"?: string | File | undefined;
52
50
  "image/jpeg"?: string | File | undefined;
@@ -56,6 +54,8 @@ export declare const readSystemClipboard: () => Promise<{
56
54
  "image/x-icon"?: string | File | undefined;
57
55
  "image/avif"?: string | File | undefined;
58
56
  "image/jfif"?: string | File | undefined;
57
+ "text/plain"?: string | File | undefined;
58
+ "text/html"?: string | File | undefined;
59
59
  }>;
60
60
  /**
61
61
  * Attempts to parse clipboard event.
@@ -143,6 +143,7 @@ export declare const DEFAULT_VERTICAL_ALIGN = "top";
143
143
  export declare const DEFAULT_VERSION = "{version}";
144
144
  export declare const DEFAULT_TRANSFORM_HANDLE_SPACING = 2;
145
145
  export declare const SIDE_RESIZING_THRESHOLD: number;
146
+ export declare const EPSILON = 0.00001;
146
147
  export declare const DEFAULT_COLLISION_THRESHOLD: number;
147
148
  export declare const COLOR_WHITE = "#ffffff";
148
149
  export declare const COLOR_CHARCOAL_BLACK = "#1e1e1e";
@@ -6,7 +6,7 @@ import type { FileSystemHandle } from "./filesystem";
6
6
  import type { ImportedLibraryData } from "./types";
7
7
  export declare const getMimeType: (blob: Blob | string) => string;
8
8
  export declare const getFileHandleType: (handle: FileSystemHandle | null) => string | null;
9
- export declare const isImageFileHandleType: (type: string | null) => type is "png" | "svg";
9
+ export declare const isImageFileHandleType: (type: string | null) => type is "svg" | "png";
10
10
  export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
11
11
  export declare const isSupportedImageFileType: (type: string | null | undefined) => boolean;
12
12
  export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
@@ -39,7 +39,7 @@ export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawE
39
39
  changedElements?: Map<string, OrderedExcalidrawElement>;
40
40
  }) => void;
41
41
  export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, elementsMap: ElementsMap, origPoint: GlobalPoint, zoom?: AppState["zoom"]) => Heading;
42
- export declare const bindPointToSnapToElementOutline: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined, elementsMap: ElementsMap) => GlobalPoint;
42
+ export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement | undefined, startOrEnd: "start" | "end") => GlobalPoint;
43
43
  export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: GlobalPoint) => GlobalPoint;
44
44
  export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPoint, tolerance?: number) => GlobalPoint;
45
45
  export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
@@ -52,7 +52,6 @@ export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableE
52
52
  y: number;
53
53
  }, elementsMap: NonDeletedSceneElementsMap, zoom?: AppState["zoom"], fullShape?: boolean) => boolean;
54
54
  export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number, zoom?: AppState["zoom"]) => number;
55
- export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, point: GlobalPoint, elementsMap: ElementsMap) => number;
56
55
  export declare const bindingProperties: Set<BindableProp | BindingProp>;
57
56
  export type BindableProp = "boundElements";
58
57
  export type BindingProp = "frameId" | "containerId" | "startBinding" | "endBinding";
@@ -1,7 +1,7 @@
1
1
  import type { ElementsMap, ExcalidrawElement } from "./types";
2
2
  import type { FrameNameBounds } from "../types";
3
3
  import type { GeometricShape } from "@excalidraw/utils/geometry/shape";
4
- import type { GlobalPoint, LocalPoint } from "@excalidraw/math";
4
+ import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
5
5
  export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
6
6
  export type HitTestArgs<Point extends GlobalPoint | LocalPoint> = {
7
7
  x: number;
@@ -15,3 +15,12 @@ export declare const hitElementItself: <Point extends GlobalPoint | LocalPoint>(
15
15
  export declare const hitElementBoundingBox: (x: number, y: number, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
16
16
  export declare const hitElementBoundingBoxOnly: <Point extends GlobalPoint | LocalPoint>(hitArgs: HitTestArgs<Point>, elementsMap: ElementsMap) => boolean;
17
17
  export declare const hitElementBoundText: <Point extends GlobalPoint | LocalPoint>(x: number, y: number, textShape: GeometricShape<Point> | null) => boolean;
18
+ /**
19
+ * Intersect a line with an element for binding test
20
+ *
21
+ * @param element
22
+ * @param line
23
+ * @param offset
24
+ * @returns
25
+ */
26
+ export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, line: LineSegment<GlobalPoint>, offset?: number) => GlobalPoint[];
@@ -0,0 +1,3 @@
1
+ import type { GlobalPoint } from "@excalidraw/math";
2
+ import type { ExcalidrawBindableElement } from "./types";
3
+ export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, p: GlobalPoint) => number;
@@ -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?: FixedSegment[] | null | undefined;
55
- } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "angle" | "link" | "width" | "height" | "backgroundColor" | "strokeColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "angle" | "link" | "width" | "height" | "backgroundColor" | "strokeColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "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"];
@@ -31,8 +31,8 @@ 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;
35
34
  s?: boolean | undefined;
35
+ e?: boolean | undefined;
36
36
  w?: boolean | undefined;
37
37
  n?: boolean | undefined;
38
38
  nw?: boolean | undefined;
@@ -42,8 +42,8 @@ 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;
46
45
  s?: boolean | undefined;
46
+ e?: boolean | undefined;
47
47
  w?: boolean | undefined;
48
48
  n?: boolean | undefined;
49
49
  nw?: boolean | undefined;
@@ -0,0 +1,21 @@
1
+ import type { Curve, LineSegment } from "@excalidraw/math";
2
+ import { type GlobalPoint } from "@excalidraw/math";
3
+ import type { ExcalidrawDiamondElement, ExcalidrawRectanguloidElement } from "./types";
4
+ /**
5
+ * Get the building components of a rectanguloid element in the form of
6
+ * line segments and curves.
7
+ *
8
+ * @param element Target rectanguloid element
9
+ * @param offset Optional offset to expand the rectanguloid shape
10
+ * @returns Tuple of line segments (0) and curves (1)
11
+ */
12
+ export declare function deconstructRectanguloidElement(element: ExcalidrawRectanguloidElement, offset?: number): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
13
+ /**
14
+ * Get the building components of a diamond element in the form of
15
+ * line segments and curves as a tuple, in this order.
16
+ *
17
+ * @param element The element to deconstruct
18
+ * @param offset An optional offset
19
+ * @returns Tuple of line segments (0) and curves (1)
20
+ */
21
+ export declare function deconstructDiamondElement(element: ExcalidrawDiamondElement, offset?: number): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
@@ -64,7 +64,7 @@ export declare const SHAPES: readonly [{
64
64
  readonly numericKey: "0";
65
65
  readonly fillable: false;
66
66
  }];
67
- export declare const findShapeByKey: (key: string) => "line" | "text" | "arrow" | "diamond" | "selection" | "rectangle" | "ellipse" | "freedraw" | "image" | "eraser" | null;
67
+ export declare const findShapeByKey: (key: string) => "text" | "line" | "arrow" | "image" | "selection" | "rectangle" | "diamond" | "ellipse" | "freedraw" | "eraser" | null;
68
68
  /**
69
69
  * get the pure geometric shape of an excalidraw element
70
70
  * which is then used for hit detection
@@ -6,9 +6,9 @@ export declare const setDateTimeForTests: (dateTime: string) => void;
6
6
  export declare const getDateTime: () => string;
7
7
  export declare const capitalizeString: (str: string) => string;
8
8
  export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
9
- export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLBRElement | HTMLDivElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
9
+ export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
10
10
  export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
11
- export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLBRElement | HTMLDivElement | HTMLInputElement | HTMLTextAreaElement;
11
+ export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
12
12
  export declare const getFontFamilyString: ({ fontFamily, }: {
13
13
  fontFamily: FontFamilyValues;
14
14
  }) => string;
@@ -184,7 +184,7 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
184
184
  }>;
185
185
  export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
186
186
  export declare const isPrimitive: (val: any) => boolean;
187
- export declare const getFrame: () => "iframe" | "top";
187
+ export declare const getFrame: () => "top" | "iframe";
188
188
  export declare const isRunningInIframe: () => boolean;
189
189
  export declare const isPromiseLike: (value: any) => value is Promise<any>;
190
190
  export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
@@ -1,33 +1,32 @@
1
+ import type { Curve } from "@excalidraw/math";
1
2
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
2
3
  import type { LineSegment } from "@excalidraw/utils";
3
- import type { BoundingBox, Bounds } from "./element/bounds";
4
+ import type { Bounds } from "./element/bounds";
4
5
  declare global {
5
6
  interface Window {
6
7
  visualDebug?: {
7
8
  data: DebugElement[][];
8
9
  currentFrame?: number;
9
10
  };
10
- debugDrawPoint: typeof debugDrawPoint;
11
- debugDrawLine: typeof debugDrawLine;
12
11
  }
13
12
  }
14
13
  export type DebugElement = {
15
14
  color: string;
16
- data: LineSegment<GlobalPoint>;
15
+ data: LineSegment<GlobalPoint> | Curve<GlobalPoint>;
17
16
  permanent: boolean;
18
17
  };
19
- export declare const debugDrawLine: (segment: LineSegment<GlobalPoint> | LineSegment<GlobalPoint>[], opts?: {
18
+ export declare const debugDrawCubicBezier: (c: Curve<GlobalPoint>, opts?: {
20
19
  color?: string;
21
20
  permanent?: boolean;
22
21
  }) => void;
23
- export declare const debugDrawPoint: (p: GlobalPoint, opts?: {
22
+ export declare const debugDrawLine: (segment: LineSegment<GlobalPoint> | LineSegment<GlobalPoint>[], opts?: {
24
23
  color?: string;
25
24
  permanent?: boolean;
26
- fuzzy?: boolean;
27
25
  }) => void;
28
- export declare const debugDrawBoundingBox: (box: BoundingBox | BoundingBox[], opts?: {
26
+ export declare const debugDrawPoint: (p: GlobalPoint, opts?: {
29
27
  color?: string;
30
28
  permanent?: boolean;
29
+ fuzzy?: boolean;
31
30
  }) => void;
32
31
  export declare const debugDrawBounds: (box: Bounds | Bounds[], opts?: {
33
32
  color?: string;
@@ -2,5 +2,5 @@ import type { ExcalidrawElement } from "./element/types";
2
2
  import type { AppState } from "./types";
3
3
  export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
4
4
  export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
5
- export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[] | readonly ExcalidrawElement[];
6
- export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[] | readonly ExcalidrawElement[];
5
+ export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
6
+ export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
@@ -1,4 +1,4 @@
1
- import type { Curve, GlobalPoint, LocalPoint, Radians } from "./types";
1
+ import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
2
2
  /**
3
3
  *
4
4
  * @param a
@@ -8,25 +8,33 @@ import type { Curve, GlobalPoint, LocalPoint, Radians } from "./types";
8
8
  * @returns
9
9
  */
10
10
  export declare function curve<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, c: Point, d: Point): Curve<Point>;
11
- export declare const curveRotate: <Point extends GlobalPoint | LocalPoint>(curve: Curve<Point>, angle: Radians, origin: Point) => Point[];
12
11
  /**
13
- *
14
- * @param pointsIn
15
- * @param curveTightness
16
- * @returns
12
+ * Computes the intersection between a cubic spline and a line segment.
17
13
  */
18
- export declare function curveToBezier<Point extends LocalPoint | GlobalPoint>(pointsIn: readonly Point[], curveTightness?: number): Point[];
14
+ export declare function curveIntersectLineSegment<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, l: LineSegment<Point>): Point[];
19
15
  /**
16
+ * Finds the closest point on the Bezier curve from another point
20
17
  *
21
- * @param t
22
- * @param controlPoints
18
+ * @param x
19
+ * @param y
20
+ * @param P0
21
+ * @param P1
22
+ * @param P2
23
+ * @param P3
24
+ * @param tolerance
25
+ * @param maxLevel
23
26
  * @returns
24
27
  */
25
- export declare const cubicBezierPoint: <Point extends GlobalPoint | LocalPoint>(t: number, controlPoints: Curve<Point>) => Point;
28
+ export declare function curveClosestPoint<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): Point | null;
26
29
  /**
30
+ * Determines the distance between a point and the closest point on the
31
+ * Bezier curve.
27
32
  *
28
- * @param point
29
- * @param controlPoints
30
- * @returns
33
+ * @param c The curve to test
34
+ * @param p The point to measure from
35
+ */
36
+ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point): number;
37
+ /**
38
+ * Determines if the parameter is a Curve
31
39
  */
32
- export declare const cubicBezierDistance: <Point extends GlobalPoint | LocalPoint>(point: Point, controlPoints: Curve<Point>) => number;
40
+ export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
@@ -0,0 +1,44 @@
1
+ import type { Ellipse, GlobalPoint, Line, LineSegment, LocalPoint } from "./types";
2
+ /**
3
+ * Construct an Ellipse object from the parameters
4
+ *
5
+ * @param center The center of the ellipse
6
+ * @param angle The slanting of the ellipse in radians
7
+ * @param halfWidth Half of the width of a non-slanted version of the ellipse
8
+ * @param halfHeight Half of the height of a non-slanted version of the ellipse
9
+ * @returns The constructed Ellipse object
10
+ */
11
+ export declare function ellipse<Point extends GlobalPoint | LocalPoint>(center: Point, halfWidth: number, halfHeight: number): Ellipse<Point>;
12
+ /**
13
+ * Determines if a point is inside or on the ellipse outline
14
+ *
15
+ * @param p The point to test
16
+ * @param ellipse The ellipse to compare against
17
+ * @returns TRUE if the point is inside or on the outline of the ellipse
18
+ */
19
+ export declare const ellipseIncludesPoint: <Point extends GlobalPoint | LocalPoint>(p: Point, ellipse: Ellipse<Point>) => boolean;
20
+ /**
21
+ * Tests whether a point lies on the outline of the ellipse within a given
22
+ * tolerance
23
+ *
24
+ * @param point The point to test
25
+ * @param ellipse The ellipse to compare against
26
+ * @param threshold The distance to consider a point close enough to be "on" the outline
27
+ * @returns TRUE if the point is on the ellise outline
28
+ */
29
+ export declare const ellipseTouchesPoint: <Point extends GlobalPoint | LocalPoint>(point: Point, ellipse: Ellipse<Point>, threshold?: number) => boolean;
30
+ /**
31
+ * Determine the shortest euclidean distance from a point to the
32
+ * outline of the ellipse
33
+ *
34
+ * @param p The point to consider
35
+ * @param ellipse The ellipse to calculate the distance to
36
+ * @returns The eucledian distance
37
+ */
38
+ export declare const ellipseDistanceFromPoint: <Point extends GlobalPoint | LocalPoint>(p: Point, ellipse: Ellipse<Point>) => number;
39
+ /**
40
+ * Calculate a maximum of two intercept points for a line going throug an
41
+ * ellipse.
42
+ */
43
+ export declare function ellipseSegmentInterceptPoints<Point extends GlobalPoint | LocalPoint>(e: Readonly<Ellipse<Point>>, s: Readonly<LineSegment<Point>>): Point[];
44
+ export declare function ellipseLineIntersectionPoints<Point extends GlobalPoint | LocalPoint>({ center, halfWidth, halfHeight }: Ellipse<Point>, [g, h]: Line<Point>): Point[];
@@ -1,10 +1,10 @@
1
- export * from "./arc";
2
1
  export * from "./angle";
3
2
  export * from "./curve";
4
3
  export * from "./line";
5
4
  export * from "./point";
6
5
  export * from "./polygon";
7
6
  export * from "./range";
7
+ export * from "./rectangle";
8
8
  export * from "./segment";
9
9
  export * from "./triangle";
10
10
  export * from "./types";
@@ -1,4 +1,4 @@
1
- import type { GlobalPoint, Line, LocalPoint, Radians } from "./types";
1
+ import type { GlobalPoint, Line, LocalPoint } from "./types";
2
2
  /**
3
3
  * Create a line from two points.
4
4
  *
@@ -6,34 +6,6 @@ import type { GlobalPoint, Line, LocalPoint, Radians } from "./types";
6
6
  * @returns The line on which the points lie
7
7
  */
8
8
  export declare function line<P extends GlobalPoint | LocalPoint>(a: P, b: P): Line<P>;
9
- /**
10
- * Convenient point creation from an array of two points.
11
- *
12
- * @param param0 The array with the two points to convert to a line
13
- * @returns The created line
14
- */
15
- export declare function lineFromPointPair<P extends GlobalPoint | LocalPoint>([a, b]: [
16
- P,
17
- P
18
- ]): Line<P>;
19
- /**
20
- * TODO
21
- *
22
- * @param pointArray
23
- * @returns
24
- */
25
- export declare function lineFromPointArray<P extends GlobalPoint | LocalPoint>(pointArray: P[]): Line<P> | undefined;
26
- /**
27
- * Return the coordinates resulting from rotating the given line about an
28
- * origin by an angle in degrees note that when the origin is not given,
29
- * the midpoint of the given line is used as the origin
30
- *
31
- * @param l
32
- * @param angle
33
- * @param origin
34
- * @returns
35
- */
36
- export declare const lineRotate: <Point extends GlobalPoint | LocalPoint>(l: Line<Point>, angle: Radians, origin?: Point | undefined) => Line<Point>;
37
9
  /**
38
10
  * Determines the intersection point (unless the lines are parallel) of two
39
11
  * lines
@@ -42,4 +14,4 @@ export declare const lineRotate: <Point extends GlobalPoint | LocalPoint>(l: Lin
42
14
  * @param b
43
15
  * @returns
44
16
  */
45
- export declare const linesIntersectAt: <Point extends GlobalPoint | LocalPoint>(a: Line<Point>, b: Line<Point>) => Point | null;
17
+ export declare function linesIntersectAt<Point extends GlobalPoint | LocalPoint>(a: Line<Point>, b: Line<Point>): Point | null;
@@ -27,17 +27,7 @@ export declare function pointFromPair<Point extends GlobalPoint | LocalPoint>(pa
27
27
  * @param v The vector to convert
28
28
  * @returns The point the vector points at with origin 0,0
29
29
  */
30
- export declare function pointFromVector<P extends GlobalPoint | LocalPoint>(v: Vector): P;
31
- /**
32
- * Convert the coordiante object to a point.
33
- *
34
- * @param coords The coordinate object with x and y properties
35
- * @returns
36
- */
37
- export declare function pointFromCoords<Point extends GlobalPoint | LocalPoint>({ x, y, }: {
38
- x: number;
39
- y: number;
40
- }): Point;
30
+ export declare function pointFromVector<P extends GlobalPoint | LocalPoint>(v: Vector, offset?: P): P;
41
31
  /**
42
32
  * Checks if the provided value has the shape of a Point.
43
33
  *
@@ -93,24 +83,6 @@ export declare function pointTranslate<From extends GlobalPoint | LocalPoint, To
93
83
  * @returns The middle point
94
84
  */
95
85
  export declare function pointCenter<P extends LocalPoint | GlobalPoint>(a: P, b: P): P;
96
- /**
97
- * Add together two points by their coordinates like you'd apply a translation
98
- * to a point by a vector.
99
- *
100
- * @param a One point to act as a basis
101
- * @param b The other point to act like the vector to translate by
102
- * @returns
103
- */
104
- export declare function pointAdd<Point extends LocalPoint | GlobalPoint>(a: Point, b: Point): Point;
105
- /**
106
- * Subtract a point from another point like you'd translate a point by an
107
- * invese vector.
108
- *
109
- * @param a The point to translate
110
- * @param b The point which will act like a vector
111
- * @returns The resulting point
112
- */
113
- export declare function pointSubtract<Point extends LocalPoint | GlobalPoint>(a: Point, b: Point): Point;
114
86
  /**
115
87
  * Calculate the distance between two points.
116
88
  *
@@ -0,0 +1,3 @@
1
+ import type { GlobalPoint, LineSegment, LocalPoint, Rectangle } from "./types";
2
+ export declare function rectangle<P extends GlobalPoint | LocalPoint>(topLeft: P, bottomRight: P): Rectangle<P>;
3
+ export declare function rectangleIntersectLineSegment<Point extends LocalPoint | GlobalPoint>(r: Rectangle<Point>, l: LineSegment<Point>): Point[];