Skip to content

feat(joint-router-avoid): new avoid router package - #3457

Open
kumilingus wants to merge 50 commits into
clientIO:masterfrom
kumilingus:router-avoid-api-cleanup
Open

feat(joint-router-avoid): new avoid router package#3457
kumilingus wants to merge 50 commits into
clientIO:masterfrom
kumilingus:router-avoid-api-cleanup

Conversation

@kumilingus

@kumilingus kumilingus commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Supersedes #3443.

Summary

  • Adds @joint/router-avoid, a new package that routes JointJS links via libavoid (WASM, through libavoid-js), keeping a graph's links obstacle-avoiding and orthogonally routed - no router: attribute needed once a link connects two elements. Ships both a main-thread provider and a Web-Worker-backed provider (worker: true) for larger graphs.
  • Extracts the rightAngle router's path-finding into a new public @joint/core alg.rightAnglePath function, shared between the built-in rightAngle router and @joint/router-avoid's fallback route (used while avoid computes a link's real route, or when a link can't be routed by avoid at all). Fixes stale flat-property references left over from the bbox-based refactor that were breaking most of the rightAngle router's own test suite.
  • Adds useModelGeometry to the rightAngle router's options.
  • Adds examples/avoid-router-ts, a TypeScript demo app (simple graph, two independent RouterService instances on one dia.Graph, large graph routed via a Web Worker).
  • Full TSDoc across the public and internal API.

API surface

  • initAvoidRouter(graph, options) / loadAvoidRouter(filePath?) - entry points (also on the UMD global as joint.routers.avoid.*). The returned RouterService is not started: start()/stop() for continuous routing, routeAll()/routeSubgraph(cells) for one-shot passes (e.g. routing each container's content independently), isStarted, destroy().
  • Positive filter callbacks trackLink/trackElement select what is routed/tracked as an obstacle.
  • interceptUnroutableLink gives the consumer first refusal on a link avoid can't route, with a reason: 'unconnected' (loose end), 'untracked' (end element excluded via trackElement), or 'unsupported' (link-to-link connection).
  • setRouteAttributes overrides how computed routes are applied (e.g. through a command manager), receiving origin: 'avoid' | 'fallback' and the provisional/final state; changeFlag names the opt flag marking the router's own writes.
  • worker: boolean | { debounceTime?: number } runs libavoid inside a Web Worker; debounceTime controls how long the Worker batches incoming updates before processing them in one transaction.
  • Events: link:routing, link:routed ({ origin, reason }), link:routing:cancelled, idle.

Test plan

  • yarn test for @joint/router-avoid passes (28/28)
  • @joint/core's test suite passes, including the previously-broken rightAngle router suite
  • examples/avoid-router-ts type-checks (tsc --noEmit)
  • Manual review of the libavoid integration (main-thread and Worker providers) against a real app

🤖 Generated with Claude Code

Geliogabalus and others added 18 commits August 13, 2026 14:06
# Conflicts:
#	packages/joint-core/src/routers/rightAngle.mjs
- rename unroutable reason 'untracked-element' to 'untracked',
  matching the trackElement option it derives from
- replace useWorker/workerUpdateDebounceTime with nested
  worker: boolean | { debounceTime } so the debounce option
  cannot be set without the worker it belongs to
- align provider-level default values with initAvoidRouter
  (shapeBufferDistance 10, idealNudgingDistance 5)
- export public option/callback types under their real names
  (index.mts still aliased the old Skip* names)
- document why WorkerProvider.sync may resolve on an
  uncorrelated 'processed' response
- update READMEs and examples to the current API

Note: test/index.js still asserts 'untracked-element' and needs
updating by the package author.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kumilingus kumilingus changed the title refactor(router-avoid): public API cleanup on top of #3443 feat(joint-router-avoid): new avoid router package Aug 17, 2026
kumilingus and others added 2 commits August 17, 2026 22:28
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants