@avis-studio/engine 0.0.0-stage → 0.1.0-beta.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 (424) hide show
  1. package/README.md +193 -2
  2. package/THIRD_PARTY_NOTICES.md +29 -0
  3. package/dist/a11y/focus.d.ts +60 -0
  4. package/dist/a11y/focus.js +222 -0
  5. package/dist/a11y/index.d.ts +2 -0
  6. package/dist/a11y/index.js +4 -0
  7. package/dist/a11y/semantics.d.ts +37 -0
  8. package/dist/a11y/semantics.js +88 -0
  9. package/dist/commands/builtins.d.ts +88 -0
  10. package/dist/commands/builtins.js +362 -0
  11. package/dist/commands/command.d.ts +23 -0
  12. package/dist/commands/command.js +20 -0
  13. package/dist/commands/draft.d.ts +33 -0
  14. package/dist/commands/draft.js +96 -0
  15. package/dist/commands/history.d.ts +34 -0
  16. package/dist/commands/history.js +80 -0
  17. package/dist/commands/index.d.ts +6 -0
  18. package/dist/commands/index.js +6 -0
  19. package/dist/commands/patch.d.ts +24 -0
  20. package/dist/commands/patch.js +44 -0
  21. package/dist/commands/transaction.d.ts +16 -0
  22. package/dist/commands/transaction.js +39 -0
  23. package/dist/core/diagnostics.d.ts +23 -0
  24. package/dist/core/diagnostics.js +23 -0
  25. package/dist/core/disposable.d.ts +14 -0
  26. package/dist/core/disposable.js +51 -0
  27. package/dist/core/engine.d.ts +108 -0
  28. package/dist/core/engine.js +323 -0
  29. package/dist/core/event-bus.d.ts +10 -0
  30. package/dist/core/event-bus.js +33 -0
  31. package/dist/core/ids.d.ts +13 -0
  32. package/dist/core/ids.js +6 -0
  33. package/dist/core/index.d.ts +7 -0
  34. package/dist/core/index.js +7 -0
  35. package/dist/core/plugin.d.ts +20 -0
  36. package/dist/core/plugin.js +47 -0
  37. package/dist/core/services.d.ts +14 -0
  38. package/dist/core/services.js +20 -0
  39. package/dist/devtools/index.d.ts +1 -0
  40. package/dist/devtools/index.js +2 -0
  41. package/dist/devtools/panel.d.ts +39 -0
  42. package/dist/devtools/panel.js +100 -0
  43. package/dist/dom/a11y-layer.d.ts +32 -0
  44. package/dist/dom/a11y-layer.js +358 -0
  45. package/dist/dom/anchor.d.ts +34 -0
  46. package/dist/dom/anchor.js +35 -0
  47. package/dist/dom/index.d.ts +6 -0
  48. package/dist/dom/index.js +8 -0
  49. package/dist/dom/menu.d.ts +24 -0
  50. package/dist/dom/menu.js +122 -0
  51. package/dist/dom/overlays.d.ts +29 -0
  52. package/dist/dom/overlays.js +82 -0
  53. package/dist/dom/paint/collect.d.ts +8 -0
  54. package/dist/dom/paint/collect.js +589 -0
  55. package/dist/dom/paint/css.d.ts +86 -0
  56. package/dist/dom/paint/css.js +526 -0
  57. package/dist/dom/paint/draw.d.ts +16 -0
  58. package/dist/dom/paint/draw.js +413 -0
  59. package/dist/dom/paint/ghost.d.ts +2 -0
  60. package/dist/dom/paint/ghost.js +8 -0
  61. package/dist/dom/paint/index.d.ts +6 -0
  62. package/dist/dom/paint/index.js +9 -0
  63. package/dist/dom/paint/text.d.ts +26 -0
  64. package/dist/dom/paint/text.js +209 -0
  65. package/dist/dom/paint/types.d.ts +174 -0
  66. package/dist/dom/paint/types.js +7 -0
  67. package/dist/dom/paint/watch.d.ts +10 -0
  68. package/dist/dom/paint/watch.js +109 -0
  69. package/dist/dom/position.d.ts +37 -0
  70. package/dist/dom/position.js +125 -0
  71. package/dist/dom/text-editor.d.ts +27 -0
  72. package/dist/dom/text-editor.js +128 -0
  73. package/dist/events/event.d.ts +122 -0
  74. package/dist/events/event.js +130 -0
  75. package/dist/events/eventer.d.ts +24 -0
  76. package/dist/events/eventer.js +83 -0
  77. package/dist/events/index.d.ts +3 -0
  78. package/dist/events/index.js +3 -0
  79. package/dist/events/interaction.d.ts +43 -0
  80. package/dist/events/interaction.js +203 -0
  81. package/dist/geometry/anchors.d.ts +14 -0
  82. package/dist/geometry/anchors.js +13 -0
  83. package/dist/geometry/bounds.d.ts +16 -0
  84. package/dist/geometry/bounds.js +42 -0
  85. package/dist/geometry/curves.d.ts +39 -0
  86. package/dist/geometry/curves.js +68 -0
  87. package/dist/geometry/index.d.ts +6 -0
  88. package/dist/geometry/index.js +6 -0
  89. package/dist/geometry/matrix.d.ts +22 -0
  90. package/dist/geometry/matrix.js +56 -0
  91. package/dist/geometry/spaces.d.ts +22 -0
  92. package/dist/geometry/spaces.js +28 -0
  93. package/dist/geometry/vec2.d.ts +12 -0
  94. package/dist/geometry/vec2.js +10 -0
  95. package/dist/index.d.ts +16 -0
  96. package/dist/index.js +22 -0
  97. package/dist/interaction/behaviors.d.ts +10 -0
  98. package/dist/interaction/behaviors.js +744 -0
  99. package/dist/interaction/controller.d.ts +180 -0
  100. package/dist/interaction/controller.js +269 -0
  101. package/dist/interaction/hit-test.d.ts +45 -0
  102. package/dist/interaction/hit-test.js +119 -0
  103. package/dist/interaction/index.d.ts +4 -0
  104. package/dist/interaction/index.js +7 -0
  105. package/dist/interaction/web-input.d.ts +13 -0
  106. package/dist/interaction/web-input.js +172 -0
  107. package/dist/layout/index.d.ts +1 -0
  108. package/dist/layout/index.js +2 -0
  109. package/dist/layout/layout.d.ts +27 -0
  110. package/dist/layout/layout.js +266 -0
  111. package/dist/react/canvas/graph.d.ts +83 -0
  112. package/dist/react/canvas/graph.js +89 -0
  113. package/dist/react/canvas/hooks.d.ts +42 -0
  114. package/dist/react/canvas/hooks.js +78 -0
  115. package/dist/react/canvas/index.d.ts +35 -0
  116. package/dist/react/canvas/index.js +8 -0
  117. package/dist/react/components.d.ts +55 -0
  118. package/dist/react/components.js +197 -0
  119. package/dist/react/context.d.ts +4 -0
  120. package/dist/react/context.js +9 -0
  121. package/dist/react/flow/api/LICENSE +21 -0
  122. package/dist/react/flow/api/externals.d.ts +12 -0
  123. package/dist/react/flow/api/react/additional-components/Background/Background.d.ts +7 -0
  124. package/dist/react/flow/api/react/additional-components/Background/Patterns.d.ts +17 -0
  125. package/dist/react/flow/api/react/additional-components/Background/index.d.ts +2 -0
  126. package/dist/react/flow/api/react/additional-components/Background/types.d.ts +25 -0
  127. package/dist/react/flow/api/react/additional-components/Controls/ControlButton.d.ts +2 -0
  128. package/dist/react/flow/api/react/additional-components/Controls/Controls.d.ts +7 -0
  129. package/dist/react/flow/api/react/additional-components/Controls/Icons/FitView.d.ts +1 -0
  130. package/dist/react/flow/api/react/additional-components/Controls/Icons/Lock.d.ts +1 -0
  131. package/dist/react/flow/api/react/additional-components/Controls/Icons/Minus.d.ts +1 -0
  132. package/dist/react/flow/api/react/additional-components/Controls/Icons/Plus.d.ts +1 -0
  133. package/dist/react/flow/api/react/additional-components/Controls/Icons/Unlock.d.ts +1 -0
  134. package/dist/react/flow/api/react/additional-components/Controls/index.d.ts +3 -0
  135. package/dist/react/flow/api/react/additional-components/Controls/types.d.ts +20 -0
  136. package/dist/react/flow/api/react/additional-components/EdgeToolbar/EdgeToolbar.d.ts +2 -0
  137. package/dist/react/flow/api/react/additional-components/EdgeToolbar/index.d.ts +2 -0
  138. package/dist/react/flow/api/react/additional-components/EdgeToolbar/types.d.ts +6 -0
  139. package/dist/react/flow/api/react/additional-components/MiniMap/MiniMap.d.ts +8 -0
  140. package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNode.d.ts +4 -0
  141. package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNodes.d.ts +5 -0
  142. package/dist/react/flow/api/react/additional-components/MiniMap/index.d.ts +3 -0
  143. package/dist/react/flow/api/react/additional-components/MiniMap/types.d.ts +44 -0
  144. package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizeControl.d.ts +5 -0
  145. package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizer.d.ts +2 -0
  146. package/dist/react/flow/api/react/additional-components/NodeResizer/index.d.ts +3 -0
  147. package/dist/react/flow/api/react/additional-components/NodeResizer/types.d.ts +32 -0
  148. package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbar.d.ts +2 -0
  149. package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbarPortal.d.ts +4 -0
  150. package/dist/react/flow/api/react/additional-components/NodeToolbar/index.d.ts +2 -0
  151. package/dist/react/flow/api/react/additional-components/NodeToolbar/types.d.ts +9 -0
  152. package/dist/react/flow/api/react/additional-components/index.d.ts +6 -0
  153. package/dist/react/flow/api/react/components/A11yDescriptions/index.d.ts +7 -0
  154. package/dist/react/flow/api/react/components/Attribution/index.d.ts +8 -0
  155. package/dist/react/flow/api/react/components/BatchProvider/index.d.ts +10 -0
  156. package/dist/react/flow/api/react/components/BatchProvider/types.d.ts +6 -0
  157. package/dist/react/flow/api/react/components/BatchProvider/useQueue.d.ts +2 -0
  158. package/dist/react/flow/api/react/components/ConnectionLine/index.d.ts +11 -0
  159. package/dist/react/flow/api/react/components/EdgeLabelRenderer/index.d.ts +5 -0
  160. package/dist/react/flow/api/react/components/EdgeWrapper/EdgeUpdateAnchors.d.ts +14 -0
  161. package/dist/react/flow/api/react/components/EdgeWrapper/index.d.ts +5 -0
  162. package/dist/react/flow/api/react/components/EdgeWrapper/utils.d.ts +11 -0
  163. package/dist/react/flow/api/react/components/Edges/BaseEdge.d.ts +2 -0
  164. package/dist/react/flow/api/react/components/Edges/BezierEdge.d.ts +4 -0
  165. package/dist/react/flow/api/react/components/Edges/EdgeAnchor.d.ts +13 -0
  166. package/dist/react/flow/api/react/components/Edges/EdgeText.d.ts +7 -0
  167. package/dist/react/flow/api/react/components/Edges/SimpleBezierEdge.d.ts +20 -0
  168. package/dist/react/flow/api/react/components/Edges/SmoothStepEdge.d.ts +4 -0
  169. package/dist/react/flow/api/react/components/Edges/StepEdge.d.ts +4 -0
  170. package/dist/react/flow/api/react/components/Edges/StraightEdge.d.ts +4 -0
  171. package/dist/react/flow/api/react/components/Edges/index.d.ts +5 -0
  172. package/dist/react/flow/api/react/components/Handle/index.d.ts +8 -0
  173. package/dist/react/flow/api/react/components/NodeWrapper/index.d.ts +4 -0
  174. package/dist/react/flow/api/react/components/NodeWrapper/useNodeObserver.d.ts +7 -0
  175. package/dist/react/flow/api/react/components/NodeWrapper/utils.d.ts +8 -0
  176. package/dist/react/flow/api/react/components/Nodes/DefaultNode.d.ts +2 -0
  177. package/dist/react/flow/api/react/components/Nodes/GroupNode.d.ts +1 -0
  178. package/dist/react/flow/api/react/components/Nodes/InputNode.d.ts +2 -0
  179. package/dist/react/flow/api/react/components/Nodes/OutputNode.d.ts +2 -0
  180. package/dist/react/flow/api/react/components/Nodes/utils.d.ts +12 -0
  181. package/dist/react/flow/api/react/components/NodesSelection/index.d.ts +8 -0
  182. package/dist/react/flow/api/react/components/Panel/index.d.ts +8 -0
  183. package/dist/react/flow/api/react/components/ReactFlowProvider/index.d.ts +20 -0
  184. package/dist/react/flow/api/react/components/SelectionListener/index.d.ts +6 -0
  185. package/dist/react/flow/api/react/components/StoreUpdater/index.d.ts +67 -0
  186. package/dist/react/flow/api/react/components/UserSelection/index.d.ts +1 -0
  187. package/dist/react/flow/api/react/components/ViewportPortal/index.d.ts +4 -0
  188. package/dist/react/flow/api/react/container/EdgeRenderer/MarkerDefinitions.d.ts +9 -0
  189. package/dist/react/flow/api/react/container/EdgeRenderer/MarkerSymbols.d.ts +8 -0
  190. package/dist/react/flow/api/react/container/EdgeRenderer/index.d.ts +12 -0
  191. package/dist/react/flow/api/react/container/FlowRenderer/index.d.ts +13 -0
  192. package/dist/react/flow/api/react/container/GraphView/index.d.ts +10 -0
  193. package/dist/react/flow/api/react/container/GraphView/useNodeOrEdgeTypesWarning.d.ts +3 -0
  194. package/dist/react/flow/api/react/container/GraphView/useStylesLoadedWarning.d.ts +1 -0
  195. package/dist/react/flow/api/react/container/NodeRenderer/index.d.ts +9 -0
  196. package/dist/react/flow/api/react/container/NodeRenderer/useResizeObserver.d.ts +1 -0
  197. package/dist/react/flow/api/react/container/Pane/index.d.ts +10 -0
  198. package/dist/react/flow/api/react/container/ReactFlow/Wrapper.d.ts +19 -0
  199. package/dist/react/flow/api/react/container/ReactFlow/index.d.ts +3 -0
  200. package/dist/react/flow/api/react/container/ReactFlow/init-values.d.ts +3 -0
  201. package/dist/react/flow/api/react/container/Viewport/index.d.ts +6 -0
  202. package/dist/react/flow/api/react/container/ZoomPane/index.d.ts +7 -0
  203. package/dist/react/flow/api/react/contexts/HandleConfigContext.d.ts +11 -0
  204. package/dist/react/flow/api/react/contexts/NodeIdContext.d.ts +5 -0
  205. package/dist/react/flow/api/react/contexts/StoreContext.d.ts +3 -0
  206. package/dist/react/flow/api/react/hooks/useColorModeClass.d.ts +2 -0
  207. package/dist/react/flow/api/react/hooks/useConnection.d.ts +3 -0
  208. package/dist/react/flow/api/react/hooks/useDrag.d.ts +12 -0
  209. package/dist/react/flow/api/react/hooks/useEdges.d.ts +2 -0
  210. package/dist/react/flow/api/react/hooks/useGlobalKeyHandler.d.ts +5 -0
  211. package/dist/react/flow/api/react/hooks/useHandleConnections.d.ts +10 -0
  212. package/dist/react/flow/api/react/hooks/useInternalNode.d.ts +2 -0
  213. package/dist/react/flow/api/react/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
  214. package/dist/react/flow/api/react/hooks/useKeyPress.d.ts +7 -0
  215. package/dist/react/flow/api/react/hooks/useMoveSelectedNodes.d.ts +5 -0
  216. package/dist/react/flow/api/react/hooks/useNodeConnections.d.ts +2 -0
  217. package/dist/react/flow/api/react/hooks/useNodes.d.ts +2 -0
  218. package/dist/react/flow/api/react/hooks/useNodesData.d.ts +4 -0
  219. package/dist/react/flow/api/react/hooks/useNodesEdgesState.d.ts +12 -0
  220. package/dist/react/flow/api/react/hooks/useNodesInitialized.d.ts +4 -0
  221. package/dist/react/flow/api/react/hooks/useOnEdgesChangeMiddleware.d.ts +3 -0
  222. package/dist/react/flow/api/react/hooks/useOnInitHandler.d.ts +2 -0
  223. package/dist/react/flow/api/react/hooks/useOnNodesChangeMiddleware.d.ts +3 -0
  224. package/dist/react/flow/api/react/hooks/useOnSelectionChange.d.ts +5 -0
  225. package/dist/react/flow/api/react/hooks/useOnViewportChange.d.ts +7 -0
  226. package/dist/react/flow/api/react/hooks/useReactFlow.d.ts +2 -0
  227. package/dist/react/flow/api/react/hooks/useResizeHandler.d.ts +2 -0
  228. package/dist/react/flow/api/react/hooks/useStore.d.ts +8 -0
  229. package/dist/react/flow/api/react/hooks/useUpdateNodeInternals.d.ts +2 -0
  230. package/dist/react/flow/api/react/hooks/useViewport.d.ts +2 -0
  231. package/dist/react/flow/api/react/hooks/useViewportHelper.d.ts +3 -0
  232. package/dist/react/flow/api/react/hooks/useViewportSync.d.ts +2 -0
  233. package/dist/react/flow/api/react/hooks/useVisibleEdgeIds.d.ts +1 -0
  234. package/dist/react/flow/api/react/hooks/useVisibleNodeIds.d.ts +1 -0
  235. package/dist/react/flow/api/react/index.d.ts +41 -0
  236. package/dist/react/flow/api/react/store/index.d.ts +18 -0
  237. package/dist/react/flow/api/react/store/initialState.d.ts +18 -0
  238. package/dist/react/flow/api/react/styles/utils.d.ts +2 -0
  239. package/dist/react/flow/api/react/types/component-props.d.ts +127 -0
  240. package/dist/react/flow/api/react/types/edges.d.ts +111 -0
  241. package/dist/react/flow/api/react/types/general.d.ts +53 -0
  242. package/dist/react/flow/api/react/types/index.d.ts +6 -0
  243. package/dist/react/flow/api/react/types/instance.d.ts +64 -0
  244. package/dist/react/flow/api/react/types/nodes.d.ts +41 -0
  245. package/dist/react/flow/api/react/types/store.d.ts +114 -0
  246. package/dist/react/flow/api/react/utils/changes.d.ts +15 -0
  247. package/dist/react/flow/api/react/utils/edges.d.ts +3 -0
  248. package/dist/react/flow/api/react/utils/general.d.ts +5 -0
  249. package/dist/react/flow/api/react/utils/index.d.ts +3 -0
  250. package/dist/react/flow/api/system/constants.d.ts +43 -0
  251. package/dist/react/flow/api/system/index.d.ts +8 -0
  252. package/dist/react/flow/api/system/types/changes.d.ts +48 -0
  253. package/dist/react/flow/api/system/types/edges.d.ts +72 -0
  254. package/dist/react/flow/api/system/types/general.d.ts +175 -0
  255. package/dist/react/flow/api/system/types/handles.d.ts +21 -0
  256. package/dist/react/flow/api/system/types/index.d.ts +7 -0
  257. package/dist/react/flow/api/system/types/nodes.d.ts +89 -0
  258. package/dist/react/flow/api/system/types/panzoom.d.ts +58 -0
  259. package/dist/react/flow/api/system/types/utils.d.ts +46 -0
  260. package/dist/react/flow/api/system/utils/attribution.d.ts +1 -0
  261. package/dist/react/flow/api/system/utils/connections.d.ts +4 -0
  262. package/dist/react/flow/api/system/utils/dom.d.ts +20 -0
  263. package/dist/react/flow/api/system/utils/edge-toolbar.d.ts +1 -0
  264. package/dist/react/flow/api/system/utils/edges/bezier-edge.d.ts +40 -0
  265. package/dist/react/flow/api/system/utils/edges/general.d.ts +44 -0
  266. package/dist/react/flow/api/system/utils/edges/index.d.ts +5 -0
  267. package/dist/react/flow/api/system/utils/edges/positions.d.ts +16 -0
  268. package/dist/react/flow/api/system/utils/edges/smoothstep-edge.d.ts +21 -0
  269. package/dist/react/flow/api/system/utils/edges/straight-edge.d.ts +13 -0
  270. package/dist/react/flow/api/system/utils/general.d.ts +56 -0
  271. package/dist/react/flow/api/system/utils/graph.d.ts +45 -0
  272. package/dist/react/flow/api/system/utils/index.d.ts +12 -0
  273. package/dist/react/flow/api/system/utils/marker.d.ts +8 -0
  274. package/dist/react/flow/api/system/utils/node-toolbar.d.ts +2 -0
  275. package/dist/react/flow/api/system/utils/shallow-node-data.d.ts +4 -0
  276. package/dist/react/flow/api/system/utils/store.d.ts +33 -0
  277. package/dist/react/flow/api/system/utils/types.d.ts +7 -0
  278. package/dist/react/flow/api/system/xydrag/XYDrag.d.ts +56 -0
  279. package/dist/react/flow/api/system/xydrag/index.d.ts +1 -0
  280. package/dist/react/flow/api/system/xydrag/utils.d.ts +22 -0
  281. package/dist/react/flow/api/system/xyhandle/XYHandle.d.ts +2 -0
  282. package/dist/react/flow/api/system/xyhandle/index.d.ts +1 -0
  283. package/dist/react/flow/api/system/xyhandle/types.d.ts +49 -0
  284. package/dist/react/flow/api/system/xyhandle/utils.d.ts +9 -0
  285. package/dist/react/flow/api/system/xyminimap/index.d.ts +27 -0
  286. package/dist/react/flow/api/system/xypanzoom/XYPanZoom.d.ts +11 -0
  287. package/dist/react/flow/api/system/xypanzoom/eventhandler.d.ts +45 -0
  288. package/dist/react/flow/api/system/xypanzoom/filter.d.ts +15 -0
  289. package/dist/react/flow/api/system/xypanzoom/index.d.ts +1 -0
  290. package/dist/react/flow/api/system/xypanzoom/utils.d.ts +8 -0
  291. package/dist/react/flow/api/system/xyresizer/XYResizer.d.ts +51 -0
  292. package/dist/react/flow/api/system/xyresizer/index.d.ts +2 -0
  293. package/dist/react/flow/api/system/xyresizer/types.d.ts +26 -0
  294. package/dist/react/flow/api/system/xyresizer/utils.d.ts +41 -0
  295. package/dist/react/flow/components.d.ts +148 -0
  296. package/dist/react/flow/components.js +526 -0
  297. package/dist/react/flow/configuration.d.ts +6 -0
  298. package/dist/react/flow/configuration.js +27 -0
  299. package/dist/react/flow/drag.d.ts +14 -0
  300. package/dist/react/flow/drag.js +273 -0
  301. package/dist/react/flow/extras.d.ts +155 -0
  302. package/dist/react/flow/extras.js +317 -0
  303. package/dist/react/flow/handle.d.ts +21 -0
  304. package/dist/react/flow/handle.js +149 -0
  305. package/dist/react/flow/hooks.d.ts +47 -0
  306. package/dist/react/flow/hooks.js +131 -0
  307. package/dist/react/flow/index.d.ts +78 -0
  308. package/dist/react/flow/index.js +73 -0
  309. package/dist/react/flow/queries.d.ts +20 -0
  310. package/dist/react/flow/queries.js +30 -0
  311. package/dist/react/flow/react-flow.d.ts +73 -0
  312. package/dist/react/flow/react-flow.js +1445 -0
  313. package/dist/react/flow/resize.d.ts +30 -0
  314. package/dist/react/flow/resize.js +49 -0
  315. package/dist/react/flow/store.d.ts +412 -0
  316. package/dist/react/flow/store.js +713 -0
  317. package/dist/react/flow/style.css +630 -0
  318. package/dist/react/flow/style.css.d.ts +2 -0
  319. package/dist/react/flow/system.d.ts +146 -0
  320. package/dist/react/flow/system.js +300 -0
  321. package/dist/react/flow/types.d.ts +131 -0
  322. package/dist/react/flow/types.js +1 -0
  323. package/dist/react/flow/utils.d.ts +77 -0
  324. package/dist/react/flow/utils.js +285 -0
  325. package/dist/react/hooks.d.ts +14 -0
  326. package/dist/react/hooks.js +44 -0
  327. package/dist/react/index.d.ts +3 -0
  328. package/dist/react/index.js +5 -0
  329. package/dist/render/backend.d.ts +26 -0
  330. package/dist/render/backend.js +5 -0
  331. package/dist/render/canvas2d/backend.d.ts +7 -0
  332. package/dist/render/canvas2d/backend.js +122 -0
  333. package/dist/render/canvas2d/index.d.ts +1 -0
  334. package/dist/render/canvas2d/index.js +2 -0
  335. package/dist/render/color.d.ts +9 -0
  336. package/dist/render/color.js +69 -0
  337. package/dist/render/commands.d.ts +69 -0
  338. package/dist/render/commands.js +1 -0
  339. package/dist/render/display-list.d.ts +65 -0
  340. package/dist/render/display-list.js +316 -0
  341. package/dist/render/images.d.ts +35 -0
  342. package/dist/render/images.js +83 -0
  343. package/dist/render/index.d.ts +14 -0
  344. package/dist/render/index.js +16 -0
  345. package/dist/render/painters.d.ts +35 -0
  346. package/dist/render/painters.js +109 -0
  347. package/dist/render/renderer.d.ts +70 -0
  348. package/dist/render/renderer.js +162 -0
  349. package/dist/render/scene-index.d.ts +21 -0
  350. package/dist/render/scene-index.js +64 -0
  351. package/dist/render/text.d.ts +8 -0
  352. package/dist/render/text.js +100 -0
  353. package/dist/render/theme.d.ts +21 -0
  354. package/dist/render/theme.js +33 -0
  355. package/dist/render/ui.d.ts +63 -0
  356. package/dist/render/ui.js +188 -0
  357. package/dist/render/webgl2/atlas.d.ts +36 -0
  358. package/dist/render/webgl2/atlas.js +93 -0
  359. package/dist/render/webgl2/backend.d.ts +19 -0
  360. package/dist/render/webgl2/backend.js +338 -0
  361. package/dist/render/webgl2/index.d.ts +2 -0
  362. package/dist/render/webgl2/index.js +3 -0
  363. package/dist/render/webgl2/shaders.d.ts +6 -0
  364. package/dist/render/webgl2/shaders.js +112 -0
  365. package/dist/render/webgpu/index.d.ts +1 -0
  366. package/dist/render/webgpu/index.js +3 -0
  367. package/dist/scene/builtins.d.ts +25 -0
  368. package/dist/scene/builtins.js +60 -0
  369. package/dist/scene/dirty.d.ts +11 -0
  370. package/dist/scene/dirty.js +10 -0
  371. package/dist/scene/index.d.ts +5 -0
  372. package/dist/scene/index.js +5 -0
  373. package/dist/scene/record.d.ts +40 -0
  374. package/dist/scene/record.js +12 -0
  375. package/dist/scene/scene-graph.d.ts +58 -0
  376. package/dist/scene/scene-graph.js +178 -0
  377. package/dist/scene/schema.d.ts +27 -0
  378. package/dist/scene/schema.js +32 -0
  379. package/dist/sdk/create-avis.d.ts +109 -0
  380. package/dist/sdk/create-avis.js +162 -0
  381. package/dist/sdk/index.d.ts +1 -0
  382. package/dist/sdk/index.js +2 -0
  383. package/dist/serialization/format.d.ts +46 -0
  384. package/dist/serialization/format.js +20 -0
  385. package/dist/serialization/index.d.ts +3 -0
  386. package/dist/serialization/index.js +3 -0
  387. package/dist/serialization/migrate.d.ts +7 -0
  388. package/dist/serialization/migrate.js +54 -0
  389. package/dist/serialization/serialize.d.ts +10 -0
  390. package/dist/serialization/serialize.js +114 -0
  391. package/dist/state/index.d.ts +2 -0
  392. package/dist/state/index.js +2 -0
  393. package/dist/state/selector.d.ts +6 -0
  394. package/dist/state/selector.js +29 -0
  395. package/dist/state/store.d.ts +91 -0
  396. package/dist/state/store.js +102 -0
  397. package/dist/style/computed.d.ts +84 -0
  398. package/dist/style/computed.js +296 -0
  399. package/dist/style/index.d.ts +6 -0
  400. package/dist/style/index.js +8 -0
  401. package/dist/style/style-engine.d.ts +33 -0
  402. package/dist/style/style-engine.js +113 -0
  403. package/dist/style/tokens.d.ts +49 -0
  404. package/dist/style/tokens.js +142 -0
  405. package/dist/style/utilities.d.ts +34 -0
  406. package/dist/style/utilities.js +341 -0
  407. package/dist/style/values.d.ts +30 -0
  408. package/dist/style/values.js +361 -0
  409. package/dist/style/variants.d.ts +38 -0
  410. package/dist/style/variants.js +55 -0
  411. package/dist/sync/index.d.ts +2 -0
  412. package/dist/sync/index.js +1 -0
  413. package/dist/sync/save-queue.d.ts +24 -0
  414. package/dist/sync/save-queue.js +88 -0
  415. package/dist/wasm/index.d.ts +2 -0
  416. package/dist/wasm/index.js +2 -0
  417. package/dist/wasm/load.d.ts +7 -0
  418. package/dist/wasm/load.js +47 -0
  419. package/dist/wasm/pkg/avis_engine_wasm.d.ts +84 -0
  420. package/dist/wasm/pkg/avis_engine_wasm.js +339 -0
  421. package/dist/wasm/pkg/avis_engine_wasm_bg.wasm +0 -0
  422. package/dist/wasm/reference.d.ts +38 -0
  423. package/dist/wasm/reference.js +174 -0
  424. package/package.json +76 -4
@@ -0,0 +1,146 @@
1
+ import type { Connection, FlowNode, HandleBox, InternalNode, Rect, Transform, XY } from "./types.js";
2
+ export type ConnectionState = {
3
+ inProgress: boolean;
4
+ isValid: boolean | null;
5
+ from: XY | null;
6
+ fromHandle: (HandleBox & {
7
+ nodeId: string;
8
+ }) | null;
9
+ fromPosition: string | null;
10
+ fromNode: InternalNode | null;
11
+ to: XY | null;
12
+ toHandle: (HandleBox & {
13
+ nodeId: string;
14
+ }) | null;
15
+ toPosition: string | null;
16
+ toNode: InternalNode | null;
17
+ pointer: XY | null;
18
+ };
19
+ export declare const initialConnection: ConnectionState;
20
+ export declare const oppositePosition: Record<string, string>;
21
+ export declare const getConnectionStatus: (isValid: boolean | null) => "valid" | "invalid" | null;
22
+ export declare const getEventPosition: (event: MouseEvent | TouchEvent, bounds?: {
23
+ left: number;
24
+ top: number;
25
+ } | null) => XY;
26
+ export declare const snapPosition: (position: XY, snapGrid?: [number, number]) => XY;
27
+ export declare const pointToRendererPoint: ({ x, y }: XY, [tx, ty, scale]: Transform, snapToGrid?: boolean, snapGrid?: [number, number]) => XY;
28
+ export declare const rendererPointToPoint: ({ x, y }: XY, [tx, ty, scale]: Transform) => XY;
29
+ export declare function getPointerPosition(event: MouseEvent | TouchEvent, { snapGrid, snapToGrid, transform, containerBounds }: {
30
+ snapGrid?: [number, number];
31
+ snapToGrid?: boolean;
32
+ transform: Transform;
33
+ containerBounds: DOMRect | null;
34
+ }): {
35
+ x: number;
36
+ y: number;
37
+ xSnapped: number;
38
+ ySnapped: number;
39
+ };
40
+ export declare const calcAutoPan: (pos: XY, bounds: {
41
+ width: number;
42
+ height: number;
43
+ }, speed?: number, distance?: number) => [number, number];
44
+ export declare const getOverlappingArea: (a: Rect, b: Rect) => number;
45
+ export declare const nodeDimensions: (node: InternalNode | FlowNode) => {
46
+ width: number;
47
+ height: number;
48
+ };
49
+ export declare const nodeToRect: (node: InternalNode) => Rect;
50
+ /** xyflow's getNodesInside: nodes in a screen rect (fully, or partly when `partially`). */
51
+ export declare function getNodesInside(nodes: Map<string, InternalNode>, rect: Rect, [tx, ty, scale]?: Transform, partially?: boolean, excludeNonSelectableNodes?: boolean): InternalNode[];
52
+ /** xyflow's calculateNodePosition: the relative and absolute position for a dragged node, kept in its extent. */
53
+ export declare function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin, nodeExtent, }: {
54
+ nodeId: string;
55
+ nextPosition: XY;
56
+ nodeLookup: Map<string, InternalNode>;
57
+ nodeOrigin?: [number, number];
58
+ nodeExtent?: unknown;
59
+ }): {
60
+ position: {
61
+ x: number;
62
+ y: number;
63
+ };
64
+ positionAbsolute: XY;
65
+ };
66
+ export type DragItem = {
67
+ id: string;
68
+ position: XY;
69
+ distance: XY;
70
+ extent?: unknown;
71
+ parentId?: string;
72
+ internals: {
73
+ positionAbsolute: XY;
74
+ };
75
+ measured: {
76
+ width: number;
77
+ height: number;
78
+ };
79
+ };
80
+ /** xyflow's getDragItems: the selected (or pressed), draggable nodes whose parent isn't dragged too. */
81
+ export declare function getDragItems(lookup: Map<string, InternalNode>, nodesDraggable: boolean, mouse: XY, nodeId?: string): Map<string, DragItem>;
82
+ /** xyflow's getEventHandlerParams: the dragged node (or the first) and all dragged nodes. */
83
+ export declare function getEventHandlerParams({ nodeId, dragItems, nodeLookup, dragging, }: {
84
+ nodeId?: string;
85
+ dragItems: Map<string, DragItem>;
86
+ nodeLookup: Map<string, InternalNode>;
87
+ dragging?: boolean;
88
+ }): [FlowNode, FlowNode[]];
89
+ export declare function calculateSnapOffset({ dragItems, snapGrid, x, y }: {
90
+ dragItems: Map<string, DragItem>;
91
+ snapGrid: [number, number];
92
+ x: number;
93
+ y: number;
94
+ }): {
95
+ x: number;
96
+ y: number;
97
+ } | null;
98
+ /** The bounds of the dragged items (xyflow's getInternalNodesBounds over drag items). */
99
+ export declare function dragItemsBox(items: Map<string, DragItem>): {
100
+ x: number;
101
+ y: number;
102
+ x2: number;
103
+ y2: number;
104
+ };
105
+ /** xyflow's getHandlePosition: a handle's side point (or centre) in flow coordinates. */
106
+ export declare function getHandlePosition(node: InternalNode, handle: HandleBox | null, fallback?: string, center?: boolean): XY;
107
+ /** The bounds of the selected nodes (for the selection rectangle). */
108
+ export declare function selectedNodesBounds(lookup: Map<string, InternalNode>): {
109
+ x: number;
110
+ y: number;
111
+ width: number;
112
+ height: number;
113
+ } | null;
114
+ /** xyflow's getClosestHandle: the nearest handle within the radius (the opposite type wins a tie). */
115
+ export declare function getClosestHandle(position: XY, radius: number, lookup: Map<string, InternalNode>, from: {
116
+ nodeId: string;
117
+ type: string;
118
+ id: string | null;
119
+ }): (HandleBox & {
120
+ x: number;
121
+ y: number;
122
+ }) | null;
123
+ export declare function getHandle(nodeId: string, type: "source" | "target", id: string | null, lookup: Map<string, InternalNode>, connectionMode: string, withAbsolutePosition?: boolean): HandleBox | null;
124
+ export declare function getHandleType(edgeUpdaterType: "source" | "target" | undefined, handleDomNode: Element | null): "source" | "target" | null;
125
+ /** xyflow's isValidHandle: the connection to the handle under the pointer (or the closest one). */
126
+ export declare function isValidHandle(event: MouseEvent | TouchEvent, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, flowId, isValidConnection, nodeLookup, }: {
127
+ handle: {
128
+ nodeId: string;
129
+ id: string | null;
130
+ type: string;
131
+ } | null;
132
+ connectionMode: string;
133
+ fromNodeId: string;
134
+ fromHandleId: string | null;
135
+ fromType: string;
136
+ doc: Document | ShadowRoot;
137
+ flowId: string;
138
+ isValidConnection: (connection: Connection) => boolean;
139
+ nodeLookup: Map<string, InternalNode>;
140
+ }): {
141
+ handleDomNode: Element | null;
142
+ isValid: boolean;
143
+ connection: Connection | null;
144
+ toHandle: ReturnType<typeof getHandle>;
145
+ };
146
+ export declare const isConnectionValid: (insideRadius: boolean, handleValid: boolean) => boolean | null;
@@ -0,0 +1,300 @@
1
+ export const initialConnection = {
2
+ inProgress: false,
3
+ isValid: null,
4
+ from: null,
5
+ fromHandle: null,
6
+ fromPosition: null,
7
+ fromNode: null,
8
+ to: null,
9
+ toHandle: null,
10
+ toPosition: null,
11
+ toNode: null,
12
+ pointer: null,
13
+ };
14
+ export const oppositePosition = { left: "right", right: "left", top: "bottom", bottom: "top" };
15
+ export const getConnectionStatus = (isValid) => (isValid === null ? null : isValid ? "valid" : "invalid");
16
+ export const getEventPosition = (event, bounds) => {
17
+ const mouse = "clientX" in event;
18
+ const x = mouse ? event.clientX : event.touches?.[0].clientX;
19
+ const y = mouse ? event.clientY : event.touches?.[0].clientY;
20
+ return { x: x - (bounds?.left ?? 0), y: y - (bounds?.top ?? 0) };
21
+ };
22
+ export const snapPosition = (position, snapGrid = [1, 1]) => ({
23
+ x: snapGrid[0] * Math.round(position.x / snapGrid[0]),
24
+ y: snapGrid[1] * Math.round(position.y / snapGrid[1]),
25
+ });
26
+ export const pointToRendererPoint = ({ x, y }, [tx, ty, scale], snapToGrid = false, snapGrid = [1, 1]) => {
27
+ const position = { x: (x - tx) / scale, y: (y - ty) / scale };
28
+ return snapToGrid ? snapPosition(position, snapGrid) : position;
29
+ };
30
+ export const rendererPointToPoint = ({ x, y }, [tx, ty, scale]) => ({ x: x * scale + tx, y: y * scale + ty });
31
+ export function getPointerPosition(event, { snapGrid = [0, 0], snapToGrid = false, transform, containerBounds }) {
32
+ const { x, y } = getEventPosition(event);
33
+ const pointer = pointToRendererPoint({ x: x - (containerBounds?.left ?? 0), y: y - (containerBounds?.top ?? 0) }, transform);
34
+ const snapped = snapToGrid ? snapPosition(pointer, snapGrid) : pointer;
35
+ return { xSnapped: snapped.x, ySnapped: snapped.y, ...pointer };
36
+ }
37
+ const clamp = (value, min = 0, max = 1) => Math.min(Math.max(value, min), max);
38
+ const calcAutoPanVelocity = (value, min, max) => {
39
+ if (value < min)
40
+ return clamp(Math.abs(value - min), 1, min) / min;
41
+ if (value > max)
42
+ return -clamp(Math.abs(value - max), 1, min) / min;
43
+ return 0;
44
+ };
45
+ export const calcAutoPan = (pos, bounds, speed = 15, distance = 40) => [
46
+ calcAutoPanVelocity(pos.x, distance, bounds.width - distance) * speed,
47
+ calcAutoPanVelocity(pos.y, distance, bounds.height - distance) * speed,
48
+ ];
49
+ const overlap = (ax, ay, aw, ah, bx, by, bw, bh) => Math.max(0, Math.min(ax + aw, bx + bw) - Math.max(ax, bx)) * Math.max(0, Math.min(ay + ah, by + bh) - Math.max(ay, by));
50
+ export const getOverlappingArea = (a, b) => overlap(a.x, a.y, a.width, a.height, b.x, b.y, b.width, b.height);
51
+ export const nodeDimensions = (node) => ({
52
+ width: node.measured?.width ?? node.width ?? node.initialWidth ?? 0,
53
+ height: node.measured?.height ?? node.height ?? node.initialHeight ?? 0,
54
+ });
55
+ export const nodeToRect = (node) => ({ ...node.internals.positionAbsolute, ...nodeDimensions(node) });
56
+ /** xyflow's getNodesInside: nodes in a screen rect (fully, or partly when `partially`). */
57
+ export function getNodesInside(nodes, rect, [tx, ty, scale] = [0, 0, 1], partially = false, excludeNonSelectableNodes = false) {
58
+ const px = (rect.x - tx) / scale;
59
+ const py = (rect.y - ty) / scale;
60
+ const pw = rect.width / scale;
61
+ const ph = rect.height / scale;
62
+ const out = [];
63
+ for (const node of nodes.values()) {
64
+ const selectable = node.selectable ?? true;
65
+ if ((excludeNonSelectableNodes && !selectable) || node.hidden)
66
+ continue;
67
+ const { width, height } = nodeDimensions(node);
68
+ const { x, y } = node.internals.positionAbsolute;
69
+ const area = overlap(px, py, pw, ph, x, y, width, height);
70
+ const visible = !node.internals.handleBounds || (partially && area > 0) || area >= width * height;
71
+ if (visible || node.dragging)
72
+ out.push(node);
73
+ }
74
+ return out;
75
+ }
76
+ const isExtent = (value) => Array.isArray(value) && value.length === 2 && Array.isArray(value[0]);
77
+ const clampPosition = (position, extent, dimensions) => ({
78
+ x: clamp(position.x, extent[0][0], extent[1][0] - (dimensions.width ?? 0)),
79
+ y: clamp(position.y, extent[0][1], extent[1][1] - (dimensions.height ?? 0)),
80
+ });
81
+ /** xyflow's calculateNodePosition: the relative and absolute position for a dragged node, kept in its extent. */
82
+ export function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin = [0, 0], nodeExtent, }) {
83
+ const node = nodeLookup.get(nodeId);
84
+ const parent = node.parentId ? nodeLookup.get(node.parentId) : undefined;
85
+ const { x: parentX, y: parentY } = parent ? parent.internals.positionAbsolute : { x: 0, y: 0 };
86
+ const origin = node.origin ?? nodeOrigin;
87
+ let extent = node.extent || nodeExtent;
88
+ if (node.extent === "parent" && !node.expandParent) {
89
+ if (parent) {
90
+ const { width, height } = nodeDimensions(parent);
91
+ if (width && height)
92
+ extent = [[parentX, parentY], [parentX + width, parentY + height]];
93
+ }
94
+ }
95
+ else if (parent && isExtent(node.extent)) {
96
+ extent = [
97
+ [node.extent[0][0] + parentX, node.extent[0][1] + parentY],
98
+ [node.extent[1][0] + parentX, node.extent[1][1] + parentY],
99
+ ];
100
+ }
101
+ const positionAbsolute = isExtent(extent) ? clampPosition(nextPosition, extent, node.measured) : nextPosition;
102
+ return {
103
+ position: {
104
+ x: positionAbsolute.x - parentX + (node.measured.width ?? 0) * origin[0],
105
+ y: positionAbsolute.y - parentY + (node.measured.height ?? 0) * origin[1],
106
+ },
107
+ positionAbsolute,
108
+ };
109
+ }
110
+ function isParentSelected(node, lookup) {
111
+ if (!node.parentId)
112
+ return false;
113
+ const parent = lookup.get(node.parentId);
114
+ if (!parent)
115
+ return false;
116
+ return parent.selected ? true : isParentSelected(parent, lookup);
117
+ }
118
+ /** xyflow's getDragItems: the selected (or pressed), draggable nodes whose parent isn't dragged too. */
119
+ export function getDragItems(lookup, nodesDraggable, mouse, nodeId) {
120
+ const items = new Map();
121
+ for (const [id, node] of lookup) {
122
+ if ((node.selected || node.id === nodeId) &&
123
+ (!node.parentId || !isParentSelected(node, lookup)) &&
124
+ (node.draggable || (nodesDraggable && typeof node.draggable === "undefined"))) {
125
+ items.set(id, {
126
+ id,
127
+ position: node.position || { x: 0, y: 0 },
128
+ distance: { x: mouse.x - node.internals.positionAbsolute.x, y: mouse.y - node.internals.positionAbsolute.y },
129
+ extent: node.extent,
130
+ parentId: node.parentId,
131
+ internals: { positionAbsolute: node.internals.positionAbsolute || { x: 0, y: 0 } },
132
+ measured: { width: node.measured.width ?? 0, height: node.measured.height ?? 0 },
133
+ });
134
+ }
135
+ }
136
+ return items;
137
+ }
138
+ /** xyflow's getEventHandlerParams: the dragged node (or the first) and all dragged nodes. */
139
+ export function getEventHandlerParams({ nodeId, dragItems, nodeLookup, dragging = true, }) {
140
+ const nodes = [];
141
+ for (const [id, item] of dragItems) {
142
+ const node = nodeLookup.get(id)?.internals.userNode;
143
+ if (node)
144
+ nodes.push({ ...node, position: item.position, dragging });
145
+ }
146
+ if (!nodeId)
147
+ return [nodes[0], nodes];
148
+ const node = nodeLookup.get(nodeId)?.internals.userNode;
149
+ return [node ? { ...node, position: dragItems.get(nodeId)?.position || node.position, dragging } : nodes[0], nodes];
150
+ }
151
+ export function calculateSnapOffset({ dragItems, snapGrid, x, y }) {
152
+ const ref = dragItems.values().next().value;
153
+ if (!ref)
154
+ return null;
155
+ const at = { x: x - ref.distance.x, y: y - ref.distance.y };
156
+ const snapped = snapPosition(at, snapGrid);
157
+ return { x: snapped.x - at.x, y: snapped.y - at.y };
158
+ }
159
+ /** The bounds of the dragged items (xyflow's getInternalNodesBounds over drag items). */
160
+ export function dragItemsBox(items) {
161
+ let x = Infinity;
162
+ let y = Infinity;
163
+ let x2 = -Infinity;
164
+ let y2 = -Infinity;
165
+ for (const item of items.values()) {
166
+ const p = item.internals.positionAbsolute;
167
+ x = Math.min(x, p.x);
168
+ y = Math.min(y, p.y);
169
+ x2 = Math.max(x2, p.x + item.measured.width);
170
+ y2 = Math.max(y2, p.y + item.measured.height);
171
+ }
172
+ return { x, y, x2, y2 };
173
+ }
174
+ /** xyflow's getHandlePosition: a handle's side point (or centre) in flow coordinates. */
175
+ export function getHandlePosition(node, handle, fallback = "left", center = false) {
176
+ const x = (handle?.x ?? 0) + node.internals.positionAbsolute.x;
177
+ const y = (handle?.y ?? 0) + node.internals.positionAbsolute.y;
178
+ const { width, height } = handle ?? nodeDimensions(node);
179
+ if (center)
180
+ return { x: x + width / 2, y: y + height / 2 };
181
+ switch (handle?.position ?? fallback) {
182
+ case "top":
183
+ return { x: x + width / 2, y };
184
+ case "right":
185
+ return { x: x + width, y: y + height / 2 };
186
+ case "bottom":
187
+ return { x: x + width / 2, y: y + height };
188
+ default:
189
+ return { x, y: y + height / 2 };
190
+ }
191
+ }
192
+ /** The bounds of the selected nodes (for the selection rectangle). */
193
+ export function selectedNodesBounds(lookup) {
194
+ let x = Infinity;
195
+ let y = Infinity;
196
+ let x2 = -Infinity;
197
+ let y2 = -Infinity;
198
+ for (const node of lookup.values()) {
199
+ if (!node.selected)
200
+ continue;
201
+ const { width, height } = nodeDimensions(node);
202
+ const p = node.internals.positionAbsolute;
203
+ x = Math.min(x, p.x);
204
+ y = Math.min(y, p.y);
205
+ x2 = Math.max(x2, p.x + width);
206
+ y2 = Math.max(y2, p.y + height);
207
+ }
208
+ return Number.isFinite(x) ? { x, y, width: x2 - x, height: y2 - y } : null;
209
+ }
210
+ // ---- handles (XYHandle) ----------------------------------------------------------------
211
+ const ADDITIONAL_DISTANCE = 250;
212
+ /** xyflow's getClosestHandle: the nearest handle within the radius (the opposite type wins a tie). */
213
+ export function getClosestHandle(position, radius, lookup, from) {
214
+ let closest = [];
215
+ let min = Infinity;
216
+ const area = { x: position.x - radius - ADDITIONAL_DISTANCE, y: position.y - radius - ADDITIONAL_DISTANCE, width: (radius + ADDITIONAL_DISTANCE) * 2, height: (radius + ADDITIONAL_DISTANCE) * 2 };
217
+ for (const node of lookup.values()) {
218
+ if (getOverlappingArea(area, nodeToRect(node)) <= 0)
219
+ continue;
220
+ const handles = [...(node.internals.handleBounds?.source ?? []), ...(node.internals.handleBounds?.target ?? [])];
221
+ for (const handle of handles) {
222
+ if (from.nodeId === handle.nodeId && from.type === handle.type && from.id === handle.id)
223
+ continue;
224
+ const { x, y } = getHandlePosition(node, handle, handle.position, true);
225
+ const distance = Math.hypot(x - position.x, y - position.y);
226
+ if (distance > radius)
227
+ continue;
228
+ if (distance < min) {
229
+ closest = [{ ...handle, x, y }];
230
+ min = distance;
231
+ }
232
+ else if (distance === min) {
233
+ closest.push({ ...handle, x, y });
234
+ }
235
+ }
236
+ }
237
+ if (!closest.length)
238
+ return null;
239
+ if (closest.length > 1) {
240
+ const opposite = from.type === "source" ? "target" : "source";
241
+ return closest.find((h) => h.type === opposite) ?? closest[0];
242
+ }
243
+ return closest[0];
244
+ }
245
+ export function getHandle(nodeId, type, id, lookup, connectionMode, withAbsolutePosition = false) {
246
+ const node = lookup.get(nodeId);
247
+ if (!node)
248
+ return null;
249
+ const handles = connectionMode === "strict"
250
+ ? node.internals.handleBounds?.[type]
251
+ : [...(node.internals.handleBounds?.source ?? []), ...(node.internals.handleBounds?.target ?? [])];
252
+ const handle = (id ? handles?.find((h) => h.id === id) : handles?.[0]) ?? null;
253
+ return handle && withAbsolutePosition ? { ...handle, ...getHandlePosition(node, handle, handle.position, true) } : handle;
254
+ }
255
+ export function getHandleType(edgeUpdaterType, handleDomNode) {
256
+ if (edgeUpdaterType)
257
+ return edgeUpdaterType;
258
+ if (handleDomNode?.classList.contains("target"))
259
+ return "target";
260
+ if (handleDomNode?.classList.contains("source"))
261
+ return "source";
262
+ return null;
263
+ }
264
+ /** xyflow's isValidHandle: the connection to the handle under the pointer (or the closest one). */
265
+ export function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, flowId, isValidConnection, nodeLookup, }) {
266
+ const isTarget = fromType === "target";
267
+ const handleDomNode = handle ? doc.querySelector(`.avis-flow__handle[data-id="${flowId}-${handle.nodeId}-${handle.id}-${handle.type}"]`) : null;
268
+ const { x, y } = getEventPosition(event);
269
+ const below = doc.elementFromPoint(x, y);
270
+ const toCheck = below?.classList.contains("avis-flow__handle") ? below : handleDomNode;
271
+ const result = {
272
+ handleDomNode: toCheck,
273
+ isValid: false,
274
+ connection: null,
275
+ toHandle: null,
276
+ };
277
+ if (toCheck) {
278
+ const type = getHandleType(undefined, toCheck);
279
+ const nodeId = toCheck.getAttribute("data-nodeid");
280
+ const handleId = toCheck.getAttribute("data-handleid");
281
+ const connectable = toCheck.classList.contains("connectable");
282
+ const connectableEnd = toCheck.classList.contains("connectableend");
283
+ if (!nodeId || !type)
284
+ return result;
285
+ const connection = {
286
+ source: isTarget ? nodeId : fromNodeId,
287
+ sourceHandle: isTarget ? handleId : fromHandleId,
288
+ target: isTarget ? fromNodeId : nodeId,
289
+ targetHandle: isTarget ? fromHandleId : handleId,
290
+ };
291
+ result.connection = connection;
292
+ const valid = connectable &&
293
+ connectableEnd &&
294
+ (connectionMode === "strict" ? (isTarget && type === "source") || (!isTarget && type === "target") : nodeId !== fromNodeId || handleId !== fromHandleId);
295
+ result.isValid = valid && isValidConnection(connection);
296
+ result.toHandle = getHandle(nodeId, type, handleId, nodeLookup, connectionMode, true);
297
+ }
298
+ return result;
299
+ }
300
+ export const isConnectionValid = (insideRadius, handleValid) => (handleValid ? true : insideRadius && !handleValid ? false : null);
@@ -0,0 +1,131 @@
1
+ export type XY = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ export type Dimensions = {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ export type Rect = XY & Dimensions;
10
+ export type Transform = [number, number, number];
11
+ export type HandleBox = {
12
+ id: string | null;
13
+ type: "source" | "target";
14
+ nodeId: string;
15
+ position: string;
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ };
21
+ export type FlowNode = {
22
+ id: string;
23
+ position: XY;
24
+ data: Record<string, unknown>;
25
+ type?: string;
26
+ parentId?: string;
27
+ hidden?: boolean;
28
+ selected?: boolean;
29
+ dragging?: boolean;
30
+ width?: number;
31
+ height?: number;
32
+ measured?: Partial<Dimensions>;
33
+ zIndex?: number;
34
+ selectable?: boolean;
35
+ draggable?: boolean;
36
+ connectable?: boolean;
37
+ deletable?: boolean;
38
+ className?: string;
39
+ style?: Record<string, unknown>;
40
+ domAttributes?: Record<string, unknown>;
41
+ handles?: Omit<HandleBox, "nodeId">[];
42
+ sourcePosition?: string;
43
+ targetPosition?: string;
44
+ dragHandle?: string;
45
+ [key: string]: unknown;
46
+ };
47
+ export type FlowEdge = {
48
+ id: string;
49
+ source: string;
50
+ target: string;
51
+ sourceHandle?: string | null;
52
+ targetHandle?: string | null;
53
+ type?: string;
54
+ data?: Record<string, unknown>;
55
+ hidden?: boolean;
56
+ selected?: boolean;
57
+ selectable?: boolean;
58
+ deletable?: boolean;
59
+ animated?: boolean;
60
+ style?: Record<string, unknown>;
61
+ className?: string;
62
+ markerEnd?: unknown;
63
+ markerStart?: unknown;
64
+ label?: unknown;
65
+ interactionWidth?: number;
66
+ zIndex?: number;
67
+ [key: string]: unknown;
68
+ };
69
+ export type InternalNode = FlowNode & {
70
+ measured: Partial<Dimensions>;
71
+ internals: {
72
+ positionAbsolute: XY;
73
+ z: number;
74
+ userNode: FlowNode;
75
+ handleBounds: {
76
+ source: HandleBox[] | null;
77
+ target: HandleBox[] | null;
78
+ } | undefined;
79
+ bounds?: unknown;
80
+ };
81
+ };
82
+ export type NodeChange = {
83
+ type: "add";
84
+ item: FlowNode;
85
+ index?: number;
86
+ } | {
87
+ type: "remove";
88
+ id: string;
89
+ } | {
90
+ type: "replace";
91
+ id: string;
92
+ item: FlowNode;
93
+ } | {
94
+ type: "select";
95
+ id: string;
96
+ selected: boolean;
97
+ } | {
98
+ type: "position";
99
+ id: string;
100
+ position?: XY;
101
+ positionAbsolute?: XY;
102
+ dragging?: boolean;
103
+ } | {
104
+ type: "dimensions";
105
+ id: string;
106
+ dimensions?: Dimensions;
107
+ resizing?: boolean;
108
+ setAttributes?: boolean | "width" | "height";
109
+ };
110
+ export type EdgeChange = {
111
+ type: "add";
112
+ item: FlowEdge;
113
+ index?: number;
114
+ } | {
115
+ type: "remove";
116
+ id: string;
117
+ } | {
118
+ type: "replace";
119
+ id: string;
120
+ item: FlowEdge;
121
+ } | {
122
+ type: "select";
123
+ id: string;
124
+ selected: boolean;
125
+ };
126
+ export type Connection = {
127
+ source: string;
128
+ target: string;
129
+ sourceHandle: string | null;
130
+ targetHandle: string | null;
131
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,77 @@
1
+ import type { Connection, EdgeChange, FlowEdge, FlowNode, NodeChange } from "./types.js";
2
+ export declare const Position: {
3
+ readonly Left: "left";
4
+ readonly Top: "top";
5
+ readonly Right: "right";
6
+ readonly Bottom: "bottom";
7
+ };
8
+ export declare const SelectionMode: {
9
+ readonly Partial: "partial";
10
+ readonly Full: "full";
11
+ };
12
+ export declare const ConnectionMode: {
13
+ readonly Strict: "strict";
14
+ readonly Loose: "loose";
15
+ };
16
+ export declare const BackgroundVariant: {
17
+ readonly Lines: "lines";
18
+ readonly Dots: "dots";
19
+ readonly Cross: "cross";
20
+ };
21
+ export declare const MarkerType: {
22
+ readonly Arrow: "arrow";
23
+ readonly ArrowClosed: "arrowclosed";
24
+ };
25
+ export declare const PanOnScrollMode: {
26
+ readonly Free: "free";
27
+ readonly Vertical: "vertical";
28
+ readonly Horizontal: "horizontal";
29
+ };
30
+ type PathInput = {
31
+ sourceX: number;
32
+ sourceY: number;
33
+ sourcePosition?: string;
34
+ targetX: number;
35
+ targetY: number;
36
+ targetPosition?: string;
37
+ curvature?: number;
38
+ };
39
+ /** [path, labelX, labelY, offsetX, offsetY], as xyflow's. */
40
+ export declare function getBezierPath({ sourcePosition, targetPosition, ...rest }: PathInput): [string, number, number, number, number];
41
+ export declare function getStraightPath({ sourceX, sourceY, targetX, targetY }: PathInput): [string, number, number, number, number];
42
+ /** xyflow's getEdgeCenter (straight and simple smoothstep edges). */
43
+ export declare function getEdgeCenter({ sourceX, sourceY, targetX, targetY }: {
44
+ sourceX: number;
45
+ sourceY: number;
46
+ targetX: number;
47
+ targetY: number;
48
+ }): [number, number, number, number];
49
+ /** xyflow's getSmoothStepPath: right-angled with rounded bends. */
50
+ export declare function getSmoothStepPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, borderRadius, centerX, centerY, offset, stepPosition, }: PathInput & {
51
+ borderRadius?: number;
52
+ centerX?: number;
53
+ centerY?: number;
54
+ offset?: number;
55
+ stepPosition?: number;
56
+ }): [string, number, number, number, number];
57
+ /** xyflow's getSimpleBezierPath. */
58
+ export declare function getSimpleBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition }: PathInput): [string, number, number, number, number];
59
+ /** Adds an edge unless one with the same ends exists (xyflow's addEdge). */
60
+ export declare function addEdge<E extends FlowEdge>(params: E | Connection, edges: E[]): E[];
61
+ export declare function applyNodeChanges<N extends FlowNode>(changes: readonly NodeChange[], nodes: readonly N[]): N[];
62
+ export declare function applyEdgeChanges<E extends FlowEdge>(changes: readonly EdgeChange[], edges: readonly E[]): E[];
63
+ /** Where an edge leaves or meets a handle box, on its side (xyflow's getHandlePosition). */
64
+ export declare function handlePoint(box: {
65
+ x: number;
66
+ y: number;
67
+ width: number;
68
+ height: number;
69
+ position: string;
70
+ }, origin: {
71
+ x: number;
72
+ y: number;
73
+ }): {
74
+ x: number;
75
+ y: number;
76
+ };
77
+ export {};