@@ -6,7 +6,18 @@ import { writable, derived, get } from 'svelte/store';
66import type { Position } from '$lib/types/common' ;
77import type { Connection , Waypoint } from '$lib/types/nodes' ;
88import type { RoutingContext , RouteResult , Bounds , Direction , PortStub } from '$lib/routing' ;
9- import { calculateRoute , calculateRouteWithWaypoints , calculateSimpleRoute , getPathCells , ROUTING_MARGIN } from '$lib/routing' ;
9+ import {
10+ calculateRoute ,
11+ calculateRouteWithWaypoints ,
12+ calculateSimpleRoute ,
13+ getPathCells ,
14+ ROUTING_MARGIN ,
15+ ASYNC_BATCH_SIZE ,
16+ WAYPOINT_MERGE_THRESHOLD ,
17+ WAYPOINT_COLLINEAR_THRESHOLD ,
18+ ROUTING_CONTEXT_PADDING
19+ } from '$lib/routing' ;
20+ import { DEFAULT_NODE_WIDTH , DEFAULT_NODE_HEIGHT } from '$lib/constants/dimensions' ;
1021import { SparseGrid } from '$lib/routing/gridBuilder' ;
1122import { generateId } from '$lib/stores/utils' ;
1223import { graphStore } from '$lib/stores/graph' ;
@@ -53,9 +64,6 @@ function hashRouteInputs(
5364 return `${ sourcePos . x } ,${ sourcePos . y } |${ targetPos . x } ,${ targetPos . y } |${ sourceDir } |${ targetDir } |${ wpHash } ` ;
5465}
5566
56- /** Number of routes to calculate per async batch before yielding to browser */
57- const ASYNC_BATCH_SIZE = 8 ;
58-
5967interface RoutingState {
6068 /** Cached routes by connection ID */
6169 routes : Map < string , RouteResult > ;
@@ -734,8 +742,8 @@ export const routingStore = {
734742 const sourcePos = sourceInfo ?. position || null ;
735743 const targetPos = targetInfo ?. position || null ;
736744
737- const MERGE_THRESHOLD = 15 ; // Pixels - merge waypoints closer than this
738- const COLLINEAR_THRESHOLD = 5 ; // Pixels - consider collinear if deviation less than this
745+ const MERGE_THRESHOLD = WAYPOINT_MERGE_THRESHOLD ;
746+ const COLLINEAR_THRESHOLD = WAYPOINT_COLLINEAR_THRESHOLD ;
739747
740748 // Helper to check if point is collinear with prev and next
741749 const isCollinear = ( prev : Position , curr : Position , next : Position ) : boolean => {
@@ -856,7 +864,7 @@ export const routingStore = {
856864 */
857865export function buildRoutingContext (
858866 nodes : Array < { id : string ; position : Position ; width ?: number ; height ?: number ; measured ?: { width ?: number ; height ?: number } } > ,
859- padding = 100
867+ padding = ROUTING_CONTEXT_PADDING
860868) : { nodeBounds : Map < string , Bounds > ; canvasBounds : Bounds } {
861869 const nodeBounds = new Map < string , Bounds > ( ) ;
862870
@@ -866,8 +874,8 @@ export function buildRoutingContext(
866874 let maxY = - Infinity ;
867875
868876 for ( const node of nodes ) {
869- const width = node . measured ?. width ?? node . width ?? 80 ;
870- const height = node . measured ?. height ?? node . height ?? 40 ;
877+ const width = node . measured ?. width ?? node . width ?? DEFAULT_NODE_WIDTH ;
878+ const height = node . measured ?. height ?? node . height ?? DEFAULT_NODE_HEIGHT ;
871879
872880 // Node position is center (nodeOrigin = [0.5, 0.5])
873881 const left = node . position . x - width / 2 ;
0 commit comments