@draftably/mermaid 0.0.0-stage → 0.2.0
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/README.md +67 -2
- package/dist/LICENSE +21 -0
- package/dist/cdn/font-data-tnqJ-kTK-CF1yb2a5.mjs +30 -0
- package/dist/cdn/index-DRFxGmQq.mjs +7781 -0
- package/dist/cdn/mermaid-facade-BoLWBerE.mjs +289 -0
- package/dist/cdn/mermaid-importer-SlRnjUhj.mjs +3753 -0
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-IVovOQE9.js +3753 -0
- package/dist/mermaid.esm.min.mjs +13 -0
- package/dist/mermaid.js +117 -0
- package/dist/types/packages/mermaid/src/index.d.ts +59 -0
- package/dist/types/src/dsl/cells.d.ts +91 -0
- package/dist/types/src/dsl/channels.d.ts +53 -0
- package/dist/types/src/dsl/compile.d.ts +162 -0
- package/dist/types/src/dsl/frame.d.ts +38 -0
- package/dist/types/src/dsl/lanes.d.ts +23 -0
- package/dist/types/src/dsl/legend-notes.d.ts +3 -0
- package/dist/types/src/dsl/project.d.ts +39 -0
- package/dist/types/src/dsl/syntax.d.ts +317 -0
- package/dist/types/src/import/import-core.d.ts +105 -0
- package/dist/types/src/import/mermaid-facade.d.ts +120 -0
- package/dist/types/src/import/mermaid-importer.d.ts +4 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
- package/dist/types/src/model/appearance.d.ts +209 -0
- package/dist/types/src/model/bounds.d.ts +19 -0
- package/dist/types/src/model/document.d.ts +24 -0
- package/dist/types/src/model/font-faces.d.ts +24 -0
- package/dist/types/src/model/fonts.d.ts +47 -0
- package/dist/types/src/model/footnote.d.ts +34 -0
- package/dist/types/src/model/geometry.d.ts +29 -0
- package/dist/types/src/model/graph.d.ts +53 -0
- package/dist/types/src/model/heading.d.ts +38 -0
- package/dist/types/src/model/icons.d.ts +2 -0
- package/dist/types/src/model/labels.d.ts +88 -0
- package/dist/types/src/model/link.d.ts +63 -0
- package/dist/types/src/model/markers.d.ts +47 -0
- package/dist/types/src/model/note.d.ts +75 -0
- package/dist/types/src/model/rich-text.d.ts +24 -0
- package/dist/types/src/model/routes.d.ts +170 -0
- package/dist/types/src/model/status.d.ts +84 -0
- package/dist/types/src/model/styles.d.ts +13 -0
- package/dist/types/src/model/types.d.ts +277 -0
- package/package.json +36 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The marks at a connection's ends, `head=` and `tail=` in a file. The canvas and the CLI draw
|
|
3
|
+
* them from these definitions, so both give the same geometry.
|
|
4
|
+
*/
|
|
5
|
+
import type { Point, Rect } from './types';
|
|
6
|
+
/** What `head=` and `tail=` accept. A plain edge is `head=arrow tail=none`. */
|
|
7
|
+
export declare const MARKERS: readonly ["arrow", "none", "triangle", "open-triangle", "diamond", "open-diamond", "circle", "cross"];
|
|
8
|
+
export type EndMarker = (typeof MARKERS)[number];
|
|
9
|
+
export interface MarkerShape {
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
/** Where the marker sits on its line, at the height of its middle. */
|
|
13
|
+
x: number;
|
|
14
|
+
d: string;
|
|
15
|
+
/** Solid marks take the line's ink. Open marks take the surface, which hides what is under. */
|
|
16
|
+
fill: 'ink' | 'surface' | 'none';
|
|
17
|
+
/** How far short of the end its line stops; the mark fills that gap, tip on the end. */
|
|
18
|
+
stop: number;
|
|
19
|
+
}
|
|
20
|
+
/** Each marker points along +x, in drawing units. `arrow` is the original open chevron. */
|
|
21
|
+
export declare const MARKER_SHAPES: Record<Exclude<EndMarker, 'none'>, MarkerShape>;
|
|
22
|
+
export declare const MARKER_STROKE = 1.5;
|
|
23
|
+
/** The `<marker>` box for an end. A tail's mark turns to face away from the line. */
|
|
24
|
+
export declare const markerBox: (kind: Exclude<EndMarker, "none">, tail: boolean) => {
|
|
25
|
+
markerWidth: number;
|
|
26
|
+
markerHeight: number;
|
|
27
|
+
refX: number;
|
|
28
|
+
refY: number;
|
|
29
|
+
orient: string;
|
|
30
|
+
};
|
|
31
|
+
/** The fill a marker takes on this line and surface. */
|
|
32
|
+
export declare function markerFill(kind: Exclude<EndMarker, 'none'>, ink: string, surface: string): string;
|
|
33
|
+
type Ends = {
|
|
34
|
+
directed?: boolean;
|
|
35
|
+
head?: EndMarker;
|
|
36
|
+
tail?: EndMarker;
|
|
37
|
+
};
|
|
38
|
+
/** An undirected edge has no marks, whatever else it holds. */
|
|
39
|
+
export declare const headOf: (e: Ends) => EndMarker;
|
|
40
|
+
export declare const tailOf: (e: Ends) => EndMarker;
|
|
41
|
+
/** Whether an edge has anything beyond the plain arrow, which labels and lines ignore. */
|
|
42
|
+
export declare const hasMarkers: (e: Ends) => boolean;
|
|
43
|
+
/** A route with each end pulled back to its marker's stop, so no line runs through a mark. */
|
|
44
|
+
export declare function stoppedPoints(points: Point[], e: Ends): Point[];
|
|
45
|
+
/** The room an edge's marks take. A label keeps off them. */
|
|
46
|
+
export declare function markerRects(points: Point[], e: Ends): Rect[];
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notes: sentences on a diagram that never move its layout, from `note` statements. An anchored
|
|
3
|
+
* note (`near=`) is placed after layout in free space beside its object or sequence message; a
|
|
4
|
+
* note without one sits in the frame under the subtitle. The viewer, `inspect --svg` and the
|
|
5
|
+
* editor's exports all place and draw them from here.
|
|
6
|
+
*/
|
|
7
|
+
import { type ResolvedAppearance } from './appearance';
|
|
8
|
+
import type { BoundedRoute } from './bounds';
|
|
9
|
+
import { type Run } from './rich-text';
|
|
10
|
+
import type { Diagram, Point, Rect } from './types';
|
|
11
|
+
export declare const NOTE_SIDES: readonly ["below", "above", "left", "right"];
|
|
12
|
+
export type NoteSide = (typeof NOTE_SIDES)[number];
|
|
13
|
+
export interface Note {
|
|
14
|
+
text: string;
|
|
15
|
+
/** The node, group or sequence message the note sits beside; the frame when unset. */
|
|
16
|
+
near?: string;
|
|
17
|
+
/** Which side of `near`; `below` when unset, or `right` for a message. */
|
|
18
|
+
side?: NoteSide;
|
|
19
|
+
/** Wrap width; `NOTE_WIDTH` when unset. */
|
|
20
|
+
width?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A note with its box and wrapped lines. `inFrame` notes sit under the subtitle; `overlaps` is set
|
|
24
|
+
* on an anchored note when no clear spot was found.
|
|
25
|
+
*/
|
|
26
|
+
export interface PlacedNote {
|
|
27
|
+
note: Note;
|
|
28
|
+
rect: Rect;
|
|
29
|
+
/** Wrapped lines, each as runs of plain text and links. */
|
|
30
|
+
lines: Run[][];
|
|
31
|
+
inFrame?: boolean;
|
|
32
|
+
overlaps?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The side a note sits on: its `side`, or by default right of a message and below anything else. */
|
|
35
|
+
export declare const noteSide: (doc: Diagram, note: Note) => NoteSide;
|
|
36
|
+
/** Default wrap width, and the room between a note and its object. */
|
|
37
|
+
export declare const NOTE_WIDTH = 280;
|
|
38
|
+
/** Room between a note's panel and its text. */
|
|
39
|
+
export declare const NOTE_PAD: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
/** The note's wrapped lines and box size, at 0,0. */
|
|
44
|
+
export declare function noteBox(look: ResolvedAppearance, note: Note): PlacedNote;
|
|
45
|
+
/**
|
|
46
|
+
* Spots in a sequence's side margins, by index in `notes`, for notes on the messages in `rows`.
|
|
47
|
+
* `left` and `right` are the margins' inner edges and `top` the highest a note goes. A note is
|
|
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.
|
|
50
|
+
*/
|
|
51
|
+
export declare function marginNotes(look: ResolvedAppearance, notes: readonly Note[], rows: ReadonlyMap<string, number>, { left, right, top }: {
|
|
52
|
+
left: number;
|
|
53
|
+
right: number;
|
|
54
|
+
top: number;
|
|
55
|
+
}): (Rect | null)[];
|
|
56
|
+
/**
|
|
57
|
+
* Place every anchored note beside its object or message, clear of shapes, group borders, lines
|
|
58
|
+
* and earlier notes when a nearby spot allows it. Frame notes, and notes whose object is not drawn,
|
|
59
|
+
* come back `inFrame` at 0,0 for `diagramFrame` to place.
|
|
60
|
+
*/
|
|
61
|
+
export declare function placeNotes(doc: Diagram, look: ResolvedAppearance, rects: ReadonlyMap<string, Rect>, routes: readonly BoundedRoute[]): PlacedNote[];
|
|
62
|
+
/**
|
|
63
|
+
* SVG markup for placed notes: a quiet panel with a bar on its left edge, then the text. Links
|
|
64
|
+
* are `<a>` elements with `href` as `write` gives it.
|
|
65
|
+
*/
|
|
66
|
+
export declare function noteMarkup(look: ResolvedAppearance, notes: readonly PlacedNote[], write?: (href: string) => string | null): string;
|
|
67
|
+
/**
|
|
68
|
+
* Where a note dropped at `p` belongs: beside the closest object or (in a sequence) message, on
|
|
69
|
+
* the side of it `p` is on. Inside several objects the smallest wins, so a note dropped on a
|
|
70
|
+
* shape in a group goes to the shape. Undefined when nothing is within reach.
|
|
71
|
+
*/
|
|
72
|
+
export declare function noteAnchor(p: Point, rects: ReadonlyMap<string, Rect>, messages?: readonly BoundedRoute[]): {
|
|
73
|
+
near: string;
|
|
74
|
+
side: NoteSide;
|
|
75
|
+
} | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prose with links, for notes and footnotes: `[#1997](https://github.com/org/repo/pull/1997)`
|
|
3
|
+
* draws `#1997` as a link. Lines wrap exactly as the plain words would, so a link never moves
|
|
4
|
+
* anything; each line comes back as runs with their offsets, for SVG `<a>` and click targets.
|
|
5
|
+
*/
|
|
6
|
+
import { type TypeProfile } from './fonts';
|
|
7
|
+
export interface Run {
|
|
8
|
+
text: string;
|
|
9
|
+
href?: string;
|
|
10
|
+
/** Offset from the line's start, and width. */
|
|
11
|
+
x: number;
|
|
12
|
+
w: number;
|
|
13
|
+
}
|
|
14
|
+
/** The text as drawn, with every link written as its label. */
|
|
15
|
+
export declare const plainText: (text: string) => string;
|
|
16
|
+
/** Every link's target, in order. */
|
|
17
|
+
export declare const textLinks: (text: string) => string[];
|
|
18
|
+
/** The text's lines at `width`, each as runs of plain text and links. */
|
|
19
|
+
export declare function richLines(text: string, width: number, type: TypeProfile): Run[][];
|
|
20
|
+
/**
|
|
21
|
+
* One line's content inside its `<text>`: plain runs as text, links as an underlined `<tspan>` in
|
|
22
|
+
* `link`, wrapped in `<a>` with `href` as `write` gives it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function runsMarkup(runs: Run[], link: string, write: (href: string) => string | null): string;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { type PriorRoute, type Route, type RoutingResult } from '../engines/routing-engine.js';
|
|
2
|
+
import { type ResolvedAppearance } from './appearance';
|
|
3
|
+
import { type VisibleGraph } from './graph';
|
|
4
|
+
import type { Diagram, EdgeLayout, Point, Rect, ShapeKind, Side } from './types';
|
|
5
|
+
export declare const SIDE_VECTORS: Record<Side, Point>;
|
|
6
|
+
/** Where a connection meets a shape's outline on the given side. */
|
|
7
|
+
export declare function portPoint(shape: ShapeKind, r: Rect, side: Side, offset?: number): Point;
|
|
8
|
+
/** Side of `r` facing `p`. */
|
|
9
|
+
export declare function sideToward(r: Rect, p: Point): Side;
|
|
10
|
+
export interface EdgeLabelBox extends Point {
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
score?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Lines and borders a label may sit on only when nothing better is free. */
|
|
16
|
+
export interface LabelAvoid {
|
|
17
|
+
/** Other edges' routes. Routes that leave from this edge's first point share its trunk. */
|
|
18
|
+
routes?: Point[][];
|
|
19
|
+
/** Thin strips along group borders. */
|
|
20
|
+
borders?: Rect[];
|
|
21
|
+
/** The marks at line ends. A spot that hides one costs as much as a line through the text. */
|
|
22
|
+
marks?: Rect[];
|
|
23
|
+
/** The open group that holds both ends. A spot not inside it costs a little less than a line. */
|
|
24
|
+
home?: Rect;
|
|
25
|
+
}
|
|
26
|
+
/** One edge label for `placeEdgeLabels`: its text, its route, and what it should keep clear of. */
|
|
27
|
+
export interface LabelJob {
|
|
28
|
+
label: string;
|
|
29
|
+
points: Point[];
|
|
30
|
+
avoid?: LabelAvoid;
|
|
31
|
+
/** The user's nudge, added to the chosen spot. */
|
|
32
|
+
dx?: number;
|
|
33
|
+
dy?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Place every edge label at once, after all routes exist. Each label takes a spot on its own
|
|
37
|
+
* route that covers no shape, group title or other label, and crosses as few other lines as it
|
|
38
|
+
* can; a label closer to another than its own height costs as much as a line beside it. Labels
|
|
39
|
+
* with a clean spot go first, then one repair sweep moves each label to its best spot given all
|
|
40
|
+
* the others. Only a label with every spot near its route blocked moves away from it, and then as
|
|
41
|
+
* little as possible.
|
|
42
|
+
*/
|
|
43
|
+
export declare function placeEdgeLabels(jobs: LabelJob[], obstacles: Rect[], look?: ResolvedAppearance, fixed?: Rect[]): EdgeLabelBox[];
|
|
44
|
+
/**
|
|
45
|
+
* Choose a label spot on the edge's own route, clear of the labels already placed: see
|
|
46
|
+
* `placeEdgeLabels`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function placeEdgeLabel(label: string, points: Point[], obstacles: Rect[], existing?: Rect[], look?: ResolvedAppearance, avoid?: LabelAvoid): EdgeLabelBox;
|
|
49
|
+
export interface DrawnRoute extends Route {
|
|
50
|
+
label: EdgeLabelBox | null;
|
|
51
|
+
path: string;
|
|
52
|
+
/**
|
|
53
|
+
* Short pieces of the line where it crosses another line or a group's frame: the only places a
|
|
54
|
+
* canvas-colored halo is drawn under it, so the crossing reads as a clean break. Empty when the
|
|
55
|
+
* line crosses nothing.
|
|
56
|
+
*/
|
|
57
|
+
halo: string;
|
|
58
|
+
/**
|
|
59
|
+
* For a line to or from a cell with no side on its group's outline: the stretch from the outline
|
|
60
|
+
* across other cells to that cell's edge. It is drawn over the cells, with a dot at the edge.
|
|
61
|
+
*/
|
|
62
|
+
cross?: [Point, Point];
|
|
63
|
+
}
|
|
64
|
+
export interface SceneRoutes {
|
|
65
|
+
routes: DrawnRoute[];
|
|
66
|
+
result: RoutingResult;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* An edge's routing settings, with its lane turned into bends and sides: out of the source to
|
|
70
|
+
* the lane, along it, and into the target. A lane with `leave` or `enter` turns at that coordinate beside
|
|
71
|
+
* the source or target, to meet it side on. A lane that no longer lies between the two ends (a
|
|
72
|
+
* node was dragged across it) is ignored, as is any lane on an edge with its own bends.
|
|
73
|
+
*/
|
|
74
|
+
export declare function laneBends(cfg: EdgeLayout, a: Rect, b: Rect): EdgeLayout;
|
|
75
|
+
export declare function routeInput(doc: Diagram, vg: VisibleGraph, all: Map<string, Rect>): {
|
|
76
|
+
nodes: ({
|
|
77
|
+
shape: ShapeKind;
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
w: number;
|
|
81
|
+
h: number;
|
|
82
|
+
id: string;
|
|
83
|
+
title: string;
|
|
84
|
+
was?: string;
|
|
85
|
+
wasShape?: ShapeKind;
|
|
86
|
+
wasCount?: number | string;
|
|
87
|
+
href?: string;
|
|
88
|
+
count?: number | string;
|
|
89
|
+
span?: number | "var";
|
|
90
|
+
parentId?: string;
|
|
91
|
+
image?: string;
|
|
92
|
+
lifeline?: number;
|
|
93
|
+
} | {
|
|
94
|
+
parentId?: string | undefined;
|
|
95
|
+
frame?: boolean | undefined;
|
|
96
|
+
shape: ShapeKind;
|
|
97
|
+
x: number;
|
|
98
|
+
y: number;
|
|
99
|
+
w: number;
|
|
100
|
+
h: number;
|
|
101
|
+
id: string;
|
|
102
|
+
title: string;
|
|
103
|
+
})[];
|
|
104
|
+
groups: {
|
|
105
|
+
titleHeight?: number | undefined;
|
|
106
|
+
collapsed: boolean;
|
|
107
|
+
titleWidth: number;
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
w: number;
|
|
111
|
+
h: number;
|
|
112
|
+
id: string;
|
|
113
|
+
title: string;
|
|
114
|
+
was?: string;
|
|
115
|
+
href?: string;
|
|
116
|
+
parentId?: string;
|
|
117
|
+
frame?: "soft" | "none";
|
|
118
|
+
titleLines?: number;
|
|
119
|
+
hull?: Rect[];
|
|
120
|
+
}[];
|
|
121
|
+
edges: {
|
|
122
|
+
from: string;
|
|
123
|
+
to: string;
|
|
124
|
+
cfg: EdgeLayout;
|
|
125
|
+
a: string;
|
|
126
|
+
b: string;
|
|
127
|
+
id: string;
|
|
128
|
+
label: string;
|
|
129
|
+
was?: string;
|
|
130
|
+
directed: boolean;
|
|
131
|
+
head?: import("./markers").EndMarker;
|
|
132
|
+
tail?: import("./markers").EndMarker;
|
|
133
|
+
emphasis: boolean;
|
|
134
|
+
dashed: boolean;
|
|
135
|
+
status?: import("./status.js").Status;
|
|
136
|
+
spot?: import("./status.js").Spot;
|
|
137
|
+
}[];
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* A labelled route with no run the label clears slides one bend along, so one run holds the label
|
|
141
|
+
* away from the bend; a label on the corner reads as part of neither run. `w` and `h` are the
|
|
142
|
+
* label's box. The bend moves the least that gives a run the label plus `LABEL_RUN` at each end,
|
|
143
|
+
* or as close to that as the route allows while the label still clears both ends. The move stands
|
|
144
|
+
* only when the route stays out of every box, crosses no more lines and runs beside no more.
|
|
145
|
+
*/
|
|
146
|
+
export declare function roomForLabel(points: Point[], w: number, h: number, boxes: Rect[], others: Point[][]): Point[];
|
|
147
|
+
/** Add label positions and SVG paths to raw routes. */
|
|
148
|
+
export declare function drawRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>, result: RoutingResult): DrawnRoute[];
|
|
149
|
+
/** Width of the halo under a connection, in drawing units. */
|
|
150
|
+
export declare const HALO_WIDTH = 8;
|
|
151
|
+
/** How far a halo piece runs each way from a crossing, along the line. */
|
|
152
|
+
export declare const HALO_REACH = 7;
|
|
153
|
+
/**
|
|
154
|
+
* The lines, by index, that another line's halo would cut at a mark. A halo there leaves half a
|
|
155
|
+
* mark, or on a short line almost nothing, so these lines stay whole.
|
|
156
|
+
*/
|
|
157
|
+
export declare function wholeLines(lines: {
|
|
158
|
+
points: Point[];
|
|
159
|
+
marks: Rect[];
|
|
160
|
+
}[]): Set<number>;
|
|
161
|
+
/** The pieces of `points` around each place it crosses `others` or a frame's border, as a path. */
|
|
162
|
+
export declare function haloPath(points: Point[], others: Point[][], frames: Rect[]): string;
|
|
163
|
+
/** Full routes already computed for this drawing, or null. */
|
|
164
|
+
export declare function knownRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>): RoutingResult | null;
|
|
165
|
+
/** Record full routes computed elsewhere (the engine worker) for this drawing. */
|
|
166
|
+
export declare function rememberRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>, result: RoutingResult): void;
|
|
167
|
+
export declare function computeRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>, options?: {
|
|
168
|
+
previous?: PriorRoute[];
|
|
169
|
+
quick?: boolean;
|
|
170
|
+
}): SceneRoutes;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change status: how an object or connection differs between two versions of a diagram, drawn
|
|
3
|
+
* the same way by the canvas, `inspect --svg` and the exports.
|
|
4
|
+
*
|
|
5
|
+
* A file with change marks is a diff, and in a diff color means change and nothing else:
|
|
6
|
+
* unchanged shapes turn neutral, containers become quiet outlines, unchanged lines go grey, and
|
|
7
|
+
* only added (green), changed (amber) and removed (red) objects keep a hue, as a tinted fill with
|
|
8
|
+
* a strong border. Each status also has a border weight, dash, fade or marker, so a diff still
|
|
9
|
+
* reads in grayscale. A removed title stays readable; `config strike-removed=on` strikes it.
|
|
10
|
+
*/
|
|
11
|
+
import { type LegendEntry, type ResolvedAppearance, type Swatch } from './appearance';
|
|
12
|
+
import type { Diagram, DiagramEdge } from './types';
|
|
13
|
+
export type Status = 'same' | 'added' | 'removed' | 'changed' | 'context';
|
|
14
|
+
/**
|
|
15
|
+
* How an emphasis state draws an object or connection: in focus (a heavier border or line),
|
|
16
|
+
* ringed (in focus where nothing else fades, so it also takes an accent ring or line), or dimmed
|
|
17
|
+
* (faded and neutral, like a `.` context line). Unset means it draws as usual.
|
|
18
|
+
*/
|
|
19
|
+
export type Spot = 'focus' | 'ring' | 'dim';
|
|
20
|
+
export declare const STATUSES: Status[];
|
|
21
|
+
/** Legend order and wording, after a count; `same` needs no entry. */
|
|
22
|
+
export declare const STATUS_LABELS: Partial<Record<Status, string>>;
|
|
23
|
+
export interface StatusCount {
|
|
24
|
+
status: Status;
|
|
25
|
+
/** Objects with the mark. */
|
|
26
|
+
count: number;
|
|
27
|
+
/** Connections with the mark. */
|
|
28
|
+
lines: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A legend entry's text: how many objects carry the mark and what it means, then how many
|
|
32
|
+
* connections, so five added boxes and their five lines read "5 added · 5 lines", not "10 added".
|
|
33
|
+
*/
|
|
34
|
+
export declare const statusLabel: ({ status, count, lines }: StatusCount) => string;
|
|
35
|
+
export interface StatusPaint {
|
|
36
|
+
/** Line color for connections; shapes take theirs from `statusSwatch`. */
|
|
37
|
+
stroke?: string;
|
|
38
|
+
width?: number;
|
|
39
|
+
dash?: string;
|
|
40
|
+
opacity: number;
|
|
41
|
+
/** Strike the title through. */
|
|
42
|
+
strike: boolean;
|
|
43
|
+
/** Fade of the title text alone, on top of `opacity`. */
|
|
44
|
+
inkFade?: number;
|
|
45
|
+
/** Draw the removed marker, a minus in a disc, on the shape's top-right corner. */
|
|
46
|
+
marker?: boolean;
|
|
47
|
+
/** Draw an accent ring around the shape (`haloInk`). */
|
|
48
|
+
halo?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** The removed marker's radius and its inset from a shape's top-right corner. */
|
|
51
|
+
export declare const MARKER: {
|
|
52
|
+
r: number;
|
|
53
|
+
inset: number;
|
|
54
|
+
};
|
|
55
|
+
/** Room between a shape and its focus ring. */
|
|
56
|
+
export declare const HALO_GAP = 4;
|
|
57
|
+
/** The accent a ringed object or connection is drawn with: the theme's second accent. */
|
|
58
|
+
export declare const haloInk: (look: ResolvedAppearance) => string;
|
|
59
|
+
/** The paint for a change status, with an emphasis state's weight or fade on top. */
|
|
60
|
+
export declare function statusPaint(look: ResolvedAppearance, status?: Status, spot?: Spot): StatusPaint;
|
|
61
|
+
/** Whether the document is a diff: any object or connection carries a change mark. */
|
|
62
|
+
export declare const isDiff: (doc: Diagram) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* In a diff, the swatch a status draws a shape with: a pale tint of its hue with a strong border
|
|
65
|
+
* and dark ink, or the neutral surface (a quiet outline for containers) when unchanged.
|
|
66
|
+
*/
|
|
67
|
+
export declare function statusSwatch(look: ResolvedAppearance, status: Status | undefined, kind: 'node' | 'group'): Swatch;
|
|
68
|
+
/** A connection's color: its status hue, or quiet grey for an unchanged line in a diff. */
|
|
69
|
+
export declare const edgeInk: (look: ResolvedAppearance, edge: DiagramEdge, diff: boolean) => string;
|
|
70
|
+
/**
|
|
71
|
+
* The document drawn in emphasis state `id`. Listed objects (a group with all its members) and
|
|
72
|
+
* listed connections are in focus, and so is a connection between two focused nodes. With
|
|
73
|
+
* `rest=dim`, everything else fades, except the containers that hold something in focus, so the
|
|
74
|
+
* context still reads. With `rest=plain` nothing fades, so focus also takes an accent ring.
|
|
75
|
+
* Nothing moves.
|
|
76
|
+
*/
|
|
77
|
+
export declare function withState(doc: Diagram, id: string): Diagram;
|
|
78
|
+
/**
|
|
79
|
+
* The marks a document uses that the legend explains, in legend order, each with how many
|
|
80
|
+
* objects and connections carry it, so the key doubles as the change's size.
|
|
81
|
+
*/
|
|
82
|
+
export declare function usedStatuses(doc: Diagram): StatusCount[];
|
|
83
|
+
/** The color key's rows: a diff draws no family colors, so it lists only its statuses. */
|
|
84
|
+
export declare const drawnLegend: (doc: Diagram) => LegendEntry[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NodeStyle, ShapeKind } from './types';
|
|
2
|
+
export declare const SHAPES: ShapeKind[];
|
|
3
|
+
export declare const SHAPE_LABELS: Record<ShapeKind, string>;
|
|
4
|
+
/** Icons offered in the inspector for a shape. */
|
|
5
|
+
export declare const NODE_ICONS: string[];
|
|
6
|
+
/** Styles for version 1 node types, used only when migrating old files. */
|
|
7
|
+
export declare const LEGACY_TYPE_STYLE: Record<string, NodeStyle>;
|
|
8
|
+
export declare const DEFAULT_STYLE: NodeStyle;
|
|
9
|
+
/** Default size for a new shape of the given kind. */
|
|
10
|
+
export declare function defaultShapeSize(shape: ShapeKind): {
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
};
|