@octaviaflow/core 3.0.18-beta.11 → 3.0.18-beta.13

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 (35) hide show
  1. package/dist/chunk-3DWB2PUF.js +2991 -0
  2. package/dist/chunk-3DWB2PUF.js.map +1 -0
  3. package/dist/chunk-6QCJK7H7.js +2991 -0
  4. package/dist/chunk-6QCJK7H7.js.map +1 -0
  5. package/dist/chunk-76TP67ED.js +2984 -0
  6. package/dist/chunk-76TP67ED.js.map +1 -0
  7. package/dist/chunk-DBNSBJO7.js +2993 -0
  8. package/dist/chunk-DBNSBJO7.js.map +1 -0
  9. package/dist/chunk-ECIHUVU7.js +2986 -0
  10. package/dist/chunk-ECIHUVU7.js.map +1 -0
  11. package/dist/chunk-MXJL3EPE.js +2986 -0
  12. package/dist/chunk-MXJL3EPE.js.map +1 -0
  13. package/dist/chunk-MYZ25B2R.js +2995 -0
  14. package/dist/chunk-MYZ25B2R.js.map +1 -0
  15. package/dist/chunk-Q6ERDPQR.js +2981 -0
  16. package/dist/chunk-Q6ERDPQR.js.map +1 -0
  17. package/dist/chunk-UQBPYONV.js +2991 -0
  18. package/dist/chunk-UQBPYONV.js.map +1 -0
  19. package/dist/chunk-WEGED7TA.js +2991 -0
  20. package/dist/chunk-WEGED7TA.js.map +1 -0
  21. package/dist/chunk-ZAMJEU42.js +2992 -0
  22. package/dist/chunk-ZAMJEU42.js.map +1 -0
  23. package/dist/index.cjs +57 -43
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/workflow/components/FlowCanvas/FlowCanvas.d.ts.map +1 -1
  27. package/dist/workflow/components/FlowEdge/FlowEdge.d.ts.map +1 -1
  28. package/dist/workflow/components/Handle/Handle.d.ts +9 -1
  29. package/dist/workflow/components/Handle/Handle.d.ts.map +1 -1
  30. package/dist/workflow/components/Handle/handleRegistry.d.ts +19 -0
  31. package/dist/workflow/components/Handle/handleRegistry.d.ts.map +1 -1
  32. package/dist/workflow.cjs +57 -43
  33. package/dist/workflow.cjs.map +1 -1
  34. package/dist/workflow.js +1 -1
  35. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -29797,6 +29797,9 @@ function createHandleRegistry() {
29797
29797
  resolve(nodeId, type, handleId) {
29798
29798
  return map.get(key(nodeId, type, handleId));
29799
29799
  },
29800
+ all() {
29801
+ return Array.from(map.values());
29802
+ },
29800
29803
  subscribe(listener) {
29801
29804
  listeners.add(listener);
29802
29805
  return () => {
@@ -29837,6 +29840,8 @@ function FlowEdgeImpl({
29837
29840
  const targetDesc = registry.resolve(targetNode.id, "target", targetHandleId);
29838
29841
  const sourceSide = sourceDesc?.side ?? sourceNode.sourcePosition ?? "bottom";
29839
29842
  const targetSide = targetDesc?.side ?? targetNode.targetPosition ?? "top";
29843
+ const sourceRoute = sourceDesc?.routeSide ?? sourceSide;
29844
+ const targetRoute = targetDesc?.routeSide ?? targetSide;
29840
29845
  const sourceIndex = sourceDesc?.index ?? 0;
29841
29846
  const sourceTotal = sourceDesc?.total ?? 1;
29842
29847
  const targetIndex = targetDesc?.index ?? 0;
@@ -29844,14 +29849,14 @@ function FlowEdgeImpl({
29844
29849
  const rawStart = handleCentre(sourceNode, sourceSide, sourceIndex, sourceTotal);
29845
29850
  const rawEnd = handleCentre(targetNode, targetSide, targetIndex, targetTotal);
29846
29851
  const HANDLE_GAP = 8;
29847
- const start = offsetAlongSide3(rawStart, sourceSide, HANDLE_GAP);
29848
- const end = offsetAlongSide3(rawEnd, targetSide, HANDLE_GAP);
29852
+ const start = offsetAlongSide3(rawStart, sourceRoute, HANDLE_GAP);
29853
+ const end = offsetAlongSide3(rawEnd, targetRoute, HANDLE_GAP);
29849
29854
  const routing = edge.routing ?? "bezier";
29850
- const { d, midX, midY } = buildEdgePath(routing, start, sourceSide, end, targetSide, {
29855
+ const { d, midX, midY } = buildEdgePath(routing, start, sourceRoute, end, targetRoute, {
29851
29856
  curvature,
29852
29857
  borderRadius
29853
29858
  });
29854
- const { d: hitD } = buildEdgePath(routing, rawStart, sourceSide, rawEnd, targetSide, {
29859
+ const { d: hitD } = buildEdgePath(routing, rawStart, sourceRoute, rawEnd, targetRoute, {
29855
29860
  curvature,
29856
29861
  borderRadius
29857
29862
  });
@@ -30169,6 +30174,7 @@ var DEFAULT_HANDLE_ID = "default";
30169
30174
  function Handle({
30170
30175
  type,
30171
30176
  position,
30177
+ routeSide,
30172
30178
  id = DEFAULT_HANDLE_ID,
30173
30179
  isConnectable = true,
30174
30180
  isConnectableStart,
@@ -30191,11 +30197,14 @@ function Handle({
30191
30197
  handleId: id,
30192
30198
  type,
30193
30199
  side: position,
30200
+ routeSide: routeSide ?? position,
30194
30201
  index,
30195
- total
30202
+ total,
30203
+ canStart,
30204
+ canEnd
30196
30205
  });
30197
30206
  return dispose;
30198
- }, [registry, node.id, id, type, position, index, total]);
30207
+ }, [registry, node.id, id, type, position, routeSide, index, total, canStart, canEnd]);
30199
30208
  const handlePointerDown = (e) => {
30200
30209
  if (!canStart) return;
30201
30210
  e.stopPropagation();
@@ -31331,49 +31340,54 @@ function FlowCanvas2(props) {
31331
31340
  }
31332
31341
  const c = connRef.current;
31333
31342
  if (c && c.pointerId === e.pointerId) {
31334
- let handleEl = null;
31335
- if (typeof document !== "undefined") {
31336
- const stack = document.elementsFromPoint(e.clientX, e.clientY);
31337
- for (const el of stack) {
31338
- const candidate = el.closest(
31339
- "[data-handle-id]"
31340
- );
31341
- if (!candidate) continue;
31342
- if (candidate.dataset.handleNodeId === c.from.nodeId) continue;
31343
- handleEl = candidate;
31344
- break;
31343
+ const rect = containerRef.current?.getBoundingClientRect();
31344
+ const flowPos = rect ? screenToFlow({ x: e.clientX - rect.left, y: e.clientY - rect.top }, vp) : { x: 0, y: 0 };
31345
+ const snapRadius = 26 / Math.max(0.1, vp.zoom);
31346
+ let bestDesc = null;
31347
+ let bestDist = snapRadius;
31348
+ for (const desc of handleRegistry.all()) {
31349
+ if (desc.nodeId === c.from.nodeId) continue;
31350
+ if (desc.type === c.from.handleType) continue;
31351
+ if (!desc.canEnd) continue;
31352
+ const targetNode = nodesRef.current.find((n) => n.id === desc.nodeId);
31353
+ if (!targetNode || targetNode.hidden) continue;
31354
+ const centre = handleCentre(targetNode, desc.side, desc.index, desc.total);
31355
+ const dist = Math.hypot(centre.x - flowPos.x, centre.y - flowPos.y);
31356
+ if (dist < bestDist) {
31357
+ bestDist = dist;
31358
+ bestDesc = desc;
31345
31359
  }
31346
31360
  }
31347
31361
  let connection = null;
31348
31362
  let connectedTo;
31349
- if (handleEl) {
31350
- const targetNodeId = handleEl.dataset.handleNodeId;
31351
- const targetHandleId = handleEl.dataset.handleId;
31352
- const targetType = handleEl.dataset.handleType;
31353
- const connectableEnd = handleEl.dataset.handleConnectableEnd === "true";
31354
- if (connectableEnd && (targetNodeId !== c.from.nodeId || targetHandleId !== c.from.handleId) && targetType !== c.from.handleType) {
31355
- const source = c.from.handleType === "source" ? c.from : { nodeId: targetNodeId, handleId: targetHandleId, handleType: "source" };
31356
- const target2 = c.from.handleType === "target" ? c.from : { nodeId: targetNodeId, handleId: targetHandleId, handleType: "target" };
31357
- connection = {
31358
- source: source.nodeId,
31359
- sourceHandle: source.handleId,
31360
- target: target2.nodeId,
31361
- targetHandle: target2.handleId
31362
- };
31363
- connectedTo = {
31364
- nodeId: targetNodeId,
31365
- handleId: targetHandleId,
31366
- handleType: targetType
31367
- };
31368
- const validator = isValidConnectionRef.current;
31369
- if (validator && !validator(connection)) {
31370
- connection = null;
31371
- connectedTo = void 0;
31372
- }
31363
+ if (bestDesc) {
31364
+ const source = c.from.handleType === "source" ? c.from : {
31365
+ nodeId: bestDesc.nodeId,
31366
+ handleId: bestDesc.handleId,
31367
+ handleType: "source"
31368
+ };
31369
+ const target2 = c.from.handleType === "target" ? c.from : {
31370
+ nodeId: bestDesc.nodeId,
31371
+ handleId: bestDesc.handleId,
31372
+ handleType: "target"
31373
+ };
31374
+ connection = {
31375
+ source: source.nodeId,
31376
+ sourceHandle: source.handleId,
31377
+ target: target2.nodeId,
31378
+ targetHandle: target2.handleId
31379
+ };
31380
+ connectedTo = {
31381
+ nodeId: bestDesc.nodeId,
31382
+ handleId: bestDesc.handleId,
31383
+ handleType: bestDesc.type
31384
+ };
31385
+ const validator = isValidConnectionRef.current;
31386
+ if (validator && !validator(connection)) {
31387
+ connection = null;
31388
+ connectedTo = void 0;
31373
31389
  }
31374
31390
  }
31375
- const rect = containerRef.current?.getBoundingClientRect();
31376
- const flowPos = rect ? screenToFlow({ x: e.clientX - rect.left, y: e.clientY - rect.top }, vp) : { x: 0, y: 0 };
31377
31391
  const endState = {
31378
31392
  cancelled: !connection,
31379
31393
  position: { x: e.clientX, y: e.clientY },