List the possibilities of interactions
List all the shapes that can be drawn
Lists all events that can be listened to on the canvas or DOM element
The server version, fetched once and stored in the configuration
Message for an error code the server sends, undefined when it has none of its own
Reads the exports of a websocket message, parsing the JIIX sent as a JSON string
Reads a recognition response body according to its content type
Posts a recognition request and reads its response
The undo/redo state a contentChanged message carries, both websocket protocols alike
List all authorized gestures
result of a math solver message, by action
The contentType a recognition request names for a recognition type: "TEXT" → "Text", "Raw Content" as is
Turns what a failed postRecognition threw into the error reported to the caller
A request waiting on an answer from the server
One handler per message type the server sends
Math solver message for one action
Message the server sends, by TWebSocketClientMessageType
Message the server sends, by type
Exports as the websocket protocols send them: every format a string, JIIX included
Clone any TSymbol — all types are now plain objects, use structuredClone.
Filter the stroke symbols out of a list that may contain other symbol types (text, math, shapes, ...).
Check if symbol is a standalone decorator
Check if symbol is math
Check if symbol is a stroke with Math JIIX metadata
Check if symbol is a stroke with Text JIIX metadata
Check if symbol is a stroke
Check if symbol is a stroke with Solver Output JIIX metadata
Check if symbol is text
Create any TSymbol from partial data, by asking the registry which util owns the type.
There used to be a switch here with a branch per built-in type, calling each family's Ops
directly and falling back to the registry only for unknown types. That made the registry a
second-class path: ShapeUtil.create and EdgeUtil.create were never reached, so the switch
on kind inside them was dead code kept alive by a contract nobody called.
Requires registerBuiltinSymbolUtils to have run. Both canvases that create symbols from
partials call it in initialize(), and the error below says so rather than letting a missing
registration surface as a TypeError.
Create multiple TSymbols from partial data — accumulates errors.
A symbol drawn as a single <path>.
The shape of most of what the library renders — a stroke, a geometric shape, an edge. Each one
used to build a <g>, append one <path> to it and return the group, which is three copies of an
assembly that differs only in what goes on the path.
There is no group any more. A group holding exactly one child adds a node per symbol and
carries nothing the child could not carry itself: id, type and kind are found by attribute
either way, transform on a single child is the same transform, and stroke-linecap and
stroke-linejoin inherit. On a 4419-symbol document that is 4419 nodes the browser no longer
lays out.
One attribute did not merely move: vector-effect. It is not an inherited property, so on the
group it applied to the group — which draws nothing — and never reached the path. It was inert.
On the path it takes effect, and non-scaling-stroke means what it says: stroke width stops
growing with the zoom, since the renderer zooms by viewBox. That is a deliberate change of
appearance, not a side effect — the attribute had been asking for this since it was written.
A type in this family says what its path is worth drawing — its d, and the fill, stroke and
width around it — and inherits the rest.
Reads a symbol's derived geometry — bounds, vertices, snap points, edges, length.
Every accessor below calls the module-level of directly rather than this.of — so
const { boundsOf } = SymbolGeometry and symbols.map(SymbolGeometry.boundsOf) both work. A
this-bound accessor throws the moment it is detached from the object, which is exactly the
shape a read-site migration across the codebase produces.
Registry for SymbolUtil implementations.
Built-in types are registered via registerBuiltinSymbolUtils(), which the
canvas calls on initialisation. External consumers may register additional
types before or after canvas creation:
Plugin interface for registering symbol behaviour.
Implement this class to add a new symbol type that participates in the standard dispatch for factory, derived-field updates, overlap detection, snap-point extraction, and capability flags.
Register with symbolRegistry.register(new MyUtil()).
Plugin interface for registering symbol behaviour.
Implement this class to add a new symbol type that participates in the standard dispatch for factory, derived-field updates, overlap detection, snap-point extraction, and capability flags.
Register with symbolRegistry.register(new MyUtil()).
Where each occupant sits when the configuration does not say
List all action allowed on split detected
List all action allowed on join detected
The places of the canvas UI where menus and other occupants sit; the center belongs to the ink
Places the canvas UI occupants (menus, connection state, minimap, custom ones) in the slots of the layout
The horizontal side a slot sits against, which a dropdown grows away from
The side a slot's menus open towards: away from the edge they sit on
The axis a slot gives its menus: vertical bars on the sides, horizontal ones at the top and bottom
List all action allowed on strikeThrough detected
List all action allowed on surround detected
What goes in each slot, in stacking order
A custom occupant declared at load, in options.extend.layout
What a custom occupant's factory knows of its slot, to fit it
Builds a custom occupant's element each time it is placed, so it can fit its slot
Where a custom occupant goes when the layout table does not place it already
The side a menu's dropdowns open towards
The axis of a menu's bar
List all action allowed on underline detected
Abstract base class for all renderer implementations
Defines the common interface that both Canvas and SVG renderers must implement, enabling consistent rendering behavior across different output formats.
List all svg elements resize direction
List all svg elements roles
Base renderer configuration interface
Common configuration properties required by all renderer implementations.
What every menu shares: its items, their lifecycle, its zones and the dropdown mechanics
Builds an item each time its menu renders: a menu destroys its items, which cannot be reused
An item declared at load, in options.extend.menuItems: in its menu from the first render
How a menu sits in its slot; without them, the slot decides (see configuration.layout)
Menu classes options.override.menu can replace
How the style menu sits in its slot: TMenuLayoutConfig, and whether its panel folds
Where an item goes in a menu: its always-visible row, or the column behind its trigger
An item registered through IIMenuManager.addItem, added after the menu's own items
Split a JIIX export's elements into diagram Nodes/Edges and their Text labels
Find the Text element whose bounding-box center lands inside a given box
Convert a JIIX export into a flat, prompt-ready JSON structure for LLM consumption
Convert a JIIX export into a Markdown string
Convert a JIIX diagram export into a Mermaid flowchart
Convert a JIIX diagram export into a PlantUML diagram
Resolve the two Nodes an Edge connects
Sanitize a JIIX element id into a valid Mermaid/PlantUML identifier
Convert a LaTeX math string into a flat UnicodeMath-compatible linear string
A circle, tested by its radius rather than by a polygon standing in for it.
Its overlap is exact, where every other curved shape here settles for a sampled outline: a circle is the one curve with a cheap closed-form answer to "does this segment cross me", so it would be perverse to approximate it. Its box is exact too, and free — a circle's box is its radius.
An ellipse, and so also a circle that a matrix has stretched out of shape.
Two things are exact here and were approximations before: its box, and what it becomes under a transform. Its overlap test is not — see Ellipse2d.computeVertices.
A shape that can answer questions about itself.
Geometry used to be data — a { bounds, vertices, edges, length } record each symbol type built
for itself — and every type then had to carry its own overlaps, because a record cannot be
asked anything. Six of the eight ended up as the same call, polygonOverlapsBox, and the two
that did not (a stroke tests its pointers, a circle tests its radius) had to be special-cased
elsewhere. Here the shape answers, so a symbol type only has to say what shape it is.
The hole this closes. polygonOverlapsBox is "the shape's bounds sit inside the query, or
some edge crosses some side of it". Both halves are about the boundary, so a query landing
entirely within a shape without touching its outline was missed — a real miss for a filled
shape, and correct for an unfilled one. Nothing in a plain record could tell those apart;
TGeometry2dOptions.isFilled does.
Derived values are computed once per instance. vertices, edges, bounds and length all
fall out of each other, and a caller that reads bounds usually reads vertices next. Instances are
themselves cached per symbol by SymbolGeometry, so "once per instance" is once per symbol
version — there is no invalidation to get wrong, because a changed symbol is a different object
and gets a different instance.
An ordered run of sampled points, caught by the samples themselves.
The shape a stroke has. Its path, its length and its bounds all come from the same run of points, so everything Geometry2d derives is already right here — only the overlap test differs, and it differs on purpose.
Why the test is the points and not the path. Everything else in this module answers "does the query touch the shape I draw". A stroke answers a different question: "did the query catch a sample". The two part company when a query slips between two consecutive samples — a box crossing the segment without containing either end. Treating that as a hit is right for a drawn line and wrong for a stroke, whose selection has always meant the points it captured. Preserving that is not conservatism: a stroke samples sparsely where the pen moved fast, so an edge-crossing test would make a quick flick selectable from far more places than a slow one drawn identically.
isClosed is false — the last sample does not join back to the first, and inventing that edge
would add a phantom segment straight across the stroke, lengthening it and giving hit-testing
something to catch that was never drawn. isFilled is false for the same reason a line has no
inside.
A shape defined by a list of points it stores.
What every straight-edged geometry here has in common: it holds its vertices rather than deriving
them, so computeVertices is the list, and moving it is mapping the list. Only the flags and, for
one of them, the overlap test differ — which is all a subclass is left to say.
Curved shapes do not belong here. A circle is defined by a centre and a radius, and tessellating it into a point list is what it does to approximate itself for a generic test, not what it is.
A closed run of vertices: the last joins back to the first.
The shape of a polygon, and of anything a straight-edged outline approximates — a tessellated ellipse, the box a typeset symbol is measured at. Everything it answers comes from Geometry2d: a closed ring of straight edges is exactly the case the base class computes for, so there is nothing to override but the vertices and how they move.
isFilled is a real question, not a default. It decides whether a point inside the outline,
touching no edge, counts as a hit — and with it, whether a selection box lying wholly within the
shape selects it. The test this replaces, OBBOps.polygonOverlapsBox, could not ask: it is "the
shape's bounds sit inside the query, or an edge crosses a side of it", both of which are about the
boundary, so a query strictly inside was always missed. That is right for an outline and wrong for
a filled shape, and only the caller knows which it has.
An open run of vertices: a drawn path that does not close.
The shape of a line, a polyline, and of an arc once tessellated. It is a Polygon2d minus the closing edge, and that edge is the whole difference: without it the last vertex joins nothing, so the path has a length rather than a perimeter and no inside for anything to be in.
Caught by a query its path crosses — the generic test Geometry2d provides, which is the right one for a line someone drew. A stroke looks the same and is not tested this way; see PointSet2d for why.
The two vectors the unit circle's axes are sent to.
An ellipse is the image of the unit circle under a linear map, and this is that map: the point at
angle t is center + (xx·cos t + xy·sin t, yx·cos t + yy·sin t). (xx, yx) is where (1, 0)
lands and (xy, yy) where (0, 1) does.
Stored this way rather than as radii and an orientation because it is what makes Ellipse2d.transform exact and cheap: carrying an ellipse through a matrix is composing the two maps, where radii and an angle would have to be recovered from the product — a singular value decomposition, per transform, to describe the same thing.
What a geometry is, beyond the points it is made of.
Two independent questions, and conflating them is what left a hole in the test this replaces.
isClosed — does the last vertex join back to the first? A polygon does, a polyline does not.
It decides whether Geometry2d.edges emits a closing edge, and so what the perimeter is.isFilled — does the inside belong to the shape? A rectangle with a fill does, the same
rectangle drawn as an outline does not. It decides whether a point strictly inside, touching no
edge, counts as a hit.Options on the base rather than separate subclasses: a filled and an unfilled polygon differ in one predicate, not in how either computes anything.
Compute approximate average radius of an ellipse
Compute how many vertices a curve of the given length should tessellate into
Millimeters in one CSS pixel (96 per inch)
Round a value to the nearest multiple of a step
Target length of one segment when a curve is approximated by a polyline
Get diagnostic message for a given diagnostic code
Main Canvas facade for loading canvas instances
This class provides a convenient interface for loading canvas instances. It delegates to CanvasFactory for the actual implementation.