@yh-ui/flow 0.1.21

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 (354) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/dist/Flow.d.vue.ts +306 -0
  4. package/dist/Flow.vue +959 -0
  5. package/dist/Flow.vue.d.ts +306 -0
  6. package/dist/__tests__/ai-workflow.ssr.test.cjs +352 -0
  7. package/dist/__tests__/ai-workflow.ssr.test.d.ts +1 -0
  8. package/dist/__tests__/ai-workflow.ssr.test.mjs +283 -0
  9. package/dist/__tests__/ai-workflow.test.cjs +109 -0
  10. package/dist/__tests__/ai-workflow.test.d.ts +1 -0
  11. package/dist/__tests__/ai-workflow.test.mjs +112 -0
  12. package/dist/__tests__/bpmn.ssr.test.cjs +278 -0
  13. package/dist/__tests__/bpmn.ssr.test.d.ts +1 -0
  14. package/dist/__tests__/bpmn.ssr.test.mjs +237 -0
  15. package/dist/__tests__/bpmn.test.cjs +103 -0
  16. package/dist/__tests__/bpmn.test.d.ts +1 -0
  17. package/dist/__tests__/bpmn.test.mjs +106 -0
  18. package/dist/__tests__/custom-types.test.cjs +300 -0
  19. package/dist/__tests__/custom-types.test.d.ts +1 -0
  20. package/dist/__tests__/custom-types.test.mjs +248 -0
  21. package/dist/__tests__/edge.test.cjs +56 -0
  22. package/dist/__tests__/edge.test.d.ts +1 -0
  23. package/dist/__tests__/edge.test.mjs +69 -0
  24. package/dist/__tests__/event-bus.test.cjs +80 -0
  25. package/dist/__tests__/event-bus.test.d.ts +1 -0
  26. package/dist/__tests__/event-bus.test.mjs +51 -0
  27. package/dist/__tests__/flow.ssr.test.cjs +156 -0
  28. package/dist/__tests__/flow.ssr.test.d.ts +1 -0
  29. package/dist/__tests__/flow.ssr.test.mjs +112 -0
  30. package/dist/__tests__/geometry.test.cjs +191 -0
  31. package/dist/__tests__/geometry.test.d.ts +1 -0
  32. package/dist/__tests__/geometry.test.mjs +105 -0
  33. package/dist/__tests__/graph.test.cjs +115 -0
  34. package/dist/__tests__/graph.test.d.ts +1 -0
  35. package/dist/__tests__/graph.test.mjs +85 -0
  36. package/dist/__tests__/history-plugin.test.cjs +191 -0
  37. package/dist/__tests__/history-plugin.test.d.ts +1 -0
  38. package/dist/__tests__/history-plugin.test.mjs +161 -0
  39. package/dist/__tests__/history.test.cjs +81 -0
  40. package/dist/__tests__/history.test.d.ts +1 -0
  41. package/dist/__tests__/history.test.mjs +43 -0
  42. package/dist/__tests__/layout.test.cjs +213 -0
  43. package/dist/__tests__/layout.test.d.ts +1 -0
  44. package/dist/__tests__/layout.test.mjs +170 -0
  45. package/dist/__tests__/node-edit-panel.ssr.test.cjs +168 -0
  46. package/dist/__tests__/node-edit-panel.ssr.test.d.ts +1 -0
  47. package/dist/__tests__/node-edit-panel.ssr.test.mjs +118 -0
  48. package/dist/__tests__/node-group-plugin.test.cjs +235 -0
  49. package/dist/__tests__/node-group-plugin.test.d.ts +1 -0
  50. package/dist/__tests__/node-group-plugin.test.mjs +187 -0
  51. package/dist/__tests__/node-handles.test.cjs +340 -0
  52. package/dist/__tests__/node-handles.test.d.ts +1 -0
  53. package/dist/__tests__/node-handles.test.mjs +230 -0
  54. package/dist/__tests__/plugin.test.cjs +151 -0
  55. package/dist/__tests__/plugin.test.d.ts +1 -0
  56. package/dist/__tests__/plugin.test.mjs +116 -0
  57. package/dist/__tests__/transform.test.cjs +58 -0
  58. package/dist/__tests__/transform.test.d.ts +1 -0
  59. package/dist/__tests__/transform.test.mjs +38 -0
  60. package/dist/__tests__/useAlignment.test.cjs +91 -0
  61. package/dist/__tests__/useAlignment.test.d.ts +1 -0
  62. package/dist/__tests__/useAlignment.test.mjs +52 -0
  63. package/dist/__tests__/useEdges.test.cjs +117 -0
  64. package/dist/__tests__/useEdges.test.d.ts +1 -0
  65. package/dist/__tests__/useEdges.test.mjs +80 -0
  66. package/dist/__tests__/useKeyboard.test.cjs +88 -0
  67. package/dist/__tests__/useKeyboard.test.d.ts +1 -0
  68. package/dist/__tests__/useKeyboard.test.mjs +56 -0
  69. package/dist/__tests__/useNodes.test.cjs +150 -0
  70. package/dist/__tests__/useNodes.test.d.ts +1 -0
  71. package/dist/__tests__/useNodes.test.mjs +80 -0
  72. package/dist/__tests__/useSelection.test.cjs +112 -0
  73. package/dist/__tests__/useSelection.test.d.ts +1 -0
  74. package/dist/__tests__/useSelection.test.mjs +76 -0
  75. package/dist/__tests__/useViewport.test.cjs +171 -0
  76. package/dist/__tests__/useViewport.test.d.ts +1 -0
  77. package/dist/__tests__/useViewport.test.mjs +82 -0
  78. package/dist/__tests__/utils/ssr.cjs +124 -0
  79. package/dist/__tests__/utils/ssr.d.ts +33 -0
  80. package/dist/__tests__/utils/ssr.mjs +129 -0
  81. package/dist/__tests__/validation.test.cjs +95 -0
  82. package/dist/__tests__/validation.test.d.ts +1 -0
  83. package/dist/__tests__/validation.test.mjs +36 -0
  84. package/dist/components/AiNodeEditPanel.d.vue.ts +13 -0
  85. package/dist/components/AiNodeEditPanel.vue +413 -0
  86. package/dist/components/AiNodeEditPanel.vue.d.ts +13 -0
  87. package/dist/components/EdgeEditPanel.d.vue.ts +14 -0
  88. package/dist/components/EdgeEditPanel.vue +205 -0
  89. package/dist/components/EdgeEditPanel.vue.d.ts +14 -0
  90. package/dist/components/NodeEditPanel.d.vue.ts +13 -0
  91. package/dist/components/NodeEditPanel.vue +214 -0
  92. package/dist/components/NodeEditPanel.vue.d.ts +13 -0
  93. package/dist/components/edges/BaseEdge.d.vue.ts +23 -0
  94. package/dist/components/edges/BaseEdge.vue +55 -0
  95. package/dist/components/edges/BaseEdge.vue.d.ts +23 -0
  96. package/dist/components/edges/BezierEdge.d.vue.ts +22 -0
  97. package/dist/components/edges/BezierEdge.vue +57 -0
  98. package/dist/components/edges/BezierEdge.vue.d.ts +22 -0
  99. package/dist/components/edges/DataFlowEdge.d.vue.ts +41 -0
  100. package/dist/components/edges/DataFlowEdge.vue +211 -0
  101. package/dist/components/edges/DataFlowEdge.vue.d.ts +41 -0
  102. package/dist/components/edges/SmoothEdge.d.vue.ts +22 -0
  103. package/dist/components/edges/SmoothEdge.vue +53 -0
  104. package/dist/components/edges/SmoothEdge.vue.d.ts +22 -0
  105. package/dist/components/edges/StepEdge.d.vue.ts +22 -0
  106. package/dist/components/edges/StepEdge.vue +42 -0
  107. package/dist/components/edges/StepEdge.vue.d.ts +22 -0
  108. package/dist/components/edges/index.cjs +41 -0
  109. package/dist/components/edges/index.d.ts +5 -0
  110. package/dist/components/edges/index.mjs +5 -0
  111. package/dist/components/nodes/BaseNode.d.vue.ts +25 -0
  112. package/dist/components/nodes/BaseNode.vue +93 -0
  113. package/dist/components/nodes/BaseNode.vue.d.ts +25 -0
  114. package/dist/components/nodes/CustomNode.d.vue.ts +36 -0
  115. package/dist/components/nodes/CustomNode.vue +44 -0
  116. package/dist/components/nodes/CustomNode.vue.d.ts +36 -0
  117. package/dist/components/nodes/DatabaseNode.d.vue.ts +19 -0
  118. package/dist/components/nodes/DatabaseNode.vue +62 -0
  119. package/dist/components/nodes/DatabaseNode.vue.d.ts +19 -0
  120. package/dist/components/nodes/DiamondNode.d.vue.ts +19 -0
  121. package/dist/components/nodes/DiamondNode.vue +62 -0
  122. package/dist/components/nodes/DiamondNode.vue.d.ts +19 -0
  123. package/dist/components/nodes/GroupNode.d.vue.ts +31 -0
  124. package/dist/components/nodes/GroupNode.vue +48 -0
  125. package/dist/components/nodes/GroupNode.vue.d.ts +31 -0
  126. package/dist/components/nodes/InputNode.d.vue.ts +23 -0
  127. package/dist/components/nodes/InputNode.vue +63 -0
  128. package/dist/components/nodes/InputNode.vue.d.ts +23 -0
  129. package/dist/components/nodes/NodeResizer.d.vue.ts +27 -0
  130. package/dist/components/nodes/NodeResizer.vue +89 -0
  131. package/dist/components/nodes/NodeResizer.vue.d.ts +27 -0
  132. package/dist/components/nodes/NodeToolbar.d.vue.ts +32 -0
  133. package/dist/components/nodes/NodeToolbar.vue +101 -0
  134. package/dist/components/nodes/NodeToolbar.vue.d.ts +32 -0
  135. package/dist/components/nodes/OutputNode.d.vue.ts +21 -0
  136. package/dist/components/nodes/OutputNode.vue +53 -0
  137. package/dist/components/nodes/OutputNode.vue.d.ts +21 -0
  138. package/dist/components/nodes/ai-workflow/AiAgentNode.d.vue.ts +20 -0
  139. package/dist/components/nodes/ai-workflow/AiAgentNode.vue +59 -0
  140. package/dist/components/nodes/ai-workflow/AiAgentNode.vue.d.ts +20 -0
  141. package/dist/components/nodes/ai-workflow/AiConditionNode.d.vue.ts +19 -0
  142. package/dist/components/nodes/ai-workflow/AiConditionNode.vue +65 -0
  143. package/dist/components/nodes/ai-workflow/AiConditionNode.vue.d.ts +19 -0
  144. package/dist/components/nodes/ai-workflow/AiEndNode.d.vue.ts +19 -0
  145. package/dist/components/nodes/ai-workflow/AiEndNode.vue +47 -0
  146. package/dist/components/nodes/ai-workflow/AiEndNode.vue.d.ts +19 -0
  147. package/dist/components/nodes/ai-workflow/AiLlmNode.d.vue.ts +19 -0
  148. package/dist/components/nodes/ai-workflow/AiLlmNode.vue +64 -0
  149. package/dist/components/nodes/ai-workflow/AiLlmNode.vue.d.ts +19 -0
  150. package/dist/components/nodes/ai-workflow/AiMemoryNode.d.vue.ts +19 -0
  151. package/dist/components/nodes/ai-workflow/AiMemoryNode.vue +59 -0
  152. package/dist/components/nodes/ai-workflow/AiMemoryNode.vue.d.ts +19 -0
  153. package/dist/components/nodes/ai-workflow/AiPromptNode.d.vue.ts +19 -0
  154. package/dist/components/nodes/ai-workflow/AiPromptNode.vue +61 -0
  155. package/dist/components/nodes/ai-workflow/AiPromptNode.vue.d.ts +19 -0
  156. package/dist/components/nodes/ai-workflow/AiStartNode.d.vue.ts +19 -0
  157. package/dist/components/nodes/ai-workflow/AiStartNode.vue +47 -0
  158. package/dist/components/nodes/ai-workflow/AiStartNode.vue.d.ts +19 -0
  159. package/dist/components/nodes/ai-workflow/AiToolNode.d.vue.ts +19 -0
  160. package/dist/components/nodes/ai-workflow/AiToolNode.vue +59 -0
  161. package/dist/components/nodes/ai-workflow/AiToolNode.vue.d.ts +19 -0
  162. package/dist/components/nodes/ai-workflow/index.cjs +109 -0
  163. package/dist/components/nodes/ai-workflow/index.d.ts +23 -0
  164. package/dist/components/nodes/ai-workflow/index.mjs +37 -0
  165. package/dist/components/nodes/bpmn/BpmnEndEvent.d.vue.ts +19 -0
  166. package/dist/components/nodes/bpmn/BpmnEndEvent.vue +50 -0
  167. package/dist/components/nodes/bpmn/BpmnEndEvent.vue.d.ts +19 -0
  168. package/dist/components/nodes/bpmn/BpmnExclusiveGateway.d.vue.ts +19 -0
  169. package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue +60 -0
  170. package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue.d.ts +19 -0
  171. package/dist/components/nodes/bpmn/BpmnInclusiveGateway.d.vue.ts +19 -0
  172. package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue +60 -0
  173. package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue.d.ts +19 -0
  174. package/dist/components/nodes/bpmn/BpmnParallelGateway.d.vue.ts +19 -0
  175. package/dist/components/nodes/bpmn/BpmnParallelGateway.vue +60 -0
  176. package/dist/components/nodes/bpmn/BpmnParallelGateway.vue.d.ts +19 -0
  177. package/dist/components/nodes/bpmn/BpmnServiceTask.d.vue.ts +19 -0
  178. package/dist/components/nodes/bpmn/BpmnServiceTask.vue +55 -0
  179. package/dist/components/nodes/bpmn/BpmnServiceTask.vue.d.ts +19 -0
  180. package/dist/components/nodes/bpmn/BpmnStartEvent.d.vue.ts +19 -0
  181. package/dist/components/nodes/bpmn/BpmnStartEvent.vue +50 -0
  182. package/dist/components/nodes/bpmn/BpmnStartEvent.vue.d.ts +19 -0
  183. package/dist/components/nodes/bpmn/BpmnTask.d.vue.ts +19 -0
  184. package/dist/components/nodes/bpmn/BpmnTask.vue +54 -0
  185. package/dist/components/nodes/bpmn/BpmnTask.vue.d.ts +19 -0
  186. package/dist/components/nodes/bpmn/BpmnUserTask.d.vue.ts +19 -0
  187. package/dist/components/nodes/bpmn/BpmnUserTask.vue +55 -0
  188. package/dist/components/nodes/bpmn/BpmnUserTask.vue.d.ts +19 -0
  189. package/dist/components/nodes/bpmn/index.cjs +109 -0
  190. package/dist/components/nodes/bpmn/index.d.ts +23 -0
  191. package/dist/components/nodes/bpmn/index.mjs +37 -0
  192. package/dist/components/nodes/index.cjs +246 -0
  193. package/dist/components/nodes/index.d.ts +13 -0
  194. package/dist/components/nodes/index.mjs +44 -0
  195. package/dist/core/FlowContext.cjs +21 -0
  196. package/dist/core/FlowContext.d.ts +10 -0
  197. package/dist/core/FlowContext.mjs +13 -0
  198. package/dist/core/index.cjs +104 -0
  199. package/dist/core/index.d.ts +9 -0
  200. package/dist/core/index.mjs +9 -0
  201. package/dist/core/useAlignment.cjs +81 -0
  202. package/dist/core/useAlignment.d.ts +33 -0
  203. package/dist/core/useAlignment.mjs +71 -0
  204. package/dist/core/useEdges.cjs +132 -0
  205. package/dist/core/useEdges.d.ts +29 -0
  206. package/dist/core/useEdges.mjs +89 -0
  207. package/dist/core/useFlow.cjs +40 -0
  208. package/dist/core/useFlow.d.ts +31 -0
  209. package/dist/core/useFlow.mjs +32 -0
  210. package/dist/core/useHistory.cjs +63 -0
  211. package/dist/core/useHistory.d.ts +15 -0
  212. package/dist/core/useHistory.mjs +54 -0
  213. package/dist/core/useKeyboard.cjs +54 -0
  214. package/dist/core/useKeyboard.d.ts +18 -0
  215. package/dist/core/useKeyboard.mjs +45 -0
  216. package/dist/core/useNodeDistribution.cjs +171 -0
  217. package/dist/core/useNodeDistribution.d.ts +12 -0
  218. package/dist/core/useNodeDistribution.mjs +145 -0
  219. package/dist/core/useNodes.cjs +146 -0
  220. package/dist/core/useNodes.d.ts +26 -0
  221. package/dist/core/useNodes.mjs +101 -0
  222. package/dist/core/useSelection.cjs +83 -0
  223. package/dist/core/useSelection.d.ts +18 -0
  224. package/dist/core/useSelection.mjs +53 -0
  225. package/dist/core/useViewport.cjs +157 -0
  226. package/dist/core/useViewport.d.ts +65 -0
  227. package/dist/core/useViewport.mjs +125 -0
  228. package/dist/flow.cjs +240 -0
  229. package/dist/flow.d.ts +276 -0
  230. package/dist/flow.mjs +230 -0
  231. package/dist/index.cjs +378 -0
  232. package/dist/index.d.ts +28 -0
  233. package/dist/index.mjs +50 -0
  234. package/dist/plugins/index.cjs +96 -0
  235. package/dist/plugins/index.d.ts +34 -0
  236. package/dist/plugins/index.mjs +47 -0
  237. package/dist/plugins/plugin.cjs +117 -0
  238. package/dist/plugins/plugin.d.ts +72 -0
  239. package/dist/plugins/plugin.mjs +110 -0
  240. package/dist/plugins/plugins/controls.cjs +38 -0
  241. package/dist/plugins/plugins/controls.d.ts +12 -0
  242. package/dist/plugins/plugins/controls.mjs +28 -0
  243. package/dist/plugins/plugins/export.cjs +102 -0
  244. package/dist/plugins/plugins/export.d.ts +12 -0
  245. package/dist/plugins/plugins/export.mjs +89 -0
  246. package/dist/plugins/plugins/grid.cjs +36 -0
  247. package/dist/plugins/plugins/grid.d.ts +11 -0
  248. package/dist/plugins/plugins/grid.mjs +26 -0
  249. package/dist/plugins/plugins/history.cjs +140 -0
  250. package/dist/plugins/plugins/history.d.ts +53 -0
  251. package/dist/plugins/plugins/history.mjs +132 -0
  252. package/dist/plugins/plugins/index.cjs +104 -0
  253. package/dist/plugins/plugins/index.d.ts +9 -0
  254. package/dist/plugins/plugins/index.mjs +9 -0
  255. package/dist/plugins/plugins/keyboard.cjs +27 -0
  256. package/dist/plugins/plugins/keyboard.d.ts +10 -0
  257. package/dist/plugins/plugins/keyboard.mjs +18 -0
  258. package/dist/plugins/plugins/layout.cjs +275 -0
  259. package/dist/plugins/plugins/layout.d.ts +34 -0
  260. package/dist/plugins/plugins/layout.mjs +246 -0
  261. package/dist/plugins/plugins/minimap.cjs +60 -0
  262. package/dist/plugins/plugins/minimap.d.ts +25 -0
  263. package/dist/plugins/plugins/minimap.mjs +50 -0
  264. package/dist/plugins/plugins/node-group.cjs +209 -0
  265. package/dist/plugins/plugins/node-group.d.ts +26 -0
  266. package/dist/plugins/plugins/node-group.mjs +178 -0
  267. package/dist/plugins/plugins/snap.cjs +36 -0
  268. package/dist/plugins/plugins/snap.d.ts +12 -0
  269. package/dist/plugins/plugins/snap.mjs +26 -0
  270. package/dist/renderer/AlignmentLines.d.vue.ts +5 -0
  271. package/dist/renderer/AlignmentLines.vue +113 -0
  272. package/dist/renderer/AlignmentLines.vue.d.ts +5 -0
  273. package/dist/renderer/Background.d.vue.ts +7 -0
  274. package/dist/renderer/Background.vue +86 -0
  275. package/dist/renderer/Background.vue.d.ts +7 -0
  276. package/dist/renderer/Controls.d.vue.ts +13 -0
  277. package/dist/renderer/Controls.vue +82 -0
  278. package/dist/renderer/Controls.vue.d.ts +13 -0
  279. package/dist/renderer/EdgeHandlesRenderer.d.vue.ts +11 -0
  280. package/dist/renderer/EdgeHandlesRenderer.vue +75 -0
  281. package/dist/renderer/EdgeHandlesRenderer.vue.d.ts +11 -0
  282. package/dist/renderer/EdgeRenderer.d.vue.ts +39 -0
  283. package/dist/renderer/EdgeRenderer.vue +204 -0
  284. package/dist/renderer/EdgeRenderer.vue.d.ts +39 -0
  285. package/dist/renderer/FlowBackground.d.vue.ts +11 -0
  286. package/dist/renderer/FlowBackground.vue +82 -0
  287. package/dist/renderer/FlowBackground.vue.d.ts +11 -0
  288. package/dist/renderer/Minimap.d.vue.ts +30 -0
  289. package/dist/renderer/Minimap.vue +290 -0
  290. package/dist/renderer/Minimap.vue.d.ts +30 -0
  291. package/dist/renderer/NodeRenderer.d.vue.ts +56 -0
  292. package/dist/renderer/NodeRenderer.vue +328 -0
  293. package/dist/renderer/NodeRenderer.vue.d.ts +56 -0
  294. package/dist/renderer/SelectionBox.d.vue.ts +11 -0
  295. package/dist/renderer/SelectionBox.vue +28 -0
  296. package/dist/renderer/SelectionBox.vue.d.ts +11 -0
  297. package/dist/types/edge.cjs +13 -0
  298. package/dist/types/edge.d.ts +65 -0
  299. package/dist/types/edge.mjs +6 -0
  300. package/dist/types/events.cjs +1 -0
  301. package/dist/types/events.d.ts +115 -0
  302. package/dist/types/events.mjs +0 -0
  303. package/dist/types/index.cjs +1 -0
  304. package/dist/types/index.d.ts +366 -0
  305. package/dist/types/index.mjs +0 -0
  306. package/dist/types/node.cjs +9 -0
  307. package/dist/types/node.d.ts +90 -0
  308. package/dist/types/node.mjs +3 -0
  309. package/dist/types/viewport.cjs +42 -0
  310. package/dist/types/viewport.d.ts +62 -0
  311. package/dist/types/viewport.mjs +36 -0
  312. package/dist/utils/bpmn-engine.cjs +390 -0
  313. package/dist/utils/bpmn-engine.d.ts +164 -0
  314. package/dist/utils/bpmn-engine.mjs +378 -0
  315. package/dist/utils/bpmn.cjs +492 -0
  316. package/dist/utils/bpmn.d.ts +53 -0
  317. package/dist/utils/bpmn.mjs +430 -0
  318. package/dist/utils/collaboration.cjs +537 -0
  319. package/dist/utils/collaboration.d.ts +189 -0
  320. package/dist/utils/collaboration.mjs +521 -0
  321. package/dist/utils/custom-types.cjs +138 -0
  322. package/dist/utils/custom-types.d.ts +78 -0
  323. package/dist/utils/custom-types.mjs +108 -0
  324. package/dist/utils/edge.cjs +235 -0
  325. package/dist/utils/edge.d.ts +79 -0
  326. package/dist/utils/edge.mjs +172 -0
  327. package/dist/utils/event-bus.cjs +91 -0
  328. package/dist/utils/event-bus.d.ts +39 -0
  329. package/dist/utils/event-bus.mjs +82 -0
  330. package/dist/utils/geometry.cjs +178 -0
  331. package/dist/utils/geometry.d.ts +186 -0
  332. package/dist/utils/geometry.mjs +144 -0
  333. package/dist/utils/graph.cjs +158 -0
  334. package/dist/utils/graph.d.ts +40 -0
  335. package/dist/utils/graph.mjs +147 -0
  336. package/dist/utils/index.cjs +137 -0
  337. package/dist/utils/index.d.ts +12 -0
  338. package/dist/utils/index.mjs +12 -0
  339. package/dist/utils/performance.cjs +94 -0
  340. package/dist/utils/performance.d.ts +18 -0
  341. package/dist/utils/performance.mjs +82 -0
  342. package/dist/utils/screenshot.cjs +87 -0
  343. package/dist/utils/screenshot.d.ts +22 -0
  344. package/dist/utils/screenshot.mjs +66 -0
  345. package/dist/utils/theme.cjs +228 -0
  346. package/dist/utils/theme.d.ts +92 -0
  347. package/dist/utils/theme.mjs +217 -0
  348. package/dist/utils/transform.cjs +76 -0
  349. package/dist/utils/transform.d.ts +45 -0
  350. package/dist/utils/transform.mjs +57 -0
  351. package/dist/utils/validation.cjs +107 -0
  352. package/dist/utils/validation.d.ts +29 -0
  353. package/dist/utils/validation.mjs +85 -0
  354. package/package.json +61 -0
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EventBus = void 0;
7
+ exports.createEventBus = createEventBus;
8
+ exports.getEventBus = getEventBus;
9
+ class EventBus {
10
+ handlers = /* @__PURE__ */new Map();
11
+ /**
12
+ * 订阅事件
13
+ */
14
+ on(event, handler) {
15
+ if (!this.handlers.has(event)) {
16
+ this.handlers.set(event, /* @__PURE__ */new Set());
17
+ }
18
+ this.handlers.get(event).add(handler);
19
+ }
20
+ /**
21
+ * 取消订阅
22
+ */
23
+ off(event, handler) {
24
+ const handlers = this.handlers.get(event);
25
+ if (handlers) {
26
+ handlers.delete(handler);
27
+ if (handlers.size === 0) {
28
+ this.handlers.delete(event);
29
+ }
30
+ }
31
+ }
32
+ /**
33
+ * 触发事件
34
+ */
35
+ emit(event, payload) {
36
+ const handlers = this.handlers.get(event);
37
+ if (handlers) {
38
+ handlers.forEach(handler => {
39
+ try {
40
+ if (payload !== void 0) {
41
+ handler(payload);
42
+ } else {
43
+ handler();
44
+ }
45
+ } catch (error) {
46
+ console.error(`[YhFlow EventBus] Error in event handler for "${event}":`, error);
47
+ }
48
+ });
49
+ }
50
+ }
51
+ /**
52
+ * 单次订阅
53
+ */
54
+ once(event, handler) {
55
+ const wrappedHandler = (...args) => {
56
+ handler(...args);
57
+ this.off(event, handler);
58
+ };
59
+ this.on(event, wrappedHandler);
60
+ }
61
+ /**
62
+ * 清空所有事件处理函数
63
+ */
64
+ clear() {
65
+ this.handlers.clear();
66
+ }
67
+ /**
68
+ * 获取事件处理器数量
69
+ */
70
+ listenerCount(event) {
71
+ if (event) {
72
+ return this.handlers.get(event)?.size || 0;
73
+ }
74
+ let total = 0;
75
+ this.handlers.forEach(handlers => {
76
+ total += handlers.size;
77
+ });
78
+ return total;
79
+ }
80
+ }
81
+ exports.EventBus = EventBus;
82
+ let eventBusInstance = null;
83
+ function getEventBus() {
84
+ if (!eventBusInstance) {
85
+ eventBusInstance = new EventBus();
86
+ }
87
+ return eventBusInstance;
88
+ }
89
+ function createEventBus() {
90
+ return new EventBus();
91
+ }
@@ -0,0 +1,39 @@
1
+ import type { FlowEventKey, FlowEventHandler, FlowEvents } from '../types';
2
+ /**
3
+ * 简单事件总线实现 - 用于 Flow 组件内部和插件系统
4
+ */
5
+ export declare class EventBus {
6
+ private handlers;
7
+ /**
8
+ * 订阅事件
9
+ */
10
+ on<K extends FlowEventKey>(event: K, handler: FlowEventHandler<K>): void;
11
+ /**
12
+ * 取消订阅
13
+ */
14
+ off<K extends FlowEventKey>(event: K, handler: FlowEventHandler<K>): void;
15
+ /**
16
+ * 触发事件
17
+ */
18
+ emit<K extends FlowEventKey>(event: K, payload?: FlowEvents[K]): void;
19
+ /**
20
+ * 单次订阅
21
+ */
22
+ once<K extends FlowEventKey>(event: K, handler: FlowEventHandler<K>): void;
23
+ /**
24
+ * 清空所有事件处理函数
25
+ */
26
+ clear(): void;
27
+ /**
28
+ * 获取事件处理器数量
29
+ */
30
+ listenerCount(event?: FlowEventKey): number;
31
+ }
32
+ /**
33
+ * 获取事件总线单例
34
+ */
35
+ export declare function getEventBus(): EventBus;
36
+ /**
37
+ * 创建新的事件总线实例
38
+ */
39
+ export declare function createEventBus(): EventBus;
@@ -0,0 +1,82 @@
1
+ export class EventBus {
2
+ handlers = /* @__PURE__ */ new Map();
3
+ /**
4
+ * 订阅事件
5
+ */
6
+ on(event, handler) {
7
+ if (!this.handlers.has(event)) {
8
+ this.handlers.set(event, /* @__PURE__ */ new Set());
9
+ }
10
+ this.handlers.get(event).add(handler);
11
+ }
12
+ /**
13
+ * 取消订阅
14
+ */
15
+ off(event, handler) {
16
+ const handlers = this.handlers.get(event);
17
+ if (handlers) {
18
+ handlers.delete(handler);
19
+ if (handlers.size === 0) {
20
+ this.handlers.delete(event);
21
+ }
22
+ }
23
+ }
24
+ /**
25
+ * 触发事件
26
+ */
27
+ emit(event, payload) {
28
+ const handlers = this.handlers.get(event);
29
+ if (handlers) {
30
+ handlers.forEach((handler) => {
31
+ try {
32
+ if (payload !== void 0) {
33
+ handler(payload);
34
+ } else {
35
+ handler();
36
+ }
37
+ } catch (error) {
38
+ console.error(`[YhFlow EventBus] Error in event handler for "${event}":`, error);
39
+ }
40
+ });
41
+ }
42
+ }
43
+ /**
44
+ * 单次订阅
45
+ */
46
+ once(event, handler) {
47
+ const wrappedHandler = ((...args) => {
48
+ handler(...args);
49
+ this.off(event, handler);
50
+ });
51
+ this.on(event, wrappedHandler);
52
+ }
53
+ /**
54
+ * 清空所有事件处理函数
55
+ */
56
+ clear() {
57
+ this.handlers.clear();
58
+ }
59
+ /**
60
+ * 获取事件处理器数量
61
+ */
62
+ listenerCount(event) {
63
+ if (event) {
64
+ return this.handlers.get(event)?.size || 0;
65
+ }
66
+ let total = 0;
67
+ this.handlers.forEach((handlers) => {
68
+ total += handlers.size;
69
+ });
70
+ return total;
71
+ }
72
+ }
73
+ let eventBusInstance = null;
74
+ export function getEventBus() {
75
+ if (!eventBusInstance) {
76
+ eventBusInstance = new EventBus();
77
+ }
78
+ return eventBusInstance;
79
+ }
80
+ export function createEventBus() {
81
+ return new EventBus();
82
+ }
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.angleToCanvasCoordinateSystem = angleToCanvasCoordinateSystem;
7
+ exports.degToRad = degToRad;
8
+ exports.getAngle = getAngle;
9
+ exports.getAngleBetweenPoints = getAngleBetweenPoints;
10
+ exports.getBoundingBox = getBoundingBox;
11
+ exports.getLineIntersection = getLineIntersection;
12
+ exports.getNodeBounds = getNodeBounds;
13
+ exports.getRectIntersection = getRectIntersection;
14
+ exports.isPointInPolygon = isPointInPolygon;
15
+ exports.isPointInRect = isPointInRect;
16
+ exports.pointToLineDistance = pointToLineDistance;
17
+ exports.pointToPointDistance = pointToPointDistance;
18
+ exports.pointToRectDistance = pointToRectDistance;
19
+ exports.radToDeg = radToDeg;
20
+ exports.rectIntersect = rectIntersect;
21
+ exports.viewportIntersectsBounds = viewportIntersectsBounds;
22
+ function isPointInRect(point, rect) {
23
+ return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
24
+ }
25
+ function rectIntersect(rect1, rect2) {
26
+ return !(rect1.x + rect1.width < rect2.x || rect2.x + rect2.width < rect1.x || rect1.y + rect1.height < rect2.y || rect2.y + rect2.height < rect1.y);
27
+ }
28
+ function getRectIntersection(rect1, rect2) {
29
+ if (!rectIntersect(rect1, rect2)) {
30
+ return null;
31
+ }
32
+ const x = Math.max(rect1.x, rect2.x);
33
+ const y = Math.max(rect1.y, rect2.y);
34
+ const width = Math.min(rect1.x + rect1.width, rect2.x + rect2.x) - x;
35
+ const height = Math.min(rect1.y + rect1.height, rect2.y + rect2.height) - y;
36
+ return {
37
+ x,
38
+ y,
39
+ width,
40
+ height
41
+ };
42
+ }
43
+ function getBoundingBox(points) {
44
+ if (points.length === 0) {
45
+ return {
46
+ x: 0,
47
+ y: 0,
48
+ width: 0,
49
+ height: 0
50
+ };
51
+ }
52
+ let minX = Infinity;
53
+ let minY = Infinity;
54
+ let maxX = -Infinity;
55
+ let maxY = -Infinity;
56
+ for (const point of points) {
57
+ minX = Math.min(minX, point.x);
58
+ minY = Math.min(minY, point.y);
59
+ maxX = Math.max(maxX, point.x);
60
+ maxY = Math.max(maxY, point.y);
61
+ }
62
+ return {
63
+ x: minX,
64
+ y: minY,
65
+ width: maxX - minX,
66
+ height: maxY - minY
67
+ };
68
+ }
69
+ function getNodeBounds(nodes) {
70
+ const points = nodes.flatMap(node => {
71
+ const w = node.width || 0;
72
+ const h = node.height || 0;
73
+ return [{
74
+ x: node.position.x,
75
+ y: node.position.y
76
+ }, {
77
+ x: node.position.x + w,
78
+ y: node.position.y + h
79
+ }];
80
+ });
81
+ return getBoundingBox(points);
82
+ }
83
+ function pointToLineDistance(point, lineStart, lineEnd) {
84
+ const A = point.x - lineStart.x;
85
+ const B = point.y - lineStart.y;
86
+ const C = lineEnd.x - lineStart.x;
87
+ const D = lineEnd.y - lineStart.y;
88
+ const dot = A * C + B * D;
89
+ const lenSq = C * C + D * D;
90
+ let param = -1;
91
+ if (lenSq !== 0) {
92
+ param = dot / lenSq;
93
+ }
94
+ let xx;
95
+ let yy;
96
+ if (param < 0) {
97
+ xx = lineStart.x;
98
+ yy = lineStart.y;
99
+ } else if (param > 1) {
100
+ xx = lineEnd.x;
101
+ yy = lineEnd.y;
102
+ } else {
103
+ xx = lineStart.x + param * C;
104
+ yy = lineStart.y + param * D;
105
+ }
106
+ const dx = point.x - xx;
107
+ const dy = point.y - yy;
108
+ return Math.sqrt(dx * dx + dy * dy);
109
+ }
110
+ function pointToPointDistance(p1, p2) {
111
+ const dx = p2.x - p1.x;
112
+ const dy = p2.y - p1.y;
113
+ return Math.sqrt(dx * dx + dy * dy);
114
+ }
115
+ function degToRad(deg) {
116
+ return deg * Math.PI / 180;
117
+ }
118
+ function radToDeg(rad) {
119
+ return rad * 180 / Math.PI;
120
+ }
121
+ function getLineIntersection(line1Start, line1End, line2Start, line2End) {
122
+ const d1x = line1End.x - line1Start.x;
123
+ const d1y = line1End.y - line1Start.y;
124
+ const d2x = line2End.x - line2Start.x;
125
+ const d2y = line2End.y - line2Start.y;
126
+ const cross = d1x * d2y - d1y * d2x;
127
+ if (Math.abs(cross) < 1e-10) {
128
+ return null;
129
+ }
130
+ const d = {
131
+ x: line1Start.x - line2Start.x,
132
+ y: line1Start.y - line2Start.y
133
+ };
134
+ const t = (d.x * d2y - d.y * d2x) / cross;
135
+ return {
136
+ x: line1Start.x + t * d1x,
137
+ y: line1Start.y + t * d1y
138
+ };
139
+ }
140
+ function getAngle(from, to) {
141
+ return Math.atan2(to.y - from.y, to.x - from.x);
142
+ }
143
+ function getAngleBetweenPoints(p1, p2, origin) {
144
+ return Math.atan2(p2.y - origin.y, p2.x - origin.x) - Math.atan2(p1.y - origin.y, p1.x - origin.x);
145
+ }
146
+ function angleToCanvasCoordinateSystem(angle) {
147
+ return -angle;
148
+ }
149
+ function isPointInPolygon(point, polygon) {
150
+ let inside = false;
151
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
152
+ const xi = polygon[i].x;
153
+ const yi = polygon[i].y;
154
+ const xj = polygon[j].x;
155
+ const yj = polygon[j].y;
156
+ const intersect = yi > point.y !== yj > point.y && point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi;
157
+ if (intersect) {
158
+ inside = !inside;
159
+ }
160
+ }
161
+ return inside;
162
+ }
163
+ function pointToRectDistance(point, rect) {
164
+ const rectRight = rect.x + rect.width;
165
+ const rectBottom = rect.y + rect.height;
166
+ const dx = Math.max(rect.x - point.x, 0, point.x - rectRight);
167
+ const dy = Math.max(rect.y - point.y, 0, point.y - rectBottom);
168
+ return Math.sqrt(dx * dx + dy * dy);
169
+ }
170
+ function viewportIntersectsBounds(viewport, bounds, zoom) {
171
+ const scaledBounds = {
172
+ x: bounds.x * zoom,
173
+ y: bounds.y * zoom,
174
+ width: bounds.width * zoom,
175
+ height: bounds.height * zoom
176
+ };
177
+ return rectIntersect(viewport, scaledBounds);
178
+ }
@@ -0,0 +1,186 @@
1
+ /**
2
+ * 判断点是否在矩形内
3
+ */
4
+ export declare function isPointInRect(point: {
5
+ x: number;
6
+ y: number;
7
+ }, rect: {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ }): boolean;
13
+ /**
14
+ * 判断两个矩形是否相交
15
+ */
16
+ export declare function rectIntersect(rect1: {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ }, rect2: {
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ }): boolean;
27
+ /**
28
+ * 获取两个矩形的交集
29
+ */
30
+ export declare function getRectIntersection(rect1: {
31
+ x: number;
32
+ y: number;
33
+ width: number;
34
+ height: number;
35
+ }, rect2: {
36
+ x: number;
37
+ y: number;
38
+ width: number;
39
+ height: number;
40
+ }): {
41
+ x: number;
42
+ y: number;
43
+ width: number;
44
+ height: number;
45
+ } | null;
46
+ /**
47
+ * 获取包含多个点的最小矩形
48
+ */
49
+ export declare function getBoundingBox(points: {
50
+ x: number;
51
+ y: number;
52
+ }[]): {
53
+ x: number;
54
+ y: number;
55
+ width: number;
56
+ height: number;
57
+ };
58
+ /**
59
+ * 获取节点边界框
60
+ */
61
+ export declare function getNodeBounds(nodes: {
62
+ position: {
63
+ x: number;
64
+ y: number;
65
+ };
66
+ width?: number;
67
+ height?: number;
68
+ }[]): {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ };
74
+ /**
75
+ * 计算点到直线的距离
76
+ */
77
+ export declare function pointToLineDistance(point: {
78
+ x: number;
79
+ y: number;
80
+ }, lineStart: {
81
+ x: number;
82
+ y: number;
83
+ }, lineEnd: {
84
+ x: number;
85
+ y: number;
86
+ }): number;
87
+ /**
88
+ * 计算点到点的距离
89
+ */
90
+ export declare function pointToPointDistance(p1: {
91
+ x: number;
92
+ y: number;
93
+ }, p2: {
94
+ x: number;
95
+ y: number;
96
+ }): number;
97
+ /**
98
+ * 角度转弧度
99
+ */
100
+ export declare function degToRad(deg: number): number;
101
+ /**
102
+ * 弧度转角度
103
+ */
104
+ export declare function radToDeg(rad: number): number;
105
+ /**
106
+ * 计算两条线的交点
107
+ */
108
+ export declare function getLineIntersection(line1Start: {
109
+ x: number;
110
+ y: number;
111
+ }, line1End: {
112
+ x: number;
113
+ y: number;
114
+ }, line2Start: {
115
+ x: number;
116
+ y: number;
117
+ }, line2End: {
118
+ x: number;
119
+ y: number;
120
+ }): {
121
+ x: number;
122
+ y: number;
123
+ } | null;
124
+ /**
125
+ * 获取角度
126
+ */
127
+ export declare function getAngle(from: {
128
+ x: number;
129
+ y: number;
130
+ }, to: {
131
+ x: number;
132
+ y: number;
133
+ }): number;
134
+ /**
135
+ * 获取从原点到目标点的角度
136
+ */
137
+ export declare function getAngleBetweenPoints(p1: {
138
+ x: number;
139
+ y: number;
140
+ }, p2: {
141
+ x: number;
142
+ y: number;
143
+ }, origin: {
144
+ x: number;
145
+ y: number;
146
+ }): number;
147
+ /**
148
+ * 角度规范化到 [-PI, PI]
149
+ */
150
+ export declare function angleToCanvasCoordinateSystem(angle: number): number;
151
+ /**
152
+ * 判断点是否在多边形内
153
+ */
154
+ export declare function isPointInPolygon(point: {
155
+ x: number;
156
+ y: number;
157
+ }, polygon: {
158
+ x: number;
159
+ y: number;
160
+ }[]): boolean;
161
+ /**
162
+ * 点到矩形边缘的最短距离
163
+ */
164
+ export declare function pointToRectDistance(point: {
165
+ x: number;
166
+ y: number;
167
+ }, rect: {
168
+ x: number;
169
+ y: number;
170
+ width: number;
171
+ height: number;
172
+ }): number;
173
+ /**
174
+ * 检查视口是否与边界相交(用于虚拟滚动)
175
+ */
176
+ export declare function viewportIntersectsBounds(viewport: {
177
+ x: number;
178
+ y: number;
179
+ width: number;
180
+ height: number;
181
+ }, bounds: {
182
+ x: number;
183
+ y: number;
184
+ width: number;
185
+ height: number;
186
+ }, zoom: number): boolean;
@@ -0,0 +1,144 @@
1
+ export function isPointInRect(point, rect) {
2
+ return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
3
+ }
4
+ export function rectIntersect(rect1, rect2) {
5
+ return !(rect1.x + rect1.width < rect2.x || rect2.x + rect2.width < rect1.x || rect1.y + rect1.height < rect2.y || rect2.y + rect2.height < rect1.y);
6
+ }
7
+ export function getRectIntersection(rect1, rect2) {
8
+ if (!rectIntersect(rect1, rect2)) {
9
+ return null;
10
+ }
11
+ const x = Math.max(rect1.x, rect2.x);
12
+ const y = Math.max(rect1.y, rect2.y);
13
+ const width = Math.min(rect1.x + rect1.width, rect2.x + rect2.x) - x;
14
+ const height = Math.min(rect1.y + rect1.height, rect2.y + rect2.height) - y;
15
+ return { x, y, width, height };
16
+ }
17
+ export function getBoundingBox(points) {
18
+ if (points.length === 0) {
19
+ return { x: 0, y: 0, width: 0, height: 0 };
20
+ }
21
+ let minX = Infinity;
22
+ let minY = Infinity;
23
+ let maxX = -Infinity;
24
+ let maxY = -Infinity;
25
+ for (const point of points) {
26
+ minX = Math.min(minX, point.x);
27
+ minY = Math.min(minY, point.y);
28
+ maxX = Math.max(maxX, point.x);
29
+ maxY = Math.max(maxY, point.y);
30
+ }
31
+ return {
32
+ x: minX,
33
+ y: minY,
34
+ width: maxX - minX,
35
+ height: maxY - minY
36
+ };
37
+ }
38
+ export function getNodeBounds(nodes) {
39
+ const points = nodes.flatMap((node) => {
40
+ const w = node.width || 0;
41
+ const h = node.height || 0;
42
+ return [
43
+ { x: node.position.x, y: node.position.y },
44
+ { x: node.position.x + w, y: node.position.y + h }
45
+ ];
46
+ });
47
+ return getBoundingBox(points);
48
+ }
49
+ export function pointToLineDistance(point, lineStart, lineEnd) {
50
+ const A = point.x - lineStart.x;
51
+ const B = point.y - lineStart.y;
52
+ const C = lineEnd.x - lineStart.x;
53
+ const D = lineEnd.y - lineStart.y;
54
+ const dot = A * C + B * D;
55
+ const lenSq = C * C + D * D;
56
+ let param = -1;
57
+ if (lenSq !== 0) {
58
+ param = dot / lenSq;
59
+ }
60
+ let xx;
61
+ let yy;
62
+ if (param < 0) {
63
+ xx = lineStart.x;
64
+ yy = lineStart.y;
65
+ } else if (param > 1) {
66
+ xx = lineEnd.x;
67
+ yy = lineEnd.y;
68
+ } else {
69
+ xx = lineStart.x + param * C;
70
+ yy = lineStart.y + param * D;
71
+ }
72
+ const dx = point.x - xx;
73
+ const dy = point.y - yy;
74
+ return Math.sqrt(dx * dx + dy * dy);
75
+ }
76
+ export function pointToPointDistance(p1, p2) {
77
+ const dx = p2.x - p1.x;
78
+ const dy = p2.y - p1.y;
79
+ return Math.sqrt(dx * dx + dy * dy);
80
+ }
81
+ export function degToRad(deg) {
82
+ return deg * Math.PI / 180;
83
+ }
84
+ export function radToDeg(rad) {
85
+ return rad * 180 / Math.PI;
86
+ }
87
+ export function getLineIntersection(line1Start, line1End, line2Start, line2End) {
88
+ const d1x = line1End.x - line1Start.x;
89
+ const d1y = line1End.y - line1Start.y;
90
+ const d2x = line2End.x - line2Start.x;
91
+ const d2y = line2End.y - line2Start.y;
92
+ const cross = d1x * d2y - d1y * d2x;
93
+ if (Math.abs(cross) < 1e-10) {
94
+ return null;
95
+ }
96
+ const d = {
97
+ x: line1Start.x - line2Start.x,
98
+ y: line1Start.y - line2Start.y
99
+ };
100
+ const t = (d.x * d2y - d.y * d2x) / cross;
101
+ return {
102
+ x: line1Start.x + t * d1x,
103
+ y: line1Start.y + t * d1y
104
+ };
105
+ }
106
+ export function getAngle(from, to) {
107
+ return Math.atan2(to.y - from.y, to.x - from.x);
108
+ }
109
+ export function getAngleBetweenPoints(p1, p2, origin) {
110
+ return Math.atan2(p2.y - origin.y, p2.x - origin.x) - Math.atan2(p1.y - origin.y, p1.x - origin.x);
111
+ }
112
+ export function angleToCanvasCoordinateSystem(angle) {
113
+ return -angle;
114
+ }
115
+ export function isPointInPolygon(point, polygon) {
116
+ let inside = false;
117
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
118
+ const xi = polygon[i].x;
119
+ const yi = polygon[i].y;
120
+ const xj = polygon[j].x;
121
+ const yj = polygon[j].y;
122
+ const intersect = yi > point.y !== yj > point.y && point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi;
123
+ if (intersect) {
124
+ inside = !inside;
125
+ }
126
+ }
127
+ return inside;
128
+ }
129
+ export function pointToRectDistance(point, rect) {
130
+ const rectRight = rect.x + rect.width;
131
+ const rectBottom = rect.y + rect.height;
132
+ const dx = Math.max(rect.x - point.x, 0, point.x - rectRight);
133
+ const dy = Math.max(rect.y - point.y, 0, point.y - rectBottom);
134
+ return Math.sqrt(dx * dx + dy * dy);
135
+ }
136
+ export function viewportIntersectsBounds(viewport, bounds, zoom) {
137
+ const scaledBounds = {
138
+ x: bounds.x * zoom,
139
+ y: bounds.y * zoom,
140
+ width: bounds.width * zoom,
141
+ height: bounds.height * zoom
142
+ };
143
+ return rectIntersect(viewport, scaledBounds);
144
+ }