@draftably/markdown 0.2.2 → 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.
- package/dist/chunks/mermaid-importer-S5o6DWXk.js +4381 -0
- package/dist/mermaid.js +1 -1
- package/dist/types/src/dsl/compile.d.ts +2 -0
- package/dist/types/src/dsl/sequence-layout.d.ts +87 -0
- package/dist/types/src/dsl/syntax.d.ts +8 -2
- package/dist/types/src/engines/layout/arrange.d.ts +36 -0
- package/dist/types/src/engines/layout/compute.d.ts +7 -0
- package/dist/types/src/engines/layout/forces.d.ts +8 -0
- package/dist/types/src/engines/layout/grid.d.ts +10 -0
- package/dist/types/src/engines/layout/intent.d.ts +14 -0
- package/dist/types/src/engines/layout/layered.d.ts +5 -0
- package/dist/types/src/engines/layout/objective.d.ts +6 -0
- package/dist/types/src/engines/layout/packing.d.ts +7 -0
- package/dist/types/src/engines/layout/report.d.ts +7 -0
- package/dist/types/src/engines/layout/scene.d.ts +53 -0
- package/dist/types/src/engines/layout/seed.d.ts +3 -0
- package/dist/types/src/engines/layout/separation.d.ts +17 -0
- package/dist/types/src/engines/layout/settings.d.ts +6 -0
- package/dist/types/src/engines/layout/topology.d.ts +18 -0
- package/dist/types/src/engines/layout/trees.d.ts +8 -0
- package/dist/types/src/engines/layout/types.d.ts +133 -0
- package/dist/types/src/engines/layout/util.d.ts +19 -0
- package/dist/types/src/engines/layout-engine.d.ts +15 -0
- package/dist/types/src/engines/routing/compute.d.ts +6 -0
- package/dist/types/src/engines/routing/conflicts.d.ts +36 -0
- package/dist/types/src/engines/routing/context.d.ts +37 -0
- package/dist/types/src/engines/routing/cost.d.ts +13 -0
- package/dist/types/src/engines/routing/doglegs.d.ts +16 -0
- package/dist/types/src/engines/routing/find.d.ts +6 -0
- package/dist/types/src/engines/routing/geometry.d.ts +24 -0
- package/dist/types/src/engines/routing/heap.d.ts +20 -0
- package/dist/types/src/engines/routing/improve.d.ts +7 -0
- package/dist/types/src/engines/routing/nudge.d.ts +7 -0
- package/dist/types/src/engines/routing/paths.d.ts +8 -0
- package/dist/types/src/engines/routing/planned.d.ts +7 -0
- package/dist/types/src/engines/routing/ports.d.ts +10 -0
- package/dist/types/src/engines/routing/repair.d.ts +9 -0
- package/dist/types/src/engines/routing/score.d.ts +12 -0
- package/dist/types/src/engines/routing/search.d.ts +16 -0
- package/dist/types/src/engines/routing/settings.d.ts +4 -0
- package/dist/types/src/engines/routing/sidepairs.d.ts +20 -0
- package/dist/types/src/engines/routing/tidy-ports.d.ts +13 -0
- package/dist/types/src/engines/routing/tidy.d.ts +10 -0
- package/dist/types/src/engines/routing/tuning.d.ts +9 -0
- package/dist/types/src/engines/routing/types.d.ts +157 -0
- package/dist/types/src/engines/routing-engine.d.ts +20 -0
- package/dist/types/src/import/import-core.d.ts +5 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +1 -1
- package/dist/types/src/model/appearance.d.ts +18 -2
- package/dist/types/src/model/labels.d.ts +23 -0
- package/dist/types/src/model/markers.d.ts +7 -0
- package/dist/types/src/model/note.d.ts +11 -2
- package/dist/types/src/model/routes.d.ts +5 -3
- package/dist/types/src/model/status.d.ts +18 -0
- package/dist/types/src/model/types.d.ts +20 -1
- package/package.json +2 -2
- package/dist/chunks/mermaid-importer-BHKoojYC.js +0 -4132
|
@@ -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,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,7 +9,8 @@ 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
|
-
|
|
12
|
+
import type { MessageKind } from './markers';
|
|
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;
|
|
15
16
|
/** Shade stops. Lower numbers are lighter and higher numbers darker, in every theme. */
|
|
@@ -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
|
-
/**
|
|
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;
|
|
@@ -154,6 +163,13 @@ interface Preset {
|
|
|
154
163
|
hues?: Partial<Record<string, [number, number]>>;
|
|
155
164
|
}
|
|
156
165
|
export declare const PRESETS: Record<ThemeId, Preset>;
|
|
166
|
+
/**
|
|
167
|
+
* The appearance to draw on a page of this scheme. The default theme follows the page, with or
|
|
168
|
+
* without a `theme drafting` line and its size and font overrides: dark draws it as
|
|
169
|
+
* `drafting-dark`. Another named theme, a `theme-color` line or a color override on the `theme`
|
|
170
|
+
* line keeps the file's colors on every page.
|
|
171
|
+
*/
|
|
172
|
+
export declare function forScheme(appearance: DiagramAppearance, dark: boolean): DiagramAppearance;
|
|
157
173
|
/** `a` moved toward `b` by `t` (0–1), in sRGB. */
|
|
158
174
|
export declare function mixColors(a: string, b: string, t: number): string;
|
|
159
175
|
export declare function contrast(a: string, b: string): number;
|
|
@@ -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
|
-
}
|
|
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
|
|
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
|
-
|
|
136
|
-
|
|
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[];
|