@draftably/markdown 0.2.0 → 0.2.2
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 +25 -8
- package/dist/chunks/mermaid-importer-BHKoojYC.js +4132 -0
- package/dist/mermaid.js +1 -1
- package/dist/types/src/dsl/cells.d.ts +1 -0
- package/dist/types/src/dsl/compile.d.ts +15 -1
- package/dist/types/src/dsl/corridors.d.ts +38 -0
- package/dist/types/src/dsl/legend-notes.d.ts +14 -0
- package/dist/types/src/dsl/syntax.d.ts +2 -0
- package/dist/types/src/model/appearance.d.ts +19 -0
- package/dist/types/src/model/labels.d.ts +22 -6
- package/dist/types/src/model/types.d.ts +9 -0
- package/package.json +2 -2
- package/dist/chunks/mermaid-importer-IVovOQE9.js +0 -3753
package/dist/mermaid.js
CHANGED
|
@@ -61,7 +61,7 @@ async function S() {
|
|
|
61
61
|
globalThis.fetch = async () => {
|
|
62
62
|
throw Error("Mermaid resource loading is disabled.");
|
|
63
63
|
};
|
|
64
|
-
const { JSDOM: i } = await import("jsdom"), { createMermaidFlowParser: s, makePlainLabel: e } = await import("./chunks/mermaid-facade-BoLWBerE.js"), { importMermaidFlow: t } = await import("./chunks/mermaid-importer-
|
|
64
|
+
const { JSDOM: i } = await import("jsdom"), { createMermaidFlowParser: s, makePlainLabel: e } = await import("./chunks/mermaid-facade-BoLWBerE.js"), { importMermaidFlow: t } = await import("./chunks/mermaid-importer-BHKoojYC.js"), r = new i("<!doctype html><html><body></body></html>", {
|
|
65
65
|
url: "https://import.invalid/"
|
|
66
66
|
});
|
|
67
67
|
Object.assign(globalThis, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ResolvedAppearance } from '../model/appearance';
|
|
2
2
|
import type { CellsChrome, Lane, SequenceLayout } from '../model/types';
|
|
3
|
+
import { type Planned } from './corridors';
|
|
3
4
|
import { GROUP_HEADER, GROUP_INSET, contentOrigin } from './frame';
|
|
4
5
|
import { type Model, type ModelEdge, type ModelLayout, type ModelObject } from './syntax';
|
|
5
6
|
/** The single render context. Browser window size changes the camera, never the layout. */
|
|
@@ -44,6 +45,8 @@ export interface Diagnostic {
|
|
|
44
45
|
/** A connection as the file declares it, plus the lane a fold's wrap edge returns along. */
|
|
45
46
|
export interface SceneEdge extends ModelEdge {
|
|
46
47
|
lane?: Lane;
|
|
48
|
+
/** A forward line's route, planned from its scope's ranks and corridors (`planRoutes`). */
|
|
49
|
+
plan?: Planned;
|
|
47
50
|
/** A sequence message: the height of its row; it is drawn straight between lifelines there. */
|
|
48
51
|
row?: number;
|
|
49
52
|
}
|
|
@@ -96,11 +99,12 @@ export declare function layoutFor(m: Model, scope: string): ModelLayout;
|
|
|
96
99
|
/**
|
|
97
100
|
* Size of a node: its requested size, or the default width with a height that fits the title in
|
|
98
101
|
* the theme's type and padding. A requested size is kept exactly; `overflow` reports a title that
|
|
99
|
-
* no longer fits in it.
|
|
102
|
+
* no longer fits in it. With `height=auto`, `min-height` is a floor under the title's height.
|
|
100
103
|
*/
|
|
101
104
|
export declare function leafSize(o: ModelObject, size: {
|
|
102
105
|
width: number;
|
|
103
106
|
height?: number;
|
|
107
|
+
minHeight?: number;
|
|
104
108
|
} | undefined, look: ResolvedAppearance): {
|
|
105
109
|
w: number;
|
|
106
110
|
h: number;
|
|
@@ -149,6 +153,16 @@ export declare function crossings(paths: Array<Array<{
|
|
|
149
153
|
}>>): number;
|
|
150
154
|
/** The order of up to six items that scores fewest crossings; the first such, from `items`. */
|
|
151
155
|
export declare function fewestCrossings<T>(items: T[], score: (order: T[]) => number): T[];
|
|
156
|
+
/**
|
|
157
|
+
* The corridors a `flow` scope keeps for lines that skip ranks: the ranks with their stand-ins,
|
|
158
|
+
* each line's stand-ins by its index in the scope's pairs, and each stand-in's place across the
|
|
159
|
+
* run, in the scope's coordinates.
|
|
160
|
+
*/
|
|
161
|
+
export interface Corridors {
|
|
162
|
+
order: string[][];
|
|
163
|
+
chains: Map<number, string[]>;
|
|
164
|
+
across: Map<string, number>;
|
|
165
|
+
}
|
|
152
166
|
/**
|
|
153
167
|
* Lay out a model. `arranged` holds world positions from layout engines; scopes that an engine
|
|
154
168
|
* governs take their children's relative placement from it instead of their built-in recipe.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routes for a `flow` scope's forward lines, planned from its ranks as a layered layout routes its
|
|
3
|
+
* edges: out of the source's trailing side, along a track in each gap the line turns in, down a
|
|
4
|
+
* corridor through each rank it skips, and into the target's leading side. The ranks' order already
|
|
5
|
+
* keeps crossings few, so the plan only has to place ports and order each gap's tracks. The router
|
|
6
|
+
* takes a planned route as it is when it clears every box.
|
|
7
|
+
*/
|
|
8
|
+
import type { Point, Rect } from '../model/types';
|
|
9
|
+
export interface PlanLine {
|
|
10
|
+
id: string;
|
|
11
|
+
/** Source, the stand-ins of the ranks it skips, target. */
|
|
12
|
+
chain: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface Planned {
|
|
15
|
+
points: Point[];
|
|
16
|
+
fromOffset: number;
|
|
17
|
+
toOffset: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Space between ports on one side and between neighbouring tracks in a gap, as the router keeps
|
|
21
|
+
* them: ports `max(portGap, edgeGap)` apart and tracks `edgeGap` apart.
|
|
22
|
+
*/
|
|
23
|
+
export interface Spacing {
|
|
24
|
+
port: number;
|
|
25
|
+
track: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Plans each line of `lines`. `order` is the ranks with stand-ins, `box` each real member's drawn
|
|
29
|
+
* box and `across` each stand-in's place across the run, all in drawing coordinates. Lines that
|
|
30
|
+
* cannot be planned (a member without a box) are left out.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planRoutes(axis: 'down' | 'right', order: string[][], lines: PlanLine[], box: (id: string) => Rect | undefined, across: (id: string) => number | undefined, spacing?: Spacing): Map<string, Planned>;
|
|
33
|
+
/**
|
|
34
|
+
* The room each gap between ranks needs for the tracks `planRoutes` lays in it: a standoff from
|
|
35
|
+
* the boxes either side and a pitch between tracks, by gap index; a gap with no track is absent.
|
|
36
|
+
* `box` may be a member's slot: only its place across the run counts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function trackRoom(axis: 'down' | 'right', order: string[][], lines: PlanLine[], box: (id: string) => Rect | undefined, across: (id: string) => number | undefined, spacing?: Spacing): number[];
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `check` advice on the key and the prose round a drawing: a key that leaves a color or a line
|
|
3
|
+
* style unexplained, a `legend` swatch drawn in a shade that no node of its family uses, and
|
|
4
|
+
* heading prose that the drawing should say instead.
|
|
5
|
+
*/
|
|
6
|
+
import { type Shade } from '../model/appearance';
|
|
1
7
|
import type { Diagnostic } from './compile';
|
|
2
8
|
import type { Model } from './syntax';
|
|
3
9
|
export declare function legendNotes(m: Model): Diagnostic[];
|
|
10
|
+
/**
|
|
11
|
+
* The shade a `legend family` swatch draws when its line sets none: what the family's nodes draw.
|
|
12
|
+
* When no node names the family and its nodes are all member cards (they inherit it from a group
|
|
13
|
+
* on a quiet surface shade), that is the member card's shade; otherwise it is a colored node's.
|
|
14
|
+
*/
|
|
15
|
+
export declare function legendShade(m: Model, family: string): Shade;
|
|
16
|
+
/** Give each `legend family` line with no `shade=` the shade its family's nodes draw. */
|
|
17
|
+
export declare function settleLegendShades(m: Model): void;
|
|
@@ -210,11 +210,13 @@ export type Hint = {
|
|
|
210
210
|
line: number;
|
|
211
211
|
}
|
|
212
212
|
/** `height` is unset for `height=auto`: the title's height at that width, as without a size. */
|
|
213
|
+
/** `minHeight` is a floor under `height=auto`, for a host that draws more than the title. */
|
|
213
214
|
| {
|
|
214
215
|
type: 'size';
|
|
215
216
|
id: string;
|
|
216
217
|
width: number;
|
|
217
218
|
height?: number;
|
|
219
|
+
minHeight?: number;
|
|
218
220
|
line: number;
|
|
219
221
|
};
|
|
220
222
|
export type Strength = 'prefer' | 'required';
|
|
@@ -18,6 +18,12 @@ export type Shade = (typeof SHADES)[number];
|
|
|
18
18
|
export declare const isShade: (n: unknown) => n is Shade;
|
|
19
19
|
/** Shade of a node that names a color without a shade. */
|
|
20
20
|
export declare const NODE_SHADE: Shade;
|
|
21
|
+
/**
|
|
22
|
+
* Shade of a member card: a node drawn in its container's family with no shade of its own. It is
|
|
23
|
+
* the palest stop on the canvas side of the frame (50 in light themes, 950 in dark ones), so the
|
|
24
|
+
* card stands apart from its frame by fill and keeps the family's outline and ink.
|
|
25
|
+
*/
|
|
26
|
+
export declare const memberShadeFor: (theme: ThemeId) => Shade;
|
|
21
27
|
/**
|
|
22
28
|
* Shade of a group that names a color without a shade. Groups are quiet surfaces behind nodes, so
|
|
23
29
|
* this is a pale shade in light themes and a deep one in dark themes; the scale itself never flips.
|
|
@@ -148,6 +154,8 @@ interface Preset {
|
|
|
148
154
|
hues?: Partial<Record<string, [number, number]>>;
|
|
149
155
|
}
|
|
150
156
|
export declare const PRESETS: Record<ThemeId, Preset>;
|
|
157
|
+
/** `a` moved toward `b` by `t` (0–1), in sRGB. */
|
|
158
|
+
export declare function mixColors(a: string, b: string, t: number): string;
|
|
151
159
|
export declare function contrast(a: string, b: string): number;
|
|
152
160
|
/** Contrast targets (WCAG ratios) every generated color meets. */
|
|
153
161
|
export declare const CONTRAST: {
|
|
@@ -184,6 +192,8 @@ export interface ResolvedAppearance {
|
|
|
184
192
|
radius: number;
|
|
185
193
|
shadow: boolean;
|
|
186
194
|
title: TypeProfile;
|
|
195
|
+
/** A node title's detail lines (after its first `\n`): a step smaller and lighter. */
|
|
196
|
+
detail: TypeProfile;
|
|
187
197
|
groupTitle: TypeProfile;
|
|
188
198
|
annotation: TypeProfile;
|
|
189
199
|
/** Space above a group's content; the group title sits in it. */
|
|
@@ -204,6 +214,15 @@ export declare function resolveAppearance(appearance?: DiagramAppearance): Resol
|
|
|
204
214
|
* default surface; the file parser reports them before they get here.
|
|
205
215
|
*/
|
|
206
216
|
export declare function swatchFor(r: ResolvedAppearance, family: string | undefined, shade: Shade | undefined, kind?: 'node' | 'group'): Swatch;
|
|
217
|
+
/**
|
|
218
|
+
* The quiet panel behind notes and a sequence diagram: slate 50 in light themes, and the theme's
|
|
219
|
+
* own group surface in dark ones, so the theme's text ink reads on it.
|
|
220
|
+
*/
|
|
221
|
+
export declare const panelSwatch: (r: ResolvedAppearance) => Swatch;
|
|
222
|
+
/** Bands and dividers drawn over that panel. */
|
|
223
|
+
export declare const bandSwatch: (r: ResolvedAppearance) => Swatch;
|
|
224
|
+
/** Ink for a link in a note or footnote, held to 4.5:1 on `against`. */
|
|
225
|
+
export declare const linkInk: (r: ResolvedAppearance, against: string) => string;
|
|
207
226
|
/** Shades a family defines, in numeric order. */
|
|
208
227
|
export declare const shadesOf: (r: ResolvedAppearance, family: string) => Shade[];
|
|
209
228
|
export {};
|
|
@@ -12,10 +12,25 @@ export interface TitleArea {
|
|
|
12
12
|
maxHeight: number;
|
|
13
13
|
}
|
|
14
14
|
export declare function titleArea(shape: ShapeKind, w: number, h: number, r: ResolvedAppearance, icon?: boolean): TitleArea;
|
|
15
|
-
/** Height a shape needs for `
|
|
16
|
-
export declare function titleHeight(shape: ShapeKind,
|
|
17
|
-
/**
|
|
18
|
-
export
|
|
15
|
+
/** Height a shape needs for a title block `text` px tall; never less than `base`. */
|
|
16
|
+
export declare function titleHeight(shape: ShapeKind, text: number, base: number, r: ResolvedAppearance): number;
|
|
17
|
+
/** One line of a shape's title: part of its name, or of its detail. */
|
|
18
|
+
export interface TitleLine {
|
|
19
|
+
text: string;
|
|
20
|
+
/** A detail line, from the text after the title's first `\n`, drawn in `r.detail`. */
|
|
21
|
+
detail: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A shape's title in balanced lines no wider than `width` (see `wrapLines`). The text before the
|
|
25
|
+
* first `\n` is the name, in the title type; the rest is detail, in the smaller detail type.
|
|
26
|
+
*/
|
|
27
|
+
export declare function wrapTitle(text: string, width: number, r: ResolvedAppearance): TitleLine[];
|
|
28
|
+
/** The type a title line is set in. */
|
|
29
|
+
export declare const lineType: (l: TitleLine, r: ResolvedAppearance) => TypeProfile;
|
|
30
|
+
/** Height of a block of title lines. */
|
|
31
|
+
export declare const textHeight: (lines: TitleLine[], r: ResolvedAppearance) => number;
|
|
32
|
+
/** Each line's centre, measured from the middle of the block. */
|
|
33
|
+
export declare function lineOffsets(lines: TitleLine[], r: ResolvedAppearance): number[];
|
|
19
34
|
/**
|
|
20
35
|
* Line width for a diamond's title, `s` its side. A text block W wide and H tall fits inside a
|
|
21
36
|
* square diamond when W + H <= s, so this takes the widest measure whose wrapped lines still fit:
|
|
@@ -37,9 +52,10 @@ export interface NodeLabel {
|
|
|
37
52
|
y: number;
|
|
38
53
|
width: number;
|
|
39
54
|
height: number;
|
|
40
|
-
lines:
|
|
55
|
+
lines: TitleLine[];
|
|
56
|
+
/** Each line's centre, relative to `y`. */
|
|
57
|
+
offsets: number[];
|
|
41
58
|
mode: LabelMode;
|
|
42
|
-
lineHeight: number;
|
|
43
59
|
leader: boolean;
|
|
44
60
|
}
|
|
45
61
|
/** Where a shape's title is drawn, relative to the shape. */
|
|
@@ -93,6 +93,15 @@ export interface EdgeLayout {
|
|
|
93
93
|
toOffset?: number;
|
|
94
94
|
/** A sequence message: drawn straight between the two lifelines at this height, not routed. */
|
|
95
95
|
row?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Set by the compiler for a forward line in a `flow` scope: its route planned from the ranks.
|
|
98
|
+
* The quick router takes it as it is when it clears every box.
|
|
99
|
+
*/
|
|
100
|
+
plan?: {
|
|
101
|
+
points: Point[];
|
|
102
|
+
fromOffset: number;
|
|
103
|
+
toOffset: number;
|
|
104
|
+
};
|
|
96
105
|
}
|
|
97
106
|
/**
|
|
98
107
|
* A channel between two bands of a fold: a level line at `y`, or an upright one at `x`. With
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftably/markdown",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Build static SVG diagram assets from Markdown draft fences.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"jsdom": "26.1.0",
|
|
37
37
|
"mermaid": "12.2.0",
|
|
38
|
-
"@draftably/runtime": "0.
|
|
38
|
+
"@draftably/runtime": "0.4.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=22.21.0"
|