feat(joint-router-avoid): new avoid router package - #3457
Open
kumilingus wants to merge 50 commits into
Open
Conversation
… content after paper unfreeze Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# 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>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #3443.
Summary
@joint/router-avoid, a new package that routes JointJS links via libavoid (WASM, throughlibavoid-js), keeping a graph's links obstacle-avoiding and orthogonally routed - norouter: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.rightAnglerouter's path-finding into a new public@joint/corealg.rightAnglePathfunction, shared between the built-inrightAnglerouter 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 therightAnglerouter's own test suite.useModelGeometryto therightAnglerouter's options.examples/avoid-router-ts, a TypeScript demo app (simple graph, two independentRouterServiceinstances on onedia.Graph, large graph routed via a Web Worker).API surface
initAvoidRouter(graph, options)/loadAvoidRouter(filePath?)- entry points (also on the UMD global asjoint.routers.avoid.*). The returnedRouterServiceis not started:start()/stop()for continuous routing,routeAll()/routeSubgraph(cells)for one-shot passes (e.g. routing each container's content independently),isStarted,destroy().trackLink/trackElementselect what is routed/tracked as an obstacle.interceptUnroutableLinkgives the consumer first refusal on a link avoid can't route, with a reason:'unconnected'(loose end),'untracked'(end element excluded viatrackElement), or'unsupported'(link-to-link connection).setRouteAttributesoverrides how computed routes are applied (e.g. through a command manager), receivingorigin: 'avoid' | 'fallback'and the provisional/final state;changeFlagnames theoptflag marking the router's own writes.worker: boolean | { debounceTime?: number }runs libavoid inside a Web Worker;debounceTimecontrols how long the Worker batches incoming updates before processing them in one transaction.link:routing,link:routed({ origin, reason }),link:routing:cancelled,idle.Test plan
yarn testfor@joint/router-avoidpasses (28/28)@joint/core's test suite passes, including the previously-brokenrightAnglerouter suiteexamples/avoid-router-tstype-checks (tsc --noEmit)🤖 Generated with Claude Code