@oh-my-pi-zen/pi-utils 16.3.6-zen.1
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/CHANGELOG.md +245 -0
- package/README.md +36 -0
- package/dist/types/abortable.d.ts +32 -0
- package/dist/types/async.d.ts +6 -0
- package/dist/types/binary.d.ts +17 -0
- package/dist/types/cli.d.ts +117 -0
- package/dist/types/color.d.ts +102 -0
- package/dist/types/dirs.d.ts +260 -0
- package/dist/types/env.d.ts +74 -0
- package/dist/types/fetch-retry.d.ts +94 -0
- package/dist/types/format.d.ts +37 -0
- package/dist/types/frontmatter.d.ts +25 -0
- package/dist/types/fs-error.d.ts +31 -0
- package/dist/types/glob.d.ts +28 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/json-parse.d.ts +48 -0
- package/dist/types/json.d.ts +4 -0
- package/dist/types/logger.d.ts +83 -0
- package/dist/types/loop-phase.d.ts +10 -0
- package/dist/types/mermaid-ascii.d.ts +11 -0
- package/dist/types/mime.d.ts +29 -0
- package/dist/types/module-timer.d.ts +1 -0
- package/dist/types/path-tree.d.ts +76 -0
- package/dist/types/path.d.ts +2 -0
- package/dist/types/peek-file.d.ts +29 -0
- package/dist/types/postmortem.d.ts +37 -0
- package/dist/types/procmgr.d.ts +29 -0
- package/dist/types/prompt.d.ts +18 -0
- package/dist/types/ptree.d.ts +108 -0
- package/dist/types/ring.d.ts +93 -0
- package/dist/types/runtime-install.d.ts +68 -0
- package/dist/types/sanitize-text.d.ts +29 -0
- package/dist/types/snowflake.d.ts +25 -0
- package/dist/types/stream.d.ts +68 -0
- package/dist/types/tab-spacing.d.ts +24 -0
- package/dist/types/temp.d.ts +17 -0
- package/dist/types/timing-buffer.d.ts +22 -0
- package/dist/types/tls-fetch.d.ts +37 -0
- package/dist/types/type-guards.d.ts +3 -0
- package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
- package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
- package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
- package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
- package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
- package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
- package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
- package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
- package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
- package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
- package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
- package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
- package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
- package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
- package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
- package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
- package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
- package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
- package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
- package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +21 -0
- package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
- package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
- package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
- package/dist/types/which.d.ts +37 -0
- package/dist/types/worker-host.d.ts +47 -0
- package/package.json +62 -0
- package/src/abortable.ts +109 -0
- package/src/async.ts +50 -0
- package/src/binary.ts +50 -0
- package/src/cli.ts +457 -0
- package/src/color.ts +302 -0
- package/src/dirs.ts +925 -0
- package/src/env.ts +226 -0
- package/src/fetch-retry.ts +355 -0
- package/src/format.ts +113 -0
- package/src/frontmatter.ts +162 -0
- package/src/fs-error.ts +56 -0
- package/src/glob.ts +189 -0
- package/src/index.ts +55 -0
- package/src/json-parse.ts +612 -0
- package/src/json.ts +10 -0
- package/src/logger.ts +672 -0
- package/src/loop-phase.ts +49 -0
- package/src/mermaid-ascii.ts +31 -0
- package/src/mime.ts +159 -0
- package/src/module-timer.ts +148 -0
- package/src/path-tree.ts +147 -0
- package/src/path.ts +28 -0
- package/src/peek-file.ts +188 -0
- package/src/postmortem.ts +222 -0
- package/src/procmgr.ts +195 -0
- package/src/prompt.ts +562 -0
- package/src/ptree.ts +395 -0
- package/src/ring.ts +169 -0
- package/src/runtime-install.ts +372 -0
- package/src/sanitize-text.ts +96 -0
- package/src/snowflake.ts +121 -0
- package/src/stream.ts +432 -0
- package/src/tab-spacing.ts +336 -0
- package/src/temp.ts +134 -0
- package/src/timing-buffer.ts +47 -0
- package/src/tls-fetch.ts +178 -0
- package/src/type-guards.ts +11 -0
- package/src/vendor/mermaid-ascii/NOTICE +33 -0
- package/src/vendor/mermaid-ascii/ascii/ansi.ts +409 -0
- package/src/vendor/mermaid-ascii/ascii/canvas.ts +476 -0
- package/src/vendor/mermaid-ascii/ascii/class-diagram.ts +699 -0
- package/src/vendor/mermaid-ascii/ascii/converter.ts +271 -0
- package/src/vendor/mermaid-ascii/ascii/draw.ts +1382 -0
- package/src/vendor/mermaid-ascii/ascii/edge-bundling.ts +328 -0
- package/src/vendor/mermaid-ascii/ascii/edge-routing.ts +297 -0
- package/src/vendor/mermaid-ascii/ascii/er-diagram.ts +441 -0
- package/src/vendor/mermaid-ascii/ascii/grid.ts +578 -0
- package/src/vendor/mermaid-ascii/ascii/index.ts +187 -0
- package/src/vendor/mermaid-ascii/ascii/multiline-utils.ts +78 -0
- package/src/vendor/mermaid-ascii/ascii/pathfinder.ts +215 -0
- package/src/vendor/mermaid-ascii/ascii/sequence.ts +460 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/circle.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/corners.ts +127 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/diamond.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/hexagon.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/index.ts +101 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/rectangle.ts +175 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/rounded.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/special.ts +296 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/stadium.ts +114 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/state.ts +192 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/types.ts +73 -0
- package/src/vendor/mermaid-ascii/ascii/types.ts +273 -0
- package/src/vendor/mermaid-ascii/ascii/validate.ts +120 -0
- package/src/vendor/mermaid-ascii/ascii/xychart.ts +875 -0
- package/src/vendor/mermaid-ascii/class/parser.ts +290 -0
- package/src/vendor/mermaid-ascii/class/types.ts +121 -0
- package/src/vendor/mermaid-ascii/er/parser.ts +181 -0
- package/src/vendor/mermaid-ascii/er/types.ts +91 -0
- package/src/vendor/mermaid-ascii/index.ts +14 -0
- package/src/vendor/mermaid-ascii/multiline-utils.ts +30 -0
- package/src/vendor/mermaid-ascii/parser.ts +645 -0
- package/src/vendor/mermaid-ascii/sequence/parser.ts +207 -0
- package/src/vendor/mermaid-ascii/sequence/types.ts +146 -0
- package/src/vendor/mermaid-ascii/text-metrics.ts +71 -0
- package/src/vendor/mermaid-ascii/types.ts +164 -0
- package/src/vendor/mermaid-ascii/xychart/colors.ts +140 -0
- package/src/vendor/mermaid-ascii/xychart/parser.ts +115 -0
- package/src/vendor/mermaid-ascii/xychart/types.ts +150 -0
- package/src/which.ts +232 -0
- package/src/worker-host.ts +92 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** Parsed class diagram — logical structure from mermaid text */
|
|
2
|
+
export interface ClassDiagram {
|
|
3
|
+
/** All class definitions */
|
|
4
|
+
classes: ClassNode[];
|
|
5
|
+
/** Relationships between classes */
|
|
6
|
+
relationships: ClassRelationship[];
|
|
7
|
+
/** Optional namespace groupings */
|
|
8
|
+
namespaces: ClassNamespace[];
|
|
9
|
+
}
|
|
10
|
+
export interface ClassNode {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
/** Annotation like <<interface>>, <<abstract>>, <<service>>, <<enumeration>> */
|
|
14
|
+
annotation?: string;
|
|
15
|
+
/** Class attributes (fields/properties) */
|
|
16
|
+
attributes: ClassMember[];
|
|
17
|
+
/** Class methods (functions) */
|
|
18
|
+
methods: ClassMember[];
|
|
19
|
+
}
|
|
20
|
+
export interface ClassMember {
|
|
21
|
+
/** Visibility: + public, - private, # protected, ~ package */
|
|
22
|
+
visibility: '+' | '-' | '#' | '~' | '';
|
|
23
|
+
/** Member name */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Type annotation (e.g., "String", "int", "void") */
|
|
26
|
+
type?: string;
|
|
27
|
+
/** Whether the member is static (underlined in UML) */
|
|
28
|
+
isStatic?: boolean;
|
|
29
|
+
/** Whether the member is abstract (italic in UML) */
|
|
30
|
+
isAbstract?: boolean;
|
|
31
|
+
/** Whether the member is a method (renders with parentheses) */
|
|
32
|
+
isMethod?: boolean;
|
|
33
|
+
/** Method parameters (e.g., "data", "key, val") — only for methods */
|
|
34
|
+
params?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Relationship types following UML conventions */
|
|
37
|
+
export type RelationshipType = 'inheritance' | 'composition' | 'aggregation' | 'association' | 'dependency' | 'realization';
|
|
38
|
+
export interface ClassRelationship {
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
type: RelationshipType;
|
|
42
|
+
/**
|
|
43
|
+
* Which end of the relationship line has the UML marker (triangle, diamond, arrow).
|
|
44
|
+
* Determined by the arrow syntax direction:
|
|
45
|
+
* - Prefix markers like `<|--`, `*--`, `o--` → 'from' (marker on left/from side)
|
|
46
|
+
* - Suffix markers like `..|>`, `-->`, `..>`, `--*`, `--o` → 'to' (marker on right/to side)
|
|
47
|
+
*/
|
|
48
|
+
markerAt: 'from' | 'to';
|
|
49
|
+
/** Label on the relationship line */
|
|
50
|
+
label?: string;
|
|
51
|
+
/** Cardinality at the "from" end (e.g., "1", "*", "0..1") */
|
|
52
|
+
fromCardinality?: string;
|
|
53
|
+
/** Cardinality at the "to" end */
|
|
54
|
+
toCardinality?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ClassNamespace {
|
|
57
|
+
name: string;
|
|
58
|
+
classIds: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface PositionedClassDiagram {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
classes: PositionedClassNode[];
|
|
64
|
+
relationships: PositionedClassRelationship[];
|
|
65
|
+
}
|
|
66
|
+
export interface PositionedClassNode {
|
|
67
|
+
id: string;
|
|
68
|
+
label: string;
|
|
69
|
+
annotation?: string;
|
|
70
|
+
attributes: ClassMember[];
|
|
71
|
+
methods: ClassMember[];
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
/** Height of the header section (name + annotation) */
|
|
77
|
+
headerHeight: number;
|
|
78
|
+
/** Height of the attributes section */
|
|
79
|
+
attrHeight: number;
|
|
80
|
+
/** Height of the methods section */
|
|
81
|
+
methodHeight: number;
|
|
82
|
+
}
|
|
83
|
+
export interface PositionedClassRelationship {
|
|
84
|
+
from: string;
|
|
85
|
+
to: string;
|
|
86
|
+
type: RelationshipType;
|
|
87
|
+
/** Which end of the line has the UML marker — propagated from ClassRelationship */
|
|
88
|
+
markerAt: 'from' | 'to';
|
|
89
|
+
label?: string;
|
|
90
|
+
fromCardinality?: string;
|
|
91
|
+
toCardinality?: string;
|
|
92
|
+
/** Path points from source to target */
|
|
93
|
+
points: Array<{
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
}>;
|
|
97
|
+
/** Dagre-computed label center position (avoids overlaps between nearby edges) */
|
|
98
|
+
labelPosition?: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Parsed ER diagram — logical structure from mermaid text */
|
|
2
|
+
export interface ErDiagram {
|
|
3
|
+
/** All entity definitions */
|
|
4
|
+
entities: ErEntity[];
|
|
5
|
+
/** Relationships between entities */
|
|
6
|
+
relationships: ErRelationship[];
|
|
7
|
+
}
|
|
8
|
+
export interface ErEntity {
|
|
9
|
+
id: string;
|
|
10
|
+
/** Display name (same as id unless aliased) */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Entity attributes (columns) */
|
|
13
|
+
attributes: ErAttribute[];
|
|
14
|
+
}
|
|
15
|
+
export interface ErAttribute {
|
|
16
|
+
/** Data type (string, int, varchar, etc.) */
|
|
17
|
+
type: string;
|
|
18
|
+
/** Attribute name */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Key constraints: PK, FK, UK */
|
|
21
|
+
keys: Array<'PK' | 'FK' | 'UK'>;
|
|
22
|
+
/** Optional comment */
|
|
23
|
+
comment?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cardinality notation (crow's foot):
|
|
27
|
+
* 'one' || exactly one
|
|
28
|
+
* 'zero-one' |o zero or one
|
|
29
|
+
* 'many' }| one or more
|
|
30
|
+
* 'zero-many' o{ zero or more
|
|
31
|
+
*/
|
|
32
|
+
export type Cardinality = 'one' | 'zero-one' | 'many' | 'zero-many';
|
|
33
|
+
export interface ErRelationship {
|
|
34
|
+
entity1: string;
|
|
35
|
+
entity2: string;
|
|
36
|
+
/** Cardinality at entity1's end */
|
|
37
|
+
cardinality1: Cardinality;
|
|
38
|
+
/** Cardinality at entity2's end */
|
|
39
|
+
cardinality2: Cardinality;
|
|
40
|
+
/** Relationship verb/label (e.g., "places", "contains") */
|
|
41
|
+
label: string;
|
|
42
|
+
/** Whether the relationship is identifying (solid line) or non-identifying (dashed) */
|
|
43
|
+
identifying: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface PositionedErDiagram {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
entities: PositionedErEntity[];
|
|
49
|
+
relationships: PositionedErRelationship[];
|
|
50
|
+
}
|
|
51
|
+
export interface PositionedErEntity {
|
|
52
|
+
id: string;
|
|
53
|
+
label: string;
|
|
54
|
+
attributes: ErAttribute[];
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
/** Height of the header row */
|
|
60
|
+
headerHeight: number;
|
|
61
|
+
/** Height per attribute row */
|
|
62
|
+
rowHeight: number;
|
|
63
|
+
}
|
|
64
|
+
export interface PositionedErRelationship {
|
|
65
|
+
entity1: string;
|
|
66
|
+
entity2: string;
|
|
67
|
+
cardinality1: Cardinality;
|
|
68
|
+
cardinality2: Cardinality;
|
|
69
|
+
label: string;
|
|
70
|
+
identifying: boolean;
|
|
71
|
+
/** Path points from entity1 to entity2 */
|
|
72
|
+
points: Array<{
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ascii/index';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize label text for terminal ASCII output: strip surrounding quotes,
|
|
3
|
+
* convert <br> tags and literal newline escapes to newlines, and reduce
|
|
4
|
+
* inline formatting (HTML bold/italic/underline/strike tags and the markdown
|
|
5
|
+
* bold, italic, and strikethrough markers) to plain text. The ASCII renderer
|
|
6
|
+
* has no styled spans, so preserving the markup would print raw tags and
|
|
7
|
+
* markers inside node boxes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeBrTags(label: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MermaidGraph } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse Mermaid text into a logical graph structure.
|
|
4
|
+
* Auto-detects diagram type (flowchart or state diagram).
|
|
5
|
+
* Throws on invalid/unsupported input.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseMermaid(text: string): MermaidGraph;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/** Parsed sequence diagram — logical structure from mermaid text */
|
|
2
|
+
export interface SequenceDiagram {
|
|
3
|
+
/** Ordered list of actors/participants */
|
|
4
|
+
actors: Actor[];
|
|
5
|
+
/** Messages between actors in chronological order */
|
|
6
|
+
messages: Message[];
|
|
7
|
+
/** Structural blocks (loop, alt, opt, par, critical) */
|
|
8
|
+
blocks: Block[];
|
|
9
|
+
/** Notes attached to actors */
|
|
10
|
+
notes: Note[];
|
|
11
|
+
}
|
|
12
|
+
export interface Actor {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
/** 'participant' renders as a box, 'actor' renders as a stick figure */
|
|
16
|
+
type: 'participant' | 'actor';
|
|
17
|
+
}
|
|
18
|
+
export interface Message {
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
label: string;
|
|
22
|
+
/** Arrow style: solid line or dashed line */
|
|
23
|
+
lineStyle: 'solid' | 'dashed';
|
|
24
|
+
/** Arrow head: filled (closed) or open */
|
|
25
|
+
arrowHead: 'filled' | 'open';
|
|
26
|
+
/** Activate the target lifeline (+) */
|
|
27
|
+
activate?: boolean;
|
|
28
|
+
/** Deactivate the source lifeline (-) */
|
|
29
|
+
deactivate?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface Block {
|
|
32
|
+
/** Block type keyword */
|
|
33
|
+
type: 'loop' | 'alt' | 'opt' | 'par' | 'critical' | 'break' | 'rect';
|
|
34
|
+
/** Label for the block header */
|
|
35
|
+
label: string;
|
|
36
|
+
/** Index of the first message inside this block */
|
|
37
|
+
startIndex: number;
|
|
38
|
+
/** Index of the last message inside this block (inclusive) */
|
|
39
|
+
endIndex: number;
|
|
40
|
+
/** For alt/par blocks: indices where "else"/"and" dividers appear (message indices) */
|
|
41
|
+
dividers: Array<{
|
|
42
|
+
index: number;
|
|
43
|
+
label: string;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export interface Note {
|
|
47
|
+
/** Which actor(s) the note is attached to */
|
|
48
|
+
actorIds: string[];
|
|
49
|
+
/** Note text content */
|
|
50
|
+
text: string;
|
|
51
|
+
/** Position relative to the actor(s) */
|
|
52
|
+
position: 'left' | 'right' | 'over';
|
|
53
|
+
/** Message index after which this note appears */
|
|
54
|
+
afterIndex: number;
|
|
55
|
+
}
|
|
56
|
+
export interface PositionedSequenceDiagram {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
actors: PositionedActor[];
|
|
60
|
+
lifelines: Lifeline[];
|
|
61
|
+
messages: PositionedMessage[];
|
|
62
|
+
activations: Activation[];
|
|
63
|
+
blocks: PositionedBlock[];
|
|
64
|
+
notes: PositionedNote[];
|
|
65
|
+
}
|
|
66
|
+
export interface PositionedActor {
|
|
67
|
+
id: string;
|
|
68
|
+
label: string;
|
|
69
|
+
type: 'participant' | 'actor';
|
|
70
|
+
/** Center x of the actor box */
|
|
71
|
+
x: number;
|
|
72
|
+
/** Top y of the actor box */
|
|
73
|
+
y: number;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
}
|
|
77
|
+
/** Vertical dashed line from actor to bottom of diagram */
|
|
78
|
+
export interface Lifeline {
|
|
79
|
+
actorId: string;
|
|
80
|
+
x: number;
|
|
81
|
+
topY: number;
|
|
82
|
+
bottomY: number;
|
|
83
|
+
}
|
|
84
|
+
export interface PositionedMessage {
|
|
85
|
+
from: string;
|
|
86
|
+
to: string;
|
|
87
|
+
label: string;
|
|
88
|
+
lineStyle: 'solid' | 'dashed';
|
|
89
|
+
arrowHead: 'filled' | 'open';
|
|
90
|
+
/** Start point (from actor's lifeline) */
|
|
91
|
+
x1: number;
|
|
92
|
+
/** End point (to actor's lifeline) */
|
|
93
|
+
x2: number;
|
|
94
|
+
/** Vertical position */
|
|
95
|
+
y: number;
|
|
96
|
+
/** Whether this is a self-message (same actor) */
|
|
97
|
+
isSelf: boolean;
|
|
98
|
+
}
|
|
99
|
+
/** Narrow rectangle on a lifeline showing active processing */
|
|
100
|
+
export interface Activation {
|
|
101
|
+
actorId: string;
|
|
102
|
+
x: number;
|
|
103
|
+
topY: number;
|
|
104
|
+
bottomY: number;
|
|
105
|
+
width: number;
|
|
106
|
+
}
|
|
107
|
+
export interface PositionedBlock {
|
|
108
|
+
type: Block['type'];
|
|
109
|
+
label: string;
|
|
110
|
+
x: number;
|
|
111
|
+
y: number;
|
|
112
|
+
width: number;
|
|
113
|
+
height: number;
|
|
114
|
+
/** Divider lines within the block (for alt/par) */
|
|
115
|
+
dividers: Array<{
|
|
116
|
+
y: number;
|
|
117
|
+
label: string;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
export interface PositionedNote {
|
|
121
|
+
text: string;
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
/** Actor IDs this note is attached to (for SVG attribution) */
|
|
127
|
+
actors?: string[];
|
|
128
|
+
/** Note position relative to actors (for SVG attribution) */
|
|
129
|
+
position?: 'left' | 'right' | 'over';
|
|
130
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder occupying the second cell of a fullwidth glyph on the ASCII
|
|
3
|
+
* canvas. U+0000 cannot appear in parsed Mermaid labels, is treated as
|
|
4
|
+
* occupied label content by canvas merging, and is stripped at
|
|
5
|
+
* serialization time. Invariant: a WIDE_PAD cell always sits immediately
|
|
6
|
+
* right of its lead cell; canvas writes keep the pair atomic.
|
|
7
|
+
*/
|
|
8
|
+
export declare const WIDE_PAD = "\0";
|
|
9
|
+
/**
|
|
10
|
+
* Display width of a string in terminal columns, summed over grapheme
|
|
11
|
+
* clusters so it always equals `toCells(text).length`. ASCII-only strings
|
|
12
|
+
* take a fast path.
|
|
13
|
+
*/
|
|
14
|
+
export declare function displayWidth(text: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Expand a string into ASCII-canvas cells: each 2-column grapheme cluster
|
|
17
|
+
* is stored whole in one cell and followed by WIDE_PAD, so that
|
|
18
|
+
* `cells.length === displayWidth(text)`. Per-character placement loops can
|
|
19
|
+
* iterate the result with plain cell offsets.
|
|
20
|
+
*/
|
|
21
|
+
export declare function toCells(text: string): string[];
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export interface MermaidGraph {
|
|
2
|
+
direction: Direction;
|
|
3
|
+
nodes: Map<string, MermaidNode>;
|
|
4
|
+
edges: MermaidEdge[];
|
|
5
|
+
subgraphs: MermaidSubgraph[];
|
|
6
|
+
classDefs: Map<string, Record<string, string>>;
|
|
7
|
+
/** Maps node IDs to their class names (from `class X className` or `:::className` shorthand) */
|
|
8
|
+
classAssignments: Map<string, string>;
|
|
9
|
+
/** Maps node IDs to inline styles (from `style X fill:#f00,stroke:#333`) */
|
|
10
|
+
nodeStyles: Map<string, Record<string, string>>;
|
|
11
|
+
/** Maps edge indices (or 'default') to inline styles from `linkStyle` directives */
|
|
12
|
+
linkStyles: Map<number | 'default', Record<string, string>>;
|
|
13
|
+
}
|
|
14
|
+
export type Direction = 'TD' | 'TB' | 'LR' | 'BT' | 'RL';
|
|
15
|
+
export interface MermaidNode {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
shape: NodeShape;
|
|
19
|
+
}
|
|
20
|
+
export type NodeShape = 'rectangle' | 'rounded' | 'diamond' | 'stadium' | 'circle' | 'subroutine' | 'doublecircle' | 'hexagon' | 'cylinder' | 'asymmetric' | 'trapezoid' | 'trapezoid-alt' | 'state-start' | 'state-end';
|
|
21
|
+
export interface MermaidEdge {
|
|
22
|
+
source: string;
|
|
23
|
+
target: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
style: EdgeStyle;
|
|
26
|
+
/** Whether to render an arrowhead at the start (source end) of the edge */
|
|
27
|
+
hasArrowStart: boolean;
|
|
28
|
+
/** Whether to render an arrowhead at the end (target end) of the edge */
|
|
29
|
+
hasArrowEnd: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type EdgeStyle = 'solid' | 'dotted' | 'thick';
|
|
32
|
+
export interface MermaidSubgraph {
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
nodeIds: string[];
|
|
36
|
+
children: MermaidSubgraph[];
|
|
37
|
+
/** Optional direction override for this subgraph's internal layout */
|
|
38
|
+
direction?: Direction;
|
|
39
|
+
}
|
|
40
|
+
export interface PositionedGraph {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
nodes: PositionedNode[];
|
|
44
|
+
edges: PositionedEdge[];
|
|
45
|
+
groups: PositionedGroup[];
|
|
46
|
+
}
|
|
47
|
+
export interface PositionedNode {
|
|
48
|
+
id: string;
|
|
49
|
+
label: string;
|
|
50
|
+
shape: NodeShape;
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
/** Inline styles resolved from classDef + explicit `style` statements — override theme defaults */
|
|
56
|
+
inlineStyle?: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
export interface PositionedEdge {
|
|
59
|
+
source: string;
|
|
60
|
+
target: string;
|
|
61
|
+
label?: string;
|
|
62
|
+
style: EdgeStyle;
|
|
63
|
+
hasArrowStart: boolean;
|
|
64
|
+
hasArrowEnd: boolean;
|
|
65
|
+
/** Full path including bends — array of {x, y} points */
|
|
66
|
+
points: Point[];
|
|
67
|
+
/** Layout-computed label center position (avoids label-label collisions) */
|
|
68
|
+
labelPosition?: Point;
|
|
69
|
+
/** Inline styles resolved from `linkStyle` directives — override theme defaults */
|
|
70
|
+
inlineStyle?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
export interface Point {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
}
|
|
76
|
+
export interface PositionedGroup {
|
|
77
|
+
id: string;
|
|
78
|
+
label: string;
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
children: PositionedGroup[];
|
|
84
|
+
}
|
|
85
|
+
export interface RenderOptions {
|
|
86
|
+
/** Background color → CSS variable --bg. Default: '#FFFFFF' */
|
|
87
|
+
bg?: string;
|
|
88
|
+
/** Foreground / primary text color → CSS variable --fg. Default: '#27272A' */
|
|
89
|
+
fg?: string;
|
|
90
|
+
/** Edge/connector color → CSS variable --line */
|
|
91
|
+
line?: string;
|
|
92
|
+
/** Arrow heads, highlights → CSS variable --accent */
|
|
93
|
+
accent?: string;
|
|
94
|
+
/** Secondary text, edge labels → CSS variable --muted */
|
|
95
|
+
muted?: string;
|
|
96
|
+
/** Node/box fill tint → CSS variable --surface */
|
|
97
|
+
surface?: string;
|
|
98
|
+
/** Node/group stroke color → CSS variable --border */
|
|
99
|
+
border?: string;
|
|
100
|
+
/** Font family for all text. Default: 'Inter' */
|
|
101
|
+
font?: string;
|
|
102
|
+
/** Canvas padding in px. Default: 40 */
|
|
103
|
+
padding?: number;
|
|
104
|
+
/** Horizontal spacing between sibling nodes. Default: 24 */
|
|
105
|
+
nodeSpacing?: number;
|
|
106
|
+
/** Vertical spacing between layers. Default: 40 */
|
|
107
|
+
layerSpacing?: number;
|
|
108
|
+
/** Spacing between disconnected components. Default: nodeSpacing (24) */
|
|
109
|
+
componentSpacing?: number;
|
|
110
|
+
/** Render with transparent background (no background style on SVG). Default: false */
|
|
111
|
+
transparent?: boolean;
|
|
112
|
+
/** Enable hover tooltips on chart data points (xychart only). Default: false */
|
|
113
|
+
interactive?: boolean;
|
|
114
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Default accent for charts when the theme doesn't provide one. */
|
|
2
|
+
export declare const CHART_ACCENT_FALLBACK = "#3b82f6";
|
|
3
|
+
/** Check whether a string is a valid 6-digit hex color (e.g. "#3b82f6"). */
|
|
4
|
+
export declare function isValidHex(color: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Detect whether a background color is dark (lightness < 50%).
|
|
7
|
+
*/
|
|
8
|
+
export declare function isDarkBackground(bgHex: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Mix two hex colors in RGB space.
|
|
11
|
+
* `ratio` controls how much of `fgHex` shows: 0 = pure bg, 1 = pure fg.
|
|
12
|
+
* Equivalent to alpha-compositing fg over bg at the given opacity.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mixHexColors(bgHex: string, fgHex: string, ratio: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get the hex color for a series index.
|
|
17
|
+
* Index 0 returns the accent color as-is.
|
|
18
|
+
* Index 1+ alternate between darker and lighter shades of the same hue
|
|
19
|
+
* with subtle hue drift (±8-12° per tier) to stay in the same family.
|
|
20
|
+
*
|
|
21
|
+
* When `bgColor` is provided, shade direction adapts to the background:
|
|
22
|
+
* - Light bg: odd = darker, even = lighter (default)
|
|
23
|
+
* - Dark bg: odd = lighter, even = darker (so shades stay visible)
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSeriesColor(index: number, accentColor: string, bgColor?: string): string;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** Parsed XY chart — logical structure from mermaid text */
|
|
2
|
+
export interface XYChart {
|
|
3
|
+
/** Optional chart title */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Chart orientation: vertical (default) or horizontal */
|
|
6
|
+
horizontal: boolean;
|
|
7
|
+
/** X-axis configuration */
|
|
8
|
+
xAxis: XYAxis;
|
|
9
|
+
/** Y-axis configuration */
|
|
10
|
+
yAxis: XYAxis;
|
|
11
|
+
/** Data series (bar and/or line) */
|
|
12
|
+
series: XYChartSeries[];
|
|
13
|
+
}
|
|
14
|
+
/** Axis configuration — categorical (labels) or numeric (range) */
|
|
15
|
+
export interface XYAxis {
|
|
16
|
+
/** Optional axis title/label */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Categorical labels (e.g., ["jan", "feb", "mar"]) — mutually exclusive with range */
|
|
19
|
+
categories?: string[];
|
|
20
|
+
/** Numeric range — mutually exclusive with categories */
|
|
21
|
+
range?: {
|
|
22
|
+
min: number;
|
|
23
|
+
max: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** A single data series (bar or line) */
|
|
27
|
+
export interface XYChartSeries {
|
|
28
|
+
/** Series type */
|
|
29
|
+
type: 'bar' | 'line';
|
|
30
|
+
/** Data values — one per category, or evenly spaced across numeric range */
|
|
31
|
+
data: number[];
|
|
32
|
+
}
|
|
33
|
+
export interface PositionedXYChart {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
/** Whether this is a horizontal (rotated) chart */
|
|
37
|
+
horizontal?: boolean;
|
|
38
|
+
/** Title text and position (if present) */
|
|
39
|
+
title?: PositionedTitle;
|
|
40
|
+
/** Positioned x-axis with tick marks and labels */
|
|
41
|
+
xAxis: PositionedAxis;
|
|
42
|
+
/** Positioned y-axis with tick marks and labels */
|
|
43
|
+
yAxis: PositionedAxis;
|
|
44
|
+
/** The plot area bounds (inside axes) */
|
|
45
|
+
plotArea: PlotArea;
|
|
46
|
+
/** Positioned bar groups */
|
|
47
|
+
bars: PositionedBar[];
|
|
48
|
+
/** Positioned line polylines */
|
|
49
|
+
lines: PositionedLine[];
|
|
50
|
+
/** Horizontal grid lines for readability */
|
|
51
|
+
gridLines: GridLine[];
|
|
52
|
+
/** Legend items (shown when multiple series) */
|
|
53
|
+
legend: LegendItem[];
|
|
54
|
+
}
|
|
55
|
+
export interface LegendItem {
|
|
56
|
+
/** Display label */
|
|
57
|
+
label: string;
|
|
58
|
+
/** Position of the swatch/icon */
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
/** Series type determines swatch shape (rect for bar, line+dot for line) */
|
|
62
|
+
type: 'bar' | 'line';
|
|
63
|
+
/** Series index within its type (for layout grouping) */
|
|
64
|
+
seriesIndex: number;
|
|
65
|
+
/** Global color index across all series (for unified color assignment) */
|
|
66
|
+
colorIndex: number;
|
|
67
|
+
}
|
|
68
|
+
export interface PositionedTitle {
|
|
69
|
+
text: string;
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
}
|
|
73
|
+
export interface PositionedAxis {
|
|
74
|
+
/** Optional axis title text and position */
|
|
75
|
+
title?: {
|
|
76
|
+
text: string;
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
rotate?: number;
|
|
80
|
+
};
|
|
81
|
+
/** Tick positions along the axis */
|
|
82
|
+
ticks: AxisTick[];
|
|
83
|
+
/** Axis line: start and end coordinates */
|
|
84
|
+
line: {
|
|
85
|
+
x1: number;
|
|
86
|
+
y1: number;
|
|
87
|
+
x2: number;
|
|
88
|
+
y2: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface AxisTick {
|
|
92
|
+
/** Label text for this tick */
|
|
93
|
+
label: string;
|
|
94
|
+
/** Position of the tick mark on the axis */
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
/** End of the tick mark (short perpendicular line) */
|
|
98
|
+
tx: number;
|
|
99
|
+
ty: number;
|
|
100
|
+
/** Label anchor position */
|
|
101
|
+
labelX: number;
|
|
102
|
+
labelY: number;
|
|
103
|
+
/** Text anchor for label */
|
|
104
|
+
textAnchor: 'start' | 'middle' | 'end';
|
|
105
|
+
}
|
|
106
|
+
export interface PlotArea {
|
|
107
|
+
x: number;
|
|
108
|
+
y: number;
|
|
109
|
+
width: number;
|
|
110
|
+
height: number;
|
|
111
|
+
}
|
|
112
|
+
export interface PositionedBar {
|
|
113
|
+
/** Bar rectangle in SVG coordinates */
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
width: number;
|
|
117
|
+
height: number;
|
|
118
|
+
/** Original data value */
|
|
119
|
+
value: number;
|
|
120
|
+
/** Category label for this bar (e.g. "Jan") */
|
|
121
|
+
label?: string;
|
|
122
|
+
/** Series index within bar type (for layout grouping) */
|
|
123
|
+
seriesIndex: number;
|
|
124
|
+
/** Global color index across all series */
|
|
125
|
+
colorIndex: number;
|
|
126
|
+
}
|
|
127
|
+
export interface PositionedLine {
|
|
128
|
+
/** Polyline points */
|
|
129
|
+
points: Array<{
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
value: number;
|
|
133
|
+
label?: string;
|
|
134
|
+
}>;
|
|
135
|
+
/** Series index within line type (for layout grouping) */
|
|
136
|
+
seriesIndex: number;
|
|
137
|
+
/** Global color index across all series */
|
|
138
|
+
colorIndex: number;
|
|
139
|
+
}
|
|
140
|
+
export interface GridLine {
|
|
141
|
+
x1: number;
|
|
142
|
+
y1: number;
|
|
143
|
+
x2: number;
|
|
144
|
+
y2: number;
|
|
145
|
+
}
|