@draftably/markdown 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/chunks/mermaid-importer-S5o6DWXk.js +4381 -0
  2. package/dist/mermaid.js +1 -1
  3. package/dist/types/src/dsl/compile.d.ts +2 -0
  4. package/dist/types/src/dsl/sequence-layout.d.ts +87 -0
  5. package/dist/types/src/dsl/syntax.d.ts +8 -2
  6. package/dist/types/src/engines/layout/arrange.d.ts +36 -0
  7. package/dist/types/src/engines/layout/compute.d.ts +7 -0
  8. package/dist/types/src/engines/layout/forces.d.ts +8 -0
  9. package/dist/types/src/engines/layout/grid.d.ts +10 -0
  10. package/dist/types/src/engines/layout/intent.d.ts +14 -0
  11. package/dist/types/src/engines/layout/layered.d.ts +5 -0
  12. package/dist/types/src/engines/layout/objective.d.ts +6 -0
  13. package/dist/types/src/engines/layout/packing.d.ts +7 -0
  14. package/dist/types/src/engines/layout/report.d.ts +7 -0
  15. package/dist/types/src/engines/layout/scene.d.ts +53 -0
  16. package/dist/types/src/engines/layout/seed.d.ts +3 -0
  17. package/dist/types/src/engines/layout/separation.d.ts +17 -0
  18. package/dist/types/src/engines/layout/settings.d.ts +6 -0
  19. package/dist/types/src/engines/layout/topology.d.ts +18 -0
  20. package/dist/types/src/engines/layout/trees.d.ts +8 -0
  21. package/dist/types/src/engines/layout/types.d.ts +133 -0
  22. package/dist/types/src/engines/layout/util.d.ts +19 -0
  23. package/dist/types/src/engines/layout-engine.d.ts +15 -0
  24. package/dist/types/src/engines/routing/compute.d.ts +6 -0
  25. package/dist/types/src/engines/routing/conflicts.d.ts +36 -0
  26. package/dist/types/src/engines/routing/context.d.ts +37 -0
  27. package/dist/types/src/engines/routing/cost.d.ts +13 -0
  28. package/dist/types/src/engines/routing/doglegs.d.ts +16 -0
  29. package/dist/types/src/engines/routing/find.d.ts +6 -0
  30. package/dist/types/src/engines/routing/geometry.d.ts +24 -0
  31. package/dist/types/src/engines/routing/heap.d.ts +20 -0
  32. package/dist/types/src/engines/routing/improve.d.ts +7 -0
  33. package/dist/types/src/engines/routing/nudge.d.ts +7 -0
  34. package/dist/types/src/engines/routing/paths.d.ts +8 -0
  35. package/dist/types/src/engines/routing/planned.d.ts +7 -0
  36. package/dist/types/src/engines/routing/ports.d.ts +10 -0
  37. package/dist/types/src/engines/routing/repair.d.ts +9 -0
  38. package/dist/types/src/engines/routing/score.d.ts +12 -0
  39. package/dist/types/src/engines/routing/search.d.ts +16 -0
  40. package/dist/types/src/engines/routing/settings.d.ts +4 -0
  41. package/dist/types/src/engines/routing/sidepairs.d.ts +20 -0
  42. package/dist/types/src/engines/routing/tidy-ports.d.ts +13 -0
  43. package/dist/types/src/engines/routing/tidy.d.ts +10 -0
  44. package/dist/types/src/engines/routing/tuning.d.ts +9 -0
  45. package/dist/types/src/engines/routing/types.d.ts +157 -0
  46. package/dist/types/src/engines/routing-engine.d.ts +20 -0
  47. package/dist/types/src/import/import-core.d.ts +5 -0
  48. package/dist/types/src/import/mermaid-sequence.d.ts +1 -1
  49. package/dist/types/src/model/appearance.d.ts +10 -1
  50. package/dist/types/src/model/labels.d.ts +23 -0
  51. package/dist/types/src/model/markers.d.ts +7 -0
  52. package/dist/types/src/model/note.d.ts +11 -2
  53. package/dist/types/src/model/routes.d.ts +5 -3
  54. package/dist/types/src/model/status.d.ts +18 -0
  55. package/dist/types/src/model/types.d.ts +20 -1
  56. package/package.json +2 -2
  57. package/dist/chunks/mermaid-importer-DcseMRou.js +0 -4157
@@ -0,0 +1,16 @@
1
+ import { type Line } from './conflicts.ts';
2
+ import type { NearBox, Obstacle, Point, RoutingSettings } from './types.ts';
3
+ export interface Lanes {
4
+ xs: number[];
5
+ ys: number[];
6
+ }
7
+ export declare function laneLines(used: Line[], s: RoutingSettings): Lanes;
8
+ export declare function doglegs(a: Point, b: Point, obs: Obstacle[], s: RoutingSettings, lanes: Lanes, near: NearBox[], room: number, visit: (path: Point[], k: number, horizontal?: boolean) => void): void;
9
+ /**
10
+ * A lower bound on the crossings `conflicts` finds between a dogleg (2 to 4 points, before
11
+ * `compress`) and `used`: segments that cross well inside both. Two such crossings are never one
12
+ * point of one route, so each is a crossing `conflicts` counts. Runs along a fixed line use the
13
+ * level or upright segments that span it; a dogleg's middle run, which moves with its lane, uses
14
+ * the segments inside its fixed span.
15
+ */
16
+ export declare function crossingFloor(used: Line[]): (a: Point, b: Point) => (raw: Point[], horizontal?: boolean) => number;
@@ -0,0 +1,6 @@
1
+ import type { Context } from './context.ts';
2
+ import type { Obstacle, PriorRoute, Route, RouteEdge } from './types.ts';
3
+ /** The sides an edge had before, to keep them (`portStability`) or, with `quick`, to reuse them. */
4
+ type Prior = PriorRoute | null | undefined;
5
+ export declare function find(ctx: Context, e: RouteEdge, used: Route[], old?: Prior, wall?: Obstacle[]): Route;
6
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { Obstacle, Point, Rect, Side } from './types.ts';
2
+ export declare const SIDES: Side[], EPS = 0.0001;
3
+ export declare const round: (n: number) => number, clamp: (n: number, a: number, b: number) => number;
4
+ export declare const clone: <T>(v: T) => T, cmp: (a: string, b: string) => 0 | 1 | -1;
5
+ export declare const center: (r: Rect) => Point;
6
+ export declare const same: (a: Point, b: Point) => boolean;
7
+ /** Distance along the axes: every line is level or upright. */
8
+ export declare const distance: (a: Point, b: Point) => number;
9
+ /** The unit vector out of each side. */
10
+ export declare const vector: Record<Side, Point>;
11
+ export declare function inflate<R extends Rect>(r: R, p: number): R;
12
+ /** Whether the level or upright segment a→b enters an obstacle. A slanted segment always does. */
13
+ export declare function blocked(a: Point, b: Point, obs: Obstacle[]): boolean;
14
+ /** A path with rounded points, without repeats or points inside a straight run. */
15
+ export declare function compress(ps: Point[]): Point[];
16
+ export declare function segments(ps: Point[]): [Point, Point][];
17
+ export declare function below(a: number[], v: number): number;
18
+ export declare function atMost(a: number[], v: number): number;
19
+ export declare function lengthOf(ps: Point[]): number;
20
+ export declare function bendsOf(start: Point, ps: Point[], end: Point): number;
21
+ /** Length of a route's axis-aligned segments that lies inside rectangle `r`. */
22
+ export declare function insideLength(ps: Point[], r: Rect): number;
23
+ /** The length of a path, added segment by segment. */
24
+ export declare const pathLength: (ps: Point[]) => number;
@@ -0,0 +1,20 @@
1
+ /** A binary min-heap on `f`, in typed arrays. `pop` leaves the entry in `key` and `g`. */
2
+ export declare class Heap {
3
+ keys: Int32Array;
4
+ gs: Float64Array;
5
+ fs: Float64Array;
6
+ length: number;
7
+ key: number;
8
+ g: number;
9
+ constructor();
10
+ push(key: number, g: number, f: number): void;
11
+ pop(): void;
12
+ }
13
+ /** A binary min-heap of objects ordered by `before`. */
14
+ export declare class Queue<T> {
15
+ items: T[];
16
+ before: (a: T, b: T) => boolean;
17
+ constructor(before: (a: T, b: T) => boolean);
18
+ push(v: T): void;
19
+ pop(): T;
20
+ }
@@ -0,0 +1,7 @@
1
+ import type { Context } from './context.ts';
2
+ /**
3
+ * Routes again each line that is blocked, crosses, shares a run, runs too close to another or
4
+ * uses a far side, worst first, and keeps a new route when the whole drawing costs less. Returns
5
+ * how many it kept.
6
+ */
7
+ export declare function improve(ctx: Context): number;
@@ -0,0 +1,7 @@
1
+ import type { Context } from './context.ts';
2
+ /**
3
+ * Slide complete internal orthogonal segments into nearby free channels.
4
+ * Endpoints, sides, node coordinates and authored waypoint routes stay fixed.
5
+ * Returns how many routes it moved.
6
+ */
7
+ export declare function nudge(ctx: Context): number;
@@ -0,0 +1,8 @@
1
+ import { type Context } from './context.ts';
2
+ import type { Obstacle, Point, Route, RouteEdge, Side } from './types.ts';
3
+ /**
4
+ * Whether a path leaves and enters along its sides' normals, stays level or upright, clears the
5
+ * obstacles (its own end boxes aside, on the first and last segment) and never doubles back.
6
+ */
7
+ export declare function validPath(points: Point[], e: RouteEdge, fs: Side, ts: Side, obs: Obstacle[]): boolean;
8
+ export declare function simplify(ctx: Context, points: Point[], e: RouteEdge, fs: Side, ts: Side, obs: Obstacle[], used: Route[]): Point[];
@@ -0,0 +1,7 @@
1
+ import type { Context } from './context.ts';
2
+ import type { Route, RouteEdge } from './types.ts';
3
+ /**
4
+ * A line's planned route (`plan`, from a `flow` scope's ranks) is its route when it leaves and
5
+ * enters by facing sides and clears every box.
6
+ */
7
+ export declare function planned(ctx: Context, e: RouteEdge): Route | null;
@@ -0,0 +1,10 @@
1
+ import type { End, Point, Rect, Route, RoutingSettings, ShapeKind, Side } from './types.ts';
2
+ /** The fields of a route that hold the side and the offset of one end. */
3
+ export declare const sideKey: (end: End) => `${End}Side`;
4
+ export declare const offsetKey: (end: End) => `${End}Offset`;
5
+ /** The point on `side` of a shape, `offset` along it from the middle, on the shape's outline. */
6
+ export declare function port(rect: Rect & {
7
+ shape?: ShapeKind;
8
+ }, side: Side, offset?: number): Point;
9
+ export declare const TIGHT_PITCH = 12;
10
+ export declare function slot(id: string, side: Side, r: Rect, used: Route[], s: RoutingSettings, other: Rect, tight?: boolean, spread?: boolean): number;
@@ -0,0 +1,9 @@
1
+ import type { Context } from './context.ts';
2
+ /**
3
+ * Edges are routed one at a time, so a crossing priced when the later edge was routed is never
4
+ * repaired: moving either line alone costs more than the crossing. Try each crossing pair
5
+ * together: route one with the other's line as a wall, then the other round it, and keep the
6
+ * pair when the drawing as a whole costs less (NEXT.md item 9, R6).
7
+ * Returns how many pairs it rerouted.
8
+ */
9
+ export declare function repair(ctx: Context): number;
@@ -0,0 +1,12 @@
1
+ import type { Context } from './context.ts';
2
+ import type { Candidate, Point, PriorRoute, Route, RouteEdge, Side } from './types.ts';
3
+ /**
4
+ * The score of a candidate route of edge `e` against the routed lines `used`: length, bends,
5
+ * standoff, crossings and lane conflicts, plus what its sides cost (far sides, conventions, fans,
6
+ * the layout's direction, a change from `old`). `from` and `to` are the sides the edge may use.
7
+ */
8
+ export declare function createScorer(ctx: Context, e: RouteEdge, used: Route[], old: PriorRoute | null | undefined, from: Side[], to: Side[]): {
9
+ axis: (c: Candidate) => number;
10
+ score: (points: Point[], c: Candidate, bound?: number, floor?: boolean) => number;
11
+ sideFloor: (c: Candidate) => number;
12
+ };
@@ -0,0 +1,16 @@
1
+ import type { NearBox, Obstacle, Point, Route, RoutingSettings } from './types.ts';
2
+ /** Search window margins round the two boxes, tried in turn; null is the whole grid. */
3
+ export declare const WINDOWS: (number | null)[];
4
+ /** A search window: only grid lines inside it are used. */
5
+ export interface Window {
6
+ x0: number;
7
+ y0: number;
8
+ x1: number;
9
+ y1: number;
10
+ }
11
+ /**
12
+ * A* over the grid of lines through the ends, the obstacles' sides, the standoff bands and a lane
13
+ * beside every routed line. Returns the cheapest path from `start` to `end`, or null when none
14
+ * is found within `limit` visits.
15
+ */
16
+ export declare function search(start: Point, end: Point, obs: Obstacle[], used: Route[], s: RoutingSettings, near?: NearBox[], limit?: number, win?: Window | null): Point[] | null;
@@ -0,0 +1,4 @@
1
+ import type { RoutingSettings } from './types.ts';
2
+ export declare const defaults: RoutingSettings;
3
+ /** Checked settings: defaults under `raw`, with every number held to its range. */
4
+ export declare function settings(raw?: Partial<RoutingSettings>): RoutingSettings;
@@ -0,0 +1,20 @@
1
+ import type { Context } from './context.ts';
2
+ import type { Candidate, Obstacle, PriorRoute, Route, RouteEdge, Side } from './types.ts';
3
+ /** One pair of sides an edge may use, with its ports and stubs, and how to look for its paths. */
4
+ export interface SidePair {
5
+ c: Candidate;
6
+ /** Stacked neighbours closer than two stubs: the stubs meet halfway and no grid search runs. */
7
+ tight: boolean;
8
+ /** The obstacles its doglegs must clear. */
9
+ walls: Obstacle[];
10
+ /** The two ports face each other on one clear line. */
11
+ straight: boolean;
12
+ /** False for an edge with waypoints: only the grid search routes it. */
13
+ paths: boolean;
14
+ }
15
+ /**
16
+ * Port choice: for each allowed pair of sides, the port offsets the fans already on those sides
17
+ * leave free, the stubs out of them, and the obstacles gated to them. Pairs whose stubs are
18
+ * blocked, or whose diamond vertex is taken while another is free, are left out.
19
+ */
20
+ export declare function sidePairs(ctx: Context, e: RouteEdge, used: Route[], edgeObs: Obstacle[], from: Side[], to: Side[], axis: (c: Candidate) => number, old: PriorRoute | null | undefined): SidePair[];
@@ -0,0 +1,13 @@
1
+ import type { Context } from './context.ts';
2
+ import type { Box, End, Point, Route } from './types.ts';
3
+ /**
4
+ * Tries a tidy move: new points for some routes, by index, with their new offsets. It stands
5
+ * only when every moved route stays valid and nothing gets worse.
6
+ */
7
+ export type Attempt = (changes: Map<number, Point[]>, extra?: Record<number, Partial<Route>>, throughWaypoints?: boolean, slack?: number) => boolean;
8
+ /** Whether a shape's sides are straight, so a port may slide along them. */
9
+ export declare const flat: (r: Box) => boolean;
10
+ export declare const ends: End[];
11
+ /** The point `k` steps in from one end of a path. */
12
+ export declare const tip: (ps: Point[], end: End, k?: number) => Point;
13
+ export declare function centrePorts(ctx: Context, attempt: Attempt): void;
@@ -0,0 +1,10 @@
1
+ import type { Context } from './context.ts';
2
+ /**
3
+ * Tidy: make routes look drafted on purpose. Ports on a side sit symmetrically
4
+ * about its centre, edges fanning from one side turn on one line, and parallel
5
+ * runs in a corridor keep one pitch. A move stands only when every moved route
6
+ * stays valid and nothing gets worse: no crossing, shared run, lane conflict,
7
+ * short step or standoff cost is added.
8
+ * Returns how many moves stood.
9
+ */
10
+ export declare function tidy(ctx: Context): number;
@@ -0,0 +1,9 @@
1
+ import type { Flow, Side } from './types.ts';
2
+ export declare const AXIS_PENALTY = 100, TRAILING: Record<Flow, Side>, LEADING: Record<Flow, Side>, BACK_PENALTY = 300, BACK_OUT: Record<Flow, Side[]>, BACK_IN: Record<Flow, Side[]>;
3
+ export declare const HOOK_PENALTY = 80;
4
+ export declare const ARRIVE_BELOW = 40, ARRIVE_RIGHT = 12, LEAVE_BACK = 12, DETOUR_WEIGHT = 0.5, LINGER_WEIGHT = 0.3, BOUND_SLACK = 1;
5
+ export declare const FAN_PITCH = 10;
6
+ export declare const DETOUR_RATIO = 1.75, DETOUR_SOFT = 1.2, BAND_COST = 120;
7
+ export declare const PORT_SLACK = 4;
8
+ export declare const FAR_PENALTY = 100, OWN_STANDOFF = 1;
9
+ export declare const MAX_REPAIRS = 4, FAN_GROUP = 4, REPAIR_EDGES = 32;
@@ -0,0 +1,157 @@
1
+ import type { EdgeLayout, Point, Rect, RoutingSettings, ShapeKind, Side } from '../../model/types.ts';
2
+ export interface RouteNodeInput extends Rect {
3
+ id: string;
4
+ parentId?: string;
5
+ shape: ShapeKind;
6
+ /** The stub for lines that end on an open group's frame: the group's rectangle. */
7
+ frame?: boolean;
8
+ }
9
+ export interface RouteGroupInput extends Rect {
10
+ id: string;
11
+ parentId?: string;
12
+ collapsed: boolean;
13
+ /** Width of the header's icon and title from the group's left edge; the rest of the band is open. */
14
+ titleWidth?: number;
15
+ /** Height of the title band the router keeps clear; 28 when unset. */
16
+ titleHeight?: number;
17
+ }
18
+ export interface RouteEdgeInput {
19
+ id: string;
20
+ from: string;
21
+ to: string;
22
+ directed?: boolean;
23
+ /** The edge's text. A labelled edge keeps the full port gap in a fan. */
24
+ label?: string;
25
+ cfg: EdgeLayout;
26
+ }
27
+ export interface RouteInput {
28
+ nodes: RouteNodeInput[];
29
+ groups: RouteGroupInput[];
30
+ edges: RouteEdgeInput[];
31
+ }
32
+ export interface Route {
33
+ id: string;
34
+ from: string;
35
+ to: string;
36
+ fromSide: Side;
37
+ toSide: Side;
38
+ fromOffset: number;
39
+ toOffset: number;
40
+ points: Point[];
41
+ blocked: boolean;
42
+ reason?: string;
43
+ }
44
+ export interface PriorRoute {
45
+ id: string;
46
+ fromSide: Side;
47
+ toSide: Side;
48
+ }
49
+ /** What a set of routes costs: the counts the passes compare and the report shows. */
50
+ export interface RouteMetrics {
51
+ crossings: number;
52
+ shared: number;
53
+ lanePairs: number;
54
+ laneDeficit: number;
55
+ minimumConflictingGap: number | null;
56
+ requestedEdgeGap: number;
57
+ blocked: number;
58
+ bends: number;
59
+ length: number;
60
+ }
61
+ export interface RoutingReport extends RouteMetrics {
62
+ initial: RouteMetrics;
63
+ accepted: number;
64
+ /** Crossing pairs the repair pass rerouted. Absent with `quick` or `facing: false`. */
65
+ repaired?: number;
66
+ nudged: number;
67
+ tidied?: number;
68
+ edges: number;
69
+ milliseconds: number;
70
+ passes: number;
71
+ }
72
+ export interface RoutingResult {
73
+ routes: Route[];
74
+ report: RoutingReport;
75
+ }
76
+ export interface RoutingOptions extends Partial<RoutingSettings> {
77
+ previous?: PriorRoute[];
78
+ quick?: boolean;
79
+ /** A reading direction for every edge without its own `cfg.flow`; forward edges run along it. */
80
+ direction?: 'right' | 'down';
81
+ /**
82
+ * Keep fans on the sides facing their other ends, off far sides, and a full standoff away
83
+ * from their own end boxes. On unless false.
84
+ */
85
+ facing?: boolean;
86
+ /**
87
+ * Keep lines out of a group's title band, except a line straight into or out of a member's
88
+ * top. On unless false.
89
+ */
90
+ titleBands?: boolean;
91
+ /** Search each route near its two boxes first, and the whole grid only when that fails. On unless false. */
92
+ window?: boolean;
93
+ /** Even out ports, fans and corridors after routing. On unless false. */
94
+ tidy?: boolean;
95
+ /**
96
+ * In the tidy pass, straighten steps under 12px by sliding a run (and its port, or through a
97
+ * fold lane's waypoints) onto the next. On unless false.
98
+ */
99
+ jogs?: boolean;
100
+ }
101
+ export type Axis = 'x' | 'y';
102
+ /** Which end of an edge: its source or its target. */
103
+ export type End = 'from' | 'to';
104
+ export type Flow = 'right' | 'down';
105
+ /** A shape the router ends lines on: a node, or a collapsed group drawn as a box. */
106
+ export type Box = Rect & {
107
+ id: string;
108
+ parentId?: string;
109
+ shape?: ShapeKind;
110
+ frame?: boolean;
111
+ };
112
+ /**
113
+ * A rectangle no line may enter. `across` lets an upright line cross it but none run along it;
114
+ * with `gates`, only at those x coordinates.
115
+ */
116
+ export type Obstacle = Rect & {
117
+ id?: string;
118
+ across?: boolean;
119
+ gates?: number[];
120
+ };
121
+ /** A box or group border that lines should keep `band` away from, at a cost instead of a wall. */
122
+ export type NearBox = Rect & {
123
+ id: string;
124
+ band: number;
125
+ /** A group border: it counts from both sides. */
126
+ border?: boolean;
127
+ weight?: number;
128
+ };
129
+ /** A side and offset the repair pass fixes at one end of an edge. */
130
+ export interface Pin {
131
+ side: Side;
132
+ offset: number;
133
+ }
134
+ /** An edge as routed: the input edge with a config, and the repair pass's pins. */
135
+ export type RouteEdge = RouteEdgeInput & {
136
+ pin?: Partial<Record<End, Pin>>;
137
+ };
138
+ /** One choice of sides and ports for an edge, with its stubs and the obstacles it sees. */
139
+ export interface Candidate {
140
+ /** Source and target sides. */
141
+ fs: Side;
142
+ ts: Side;
143
+ /** Port offsets along those sides. */
144
+ fo: number;
145
+ toff: number;
146
+ start: Point;
147
+ end: Point;
148
+ /** Where the stubs out of each port end. */
149
+ as: Point;
150
+ bs: Point;
151
+ obs: Obstacle[];
152
+ /** A lower bound on the route's score, to order the grid searches. */
153
+ lower: number;
154
+ /** The fan-out cost of the side pair, worked out once. */
155
+ fanout?: number;
156
+ }
157
+ export type { EdgeLayout, Point, Rect, RoutingSettings, ShapeKind, Side };
@@ -0,0 +1,20 @@
1
+ import { compute } from './routing/compute.ts';
2
+ import { conflicts, parallelConflicts, type Line } from './routing/conflicts.ts';
3
+ import { blocked } from './routing/geometry.ts';
4
+ import { port } from './routing/ports.ts';
5
+ import { settings } from './routing/settings.ts';
6
+ export declare const RouteLab: {
7
+ compute: typeof compute;
8
+ settings: typeof settings;
9
+ defaults: import("./routing/types.ts").RoutingSettings;
10
+ port: typeof port;
11
+ blocked: typeof blocked;
12
+ conflicts: typeof conflicts;
13
+ parallelConflicts: typeof parallelConflicts;
14
+ /** Crossings and shared run length of a set of routes, each counted against the ones before it. */
15
+ metrics: (routes: Line[]) => {
16
+ crossings: number;
17
+ shared: number;
18
+ };
19
+ };
20
+ export type { PriorRoute, Route, RouteEdgeInput, RouteGroupInput, RouteInput, RouteMetrics, RouteNodeInput, RoutingOptions, RoutingReport, RoutingResult, } from './routing/types.ts';
@@ -29,6 +29,9 @@ export interface NativeEdge {
29
29
  head?: EndMarker;
30
30
  tail?: EndMarker;
31
31
  dashed?: boolean;
32
+ /** Sequence diagrams: the kind of message, and the earlier message a reply answers. */
33
+ message?: 'call' | 'send' | 'reply';
34
+ answers?: string;
32
35
  constraint?: false;
33
36
  fromSide?: 'left' | 'right' | 'top' | 'bottom';
34
37
  toSide?: 'left' | 'right' | 'top' | 'bottom';
@@ -36,6 +39,8 @@ export interface NativeEdge {
36
39
  export interface NativeLayout {
37
40
  scope: string;
38
41
  kind: 'flow' | 'column' | 'row' | 'sequence';
42
+ /** `sequence` only: draw activation bars from calls and their replies. */
43
+ activations?: true;
39
44
  direction?: 'right' | 'down';
40
45
  }
41
46
  export interface NativeColor {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Mermaid `sequenceDiagram` -> native source. Participants become nodes and messages become edges
3
- * in file order. Native sequences have no fragments, so each top-level branch of a block becomes
3
+ * in file order, each with its kind: a call, a send or a reply that names the call it answers. Native sequences have no fragments, so each top-level branch of a block becomes
4
4
  * a phase band, and the warning says that the branch logic is gone.
5
5
  */
6
6
  import { type Diagnostic, type ImportResult } from './import-core';
@@ -9,6 +9,7 @@ import type { Footnote } from './footnote';
9
9
  import type { Note } from './note';
10
10
  import { type FontRole, type TypeProfile } from './fonts';
11
11
  import type { FileConfig } from './link';
12
+ import type { MessageKind } from './markers';
12
13
  export type ThemeId = 'drafting' | 'fieldnotes' | 'signal' | 'ink' | 'blueprint' | 'drafting-dark';
13
14
  export declare const THEME_IDS: ThemeId[];
14
15
  export declare const DEFAULT_THEME: ThemeId;
@@ -101,10 +102,18 @@ export interface Heading {
101
102
  /** The connection styles a `legend line` row can explain. */
102
103
  export declare const LEGEND_LINES: readonly ["dashed", "solid"];
103
104
  export type LegendLine = (typeof LEGEND_LINES)[number];
104
- /** One row of the key: a color swatch (`family`), or a short connection (`line`). */
105
+ /**
106
+ * One row of the key: a color swatch (`family`), a short connection (`line`), or the mark of a
107
+ * kind of sequence message (`message`), which the drawing adds for each kind it uses.
108
+ */
105
109
  export interface LegendEntry {
106
110
  family?: string;
107
111
  line?: LegendLine;
112
+ message?: MessageKind;
113
+ /** An activation bar, which a sequence with `activations=on` adds a row for. */
114
+ activation?: true;
115
+ /** Words with no swatch: a sequence's line that its rows show order, not time. */
116
+ caption?: true;
108
117
  /** Shade of the swatch; nodes' default when omitted. */
109
118
  shade?: Shade;
110
119
  label: string;
@@ -62,6 +62,12 @@ export interface NodeLabel {
62
62
  export declare function nodeLabel(doc: Diagram, id: string, title: string, r: Rect): NodeLabel;
63
63
  /** Bounds of a shape together with its label. */
64
64
  export declare function visualBounds(doc: Diagram, id: string, title: string, r: Rect): Rect;
65
+ /** Text width a sequence phase's label wraps to, so a long one does not push the lanes right. */
66
+ export declare const PHASE_WRAP = 96;
67
+ /** Inset of a phase label from its band's top left corner. */
68
+ export declare const PHASE_TAB = 8;
69
+ /** A phase label's lines, in the annotation type. */
70
+ export declare const phaseLabelLines: (label: string, r: ResolvedAppearance) => string[];
65
71
  /** Text width a sequence message's label wraps to; the gap between participants follows it. */
66
72
  export declare const MESSAGE_WRAP = 168;
67
73
  /**
@@ -93,6 +99,23 @@ export declare function edgeLabelSize(label: string, r?: ResolvedAppearance, mes
93
99
  w: number;
94
100
  h: number;
95
101
  };
102
+ /**
103
+ * An activation bar: its width, how far a nested bar steps to the right, how far it runs past
104
+ * its first and last rows, and the length of a bar whose call gets no reply.
105
+ */
106
+ export declare const ACTIVATION: {
107
+ w: number;
108
+ step: number;
109
+ over: number;
110
+ stub: number;
111
+ };
112
+ /** Room between a local action's label and its box, on each side. */
113
+ export declare const ACTION_PAD = 5;
114
+ /** The box of a local action: its label and `ACTION_PAD` round it, centred on the lifeline. */
115
+ export declare function actionSize(label: string, r: ResolvedAppearance): {
116
+ w: number;
117
+ h: number;
118
+ };
96
119
  /**
97
120
  * What a self-message draws, measured from where its row meets the lifeline: how far right, how
98
121
  * far above the row and how far below it.
@@ -30,10 +30,17 @@ export declare const markerBox: (kind: Exclude<EndMarker, "none">, tail: boolean
30
30
  };
31
31
  /** The fill a marker takes on this line and surface. */
32
32
  export declare function markerFill(kind: Exclude<EndMarker, 'none'>, ink: string, surface: string): string;
33
+ /**
34
+ * What `message=` accepts on a sequence message, plus `action`, which an `action` line makes.
35
+ * Each says what the author means; none is read from a line's style.
36
+ */
37
+ export declare const MESSAGE_KINDS: readonly ["interaction", "call", "send", "reply", "outcome"];
38
+ export type MessageKind = (typeof MESSAGE_KINDS)[number] | 'action';
33
39
  type Ends = {
34
40
  directed?: boolean;
35
41
  head?: EndMarker;
36
42
  tail?: EndMarker;
43
+ message?: MessageKind;
37
44
  };
38
45
  /** An undirected edge has no marks, whatever else it holds. */
39
46
  export declare const headOf: (e: Ends) => EndMarker;
@@ -46,13 +46,22 @@ export declare function noteBox(look: ResolvedAppearance, note: Note): PlacedNot
46
46
  * Spots in a sequence's side margins, by index in `notes`, for notes on the messages in `rows`.
47
47
  * `left` and `right` are the margins' inner edges and `top` the highest a note goes. A note is
48
48
  * level with its row, or pushed down clear of the note above it. The panel grows round these, so
49
- * no note here can cover the drawing.
49
+ * no note here can cover the drawing. A note on a message in a phase stays inside that phase's
50
+ * band (`bands`, by message), which `marginNoteRoom` makes tall enough for its notes.
50
51
  */
51
52
  export declare function marginNotes(look: ResolvedAppearance, notes: readonly Note[], rows: ReadonlyMap<string, number>, { left, right, top }: {
52
53
  left: number;
53
54
  right: number;
54
55
  top: number;
55
- }): (Rect | null)[];
56
+ }, bands?: ReadonlyMap<string, {
57
+ y: number;
58
+ h: number;
59
+ }>): (Rect | null)[];
60
+ /**
61
+ * The height a phase band needs for the margin notes on its messages (`ids`): the taller of its
62
+ * two sides, each a stack of its notes.
63
+ */
64
+ export declare function marginNoteRoom(look: ResolvedAppearance, notes: readonly Note[], ids: string[]): number;
56
65
  /**
57
66
  * Place every anchored note beside its object or message, clear of shapes, group borders, lines
58
67
  * and earlier notes when a nearby spot allows it. Frame notes, and notes whose object is not drawn,
@@ -1,4 +1,4 @@
1
- import { type PriorRoute, type Route, type RoutingResult } from '../engines/routing-engine.js';
1
+ import { type PriorRoute, type Route, type RoutingResult } from '../engines/routing-engine';
2
2
  import { type ResolvedAppearance } from './appearance';
3
3
  import { type VisibleGraph } from './graph';
4
4
  import type { Diagram, EdgeLayout, Point, Rect, ShapeKind, Side } from './types';
@@ -132,8 +132,10 @@ export declare function routeInput(doc: Diagram, vg: VisibleGraph, all: Map<stri
132
132
  tail?: import("./markers").EndMarker;
133
133
  emphasis: boolean;
134
134
  dashed: boolean;
135
- status?: import("./status.js").Status;
136
- spot?: import("./status.js").Spot;
135
+ message?: import("./markers").MessageKind;
136
+ replyTo?: string;
137
+ status?: import("./status").Status;
138
+ spot?: import("./status").Spot;
137
139
  }[];
138
140
  };
139
141
  /**
@@ -82,3 +82,21 @@ export declare function withState(doc: Diagram, id: string): Diagram;
82
82
  export declare function usedStatuses(doc: Diagram): StatusCount[];
83
83
  /** The color key's rows: a diff draws no family colors, so it lists only its statuses. */
84
84
  export declare const drawnLegend: (doc: Diagram) => LegendEntry[];
85
+ /** What every sequence says under its drawing. */
86
+ export declare const SEQUENCE_CAPTION = "Rows show order, not elapsed time.";
87
+ /**
88
+ * The events that belong with one event of a sequence: a message, the reply that answers it,
89
+ * and the message a reply answers. Only pairs the file states, never a guess from direction.
90
+ */
91
+ export declare function replyPair(doc: Diagram, id: string): string[];
92
+ /**
93
+ * A sequence in words, for a reader who cannot see it: the participants, then each event in
94
+ * order with its kind. An exported SVG carries it as its description unless the host gives one.
95
+ */
96
+ export declare function sequenceDescription(doc: Diagram): string | undefined;
97
+ /**
98
+ * The key a sequence draws for its kinds of message: one row for each mark in use, so a reader
99
+ * never has to guess what a solid head or a box means. Nothing unless a message has a kind. A
100
+ * plain message and a shown result draw the same arrow, so they share a row.
101
+ */
102
+ export declare function messageKey(doc: Diagram): LegendEntry[];
@@ -13,7 +13,7 @@ export type PortSide = Side | 'auto';
13
13
  export type Direction = 'RIGHT' | 'DOWN';
14
14
  export type Theme = 'light' | 'dark';
15
15
  import type { DiagramAppearance, Shade } from './appearance';
16
- import type { EndMarker } from './markers';
16
+ import type { EndMarker, MessageKind } from './markers';
17
17
  import type { Spot, Status } from './status';
18
18
  export type ShapeKind = 'box' | 'pill' | 'circle' | 'diamond' | 'text' | 'icon' | 'image'
19
19
  /** A seam between two cells of a `cells` group. */
@@ -70,6 +70,13 @@ export interface DiagramEdge {
70
70
  tail?: EndMarker;
71
71
  emphasis: boolean;
72
72
  dashed: boolean;
73
+ /**
74
+ * A sequence message's meaning, from `message=`, or `action` for work one participant does
75
+ * (an `action` line; `from` and `to` are that participant). Unset for a plain message.
76
+ */
77
+ message?: MessageKind;
78
+ /** With `message: 'reply'`: the earlier message this one answers, from `answers=`. */
79
+ replyTo?: string;
73
80
  /** How it differs between two versions of the diagram. */
74
81
  status?: Status;
75
82
  /** How the drawn emphasis state treats it; see `withState`. */
@@ -93,6 +100,8 @@ export interface EdgeLayout {
93
100
  toOffset?: number;
94
101
  /** A sequence message: drawn straight between the two lifelines at this height, not routed. */
95
102
  row?: number;
103
+ /** A message between distant lanes: the middle of the gap between lifelines its label sits in. */
104
+ labelX?: number;
96
105
  /**
97
106
  * Set by the compiler for a forward line in a `flow` scope: its route planned from the ranks.
98
107
  * The quick router takes it as it is when it clears every box.
@@ -274,8 +283,18 @@ export interface SequenceLayout {
274
283
  rows: Record<string, number>;
275
284
  phases: SequencePhase[];
276
285
  grow: number;
286
+ activations?: Activation[];
277
287
  };
288
+ /** With `activations=on`: the bars on the lifelines of participants at work on a call. */
289
+ activations?: Activation[];
290
+ /** The `activations=on` switch itself, which the Inspector turns on and off. */
291
+ bars?: true;
278
292
  }
293
+ /** One activation bar: its participant, the call that opened it, and its box. */
294
+ export type Activation = Rect & {
295
+ node: string;
296
+ call: string;
297
+ };
279
298
  export type SequencePhase = {
280
299
  id: string;
281
300
  label: string;