@wildmio/excalidraw-common 0.18.0-custom.1

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 (379) hide show
  1. package/README.md +19 -0
  2. package/dist/dev/index.js +2695 -0
  3. package/dist/dev/index.js.map +7 -0
  4. package/dist/prod/index.js +4 -0
  5. package/dist/types/common/src/binary-heap.d.ts +12 -0
  6. package/dist/types/common/src/bounds.d.ts +10 -0
  7. package/dist/types/common/src/colors.d.ts +62 -0
  8. package/dist/types/common/src/constants.d.ts +352 -0
  9. package/dist/types/common/src/editorInterface.d.ts +34 -0
  10. package/dist/types/common/src/emitter.d.ts +16 -0
  11. package/dist/types/common/src/font-metadata.d.ts +46 -0
  12. package/dist/types/common/src/index.d.ts +15 -0
  13. package/dist/types/common/src/keys.d.ts +189 -0
  14. package/dist/types/common/src/points.d.ts +9 -0
  15. package/dist/types/common/src/promise-pool.d.ts +6 -0
  16. package/dist/types/common/src/queue.d.ts +9 -0
  17. package/dist/types/common/src/random.d.ts +3 -0
  18. package/dist/types/common/src/url.d.ts +7 -0
  19. package/dist/types/common/src/utility-types.d.ts +37 -0
  20. package/dist/types/common/src/utils.d.ts +279 -0
  21. package/dist/types/common/src/visualdebug.d.ts +41 -0
  22. package/dist/types/element/src/Scene.d.ts +80 -0
  23. package/dist/types/element/src/align.d.ts +8 -0
  24. package/dist/types/element/src/binding.d.ts +124 -0
  25. package/dist/types/element/src/bounds.d.ts +81 -0
  26. package/dist/types/element/src/collision.d.ts +36 -0
  27. package/dist/types/element/src/comparisons.d.ts +8 -0
  28. package/dist/types/element/src/containerCache.d.ts +11 -0
  29. package/dist/types/element/src/cropElement.d.ts +19 -0
  30. package/dist/types/element/src/delta.d.ts +228 -0
  31. package/dist/types/element/src/distance.d.ts +3 -0
  32. package/dist/types/element/src/distribute.d.ts +7 -0
  33. package/dist/types/element/src/dragElements.d.ts +33 -0
  34. package/dist/types/element/src/duplicate.d.ts +63 -0
  35. package/dist/types/element/src/elbowArrow.d.ts +17 -0
  36. package/dist/types/element/src/elementLink.d.ts +13 -0
  37. package/dist/types/element/src/embeddable.d.ts +10 -0
  38. package/dist/types/element/src/flowchart.d.ts +26 -0
  39. package/dist/types/element/src/fractionalIndex.d.ts +57 -0
  40. package/dist/types/element/src/frame.d.ts +74 -0
  41. package/dist/types/element/src/groups.d.ts +34 -0
  42. package/dist/types/element/src/heading.d.ts +16 -0
  43. package/dist/types/element/src/image.d.ts +22 -0
  44. package/dist/types/element/src/index.d.ts +56 -0
  45. package/dist/types/element/src/linearElementEditor.d.ts +113 -0
  46. package/dist/types/element/src/mutateElement.d.ts +23 -0
  47. package/dist/types/element/src/newElement.d.ts +62 -0
  48. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  49. package/dist/types/element/src/renderElement.d.ts +31 -0
  50. package/dist/types/element/src/resizeElements.d.ts +32 -0
  51. package/dist/types/element/src/resizeTest.d.ts +16 -0
  52. package/dist/types/element/src/selection.d.ts +34 -0
  53. package/dist/types/element/src/shape.d.ts +42 -0
  54. package/dist/types/element/src/showSelectedShapeActions.d.ts +3 -0
  55. package/dist/types/element/src/sizeHelpers.d.ts +35 -0
  56. package/dist/types/element/src/sortElements.d.ts +2 -0
  57. package/dist/types/element/src/store.d.ts +237 -0
  58. package/dist/types/element/src/textElement.d.ts +40 -0
  59. package/dist/types/element/src/textMeasurements.d.ts +39 -0
  60. package/dist/types/element/src/textWrapping.d.ts +13 -0
  61. package/dist/types/element/src/transform.d.ts +81 -0
  62. package/dist/types/element/src/transformHandles.d.ts +36 -0
  63. package/dist/types/element/src/typeChecks.d.ts +54 -0
  64. package/dist/types/element/src/types.d.ts +291 -0
  65. package/dist/types/element/src/utils.d.ts +34 -0
  66. package/dist/types/element/src/zindex.d.ts +13 -0
  67. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +485 -0
  68. package/dist/types/excalidraw/actions/actionAlign.d.ts +109 -0
  69. package/dist/types/excalidraw/actions/actionBoundText.d.ts +360 -0
  70. package/dist/types/excalidraw/actions/actionCanvas.d.ts +2059 -0
  71. package/dist/types/excalidraw/actions/actionClipboard.d.ts +399 -0
  72. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +174 -0
  73. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +519 -0
  74. package/dist/types/excalidraw/actions/actionDistribute.d.ts +34 -0
  75. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +17 -0
  76. package/dist/types/excalidraw/actions/actionElementLink.d.ts +194 -0
  77. package/dist/types/excalidraw/actions/actionElementLock.d.ts +346 -0
  78. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +171 -0
  79. package/dist/types/excalidraw/actions/actionExport.d.ts +683 -0
  80. package/dist/types/excalidraw/actions/actionFinalize.d.ts +13 -0
  81. package/dist/types/excalidraw/actions/actionFlip.d.ts +34 -0
  82. package/dist/types/excalidraw/actions/actionFrame.d.ts +1150 -0
  83. package/dist/types/excalidraw/actions/actionGroup.d.ts +350 -0
  84. package/dist/types/excalidraw/actions/actionHistory.d.ts +6 -0
  85. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +659 -0
  86. package/dist/types/excalidraw/actions/actionLink.d.ts +175 -0
  87. package/dist/types/excalidraw/actions/actionMenu.d.ts +163 -0
  88. package/dist/types/excalidraw/actions/actionNavigate.d.ts +20 -0
  89. package/dist/types/excalidraw/actions/actionProperties.d.ts +402 -0
  90. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +170 -0
  91. package/dist/types/excalidraw/actions/actionStyles.d.ts +188 -0
  92. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
  93. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +177 -0
  94. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +175 -0
  95. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +166 -0
  96. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  97. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +174 -0
  98. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +175 -0
  99. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +175 -0
  100. package/dist/types/excalidraw/actions/actionZindex.d.ts +74 -0
  101. package/dist/types/excalidraw/actions/index.d.ts +28 -0
  102. package/dist/types/excalidraw/actions/manager.d.ts +21 -0
  103. package/dist/types/excalidraw/actions/register.d.ts +5 -0
  104. package/dist/types/excalidraw/actions/shortcuts.d.ts +4 -0
  105. package/dist/types/excalidraw/actions/types.d.ts +47 -0
  106. package/dist/types/excalidraw/analytics.d.ts +1 -0
  107. package/dist/types/excalidraw/animated-trail.d.ts +39 -0
  108. package/dist/types/excalidraw/animation-frame-handler.d.ts +16 -0
  109. package/dist/types/excalidraw/appState.d.ts +102 -0
  110. package/dist/types/excalidraw/charts.d.ts +27 -0
  111. package/dist/types/excalidraw/clients.d.ts +14 -0
  112. package/dist/types/excalidraw/clipboard.d.ts +105 -0
  113. package/dist/types/excalidraw/components/Actions.d.ts +47 -0
  114. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +4 -0
  115. package/dist/types/excalidraw/components/App.d.ts +563 -0
  116. package/dist/types/excalidraw/components/Avatar.d.ts +11 -0
  117. package/dist/types/excalidraw/components/BraveMeasureTextError.d.ts +2 -0
  118. package/dist/types/excalidraw/components/Button.d.ts +17 -0
  119. package/dist/types/excalidraw/components/ButtonIcon.d.ts +16 -0
  120. package/dist/types/excalidraw/components/ButtonSeparator.d.ts +1 -0
  121. package/dist/types/excalidraw/components/Card.d.ts +6 -0
  122. package/dist/types/excalidraw/components/CheckboxItem.d.ts +8 -0
  123. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +10 -0
  124. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +23 -0
  125. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +8 -0
  126. package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +7 -0
  127. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +19 -0
  128. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +10 -0
  129. package/dist/types/excalidraw/components/ColorPicker/PickerHeading.d.ts +5 -0
  130. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +9 -0
  131. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +9 -0
  132. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +21 -0
  133. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +20 -0
  134. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +19 -0
  135. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +2 -0
  136. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +24 -0
  137. package/dist/types/excalidraw/components/ConfirmDialog.d.ts +10 -0
  138. package/dist/types/excalidraw/components/ContextMenu.d.ts +16 -0
  139. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  140. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +7 -0
  141. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +27 -0
  142. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +4 -0
  143. package/dist/types/excalidraw/components/Dialog.d.ts +13 -0
  144. package/dist/types/excalidraw/components/DialogActionButton.d.ts +10 -0
  145. package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +7 -0
  146. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +12 -0
  147. package/dist/types/excalidraw/components/Ellipsify.d.ts +3 -0
  148. package/dist/types/excalidraw/components/ErrorDialog.d.ts +5 -0
  149. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +15 -0
  150. package/dist/types/excalidraw/components/EyeButton.d.ts +8 -0
  151. package/dist/types/excalidraw/components/EyeDropper.d.ts +27 -0
  152. package/dist/types/excalidraw/components/FilledButton.d.ts +18 -0
  153. package/dist/types/excalidraw/components/FixedSideContainer.d.ts +9 -0
  154. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +10 -0
  155. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +22 -0
  156. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +26 -0
  157. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +8 -0
  158. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +13 -0
  159. package/dist/types/excalidraw/components/HandButton.d.ts +10 -0
  160. package/dist/types/excalidraw/components/HelpButton.d.ts +7 -0
  161. package/dist/types/excalidraw/components/HelpDialog.d.ts +4 -0
  162. package/dist/types/excalidraw/components/HintViewer.d.ts +11 -0
  163. package/dist/types/excalidraw/components/IconPicker.d.ts +15 -0
  164. package/dist/types/excalidraw/components/ImageExportDialog.d.ts +14 -0
  165. package/dist/types/excalidraw/components/InitializeApp.d.ts +10 -0
  166. package/dist/types/excalidraw/components/InlineIcon.d.ts +5 -0
  167. package/dist/types/excalidraw/components/Island.d.ts +10 -0
  168. package/dist/types/excalidraw/components/JSONExportDialog.d.ts +15 -0
  169. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +10 -0
  170. package/dist/types/excalidraw/components/LayerUI.d.ts +32 -0
  171. package/dist/types/excalidraw/components/LibraryMenu.d.ts +10 -0
  172. package/dist/types/excalidraw/components/LibraryMenuBrowseButton.d.ts +7 -0
  173. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +9 -0
  174. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +17 -0
  175. package/dist/types/excalidraw/components/LibraryMenuItems.d.ts +14 -0
  176. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +23 -0
  177. package/dist/types/excalidraw/components/LibraryUnit.d.ts +14 -0
  178. package/dist/types/excalidraw/components/LoadingMessage.d.ts +5 -0
  179. package/dist/types/excalidraw/components/LockButton.d.ts +10 -0
  180. package/dist/types/excalidraw/components/MagicButton.d.ts +10 -0
  181. package/dist/types/excalidraw/components/MobileMenu.d.ts +24 -0
  182. package/dist/types/excalidraw/components/MobileToolBar.d.ts +10 -0
  183. package/dist/types/excalidraw/components/Modal.d.ts +11 -0
  184. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
  185. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
  186. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
  187. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +8 -0
  188. package/dist/types/excalidraw/components/PenModeButton.d.ts +12 -0
  189. package/dist/types/excalidraw/components/Popover.d.ts +16 -0
  190. package/dist/types/excalidraw/components/ProjectName.d.ts +10 -0
  191. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +16 -0
  192. package/dist/types/excalidraw/components/PublishLibrary.d.ts +16 -0
  193. package/dist/types/excalidraw/components/QuickSearch.d.ts +9 -0
  194. package/dist/types/excalidraw/components/RadioGroup.d.ts +13 -0
  195. package/dist/types/excalidraw/components/RadioSelection.d.ts +20 -0
  196. package/dist/types/excalidraw/components/Range.d.ts +8 -0
  197. package/dist/types/excalidraw/components/SVGLayer.d.ts +7 -0
  198. package/dist/types/excalidraw/components/ScrollableList.d.ts +8 -0
  199. package/dist/types/excalidraw/components/SearchMenu.d.ts +5 -0
  200. package/dist/types/excalidraw/components/Section.d.ts +6 -0
  201. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +70 -0
  202. package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +7 -0
  203. package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +8 -0
  204. package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +9 -0
  205. package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +6 -0
  206. package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +6 -0
  207. package/dist/types/excalidraw/components/Sidebar/SidebarTrigger.d.ts +6 -0
  208. package/dist/types/excalidraw/components/Sidebar/common.d.ts +34 -0
  209. package/dist/types/excalidraw/components/Spinner.d.ts +8 -0
  210. package/dist/types/excalidraw/components/Stack.d.ts +15 -0
  211. package/dist/types/excalidraw/components/Stats/Angle.d.ts +11 -0
  212. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +10 -0
  213. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +10 -0
  214. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +11 -0
  215. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +44 -0
  216. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +11 -0
  217. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +11 -0
  218. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +14 -0
  219. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +12 -0
  220. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +14 -0
  221. package/dist/types/excalidraw/components/Stats/Position.d.ts +12 -0
  222. package/dist/types/excalidraw/components/Stats/index.d.ts +35 -0
  223. package/dist/types/excalidraw/components/Stats/utils.d.ts +19 -0
  224. package/dist/types/excalidraw/components/Switch.d.ts +9 -0
  225. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +6 -0
  226. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +29 -0
  227. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +9 -0
  228. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +7 -0
  229. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +17 -0
  230. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +4 -0
  231. package/dist/types/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +1 -0
  232. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +7 -0
  233. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +8 -0
  234. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +6 -0
  235. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +11 -0
  236. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +8 -0
  237. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +32 -0
  238. package/dist/types/excalidraw/components/TextField.d.ts +22 -0
  239. package/dist/types/excalidraw/components/Toast.d.ts +9 -0
  240. package/dist/types/excalidraw/components/ToolButton.d.ts +49 -0
  241. package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
  242. package/dist/types/excalidraw/components/Tooltip.d.ts +18 -0
  243. package/dist/types/excalidraw/components/Trans.d.ts +9 -0
  244. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  245. package/dist/types/excalidraw/components/UserList.d.ts +18 -0
  246. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +33 -0
  247. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +14 -0
  248. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +19 -0
  249. package/dist/types/excalidraw/components/canvases/index.d.ts +3 -0
  250. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +84 -0
  251. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +16 -0
  252. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -0
  253. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +38 -0
  254. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +8 -0
  255. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +17 -0
  256. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +7 -0
  257. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +16 -0
  258. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
  259. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +10 -0
  260. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +6 -0
  261. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
  262. package/dist/types/excalidraw/components/footer/Footer.d.ts +17 -0
  263. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +8 -0
  264. package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +4 -0
  265. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +19 -0
  266. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +10 -0
  267. package/dist/types/excalidraw/components/icons.d.ts +237 -0
  268. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +11 -0
  269. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +64 -0
  270. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +76 -0
  271. package/dist/types/excalidraw/components/shapes.d.ts +190 -0
  272. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +58 -0
  273. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
  274. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +84 -0
  275. package/dist/types/excalidraw/context/tunnels.d.ts +21 -0
  276. package/dist/types/excalidraw/context/ui-appState.d.ts +4 -0
  277. package/dist/types/excalidraw/cursor.d.ts +5 -0
  278. package/dist/types/excalidraw/data/EditorLocalStorage.d.ts +8 -0
  279. package/dist/types/excalidraw/data/blob.d.ts +57 -0
  280. package/dist/types/excalidraw/data/encode.d.ts +55 -0
  281. package/dist/types/excalidraw/data/encryption.d.ts +9 -0
  282. package/dist/types/excalidraw/data/filesystem.d.ts +21 -0
  283. package/dist/types/excalidraw/data/image.d.ts +9 -0
  284. package/dist/types/excalidraw/data/index.d.ts +22 -0
  285. package/dist/types/excalidraw/data/json.d.ts +18 -0
  286. package/dist/types/excalidraw/data/library.d.ts +127 -0
  287. package/dist/types/excalidraw/data/reconcile.d.ts +7 -0
  288. package/dist/types/excalidraw/data/resave.d.ts +5 -0
  289. package/dist/types/excalidraw/data/restore.d.ts +35 -0
  290. package/dist/types/excalidraw/data/types.d.ts +48 -0
  291. package/dist/types/excalidraw/deburr.d.ts +1 -0
  292. package/dist/types/excalidraw/editor-jotai.d.ts +56 -0
  293. package/dist/types/excalidraw/eraser/index.d.ts +12 -0
  294. package/dist/types/excalidraw/errors.d.ts +29 -0
  295. package/dist/types/excalidraw/fonts/Cascadia/index.d.ts +2 -0
  296. package/dist/types/excalidraw/fonts/ComicShanns/index.d.ts +2 -0
  297. package/dist/types/excalidraw/fonts/Emoji/index.d.ts +2 -0
  298. package/dist/types/excalidraw/fonts/ExcalidrawFontFace.d.ts +25 -0
  299. package/dist/types/excalidraw/fonts/Excalifont/index.d.ts +2 -0
  300. package/dist/types/excalidraw/fonts/Fonts.d.ts +79 -0
  301. package/dist/types/excalidraw/fonts/Helvetica/index.d.ts +2 -0
  302. package/dist/types/excalidraw/fonts/Liberation/index.d.ts +2 -0
  303. package/dist/types/excalidraw/fonts/Lilita/index.d.ts +2 -0
  304. package/dist/types/excalidraw/fonts/Nunito/index.d.ts +2 -0
  305. package/dist/types/excalidraw/fonts/Virgil/index.d.ts +2 -0
  306. package/dist/types/excalidraw/fonts/Xiaolai/index.d.ts +8 -0
  307. package/dist/types/excalidraw/fonts/index.d.ts +1 -0
  308. package/dist/types/excalidraw/gesture.d.ts +6 -0
  309. package/dist/types/excalidraw/history.d.ts +48 -0
  310. package/dist/types/excalidraw/hooks/useCallbackRefState.d.ts +1 -0
  311. package/dist/types/excalidraw/hooks/useCopiedIndicator.d.ts +5 -0
  312. package/dist/types/excalidraw/hooks/useCreatePortalContainer.d.ts +4 -0
  313. package/dist/types/excalidraw/hooks/useEmitter.d.ts +2 -0
  314. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +11 -0
  315. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +21 -0
  316. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -0
  317. package/dist/types/excalidraw/hooks/useStable.d.ts +1 -0
  318. package/dist/types/excalidraw/hooks/useStableCallback.d.ts +4 -0
  319. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  320. package/dist/types/excalidraw/hooks/useTransition.d.ts +2 -0
  321. package/dist/types/excalidraw/i18n.d.ts +24 -0
  322. package/dist/types/excalidraw/index.d.ts +45 -0
  323. package/dist/types/excalidraw/laser-trails.d.ts +20 -0
  324. package/dist/types/excalidraw/lasso/index.d.ts +16 -0
  325. package/dist/types/excalidraw/lasso/utils.d.ts +13 -0
  326. package/dist/types/excalidraw/mermaid.d.ts +2 -0
  327. package/dist/types/excalidraw/polyfill.d.ts +2 -0
  328. package/dist/types/excalidraw/reactUtils.d.ts +14 -0
  329. package/dist/types/excalidraw/renderer/animation.d.ts +12 -0
  330. package/dist/types/excalidraw/renderer/helpers.d.ts +16 -0
  331. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +14 -0
  332. package/dist/types/excalidraw/renderer/renderNewElementScene.d.ts +7 -0
  333. package/dist/types/excalidraw/renderer/renderSnaps.d.ts +2 -0
  334. package/dist/types/excalidraw/renderer/roundRect.d.ts +11 -0
  335. package/dist/types/excalidraw/renderer/staticScene.d.ts +14 -0
  336. package/dist/types/excalidraw/renderer/staticSvgScene.d.ts +5 -0
  337. package/dist/types/excalidraw/scene/Renderer.d.ts +30 -0
  338. package/dist/types/excalidraw/scene/export.d.ts +36 -0
  339. package/dist/types/excalidraw/scene/index.d.ts +4 -0
  340. package/dist/types/excalidraw/scene/normalize.d.ts +4 -0
  341. package/dist/types/excalidraw/scene/scroll.d.ts +18 -0
  342. package/dist/types/excalidraw/scene/scrollbars.d.ts +11 -0
  343. package/dist/types/excalidraw/scene/types.d.ts +132 -0
  344. package/dist/types/excalidraw/scene/zoom.d.ts +12 -0
  345. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  346. package/dist/types/excalidraw/snapping.d.ts +111 -0
  347. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +45 -0
  348. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +13 -0
  349. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +2 -0
  350. package/dist/types/excalidraw/subset/subset-main.d.ts +12 -0
  351. package/dist/types/excalidraw/subset/subset-shared.chunk.d.ts +32 -0
  352. package/dist/types/excalidraw/subset/subset-worker.chunk.d.ts +15 -0
  353. package/dist/types/excalidraw/subset/woff2/woff2-bindings.d.ts +31 -0
  354. package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +14 -0
  355. package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +2 -0
  356. package/dist/types/excalidraw/types.d.ts +744 -0
  357. package/dist/types/excalidraw/workers.d.ts +36 -0
  358. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +24 -0
  359. package/dist/types/math/src/angle.d.ts +19 -0
  360. package/dist/types/math/src/constants.d.ts +3 -0
  361. package/dist/types/math/src/curve.d.ts +74 -0
  362. package/dist/types/math/src/ellipse.d.ts +44 -0
  363. package/dist/types/math/src/index.d.ts +13 -0
  364. package/dist/types/math/src/line.d.ts +17 -0
  365. package/dist/types/math/src/point.d.ts +122 -0
  366. package/dist/types/math/src/polygon.d.ts +6 -0
  367. package/dist/types/math/src/range.d.ts +44 -0
  368. package/dist/types/math/src/rectangle.d.ts +5 -0
  369. package/dist/types/math/src/segment.d.ts +40 -0
  370. package/dist/types/math/src/triangle.d.ts +11 -0
  371. package/dist/types/math/src/types.d.ts +106 -0
  372. package/dist/types/math/src/utils.d.ts +7 -0
  373. package/dist/types/math/src/vector.d.ts +94 -0
  374. package/dist/types/utils/src/bbox.d.ts +9 -0
  375. package/dist/types/utils/src/export.d.ts +35 -0
  376. package/dist/types/utils/src/index.d.ts +4 -0
  377. package/dist/types/utils/src/shape.d.ts +58 -0
  378. package/dist/types/utils/src/withinBounds.d.ts +19 -0
  379. package/package.json +59 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Pool of idle short-lived workers.
3
+ *
4
+ * IMPORTANT: for simplicity it does not limit the number of newly created workers, leaving it up to the caller to manage the pool size.
5
+ */
6
+ export declare class WorkerPool<T, R> {
7
+ private idleWorkers;
8
+ private readonly workerUrl;
9
+ private readonly workerTTL;
10
+ private constructor();
11
+ /**
12
+ * Create a new worker pool.
13
+ *
14
+ * @param workerUrl - The URL of the worker file.
15
+ * @param options - The options for the worker pool.
16
+ * @throws If the worker is bundled into the main chunk.
17
+ * @returns A new worker pool instance.
18
+ */
19
+ static create<T, R>(workerUrl: URL | undefined, options?: {
20
+ ttl?: number;
21
+ }): WorkerPool<T, R>;
22
+ /**
23
+ * Take idle worker from the pool or create a new one and post a message to it.
24
+ */
25
+ postMessage(data: T, options: StructuredSerializeOptions): Promise<R>;
26
+ /**
27
+ * Terminate the idle workers in the pool.
28
+ */
29
+ clear(): Promise<void>;
30
+ /**
31
+ * Used to get a worker from the pool or create a new one if there is no idle available.
32
+ */
33
+ private createWorker;
34
+ private onMessageHandler;
35
+ private onErrorHandler;
36
+ }
@@ -0,0 +1,24 @@
1
+ import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
2
+ import type App from "../components/App";
3
+ type SubmitHandler = () => void;
4
+ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, }: {
5
+ id: ExcalidrawElement["id"];
6
+ /**
7
+ * textWysiwyg only deals with `originalText`
8
+ *
9
+ * Note: `text`, which can be wrapped and therefore different from `originalText`,
10
+ * is derived from `originalText`
11
+ */
12
+ onChange?: (nextOriginalText: string) => void;
13
+ onSubmit: (data: {
14
+ viaKeyboard: boolean;
15
+ nextOriginalText: string;
16
+ }) => void;
17
+ getViewportCoords: (x: number, y: number) => [number, number];
18
+ element: ExcalidrawTextElement;
19
+ canvas: HTMLCanvasElement;
20
+ excalidrawContainer: HTMLDivElement | null;
21
+ app: App;
22
+ autoSelect?: boolean;
23
+ }) => SubmitHandler;
24
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { Degrees, GlobalPoint, LocalPoint, PolarCoords, Radians } from "./types";
2
+ export declare const normalizeRadians: (angle: Radians) => Radians;
3
+ /**
4
+ * Return the polar coordinates for the given cartesian point represented by
5
+ * (x, y) for the center point 0,0 where the first number returned is the radius,
6
+ * the second is the angle in radians.
7
+ */
8
+ export declare const cartesian2Polar: <P extends GlobalPoint | LocalPoint>([x, y,]: P) => PolarCoords;
9
+ export declare function degreesToRadians(degrees: Degrees): Radians;
10
+ export declare function radiansToDegrees(degrees: Radians): Degrees;
11
+ /**
12
+ * Determines if the provided angle is a right angle.
13
+ *
14
+ * @param rads The angle to measure
15
+ * @returns TRUE if the provided angle is a right angle
16
+ */
17
+ export declare function isRightAngleRads(rads: Radians): boolean;
18
+ export declare function radiansBetweenAngles(a: Radians, min: Radians, max: Radians): boolean;
19
+ export declare function radiansDifference(a: Radians, b: Radians): Radians;
@@ -0,0 +1,3 @@
1
+ export declare const PRECISION = 0.0001;
2
+ export declare const LegendreGaussN24TValues: number[];
3
+ export declare const LegendreGaussN24CValues: number[];
@@ -0,0 +1,74 @@
1
+ import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
2
+ /**
3
+ *
4
+ * @param a
5
+ * @param b
6
+ * @param c
7
+ * @param d
8
+ * @returns
9
+ */
10
+ export declare function curve<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, c: Point, d: Point): Curve<Point>;
11
+ export declare const bezierEquation: <Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, t: number) => Point;
12
+ /**
13
+ * Computes the intersection between a cubic spline and a line segment.
14
+ */
15
+ export declare function curveIntersectLineSegment<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, l: LineSegment<Point>): Point[];
16
+ /**
17
+ * Finds the closest point on the Bezier curve from another point
18
+ *
19
+ * @param x
20
+ * @param y
21
+ * @param P0
22
+ * @param P1
23
+ * @param P2
24
+ * @param P3
25
+ * @param tolerance
26
+ * @param maxLevel
27
+ * @returns
28
+ */
29
+ export declare function curveClosestPoint<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): Point | null;
30
+ /**
31
+ * Determines the distance between a point and the closest point on the
32
+ * Bezier curve.
33
+ *
34
+ * @param c The curve to test
35
+ * @param p The point to measure from
36
+ */
37
+ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point): number;
38
+ /**
39
+ * Determines if the parameter is a Curve
40
+ */
41
+ export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
42
+ export declare function curveTangent<Point extends GlobalPoint | LocalPoint>([p0, p1, p2, p3]: Curve<Point>, t: number): import("./types").Vector;
43
+ export declare function curveCatmullRomQuadraticApproxPoints(points: GlobalPoint[], tension?: number): [GlobalPoint, GlobalPoint][] | undefined;
44
+ export declare function curveCatmullRomCubicApproxPoints<Point extends GlobalPoint | LocalPoint>(points: Point[], tension?: number): Curve<Point>[] | undefined;
45
+ export declare function curveOffsetPoints([p0, p1, p2, p3]: Curve<GlobalPoint>, offset: number, steps?: number): GlobalPoint[];
46
+ export declare function offsetPointsForQuadraticBezier(p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, offsetDist: number, steps?: number): GlobalPoint[];
47
+ /**
48
+ * Implementation based on Legendre-Gauss quadrature for more accurate arc
49
+ * length calculation.
50
+ *
51
+ * Reference: https://pomax.github.io/bezierinfo/#arclength
52
+ *
53
+ * @param c The curve to calculate the length of
54
+ * @returns The approximated length of the curve
55
+ */
56
+ export declare function curveLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>): number;
57
+ /**
58
+ * Calculates the curve length from t=0 to t=parameter using the same
59
+ * Legendre-Gauss quadrature method used in curveLength
60
+ *
61
+ * @param c The curve to calculate the partial length for
62
+ * @param t The parameter value (0 to 1) to calculate length up to
63
+ * @returns The length of the curve from beginning to parameter t
64
+ */
65
+ export declare function curveLengthAtParameter<P extends GlobalPoint | LocalPoint>(c: Curve<P>, t: number): number;
66
+ /**
67
+ * Calculates the point at a specific percentage of a curve's total length
68
+ * using binary search for improved efficiency and accuracy.
69
+ *
70
+ * @param c The curve to calculate point on
71
+ * @param percent A value between 0 and 1 representing the percentage of the curve's length
72
+ * @returns The point at the specified percentage of curve length
73
+ */
74
+ export declare function curvePointAtLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>, percent: number): 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[];
@@ -0,0 +1,13 @@
1
+ export * from "./angle";
2
+ export * from "./curve";
3
+ export * from "./ellipse";
4
+ export * from "./line";
5
+ export * from "./point";
6
+ export * from "./polygon";
7
+ export * from "./range";
8
+ export * from "./rectangle";
9
+ export * from "./segment";
10
+ export * from "./triangle";
11
+ export * from "./types";
12
+ export * from "./vector";
13
+ export * from "./utils";
@@ -0,0 +1,17 @@
1
+ import type { GlobalPoint, Line, LocalPoint } from "./types";
2
+ /**
3
+ * Create a line from two points.
4
+ *
5
+ * @param points The two points lying on the line
6
+ * @returns The line on which the points lie
7
+ */
8
+ export declare function line<P extends GlobalPoint | LocalPoint>(a: P, b: P): Line<P>;
9
+ /**
10
+ * Determines the intersection point (unless the lines are parallel) of two
11
+ * lines
12
+ *
13
+ * @param a
14
+ * @param b
15
+ * @returns
16
+ */
17
+ export declare function linesIntersectAt<Point extends GlobalPoint | LocalPoint>(a: Line<Point>, b: Line<Point>): Point | null;
@@ -0,0 +1,122 @@
1
+ import type { LocalPoint, GlobalPoint, Radians, Degrees, Vector } from "./types";
2
+ /**
3
+ * Create a properly typed Point instance from the X and Y coordinates.
4
+ *
5
+ * @param x The X coordinate
6
+ * @param y The Y coordinate
7
+ * @returns The branded and created point
8
+ */
9
+ export declare function pointFrom<Point extends GlobalPoint | LocalPoint>(x: number, y: number): Point;
10
+ /**
11
+ * Converts and remaps an array containing a pair of numbers to Point.
12
+ *
13
+ * @param numberArray The number array to check and to convert to Point
14
+ * @returns The point instance
15
+ */
16
+ export declare function pointFromArray<Point extends GlobalPoint | LocalPoint>(numberArray: number[]): Point | undefined;
17
+ /**
18
+ * Converts and remaps a pair of numbers to Point.
19
+ *
20
+ * @param pair A number pair to convert to Point
21
+ * @returns The point instance
22
+ */
23
+ export declare function pointFromPair<Point extends GlobalPoint | LocalPoint>(pair: [number, number]): Point;
24
+ /**
25
+ * Convert a vector to a point.
26
+ *
27
+ * @param v The vector to convert
28
+ * @returns The point the vector points at with origin 0,0
29
+ */
30
+ export declare function pointFromVector<P extends GlobalPoint | LocalPoint>(v: Vector, offset?: P): P;
31
+ /**
32
+ * Checks if the provided value has the shape of a Point.
33
+ *
34
+ * @param p The value to attempt verification on
35
+ * @returns TRUE if the provided value has the shape of a local or global point
36
+ */
37
+ export declare function isPoint(p: unknown): p is LocalPoint | GlobalPoint;
38
+ /**
39
+ * Compare two points coordinate-by-coordinate and if
40
+ * they are closer than INVERSE_PRECISION it returns TRUE.
41
+ *
42
+ * @param a Point The first point to compare
43
+ * @param b Point The second point to compare
44
+ * @returns TRUE if the points are sufficiently close to each other
45
+ */
46
+ export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, tolerance?: number): boolean;
47
+ /**
48
+ * Rotate a point by [angle] radians.
49
+ *
50
+ * @param point The point to rotate
51
+ * @param center The point to rotate around, the center point
52
+ * @param angle The radians to rotate the point by
53
+ * @returns The rotated point
54
+ */
55
+ export declare function pointRotateRads<Point extends GlobalPoint | LocalPoint>([x, y]: Point, [cx, cy]: Point, angle: Radians): Point;
56
+ /**
57
+ * Rotate a point by [angle] degree.
58
+ *
59
+ * @param point The point to rotate
60
+ * @param center The point to rotate around, the center point
61
+ * @param angle The degree to rotate the point by
62
+ * @returns The rotated point
63
+ */
64
+ export declare function pointRotateDegs<Point extends GlobalPoint | LocalPoint>(point: Point, center: Point, angle: Degrees): Point;
65
+ /**
66
+ * Translate a point by a vector.
67
+ *
68
+ * WARNING: This is not for translating Excalidraw element points!
69
+ * You need to account for rotation on base coordinates
70
+ * on your own.
71
+ * CONSIDER USING AN APPROPRIATE ELEMENT-AWARE TRANSLATE!
72
+ *
73
+ * @param p The point to apply the translation on
74
+ * @param v The vector to translate by
75
+ * @returns
76
+ */
77
+ export declare function pointTranslate<From extends GlobalPoint | LocalPoint, To extends GlobalPoint | LocalPoint>(p: From, v?: Vector): To;
78
+ /**
79
+ * Find the center point at equal distance from both points.
80
+ *
81
+ * @param a One of the points to create the middle point for
82
+ * @param b The other point to create the middle point for
83
+ * @returns The middle point
84
+ */
85
+ export declare function pointCenter<P extends LocalPoint | GlobalPoint>(a: P, b: P): P;
86
+ /**
87
+ * Calculate the distance between two points.
88
+ *
89
+ * @param a First point
90
+ * @param b Second point
91
+ * @returns The euclidean distance between the two points.
92
+ */
93
+ export declare function pointDistance<P extends LocalPoint | GlobalPoint>(a: P, b: P): number;
94
+ /**
95
+ * Calculate the squared distance between two points.
96
+ *
97
+ * Note: Use this if you only compare distances, it saves a square root.
98
+ *
99
+ * @param a First point
100
+ * @param b Second point
101
+ * @returns The euclidean distance between the two points.
102
+ */
103
+ export declare function pointDistanceSq<P extends LocalPoint | GlobalPoint>(a: P, b: P): number;
104
+ /**
105
+ * Scale a point from a given origin by the multiplier.
106
+ *
107
+ * @param p The point to scale
108
+ * @param mid The origin to scale from
109
+ * @param multiplier The scaling factor
110
+ * @returns
111
+ */
112
+ export declare const pointScaleFromOrigin: <P extends GlobalPoint | LocalPoint>(p: P, mid: P, multiplier: number) => GlobalPoint | LocalPoint;
113
+ /**
114
+ * Returns whether `q` lies inside the segment/rectangle defined by `p` and `r`.
115
+ * This is an approximation to "does `q` lie on a segment `pr`" check.
116
+ *
117
+ * @param p The first point to compare against
118
+ * @param q The actual point this function checks whether is in between
119
+ * @param r The other point to compare against
120
+ * @returns TRUE if q is indeed between p and r
121
+ */
122
+ export declare const isPointWithinBounds: <P extends GlobalPoint | LocalPoint>(p: P, q: P, r: P) => boolean;
@@ -0,0 +1,6 @@
1
+ import type { GlobalPoint, LocalPoint, Polygon } from "./types";
2
+ export declare function polygon<Point extends GlobalPoint | LocalPoint>(...points: Point[]): Polygon<Point>;
3
+ export declare function polygonFromPoints<Point extends GlobalPoint | LocalPoint>(points: Point[]): Polygon<Point>;
4
+ export declare const polygonIncludesPoint: <Point extends LocalPoint | GlobalPoint>(point: Point, polygon: Polygon<Point>) => boolean;
5
+ export declare const polygonIncludesPointNonZero: <Point extends [number, number]>(point: Point, polygon: Point[]) => boolean;
6
+ export declare const pointOnPolygon: <Point extends LocalPoint | GlobalPoint>(p: Point, poly: Polygon<Point>, threshold?: number) => boolean;
@@ -0,0 +1,44 @@
1
+ import type { InclusiveRange } from "./types";
2
+ /**
3
+ * Create an inclusive range from the two numbers provided.
4
+ *
5
+ * @param start Start of the range
6
+ * @param end End of the range
7
+ * @returns
8
+ */
9
+ export declare function rangeInclusive(start: number, end: number): InclusiveRange;
10
+ /**
11
+ * Turn a number pair into an inclusive range.
12
+ *
13
+ * @param pair The number pair to convert to an inclusive range
14
+ * @returns The new inclusive range
15
+ */
16
+ export declare function rangeInclusiveFromPair(pair: [start: number, end: number]): [number, number] & {
17
+ _brand: "excalimath_degree";
18
+ };
19
+ /**
20
+ * Given two ranges, return if the two ranges overlap with each other e.g.
21
+ * [1, 3] overlaps with [2, 4] while [1, 3] does not overlap with [4, 5].
22
+ *
23
+ * @param param0 One of the ranges to compare
24
+ * @param param1 The other range to compare against
25
+ * @returns TRUE if the ranges overlap
26
+ */
27
+ export declare const rangesOverlap: ([a0, a1]: InclusiveRange, [b0, b1]: InclusiveRange) => boolean;
28
+ /**
29
+ * Given two ranges,return ther intersection of the two ranges if any e.g. the
30
+ * intersection of [1, 3] and [2, 4] is [2, 3].
31
+ *
32
+ * @param param0 The first range to compare
33
+ * @param param1 The second range to compare
34
+ * @returns The inclusive range intersection or NULL if no intersection
35
+ */
36
+ export declare const rangeIntersection: ([a0, a1]: InclusiveRange, [b0, b1]: InclusiveRange) => InclusiveRange | null;
37
+ /**
38
+ * Determine if a value is inside a range.
39
+ *
40
+ * @param value The value to check
41
+ * @param range The range
42
+ * @returns
43
+ */
44
+ export declare const rangeIncludesValue: (value: number, [min, max]: InclusiveRange) => boolean;
@@ -0,0 +1,5 @@
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 rectangleFromNumberSequence<Point extends LocalPoint | GlobalPoint>(minX: number, minY: number, maxX: number, maxY: number): Rectangle<Point>;
4
+ export declare function rectangleIntersectLineSegment<Point extends LocalPoint | GlobalPoint>(r: Rectangle<Point>, l: LineSegment<Point>): Point[];
5
+ export declare function rectangleIntersectRectangle<Point extends LocalPoint | GlobalPoint>(rectangle1: Rectangle<Point>, rectangle2: Rectangle<Point>): boolean;
@@ -0,0 +1,40 @@
1
+ import type { GlobalPoint, LineSegment, LocalPoint, Radians } from "./types";
2
+ /**
3
+ * Create a line segment from two points.
4
+ *
5
+ * @param points The two points delimiting the line segment on each end
6
+ * @returns The line segment delineated by the points
7
+ */
8
+ export declare function lineSegment<P extends GlobalPoint | LocalPoint>(a: P, b: P): LineSegment<P>;
9
+ /**
10
+ *
11
+ * @param segment
12
+ * @returns
13
+ */
14
+ export declare const isLineSegment: <Point extends GlobalPoint | LocalPoint>(segment: unknown) => segment is LineSegment<Point>;
15
+ /**
16
+ * Return the coordinates resulting from rotating the given line about an origin by an angle in radians
17
+ * note that when the origin is not given, the midpoint of the given line is used as the origin.
18
+ *
19
+ * @param l
20
+ * @param angle
21
+ * @param origin
22
+ * @returns
23
+ */
24
+ export declare const lineSegmentRotate: <Point extends LocalPoint | GlobalPoint>(l: LineSegment<Point>, angle: Radians, origin?: Point) => LineSegment<Point>;
25
+ /**
26
+ * Calculates the point two line segments with a definite start and end point
27
+ * intersect at.
28
+ */
29
+ export declare const segmentsIntersectAt: <Point extends GlobalPoint | LocalPoint>(a: Readonly<LineSegment<Point>>, b: Readonly<LineSegment<Point>>) => Point | null;
30
+ export declare const pointOnLineSegment: <Point extends LocalPoint | GlobalPoint>(point: Point, line: LineSegment<Point>, threshold?: number) => boolean;
31
+ export declare const distanceToLineSegment: <Point extends LocalPoint | GlobalPoint>(point: Point, line: LineSegment<Point>) => number;
32
+ /**
33
+ * Returns the intersection point of a segment and a line
34
+ *
35
+ * @param l
36
+ * @param s
37
+ * @returns
38
+ */
39
+ export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point>, threshold?: number): Point | null;
40
+ export declare function lineSegmentsDistance<Point extends GlobalPoint | LocalPoint>(s1: LineSegment<Point>, s2: LineSegment<Point>): number;
@@ -0,0 +1,11 @@
1
+ import type { GlobalPoint, LocalPoint, Triangle } from "./types";
2
+ /**
3
+ * Tests if a point lies inside a triangle. This function
4
+ * will return FALSE if the point lies exactly on the sides
5
+ * of the triangle.
6
+ *
7
+ * @param triangle The triangle to test the point for
8
+ * @param p The point to test whether is in the triangle
9
+ * @returns TRUE if the point is inside of the triangle
10
+ */
11
+ export declare function triangleIncludesPoint<P extends GlobalPoint | LocalPoint>([a, b, c]: Triangle<P>, p: P): boolean;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * By definition one radian is the angle subtended at the centre
3
+ * of a circle by an arc that is equal in length to the radius.
4
+ */
5
+ export type Radians = number & {
6
+ _brand: "excalimath__radian";
7
+ };
8
+ /**
9
+ * An angle measurement of a plane angle in which one full
10
+ * rotation is 360 degrees.
11
+ */
12
+ export type Degrees = number & {
13
+ _brand: "excalimath_degree";
14
+ };
15
+ /**
16
+ * A number range which includes the start and end numbers in the range.
17
+ */
18
+ export type InclusiveRange = [number, number] & {
19
+ _brand: "excalimath_degree";
20
+ };
21
+ /**
22
+ * Represents a 2D position in world or canvas space. A
23
+ * global coordinate.
24
+ */
25
+ export type GlobalPoint = [x: number, y: number] & {
26
+ _brand: "excalimath__globalpoint";
27
+ };
28
+ /**
29
+ * Represents a 2D position in whatever local space it's
30
+ * needed. A local coordinate.
31
+ */
32
+ export type LocalPoint = [x: number, y: number] & {
33
+ _brand: "excalimath__localpoint";
34
+ };
35
+ /**
36
+ * A line is an infinitely long object with no width, depth, or curvature.
37
+ */
38
+ export type Line<P extends GlobalPoint | LocalPoint> = [p: P, q: P] & {
39
+ _brand: "excalimath_line";
40
+ };
41
+ /**
42
+ * In geometry, a line segment is a part of a straight
43
+ * line that is bounded by two distinct end points, and
44
+ * contains every point on the line that is between its endpoints.
45
+ */
46
+ export type LineSegment<P extends GlobalPoint | LocalPoint> = [a: P, b: P] & {
47
+ _brand: "excalimath_linesegment";
48
+ };
49
+ /**
50
+ * Represents a 2D vector
51
+ */
52
+ export type Vector = [u: number, v: number] & {
53
+ _brand: "excalimath__vector";
54
+ };
55
+ /**
56
+ * A triangle represented by 3 points
57
+ */
58
+ export type Triangle<P extends GlobalPoint | LocalPoint> = [
59
+ a: P,
60
+ b: P,
61
+ c: P
62
+ ] & {
63
+ _brand: "excalimath__triangle";
64
+ };
65
+ /**
66
+ * A rectangular shape represented by 4 points at its corners
67
+ */
68
+ export type Rectangle<P extends GlobalPoint | LocalPoint> = [a: P, b: P] & {
69
+ _brand: "excalimath__rectangle";
70
+ };
71
+ /**
72
+ * A polygon is a closed shape by connecting the given points
73
+ * rectangles and diamonds are modelled by polygons
74
+ */
75
+ export type Polygon<Point extends GlobalPoint | LocalPoint> = Point[] & {
76
+ _brand: "excalimath_polygon";
77
+ };
78
+ /**
79
+ * Cubic bezier curve with four control points
80
+ */
81
+ export type Curve<Point extends GlobalPoint | LocalPoint> = [
82
+ Point,
83
+ Point,
84
+ Point,
85
+ Point
86
+ ] & {
87
+ _brand: "excalimath_curve";
88
+ };
89
+ export type PolarCoords = [
90
+ radius: number,
91
+ /** angle in radians */
92
+ angle: number
93
+ ];
94
+ /**
95
+ An ellipse is specified by its center, angle, and its major and minor axes
96
+ but for the sake of simplicity, we've used halfWidth and halfHeight instead
97
+ in replace of semi major and semi minor axes
98
+ */
99
+ export type Ellipse<Point extends GlobalPoint | LocalPoint> = {
100
+ center: Point;
101
+ halfWidth: number;
102
+ halfHeight: number;
103
+ } & {
104
+ _brand: "excalimath_ellipse";
105
+ };
106
+ export type ElementsSegmentsMap = Map<string, LineSegment<GlobalPoint>[]>;
@@ -0,0 +1,7 @@
1
+ export declare const PRECISION = 0.0001;
2
+ export declare const clamp: (value: number, min: number, max: number) => number;
3
+ export declare const round: (value: number, precision: number, func?: "round" | "floor" | "ceil") => number;
4
+ export declare const roundToStep: (value: number, step: number, func?: "round" | "floor" | "ceil") => number;
5
+ export declare const average: (a: number, b: number) => number;
6
+ export declare const isFiniteNumber: (value: any) => value is number;
7
+ export declare const isCloseTo: (a: number, b: number, precision?: number) => boolean;