@dwelle/excalidraw 0.5.0-e05a141 → 0.5.0-e2a82c4d8

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 (138) hide show
  1. package/dist/dev/{chunk-JCMFCSXV.js → chunk-7M7SVUYU.js} +121 -7
  2. package/dist/dev/chunk-7M7SVUYU.js.map +7 -0
  3. package/dist/dev/{chunk-P7XQCHXR.js → chunk-HJWER26G.js} +901 -439
  4. package/dist/dev/chunk-HJWER26G.js.map +7 -0
  5. package/dist/dev/{chunk-B7UQ5W6R.js → chunk-Q5BO7QEK.js} +2 -2
  6. package/dist/dev/{chunk-B7UQ5W6R.js.map → chunk-Q5BO7QEK.js.map} +1 -1
  7. package/dist/dev/components/TTDDialog/CodeMirrorEditor-4GD6MAJW.js +259 -0
  8. package/dist/dev/components/TTDDialog/CodeMirrorEditor-4GD6MAJW.js.map +7 -0
  9. package/dist/dev/data/{image-BUI6GQJR.js → image-UQK7BQY4.js} +3 -3
  10. package/dist/dev/index.css +2444 -173
  11. package/dist/dev/index.css.map +3 -3
  12. package/dist/dev/index.js +6875 -1415
  13. package/dist/dev/index.js.map +4 -4
  14. package/dist/dev/locales/{en-SEGQGVZN.js → en-IHKMFGHF.js} +6 -2
  15. package/dist/dev/subset-shared.chunk.js +1 -1
  16. package/dist/dev/subset-worker.chunk.js +1 -1
  17. package/dist/prod/chunk-QHCRJDAB.js +12 -0
  18. package/dist/prod/chunk-R2CZDOAE.js +34 -0
  19. package/dist/prod/{chunk-KDBB3MAO.js → chunk-XXRJJHWR.js} +1 -1
  20. package/dist/prod/components/TTDDialog/CodeMirrorEditor-P2CDXXOC.js +1 -0
  21. package/dist/prod/data/image-WAWRV65K.js +1 -0
  22. package/dist/prod/index.css +1 -1
  23. package/dist/prod/index.js +34 -25
  24. package/dist/prod/locales/en-QQWGF6XN.js +1 -0
  25. package/dist/prod/subset-shared.chunk.js +1 -1
  26. package/dist/prod/subset-worker.chunk.js +1 -1
  27. package/dist/types/common/src/utils.d.ts +5 -3
  28. package/dist/types/element/src/Scene.d.ts +2 -0
  29. package/dist/types/element/src/arrowheads.d.ts +3 -0
  30. package/dist/types/element/src/binding.d.ts +5 -4
  31. package/dist/types/element/src/bounds.d.ts +5 -3
  32. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  33. package/dist/types/element/src/frame.d.ts +1 -1
  34. package/dist/types/element/src/index.d.ts +1 -0
  35. package/dist/types/element/src/linearElementEditor.d.ts +5 -2
  36. package/dist/types/element/src/mutateElement.d.ts +2 -0
  37. package/dist/types/element/src/selection.d.ts +7 -3
  38. package/dist/types/element/src/shape.d.ts +1 -1
  39. package/dist/types/element/src/textElement.d.ts +1 -1
  40. package/dist/types/element/src/textWrapping.d.ts +26 -0
  41. package/dist/types/element/src/types.d.ts +4 -1
  42. package/dist/types/element/src/utils.d.ts +2 -2
  43. package/dist/types/excalidraw/TTA/TTAChatEmptyState.d.ts +7 -0
  44. package/dist/types/excalidraw/TTA/TTAChatMessage.d.ts +15 -0
  45. package/dist/types/excalidraw/TTA/TTAComposer.d.ts +24 -0
  46. package/dist/types/excalidraw/TTA/TTADialog.d.ts +19 -0
  47. package/dist/types/excalidraw/TTA/TTADialogPanel.d.ts +46 -0
  48. package/dist/types/excalidraw/TTA/TTADialogTrigger.d.ts +10 -0
  49. package/dist/types/excalidraw/TTA/TTAHistory.d.ts +11 -0
  50. package/dist/types/excalidraw/TTA/TTAWarningMessage.d.ts +5 -0
  51. package/dist/types/excalidraw/TTA/chatErrors.d.ts +13 -0
  52. package/dist/types/excalidraw/TTA/chatHelpers.d.ts +26 -0
  53. package/dist/types/excalidraw/TTA/client.d.ts +74 -0
  54. package/dist/types/excalidraw/TTA/history.d.ts +2 -0
  55. package/dist/types/excalidraw/TTA/insertAISkeletons.d.ts +20 -0
  56. package/dist/types/excalidraw/TTA/types.d.ts +167 -0
  57. package/dist/types/excalidraw/TTA/useAIAssistantPreview.d.ts +18 -0
  58. package/dist/types/excalidraw/TTA/useAIStreamingCanvasPreview.d.ts +21 -0
  59. package/dist/types/excalidraw/TTA/useAIStreamingLifecycle.d.ts +34 -0
  60. package/dist/types/excalidraw/TTA/useTTAChatHistory.d.ts +18 -0
  61. package/dist/types/excalidraw/TTA/utils.d.ts +14 -0
  62. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -6
  63. package/dist/types/excalidraw/actions/actionBoundText.d.ts +11 -5
  64. package/dist/types/excalidraw/actions/actionCanvas.d.ts +50 -20
  65. package/dist/types/excalidraw/actions/actionClipboard.d.ts +10 -4
  66. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -2
  67. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +15 -6
  68. package/dist/types/excalidraw/actions/actionDeselect.d.ts +161 -0
  69. package/dist/types/excalidraw/actions/actionElementLink.d.ts +5 -2
  70. package/dist/types/excalidraw/actions/actionElementLock.d.ts +10 -4
  71. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +5 -2
  72. package/dist/types/excalidraw/actions/actionExport.d.ts +21 -8
  73. package/dist/types/excalidraw/actions/actionFrame.d.ts +20 -8
  74. package/dist/types/excalidraw/actions/actionGroup.d.ts +11 -5
  75. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +5 -2
  76. package/dist/types/excalidraw/actions/actionLink.d.ts +5 -2
  77. package/dist/types/excalidraw/actions/actionMenu.d.ts +5 -2
  78. package/dist/types/excalidraw/actions/actionProperties.d.ts +12 -6
  79. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +5 -2
  80. package/dist/types/excalidraw/actions/actionStyles.d.ts +6 -2
  81. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  82. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +174 -0
  83. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -2
  84. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +174 -0
  85. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -2
  86. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -2
  87. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -2
  88. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -2
  89. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -2
  90. package/dist/types/excalidraw/actions/index.d.ts +3 -0
  91. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  92. package/dist/types/excalidraw/aiWarnings.d.ts +7 -0
  93. package/dist/types/excalidraw/appState.d.ts +4 -0
  94. package/dist/types/excalidraw/components/AI/ChatMessage.d.ts +33 -0
  95. package/dist/types/excalidraw/components/AI/index.d.ts +2 -0
  96. package/dist/types/excalidraw/components/App.d.ts +11 -1
  97. package/dist/types/excalidraw/components/FilledButton.d.ts +1 -1
  98. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  99. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  100. package/dist/types/excalidraw/components/TTDDialog/Chat/TTDRateLimitWarningContent.d.ts +5 -0
  101. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  102. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +2 -2
  103. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  104. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  105. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  106. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +5 -1
  107. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +24 -6
  108. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  109. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  110. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  111. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
  112. package/dist/types/excalidraw/components/icons.d.ts +18 -8
  113. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +3 -0
  114. package/dist/types/excalidraw/context/tunnels.d.ts +1 -0
  115. package/dist/types/excalidraw/data/blob.d.ts +9 -3
  116. package/dist/types/excalidraw/data/filesystem.d.ts +3 -3
  117. package/dist/types/excalidraw/data/index.d.ts +1 -1
  118. package/dist/types/excalidraw/data/json.d.ts +6 -3
  119. package/dist/types/excalidraw/data/resave.d.ts +1 -1
  120. package/dist/types/excalidraw/data/sse.d.ts +15 -0
  121. package/dist/types/excalidraw/index.d.ts +15 -2
  122. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  123. package/dist/types/excalidraw/types.d.ts +15 -2
  124. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  125. package/dist/types/math/src/curve.d.ts +4 -1
  126. package/dist/types/math/src/point.d.ts +1 -1
  127. package/package.json +11 -5
  128. package/CHANGELOG.md +0 -2385
  129. package/dist/dev/chunk-JCMFCSXV.js.map +0 -7
  130. package/dist/dev/chunk-P7XQCHXR.js.map +0 -7
  131. package/dist/prod/chunk-FVPDTNSG.js +0 -12
  132. package/dist/prod/chunk-LRBVLW2I.js +0 -33
  133. package/dist/prod/data/image-KI7JN73E.js +0 -1
  134. package/dist/prod/locales/en-6237XDE7.js +0 -1
  135. package/dist/types/excalidraw/data/ai/types.d.ts +0 -242
  136. package/history.ts +0 -249
  137. /package/dist/dev/data/{image-BUI6GQJR.js.map → image-UQK7BQY4.js.map} +0 -0
  138. /package/dist/dev/locales/{en-SEGQGVZN.js.map → en-IHKMFGHF.js.map} +0 -0
@@ -0,0 +1 @@
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,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-QHCRJDAB.js";import"../chunk-SRAX5OIU.js";export{N as ai,f as alerts,e as buttons,l as canvasError,H as chat,t as clearCanvasDialog,D as colorPicker,B as colors,L as commandPalette,w as confirmDialog,O as default,i as element,b as elementLink,y as encrypted,p as errorDialog,m as errorSplash,g as errors,r as exportDialog,J as fontList,j as headings,s as helpDialog,k as hints,x as imageExportDialog,M as keys,a as labels,c as library,F as mermaid,E as overwriteConfirm,q as progressDialog,u as publishDialog,v as publishSuccessDialog,I as quickSearch,o as roomDialog,d as search,n as shareDialog,z as stats,A as toast,h as toolBar,G as ttd,K as userList,C as welcomeScreen};
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-KDBB3MAO.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-Z5NKEFVG.js";import"./chunk-XXRJJHWR.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-Z5NKEFVG.js";import"./chunk-KDBB3MAO.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-Z5NKEFVG.js";import"./chunk-XXRJJHWR.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};
@@ -6,6 +6,10 @@ import type { EVENT } from "./constants";
6
6
  export declare const setDateTimeForTests: (dateTime: string) => void;
7
7
  export declare const getDateTime: () => string;
8
8
  export declare const capitalizeString: (str: string) => string;
9
+ export declare const formatTimeToHourMinute: (value: Date | number, opts?: {
10
+ locale?: string | string[];
11
+ hour12?: boolean;
12
+ }) => string;
9
13
  export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
10
14
  export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
11
15
  export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
@@ -25,9 +29,7 @@ export declare const debounce: <T extends any[]>(fn: (...args: T) => void, timeo
25
29
  flush(): void;
26
30
  cancel(): void;
27
31
  };
28
- export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, opts?: {
29
- trailing?: boolean;
30
- }) => {
32
+ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void) => {
31
33
  (...args: T): void;
32
34
  flush(): void;
33
35
  cancel(): void;
@@ -75,6 +75,8 @@ export declare class Scene {
75
75
  mutateElement<TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, options?: {
76
76
  informMutation: boolean;
77
77
  isDragging: boolean;
78
+ isBindingEnabled?: boolean;
79
+ isMidpointSnappingEnabled?: boolean;
78
80
  }): TElement;
79
81
  }
80
82
  export {};
@@ -0,0 +1,3 @@
1
+ import type { Arrowhead, AnyArrowhead } from "./types";
2
+ export declare const normalizeArrowhead: (arrowhead: AnyArrowhead | null | undefined) => Arrowhead | null;
3
+ export declare const getArrowheadForPicker: (arrowhead: AnyArrowhead | null | undefined) => Arrowhead | null;
@@ -30,7 +30,6 @@ export declare const BASE_ARROW_MIN_LENGTH = 10;
30
30
  export declare const FOCUS_POINT_SIZE: number;
31
31
  export declare const getBindingGap: (bindTarget: ExcalidrawBindableElement, opts: Pick<ExcalidrawArrowElement, "elbowed">) => number;
32
32
  export declare const maxBindingDistance_simple: (zoom?: AppState["zoom"]) => number;
33
- export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
34
33
  export declare const isBindingEnabled: (appState: {
35
34
  isBindingEnabled: AppState["isBindingEnabled"];
36
35
  }) => boolean;
@@ -55,7 +54,7 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
55
54
  end: BindingStrategy;
56
55
  };
57
56
  export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
58
- export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint) => void;
57
+ export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean) => void;
59
58
  export declare const unbindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
60
59
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
61
60
  simultaneouslyUpdated?: readonly ExcalidrawElement[];
@@ -69,17 +68,19 @@ export declare const updateBindings: (latestElement: ExcalidrawElement, scene: S
69
68
  };
70
69
  }) => void;
71
70
  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;
72
- export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, customIntersector?: LineSegment<GlobalPoint>) => GlobalPoint;
71
+ export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
73
72
  export declare const avoidRectangularCorner: (arrowElement: ExcalidrawArrowElement, bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
74
73
  export declare const snapToMid: (bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number, arrowElement?: ExcalidrawArrowElement) => GlobalPoint | undefined;
75
74
  export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "startBinding" | "endBinding", binding: FixedPointBinding | null | undefined, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, dragging?: boolean) => LocalPoint | null;
76
- export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
75
+ export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
77
76
  fixedPoint: FixedPoint;
78
77
  };
79
78
  export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: GlobalPoint) => {
80
79
  fixedPoint: FixedPoint;
81
80
  };
82
81
  export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
82
+ export declare const normalizeElbowArrow: (arrow: ExcalidrawElbowArrowElement, elementsMap: NonDeletedSceneElementsMap) => ElementUpdate<ExcalidrawElbowArrowElement>;
83
+ export declare const normalizeElbowArrows: <T extends ExcalidrawElement>(elements: readonly T[], elementsMap?: NonDeletedSceneElementsMap) => T[];
83
84
  export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
84
85
  export declare const bindingProperties: Set<BindableProp | BindingProp>;
85
86
  export type BindableProp = "boundElements";
@@ -2,7 +2,7 @@ import { type Bounds } from "@excalidraw/common";
2
2
  import type { Degrees, GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
3
3
  import type { AppState } from "@excalidraw/excalidraw/types";
4
4
  import type { Drawable, Op } from "roughjs/bin/core";
5
- import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, NonDeleted } from "./types";
5
+ import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawLinearElement, NonDeleted } from "./types";
6
6
  export type RectangleBox = {
7
7
  x: number;
8
8
  y: number;
@@ -38,12 +38,12 @@ export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBo
38
38
  export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
39
39
  export declare const getCubicBezierCurveBound: (p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, p3: GlobalPoint) => Bounds;
40
40
  export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: (p: GlobalPoint) => GlobalPoint) => Bounds;
41
- export declare const getBoundsFromPoints: (points: ExcalidrawFreeDrawElement["points"]) => Bounds;
41
+ export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], padding?: number) => Bounds;
42
42
  /** @returns number in pixels */
43
43
  export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
44
44
  /** @returns number in degrees */
45
45
  export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
46
- export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
46
+ export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, offsetMultiplier?: number) => number[] | null;
47
47
  export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
48
48
  export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
49
49
  export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
@@ -77,5 +77,7 @@ export declare const getCenterForBounds: (bounds: Bounds) => GlobalPoint;
77
77
  */
78
78
  export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
79
79
  export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
80
+ export declare const pointInsideBoundsInclusive: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
80
81
  export declare const doBoundsIntersect: (bounds1: Bounds | null, bounds2: Bounds | null) => boolean;
82
+ export declare const boundsContainBounds: (outerBounds: Bounds, innerBounds: Bounds) => boolean;
81
83
  export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
@@ -13,5 +13,7 @@ export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArr
13
13
  endBinding?: FixedPointBinding | null;
14
14
  }, options?: {
15
15
  isDragging?: boolean;
16
+ isBindingEnabled?: boolean;
17
+ isMidpointSnappingEnabled?: boolean;
16
18
  }) => ElementUpdate<ExcalidrawElbowArrowElement>;
17
19
  export declare const validateElbowPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], tolerance?: number) => boolean;
@@ -70,5 +70,5 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
70
70
  export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
71
71
  export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
72
72
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
73
- export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
73
+ export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
74
74
  export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
@@ -56,3 +56,4 @@ export * from "./typeChecks";
56
56
  export * from "./utils";
57
57
  export * from "./zindex";
58
58
  export * from "./arrows/helpers";
59
+ export * from "./arrowheads";
@@ -55,8 +55,8 @@ export declare class LinearElementEditor {
55
55
  x: number;
56
56
  y: number;
57
57
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
58
- static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
59
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number): GlobalPoint;
58
+ static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom, elementsMap: ElementsMap): boolean;
59
+ static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number, elementsMap: ElementsMap): GlobalPoint;
60
60
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
61
61
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
62
62
  x: number;
@@ -96,6 +96,9 @@ export declare class LinearElementEditor {
96
96
  startBinding?: FixedPointBinding | null;
97
97
  endBinding?: FixedPointBinding | null;
98
98
  moveMidPointsWithElement?: boolean | null;
99
+ }, options?: {
100
+ isBindingEnabled?: boolean;
101
+ isMidpointSnappingEnabled?: boolean;
99
102
  }): void;
100
103
  static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
101
104
  static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
@@ -11,6 +11,8 @@ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TEl
11
11
  */
12
12
  export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, elementsMap: ElementsMap, updates: ElementUpdate<TElement>, options?: {
13
13
  isDragging?: boolean;
14
+ isBindingEnabled?: boolean;
15
+ isMidpointSnappingEnabled?: boolean;
14
16
  }) => TElement;
15
17
  export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>,
16
18
  /** pass `true` to always regenerate */
@@ -1,6 +1,6 @@
1
- import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
1
+ import type { AppState, BoxSelectionMode, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
2
  import { LinearElementEditor } from "./linearElementEditor";
3
- import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
3
+ import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
4
4
  /**
5
5
  * Frames and their containing elements are not to be selected at the same time.
6
6
  * Given an array of selected elements, if there are frames and their containing elements
@@ -8,7 +8,7 @@ import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExca
8
8
  * @param selectedElements
9
9
  */
10
10
  export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
11
- export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, elementsMap: ElementsMap, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
11
+ export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, elementsMap: ElementsMap, excludeElementsInFrames?: boolean, boxSelectionMode?: BoxSelectionMode) => NonDeletedExcalidrawElement[];
12
12
  export declare const getVisibleAndNonSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => NonDeletedExcalidrawElement[];
13
13
  export declare const isSomeElementSelected: {
14
14
  (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
@@ -32,3 +32,7 @@ export declare const getSelectionStateForElements: (targetElements: readonly Exc
32
32
  editingGroupId: AppState["editingGroupId"];
33
33
  selectedLinearElement: LinearElementEditor | null;
34
34
  };
35
+ /**
36
+ * Returns editing or single-selected text element, if any.
37
+ */
38
+ export declare const getActiveTextElement: (selectedElements: readonly NonDeleted<ExcalidrawElement>[], appState: Pick<AppState, "editingTextElement">) => import("./types").ExcalidrawTextElement | null;
@@ -27,7 +27,7 @@ export declare class ShapeCache {
27
27
  } | null) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & {}) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
28
28
  }
29
29
  export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean, isDarkMode?: boolean) => Options;
30
- export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement) => {
30
+ export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement, elementsMap: ElementsMap) => {
31
31
  op: string;
32
32
  data: number[];
33
33
  }[];
@@ -31,7 +31,7 @@ export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExca
31
31
  declare const VALID_CONTAINER_TYPES: Set<string>;
32
32
  export declare const isValidTextContainer: (element: {
33
33
  type: ExcalidrawElementType;
34
- }) => boolean;
34
+ }) => element is ExcalidrawTextContainer;
35
35
  export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
36
36
  export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElement | null) => number;
37
37
  export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
@@ -5,9 +5,35 @@ import type { FontString } from "./types";
5
5
  export declare const containsCJK: (text: string) => boolean;
6
6
  /**
7
7
  * Breaks the line into the tokens based on the found line break opporutnities.
8
+ *
9
+ * Note: tokenization normalizes to NFC first so decomposed graphemes are treated as
10
+ * their composed variants for wrapping. Any code that needs exact source offsets should
11
+ * keep in mind that this assumes the input text is already NFC-normalized.
8
12
  */
9
13
  export declare const parseTokens: (line: string) => string[];
10
14
  /**
11
15
  * Wraps the original text into the lines based on the given width.
16
+ *
17
+ * This is a convenience adapter over `getWrappedTextLines()` for call sites
18
+ * that only need the rendered wrapped string and not the source offsets.
12
19
  */
13
20
  export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
21
+ /**
22
+ * A single rendered visual line produced from the original text.
23
+ *
24
+ * `start` and `end` are end-exclusive code-unit offsets into the original text, and do
25
+ * not include synthetic soft line breaks inserted by this module. If trailing whitespace
26
+ * was trimmed away at a wrap boundary, `end` points to the last rendered character.
27
+ */
28
+ export type WrappedTextLine = {
29
+ text: string;
30
+ start: number;
31
+ end: number;
32
+ };
33
+ /**
34
+ * Returns the rendered visual lines together with their source offsets.
35
+ *
36
+ * This is the source-of-truth wrapping pipeline for callers that need more than the
37
+ * final wrapped string, for example caret placement or future editor/rich-text mapping.
38
+ */
39
+ export declare const getWrappedTextLines: (text: string, font: FontString, maxWidth: number) => WrappedTextLine[];
@@ -208,7 +208,10 @@ export type PointsPositionUpdates = Map<Index, {
208
208
  point: LocalPoint;
209
209
  isDragging?: boolean;
210
210
  }>;
211
- export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline" | "crowfoot_one" | "crowfoot_many" | "crowfoot_one_or_many";
211
+ export type CardinalityArrowhead = "cardinality_one" | "cardinality_many" | "cardinality_one_or_many" | "cardinality_exactly_one" | "cardinality_zero_or_one" | "cardinality_zero_or_many";
212
+ export type ArrowheadLegacy = "dot" | "crowfoot_one" | "crowfoot_many" | "crowfoot_one_or_many";
213
+ export type Arrowhead = "arrow" | "bar" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline" | CardinalityArrowhead;
214
+ export type AnyArrowhead = Arrowhead | ArrowheadLegacy;
212
215
  export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
213
216
  type: "line" | "arrow";
214
217
  points: readonly LocalPoint[];
@@ -8,7 +8,7 @@ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, Ex
8
8
  * @param element The linear element to deconstruct
9
9
  * @returns The rotated in components.
10
10
  */
11
- export declare function deconstructLinearOrFreeDrawElement(element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
11
+ export declare function deconstructLinearOrFreeDrawElement(element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement, elementsMap: ElementsMap): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
12
12
  /**
13
13
  * Get the building components of a rectanguloid element in the form of
14
14
  * line segments and curves **unrotated**.
@@ -33,4 +33,4 @@ export declare const isPathALoop: (points: ExcalidrawLinearElement["points"],
33
33
  zoomValue?: Zoom["value"]) => boolean;
34
34
  export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
35
35
  export declare const getSnapOutlineMidPoint: (point: GlobalPoint, element: ExcalidrawBindableElement, elementsMap: ElementsMap, zoom: AppState["zoom"]) => GlobalPoint | undefined;
36
- export declare const projectFixedPointOntoDiagonal: (arrow: ExcalidrawArrowElement, point: GlobalPoint, element: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"]) => GlobalPoint | null;
36
+ export declare const projectFixedPointOntoDiagonal: (arrow: ExcalidrawArrowElement, point: GlobalPoint, element: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], isMidpointSnappingEnabled?: boolean) => GlobalPoint | null;
@@ -0,0 +1,7 @@
1
+ import type { ChatConversation } from "./types";
2
+ type TTAChatEmptyStateProps = {
3
+ latestHistoryChat: ChatConversation | null;
4
+ onSelectHistoryChat: (chat: ChatConversation) => void;
5
+ };
6
+ export declare const TTAChatEmptyState: ({ latestHistoryChat, onSelectHistoryChat, }: TTAChatEmptyStateProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { ChatMessage as ChatMessageType, TTAChatScrollOptions, TTADialogRenderWarning } from "./types";
3
+ export interface TTAChatMessageProps {
4
+ message: ChatMessageType;
5
+ onInsert: () => void;
6
+ onRetry: () => void;
7
+ showRetry?: boolean;
8
+ onDelete: () => void;
9
+ showDelete?: boolean;
10
+ onPreview: (url: string) => void;
11
+ scrollChatToBottom?: (options?: TTAChatScrollOptions) => void;
12
+ renderWarning?: TTADialogRenderWarning;
13
+ rateLimitRemaining?: number | null;
14
+ }
15
+ export declare const TTAChatMessage: React.FC<TTAChatMessageProps>;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import "./TTAComposer.scss";
3
+ export type TTAComposerImage = {
4
+ hash: string;
5
+ image: string;
6
+ };
7
+ interface TTAComposerProps {
8
+ onSend: (message: string, images?: string[]) => void;
9
+ onStop?: () => void;
10
+ isSending?: boolean;
11
+ value?: string;
12
+ onChange?: (value: string) => void;
13
+ images?: TTAComposerImage[];
14
+ onImagesChange?: (images: TTAComposerImage[]) => void;
15
+ maxImages?: number;
16
+ onMaxImages?: (maxImages: number) => React.ReactNode;
17
+ placeholder?: string;
18
+ allowImageUpload?: boolean;
19
+ rightActions?: React.ReactNode;
20
+ onPreviewImage?: (url: string) => void;
21
+ disabled?: boolean;
22
+ }
23
+ declare const TTAComposer: React.FC<TTAComposerProps>;
24
+ export default TTAComposer;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import "./TTADialog.scss";
3
+ import type { ChatMessage, TTADialogRenderWarning, TTAPersistenceAdapter, TTARateLimits } from "./types";
4
+ import type { TTATransportAdapter } from "./client";
5
+ export declare const ttaChatMessagesAtom: import("jotai/vanilla/atom").PrimitiveAtom<ChatMessage[]> & {
6
+ init: ChatMessage[];
7
+ };
8
+ export declare const ttaRateLimitsAtom: import("jotai/vanilla/atom").PrimitiveAtom<TTARateLimits | null> & {
9
+ init: TTARateLimits | null;
10
+ };
11
+ export interface TTADialogProps {
12
+ maxImages?: number;
13
+ onMaxImages?: (maxImages: number) => React.ReactNode;
14
+ renderWarning?: TTADialogRenderWarning;
15
+ persistenceAdapter?: TTAPersistenceAdapter;
16
+ transportAdapter: TTATransportAdapter;
17
+ }
18
+ export declare const TTADialog: React.MemoExoticComponent<(props: TTADialogProps) => import("react/jsx-runtime").JSX.Element | null>;
19
+ export default TTADialog;
@@ -0,0 +1,46 @@
1
+ import type { ReactNode, RefObject } from "react";
2
+ import type { ChatMessage, ChatConversation, TTAChatScrollOptions, TTADialogRenderWarning, TTARateLimits } from "./types";
3
+ export type TTAPreviewModalState = {
4
+ image: string;
5
+ titleKey: "ai.chat.generatedResult" | "ai.chat.attachedImage";
6
+ };
7
+ export type TTADialogPanelView = {
8
+ hasConversation: boolean;
9
+ isSendingChat: boolean;
10
+ isHistoryVisible: boolean;
11
+ isPinned: boolean;
12
+ shouldShowSupportBanner: boolean;
13
+ composerInputValue: string;
14
+ composerImages: readonly unknown[];
15
+ previewModal: TTAPreviewModalState | null;
16
+ chatMessages: ChatMessage[];
17
+ chatHistory: ChatConversation[];
18
+ latestHistoryChat: ChatConversation | null;
19
+ latestRetryableAssistantMessageId: string | null;
20
+ rateLimits: TTARateLimits | null;
21
+ };
22
+ export type TTADialogPanelActions = {
23
+ onStartNewChat: () => void;
24
+ onToggleHistory: () => void;
25
+ onTogglePinned: () => void;
26
+ onClose: () => void;
27
+ onClosePreviewModal: () => void;
28
+ onOpenPreviewModal: (image: string, titleKey?: TTAPreviewModalState["titleKey"]) => void;
29
+ onInsertResult: (message: ChatMessage) => void;
30
+ onRetry: (messageId: string) => void;
31
+ onRequestDelete: (messageId: string) => void;
32
+ scrollChatToBottom: (options?: TTAChatScrollOptions) => void;
33
+ onDismissSupportBanner: () => void;
34
+ onSelectHistoryChat: (chat: ChatConversation) => void;
35
+ onDeleteHistoryChat: (chatId: string) => void;
36
+ onRenameHistoryChat: (chatId: string, newTitle: string) => void;
37
+ onHideHistory: () => void;
38
+ };
39
+ export type TTADialogPanelProps = {
40
+ view: TTADialogPanelView;
41
+ actions: TTADialogPanelActions;
42
+ chatHistoryRef: RefObject<HTMLDivElement | null>;
43
+ composer: ReactNode;
44
+ renderWarning?: TTADialogRenderWarning;
45
+ };
46
+ export declare const TTADialogPanel: ({ view, actions, chatHistoryRef, composer, renderWarning, }: TTADialogPanelProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ type TTADialogTriggerProps = {
3
+ isOpen: boolean;
4
+ isPinned: boolean;
5
+ hasOpenSidebar: boolean;
6
+ onToggle: () => void;
7
+ children: ReactNode;
8
+ };
9
+ export declare const TTADialogTrigger: ({ isOpen, isPinned, hasOpenSidebar, onToggle, children, }: TTADialogTriggerProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import "./TTADialog.scss";
3
+ import type { ChatConversation } from "./types";
4
+ export interface TTAHistoryProps {
5
+ history: ChatConversation[];
6
+ onSelectChat: (chat: ChatConversation) => void;
7
+ onDeleteChat: (chatId: string) => void;
8
+ onRenameChat: (chatId: string, newTitle: string) => void;
9
+ onClose: () => void;
10
+ }
11
+ export declare const TTAHistory: React.FC<TTAHistoryProps>;
@@ -0,0 +1,5 @@
1
+ import "./TTAWarningMessage.scss";
2
+ import type { ReactNode } from "react";
3
+ export declare const TTAWarningMessage: ({ children }: {
4
+ children: ReactNode;
5
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ import type { AI_ERROR_CODE } from "./types";
2
+ export type AIChatRuntimeError = Error & {
3
+ code?: AI_ERROR_CODE | number;
4
+ handled?: boolean;
5
+ cause?: unknown;
6
+ };
7
+ export declare const withAIChatErrorMeta: (error: Error, options?: {
8
+ code?: AI_ERROR_CODE | number;
9
+ handled?: boolean;
10
+ cause?: unknown;
11
+ }) => AIChatRuntimeError;
12
+ export declare const getAIChatErrorCode: (error: unknown) => AI_ERROR_CODE | number | undefined;
13
+ export declare const isAIChatErrorHandled: (error: unknown) => boolean;
@@ -0,0 +1,26 @@
1
+ import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { AssistantChatMessage, ChatConversation, ChatMessage, ChatTurn } from "./types";
3
+ /**
4
+ * Deep clones messages to ensure no mutation reference issues.
5
+ */
6
+ export declare const cloneMessages: (messages: ChatMessage[]) => ChatMessage[];
7
+ export declare const messagesToTurns: (messages: ChatMessage[]) => ChatTurn[];
8
+ export declare const turnsToMessages: (turns: ChatTurn[]) => ChatMessage[];
9
+ export declare const getConversationMessages: (conversation: Pick<ChatConversation, "turns">) => ChatMessage[];
10
+ export declare const compareConversationsByUpdatedAt: (a: Pick<ChatConversation, "updatedAt">, b: Pick<ChatConversation, "updatedAt">) => number;
11
+ export declare const stopIncompleteAssistantMessages: (messages: ChatMessage[]) => ChatMessage[];
12
+ export declare const getLatestAssistantTurnId: (messages: ChatMessage[]) => string | null;
13
+ export declare const getLatestAssistantMessageId: (messages: ChatMessage[]) => string | null;
14
+ export declare const getLatestRetryableAssistantMessage: (messages: ChatMessage[]) => Extract<ChatMessage, {
15
+ role: "assistant";
16
+ }> | null;
17
+ export declare const getLatestAssistantTurnIdBeforeIndex: (messages: ChatMessage[], beforeIndex: number) => string | null;
18
+ export declare const getAssistantGenerationTags: (messages: ChatMessage[]) => string[];
19
+ export declare const getTurnStartIndexForAssistantDelete: (messages: ChatMessage[], messageIndex: number) => number;
20
+ export declare const getConversationTitle: (messages: ChatMessage[], defaultTitle?: string) => string;
21
+ export declare const getConversationTitleFromTurns: (turns: ChatTurn[], defaultTitle?: string) => string;
22
+ export declare const getConversationPreviewMessage: (messages: ChatMessage[]) => AssistantChatMessage | null;
23
+ export declare const getElementsCenter: (elements: readonly NonDeletedExcalidrawElement[]) => {
24
+ x: number;
25
+ y: number;
26
+ } | null;
@@ -0,0 +1,74 @@
1
+ import type { AIAssistantLifecycleStatus, AIGenerateRequestPayload, AIStreamFinalPayload, AIStreamMessagePayload, AIStreamPartialPayload, AIStreamStartedPayload, AI_ERROR_CODE } from "./types";
2
+ export declare const TTA_BASE_PATH = "/v1/ai/tta";
3
+ export declare const TTA_GENERATE_STREAM_PATH = "/v1/ai/tta/generate/stream";
4
+ export declare const TTA_TRUNCATE_PATH = "/v1/ai/tta/chat/truncate";
5
+ export type AIChatTruncateRequest = {
6
+ chatId: string;
7
+ keepThroughTurnId?: string | null;
8
+ };
9
+ export type AIChatTruncateResponse = {
10
+ ok: boolean;
11
+ chatId: string;
12
+ revision: number;
13
+ updatedAt?: number;
14
+ };
15
+ export interface TTAStreamFetchRequest {
16
+ method: "POST";
17
+ headers: {
18
+ "Content-Type": "application/json";
19
+ Accept: "text/event-stream";
20
+ };
21
+ payload: AIGenerateRequestPayload;
22
+ signal?: AbortSignal;
23
+ }
24
+ export type TTAStreamResponseFetch = (request: TTAStreamFetchRequest) => Promise<Response>;
25
+ export interface TTATruncateFetchRequest {
26
+ method: "POST";
27
+ headers: {
28
+ "Content-Type": "application/json";
29
+ };
30
+ payload: AIChatTruncateRequest;
31
+ }
32
+ export type TTATruncateResponseFetch = (request: TTATruncateFetchRequest) => Promise<Response>;
33
+ export declare const truncateChat: (payload: AIChatTruncateRequest, options: {
34
+ fetch: TTATruncateResponseFetch;
35
+ }) => Promise<AIChatTruncateResponse>;
36
+ export interface TTAStreamFetchOptions {
37
+ payload: AIGenerateRequestPayload;
38
+ onStarted?: (payload: AIStreamStartedPayload) => void;
39
+ onMessage?: (payload: AIStreamMessagePayload) => void;
40
+ onChunk?: (payload: AIStreamPartialPayload) => void;
41
+ signal?: AbortSignal;
42
+ onStreamCreated?: () => void;
43
+ fetch: TTAStreamResponseFetch;
44
+ }
45
+ export type TTAStreamError = {
46
+ code?: AI_ERROR_CODE | number;
47
+ message: string;
48
+ lifecycleStatus?: Extract<AIAssistantLifecycleStatus, "failed" | "aborted">;
49
+ };
50
+ export type TTAStreamFetchResult = {
51
+ rateLimit?: number | null;
52
+ rateLimitRemaining?: number | null;
53
+ } & ({
54
+ finalPayload: AIStreamFinalPayload;
55
+ error: null;
56
+ } | {
57
+ error: TTAStreamError;
58
+ finalPayload?: null;
59
+ });
60
+ export interface TTATransportAdapter {
61
+ stream(options: Omit<TTAStreamFetchOptions, "fetch">): Promise<TTAStreamFetchResult>;
62
+ truncate(payload: AIChatTruncateRequest): Promise<AIChatTruncateResponse>;
63
+ }
64
+ export interface TTADefaultTransportAdapterConfig {
65
+ stream: TTAStreamResponseFetch;
66
+ truncate: TTATruncateResponseFetch;
67
+ }
68
+ export declare const TTAStreamFetch: (options: TTAStreamFetchOptions) => Promise<TTAStreamFetchResult>;
69
+ export declare class TTADefaultTransportAdapter implements TTATransportAdapter {
70
+ private readonly config;
71
+ constructor(config: TTADefaultTransportAdapterConfig);
72
+ stream: TTATransportAdapter["stream"];
73
+ truncate: TTATransportAdapter["truncate"];
74
+ }
@@ -0,0 +1,2 @@
1
+ import type { TTAPersistenceAdapter } from "./types";
2
+ export declare const TTAIndexedDBAdapter: TTAPersistenceAdapter;
@@ -0,0 +1,20 @@
1
+ import { Scene } from "@excalidraw/element";
2
+ import type { ExcalidrawElementSkeleton } from "@excalidraw/element";
3
+ import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
4
+ import type { CaptureUpdateActionType } from "@excalidraw/element";
5
+ import type { AppClassProperties } from "../types";
6
+ export declare const AI_GENERATED_ELEMENTS_KEY = "aiSidebarGenerationId";
7
+ interface InsertSkeletonsOptions {
8
+ targetCenter?: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ generationId?: string;
13
+ regenerateIds?: boolean;
14
+ selectInsertedElements?: boolean;
15
+ captureUpdate?: CaptureUpdateActionType;
16
+ }
17
+ export declare const fixBoundTextElements: (elements: readonly NonDeletedExcalidrawElement[], scene: Scene) => void;
18
+ export declare const convertAISkeletonsToSceneElements: (skeletons: ReadonlyArray<ExcalidrawElementSkeleton>, app: AppClassProperties, options?: InsertSkeletonsOptions) => readonly NonDeletedExcalidrawElement[];
19
+ export declare const insertAISkeletons: (app: AppClassProperties, skeletons: ReadonlyArray<ExcalidrawElementSkeleton>, options?: InsertSkeletonsOptions) => readonly NonDeletedExcalidrawElement[];
20
+ export {};