Files
next-ai-draw-io/NOTICE
dayuan.jiang a3814f702d feat(diagram-engine): flowcharts, swimlanes, sequence diagrams and mind maps
Extends the declarative engine past cloud architecture. The tool routing was
divided by icon library — AWS through the engine, everything else hand-written
XML — which is the wrong axis. What matters is the LAYOUT SHAPE.

Measured first: a six-step approval flow declared in its natural order comes out
as one column, because the layout only arranges what nesting tells it to and
never looked at the arrows. That forces the arrow from the decision to its second
branch to jump over the first branch.

graph.ts computes what the layout should have looked at: layer assignment by
longest path, cycle breaking so a loop is drawn without setting the order, and
barycentre sweeping to cut edge crossings. It emits ordinary container
operations, so layout, routing and round-tripping are unchanged — reaching zero
arrows-through-boxes on a 14-node pipeline and zero crossings on a bipartite
graph whose declared order forces three.

Three new container kinds, each because one layout rule cannot serve them all:

  pool     — swimlanes. Lanes are real cells and each step is parented to its
             band, so dragging a step to another role records the change.
  sequence — participants across the top, one lifeline cell per participant so
             head and line stay together on a drag. Messages bypass the router:
             a message's height IS its order.
  radial   — mind maps and org charts. Children are a flat list and the
             hierarchy comes from the links, because a branch is a box and a box
             cannot hold children.

Flowchart box shapes (diamond, stadium, parallelogram, document) so a reader can
tell a branch from a step.

Two bugs the new tests caught: the duplicate-link guard blocked a sequence
diagram from having two messages between the same pair, and the fallback message
numbering was shared across containers, pushing a second diagram's messages off
its own lifelines.

523 unit tests and 17 diagram e2e tests pass. Every kind verified round-trip
stable to a fixed point, and rendered in a real browser — draw.io keeps the
lifeline shape and the lane markers.
2026-08-09 13:49:11 +09:00

53 lines
2.3 KiB
Plaintext

next-ai-draw-io
Copyright the next-ai-draw-io contributors
This product includes software developed by third parties, as set out below.
--------------------------------------------------------------------------------
lib/diagram-engine/ — layout and rendering
--------------------------------------------------------------------------------
The declarative layout algorithm (bottom-up measure, top-down place, sibling
size equalisation), the swimlane-pool geometry, and the mxCell/style emission in
`lib/diagram-engine/layout.ts` and `lib/diagram-engine/render.ts` are derived
from drawio-ai-kit:
https://github.com/sparklabx/drawio-ai-kit
Copyright (c) sparklabx
Licensed under the MIT License
Original to this repository:
- the XML→tree reverse parser (`parse.ts`), which that project does not have
- the style-marker scheme (`markers.ts`) that lets structure survive a
round-trip through the draw.io editor
- the structural-operations layer (`operations.ts`)
- the invisible-container approach that replaces that project's "phantom" nodes
- the edge router (`route.ts`)
- the graph→layers pass (`graph.ts`): layer assignment, cycle breaking and
barycentre crossing reduction, which turn a flat node/arrow list into a
flowchart
- the sequence-diagram and radial (mind map / org chart) layouts
--------------------------------------------------------------------------------
lib/diagram-engine/data/aws-stencils.json — stencil catalog
--------------------------------------------------------------------------------
A name→style map for the mxgraph.aws4 stencil family, generated from
drawio-ai-kit's `catalog/aws.json`, which in turn was generated from the draw.io
shape index published by jgraph:
https://github.com/jgraph/drawio-mcp
Copyright (c) JGraph Ltd
Licensed under the Apache License, Version 2.0
The style strings are reproduced verbatim from that index. They reference the
official AWS Architecture Icons, which are trademarks of Amazon Web Services and
are NOT covered by this repository's licence. Their use is governed by the AWS
Architecture Icons terms:
https://aws.amazon.com/architecture/icons/
The catalog contains stencil *names and style strings* only — it does not embed
any AWS icon artwork. draw.io supplies the artwork at render time.