0.5 is a rewrite of the bindings: embind instead of WebIDL, emsdk 7.0.0, and a JS/TS-native API on top. Code written for 0.4.x or the 0.5 betas needs changes; see the migration guide for a table from every old call to the new one.
router.addShape,
router.addJunction, router.addConnector, shape.addPin,
junction.addPin. ShapeRef, JunctionRef, ConnRef and
ShapeConnectionPin can no longer be constructed with new.{x, y} / {x, y, width, height} objects and arrays of
points. Rectangles are given by their top-left corner and size, not
libavoid's centre.Avoid.Point and Avoid.Rect classes. They have no
.delete().Box is replaced by Rect: x/y/width/height fields instead of
min/max and width()/height()/length().Avoid.Polygon, Rectangle, PolygonInterface, ConnEnd,
Checkpoint, CheckpointVector, PointVector and Box; Point.id/vn;
ShapeRef.setNewPoly; ShapeConnectionPin.position(polygon).moveShape_poly / moveShape_delta → moveShape;moveJunction_point / moveJunction_delta → moveJunction;setSourceEndpoint / setDestEndpoint → setSource / setDest, which
take {x, y}, {shape, pin} or {junction};Point.equal → Point.equals.displayRoute() and polygon() return Point[];position() and recommendedPosition() return a Point;routingBox() returns a Rect;routingCheckpoints() returns {x, y, arrival, departure}[].{ id }.ConnRef object they were
registered on (no wrapPointer, no new handle per call).Avoid.RouterFlag.OrthogonalRouting,
Avoid.RoutingParameter.shapeBufferDistance, Avoid.ConnDirFlag.ConnDirUp,
and so on. The numeric values are unchanged.Avoid.destroy, wrapPointer and getPointer are removed.
deleteLater() is no longer in the typings, and clone() throws for
router-owned objects.esnext.disposable).Only the router needs .delete(). All other objects are owned by it:
obj.delete() or using removes one, the same as router.deleteShape(obj) etc.,
and router.delete() frees everything. A deleted object reports
isDeleted() === true, and using it throws instead of reading freed memory.
Before, values needed .delete(), temporaries such as
new Rectangle(new Point(...)) leaked silently, and calling .delete() on a
router-owned object bypassed the router.
Every argument is validated before it reaches wasm. A misspelt enum name, a
missing coordinate, NaN, a bad id or an object of another router throws a
TypeError / RangeError that names the method and argument. Before, these
could abort the whole module or produce wrong routes silently. These libavoid
restrictions that aborted the module now throw:
moveShape cannot change a shape's number of points;pin.setConnectionCost needs a cost >= 0;pin.updatePosition works only on a shape's pin, not on a junction's.Avoid.offsetPolygon, Avoid.boundingRectPolygon and
Avoid.offsetBoundingBox as functions on point arrays;
connector.hasValidRoute() and hasCrossingObstacles(); junctions and
router.deleteJunction; routing checkpoints.package.json declares "type": "module", so Node treats dist/index.js
as the ES module it is.